|
@@ -1,7 +1,9 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+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;
|
|
@@ -10,6 +12,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.pssr.domain.TPssrApprove;
|
|
|
import com.ruoyi.project.pssr.domain.TPssrPipe;
|
|
|
+import com.ruoyi.project.pssr.domain.TPssrPipe;
|
|
|
import com.ruoyi.project.pssr.domain.TPssrSubcontent;
|
|
|
import com.ruoyi.project.pssr.mapper.TPssrPipeMapper;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
@@ -18,15 +21,26 @@ import com.ruoyi.project.pssr.service.ITPssrPipeService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
|
|
|
import com.ruoyi.project.sems.domain.TSpecdevYlgd;
|
|
|
import com.ruoyi.project.sems.mapper.TSpecdevYlgdMapper;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
import org.activiti.engine.HistoryService;
|
|
|
import org.activiti.engine.RuntimeService;
|
|
|
import org.activiti.engine.impl.identity.Authentication;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
+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 javax.annotation.Resource;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -59,6 +73,9 @@ public class TPssrPipeController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITPssrSubcontentService tPssrSubcontentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询管道列表
|
|
|
*/
|
|
@@ -119,8 +136,70 @@ public class TPssrPipeController extends BaseController {
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPssrPipe tPssrPipe) {
|
|
|
List<TPssrPipe> list = tPssrPipeService.selectTPssrPipeList(tPssrPipe);
|
|
|
- ExcelUtil<TPssrPipe> util = new ExcelUtil<TPssrPipe>(TPssrPipe.class);
|
|
|
- return util.exportExcel(list, "pipe");
|
|
|
+ return AjaxResult.success(exportTmpl(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPssrPipe> list) {
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = "static/word/pssr/ylgd.xlsx"; // 模板文件
|
|
|
+ InputStream is = null;
|
|
|
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
|
+ XSSFWorkbook wb = null;
|
|
|
+ wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+
|
|
|
+ //填充数据
|
|
|
+ int rowIndex = 4;
|
|
|
+ int num = 1;
|
|
|
+
|
|
|
+ Row originalRow = sheet.getRow(4);
|
|
|
+ Cell originalcell = originalRow.getCell(0);
|
|
|
+ // 获取单元格样式
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+
|
|
|
+ for (TPssrPipe 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.getPipelineName());
|
|
|
+ row.createCell(3).setCellValue(t.getPipelineNo());
|
|
|
+ row.createCell(4).setCellValue(t.getChecked());
|
|
|
+ row.createCell(5).setCellValue(t.getRequire());
|
|
|
+ row.createCell(6).setCellValue(t.getValidity());
|
|
|
+ row.createCell(7);
|
|
|
+ row.createCell(8);
|
|
|
+ try {
|
|
|
+ SysUser sysUser1 = sysUserService.selectUserById(Long.valueOf(t.getConfirmer1()));
|
|
|
+ SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirmer2()));
|
|
|
+ String confirm1 = sysUser1.getSignUrl();
|
|
|
+ String confirm2 = sysUser2.getSignUrl();
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 7, 1, 1);
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 8, 1, 1);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ row.createCell(9).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
+ row.createCell(10).setCellValue(t.getRemarks());
|
|
|
+
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 11; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ filename = ExcelUtil.encodingFilename("Pipe");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
}
|
|
|
|
|
|
/**
|