瀏覽代碼

Merge branch 'dev-1.2' of http://192.168.2.236:10080/louhr/qc into dev-1.2

louhr 5 年之前
父節點
當前提交
3fe63a50a7
共有 1 個文件被更改,包括 51 次插入36 次删除
  1. 51 36
      dbanaly/src/main/java/com/lantone/qc/dbanaly/facade/comsis/XmlDataAnalysisFacade.java

+ 51 - 36
dbanaly/src/main/java/com/lantone/qc/dbanaly/facade/comsis/XmlDataAnalysisFacade.java

@@ -127,53 +127,24 @@ public class XmlDataAnalysisFacade {
                         .filter(i -> StringUtil.isNotBlank(behospitalCodeDeptInfoMap.get(i.getBehospitalCode())))
                         .collect(Collectors.toMap(MedicalRecord::getRecId, i -> i.getBehospitalCode()));
 
-        //根据文书记录id集合,分批次找出文书内容,有的文书记录可能没有对应文书内容,如果文书的xml是加密过的,还需要解密
-        List<MedicalRecordContent> medicalRecordContentList = Lists.newArrayList();
+        //根据文书记录id集合,分批次处理
+        List<Map.Entry<Set<String>, String>> keysBehospitalCodeEntryList = Lists.newArrayList();
         int index = 0;
-        medicalRecordQe.select("rec_id", "xml_text");
+        List<String> queryRecIds = null;
+        EncrypDES encrypDES = encryped ? new EncrypDES() : null;
         while (index <= recIds.size() - 1) {
-            QueryWrapper<MedicalRecordContent> medicalRecordContentQe = new QueryWrapper<>();
-            medicalRecordContentQe.eq("is_deleted", "N");
-            medicalRecordContentQe.eq("hospital_id", hospitalId);
             if (index + 1000 > recIds.size() - 1) {
-                medicalRecordContentQe.in("rec_id", recIds.subList(index, recIds.size()));
+                queryRecIds = recIds.subList(index, recIds.size());
             } else {
-                medicalRecordContentQe.in("rec_id", recIds.subList(index, index + 1000));
+                queryRecIds = recIds.subList(index, index + 1000);
             }
-            medicalRecordContentList.addAll(medicalRecordContentService.list(medicalRecordContentQe));
+            keysBehospitalCodeEntryList.addAll(getKeysBehospitalCodeEntryList(hospitalId, modelId, recTitle, sex, queryRecIds, recIdBehospitalCodeMap, encrypDES));
             if (index + 1000 > recIds.size() - 1) {
                 index = recIds.size();
             } else {
                 index = index + 1000;
             }
         }
-        if (ListUtil.isEmpty(medicalRecordContentList)) {
-            return;
-        }
-        if (encryped) {
-            EncrypDES encrypDES = new EncrypDES();
-            medicalRecordContentList.forEach(medicalRecordContent -> {
-                medicalRecordContent.setXmlText(encrypDES.decryptor(medicalRecordContent.getXmlText()));
-            });
-        }
-
-        //1、解析文书记录内容得出键值对,key是从文书的xml中提取的标签集合keys,value为对应的示例病历号;
-        //2、对键值对集合进行分组组装map,key为xml标签集合kesys,value为示例病历号集合;
-        List<Map.Entry<Set<String>, String>> keysBehospitalCodeEntryList = Lists.newArrayList();
-        String xmlText, behospitalCode;
-        for (MedicalRecordContent medicalRecordContent : medicalRecordContentList) {
-            xmlText = medicalRecordContent.getXmlText();
-            if (StringUtil.isBlank(xmlText)) {
-                continue;
-            }
-            behospitalCode = recIdBehospitalCodeMap.get(medicalRecordContent.getRecId());
-            keysBehospitalCodeEntryList.add(
-                    Maps.immutableEntry(
-                            getKeys(hospitalId, modelId, recTitle, sex, xmlText),
-                            behospitalCode
-                    )
-            );
-        }
         if (ListUtil.isEmpty(keysBehospitalCodeEntryList)) {
             return;
         }
@@ -303,6 +274,50 @@ public class XmlDataAnalysisFacade {
         }
     }
 
+    //根据文书记录id集合进行处理
+    private List<Map.Entry<Set<String>, String>> getKeysBehospitalCodeEntryList(long hospitalId, long modelId, String recTitle, String sex, List<String> recIds, Map<String, String> recIdBehospitalCodeMap, EncrypDES encrypDES) throws Exception {
+        List<Map.Entry<Set<String>, String>> ret = Lists.newArrayList();
+
+        //根据文书记录id集合,找出文书内容,有的文书记录可能没有对应文书内容,如果文书的xml是加密过的,还需要解密
+        QueryWrapper<MedicalRecordContent> medicalRecordContentQe = new QueryWrapper<>();
+        medicalRecordContentQe.eq("is_deleted", "N");
+        medicalRecordContentQe.eq("hospital_id", hospitalId);
+        medicalRecordContentQe.in("rec_id", recIds);
+        medicalRecordContentQe.select("rec_id", "xml_text");
+        List<MedicalRecordContent> medicalRecordContentList = medicalRecordContentService.list(medicalRecordContentQe);
+        if (ListUtil.isEmpty(medicalRecordContentList)) {
+            return ret;
+        }
+        if (encryped) {
+            medicalRecordContentList.forEach(medicalRecordContent -> {
+                medicalRecordContent.setXmlText(encrypDES.decryptor(medicalRecordContent.getXmlText()));
+            });
+        }
+
+        //1、解析文书记录内容得出键值对,key是从文书的xml中提取的标签集合keys,value为对应的示例病历号;
+        //2、对键值对集合进行分组组装map,key为xml标签集合kesys,value为示例病历号集合;
+        String xmlText, behospitalCode;
+        for (MedicalRecordContent medicalRecordContent : medicalRecordContentList) {
+            xmlText = medicalRecordContent.getXmlText();
+            if (StringUtil.isBlank(xmlText)) {
+                continue;
+            }
+            behospitalCode = recIdBehospitalCodeMap.get(medicalRecordContent.getRecId());
+            ret.add(
+                    Maps.immutableEntry(
+                            getKeys(hospitalId, modelId, recTitle, sex, xmlText),
+                            behospitalCode
+                    )
+            );
+        }
+
+        //释放内存
+        medicalRecordContentList.clear();
+        System.gc();
+
+        return ret;
+    }
+
     private Set<String> getKeys(long hospitalId, long modelId, String recTitle, String sex, String xml) throws Exception {
         Set<String> keys = new HashSet<>();
         if (hospitalId == 1) {