|
@@ -1,6 +1,8 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
@@ -16,15 +18,26 @@ import com.ruoyi.project.pssr.service.ITPssrAboveallService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrLockService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
import org.activiti.engine.ProcessEngine;
|
|
|
import org.activiti.engine.ProcessEngines;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
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.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+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 java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -51,6 +64,9 @@ public class TPssrLockController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITApplyLockService tApplyLockService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询锁开锁关阀门状态列表
|
|
|
*/
|
|
@@ -68,10 +84,82 @@ public class TPssrLockController extends BaseController {
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:lock:export')")
|
|
|
@Log(title = "锁开锁关阀门状态", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(TPssrLock tPssrLock) {
|
|
|
+ public AjaxResult export(TPssrLock tPssrLock)
|
|
|
+ {
|
|
|
List<TPssrLock> list = tPssrLockService.selectTPssrLockList(tPssrLock);
|
|
|
- ExcelUtil<TPssrLock> util = new ExcelUtil<TPssrLock>(TPssrLock.class);
|
|
|
- return util.exportExcel(list, "lock");
|
|
|
+ return AjaxResult.success(exportTmpl(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPssrLock> list) {
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = "static/word/pssr/sksgfmzt.xlsx"; // 模板文件
|
|
|
+ InputStream is = null;
|
|
|
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
|
+ XSSFWorkbook wb = null;
|
|
|
+ wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+
|
|
|
+ //填充数据
|
|
|
+ int rowIndex = 3;
|
|
|
+ int num = 1;
|
|
|
+
|
|
|
+ Row originalRow = sheet.getRow(3);
|
|
|
+ Cell originalcell = originalRow.getCell(0);
|
|
|
+ // 获取单元格样式
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+
|
|
|
+ for (TPssrLock 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.getLockPost());
|
|
|
+ row.createCell(3).setCellValue(t.getPidNo());
|
|
|
+ row.createCell(4).setCellValue(t.getLockCode());
|
|
|
+ row.createCell(5).setCellValue(t.getMedium());
|
|
|
+ row.createCell(6).setCellValue(t.getPosition());
|
|
|
+ row.createCell(7).setCellValue(t.getRiskLevel());
|
|
|
+ row.createCell(8).setCellValue(t.getLockSize());
|
|
|
+ row.createCell(9).setCellValue(t.getPidStatus());
|
|
|
+ row.createCell(10).setCellValue(t.getPositionRight());
|
|
|
+ row.createCell(11).setCellValue(t.getStatusRight());
|
|
|
+ row.createCell(12).setCellValue(t.getCodeAccord());
|
|
|
+ row.createCell(13).setCellValue(t.getFastening());
|
|
|
+ row.createCell(14).setCellValue(t.getNoDamage());
|
|
|
+ row.createCell(15);
|
|
|
+ row.createCell(16);
|
|
|
+ try {
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getLockeder()));
|
|
|
+ SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirm()));
|
|
|
+ String confirm1 = sysUser.getSignUrl();
|
|
|
+ String confirm2= sysUser2.getSignUrl();
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 15, 1, 1);
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 16, 1, 1);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ row.createCell(17).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
+ row.createCell(18).setCellValue(t.getRemarks());
|
|
|
+
|
|
|
+
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 19; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ filename = ExcelUtil.encodingFilename("Lock");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
}
|
|
|
|
|
|
/**
|