|
@@ -1,29 +1,40 @@
|
|
|
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;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
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.*;
|
|
|
import com.ruoyi.project.pssr.domain.TPssrMaterial;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrSubcontent;
|
|
|
import com.ruoyi.project.pssr.mapper.TPssrMaterialMapper;
|
|
|
-import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
|
-import com.ruoyi.project.pssr.service.ITPssrFileService;
|
|
|
-import com.ruoyi.project.pssr.service.ITPssrMaterialService;
|
|
|
-import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
|
|
|
+import com.ruoyi.project.pssr.service.*;
|
|
|
+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.HorizontalAlignment;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+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;
|
|
|
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.*;
|
|
|
|
|
|
/**
|
|
@@ -54,6 +65,13 @@ public class TPssrMaterialController extends BaseController {
|
|
|
@Resource
|
|
|
private TPssrMaterialMapper tPssrMaterialMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITPssrMaterialRawService tPssrMaterialRawService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询原料列表
|
|
|
*/
|
|
@@ -75,9 +93,161 @@ public class TPssrMaterialController extends BaseController {
|
|
|
@Log(title = "原料", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPssrMaterial tPssrMaterial) {
|
|
|
- List<TPssrMaterial> list = tPssrMaterialService.selectTPssrMaterialList(tPssrMaterial);
|
|
|
- ExcelUtil<TPssrMaterial> util = new ExcelUtil<TPssrMaterial>(TPssrMaterial.class);
|
|
|
- return util.exportExcel(list, "material");
|
|
|
+ List<TPssrMaterial> list1 = tPssrMaterialService.selectTPssrMaterialList(tPssrMaterial);
|
|
|
+ TPssrMaterialRaw materialRaw = new TPssrMaterialRaw();
|
|
|
+ materialRaw.setSubId(tPssrMaterial.getSubId());
|
|
|
+ List<TPssrMaterialRaw> list2 = tPssrMaterialRawService.selectTPssrMaterialRawList(materialRaw);
|
|
|
+ return AjaxResult.success(exportTmpl(list1, list2));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPssrMaterial> list1, List<TPssrMaterialRaw> list2) {
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = "static/word/pssr/yfl.xlsx"; // 模板文件
|
|
|
+ InputStream is = null;
|
|
|
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
|
+ XSSFWorkbook wb = null;
|
|
|
+ wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+
|
|
|
+ // Cracker commissioning material quantity
|
|
|
+ // 填充数据
|
|
|
+ int rowIndex = 3;
|
|
|
+ int num = 1;
|
|
|
+ Row originalRow = sheet.getRow(3);
|
|
|
+ Cell originalcell = originalRow.getCell(0);
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+ for (TPssrMaterial t : list1) {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ row.createCell(0).setCellValue(num);
|
|
|
+ row.createCell(1).setCellValue(t.getUtilityQuantity());
|
|
|
+ row.createCell(2).setCellValue(t.getQuantity());
|
|
|
+ row.createCell(3).setCellValue(t.getUnit());
|
|
|
+ row.createCell(4).setCellValue(t.getNote());
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Raw materials
|
|
|
+ // 标题
|
|
|
+ Row row = sheet.getRow(1);
|
|
|
+ Cell cell = row.getCell(0);
|
|
|
+ CellStyle style = cell.getCellStyle();
|
|
|
+ Row title = sheet.createRow(rowIndex);
|
|
|
+ title.setHeight((short) 800);
|
|
|
+ title.createCell(0).setCellValue("Raw materials");
|
|
|
+ title.createCell(1);
|
|
|
+ title.createCell(2);
|
|
|
+ title.createCell(3);
|
|
|
+ title.createCell(4);
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title.getCell(i).setCellStyle(style);
|
|
|
+ }
|
|
|
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(rowIndex, rowIndex, 0, 4);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress);
|
|
|
+ rowIndex++;
|
|
|
+
|
|
|
+ Row row1 = sheet.getRow(2);
|
|
|
+ Cell cell1 = row1.getCell(0);
|
|
|
+ CellStyle style1 = cell1.getCellStyle();
|
|
|
+ Row title1 = sheet.createRow(rowIndex);
|
|
|
+ title1.setHeight((short) 800);
|
|
|
+ title1.createCell(0).setCellValue("NO.");
|
|
|
+ title1.createCell(1).setCellValue("Raw materials");
|
|
|
+ title1.createCell(2).setCellValue("Quantity");
|
|
|
+ title1.createCell(3).setCellValue("Unit");
|
|
|
+ title1.createCell(4).setCellValue("Note");
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title1.getCell(i).setCellStyle(style1);
|
|
|
+ }
|
|
|
+ rowIndex++;
|
|
|
+
|
|
|
+ // 填充数据
|
|
|
+ num = 1;
|
|
|
+ for (TPssrMaterialRaw t2 : list2) {
|
|
|
+ Row row2 = sheet.createRow(rowIndex);
|
|
|
+ row2.setHeight((short) 800);
|
|
|
+ row2.createCell(0).setCellValue(num);
|
|
|
+ row2.createCell(1).setCellValue(t2.getRawMaterial());
|
|
|
+ row2.createCell(2).setCellValue(t2.getQuantity());
|
|
|
+ row2.createCell(3).setCellValue(t2.getUnit());
|
|
|
+ row2.createCell(4).setCellValue(t2.getNote());
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ row2.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 备注
|
|
|
+ Row title2 = sheet.createRow(rowIndex);
|
|
|
+ title2.setHeight((short) 800);
|
|
|
+ title2.createCell(0).setCellValue("1. 以上蒸汽裂解装置开车时所需要的物料经确认全部都已获得或具备获得条件,确认人签字。");
|
|
|
+ title2.createCell(1);
|
|
|
+ title2.createCell(2);
|
|
|
+ title2.createCell(3);
|
|
|
+ title2.createCell(4);
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title2.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ CellRangeAddress cellRangeAddress1 = new CellRangeAddress(rowIndex, rowIndex, 0, 4);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress1);
|
|
|
+ rowIndex++;
|
|
|
+ Row title3 = sheet.createRow(rowIndex);
|
|
|
+ title3.setHeight((short) 800);
|
|
|
+ title3.createCell(0).setCellValue("2. 如果某些物料没有获得或不具备获得条件,请及时联系相关责任人按要求进行整改。");
|
|
|
+ title3.createCell(1);
|
|
|
+ title3.createCell(2);
|
|
|
+ title3.createCell(3);
|
|
|
+ title3.createCell(4);
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title3.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ CellRangeAddress cellRangeAddress2 = new CellRangeAddress(rowIndex, rowIndex, 0, 4);
|
|
|
+ sheet.addMergedRegion(cellRangeAddress2);
|
|
|
+ rowIndex++;
|
|
|
+
|
|
|
+ // 确认人
|
|
|
+ Row title4 = sheet.createRow(rowIndex);
|
|
|
+ title4.setHeight((short) 800);
|
|
|
+ title4.createCell(0);
|
|
|
+ title4.createCell(1);
|
|
|
+ title4.createCell(2);
|
|
|
+ title4.createCell(3);
|
|
|
+ title4.createCell(4).setCellValue("确认人:");
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title4.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ rowIndex++;
|
|
|
+
|
|
|
+ // 确认时间
|
|
|
+ Row title5 = sheet.createRow(rowIndex);
|
|
|
+ title5.setHeight((short) 800);
|
|
|
+ title5.createCell(0);
|
|
|
+ title5.createCell(1);
|
|
|
+ title5.createCell(2);
|
|
|
+ title5.createCell(3);
|
|
|
+ title5.createCell(4).setCellValue("确认时间:");
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ title5.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ rowIndex++;
|
|
|
+
|
|
|
+ filename = ExcelUtil.encodingFilename("Material");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
}
|
|
|
|
|
|
/**
|