|
@@ -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.TReportYlrq;
|
|
|
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,236 @@ public class TReportYlgdController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITReportThirdService itReportYlrqThirdService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出选中设备
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @GetMapping("/exportSelected")
|
|
|
+ public AjaxResult exportSelected(ParamData params) throws IOException {
|
|
|
+ logger.info(JSON.toJSONString(params));
|
|
|
+ String id = params.getIds();
|
|
|
+ String[] ids = id.split(",");
|
|
|
+ List<TReportYlgd> list = new ArrayList<>();
|
|
|
+ for (String i : ids
|
|
|
+ ) {
|
|
|
+ TReportYlgd reportYlrqEntity = tReportYlgdService.selectTReportYlgdById(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 == 20 || i == 21 || i ==22 || i == 23 || i == 24 || i == 25) {
|
|
|
+ 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("1");
|
|
|
+ row0.createCell(4).setCellValue("2");
|
|
|
+ row0.createCell(5).setCellValue("3");
|
|
|
+ row0.createCell(6).setCellValue("4");
|
|
|
+ row0.createCell(7).setCellValue("5");
|
|
|
+ row0.createCell(8).setCellValue("安全附件仪表及检查情况");
|
|
|
+ row0.createCell(9);
|
|
|
+ row0.createCell(10);
|
|
|
+ row0.createCell(11);
|
|
|
+ row0.createCell(12);
|
|
|
+ row0.createCell(13);
|
|
|
+ row0.createCell(14).setCellValue("12");
|
|
|
+ row0.createCell(15).setCellValue("13");
|
|
|
+ row0.createCell(16).setCellValue("14");
|
|
|
+ row0.createCell(17).setCellValue("15");
|
|
|
+ row0.createCell(18).setCellValue("16");
|
|
|
+ row0.createCell(19).setCellValue("17");
|
|
|
+ row0.createCell(20).setCellValue("备注");
|
|
|
+ row0.createCell(21).setCellValue("检查日期");
|
|
|
+ row0.createCell(22).setCellValue("下次年度检查日期");
|
|
|
+ row0.createCell(23).setCellValue("问题及处理");
|
|
|
+ row0.createCell(24).setCellValue("检查结论");
|
|
|
+ row0.createCell(25).setCellValue("检查结论备注");
|
|
|
+ Row row1 = sheet.createRow(1);
|
|
|
+ row1.createCell(0);
|
|
|
+ row1.createCell(1);
|
|
|
+ row1.createCell(2);
|
|
|
+ row1.createCell(3);
|
|
|
+ row1.createCell(4);
|
|
|
+ row1.createCell(5);
|
|
|
+ row1.createCell(6);
|
|
|
+ row1.createCell(7);
|
|
|
+ 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);
|
|
|
+ row1.createCell(15);
|
|
|
+ row1.createCell(16);
|
|
|
+ row1.createCell(17);
|
|
|
+ row1.createCell(18);
|
|
|
+ row1.createCell(19);
|
|
|
+ row1.createCell(20);
|
|
|
+ row1.createCell(21);
|
|
|
+ row1.createCell(22);
|
|
|
+ row1.createCell(23);
|
|
|
+ row1.createCell(24);
|
|
|
+ row1.createCell(25);
|
|
|
+ Row row2 = sheet.createRow(2);
|
|
|
+ for (int i = 0; i < 26; i++) {
|
|
|
+ row2.createCell(i);
|
|
|
+ if (i == 25) row2.createCell(i).setCellValue("1:符合要求");
|
|
|
+ }
|
|
|
+ Row row3 = sheet.createRow(3);
|
|
|
+ for (int i = 0; i < 26; i++) {
|
|
|
+ row3.createCell(i);
|
|
|
+ if (i == 25) row3.createCell(i).setCellValue("2:基本符合要求");
|
|
|
+ }
|
|
|
+ Row row4 = sheet.createRow(4);
|
|
|
+ for (int i = 0; i < 26; i++) {
|
|
|
+ row4.createCell(i);
|
|
|
+ if (i == 25) 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,1,3,3));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,4,4));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,5,5));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,6,6));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,7,7));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,0,8,13));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,14,14));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,15,15));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,16,16));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,17,17));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,18,18));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,19,19));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,20,20));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,21,21));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,22,22));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,23,23));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,24,24));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,25,25));
|
|
|
+ // 表头样式
|
|
|
+ for (int i = 0; i < 25; 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 (TReportYlgd 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.getRemarks());
|
|
|
+ if (t.getCheckDate() != null) {
|
|
|
+ sheet.getRow(rowIndex).getCell(21).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getCheckDate()));
|
|
|
+ }
|
|
|
+ if (t.getNextCheckDate() != null) {
|
|
|
+ sheet.getRow(rowIndex).getCell(22).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextCheckDate()));
|
|
|
+ }
|
|
|
+ sheet.getRow(rowIndex).getCell(23).setCellValue(t.getProblem());
|
|
|
+ sheet.getRow(rowIndex).getCell(24).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.getRemarks());
|
|
|
+ if (t.getCheckDate() != null) {
|
|
|
+ row.createCell(21).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getCheckDate()));
|
|
|
+ }
|
|
|
+ if (t.getNextCheckDate() != null) {
|
|
|
+ row.createCell(22).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextCheckDate()));
|
|
|
+ }
|
|
|
+ row.createCell(23).setCellValue(t.getProblem());
|
|
|
+ row.createCell(24).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);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 同步数据
|