|
|
@@ -191,6 +191,18 @@ public class PdfUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static String getStatusTime(List<Map<String, Object>> data, Integer status, List<Long> ingoreIdList) {
|
|
|
+ Optional<Map<String, Object>> optional = data.stream()
|
|
|
+ .filter(r -> r.get("status").equals(status) && !ingoreIdList.contains(Long.valueOf(r.get("id").toString())))
|
|
|
+ .findFirst();
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ Map<String, Object> map = optional.get();
|
|
|
+ ingoreIdList.add(Long.valueOf(map.get("id").toString()));
|
|
|
+ return map.get("date").toString();
|
|
|
+ }
|
|
|
+ return StringUtil.EMPTY_STRING;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public static void dealResumptionBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
// 第一行
|
|
|
@@ -205,26 +217,12 @@ public class PdfUtil {
|
|
|
PdfUtil.createPDFCell(tableFont, table, "检查时间", Element.ALIGN_MIDDLE, 2, 0);
|
|
|
PdfUtil.createPDFCell(tableFont, table, "检查内容", Element.ALIGN_MIDDLE, 6, 0);
|
|
|
PdfUtil.createPDFCell(tableFont, table, "检查情况", Element.ALIGN_MIDDLE, 2, 0);
|
|
|
-
|
|
|
-
|
|
|
-// PdfUtil.createPDFCell(tableFont, table, "检查时间", Element.ALIGN_CENTER, 1, 0);
|
|
|
-// PdfUtil.createPDFCell(tableFont, table, "检查内容", Element.ALIGN_CENTER, 5, 0);
|
|
|
-// PdfUtil.createPDFCell(tableFont, table, "检查情况", Element.ALIGN_CENTER, 0, 0);
|
|
|
-// PdfUtil.createPDFCell(tableFont, table, "登记人", Element.ALIGN_CENTER, 0, 0);
|
|
|
-
|
|
|
- /*List<String> names = new ArrayList<>();
|
|
|
- names.add(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 2));
|
|
|
- names.add(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 3));
|
|
|
- names.add(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 4));*/
|
|
|
final List<SysDictData> dictCache = DictUtils.getDictCache(DictConstants.RESUMPTION_PLAN_EXEC);
|
|
|
final List<String> names = dictCache.stream().map(SysDictData::getDictLabel).collect(Collectors.toList());
|
|
|
for (String s : names) {
|
|
|
List<LinkedHashMap<String, Object>> lists = (List<LinkedHashMap<String, Object>>) data.get(s);
|
|
|
if (ObjectUtil.isEmpty(lists)) {
|
|
|
//不同的执行时刻
|
|
|
- /* PdfUtil.createPDFCell(tableFont, table, s, PdfPCell.ALIGN_MIDDLE, 2,1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table,"/", PdfPCell.ALIGN_MIDDLE, 6, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, "/", PdfPCell.ALIGN_MIDDLE, 2,1);*/
|
|
|
continue;
|
|
|
}
|
|
|
//不同的执行时刻
|
|
|
@@ -243,57 +241,43 @@ 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, 8, 1);*/
|
|
|
-
|
|
|
|
|
|
List<Map<String, List<Map<String, Object>>>> protectionList = (List<Map<String, List<Map<String, Object>>>>) data.get("protection");
|
|
|
if (ObjectUtil.isNotEmpty(protectionList)) {
|
|
|
- for (int i = 0; i < protectionList.size(); i++) {
|
|
|
- Map<String, List<Map<String, Object>>> listMap = protectionList.get(i);
|
|
|
+ for (Map<String, List<Map<String, Object>>> listMap : protectionList) {
|
|
|
for (Map.Entry<String, List<Map<String, Object>>> listEntry : listMap.entrySet()) {
|
|
|
- IotAlarmSubsystem subsystem = JSON.parseObject(listEntry.getKey(),IotAlarmSubsystem.class);
|
|
|
+ IotAlarmSubsystem subsystem = JSON.parseObject(listEntry.getKey(), IotAlarmSubsystem.class);
|
|
|
List<Map<String, Object>> value = listEntry.getValue();
|
|
|
//布防状态,0:撤防,1:布防
|
|
|
if (value.isEmpty()) {
|
|
|
//子系统名称
|
|
|
PdfUtil.createPDFCell(tableFont, table, subsystem.getName(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table,"撤防时间" , Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "撤防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table,"布防时间" , Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "布防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
} else {
|
|
|
- // 子系统名称
|
|
|
- PdfUtil.createPDFCell(tableFont, table, subsystem.getName(), 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, "撤防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, cfStatus, 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, "布防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table, bfStatus, Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ long num = getNum(value);//可能出现布防两次,撤防一次的情况,避免登记簿异常,取最大值
|
|
|
+ List<Long> ingoreIdList = new ArrayList<>();
|
|
|
+ for (long i = 0; i < num; i++) {
|
|
|
+ // 子系统名称
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, subsystem.getName(), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ // 撤防时间
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "撤防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, getStatusTime(value, 0, ingoreIdList), Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ // 布防时间
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "布防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, getStatusTime(value, 1, ingoreIdList), Element.ALIGN_MIDDLE, 3, 1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//子系统名称
|
|
|
- PdfUtil.createPDFCell(tableFont, table,StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table,"撤防时间" , Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
- PdfUtil.createPDFCell(tableFont, table,"布防时间" , Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "撤防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
+ PdfUtil.createPDFCell(tableFont, table, "布防时间", Element.ALIGN_MIDDLE, 2, 1);
|
|
|
PdfUtil.createPDFCell(tableFont, table, StringUtil.EMPTY_STRING, Element.ALIGN_MIDDLE, 2, 1);
|
|
|
}
|
|
|
|
|
|
@@ -337,6 +321,17 @@ public class PdfUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private static long getNum(List<Map<String, Object>> value) {
|
|
|
+ long num;
|
|
|
+ List<Integer> statusList = value.stream().map(m -> (Integer) m.get("status")).collect(Collectors.toList());
|
|
|
+ num = statusList.stream().filter(r -> ObjectUtil.equal(0, r)).count();
|
|
|
+ long bfNums = statusList.stream().filter(r -> ObjectUtil.equal(1, r)).count();
|
|
|
+ if (bfNums > num) {
|
|
|
+ num = bfNums;
|
|
|
+ }
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+
|
|
|
public static String getLineStr(String str) {
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
for (int i = 0; i < str.length(); i++) {
|