Quellcode durchsuchen

修改危急值记录,查房记录的结构化数据字段

shiyue vor 4 Jahren
Ursprung
Commit
8d9041d45c

+ 33 - 1
src/main/java/com/diagbot/facade/data/AStrCrisisNoteFacade.java

@@ -10,6 +10,7 @@ import com.diagbot.entity.MedicalRecordContent;
 import com.diagbot.entity.StrAdmissionNote;
 import com.diagbot.entity.StrCrisisNote;
 import com.diagbot.entity.StrFirstRecord;
+import com.diagbot.enums.CacheKeyEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.StrCrisisNoteServiceImpl;
 import com.diagbot.util.DateUtil;
@@ -24,6 +25,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.lang.reflect.Field;
 import java.util.*;
 
 @Component
@@ -120,14 +122,30 @@ public class AStrCrisisNoteFacade extends StrCrisisNoteServiceImpl {
         }
     }
 
-    public void dealData(StrCrisisNote medCrisisNote){
+    public void dealData(StrCrisisNote medCrisisNote,String modelName){
         try {
+            Map<String,Object> listMap =this.objectToMap(medCrisisNote);
+            Map<String,Object> map = new HashMap<>();
+            //得到表所对应的中文名和英文名
+            Map<String,String> tableKey=columnFacade.getColumn(CacheKeyEnum.getName(modelName));
+            if (listMap.size()>0){
+                listMap.forEach((k,v)->{
+                    tableKey.forEach((tableK,tableV)->{
+                        if (k.equals(tableV) && null!=v){
+                            map.put(tableK,v);
+                        }
+                    });
+                });
+            }
+
             //判断数据库中是否存在,不存在insert
             if(isExist(medCrisisNote)){
                 medCrisisNote.setGmtCreate(new Date());//记录创建时间
+                medCrisisNote.setWholeData(JSON.toJSONString(map));
                 this.save(medCrisisNote);
             }else{
                 medCrisisNote.setGmtModified(new Date());//记录修改时间
+                medCrisisNote.setWholeData(JSON.toJSONString(map));
                 this.update(medCrisisNote,new QueryWrapper<StrCrisisNote>()
                         .eq("rec_id", medCrisisNote.getRecId())
                         .eq("hospital_id", medCrisisNote.getHospitalId())
@@ -141,6 +159,20 @@ public class AStrCrisisNoteFacade extends StrCrisisNoteServiceImpl {
 
     }
 
+    private  Map<String,Object> objectToMap(Object o) throws IllegalAccessException {
+        if(null == o){
+            return null;
+        }
+        Map<String,Object> map = new HashMap<>();
+        Field[] declaredFields = o.getClass().getDeclaredFields();
+        for (Field field :declaredFields) {
+            // (此处如果不设置 无法获取对象的私有属性)
+            field.setAccessible(true);
+            map.put(field.getName(),field.get(o));
+        }
+        return map;
+    }
+
 
 
 

+ 34 - 7
src/main/java/com/diagbot/facade/data/AStrWardRecordFacade.java

@@ -9,6 +9,7 @@ import com.diagbot.dto.data.ColumnZhAndChDTO;
 import com.diagbot.entity.MedicalRecord;
 import com.diagbot.entity.MedicalRecordContent;
 import com.diagbot.entity.StrAdmissionNote;
+import com.diagbot.enums.CacheKeyEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.entity.StrWardRecord;
 import com.diagbot.service.impl.StrWardRecordServiceImpl;
@@ -23,10 +24,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.lang.reflect.Field;
+import java.util.*;
 
 @Component
 public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
@@ -84,16 +83,30 @@ public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
 
     }
 
-    public void dealData(StrWardRecord medWardRecord){
+    public void dealData(StrWardRecord medWardRecord,String modelName){
         try {
+            Map<String,Object> listMap =this.objectToMap(medWardRecord);
+            Map<String,Object> map = new HashMap<>();
+            //得到表所对应的中文名和英文名
+            Map<String,String> tableKey=columnFacade.getColumn(CacheKeyEnum.getName(modelName));
+            if (listMap.size()>0){
+                listMap.forEach((k,v)->{
+                    tableKey.forEach((tableK,tableV)->{
+                        if (k.equals(tableV) && null!=v){
+                            map.put(tableK,v);
+                        }
+                    });
+                });
+            }
+
             //判断数据库中是否存在,不存在insert
             if(isExist(medWardRecord)){
                 medWardRecord.setGmtCreate(new Date());//记录创建时间
-                medWardRecord.setWholeData(JSON.toJSONString(medWardRecord));
+                medWardRecord.setWholeData(JSON.toJSONString(map));
                 this.save(medWardRecord);
             }else{
                 medWardRecord.setGmtModified(new Date());//记录修改时间
-                medWardRecord.setWholeData(JSON.toJSONString(medWardRecord));
+                medWardRecord.setWholeData(JSON.toJSONString(map));
                 this.update(medWardRecord,new QueryWrapper<StrWardRecord>()
                         .eq("rec_id", medWardRecord.getRecId())
                         .eq("hospital_id", medWardRecord.getHospitalId())
@@ -147,4 +160,18 @@ public class AStrWardRecordFacade extends StrWardRecordServiceImpl {
             return RespDTO.onError(e.getMessage());
         }
     }
+
+    private  Map<String,Object> objectToMap(Object o) throws IllegalAccessException {
+        if(null == o){
+            return null;
+        }
+        Map<String,Object> map = new HashMap<>();
+        Field[] declaredFields = o.getClass().getDeclaredFields();
+        for (Field field :declaredFields) {
+            // (此处如果不设置 无法获取对象的私有属性)
+            field.setAccessible(true);
+            map.put(field.getName(),field.get(o));
+        }
+        return map;
+    }
 }

+ 17 - 11
src/main/java/com/diagbot/facade/data/StructuralDataFacade.java

@@ -139,12 +139,18 @@ public class StructuralDataFacade {
             List<String> strings =fjtzdbConnHarp.getBehospitalInfoDate(sql);
             strings.forEach(s->{
                 StructuralDataVo sData =new StructuralDataVo();
-                for (int i = 0; i <65 ; i++) {
-                    String tableName=TableNameEnum.getName(i);
-                    if (null!=tableName){
-                        sData.setBehospitalCode(s);
-                        sData.setModeId(String.valueOf(i));
-                        executeOld(sData);
+                if (null!=structuralDataVo.getModeId()){
+                    sData.setBehospitalCode(s);
+                    sData.setModeId(structuralDataVo.getModeId());
+                    executeOld(sData);
+                }else {
+                    for (int i = 0; i < 65; i++) {
+                        String tableName = TableNameEnum.getName(i);
+                        if (null != tableName) {
+                            sData.setBehospitalCode(s);
+                            sData.setModeId(String.valueOf(i));
+                            executeOld(sData);
+                        }
                     }
                 }
             });
@@ -154,7 +160,7 @@ public class StructuralDataFacade {
     }
 
     /**
-     * 终末质控,根据时间来导入数据
+     * 终末质控,单个病人来导入数据
      * @param behospitalCode
      */
     public void  sendOnebehospitalCode(List<String> behospitalCode){
@@ -350,12 +356,12 @@ public class StructuralDataFacade {
             }else if("危急值记录".equals(modelName)){
                 List<StrCrisisNote> medCrisisNote =fjtzdbConnHarp.getMedCrisisNote(this.sql(s));
                 if (medCrisisNote.size()>0){
-                    aStrCrisisNoteFacade.dealData(medCrisisNote.get(0));
+                    aStrCrisisNoteFacade.dealData(medCrisisNote.get(0),modelName);
                 }
             }else if("查房记录".equals(modelName)){
                 List<StrWardRecord> medWardRecords =fjtzdbConnHarp.getMedWardRecord(this.sql(s));
                 if (medWardRecords.size()>0){
-                    aStrWardRecordFacade.dealData(medWardRecords.get(0));
+                    aStrWardRecordFacade.dealData(medWardRecords.get(0),modelName);
                 }
             }
             log.info(modelName+"---- 保存数据完成!");
@@ -602,13 +608,13 @@ public class StructuralDataFacade {
             }else if("危急值记录".equals(modelName)){
                 List<StrCrisisNote> medCrisisNote =fjtzdbConnHarp.getMedCrisisNote(this.sqlOld(s));
                 if (medCrisisNote.size()>0){
-                    aStrCrisisNoteFacade.dealData(medCrisisNote.get(0));
+                    aStrCrisisNoteFacade.dealData(medCrisisNote.get(0),modelName);
                 }
             }else if("查房记录".equals(modelName)){
                 List<StrWardRecord> medWardRecords =fjtzdbConnHarp.getMedWardRecord(this.sqlOld(s));
                 if (medWardRecords.size()>0){
                     for (StrWardRecord strWardRecord:medWardRecords){
-                        aStrWardRecordFacade.dealData(strWardRecord);
+                        aStrWardRecordFacade.dealData(strWardRecord,modelName);
                     }
                 }
             }

+ 0 - 1
src/main/java/com/diagbot/util/FJTZDBConnHarp.java

@@ -644,7 +644,6 @@ public class FJTZDBConnHarp {
 				medWardRecord.setWardP(rs.getString("wardP"));// P
 				medWardRecord.setRecDoctor(rs.getString("recDoctor"));//记录医生
 				medWardRecord.setAuditDoctor(rs.getString("auditDoctor"));//审核医生
-				medWardRecord.setWholeData(rs.getString("wholeDate"));//结构化数据
 
 
 				if(null!=(rs.getString("recDate"))) {

+ 2 - 2
src/main/resources/application-test.yml

@@ -59,9 +59,9 @@ spring:
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
       platform: mysql
-      url: jdbc:mysql://127.0.0.1:3306/qc?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true
+      url: jdbc:mysql://192.168.2.241:3306/qc?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true
       username: root
-      password: root
+      password: lantone
       # 连接池的配置信息
       # 初始化大小,最小,最大
       initialSize: 5