|
@@ -1,15 +1,28 @@
|
|
package com.ruoyi.project.pssr.controller;
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.io.OutputStream;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
import com.ruoyi.project.pssr.domain.*;
|
|
import com.ruoyi.project.pssr.domain.*;
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
import com.ruoyi.project.pssr.service.ITPssrBlindService;
|
|
import com.ruoyi.project.pssr.service.ITPssrBlindService;
|
|
import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
|
|
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.ProcessEngine;
|
|
import org.activiti.engine.ProcessEngines;
|
|
import org.activiti.engine.ProcessEngines;
|
|
import org.activiti.engine.TaskService;
|
|
import org.activiti.engine.TaskService;
|
|
import org.activiti.engine.task.Task;
|
|
import org.activiti.engine.task.Task;
|
|
|
|
+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.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -51,6 +64,9 @@ public class TPssrTorchvocController extends BaseController
|
|
@Autowired
|
|
@Autowired
|
|
private ITPssrBlindService tPssrBlindService;
|
|
private ITPssrBlindService tPssrBlindService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询火炬,VOC系统列表
|
|
* 查询火炬,VOC系统列表
|
|
*/
|
|
*/
|
|
@@ -72,8 +88,71 @@ public class TPssrTorchvocController extends BaseController
|
|
public AjaxResult export(TPssrTorchvoc tPssrTorchvoc)
|
|
public AjaxResult export(TPssrTorchvoc tPssrTorchvoc)
|
|
{
|
|
{
|
|
List<TPssrTorchvoc> list = tPssrTorchvocService.selectTPssrTorchvocList(tPssrTorchvoc);
|
|
List<TPssrTorchvoc> list = tPssrTorchvocService.selectTPssrTorchvocList(tPssrTorchvoc);
|
|
- ExcelUtil<TPssrTorchvoc> util = new ExcelUtil<TPssrTorchvoc>(TPssrTorchvoc.class);
|
|
|
|
- return util.exportExcel(list, "torchvoc");
|
|
|
|
|
|
+ return AjaxResult.success(exportTmpl(list, tPssrTorchvoc.getTorchvocType()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String exportTmpl(List<TPssrTorchvoc> list, String torchvocType) {
|
|
|
|
+ OutputStream out = null;
|
|
|
|
+ String filename = null;
|
|
|
|
+ try {
|
|
|
|
+ String tempUrl = ""; // 模板文件
|
|
|
|
+ if ("1".equals(torchvocType)) {
|
|
|
|
+ tempUrl = "static/word/pssr/hbsshj.xlsx";
|
|
|
|
+ } else {
|
|
|
|
+ tempUrl = "static/word/pssr/hbssvoc.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 (TPssrTorchvoc t : list) {
|
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
|
+ row.setHeight((short) 800);
|
|
|
|
+ row.createCell(0).setCellValue(num);
|
|
|
|
+ row.createCell(1).setCellValue(t.getContent());
|
|
|
|
+ row.createCell(2).setCellValue(t.getProcedureStatus());
|
|
|
|
+ row.createCell(3);
|
|
|
|
+ row.createCell(4);
|
|
|
|
+ try {
|
|
|
|
+ SysUser sysUser1 = sysUserService.selectUserById(Long.valueOf(t.getConfirm1()));
|
|
|
|
+ SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirm2()));
|
|
|
|
+ String confirm1 = sysUser1.getSignUrl();
|
|
|
|
+ String confirm2 = sysUser2.getSignUrl();
|
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 3, 1, 1);
|
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 4, 1, 1);
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ row.createCell(5).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
|
+ row.createCell(6).setCellValue(t.getRemarks());
|
|
|
|
+
|
|
|
|
+ //渲染样式
|
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
|
+ }
|
|
|
|
+ num++;
|
|
|
|
+ rowIndex++;
|
|
|
|
+ }
|
|
|
|
+ filename = ExcelUtil.encodingFilename("Torchvoc");
|
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
|
+ wb.write(out);
|
|
|
|
+ wb.close();
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return filename;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|