|
@@ -41,6 +41,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -90,7 +91,9 @@ public class CgglServiceImpl implements CgglService {
|
|
|
|
|
|
private String Authorization = "Basic c2FiZXI6c2FiZXJfc2VjcmV0";
|
|
|
private String TenantId = "000000";
|
|
|
-
|
|
|
+ //成果包文件夹名称配置
|
|
|
+ private String folderName = "ztgh";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
private long sliceSize = 10 * 1024 * 1024;
|
|
|
|
|
|
@Override
|
|
@@ -102,16 +105,16 @@ public class CgglServiceImpl implements CgglService {
|
|
|
// return RequestResult.error("上传文件名不能大于100个字节!", false);
|
|
|
// }
|
|
|
String uuid = StringUtils.getUUID();
|
|
|
+ String filename = file.getOriginalFilename();
|
|
|
EscalationFileDTO dto = new EscalationFileDTO();
|
|
|
dto.setId(uuid);
|
|
|
- dto.setName(file.getOriginalFilename());
|
|
|
+ dto.setName(filename);
|
|
|
// dto.setStatus("0");
|
|
|
dto.setUsername(SecurityUtils.getUsername());
|
|
|
escalationFileMapper.insert(dto);
|
|
|
- long timeMillis = System.currentTimeMillis();
|
|
|
- String filename = file.getOriginalFilename();
|
|
|
- String temppath = temp + "\\" + timeMillis + "\\" + filename;
|
|
|
- String unzippath = temp + "\\" + timeMillis + "\\unzip";
|
|
|
+ String timeMillis = sdf.format(new Date());
|
|
|
+ String temppath = temp + folderName + "/" + timeMillis + "/" + filename;
|
|
|
+ String unzippath = temp + folderName + "/" + timeMillis + "";
|
|
|
File copyFile = new File(temppath);
|
|
|
System.out.println(temppath);
|
|
|
try {
|
|
@@ -135,7 +138,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
}
|
|
|
curdto.setStatus("9");
|
|
|
curdto.setPath(temppath);
|
|
|
- curdto.setUnzippath(unzippath);
|
|
|
+ curdto.setUnzippath(unzippath + "/" + StringUtils.getFileRelName(filename));
|
|
|
escalationFileMapper.update(curdto, wrapper);
|
|
|
} catch (Exception r) {
|
|
|
System.out.println("上传压缩包或者解压失败!");
|
|
@@ -174,12 +177,12 @@ public class CgglServiceImpl implements CgglService {
|
|
|
|
|
|
@Override
|
|
|
public RequestResult uploadCgInfo(EscalationDTO escalationDTO) {
|
|
|
- QueryWrapper<EscalationDTO> wrapper = new QueryWrapper<EscalationDTO>();
|
|
|
- wrapper.eq("name", escalationDTO.getName());
|
|
|
- EscalationDTO res = escalationMapper.selectOne(wrapper);
|
|
|
- if (res != null) {
|
|
|
- //return RequestResult.error("该名称已存在!", false);
|
|
|
- }
|
|
|
+// QueryWrapper<EscalationDTO> wrapper = new QueryWrapper<EscalationDTO>();
|
|
|
+// wrapper.eq("name", escalationDTO.getName());
|
|
|
+// EscalationDTO res = escalationMapper.selectOne(wrapper);
|
|
|
+// if (res != null) {
|
|
|
+// return RequestResult.error("该名称已存在!", false);
|
|
|
+// }
|
|
|
// if (escalationDTO.getName().getBytes().length > 100) {
|
|
|
// return RequestResult.error("成果名称不能大于100个字节!", false);
|
|
|
// }
|
|
@@ -532,17 +535,19 @@ public class CgglServiceImpl implements CgglService {
|
|
|
QueryWrapper<EscalationFileDTO> filewrapper = new QueryWrapper<EscalationFileDTO>();
|
|
|
filewrapper.eq("id", fileid);
|
|
|
EscalationFileDTO fileDto = escalationFileMapper.selectOne(filewrapper);
|
|
|
- String filepath = fileDto.getPath();
|
|
|
- //删除文件夹
|
|
|
- try {
|
|
|
- File file = new File(filepath);
|
|
|
- File parentDir = file.getParentFile();
|
|
|
+ if (fileDto != null) {
|
|
|
+ String filepath = fileDto.getPath();
|
|
|
+ //删除文件夹
|
|
|
+ try {
|
|
|
+ File file = new File(filepath);
|
|
|
+ File parentDir = file.getParentFile();
|
|
|
// String parentDirPath = parentDir.getAbsolutePath();
|
|
|
- FileUtils.deleteDirectory(parentDir);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ FileUtils.deleteDirectory(parentDir);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ escalationFileMapper.delete(filewrapper);
|
|
|
}
|
|
|
- escalationFileMapper.delete(filewrapper);
|
|
|
}
|
|
|
escalationMapper.delete(wrapper);
|
|
|
return RequestResult.success("删除成功!", true);
|
|
@@ -572,7 +577,9 @@ public class CgglServiceImpl implements CgglService {
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
return RequestResult.error("参数为传递", false);
|
|
|
}
|
|
|
- List<EscalationDTO> res = escalationRzMapper.getStatus(id);
|
|
|
+ List<EscalationRzDTO> res = escalationRzMapper.getStatus(id);
|
|
|
+ res.sort(Comparator.comparing(m -> sdf.format(m.getOperatetime())));
|
|
|
+ Collections.reverse(res);
|
|
|
return RequestResult.success("查询成功!", res);
|
|
|
}
|
|
|
|