代码版本回退
parent
f3b7639fcf
commit
1ad76f6a87
|
@ -81,92 +81,91 @@ public class ImgFilesController extends BaseController {
|
|||
public Object finish(
|
||||
@RequestParam(value="FFILE",required=false) MultipartFile[] files,
|
||||
@RequestParam(value="TYPE",required=false) String TYPE,
|
||||
@RequestParam(value="FOREIGN_KEY",required=false) String FOREIGN_KEY,
|
||||
@RequestParam(value="temporaryFilePath",required=false) String[] temporaryFilePath
|
||||
@RequestParam(value="FOREIGN_KEY",required=false) String FOREIGN_KEY
|
||||
) throws Exception{
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
System.out.println("+++++++++++++++"+files);
|
||||
System.out.println("==================="+temporaryFilePath);
|
||||
// System.out.println("==================="+temporaryFilePath);
|
||||
String errInfo = "success";
|
||||
if (temporaryFilePath != null && temporaryFilePath.length > 0) {
|
||||
for (int i = 0; i < temporaryFilePath.length; i++) {
|
||||
String suffixName = temporaryFilePath[i].substring(temporaryFilePath[i].lastIndexOf(".")+1).toLowerCase();
|
||||
if (!"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
||||
errInfo = "fail";
|
||||
map.put("result", errInfo);
|
||||
map.put("msg", "文件格式不正确!");
|
||||
return map;
|
||||
}
|
||||
if(TYPE.equals("2")) {//先删除原四色图
|
||||
PageData pd2 = new PageData();
|
||||
pd2.put("FOREIGN_KEY",FOREIGN_KEY);
|
||||
pd2.put("TYPE",TYPE);
|
||||
List<PageData> four = imgfilesService.listAll(pd2);
|
||||
for (PageData pageData : four) {
|
||||
File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH"));
|
||||
old.delete();
|
||||
imgfilesService.delete(pageData);
|
||||
}
|
||||
}
|
||||
|
||||
// String productPath = FileUploadUtil.copyTemporaryFileToProduct(temporaryFilePath[i]);
|
||||
PageData pd = new PageData();
|
||||
pd.put("IMGFILES_ID", this.get32UUID());
|
||||
pd.put("FILEPATH", temporaryFilePath[i]);
|
||||
pd.put("TYPE", TYPE);
|
||||
pd.put("FOREIGN_KEY", FOREIGN_KEY);
|
||||
imgfilesService.save(pd);
|
||||
}
|
||||
}
|
||||
// if (files != null && files.length > 0) {
|
||||
// for (int i = 0; i < files.length; i++) {
|
||||
// String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
||||
// if (temporaryFilePath != null && temporaryFilePath.length > 0) {
|
||||
// for (int i = 0; i < temporaryFilePath.length; i++) {
|
||||
// String suffixName = temporaryFilePath[i].substring(temporaryFilePath[i].lastIndexOf(".")+1).toLowerCase();
|
||||
// if (!"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
||||
// errInfo = "fail";
|
||||
// map.put("result", errInfo);
|
||||
// map.put("msg", "文件格式不正确!");
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < files.length; i++) {
|
||||
// MultipartFile file = files[i];
|
||||
//// 保存文件
|
||||
// File tempFile = new File(file.getOriginalFilename());
|
||||
// FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
|
||||
// if(!FileUpload.isImage(tempFile) && !TYPE.equals("2")) {//四色图改为json文件,不用判断类型
|
||||
// tempFile.delete();
|
||||
// map.put("result", "failed");
|
||||
// map.put("exception", "上传图片格式不正确,请重新上传");
|
||||
// return map;
|
||||
// }
|
||||
// if (tempFile.exists()) {
|
||||
// tempFile.delete();
|
||||
// if(TYPE.equals("2")) {//先删除原四色图
|
||||
// PageData pd2 = new PageData();
|
||||
// pd2.put("FOREIGN_KEY",FOREIGN_KEY);
|
||||
// pd2.put("TYPE",TYPE);
|
||||
// List<PageData> four = imgfilesService.listAll(pd2);
|
||||
// for (PageData pageData : four) {
|
||||
// File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH"));
|
||||
// old.delete();
|
||||
// imgfilesService.delete(pageData);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(TYPE.equals("2")) {//先删除原四色图
|
||||
// PageData pd2 = new PageData();
|
||||
// pd2.put("FOREIGN_KEY",FOREIGN_KEY);
|
||||
// pd2.put("TYPE",TYPE);
|
||||
// List<PageData> four = imgfilesService.listAll(pd2);
|
||||
// for (PageData pageData : four) {
|
||||
// File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH"));
|
||||
// old.delete();
|
||||
// imgfilesService.delete(pageData);
|
||||
// }
|
||||
// }
|
||||
// String ffile = DateUtil.getDays();
|
||||
//// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
||||
//// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
||||
// String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
// Smb.sshSftp(file, fileName,Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
||||
// PageData pd = new PageData();
|
||||
// pd.put("IMGFILES_ID", this.get32UUID());
|
||||
// pd.put("FILEPATH", Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
||||
// pd.put("TYPE", TYPE);
|
||||
// pd.put("FOREIGN_KEY", FOREIGN_KEY);
|
||||
// imgfilesService.save(pd);
|
||||
// }
|
||||
// }
|
||||
//// String productPath = FileUploadUtil.copyTemporaryFileToProduct(temporaryFilePath[i]);
|
||||
// PageData pd = new PageData();
|
||||
// pd.put("IMGFILES_ID", this.get32UUID());
|
||||
// pd.put("FILEPATH", temporaryFilePath[i]);
|
||||
// pd.put("TYPE", TYPE);
|
||||
// pd.put("FOREIGN_KEY", FOREIGN_KEY);
|
||||
// imgfilesService.save(pd);
|
||||
// }
|
||||
// }
|
||||
if (files != null && files.length > 0) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
||||
if (!"json".equals(suffixName) && !"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
||||
errInfo = "fail";
|
||||
map.put("result", errInfo);
|
||||
map.put("msg", "文件格式不正确!");
|
||||
return map;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
// 保存文件
|
||||
File tempFile = new File(file.getOriginalFilename());
|
||||
FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
|
||||
if(!FileUpload.isImage(tempFile) && !TYPE.equals("2")) {//四色图改为json文件,不用判断类型
|
||||
tempFile.delete();
|
||||
map.put("result", "failed");
|
||||
map.put("exception", "上传图片格式不正确,请重新上传");
|
||||
return map;
|
||||
}
|
||||
if (tempFile.exists()) {
|
||||
tempFile.delete();
|
||||
}
|
||||
|
||||
if(TYPE.equals("2")) {//先删除原四色图
|
||||
PageData pd2 = new PageData();
|
||||
pd2.put("FOREIGN_KEY",FOREIGN_KEY);
|
||||
pd2.put("TYPE",TYPE);
|
||||
List<PageData> four = imgfilesService.listAll(pd2);
|
||||
for (PageData pageData : four) {
|
||||
File old = new File(PathUtil.getProjectpath()+pageData.getString("FILEPATH"));
|
||||
old.delete();
|
||||
imgfilesService.delete(pageData);
|
||||
}
|
||||
}
|
||||
String ffile = DateUtil.getDays();
|
||||
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
||||
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
||||
String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||||
Smb.sshSftp(file, fileName,Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
||||
PageData pd = new PageData();
|
||||
pd.put("IMGFILES_ID", this.get32UUID());
|
||||
pd.put("FILEPATH", Const.FILEPATHYHTP + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
||||
pd.put("TYPE", TYPE);
|
||||
pd.put("FOREIGN_KEY", FOREIGN_KEY);
|
||||
imgfilesService.save(pd);
|
||||
}
|
||||
}
|
||||
map.put("result", errInfo);
|
||||
return map;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue