Sfoglia il codice sorgente

王子文 压力容器年检报告 下载选中设备

wangggziwen 2 anni fa
parent
commit
84b32194ad

+ 289 - 4
master/src/main/java/com/ruoyi/project/sems/controller/TReportYlrqController.java

@@ -1,6 +1,8 @@
 package com.ruoyi.project.sems.controller;
 
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -11,12 +13,13 @@ import com.alibaba.fastjson.JSON;
 import com.ruoyi.common.utils.file.ExcelUtils;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.framework.config.RuoYiConfig;
+import com.ruoyi.project.sems.domain.ParamData;
 import com.ruoyi.project.sems.domain.TReportThird;
+import com.ruoyi.project.sems.domain.TSpecdevCc;
 import com.ruoyi.project.sems.service.ITReportThirdService;
-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.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -46,6 +49,288 @@ public class TReportYlrqController extends BaseController {
     @Autowired
     private ITReportThirdService itReportYlrqThirdService;
 
+    /**
+     * 导出选中设备
+     *
+     * @param params
+     * @return
+     * @throws IOException
+     */
+    @GetMapping("/exportSelected")
+    public AjaxResult exportbmy(ParamData params) throws IOException {
+        logger.info(JSON.toJSONString(params));
+        String id = params.getIds();
+        String[] ids = id.split(",");
+        List<TReportYlrq> list = new ArrayList<>();
+        for (String i : ids
+        ) {
+            TReportYlrq reportYlrqEntity = tReportYlrqService.selectTReportYlrqById(Long.parseLong(i));
+            list.add(reportYlrqEntity);
+        }
+        SXSSFWorkbook wb = new SXSSFWorkbook(1000);
+        CellStyle wrapStyle = wb.createCellStyle();
+        wrapStyle.setWrapText(true);    //设置自动换行
+        //创建sheet页
+        Sheet sheet = wb.createSheet("sheet1");
+        //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
+        for (int i = 0; i < 41; i++) {
+            if (i == 0 || i == 1 || i == 2 || i == 35 || i == 36 || i ==37 || i == 38 || i == 39 || i == 40) {
+                sheet.setColumnWidth(i, 20 * 256);
+            } else {
+                sheet.setColumnWidth(i,  10 * 256);
+            }
+        }
+        //设置开始行和开始列
+        Row row0 = sheet.createRow(0);
+        CellStyle styleGrey = wb.createCellStyle();
+        Font headerFont = wb.createFont();
+        headerFont.setBold(true);
+        headerFont.setColor(IndexedColors.BLACK.getIndex());
+        styleGrey.setFont(headerFont);
+        styleGrey.setBorderBottom(BorderStyle.THIN); //下边框
+        styleGrey.setBorderLeft(BorderStyle.THIN);//左边框
+        styleGrey.setBorderTop(BorderStyle.THIN);//上边框
+        styleGrey.setBorderRight(BorderStyle.THIN);//右边框
+        styleGrey.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        styleGrey.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        CellStyle styleYellow = wb.createCellStyle();
+        styleYellow.setFont(headerFont);
+        styleYellow.setBorderBottom(BorderStyle.THIN); //下边框
+        styleYellow.setBorderLeft(BorderStyle.THIN);//左边框
+        styleYellow.setBorderTop(BorderStyle.THIN);//上边框
+        styleYellow.setBorderRight(BorderStyle.THIN);//右边框
+        styleYellow.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
+        styleYellow.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        Cell cell0 = row0.createCell(0);
+        row0.createCell(0).setCellValue("使用证");
+        row0.createCell(1).setCellValue("注册编号");
+        row0.createCell(2).setCellValue("位号");
+        row0.createCell(3).setCellValue("容器管理");
+        row0.createCell(4);
+        row0.createCell(5);
+        row0.createCell(6);
+        row0.createCell(7);
+        row0.createCell(8);
+        row0.createCell(9);
+        row0.createCell(10).setCellValue("本体及运行情况");
+        row0.createCell(11);
+        row0.createCell(12);
+        row0.createCell(13);
+        row0.createCell(14);
+        row0.createCell(15);
+        row0.createCell(16);
+        row0.createCell(17);
+        row0.createCell(18);
+        row0.createCell(19);
+        row0.createCell(20);
+        row0.createCell(21);
+        row0.createCell(22);
+        row0.createCell(23);
+        row0.createCell(24);
+        row0.createCell(25);
+        row0.createCell(26);
+        row0.createCell(27).setCellValue("安全附件及措施");
+        row0.createCell(28);
+        row0.createCell(29);
+        row0.createCell(30);
+        row0.createCell(31);
+        row0.createCell(32);
+        row0.createCell(33);
+        row0.createCell(34).setCellValue("其他");
+        row0.createCell(35).setCellValue("备注");
+        row0.createCell(36).setCellValue("检查日期");
+        row0.createCell(37).setCellValue("下次年度检查日期");
+        row0.createCell(38).setCellValue("问题及处理");
+        row0.createCell(39).setCellValue("检查结论");
+        row0.createCell(40).setCellValue("检查结论备注");
+        Row row1 = sheet.createRow(1);
+        row1.createCell(0);
+        row1.createCell(1);
+        row1.createCell(2);
+        row1.createCell(3).setCellValue("1");
+        row1.createCell(4).setCellValue("2");
+        row1.createCell(5).setCellValue("3");
+        row1.createCell(6).setCellValue("4");
+        row1.createCell(7).setCellValue("5");
+        row1.createCell(8).setCellValue("6");
+        row1.createCell(9).setCellValue("7");
+        row1.createCell(10).setCellValue("8");
+        row1.createCell(11).setCellValue("9");
+        row1.createCell(12).setCellValue("10");
+        row1.createCell(13).setCellValue("11");
+        row1.createCell(14).setCellValue("12");
+        row1.createCell(15).setCellValue("13");
+        row1.createCell(16).setCellValue("14");
+        row1.createCell(17).setCellValue("15");
+        row1.createCell(18).setCellValue("16");
+        row1.createCell(19).setCellValue("17");
+        row1.createCell(20).setCellValue("18");
+        row1.createCell(21).setCellValue("19");
+        row1.createCell(22).setCellValue("20");
+        row1.createCell(23).setCellValue("21");
+        row1.createCell(24).setCellValue("22");
+        row1.createCell(25).setCellValue("23");
+        row1.createCell(26).setCellValue("24");
+        row1.createCell(27).setCellValue("25");
+        row1.createCell(28).setCellValue("26");
+        row1.createCell(29).setCellValue("27");
+        row1.createCell(30).setCellValue("28");
+        row1.createCell(31).setCellValue("29");
+        row1.createCell(32).setCellValue("30");
+        row1.createCell(33).setCellValue("31");
+        row1.createCell(34).setCellValue("32");
+        row1.createCell(35);
+        row1.createCell(36);
+        row1.createCell(37);
+        row1.createCell(38);
+        row1.createCell(39);
+        row1.createCell(40);
+        Row row2 = sheet.createRow(2);
+        for (int i = 0; i < 41; i++) {
+            row2.createCell(i);
+            if (i == 40) row2.createCell(i).setCellValue("1:符合要求");
+        }
+        Row row3 = sheet.createRow(3);
+        for (int i = 0; i < 41; i++) {
+            row3.createCell(i);
+            if (i == 40) row3.createCell(i).setCellValue("2:基本符合要求");
+        }
+        Row row4 = sheet.createRow(4);
+        for (int i = 0; i < 41; i++) {
+            row4.createCell(i);
+            if (i == 40) row4.createCell(i).setCellValue("3:不符合要求");
+        }
+        // 合并单元格
+        sheet.addMergedRegion(new CellRangeAddress(0,1,0,0));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,1,1));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,2,2));
+        sheet.addMergedRegion(new CellRangeAddress(0,0,3,9));
+        sheet.addMergedRegion(new CellRangeAddress(0,0,10,26));
+        sheet.addMergedRegion(new CellRangeAddress(0,0,27,33));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,35,35));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,36,36));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,37,37));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,38,38));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,39,39));
+        sheet.addMergedRegion(new CellRangeAddress(0,1,40,40));
+        // 表头样式
+        for (int i = 0; i < 40; i++) {
+            if (i < 3) {
+                row0.getCell(i).setCellStyle(styleGrey);
+                row1.getCell(i).setCellStyle(styleGrey);
+            } else {
+                row0.getCell(i).setCellStyle(styleYellow);
+                row1.getCell(i).setCellStyle(styleYellow);
+            }
+        }
+        //填充数据
+        int rowIndex = 2;
+        for (TReportYlrq t : list
+        ) {
+            if (rowIndex == 2 || rowIndex == 3 || rowIndex == 4) {
+                sheet.getRow(rowIndex).getCell(0).setCellValue(t.getUseno());
+                sheet.getRow(rowIndex).getCell(1).setCellValue(t.getRegno());
+                sheet.getRow(rowIndex).getCell(2).setCellValue(t.getDevno());
+                sheet.getRow(rowIndex).getCell(3).setCellValue(t.getPj1());
+                sheet.getRow(rowIndex).getCell(4).setCellValue(t.getPj2());
+                sheet.getRow(rowIndex).getCell(5).setCellValue(t.getPj3());
+                sheet.getRow(rowIndex).getCell(6).setCellValue(t.getPj4());
+                sheet.getRow(rowIndex).getCell(7).setCellValue(t.getPj5());
+                sheet.getRow(rowIndex).getCell(8).setCellValue(t.getPj6());
+                sheet.getRow(rowIndex).getCell(9).setCellValue(t.getPj7());
+                sheet.getRow(rowIndex).getCell(10).setCellValue(t.getPj8());
+                sheet.getRow(rowIndex).getCell(11).setCellValue(t.getPj9());
+                sheet.getRow(rowIndex).getCell(12).setCellValue(t.getPj10());
+                sheet.getRow(rowIndex).getCell(13).setCellValue(t.getPj11());
+                sheet.getRow(rowIndex).getCell(14).setCellValue(t.getPj12());
+                sheet.getRow(rowIndex).getCell(15).setCellValue(t.getPj13());
+                sheet.getRow(rowIndex).getCell(16).setCellValue(t.getPj14());
+                sheet.getRow(rowIndex).getCell(17).setCellValue(t.getPj15());
+                sheet.getRow(rowIndex).getCell(18).setCellValue(t.getPj16());
+                sheet.getRow(rowIndex).getCell(19).setCellValue(t.getPj17());
+                sheet.getRow(rowIndex).getCell(20).setCellValue(t.getPj18());
+                sheet.getRow(rowIndex).getCell(21).setCellValue(t.getPj19());
+                sheet.getRow(rowIndex).getCell(22).setCellValue(t.getPj20());
+                sheet.getRow(rowIndex).getCell(23).setCellValue(t.getPj21());
+                sheet.getRow(rowIndex).getCell(24).setCellValue(t.getPj22());
+                sheet.getRow(rowIndex).getCell(25).setCellValue(t.getPj23());
+                sheet.getRow(rowIndex).getCell(26).setCellValue(t.getPj24());
+                sheet.getRow(rowIndex).getCell(27).setCellValue(t.getPj25());
+                sheet.getRow(rowIndex).getCell(28).setCellValue(t.getPj26());
+                sheet.getRow(rowIndex).getCell(29).setCellValue(t.getPj27());
+                sheet.getRow(rowIndex).getCell(30).setCellValue(t.getPj28());
+                sheet.getRow(rowIndex).getCell(31).setCellValue(t.getPj29());
+                sheet.getRow(rowIndex).getCell(32).setCellValue(t.getPj30());
+                sheet.getRow(rowIndex).getCell(33).setCellValue(t.getPj31());
+                sheet.getRow(rowIndex).getCell(34).setCellValue(t.getPj32());
+                sheet.getRow(rowIndex).getCell(35).setCellValue(t.getRemarks());
+                if (t.getCheckDate() != null) {
+                    sheet.getRow(rowIndex).getCell(36).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getCheckDate()));
+                }
+                if (t.getNextCheckDate() != null) {
+                    sheet.getRow(rowIndex).getCell(37).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextCheckDate()));
+                }
+                sheet.getRow(rowIndex).getCell(38).setCellValue(t.getProblem());
+                sheet.getRow(rowIndex).getCell(39).setCellValue(t.getCon());
+            } else {
+                Row row = sheet.createRow(rowIndex);
+                row.createCell(0).setCellValue(t.getUseno());
+                row.createCell(1).setCellValue(t.getRegno());
+                row.createCell(2).setCellValue(t.getDevno());
+                row.createCell(3).setCellValue(t.getPj1());
+                row.createCell(4).setCellValue(t.getPj2());
+                row.createCell(5).setCellValue(t.getPj3());
+                row.createCell(6).setCellValue(t.getPj4());
+                row.createCell(7).setCellValue(t.getPj5());
+                row.createCell(8).setCellValue(t.getPj6());
+                row.createCell(9).setCellValue(t.getPj7());
+                row.createCell(10).setCellValue(t.getPj8());
+                row.createCell(11).setCellValue(t.getPj9());
+                row.createCell(12).setCellValue(t.getPj10());
+                row.createCell(13).setCellValue(t.getPj11());
+                row.createCell(14).setCellValue(t.getPj12());
+                row.createCell(15).setCellValue(t.getPj13());
+                row.createCell(16).setCellValue(t.getPj14());
+                row.createCell(17).setCellValue(t.getPj15());
+                row.createCell(18).setCellValue(t.getPj16());
+                row.createCell(19).setCellValue(t.getPj17());
+                row.createCell(20).setCellValue(t.getPj18());
+                row.createCell(21).setCellValue(t.getPj19());
+                row.createCell(22).setCellValue(t.getPj20());
+                row.createCell(23).setCellValue(t.getPj21());
+                row.createCell(24).setCellValue(t.getPj22());
+                row.createCell(25).setCellValue(t.getPj23());
+                row.createCell(26).setCellValue(t.getPj24());
+                row.createCell(27).setCellValue(t.getPj25());
+                row.createCell(28).setCellValue(t.getPj26());
+                row.createCell(29).setCellValue(t.getPj27());
+                row.createCell(30).setCellValue(t.getPj28());
+                row.createCell(31).setCellValue(t.getPj29());
+                row.createCell(32).setCellValue(t.getPj30());
+                row.createCell(33).setCellValue(t.getPj31());
+                row.createCell(34).setCellValue(t.getPj32());
+                row.createCell(35).setCellValue(t.getRemarks());
+                if (t.getCheckDate() != null) {
+                    row.createCell(36).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getCheckDate()));
+                }
+                if (t.getNextCheckDate() != null) {
+                    row.createCell(37).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextCheckDate()));
+                }
+                row.createCell(38).setCellValue(t.getProblem());
+                row.createCell(39).setCellValue(t.getCon());
+            }
+            rowIndex++;
+        }
+
+        OutputStream out = null;
+        String filename = ExcelUtil.encodingFilename("压力容器年检报告批量更新");
+        out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
+        wb.write(out);
+        wb.close();
+        out.close();
+        return AjaxResult.success(filename);
+    }
+
     /**
      * 同步数据
      */

+ 2 - 1
master/src/main/java/com/ruoyi/project/sems/mapper/TReportYlrqMapper.java

@@ -1,5 +1,6 @@
 package com.ruoyi.project.sems.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScopePlant;
 import com.ruoyi.project.sems.domain.TReportYlrq;
@@ -13,7 +14,7 @@ import java.util.List;
  * @author ruoyi
  * @date 2021-09-02
  */
-public interface TReportYlrqMapper {
+public interface TReportYlrqMapper extends BaseMapper<TReportYlrq> {
 
     /**
      * 插入需要新增的压力管道年检报告

+ 2 - 1
master/src/main/java/com/ruoyi/project/sems/service/ITReportYlrqService.java

@@ -2,6 +2,7 @@ package com.ruoyi.project.sems.service;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.project.sems.domain.TReportYlrq;
 
 /**
@@ -10,7 +11,7 @@ import com.ruoyi.project.sems.domain.TReportYlrq;
  * @author ruoyi
  * @date 2021-09-02
  */
-public interface ITReportYlrqService {
+public interface ITReportYlrqService extends IService<TReportYlrq> {
     /**
      * 插入需要新增的压力管道年检报告
      *

+ 4 - 1
master/src/main/java/com/ruoyi/project/sems/service/impl/TReportYlrqServiceImpl.java

@@ -1,8 +1,11 @@
 package com.ruoyi.project.sems.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.project.sems.domain.TReportYlrq;
+import com.ruoyi.project.sems.domain.TSpecdevCc;
 import com.ruoyi.project.sems.domain.TSpecdevYlrq;
 import com.ruoyi.project.sems.mapper.TReportYlrqMapper;
+import com.ruoyi.project.sems.mapper.TSpecdevCcMapper;
 import com.ruoyi.project.sems.mapper.TSpecdevYlrqMapper;
 import com.ruoyi.project.sems.service.ITReportYlrqService;
 import org.springframework.stereotype.Service;
@@ -19,7 +22,7 @@ import java.util.concurrent.Executors;
  * @date 2021-09-02
  */
 @Service("tReportYlrqService")
-public class TReportYlrqServiceImpl implements ITReportYlrqService {
+public class TReportYlrqServiceImpl extends ServiceImpl<TReportYlrqMapper, TReportYlrq> implements ITReportYlrqService {
     @Resource
     private TReportYlrqMapper tReportYlrqMapper;
 

+ 10 - 0
ui/src/api/sems/reportYlrq.js

@@ -59,3 +59,13 @@ export function exportReportYlrq(query) {
     params: query
   })
 }
+
+// 导出选中设备
+export function exportReportYlrqSelected(query) {
+  return request({
+    url: '/sems/reportYlrq/exportSelected',
+    method: 'get',
+    params: query
+  })
+}
+

+ 44 - 24
ui/src/views/sems/reportYlrq/index.vue

@@ -802,28 +802,36 @@
     </el-dialog>
     <!-- 用户导入对话框 -->
     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
-      <el-upload
-        ref="upload"
-        :limit="1"
-        accept=".xlsx, .xls"
-        :headers="upload.headers"
-        :action="upload.url + '?updateSupport=' + upload.updateSupport"
-        :disabled="upload.isUploading"
-        :on-progress="handleFileUploadProgress"
-        :on-success="handleFileSuccess"
-        :auto-upload="false"
-        drag
-      >
-        <i class="el-icon-upload"></i>
-        <div class="el-upload__text">
-          将文件拖到此处,或
-          <em>点击上传</em>
-        </div>
-        <div class="el-upload__tip" slot="tip">
-          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
-        </div>
-        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
-      </el-upload>
+      <el-form  ref="dateform" label-width="120px">
+        <el-form-item>
+          <span>{{$t('已选择')}} {{dataListSelections.length}}</span>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" :disabled="dataListSelections.length <= 0" @click="downloadDev(2)">{{$t('downloadSelect')}}</el-button>
+        </el-form-item>
+        <el-upload
+          ref="upload"
+          :limit="1"
+          accept=".xlsx, .xls"
+          :headers="upload.headers"
+          :action="upload.url + '?updateSupport=' + upload.updateSupport"
+          :disabled="upload.isUploading"
+          :on-progress="handleFileUploadProgress"
+          :on-success="handleFileSuccess"
+          :auto-upload="false"
+          drag
+        >
+          <i class="el-icon-upload"></i>
+          <div class="el-upload__text">
+            将文件拖到此处,或
+            <em>点击上传</em>
+          </div>
+          <!--<div class="el-upload__tip" slot="tip">-->
+            <!--<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
+          <!--</div>-->
+          <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+        </el-upload>
+      </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitFileForm"
                    v-loading.fullscreen.lock="fullscreenLoading">确 定</el-button>
@@ -930,7 +938,8 @@ import {
   delReportYlrq,
   updateReportYlrq,
   exportReportYlrq,
-  syncReportYlrq
+  syncReportYlrq,
+  exportReportYlrqSelected
 } from "@/api/sems/reportYlrq";
 import {listHistoryYlrq} from "@/api/sems/historyYlrq";
 import {treeselect} from "@/api/system/dept";
@@ -1058,7 +1067,7 @@ export default {
         approveStatus: null,
         devno: null,
         pageNum: 1,
-        pageSize: 50,
+        pageSize: 20,
         orderByColumn:"unit",
         isAsc:"asc",
       },
@@ -1257,6 +1266,17 @@ export default {
     });
   },
   methods: {
+    //导出excel
+    downloadDev(type){
+      var rows = this.dataListSelections.map(item => {
+        return item.id
+      })
+      const queryParams = {ids: null};
+      queryParams.ids = rows.join()
+      exportReportYlrqSelected(queryParams).then(response => {
+        this.download(response.msg);
+      })
+    },
     /** 查询压力容器年检报告列表 */
     getList() {
       this.loading = true;