浏览代码

上报进度相关接口优化

wanger 6 月之前
父节点
当前提交
06a96fbe91

+ 26 - 9
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/impl/ResultsServiceImpl.java

@@ -217,6 +217,7 @@ public class ResultsServiceImpl implements ResultsService {
         }
         QueryWrapper<Qxcgsbrwfp> fpwrapper = new QueryWrapper<>();
         fpwrapper.eq("md5", md5);
+        fpwrapper.orderByAsc("chunk");
         List<Qxcgsbrwfp> fplist = qxcgsbrwfpMapper.selectList(fpwrapper);
         if (fplist.size() == 0) {
             return RequestResult.error("合包前请先调用【分片上传成果包接口(/api/open/results/Upload)】上传成果");
@@ -235,7 +236,7 @@ public class ResultsServiceImpl implements ResultsService {
             loginfo("完成合包:" + folder);
         } catch (IOException e) {
             e.printStackTrace();
-            qxsbcg.setRwzt(rwzt.getHbsb());
+//            qxsbcg.setRwzt(rwzt.getHbsb());
             qxcgsbrwMapper.update(qxsbcg, sbrwwrapper);
 //            deleteQxsbrw(md5);
             return RequestResult.error("合包失败,没找到合包后的文件,请联系管理员");
@@ -244,6 +245,7 @@ public class ResultsServiceImpl implements ResultsService {
         String fileMd5 = getMD5(targetfile);
         if (!fileMd5.equals(md5)) {
             deleteQxsbrw(md5);
+            deleteCurDirectory(targetfile.getParent());
             return RequestResult.error("警告:文件的MD5不一致");
         }
         //TODO wanger 进行数据解压
@@ -259,12 +261,14 @@ public class ResultsServiceImpl implements ResultsService {
         File unzipfile = new File(unzippath);
         if (!unzipfile.exists()) {
             deleteQxsbrw(md5);
+            deleteCurDirectory(targetfile.getParent());
             return RequestResult.error("压缩包名称与解压后的文件名称不一致,请检查!");
         }
         //解析txt
         String txtFilePath = FileSearch(unzippath, "基本信息.txt");
         if (StringUtils.isEmpty(txtFilePath)) {
             deleteQxsbrw(md5);
+            deleteCurDirectory(targetfile.getParent());
             return RequestResult.error("成果包中必须包含“xxx基本信息.txt”文件,同时注意成果包中应包含“xxx规划成果”的根目录");
         }
         Map<String, String> txtMap = readTxt(txtFilePath);
@@ -298,6 +302,7 @@ public class ResultsServiceImpl implements ResultsService {
         List<TCgglSjbzmlwjDto> sjbzlist = tCgglSjbzmlwjMapper.selectList(sjbzwrapper);
         if (sjbzlist.size() == 0) {
             deleteQxsbrw(md5);
+            deleteCurDirectory(targetfile.getParent());
             return RequestResult.error(String.format("未授权的数据类型:%s,请联系管理人员!", sjbz_bsm));
         }
         //记录缺失的文件列表  字符串类型
@@ -305,6 +310,7 @@ public class ResultsServiceImpl implements ResultsService {
         missfiles = checkMustFiles(unzipfile.getParent(), sjbzlist, "", missfiles, xzqdm, xzqmc);
         if (missfiles.size() > 0) {
             deleteQxsbrw(md5);
+            deleteCurDirectory(targetfile.getParent());
             return RequestResult.error(String.format("成果数据缺少以下目录或文件:%s", String.join("\n", missfiles)), missfiles);
         }
         qxsbcg.setRwzt(rwzt.getWc());
@@ -365,6 +371,15 @@ public class ResultsServiceImpl implements ResultsService {
         return RequestResult.success("操作成功", 1);
     }
 
+    private void deleteCurDirectory(String parent) {
+        try {
+            FileUtils.deleteDirectory(new File(parent));
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.out.println(String.format("文件夹删除失败:%s", parent));
+        }
+    }
+
     /**
      * 根据MD5删除数据库表和数据文件夹
      *
@@ -375,14 +390,16 @@ public class ResultsServiceImpl implements ResultsService {
         sbrwwrapper.eq("bsm", md5);
         Qxcgsbrw qxsbcg = qxcgsbrwMapper.selectOne(sbrwwrapper);
         String wjwz = qxsbcg.getCgwj();
-        File file = new File(wjwz);
-        if (file != null) {
-            String dir = file.getParent();
-            try {
-                FileUtils.deleteDirectory(new File(dir));
-            } catch (IOException e) {
-                e.printStackTrace();
-                System.out.println(String.format("%s:文件夹删除失败:%s", md5, dir));
+        if (StringUtils.isNotEmpty(wjwz)) {
+            File file = new File(wjwz);
+            if (file != null) {
+                String dir = file.getParent();
+                try {
+                    FileUtils.deleteDirectory(new File(dir));
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    System.out.println(String.format("%s:文件夹删除失败:%s", md5, dir));
+                }
             }
         }
         qxcgsbrwMapper.delete(sbrwwrapper);

+ 1 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/util/utils.java

@@ -137,6 +137,7 @@ public class utils {
                     resMap.put(curline[0], curline[1]);
                 }
             }
+            reader.close();
         } catch (IOException e) {
             e.printStackTrace();
         }

+ 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);
 }

+ 30 - 23
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/cggl/CgglServiceImpl.java

@@ -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);
     }
 

+ 10 - 2
onemap-modules/onemap-apply/src/main/resources/mapper/oracle/cggl/CgglMapper.xml

@@ -9,8 +9,16 @@
         select t.id as "id",
        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
+       (select to_char(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'
+       union all
+        select t.id,
+               t.sctime "operatetime",
+               t.username "operateuser",
+               to_char(t.scjl) "operatetype",
+               t.scyj "remark"
+          from t_cggl_scmx_record t
+         where t.cgid = #{id}
     </select>