Kaynağa Gözat

页面排序优化添加

rengb 5 yıl önce
ebeveyn
işleme
6419a0656d

+ 31 - 96
trans/src/main/java/com/lantone/qc/trans/taizhou/TaizhouDocTrans.java

@@ -167,18 +167,7 @@ public class TaizhouDocTrans extends DocTrans {
                     inputInfo.getCrisisValueReportDocs()
                             .stream()
                             .map(i -> i.getPageData())
-                            .sorted((map1, map2) -> {
-                                Date date1 = null, date2 = null;
-                                if (map1.get("病历日期") != null) {
-                                    date1 = DateUtil.parseDate(map1.get("病历日期").toString(), "yyyy-MM-dd HH:mm");
-                                }
-                                if (map2.get("病历日期") != null) {
-                                    date2 = DateUtil.parseDate(map2.get("病历日期").toString(), "yyyy-MM-dd HH:mm");
-                                }
-                                long time1 = date1 == null ? 0 : date1.getTime();
-                                long time2 = date2 == null ? 0 : date2.getTime();
-                                return (int) (time1 - time2);
-                            })
+                            .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "病历日期", "yyyy-MM-dd HH:mm"))
                             .collect(Collectors.toList())
             );
         }
@@ -215,18 +204,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(consultationDoc -> consultationDoc != null && consultationDoc.getConsultationRecordDoc() != null)
                     .map(consultationDoc -> consultationDoc.getConsultationRecordDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("事件日期") != null) {
-                            date1 = DateUtil.parseDate(map1.get("事件日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        if (map2.get("事件日期") != null) {
-                            date2 = DateUtil.parseDate(map2.get("事件日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "事件日期", "yyyy/MM/dd HH:mm"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(crePageDataList)) {
                 inputInfo.getPageData().put("会诊记录", crePageDataList);
@@ -236,18 +214,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(consultationDoc -> consultationDoc != null && consultationDoc.getConsultationApplicationDoc() != null)
                     .map(consultationDoc -> consultationDoc.getConsultationApplicationDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("事件日期") != null) {
-                            date1 = DateUtil.parseDate(map1.get("事件日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        if (map2.get("事件日期") != null) {
-                            date2 = DateUtil.parseDate(map2.get("事件日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "事件日期", "yyyy/MM/dd HH:mm"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(caPageDataList)) {
                 inputInfo.getPageData().put("会诊申请单", caPageDataList);
@@ -257,18 +224,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(consultationDoc -> consultationDoc != null && consultationDoc.getConsultationResultsDoc() != null)
                     .map(consultationDoc -> consultationDoc.getConsultationResultsDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("事件日期1(会诊申请日期)") != null) {
-                            date1 = DateUtil.parseDate(map1.get("事件日期1(会诊申请日期)").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        if (map2.get("事件日期1(会诊申请日期)") != null) {
-                            date2 = DateUtil.parseDate(map2.get("事件日期1(会诊申请日期)").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "事件日期1(会诊申请日期)", "yyyy/MM/dd HH:mm"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(crsPageDataList)) {
                 inputInfo.getPageData().put("会诊结果单", crsPageDataList);
@@ -279,18 +235,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(operationDoc -> operationDoc != null && operationDoc.getOperationDiscussionDoc() != null)
                     .map(operationDoc -> operationDoc.getOperationDiscussionDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("手术日期") != null) {
-                            date1 = DateUtil.parseDate(map1.get("手术日期").toString(), "yyyy/MM/dd");
-                        }
-                        if (map2.get("手术日期") != null) {
-                            date2 = DateUtil.parseDate(map2.get("手术日期").toString(), "yyyy/MM/dd");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "手术日期", "yyyy/MM/dd"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(odPageDataList)) {
                 inputInfo.getPageData().put("术后首次病程及谈话记录", odPageDataList);
@@ -300,18 +245,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(operationDoc -> operationDoc != null && operationDoc.getOperationRecordDoc() != null)
                     .map(operationDoc -> operationDoc.getOperationRecordDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("开始时间") != null) {
-                            date1 = DateUtil.parseDate(map1.get("开始时间").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        if (map2.get("开始时间") != null) {
-                            date2 = DateUtil.parseDate(map2.get("开始时间").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "开始时间", "yyyy/MM/dd HH:mm"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(orPageDataList)) {
                 inputInfo.getPageData().put("手术记录", orPageDataList);
@@ -321,18 +255,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(operationDoc -> operationDoc != null && operationDoc.getPreoperativeDiscussionDoc() != null)
                     .map(operationDoc -> operationDoc.getPreoperativeDiscussionDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("讨论时间") != null) {
-                            date1 = DateUtil.parseDate(map1.get("讨论时间").toString(), "yyyy年MM月dd日 HH时mm分");
-                        }
-                        if (map2.get("讨论时间") != null) {
-                            date2 = DateUtil.parseDate(map2.get("讨论时间").toString(), "yyyy年MM月dd日 HH时mm分");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "讨论时间", "yyyy年MM月dd日 HH时mm分"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(pdPageDataList)) {
                 inputInfo.getPageData().put("术前讨论、术前小结", pdPageDataList);
@@ -342,18 +265,7 @@ public class TaizhouDocTrans extends DocTrans {
                     .stream()
                     .filter(operationDoc -> operationDoc != null && operationDoc.getOperationInformedConsentDoc() != null)
                     .map(operationDoc -> operationDoc.getOperationInformedConsentDoc().getPageData())
-                    .sorted((map1, map2) -> {
-                        Date date1 = null, date2 = null;
-                        if (map1.get("谈话日期") != null) {
-                            date1 = DateUtil.parseDate(map1.get("谈话日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        if (map2.get("谈话日期") != null) {
-                            date2 = DateUtil.parseDate(map2.get("谈话日期").toString(), "yyyy/MM/dd HH:mm");
-                        }
-                        long time1 = date1 == null ? 0 : date1.getTime();
-                        long time2 = date2 == null ? 0 : date2.getTime();
-                        return (int) (time1 - time2);
-                    })
+                    .sorted((map1, map2) -> pageDataTimeSort(map1, map2, "谈话日期", "yyyy/MM/dd HH:mm"))
                     .collect(Collectors.toList());
             if (ListUtil.isNotEmpty(oicPageDataList)) {
                 inputInfo.getPageData().put("手术知情同意书", oicPageDataList);
@@ -369,4 +281,27 @@ public class TaizhouDocTrans extends DocTrans {
             }
         }
     }
+
+    /**
+     * 返回给前端的页面数据多条时排序
+     *
+     * @param map1
+     * @param map2
+     * @param key
+     * @param format
+     * @return
+     */
+    private int pageDataTimeSort(Map<String, Object> map1, Map<String, Object> map2, String key, String format) {
+        Date date1 = null, date2 = null;
+        if (map1.get(key) != null) {
+            date1 = DateUtil.parseDate(map1.get(key).toString(), format);
+        }
+        if (map2.get(key) != null) {
+            date2 = DateUtil.parseDate(map2.get(key).toString(), format);
+        }
+        long time1 = date1 == null ? 0 : date1.getTime();
+        long time2 = date2 == null ? 0 : date2.getTime();
+        return (int) (time1 - time2);
+    }
+
 }