Jelajahi Sumber

PSSR主清单导出

wangggziwen 6 bulan lalu
induk
melakukan
ad7911b03a

+ 147 - 1
master/src/main/java/com/ruoyi/project/pssr/controller/TPssrApproveController.java

@@ -1,10 +1,15 @@
 package com.ruoyi.project.pssr.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.document.PDFTemplateUtil;
+import com.ruoyi.common.utils.document.ZipUtil;
+import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
@@ -12,22 +17,43 @@ import com.ruoyi.project.approve.damain.DevTask;
 import com.ruoyi.project.plant.domain.TStaffmgr;
 import com.ruoyi.project.pssr.domain.*;
 import com.ruoyi.project.pssr.service.*;
+import com.ruoyi.project.sems.domain.TReportHiYlgd;
+import com.ruoyi.project.sems.domain.TReportYlgd;
+import com.ruoyi.project.sems.domain.TSpecdevYlgd;
+import com.ruoyi.project.system.domain.SysDictData;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.project.system.service.ISysUserService;
 import org.activiti.engine.*;
+import org.activiti.engine.history.HistoricTaskInstance;
+import org.activiti.engine.history.HistoricTaskInstanceQuery;
 import org.activiti.engine.impl.identity.Authentication;
 import org.activiti.engine.impl.util.CollectionUtil;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.task.Task;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.*;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
+import static com.ruoyi.framework.config.RuoYiConfig.getProfile;
+
 /**
  * pssr审批管理Controller
  *
@@ -188,6 +214,9 @@ public class TPssrApproveController extends BaseController {
     @Autowired
     private ITPssrPowerService tPssrPowerService;
 
+    @Autowired
+    private TPssrBlindController blindController;
+
     /**
      * 子项内容确认
      */
@@ -389,7 +418,6 @@ public class TPssrApproveController extends BaseController {
         subcontent.setAboveallId(sub.getAboveallId());
         List<String> forShorts = new ArrayList<>();
         if ("jb,ybjy".contains(sub.getForShort())) {
-
         } else if ("sbqjd".contains(sub.getForShort())){
             forShorts.add("jb");
             forShorts.add("ybjy");
@@ -579,6 +607,7 @@ public class TPssrApproveController extends BaseController {
             if (condition.equals("0")) {
                 aboveall.setApproveStatus(2L);
                 aboveall.setConfirmationDate(new Date());
+                // todo:装置经理审批通过,流程结束,审批状态为“2-已审批”,生成各子项文件,保存到服务器,打压缩包
             }
         }
         tPssrAboveallService.updateTPssrAboveall(aboveall);
@@ -594,6 +623,123 @@ public class TPssrApproveController extends BaseController {
         return AjaxResult.success();
     }
 
+    @GetMapping("/downloadAboveall")
+    public AjaxResult downloadAboveall(TPssrAboveall aboveall) {
+        Long id = aboveall.getId();//主表id
+        List<File> files = new ArrayList<>();//文件名集合
+        TPssrSubcontent queryParams = new TPssrSubcontent();
+        queryParams.setAboveallId(id);
+        List<TPssrSubcontent> tPssrSubcontents = tPssrSubcontentService.selectTPssrSubcontentList(queryParams);//子表集合
+        for (TPssrSubcontent tPssrSubcontent : tPssrSubcontents) {
+            switch (tPssrSubcontent.getSerialNumber()) {
+                case "01":
+
+                    break;
+                case "02":
+
+                    break;
+                case "03":
+
+                    break;
+                case "04"://盲板
+                    TPssrBlind blind = new TPssrBlind();
+                    blind.setSubId(tPssrSubcontent.getId());//子表id
+                    AjaxResult export = blindController.export(blind);
+                    String msg = (String) export.get("msg");
+                    String absolutePath = getProfile() + "/download/" + msg;
+                    files.add(new File(absolutePath));
+                    break;
+                case "05":
+
+                    break;
+                case "06":
+
+                    break;
+                case "07":
+
+                    break;
+                case "08":
+
+                    break;
+                case "09":
+
+                    break;
+                case "10":
+
+                    break;
+                case "11":
+
+                    break;
+                case "12":
+
+                    break;
+                case "13":
+
+                    break;
+                case "14":
+
+                    break;
+                case "15":
+
+                    break;
+                case "16":
+
+                    break;
+                case "17":
+
+                    break;
+                case "18":
+
+                    break;
+                case "19":
+
+                    break;
+                case "20":
+
+                    break;
+                case "21":
+
+                    break;
+                case "22":
+
+                    break;
+                case "23":
+
+                    break;
+                case "24":
+
+                    break;
+                case "25":
+
+                    break;
+                case "26":
+
+                    break;
+                case "27":
+
+                    break;
+                case "28":
+
+                    break;
+                case "29":
+
+                    break;
+                case "30":
+
+                    break;
+                case "31":
+
+                    break;
+            }
+        }
+        try {
+            ZipUtil.toZip(files, new File(getProfile() + "/download/"+ id + "pssr.zip"));//打包
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return AjaxResult.success(id + "pssr.zip");//fileName
+    }
+
     /**
      * 氮气置换审批流程发起申请
      *

+ 2 - 1
master/src/main/java/com/ruoyi/project/pssr/controller/TPssrBlindController.java

@@ -186,7 +186,6 @@ public class TPssrBlindController extends BaseController {
     /**
      * 导出盲板列表
      */
-    @PreAuthorize("@ss.hasPermi('pssr:blind:export')")
     @Log(title = "盲板", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(TPssrBlind tPssrBlind) {
@@ -257,6 +256,8 @@ public class TPssrBlindController extends BaseController {
             out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
             wb.write(out);
             wb.close();
+            is.close();
+            out.close();
 
         } catch (IOException e) {
             e.printStackTrace();

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

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

+ 44 - 11
ui/src/views/pssr/aboveall/index.vue

@@ -68,16 +68,16 @@
         >导入
         </el-button>
       </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="warning"
-          icon="el-icon-download"
-          size="mini"
-          @click="handleExport"
-          v-hasPermi="['pssr:aboveall:export']"
-        >导出
-        </el-button>
-      </el-col>
+      <!--<el-col :span="1.5">-->
+        <!--<el-button-->
+          <!--type="warning"-->
+          <!--icon="el-icon-download"-->
+          <!--size="mini"-->
+          <!--@click="handleExport"-->
+          <!--v-hasPermi="['pssr:aboveall:export']"-->
+        <!--&gt;导出-->
+        <!--</el-button>-->
+      <!--</el-col>-->
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -129,6 +129,13 @@
             @click="gotoSubIndex(scope.row)"
           >检查内容
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-download"
+            @click="handleDownload(scope.row)"
+          >导出
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -270,6 +277,11 @@
         <el-button @click="upload.open = false">取 消</el-button>
       </div>
     </el-dialog>
+
+    <form ref="downloadForm" :action="downloadAction" target="FORMSUBMIT">
+      <input name="fileName" v-model="downloadForm.fileName" hidden/>
+      <input name="delete" v-model="downloadForm.delete" hidden/>
+    </form>
   </div>
 </template>
 
@@ -281,7 +293,8 @@ import {
   getAboveall, getPssrUser,
   importTemplate,
   listAboveall,
-  updateAboveall
+  updateAboveall,
+  downloadAboveall
 } from "@/api/pssr/aboveall";
 import {treeselect} from "@/api/system/dept";
 import {getToken} from "@/utils/auth";
@@ -297,6 +310,11 @@ export default {
   components: {Treeselect},
   data() {
     return {
+      downloadForm: {
+        fileName: '',
+        delete: false,
+      },
+      downloadAction: process.env.VUE_APP_BASE_API + '/common/download',
       subcontents: [],
       regionGroupOptions: [],
       unitOptions: [],
@@ -387,6 +405,21 @@ export default {
     });
   },
   methods: {
+    handleDownload(row) {
+      this.queryParams.id = Number(row.id);
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return downloadAboveall(queryParams);
+      }).then(response => {
+        this.downloadForm.fileName = response.msg;
+        this.downloadForm.delete = false;
+        this.$refs['downloadForm'].submit();
+      })
+    },
     getTagType(val) {
       if (val == 0) {
         return ''