|
|
@@ -1,25 +1,40 @@
|
|
|
package com.ruoyi.project.ps.inspection.controller;
|
|
|
|
|
|
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.config.RuoYiConfig;
|
|
|
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.common.domain.TCommonfile;
|
|
|
+import com.ruoyi.project.common.service.ITCommonfileService;
|
|
|
import com.ruoyi.project.ps.inspection.domain.TPsInspectionWardrobe;
|
|
|
import com.ruoyi.project.ps.inspection.service.ITPsInspectionWardrobeService;
|
|
|
import com.ruoyi.project.ps.patrol.domain.TPsPatrolIssues;
|
|
|
import com.ruoyi.project.ps.patrol.domain.TPsPatrolPlan;
|
|
|
import com.ruoyi.project.ps.patrol.service.ITPsPatrolIssuesService;
|
|
|
import com.ruoyi.project.ps.patrol.service.ITPsPatrolPlanService;
|
|
|
-import com.ruoyi.project.common.domain.TCommonfile;
|
|
|
-import com.ruoyi.project.common.service.ITCommonfileService;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
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.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 java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -43,6 +58,8 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private ITCommonfileService tCommonfileService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
|
|
/**
|
|
|
* 查询应急物资柜列表
|
|
|
@@ -62,9 +79,13 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
@Log(title = "应急物资柜", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPsInspectionWardrobe tPsInspectionWardrobe) {
|
|
|
+ tPsInspectionWardrobe.setIssuesFlag(0L);
|
|
|
List<TPsInspectionWardrobe> list = tPsInspectionWardrobeService.selectTPsInspectionWardrobeList(tPsInspectionWardrobe);
|
|
|
- ExcelUtil<TPsInspectionWardrobe> util = new ExcelUtil<TPsInspectionWardrobe>(TPsInspectionWardrobe.class);
|
|
|
- return util.exportExcel(list, "wardrobe");
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ return AjaxResult.success(exportTmpl(list));
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error("暂无可导出数据");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -81,7 +102,7 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping(value = "/info")
|
|
|
public AjaxResult getInfoByPpeType(TPsInspectionWardrobe tPsInspectionWardrobe) {
|
|
|
- if (tPsInspectionWardrobe.getId()!=null){
|
|
|
+ if (tPsInspectionWardrobe.getId() != null) {
|
|
|
return AjaxResult.success(tPsInspectionWardrobeService.selectTPsInspectionWardrobeById(tPsInspectionWardrobe.getId()));
|
|
|
}
|
|
|
if (!"PS".equals(tPsInspectionWardrobe.getPlant())) {
|
|
|
@@ -93,9 +114,9 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
TPsInspectionWardrobe item = new TPsInspectionWardrobe();
|
|
|
item.setPlanId(tPsInspectionWardrobe.getPlanId());
|
|
|
item.setPpeType(tPsInspectionWardrobe.getPpeType());
|
|
|
- if (StringUtils.isNotEquals(tPsInspectionWardrobe.getWardrobeType())&&tPsInspectionWardrobe.getWardrobeType().contains("应急物资柜")){
|
|
|
+ if (StringUtils.isNotEquals(tPsInspectionWardrobe.getWardrobeType()) && tPsInspectionWardrobe.getWardrobeType().contains("应急物资柜")) {
|
|
|
item.setWardrobeType(tPsInspectionWardrobe.getPpeType().replace("应急物资柜", "").trim());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return AjaxResult.error("未知的应急物资柜类型!请联系管理员!");
|
|
|
}
|
|
|
item.setIssuesFlag(0L);
|
|
|
@@ -224,4 +245,139 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(tPsInspectionWardrobeService.deleteTPsInspectionWardrobeByIds(ids));
|
|
|
}
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPsInspectionWardrobe> list) {
|
|
|
+ OutputStream out;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = RuoYiConfig.getFilePath("/tempDoc/ps/wardrobe.xlsx");
|
|
|
+ InputStream is = Files.newInputStream(Paths.get(tempUrl));
|
|
|
+ XSSFWorkbook wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+ int rowIndex = 6;
|
|
|
+ int num = 1;
|
|
|
+ String dateStr = "";
|
|
|
+ String confirmerSignUrl = "";
|
|
|
+ Row row6 = sheet.getRow(rowIndex);
|
|
|
+ Cell originalcell = row6.getCell(0);
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ TPsInspectionWardrobe wardrobe = list.get(0);
|
|
|
+ TPsPatrolPlan plan = tPsPatrolPlanService.selectTPsPatrolPlanById(wardrobe.getPlanId());
|
|
|
+ dateStr = "_" + plan.getPlanYear() + "年_" + plan.getPlanMonth() + "月_";
|
|
|
+
|
|
|
+ Row row3 = sheet.getRow(3);
|
|
|
+ row3.getCell(0).setCellValue("年度:" + plan.getPlanYear() + " 年");
|
|
|
+
|
|
|
+ String r5c7Str = "检查时间: 月 日";
|
|
|
+ if (plan.getConfirmDate() != null && StringUtils.isNotEmpty(plan.getConfirmed())) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(plan.getConfirmDate());
|
|
|
+ r5c7Str = "检查时间:" + (calendar.get(Calendar.MONTH) + 1) + "月 " + calendar.get(Calendar.DAY_OF_MONTH) + "日";
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(plan.getConfirmed()));
|
|
|
+ confirmerSignUrl = sysUser.getSignUrl();
|
|
|
+ }
|
|
|
+ Row row5 = sheet.getRow(4);
|
|
|
+ row5.getCell(6).setCellValue(r5c7Str);
|
|
|
+
|
|
|
+ for (TPsInspectionWardrobe item : list) {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 300);
|
|
|
+ row.createCell(0).setCellValue(num);
|
|
|
+ row.createCell(1).setCellValue(item.getPpeType());
|
|
|
+ row.createCell(2).setCellValue("1".equals(item.getComplete()) ? "✓" : item.getComplete());
|
|
|
+ row.createCell(3).setCellValue("1".equals(item.getIntact()) ? "✓" : item.getIntact());
|
|
|
+ row.createCell(4).setCellValue("1".equals(item.getPlacement()) ? "✓" : item.getPlacement());
|
|
|
+ row.createCell(5).setCellValue("1".equals(item.getValidity()) ? "✓" : item.getValidity());
|
|
|
+ row.createCell(6).setCellValue("1".equals(item.getInspectiontag()) ? "✓" : item.getInspectiontag());
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 检查人行
|
|
|
+ Row confirmerRow = sheet.createRow(rowIndex);
|
|
|
+ confirmerRow.setHeight((short) 800);
|
|
|
+ confirmerRow.createCell(0).setCellValue("检查人");
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ confirmerRow.createCell(i);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(confirmerSignUrl))
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirmerSignUrl, rowIndex, 3, 1, 1);
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
|
+ confirmerRow.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 2));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 3, 6));
|
|
|
+
|
|
|
+ // 说明
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow1 = sheet.createRow(rowIndex);
|
|
|
+ explanationRow1.setHeight((short) 300);
|
|
|
+ explanationRow1.createCell(0).setCellValue("说明");
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow1.createCell(i);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow2 = sheet.createRow(rowIndex);
|
|
|
+ explanationRow2.setHeight((short) 300);
|
|
|
+ explanationRow2.createCell(0).setCellValue("1.「是否无缺失」参照物品存放清单的数量。如果无缺失选择「是」;如果缺失则选择「否」。");
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow2.createCell(i);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow3 = sheet.createRow(rowIndex);
|
|
|
+ explanationRow3.setHeight((short) 300);
|
|
|
+ explanationRow3.createCell(0).setCellValue("2.「摆放符合要求」参见图例。");
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow3.createCell(i);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow4 = sheet.createRow(rowIndex);
|
|
|
+ CellStyle wrapStyle = wb.createCellStyle();
|
|
|
+ wrapStyle.setWrapText(true);
|
|
|
+ Cell explanationCell4 = explanationRow4.createCell(0);
|
|
|
+ explanationCell4.setCellValue("3.未污染无破损的MC5000连体防化服、Ansell 38-628氟橡胶手套有效期为五年;防化靴有效期为五年;未使用的滤罐有效期都标在滤毒罐上。应急物资柜储存的滤罐规定为一次性使用,拆封使用后即作为危废处理。");
|
|
|
+ explanationCell4.setCellStyle(wrapStyle);
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow4.createCell(i).setCellStyle(wrapStyle);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow5 = sheet.createRow(rowIndex);
|
|
|
+ Cell explanationCell5 = explanationRow5.createCell(0);
|
|
|
+ explanationCell5.setCellValue("4.安全带、MC5000连体防化服、3S standard全面罩必须贴有在效期内检验合格的标识。MC5000连体防化服为一次性使用,拆封使用后即作为危废处理。");
|
|
|
+ explanationCell5.setCellStyle(wrapStyle);
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow5.createCell(i).setCellStyle(wrapStyle);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ rowIndex++;
|
|
|
+ Row explanationRow6 = sheet.createRow(rowIndex);
|
|
|
+ explanationRow6.setHeight((short) 300);
|
|
|
+ explanationRow6.createCell(0).setCellValue("5.检查发现其他异常,填写在「备注」栏,检查结果出现「否」,检查人应对不符合项目立即整改。");
|
|
|
+ for (int i = 1; i < 7; i++) {
|
|
|
+ explanationRow6.createCell(i);
|
|
|
+ }
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 6));
|
|
|
+
|
|
|
+ filename = "_应急物资柜" + dateStr + "检查记录.xlsx";
|
|
|
+ out = Files.newOutputStream(Paths.get(ExcelUtil.getAbsoluteFile(filename)));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
+ }
|
|
|
}
|