Ver Fonte

[task-5698] 传染病记录,对接lis数据

huangws há 2 meses atrás
pai
commit
2f4466c5e9

+ 2 - 2
GetDataByView/src/main/java/com/jyxt/getdatabyview/GetDataByViewApplication.java

@@ -41,8 +41,8 @@ public class GetDataByViewApplication implements CommandLineRunner{
     @Value("${importMode}")
     private String importMode;
 
-    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport","V_JT_OutOfControlReport");//
-//    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport");//
+    public List<String> lisTableList = Arrays.asList("V_JT_TestCodeRerunRecord", "V_JT_QCMonthReport","V_JT_OutOfControlReport","V_JT_InfectiousReport");//
+//    public List<String> lisTableList = Arrays.asList("V_JT_QCMonthReport");//
 
     public static void main(String[] args) {
         SpringApplication.run(GetDataByViewApplication.class, args);

+ 91 - 0
GetDataByView/src/main/java/com/jyxt/getdatabyview/HandleData.java

@@ -107,6 +107,10 @@ public class HandleData {
             log.info("ready to analyse UnControl report");
             HandleUnControlReport(retList);
         }
+        if (lisTable.equals("V_JT_InfectiousReport")){
+            log.info("ready to analyse infectious report");
+            HandleInfectiousReport(retList);
+        }
     }
 
     public List<Map<String, Object>> cleanExistData(String lisTable, List<Map<String, Object>> lisList, List<Map<String, Object>> existList) {
@@ -167,6 +171,27 @@ public class HandleData {
             }
             return resultList;
         }
+        if (lisTable.equals("V_JT_InfectiousReport")) {
+            // 1. 创建Set存储existList中所有 tiao_ma_hao_ 的值(转换为字符串形式)
+            Set<String> existIdSet = new HashSet<>();
+//            log.info("existList:"+existList);
+//            log.info("lisList:"+lisList);
+            for (Map<String, Object> existMap : existList) {
+                Object idObj = existMap.get("tiao_ma_hao_");
+                existIdSet.add(idObj == null ? null : idObj.toString());
+            }
+            // 2. 过滤lisList:只保留 SampleCode 不在 existIdSet 中的元素
+            List<Map<String, Object>> resultList = new ArrayList<>();
+            for (Map<String, Object> testMap : lisList) {
+                Object idObj = testMap.get("SAMPLECODE");
+                String idStr = idObj == null ? null : idObj.toString();
+                if (!existIdSet.contains(idStr)) {
+                    resultList.add(testMap);
+//                    log.info("not exist,add:"+testMap);
+                }
+            }
+            return resultList;
+        }
         return null;
     }
 
@@ -441,6 +466,63 @@ public class HandleData {
         }
     }
 
+    public void HandleInfectiousReport(List<Map<String, Object>> retList){
+        if (retList.size() > 0) {
+            Timestamp currentTimestamp = getCurTime("yyyy-MM-dd HH:mm:ss");
+            long sequenceCounter = 0;
+            List<Map<String, Object>> insertList = new ArrayList<>();
+            for (Map<String, Object> retMap : retList) {
+                Map<String, Object> insertMap = new HashMap<>();
+                // 生成有序ID:时间戳+自增序列号
+                String orderedId = String.format("%d-%06d",
+                        currentTimestamp.getTime(),  // 使用时间戳
+                        sequenceCounter++            // 自增序列号
+                );
+                insertMap.put("id_", orderedId);
+                insertMap.put("create_time_", currentTimestamp); // 直接使用Timestamp,避免字符串转换
+                String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(retMap.get("REGISTERUSER")));
+                if(createUserInfo.contains("未找到")){
+                    log.warn("createUserInfo:"+createUserInfo);
+                    continue;
+                }
+                String workGroupID = ibpsRepository.getPosiByCode(retMap.get("GROUPID").toString());
+                if(workGroupID.contains("-1")){
+                    log.warn("workGroupID:"+workGroupID);
+                    continue;
+                }
+                insertMap.put("create_by_", createUserInfo.split("@")[0]);
+                insertMap.put("bian_zhi_ren_", createUserInfo.split("@")[0]);
+                insertMap.put("bian_zhi_shi_jian", String.valueOf(retMap.get("REGISTERDATE")));
+                insertMap.put("bian_zhi_bu_men_", workGroupID);
+                insertMap.put("di_dian_", ibpsRepository.getPosiByCode("LOCAL"));
+                insertMap.put("shi_fou_guo_shen_", "已完成");
+                insertMap.put("song_jian_ke_shi_", retMap.get("DEPARTMENT"));
+                insertMap.put("song_jian_yi_shen", retMap.get("DOCTOR"));
+                insertMap.put("bing_ren_xing_min", retMap.get("PATNAME"));
+                insertMap.put("xing_bie_", retMap.get("GENDER"));
+                insertMap.put("nian_ling_", retMap.get("AGE").toString().replace("岁",""));
+                insertMap.put("jian_yan_jie_guo_", retMap.get("REPORTRESULT"));
+                insertMap.put("bao_gao_ri_qi_", retMap.get("REPORTDATE"));
+                insertMap.put("feed_back_dr_time", retMap.get("FEEDBACKDOCTOR"));
+                insertMap.put("feed_back_hosp_ti", retMap.get("FEEDBACKDPHM"));
+                insertMap.put("tiao_ma_hao_", retMap.get("SAMPLECODE"));
+                insertList.add(insertMap);
+            }
+            if (!insertList.isEmpty()) {
+                String res = ibpsRepository.saveToTable(insertList, "t_crbbgdjb", "1");
+//                String res = "success";
+                if ("success".equals(res)) {
+                    log.info("table:t_crbbgdjb success insert: {} datas", insertList.size());
+                } else {
+                    log.error("fail insert t_crbbgdjb");
+                }
+            }
+        }else {
+            log.info("No New Infectious Report exist!");
+        }
+    }
+
+
     // 辅助方法:安全获取字符串值,避免空指针异常
     private String getStringValue(Map<String, Object> map, String key) {
         Object value = map.get(key);
@@ -582,4 +664,13 @@ public class HandleData {
         }
         return matchList;
     }
+
+    public Timestamp getCurTime(String formartterStr){
+        LocalDateTime currentDateTime = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formartterStr);
+        String formattedDateTime = currentDateTime.format(formatter);
+        Timestamp currentTimestamp = Timestamp.valueOf(formattedDateTime);
+        return currentTimestamp;
+    }
 }
+

+ 66 - 0
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/IBPSRepository.java

@@ -56,6 +56,12 @@ public class IBPSRepository {
             log.info("excute sql:"+sqlQry);
             existList = jdbcTemplate.queryForList(sqlQry);
         }
+        //V_JT_InfectiousReport
+        if(lisTable.equals("V_JT_InfectiousReport")){
+            String sqlQry = "select tiao_ma_hao_ from t_crbbgdjb WHERE bao_gao_ri_qi_ >= DATE_SUB(NOW(), INTERVAL 48 HOUR)";
+            log.info("excute sql:"+sqlQry);
+            existList = jdbcTemplate.queryForList(sqlQry);
+        }
         return existList;
     }
 
@@ -245,6 +251,39 @@ public class IBPSRepository {
         return retVal;
     }
 
+    /**
+     * 返回用户ID@部门ID@部门名称
+     * @param userName
+     * @return
+     */
+    public String getUserIDByName(String userName){
+        if (userName == null || userName.trim().isEmpty()) {
+            return "-1^用户:输入为空!";
+        }
+        String[] names = userName.split(",");
+        StringBuilder result = new StringBuilder();
+        for (int i = 0; i < names.length; i++) {
+            String name = names[i].trim();
+            if (name.isEmpty()) {
+                return "-1^用户:存在空用户名!";
+            }
+            String foundId = null;
+            for (Map<String, Object> map : userList) {
+                String curName = (String) map.get("name_");
+                if (name.equals(curName)) {
+                    foundId = (String) map.get("id_");
+                    break; // 找到就跳出
+                }
+            }
+            if (foundId == null) {
+                return "-1^用户:" + name + "未找到!";
+            }
+            if (i > 0) result.append(",");
+            result.append(foundId);
+        }
+        return result.toString();
+    }
+
     public String getPosiByID(String positionId){
         String retVal = "-1";
         for (Map<String, Object> map : posiList) {
@@ -309,5 +348,32 @@ public class IBPSRepository {
 
     };
 
+    public List<Map<String, Object>> getAllUser(){
+        List<Map<String, Object>> retList = new ArrayList<>();
+        String sqlStr = "select id_,name_,POSITIONS_ from ibps_party_employee where STATUS_='actived' and ADDRESS_!='系统用户'";
+        log.info("excute sql:"+sqlStr);
+        retList = jdbcTemplate.queryForList(sqlStr);
+        return retList;
+    }
+
+    public String getMainPos(String empID){
+        String retVal = "-1";
+        List<Map<String, Object>> retList = new ArrayList<>();
+        String sqlStr = "select main_pid_ from IBPS_PARTY_REL where main_type_='position' and biz_='mainPost' and SUB_PID_='"+empID+"'";
+        log.info("excute sql:"+sqlStr);
+        retList = jdbcTemplate.queryForList(sqlStr);
+        for (Map<String, Object> map : retList) {
+            retVal = map.get("main_pid_").toString();
+        }
+        return retVal;
+    }
+
+    public List<Map<String, Object>> getMonitorContent(){
+        List<Map<String, Object>> retList = new ArrayList<>();
+        String sqlStr = "select zhu.bian_zhi_bu_men_ as DEPID,zi.xu_hao_ as SEQ,zi.jian_du_xiang_mu_ as DIR,zi.jian_du_nei_rong_ as DESCs from t_ryjdpzzb zi left join t_ryjdpzb zhu on zi.parent_id_=zhu.id_ order by DEPID,SEQ";
+        log.info("excute sql:"+sqlStr);
+        retList = jdbcTemplate.queryForList(sqlStr);
+        return retList;
+    }
 
 }

+ 12 - 0
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/LISViewRepository.java

@@ -83,6 +83,18 @@ public class LISViewRepository {
                 return retList;
             }
         }
+        if(tableName.equals("V_JT_InfectiousReport")) {
+            try{
+                String sqlQry = "SELECT * FROM V_JT_InfectiousReport WHERE TO_DATE(ReportDate, 'YYYY-MM-DD') >= SYSDATE-2 and TO_DATE(ReportDate, 'YYYY-MM-DD') <= SYSDATE";
+                log.info("excute sql:"+sqlQry);
+                retList = jdbcTemplate.queryForList(sqlQry);
+                return retList;
+            } catch (Exception e) {
+                log.error(e.getMessage());
+                e.printStackTrace();
+                return retList;
+            }
+        }
         return retList;
     }
 

+ 2 - 1
GetDataByView/src/main/resources/application.properties

@@ -25,4 +25,5 @@ delayLimit=10
 #yyyy?M??
 manualQryMonth=
 resultWithUnit=0
-importMode=0
+importMode=0
+pushDate=0320,0620,0920,1220