|
@@ -8,6 +8,7 @@ import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.transaction.Transactional;
|
|
@@ -42,6 +43,7 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
protected SecurityMgr securityMgr;
|
|
|
@Autowired
|
|
|
private AccessoryDao accessoryDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private HttpServletRequest request;
|
|
|
|
|
@@ -60,9 +62,9 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
@Transactional
|
|
|
public AccessoryEntity saveFile(MultipartFile file, String sstype) {
|
|
|
// UserEntity user = securityMgr.getCurrUser();
|
|
|
- if (file.getSize() > GlobalData.UPLOAD_FILE_SIZE * 1024 * 1024) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ // if (file.getSize() > GlobalData.UPLOAD_FILE_SIZE * 1024 * 1024) {
|
|
|
+ // return null;
|
|
|
+ // }
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
String suffix = "";
|
|
|
int index = fileName.lastIndexOf('.');
|
|
@@ -100,9 +102,9 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
f.setPwd(GlobalData.FTP_QT_USER);
|
|
|
f.setPath("");
|
|
|
if (FtpUtil.connectFtp(f)) {
|
|
|
- String ftpPath = GlobalData.UPLOAD_FILE_PATH +File.separator + sstype ;
|
|
|
+ String ftpPath = GlobalData.UPLOAD_FILE_PATH + File.separator + sstype;
|
|
|
FtpUtil.makeDirFile(ftpPath);
|
|
|
- ftpPath = ftpPath +File.separator + GlobalData.CITY_CODE + File.separator;
|
|
|
+ ftpPath = ftpPath + File.separator + GlobalData.CITY_CODE + File.separator;
|
|
|
FtpUtil.makeDirFile(ftpPath);
|
|
|
File ftpFile = new File(ftpPath + filename);
|
|
|
if (ftpFile != null) {
|
|
@@ -231,7 +233,7 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
AccessoryEntity entity = this.findOne(id);
|
|
|
AccessoryEntity nacc = new AccessoryEntity();
|
|
|
if (!StringUtils.isEmpty(entity)) {
|
|
|
- File file = new File(entity.getFilepath() + entity.getFilename());
|
|
|
+ File file = new File(GlobalData.UPLOAD_FILE_PATH + entity.getFilepath() + entity.getFilename());
|
|
|
SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
Date today = new Date();
|
|
|
String filename = dateTimeFormat.format(today) + "." + entity.getSuffix();
|
|
@@ -247,7 +249,7 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
}
|
|
|
try {
|
|
|
inStream = new FileInputStream(file);
|
|
|
- fs = new FileOutputStream(newurl + filename);
|
|
|
+ fs = new FileOutputStream(GlobalData.UPLOAD_FILE_PATH +newurl + filename);
|
|
|
byte[] buffer = new byte[1024 * 1024];
|
|
|
int len;
|
|
|
while ((len = inStream.read(buffer)) != -1) {
|
|
@@ -258,7 +260,7 @@ public class AccessoryServiceImpl extends JyglBaseService<AccessoryEntity, Strin
|
|
|
nacc.setId(null);
|
|
|
nacc.setFilename(filename);
|
|
|
nacc.setFilepath(newurl);
|
|
|
- nacc = this.save(nacc);
|
|
|
+ nacc = save(nacc);
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|