Prechádzať zdrojové kódy

上报进度查询接口优化

wanger 3 mesiacov pred
rodič
commit
43a79ecb9a

+ 2 - 0
onemap-common/onemap-common-core/src/main/java/com/onemap/common/core/utils/StringUtils.java

@@ -611,6 +611,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
      * @return
      */
     public static String getFileStaticPath(String filename, String platform) {
+        System.out.println(String.format("filename:%s;platform:%s", filename, platform));
         filename = filename.replaceAll("\\\\", "/");
         if ("windows".equals(platform)) {
             return filename.replace(platform, "/file/statics/");
@@ -627,6 +628,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
      * @return
      */
     public static String getFileAbsolutePath(String filename, String platform) {
+        System.out.println(String.format("filename:%s;platform:%s", filename, platform));
         filename = filename.replaceAll("\\\\", "/");
         if ("windows".equals(platform)) {
             return filename.replace("/file/statics/", platform);

+ 1 - 1
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/mapper/cggl/EscalationRzMapper.java

@@ -13,5 +13,5 @@ import java.util.List;
  */
 public interface EscalationRzMapper extends BaseMapper<EscalationRzDTO> {
 
-    List<EscalationDTO> getStatus(String id);
+    List<EscalationRzDTO> getStatus(String id);
 }

+ 33 - 26
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/cggl/CgglServiceImpl.java

@@ -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 {

+ 9 - 1
onemap-modules/onemap-apply/src/main/resources/mapper/postgresql/cggl/CgglMapper.xml

@@ -10,7 +10,15 @@
        t.operatetime as "operatetime",
        t.operateuser as "operateuser",
        (select dict.dict_label from sys_dict_data dict where dict.dict_type = 'escalationstatus' and dict.dict_value = t.operatetype) as "operatetype",
-       t.remark from t_cggl_escalation_rz t where t.targetid = #{id} and t.operatetype != '999' order by t.operatetime
+       t.remark from t_cggl_escalation_rz t where t.targetid = #{id} and t.operatetype != '999'
+       union all
+        select t.id,
+               t.sctime "operatetime",
+               t.username "operateuser",
+               t.scjl "operatetype",
+               t.scyj "remark"
+          from t_cggl_scmx_record t
+         where t.cgid = #{id}
     </select>