Forráskód Böngészése

PSSR主清单导出文件目录结构

wangggziwen 6 hónapja
szülő
commit
daa8ffa14c

+ 38 - 0
master/src/main/java/com/ruoyi/common/utils/document/ZipUtil.java

@@ -113,4 +113,42 @@ public class ZipUtil {
             }
         }
     }
+
+    public static void toZipWithDirectory(String sourceFile, String outputFile) throws IOException {
+        FileOutputStream fos = new FileOutputStream(outputFile);
+        ZipOutputStream zos = new ZipOutputStream(fos);
+        FileInputStream in = null;
+
+        try {
+            createZipWithDirectory(new File(sourceFile), zos, "");
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+            zos.close();
+            fos.close();
+        }
+    }
+
+    private static void createZipWithDirectory(File file, ZipOutputStream zos, String dir) throws IOException {
+        if (file.isDirectory()) {
+            File[] files = file.listFiles();
+            for (File f : files) {
+                createZipWithDirectory(f, zos, dir + file.getName() + "/");
+            }
+        } else {
+            FileInputStream fis = new FileInputStream(file);
+            ZipEntry zipEntry = new ZipEntry(dir + file.getName());
+            zos.putNextEntry(zipEntry);
+
+            byte[] buffer = new byte[1024];
+            int length;
+            while ((length = fis.read(buffer)) > 0) {
+                zos.write(buffer, 0, length);
+            }
+
+            zos.closeEntry();
+            fis.close();
+        }
+    }
 }

+ 220 - 102
master/src/main/java/com/ruoyi/project/pssr/controller/TPssrApproveController.java

@@ -270,7 +270,6 @@ public class TPssrApproveController extends BaseController {
     @Autowired
     private TPssrPumpOverhaulController pumpOverhaulController;
 
-
     @Autowired
     private TPssrMocController mocController;
 
@@ -283,6 +282,9 @@ public class TPssrApproveController extends BaseController {
     @Autowired
     private TPssrNitrogenController nitrogenController;
 
+    @Autowired
+    private TPssrPatrolController patrolController;
+
     @Autowired
     private TPssrPowerController powerController;
 
@@ -689,7 +691,7 @@ public class TPssrApproveController extends BaseController {
     }
 
     @PutMapping("/handleMgrApprove")
-    public AjaxResult handleMgrApprove(@RequestBody DevTask devTask) {
+    public AjaxResult handleMgrApprove(@RequestBody DevTask devTask) throws IOException {
         TPssrApprove approve = devTask.gettPssrApprove();
         //使用任务服务完成任务(提交任务)
         String taskId = devTask.getTaskId();
@@ -719,7 +721,7 @@ public class TPssrApproveController extends BaseController {
             if (condition.equals("0")) {
                 aboveall.setApproveStatus(2L);
                 aboveall.setConfirmationDate(new Date());
-                // todo:装置经理审批通过,流程结束,审批状态为“2-已审批”,生成子项文件,保存到服务器,打压缩包
+                this.genZip(aboveall);//生成子项文件压缩包
             }
         }
         tPssrAboveallService.updateTPssrAboveall(aboveall);
@@ -735,365 +737,481 @@ public class TPssrApproveController extends BaseController {
         return AjaxResult.success();
     }
 
-    @GetMapping("/downloadAboveall")
-    public AjaxResult downloadAboveall(TPssrAboveall aboveall) {
+    /**
+     * 生成子项文件压缩包
+     */
+    @GetMapping("/genZip")
+    public void genZip(TPssrAboveall aboveall) throws IOException {
         Long id = aboveall.getId();//主表id
-        List<File> files = new ArrayList<>();//文件名集合
+        AjaxResult result = null;
+        String msg = "";//导出方法文件名
+        String downloadPath = getProfile() + "/download/";//导出方法默认目录
+        String path = "";//导出方法默认文件路径=msg+downloadPath
+        String rootPath = getProfile() + "/download/pssr/" + id + "/";//即将被打包的根目录
+        String subTitle = "";//子表目录字符串
+        List<File> files = new ArrayList<>();//文件路径集合
         TPssrSubcontent queryParams = new TPssrSubcontent();
         queryParams.setAboveallId(id);
         List<TPssrSubcontent> tPssrSubcontents = tPssrSubcontentService.selectTPssrSubcontentList(queryParams);//子表集合
-        AjaxResult result = null;
-        String msg = "";
-        String path = "";
+        this.createSubitemDirectory(rootPath);//创建子表目录
         for (TPssrSubcontent tPssrSubcontent : tPssrSubcontents) {
             switch (tPssrSubcontent.getForShort()) {
                 case "jxxm"://检修项目
+                    subTitle = "01检修项目/";
                     TPssrOverhaulFilter filter = new TPssrOverhaulFilter();//过滤器
                     filter.setSubId(tPssrSubcontent.getId());//子表id
                     result = filterController.export(filter);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrOverhaulTower tower = new TPssrOverhaulTower();//塔罐
                     tower.setSubId(tPssrSubcontent.getId());//子表id
                     result = towerController.export(tower);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrOverhaulValve valve = new TPssrOverhaulValve();//阀门
                     valve.setSubId(tPssrSubcontent.getId());//子表id
                     result = valveController.export(valve);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrOverhaulExchanger exchanger = new TPssrOverhaulExchanger();//换热器
                     exchanger.setSubId(tPssrSubcontent.getId());//子表id
                     exchanger.setDevType(1L);
                     result = exchangerController.export(exchanger);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     exchanger.setDevType(2L);
                     result = exchangerController.export(exchanger);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     exchanger.setDevType(3L);
                     result = exchangerController.export(exchanger);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     exchanger.setDevType(4L);
                     result = exchangerController.export(exchanger);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     exchanger.setDevType(5L);
                     result = exchangerController.export(exchanger);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "kgfa"://开工方案
+                    subTitle = "02开工方案/";
                     TPssrProgramme programme = new TPssrProgramme();
                     programme.setSubId(tPssrSubcontent.getId());//子表id
                     result = programmeController.export(programme);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
+                    //todo:附件
                     break;
                 case "sjbg"://设计变更
+                    subTitle = "03设计变更/";
                     TPssrMoc moc = new TPssrMoc();
                     moc.setSubId(tPssrSubcontent.getId());//子表id
                     result = mocController.export(moc);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
+                    path = downloadPath + msg;
                     files.add(new File(path));
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "mb"://盲板
+                    subTitle = "04盲板/";
                     TPssrBlind blind = new TPssrBlind();
                     blind.setSubId(tPssrSubcontent.getId());//子表id
                     result = blindController.export(blind);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "xcws"://现场卫生
+                    subTitle = "05现场卫生/";
                     TPssrHygiene hygiene = new TPssrHygiene();
                     hygiene.setSubId(tPssrSubcontent.getId());//子表id
                     result = hygieneController.export(hygiene);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "rsfh"://人身防护
+                    subTitle = "06人身防护/";
                     TPssrProtection protection = new TPssrProtection();
                     protection.setSubId(tPssrSubcontent.getId());//子表id
                     result = protectionController.export(protection);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrMeasure measure = new TPssrMeasure();
                     measure.setSubId(tPssrSubcontent.getId());//子表id
                     result = measureController.export(measure);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "sbqjd"://设备清洁度
+                    subTitle = "07设备清洁度/";
                     TPssrCleaning cleaning = new TPssrCleaning();
                     cleaning.setSubId(tPssrSubcontent.getId());//子表id
                     result = cleaningController.export(cleaning);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "qm"://气密
+                    subTitle = "08气密/";
                     TPssrAirtight airtight = new TPssrAirtight();
                     airtight.setSubId(tPssrSubcontent.getId());//子表id
                     result = airtightController.export(airtight);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
-                    break;
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
+//                    break;
                 case "sksgfmzt"://锁开锁关阀门状态
+                    subTitle = "09锁开锁关阀门状态/";
                     TPssrLock lock = new TPssrLock();
                     lock.setSubId(tPssrSubcontent.getId());//子表id
                     result = lockController.export(lock);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "sys"://实验室
+                    subTitle = "10实验室/";
                     TPssrLaboratory laboratory = new TPssrLaboratory();
                     laboratory.setSubId(tPssrSubcontent.getId());//子表id
                     result = laboratoryController.export(laboratory);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "dj"://短接
+                    subTitle = "11短接/";
                     TPssrCircuit circuit = new TPssrCircuit();
                     circuit.setSubId(tPssrSubcontent.getId());//子表id
                     result = circuitController.export(circuit);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "dqzh"://氮气置换
+                    subTitle = "12氮气置换/";
                     TPssrNitrogen nitrogen = new TPssrNitrogen();
                     nitrogen.setSubId(tPssrSubcontent.getId());//子表id
                     result = nitrogenController.export(nitrogen);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "xqf"://消气防设施
-
+                    //todo:巡检
                     break;
                 case "aqss"://安全设施
+                    subTitle = "14安全设施/";
                     TPssrSafetyBleed bleed = new TPssrSafetyBleed();
                     bleed.setSubId(tPssrSubcontent.getId());//子表id
                     result = bleedController.export(bleed);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrSafetyBreath breath = new TPssrSafetyBreath();
                     breath.setSubId(tPssrSubcontent.getId());//子表id
                     result = breathController.export(breath);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrSafetyBrust brust = new TPssrSafetyBrust();
                     brust.setSubId(tPssrSubcontent.getId());//子表id
                     result = brustController.export(brust);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrSafetyFlamearrester flamearrester = new TPssrSafetyFlamearrester();
                     flamearrester.setSubId(tPssrSubcontent.getId());//子表id
                     result = flamearresterController.export(flamearrester);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrSafetyValve safetyValve = new TPssrSafetyValve();
                     safetyValve.setSubId(tPssrSubcontent.getId());//子表id
                     result = safetyValveController.export(safetyValve);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "txjk"://通讯监控
-
+                    //todo:巡检
                     break;
                 case "bxsjcy"://便携式检测仪
-
+                    //todo:巡检
                     break;
                 case "gygc"://公用工程
+                    subTitle = "17公用工程/";
                     TPssrPublic tPssrPublic = new TPssrPublic();
                     tPssrPublic.setSubId(tPssrSubcontent.getId());//子表id
                     result = publicController.export(tPssrPublic);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "hbss"://环保设施
+                    subTitle = "18环保设施/";
                     TPssrTorchvoc torchvoc = new TPssrTorchvoc();
                     torchvoc.setSubId(tPssrSubcontent.getId());//子表id
                     torchvoc.setTorchvocType("1");
                     result = torchvocController.export(torchvoc);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     torchvoc.setTorchvocType("2");
                     result = torchvocController.export(torchvoc);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "yfl"://原辅料
+                    subTitle = "19原辅料/";
                     TPssrMaterial material = new TPssrMaterial();
                     material.setSubId(tPssrSubcontent.getId());//子表id
                     result = materialController.export(material);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "jb"://机泵
+                    subTitle = "20机泵/";
                     TPssrPumpCleaning pumpCleaning = new TPssrPumpCleaning();
                     pumpCleaning.setSubId(tPssrSubcontent.getId());//子表id
                     result = pumpCleaningController.export(pumpCleaning);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrPumpFill pumpFill = new TPssrPumpFill();
                     pumpFill.setSubId(tPssrSubcontent.getId());//子表id
                     result = pumpFillController.export(pumpFill);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrPumpOverhaul pumpOverhaul = new TPssrPumpOverhaul();
                     pumpOverhaul.setSubId(tPssrSubcontent.getId());//子表id
                     result = pumpOverhaulController.export(pumpOverhaul);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "zdj"://支(吊)架
+                    subTitle = "21支(吊)架/";
                     TPssrFrame frame = new TPssrFrame();
                     frame.setSubId(tPssrSubcontent.getId());//子表id
                     result = frameController.export(frame);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "tzsb"://压力管道/压力容器
+                    subTitle = "22压力管道、压力容器/";
                     TPssrPipe pipe = new TPssrPipe();
                     pipe.setSubId(tPssrSubcontent.getId());//子表id
                     result = pipeController.export(pipe);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     TPssrVessel vessel = new TPssrVessel();
                     vessel.setSubId(tPssrSubcontent.getId());//子表id
                     result = vesselController.export(vessel);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "ybjy"://仪表校验
+                    subTitle = "23仪表校验/";
                     TPssrInstrumentCalibration calibration = new TPssrInstrumentCalibration();
                     calibration.setSubId(tPssrSubcontent.getId());//子表id
                     result = instrumentCalibrationController.export(calibration);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "yblscs"://仪表联锁测试
-
+                    //todo:附件
                     break;
                 case "bjlszqr"://报警/联锁值确认
-
+                    //todo:附件
                     break;
                 case "lsdy"://临时电源
+                    subTitle = "26临时电源/";
                     TPssrPower power = new TPssrPower();
                     power.setSubId(tPssrSubcontent.getId());//子表id
                     result = powerController.export(power);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "djsb"://电机设备
+                    subTitle = "27电机设备/";
                     TPssrMotor motor = new TPssrMotor();
                     motor.setSubId(tPssrSubcontent.getId());//子表id
                     result = motorController.export(motor);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "zmdbr"://照明、电伴热
+                    subTitle = "28照明、电伴热/";
                     TPssrLighting lighting = new TPssrLighting();
                     lighting.setSubId(tPssrSubcontent.getId());//子表id
                     lighting.setLightingType("1");
                     result = lightingController.export(lighting);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
 
                     lighting.setLightingType("2");
                     result = lightingController.export(lighting);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "jdjdkj"://静电接地/跨接
+                    subTitle = "29静电接地、跨接/";
                     TPssrFranklinism franklinism = new TPssrFranklinism();
                     franklinism.setSubId(tPssrSubcontent.getId());//子表id
                     result = franklinismController.export(franklinism);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "qtjcy"://气体检测仪
+                    subTitle = "30气体检测仪/";
                     TPssrGasdetector gasdetector = new TPssrGasdetector();
                     gasdetector.setSubId(tPssrSubcontent.getId());//子表id
                     result = gasdetectorController.export(gasdetector);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
                 case "zxfxy"://在线分析仪
+                    subTitle = "31在线分析仪/";
                     TPssrAnalyzer analyzer = new TPssrAnalyzer();
                     analyzer.setSubId(tPssrSubcontent.getId());//子表id
                     result = analyzerController.export(analyzer);
                     msg = (String) result.get("msg");
-                    path = getProfile() + "/download/" + msg;
-                    files.add(new File(path));
+                    path = downloadPath + msg;
+                    Files.copy(Paths.get(path), Paths.get(rootPath + subTitle + msg), StandardCopyOption.REPLACE_EXISTING);//拷贝导出的文件
+                    files.add(new File(rootPath + subTitle + msg));
                     break;
             }
         }
         try {
-            ZipUtil.toZip(files, new File(getProfile() + "/download/"+ id + "pssr.zip"));//打包
+            ZipUtil.toZipWithDirectory(rootPath, downloadPath + id + "pssr.zip");//打包
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return AjaxResult.success(id + "pssr.zip");//fileName
+    }
+
+    private void createSubitemDirectory(String rootPath) {
+        boolean mkdir1 = new File(rootPath + "01检修项目").mkdirs();//子项文件目录
+        boolean mkdir2 = new File(rootPath + "02开工方案").mkdirs();
+        boolean mkdir3 = new File(rootPath + "03设计变更").mkdirs();
+        boolean mkdir4 = new File(rootPath + "04盲板").mkdirs();
+        boolean mkdir5 = new File(rootPath + "05现场卫生").mkdirs();
+        boolean mkdir6 = new File(rootPath + "06人身防护").mkdirs();
+        boolean mkdir7 = new File(rootPath + "07设备清洁度").mkdirs();
+        boolean mkdir8 = new File(rootPath + "08气密").mkdirs();
+        boolean mkdir9 = new File(rootPath + "09锁开锁关阀门状态").mkdirs();
+        boolean mkdir10 = new File(rootPath + "10实验室").mkdirs();
+        boolean mkdir11 = new File(rootPath + "11短接").mkdirs();
+        boolean mkdir12 = new File(rootPath + "12氮气置换").mkdirs();
+        boolean mkdir13 = new File(rootPath + "13消气防设施").mkdirs();
+        boolean mkdir14 = new File(rootPath + "14安全设施").mkdirs();
+        boolean mkdir15 = new File(rootPath + "15通讯监控").mkdirs();
+        boolean mkdir16 = new File(rootPath + "16便携式检测仪").mkdirs();
+        boolean mkdir17 = new File(rootPath + "17公用工程").mkdirs();
+        boolean mkdir18 = new File(rootPath + "18环保设施").mkdirs();
+        boolean mkdir19 = new File(rootPath + "19原辅料").mkdirs();
+        boolean mkdir20 = new File(rootPath + "20机泵").mkdirs();
+        boolean mkdir21 = new File(rootPath + "21支(吊)架").mkdirs();
+        boolean mkdir22 = new File(rootPath + "22压力管道、压力容器").mkdirs();
+        boolean mkdir23 = new File(rootPath + "23仪表校验").mkdirs();
+        boolean mkdir24 = new File(rootPath + "24仪表联锁测试").mkdirs();
+        boolean mkdir25 = new File(rootPath + "25报警、联锁值确认").mkdirs();
+        boolean mkdir26 = new File(rootPath + "26临时电源").mkdirs();
+        boolean mkdir27 = new File(rootPath + "27电机设备").mkdirs();
+        boolean mkdir28 = new File(rootPath + "28照明、电伴热").mkdirs();
+        boolean mkdir29 = new File(rootPath + "29静电接地、跨接").mkdirs();
+        boolean mkdir30 = new File(rootPath + "30气体检测仪").mkdirs();
+        boolean mkdir31 = new File(rootPath + "31在线分析仪").mkdirs();
+    }
+
+    @GetMapping("/downloadAboveall")
+    public AjaxResult downloadAboveall(TPssrAboveall aboveall) {
+        return AjaxResult.success(aboveall.getId() + "pssr.zip");//fileName
     }
 
     /**

+ 10 - 0
master/src/main/java/com/ruoyi/project/pssr/domain/TPssrAboveall.java

@@ -91,6 +91,16 @@ public class TPssrAboveall extends BaseEntity
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
     private Date drivingTime;
 
+    private String zipUrl;
+
+    public String getZipUrl() {
+        return zipUrl;
+    }
+
+    public void setZipUrl(String zipUrl) {
+        this.zipUrl = zipUrl;
+    }
+
     public String getConfirmName() {
         return confirmName;
     }

+ 6 - 0
master/src/main/resources/mybatis/pssr/TPssrAboveallMapper.xml

@@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="ctaConfirmdate" column="cta_confirmdate" />
         <result property="ctmConfirmdate" column="ctm_confirmdate" />
         <result property="drivingTime" column="driving_time" />
+        <result property="zipUrl" column="zip_url" />
     </resultMap>
 
     <sql id="selectTPssrAboveallVo">
@@ -40,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                d.cta_confirmdate,
                d.ctm_confirmdate,
                d.driving_time,
+               d.zip_url,
             d.id, d.approve_id, d.region, d.approve_status, d.unit, d.confirm, u.NICK_NAME confirm_name , d.confirmation_date, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks, d.include_public, d.unit_des ,s.dept_name from t_pssr_aboveall d
       left join sys_dept s on s.dept_id = d.dept_id
       left join sys_user u on u.USER_ID = d.CONFIRM
@@ -69,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="ctaConfirmdate != null  "> and cta_confirmdate = #{ctaConfirmdate}</if>
             <if test="ctmConfirmdate != null  "> and ctm_confirmdate = #{ctmConfirmdate}</if>
             <if test="drivingTime != null  "> and driving_time = #{drivingTime}</if>
+            <if test="zipUrl != null  "> and zip_url = #{zipUrl}</if>
             and d.del_flag = 0
         </where>
         <!-- 数据范围过滤 -->
@@ -110,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="ctaConfirmdate != null">cta_confirmdate,</if>
             <if test="ctmConfirmdate != null">ctm_confirmdate,</if>
             <if test="drivingTime != null">driving_time,</if>
+            <if test="zipUrl != null">zip_url,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -135,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="ctaConfirmdate != null">#{ctaConfirmdate},</if>
             <if test="ctmConfirmdate != null">#{ctmConfirmdate},</if>
             <if test="drivingTime != null">#{drivingTime},</if>
+            <if test="zipUrl != null">#{zipUrl},</if>
          </trim>
     </insert>
 
@@ -163,6 +168,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="ctaConfirmdate != null">cta_confirmdate = #{ctaConfirmdate},</if>
             <if test="ctmConfirmdate != null">ctm_confirmdate = #{ctmConfirmdate},</if>
             <if test="drivingTime != null">driving_time = #{drivingTime},</if>
+            <if test="zipUrl != null">zip_url = #{zipUrl},</if>
         </trim>
         where id = #{id}
     </update>

+ 8 - 0
ui/src/api/pssr/aboveall.js

@@ -1,5 +1,13 @@
 import request from '@/utils/request'
 
+export function genZip(query) {
+  return request({
+    url: '/pssr/approve/genZip',
+    method: 'get',
+    params: query
+  })
+}
+
 export function downloadAboveall(query) {
   return request({
     url: '/pssr/approve/downloadAboveall',

+ 25 - 7
ui/src/views/pssr/aboveall/index.vue

@@ -129,6 +129,13 @@
             @click="gotoSubIndex(scope.row)"
           >检查内容
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-download"
+            @click="handleZip(scope.row)"
+          >打包
+          </el-button>
           <el-button
             size="mini"
             type="text"
@@ -294,7 +301,8 @@ import {
   importTemplate,
   listAboveall,
   updateAboveall,
-  downloadAboveall
+  downloadAboveall,
+  genZip
 } from "@/api/pssr/aboveall";
 import {treeselect} from "@/api/system/dept";
 import {getToken} from "@/utils/auth";
@@ -405,21 +413,31 @@ export default {
     });
   },
   methods: {
-    handleDownload(row) {
+    handleZip(row) {
       this.queryParams.id = Number(row.id);
       const queryParams = this.queryParams;
-      this.$confirm('是否确认导出?', "警告", {
+      this.$confirm('是否确认打包?', "警告", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
       }).then(function () {
-        return downloadAboveall(queryParams);
+        return genZip(queryParams);
       }).then(response => {
-        this.downloadForm.fileName = response.msg;
-        this.downloadForm.delete = false;
-        this.$refs['downloadForm'].submit();
+        this.msgSuccess("打包成功");
       })
     },
+    handleDownload(row) {
+      let _this = this;
+      this.$confirm('是否确认导出?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        _this.downloadForm.fileName = row.id + "pssr.zip";
+        _this.downloadForm.delete = false;
+        _this.$refs['downloadForm'].submit();
+      });
+    },
     getTagType(val) {
       if (val == 0) {
         return ''