|
@@ -45,6 +45,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.*;
|
|
|
|
|
|
|
|
@@ -71,7 +72,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
@Value("${Cggl.temp}")
|
|
|
private static String platform;
|
|
|
@Value("${Cggl.temp}")
|
|
|
- private static String temp;
|
|
|
+ private String temp;
|
|
|
@Value("${Cggl.appid}")
|
|
|
private String appid;
|
|
|
@Value("${Cggl.oauthUrl}")
|
|
@@ -97,7 +98,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;
|
|
|
|
|
|
//规划成果上传
|
|
@@ -112,14 +115,14 @@ public class CgglServiceImpl implements CgglService {
|
|
|
String uuid = StringUtils.getUUID();
|
|
|
EscalationFileDTO dto = new EscalationFileDTO();
|
|
|
dto.setId(uuid);
|
|
|
- dto.setName(file.getOriginalFilename());
|
|
|
+ String filename = 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 {
|
|
@@ -143,7 +146,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
//TODO wanger 总体规划跳过机器审查,原始赋值是9(待审查),现在改为1(审查结束)
|
|
|
curdto.setStatus("9");
|
|
|
curdto.setPath(temppath);
|
|
|
- curdto.setUnzippath(unzippath);
|
|
|
+ curdto.setUnzippath(unzippath + "/" + StringUtils.getFileRelName(filename));
|
|
|
escalationFileMapper.update(curdto, wrapper);
|
|
|
} catch (Exception r) {
|
|
|
r.printStackTrace();
|
|
@@ -181,12 +184,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) {
|
|
|
+// 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);
|
|
|
// }
|
|
@@ -573,17 +576,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);
|
|
@@ -613,7 +618,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);
|
|
|
}
|
|
|
|
|
@@ -656,7 +663,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
//TODO 整理成果包树状结构
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
List<EscalationFolderDTO> datas = new ArrayList<>();
|
|
|
- findFolder(new File(fileDir), map, datas);
|
|
|
+ findFolder(new File(fileDir), map, datas, temp);
|
|
|
//递归生成树结构
|
|
|
datas = buildFolderTree(datas);
|
|
|
if (id.contains("/")) {
|
|
@@ -859,7 +866,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
/**
|
|
|
* 递归文件
|
|
|
*/
|
|
|
- private static void findFolder(File file, Map<String, String> map, List<EscalationFolderDTO> allFile) {
|
|
|
+ private static void findFolder(File file, Map<String, String> map, List<EscalationFolderDTO> allFile, String temp) {
|
|
|
map.put(file.getAbsolutePath(), StringUtils.getUUID());
|
|
|
if (file.isDirectory()) {
|
|
|
EscalationFolderDTO data = new EscalationFolderDTO();
|
|
@@ -880,7 +887,7 @@ public class CgglServiceImpl implements CgglService {
|
|
|
allFile.add(data);
|
|
|
File[] files = file.listFiles();
|
|
|
for (File f : files) {
|
|
|
- findFolder(f, map, allFile);
|
|
|
+ findFolder(f, map, allFile, temp);
|
|
|
}
|
|
|
}
|
|
|
} else {
|