|
|
@@ -20,10 +20,7 @@ import com.ruoyi.project.ps.patrol.service.ITPsPatrolPlanService;
|
|
|
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;
|
|
|
@@ -80,12 +77,8 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPsInspectionWardrobe tPsInspectionWardrobe) {
|
|
|
tPsInspectionWardrobe.setIssuesFlag(0L);
|
|
|
- List<TPsInspectionWardrobe> list = tPsInspectionWardrobeService.selectTPsInspectionWardrobeList(tPsInspectionWardrobe);
|
|
|
- if (!list.isEmpty()) {
|
|
|
- return AjaxResult.success(exportTmpl(list));
|
|
|
- } else {
|
|
|
- return AjaxResult.error("暂无可导出数据");
|
|
|
- }
|
|
|
+ return AjaxResult.success(exportTmpl(tPsInspectionWardrobe));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -246,132 +239,22 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
return toAjax(tPsInspectionWardrobeService.deleteTPsInspectionWardrobeByIds(ids));
|
|
|
}
|
|
|
|
|
|
- public String exportTmpl(List<TPsInspectionWardrobe> list) {
|
|
|
+ public String exportTmpl(TPsInspectionWardrobe tPsInspectionWardrobe) {
|
|
|
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";
|
|
|
+ StringBuilder dateStrBuilder = new StringBuilder();
|
|
|
+
|
|
|
+ exportSheet(wb, 0, "1", tPsInspectionWardrobe, dateStrBuilder, 21);
|
|
|
+ exportSheet(wb, 1, "2", tPsInspectionWardrobe, dateStrBuilder, 23);
|
|
|
+ exportSheet(wb, 2, "3", tPsInspectionWardrobe, dateStrBuilder, 22);
|
|
|
+ exportSheet(wb, 3, "4", tPsInspectionWardrobe, dateStrBuilder, 22);
|
|
|
+
|
|
|
+ filename = "_应急物资柜" + dateStrBuilder.toString() + "检查记录.xlsx";
|
|
|
out = Files.newOutputStream(Paths.get(ExcelUtil.getAbsoluteFile(filename)));
|
|
|
wb.write(out);
|
|
|
wb.close();
|
|
|
@@ -380,4 +263,45 @@ public class TPsInspectionWardrobeController extends BaseController {
|
|
|
}
|
|
|
return filename;
|
|
|
}
|
|
|
+
|
|
|
+ private void exportSheet(XSSFWorkbook wb, int sheetIndex, String wardrobeType, TPsInspectionWardrobe tPsInspectionWardrobe, StringBuilder dateStrBuilder, int confirmerRowIndex) throws Exception {
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(sheetIndex);
|
|
|
+ int rowIndex = 4;
|
|
|
+ tPsInspectionWardrobe.setWardrobeType(wardrobeType);
|
|
|
+ List<TPsInspectionWardrobe> list = tPsInspectionWardrobeService.selectTPsInspectionWardrobeList(tPsInspectionWardrobe);
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ TPsInspectionWardrobe wardrobe = list.get(0);
|
|
|
+ TPsPatrolPlan plan = tPsPatrolPlanService.selectTPsPatrolPlanById(wardrobe.getPlanId());
|
|
|
+
|
|
|
+ String r5c7Str = "检查日期: 月 日";
|
|
|
+ String confirmerSignUrl = "";
|
|
|
+ if (plan.getConfirmDate() != null && StringUtils.isNotEmpty(plan.getConfirmed())) {
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(plan.getConfirmed()));
|
|
|
+ confirmerSignUrl = sysUser.getSignUrl();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(plan.getConfirmDate());
|
|
|
+ r5c7Str = "检查日期:" + (calendar.get(Calendar.MONTH) + 1) + "月 " + calendar.get(Calendar.DAY_OF_MONTH) + "日";
|
|
|
+
|
|
|
+ if (dateStrBuilder.length() == 0) {
|
|
|
+ dateStrBuilder.append("_").append(plan.getPlanYear()).append("年_").append(plan.getPlanMonth()).append("月_");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (TPsInspectionWardrobe item : list) {
|
|
|
+ Row row = sheet.getRow(rowIndex);
|
|
|
+ row.getCell(0).setCellValue(item.getPpeType());
|
|
|
+ row.getCell(1).setCellValue("1".equals(item.getComplete()) ? "✓" : item.getComplete());
|
|
|
+ row.getCell(2).setCellValue("1".equals(item.getIntact()) ? "✓" : item.getIntact());
|
|
|
+ row.getCell(3).setCellValue("1".equals(item.getPlacement()) ? "✓" : item.getPlacement());
|
|
|
+ row.getCell(4).setCellValue("1".equals(item.getValidity()) ? "✓" : item.getValidity());
|
|
|
+ row.getCell(5).setCellValue("1".equals(item.getInspectiontag()) ? "✓" : item.getInspectiontag());
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ // 检查人行
|
|
|
+ Row confirmerRow = sheet.getRow(confirmerRowIndex);
|
|
|
+ confirmerRow.getCell(4).setCellValue(r5c7Str);
|
|
|
+ if (StringUtils.isNotEmpty(confirmerSignUrl)) {
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirmerSignUrl, rowIndex, 3, 1, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|