|
@@ -1,6 +1,9 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
@@ -26,6 +29,7 @@ import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -202,36 +206,83 @@ public class TPssrCleaningController extends BaseController {
|
|
|
CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
|
|
|
for (TPssrCleaning t : list) {
|
|
|
- Row row = sheet.createRow(rowIndex);
|
|
|
- row.setHeight((short) 800);
|
|
|
- row.createCell(0).setCellValue(num);
|
|
|
- row.createCell(1).setCellValue(t.getUnit());
|
|
|
-// row.createCell(2).setCellValue(t.getDevNo());
|
|
|
-// row.createCell(3).setCellValue(t.getSerialNumber());
|
|
|
- row.createCell(2).setCellValue(t.getCheckContent());
|
|
|
- row.createCell(3).setCellValue(t.getCheckResult());
|
|
|
- row.createCell(4);
|
|
|
- row.createCell(5);
|
|
|
- try {
|
|
|
- SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getConfirm1()));
|
|
|
- SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirm2()));
|
|
|
- String confirm1 = sysUser.getSignUrl();
|
|
|
- String confirm2 = sysUser2.getSignUrl();
|
|
|
- ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 4, 1, 1);
|
|
|
- ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 5, 1, 1);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- row.createCell(6).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
- row.createCell(7).setCellValue(t.getRemarks());
|
|
|
-
|
|
|
-
|
|
|
- //渲染样式
|
|
|
- for (int i = 0; i < 8; i++) {
|
|
|
- row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ // 处理检查内容JSON
|
|
|
+ String checkContent = t.getCheckContent();
|
|
|
+ JSONArray objects = JSONObject.parseArray(checkContent);
|
|
|
+ int i = 0;
|
|
|
+ int startRow = 0;
|
|
|
+ for (Object object : objects) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(object.toString());
|
|
|
+ String num1 = jsonObject.get("num").toString();
|
|
|
+ String content = jsonObject.get("content").toString();
|
|
|
+ String result = jsonObject.get("result").toString();
|
|
|
+ if (i == 0) {
|
|
|
+ startRow = rowIndex;
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ row.createCell(0).setCellValue(t.getUnit());
|
|
|
+ row.createCell(1).setCellValue(t.getDevType());
|
|
|
+ row.createCell(2).setCellValue(t.getDevNo());
|
|
|
+ row.createCell(3).setCellValue(num1);
|
|
|
+ row.createCell(4).setCellValue(content);
|
|
|
+ row.createCell(5).setCellValue(result);
|
|
|
+ row.createCell(6);
|
|
|
+ row.createCell(7);
|
|
|
+ try {
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getConfirm1()));
|
|
|
+ SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirm2()));
|
|
|
+ String confirm1 = sysUser.getSignUrl();
|
|
|
+ String confirm2 = sysUser2.getSignUrl();
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 6, 1, 1);
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 7, 1, 1);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ row.createCell(8).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
+ row.createCell(9).setCellValue(t.getRemarks());
|
|
|
+ //渲染样式
|
|
|
+ for (int j = 0; j < 10; j++) {
|
|
|
+ row.getCell(j).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ } else {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ row.createCell(0).setCellValue("");
|
|
|
+ row.createCell(1).setCellValue("");
|
|
|
+ row.createCell(2).setCellValue("");
|
|
|
+ row.createCell(3).setCellValue(num1);
|
|
|
+ row.createCell(4).setCellValue(content);
|
|
|
+ row.createCell(5).setCellValue(result);
|
|
|
+ row.createCell(6).setCellValue("");
|
|
|
+ row.createCell(7).setCellValue("");
|
|
|
+ row.createCell(8).setCellValue("");
|
|
|
+ row.createCell(9).setCellValue("");
|
|
|
+ //渲染样式
|
|
|
+ for (int j = 0; j < 10; j++) {
|
|
|
+ row.getCell(j).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
- num++;
|
|
|
- rowIndex++;
|
|
|
+ // 合并单元格
|
|
|
+ CellRangeAddress cellRangeAddress1 = new CellRangeAddress(startRow, rowIndex - 1, 0, 0);
|
|
|
+ CellRangeAddress cellRangeAddress2 = new CellRangeAddress(startRow, rowIndex - 1, 1, 1);
|
|
|
+ CellRangeAddress cellRangeAddress3 = new CellRangeAddress(startRow, rowIndex - 1, 2, 2);
|
|
|
+ CellRangeAddress cellRangeAddress4 = new CellRangeAddress(startRow, rowIndex - 1, 6, 6);
|
|
|
+ CellRangeAddress cellRangeAddress5 = new CellRangeAddress(startRow, rowIndex - 1, 7, 7);
|
|
|
+ CellRangeAddress cellRangeAddress6 = new CellRangeAddress(startRow, rowIndex - 1, 8, 8);
|
|
|
+ CellRangeAddress cellRangeAddress7 = new CellRangeAddress(startRow, rowIndex - 1, 9, 9);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress1);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress2);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress3);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress4);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress5);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress6);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress7);
|
|
|
}
|
|
|
filename = "PSSR_07_设备清洁_" + UUID.randomUUID().toString() + ".xlsx";
|
|
|
out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|