|
@@ -1,6 +1,8 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+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;
|
|
@@ -12,6 +14,8 @@ import com.ruoyi.project.pssr.domain.TPssrOverhaulExchanger;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrOverhaulExchangerService;
|
|
|
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.*;
|
|
|
import org.activiti.engine.impl.identity.Authentication;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
@@ -20,14 +24,17 @@ import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
+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 javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -54,6 +61,8 @@ public class TPssrOverhaulExchangerController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITPssrSubcontentService tPssrSubcontentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
|
|
/**
|
|
|
* 查询检修项目-换热器列表
|
|
@@ -77,8 +86,64 @@ public class TPssrOverhaulExchangerController extends BaseController {
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPssrOverhaulExchanger tPssrOverhaulExchanger) {
|
|
|
List<TPssrOverhaulExchanger> list = tPssrOverhaulExchangerService.selectTPssrOverhaulExchangerList(tPssrOverhaulExchanger);
|
|
|
- ExcelUtil<TPssrOverhaulExchanger> util = new ExcelUtil<TPssrOverhaulExchanger>(TPssrOverhaulExchanger.class);
|
|
|
- return util.exportExcel(list, "overhaulExchanger");
|
|
|
+ return AjaxResult.success(exportTmpl(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPssrOverhaulExchanger> list) {
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = "static/word/pssr/jxxmhrq.xlsx"; // 模板文件
|
|
|
+ InputStream is = null;
|
|
|
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
|
+ XSSFWorkbook wb = null;
|
|
|
+ wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+
|
|
|
+ //填充数据
|
|
|
+ int rowIndex = 2;
|
|
|
+ int num = 1;
|
|
|
+
|
|
|
+ Row originalRow = sheet.getRow(2);
|
|
|
+ Cell originalcell = originalRow.getCell(0);
|
|
|
+ // 获取单元格样式
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+
|
|
|
+ for (TPssrOverhaulExchanger t : list) {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ row.createCell(0).setCellValue(num);
|
|
|
+ row.createCell(1).setCellValue(t.getTagNo());
|
|
|
+ row.createCell(2).setCellValue(t.getEquipmentName());
|
|
|
+ row.createCell(3).setCellValue(t.getWorkDes());
|
|
|
+ row.createCell(4).setCellValue(t.getPidNo());
|
|
|
+ row.createCell(5).setCellValue(DateUtils.dateTime(t.getCompletionDate()));
|
|
|
+ row.createCell(6);
|
|
|
+ try {
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getConfirmedPerson()));
|
|
|
+ String confirm1 = sysUser.getSignUrl();
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 6, 1, 1);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ row.createCell(7).setCellValue(t.getRemarks());
|
|
|
+
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ filename = ExcelUtil.encodingFilename("OverhaulExchanger");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
}
|
|
|
|
|
|
/**
|