|
|
@@ -4,15 +4,18 @@ package com.xunmei.file.utils;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.lowagie.text.*;
|
|
|
import com.lowagie.text.pdf.*;
|
|
|
import com.xunmei.common.core.constant.DictConstants;
|
|
|
+import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
|
|
|
import com.xunmei.common.security.utils.DictUtils;
|
|
|
import com.xunmei.file.vo.ItextPdfTableVo;
|
|
|
import com.xunmei.system.api.domain.AccessDataVo;
|
|
|
import com.xunmei.system.api.domain.CheckDataVo;
|
|
|
import com.xunmei.system.api.domain.SafeCheckTaskRegisterBookVo;
|
|
|
import com.xunmei.system.api.domain.SysDictData;
|
|
|
+import io.netty.util.internal.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
@@ -240,25 +243,60 @@ public class PdfUtil {
|
|
|
PdfUtil.createPDFCell(tableFont, table, "布撤防情况", Element.ALIGN_MIDDLE, 10, 1);
|
|
|
|
|
|
PdfUtil.createPDFCell(tableFont, table, "序号", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, "布撤防状态", Element.ALIGN_MIDDLE, 4, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, "时间", Element.ALIGN_MIDDLE, 4, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "控制器", Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "状态", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "时间", Element.ALIGN_MIDDLE, 3, 1);
|
|
|
|
|
|
- final List<HashMap> protectionList = (List<HashMap>) data.get("protection");
|
|
|
+ List<Map<String, List<Map<String, Object>>>> protectionList = (List<Map<String, List<Map<String, Object>>>>) data.get("protection");
|
|
|
if (ObjectUtil.isEmpty(protectionList)) {
|
|
|
PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 4, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 4, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "/", Element.ALIGN_MIDDLE, 3, 1);
|
|
|
document.add(table);
|
|
|
-
|
|
|
} else {
|
|
|
for (int i = 0; i < protectionList.size(); i++) {
|
|
|
- PdfUtil.createPDFCell(tableFont, table, String.valueOf(i+1), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- HashMap<String,Object> hashMap = protectionList.get(i);
|
|
|
- Integer status = (Integer) hashMap.get("status");
|
|
|
- String date = (String) hashMap.get("date");
|
|
|
- String text = ObjectUtil.equal(1, status) ? "布防" : "撤防";//布防状态,0:撤防,1:布防
|
|
|
- PdfUtil.createPDFCell(tableFont, table, text, Element.ALIGN_MIDDLE, 4, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, date, Element.ALIGN_MIDDLE, 4, 1);
|
|
|
+ Map<String, List<Map<String, Object>>> listMap = protectionList.get(i);
|
|
|
+ for (Map.Entry<String, List<Map<String, Object>>> listEntry : listMap.entrySet()) {
|
|
|
+ IotAlarmSubsystem subsystem = JSON.parseObject(listEntry.getKey(),IotAlarmSubsystem.class);
|
|
|
+ List<Map<String, Object>> value = listEntry.getValue();
|
|
|
+ //布防状态,0:撤防,1:布防
|
|
|
+ if (value.isEmpty()) {
|
|
|
+ // 序号
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, String.valueOf(i + 1), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ //子系统名称
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, subsystem.getName(), Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ //状态
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ // 时间
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ } else {
|
|
|
+ // 序号
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, String.valueOf(i + 1), Element.ALIGN_MIDDLE, 2, 2);
|
|
|
+ //子系统名称
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, subsystem.getName(), Element.ALIGN_MIDDLE, 3, 2);
|
|
|
+ //状态
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "撤防", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ Optional<Map<String, Object>> statusOptional1 = value.stream().filter(r -> {
|
|
|
+ Integer status = (Integer) r.get("status");
|
|
|
+ return ObjectUtil.equal(0,status);
|
|
|
+ }).findFirst();
|
|
|
+ String cfStatus = statusOptional1.isPresent() ? String.valueOf(statusOptional1.get().get("date")) : StringUtil.EMPTY_STRING;
|
|
|
+ // 撤防时间
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, cfStatus, Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+
|
|
|
+
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "布防", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ Optional<Map<String, Object>> statusOptional = value.stream().filter(r -> {
|
|
|
+ Integer status = (Integer) r.get("status");
|
|
|
+ return ObjectUtil.equal(1,status);
|
|
|
+ }).findFirst();
|
|
|
+ String bfStatus = statusOptional.isPresent() ? String.valueOf(statusOptional.get().get("date")) : StringUtil.EMPTY_STRING;
|
|
|
+ // 布防时间
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, bfStatus, Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|