瀏覽代碼

需进模型数据写入数据库修改bug

hujing 5 年之前
父節點
當前提交
fccf6fec42

+ 35 - 10
kernel/src/main/java/com/lantone/qc/kernel/util/ModelDataUtil.java

@@ -13,6 +13,7 @@ import com.lantone.qc.pub.model.doc.operation.OperationDoc;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.PropertiesUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.TransDispatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,7 +44,7 @@ public class ModelDataUtil {
         firstCourseRecord(inputInfo, changxDocs, "首次病程录");
         operationDiscussion(inputInfo, changxDocs, "术后首次病程及谈话记录文档");
         threeLevelWard(inputInfo, changxDocs, "三级查房记录");
-        leaveHospital(inputInfo, changxDocs, "出院小结");
+        //        leaveHospital(inputInfo, changxDocs, "出院小结");
         insertDB(caseNumber, changxDocs);
     }
 
@@ -54,13 +55,9 @@ public class ModelDataUtil {
                 propertiesUtil.getProperty("mysql.test.url"));
         Connection connect = null;
         PreparedStatement pst = null;
-        String sql = "TRUNCATE qc_model_input_info";
+        String sql = "INSERT INTO qc_model_input_info(case_number,title,sub_title,text) VALUES(?,?,?,?)";
         try {
             connect = mysqlJdbc.connect();
-            pst = connect.prepareStatement(sql);
-            pst.execute();
-
-            sql = "INSERT INTO qc_model_input_info(case_number,title,sub_title,text) VALUES(?,?,?,?)";
             connect.setAutoCommit(false);
             pst = connect.prepareStatement(sql);
             for (Map.Entry<String, Map<String, String>> changxDoc : changxDocs.entrySet()) {
@@ -73,7 +70,7 @@ public class ModelDataUtil {
                     pst.setString(4, doc.getValue());
                     pst.addBatch();
                     i++;
-                    if ((i != 0 && i % 1000 == 0) || i == changxDoc.getValue().size() - 1) {
+                    if ((i != 0 && i % 1000 == 0) || i == changxDoc.getValue().size()) {
                         pst.executeBatch();
                         connect.commit();
                         pst.clearBatch();
@@ -92,6 +89,31 @@ public class ModelDataUtil {
         }
     }
 
+    public void truncateDB(String dbName) {
+        PropertiesUtil propertiesUtil = new PropertiesUtil("kernel.properties");
+        MysqlJdbc mysqlJdbc = new MysqlJdbc(propertiesUtil.getProperty("mysql.test.user"),
+                propertiesUtil.getProperty("mysql.test.password"),
+                propertiesUtil.getProperty("mysql.test.url"));
+        Connection connect = null;
+        PreparedStatement pst = null;
+        String sql = "TRUNCATE " + dbName;
+        try {
+            connect = mysqlJdbc.connect();
+            pst = connect.prepareStatement(sql);
+            pst.execute();
+            logger.info(dbName + "表已清空");
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        } finally {
+            try {
+                pst.close();
+                connect.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
     /**
      * 入院记录
      *
@@ -217,9 +239,12 @@ public class ModelDataUtil {
         if (firstWardRecord.get(Content.director) != null) {
             putDoc(changxDoc, Content.director + "首次查房记录", firstWardRecord.get(Content.director).get("病情记录"));
         }
+
         Map<String, String> lastCourseRecord = threeLevelWardAI.getLastCourseRecord(threeLevelWardDocs);
-        //主任医师最后一次查房记录
-        putDoc(changxDoc, Content.director + "末次查房记录", lastCourseRecord.get("病情记录"));
+        if (lastCourseRecord != null && lastCourseRecord.containsKey("病情记录")) {
+            //主任医师最后一次查房记录
+            putDoc(changxDoc, Content.director + "末次查房记录", lastCourseRecord.get("病情记录"));
+        }
 
         List<Map<String, String>> directorDifficultRecord = new ArrayList<>();
         //疑难患者副高及以上查房记录
@@ -260,7 +285,7 @@ public class ModelDataUtil {
     }
 
     private void putDoc(Map<String, String> changxDoc, String title, String content) {
-        if (CatalogueUtil.isEmpty(content)) {
+        if (StringUtil.isEmpty(content)) {
             return;
         }
         if (title.contains("、")) {

+ 1 - 0
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java

@@ -64,6 +64,7 @@ public class QCTestController {
 
         List<Map<String, Object>> updates = new ArrayList<>();
         List<Map<String, Object>> wheres = new ArrayList<>();
+//        modelDataUtil.truncateDB("qc_model_input_info");//清空表
         for (Map.Entry<String, QueryVo> entry : queryVoMap.entrySet()) {
             System.out.println("患者就诊号:" + entry.getKey() + "..........");
 //            modelDataUtil.executor(entry.getKey(), entry.getValue());//AI所需模块数据存入DB