Эх сурвалжийг харах

[task-6725] 附加检验申请对接

huangws 1 өдөр өмнө
parent
commit
8cc50e8db5

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

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

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

@@ -123,6 +123,10 @@ public class HandleData {
             log.info("ready to analyse infectious report");
             HandleInfectiousReport(retList);
         }
+        if (lisTable.equals("V_JT_AdditionalRequest")){
+            log.info("ready to analyse additional request");
+            HandleAdditionalRequest(retList);
+        }
     }
 
     public List<Map<String, Object>> cleanExistData(String lisTable, List<Map<String, Object>> lisList, List<Map<String, Object>> existList) {
@@ -199,6 +203,27 @@ public class HandleData {
                 String idStr = idObj == null ? null : idObj.toString();
                 if (!existIdSet.contains(idStr)) {
                     resultList.add(testMap);
+//                    log.info("not exist,add:"+testMap);
+                }
+            }
+            return resultList;
+        }
+        if (lisTable.equals("V_JT_AdditionalRequest")) {
+            // 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("bian_zhi_shi_jian");
+                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("REGTIME");
+                String idStr = idObj == null ? null : idObj.toString();
+                if (!existIdSet.contains(idStr)) {
+                    resultList.add(testMap);
 //                    log.info("not exist,add:"+testMap);
                 }
             }
@@ -524,6 +549,69 @@ public class HandleData {
         }
     }
 
+    public void HandleAdditionalRequest(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("REGUSER")));
+                String inUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(retMap.get("INSPUSER")));
+                if(createUserInfo.contains("未找到")){
+                    log.warn("createUserInfo:"+createUserInfo);
+                    continue;
+                }
+                String workGroupID = ibpsRepository.getPosiByCode(retMap.get("REGLOCATION").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("REGTIME")));
+                insertMap.put("bian_zhi_bu_men_", workGroupID);
+                insertMap.put("di_dian_", ibpsRepository.getPosiByCode("LOCAL"));
+                insertMap.put("shi_fou_guo_shen_", "已完成");
+                insertMap.put("shen_qing_shi_jia", retMap.get("REQTIME"));
+                insertMap.put("shen_qing_ke_shi_", retMap.get("REQLOCATION"));
+                insertMap.put("shen_qing_ren_zh", retMap.get("REQUSER"));
+                insertMap.put("shen_qing_ren_", retMap.get("REQUSER"));
+                insertMap.put("yang_pin_bian_hao", retMap.get("SAMPLECODE"));
+                insertMap.put("nei_ron_zh", retMap.get("TESTCODE"));
+                insertMap.put("jian_yan_shi_xian", String.valueOf(retMap.get("ADDTIME")));
+                insertMap.put("ke_shi_lei_xing_", "外部");
+                insertMap.put("deng_ji_ren_yuan_", "受理");
+                insertMap.put("jie_shou_ren_yuan", inUserInfo.split("@")[0]);
+                insertMap.put("song_da_qing_kuan", "已送");
+                insertMap.put("song_da_ren_yuan_", retMap.get("RECUSER"));
+                insertMap.put("song_da_shi_jian_", String.valueOf(retMap.get("RECTIME")));
+                insertMap.put("bei_zhu_", retMap.get("REMARK"));
+
+                insertList.add(insertMap);
+            }
+            if (!insertList.isEmpty()) {
+                String res = ibpsRepository.saveToTable(insertList, "t_fjjysqdjb", "1");
+//                String res = "success";
+                if ("success".equals(res)) {
+                    log.info("table:t_fjjysqdjb success insert: {} datas", insertList.size());
+                } else {
+                    log.error("fail insert t_fjjysqdjb");
+                }
+            }
+        }else {
+            log.info("No New Additional Request exist!");
+        }
+
+    }
+
 
     // 辅助方法:安全获取字符串值,避免空指针异常
     private String getStringValue(Map<String, Object> map, String key) {

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

@@ -62,6 +62,12 @@ public class IBPSRepository {
             log.info("excute sql:"+sqlQry);
             existList = jdbcTemplate.queryForList(sqlQry);
         }
+        //V_JT_AdditionalRequest
+        if(lisTable.equals("V_JT_AdditionalRequest")){
+            String sqlQry = "select bian_zhi_shi_jian from t_fjjysqdjb WHERE bian_zhi_shi_jian >= DATE_SUB(NOW(), INTERVAL 48 HOUR)";
+            log.info("excute sql:"+sqlQry);
+            existList = jdbcTemplate.queryForList(sqlQry);
+        }
         return existList;
     }
 

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

@@ -108,6 +108,40 @@ public class LISViewRepository {
                 e.printStackTrace();
                 return retList;
             }
+        }if(tableName.equals("V_JT_AdditionalRequest")) {
+            if (1 == 2) {
+                List<Map<String, Object>> list = new ArrayList<>();
+                // 2. 创建内层Map
+                Map<String, Object> map = new HashMap<>(); // 保持插入顺序
+                // 3. 向Map中添加数据
+                map.put("REGLOCATION", "G032");
+                map.put("REGUSER", "李攀");
+                map.put("REGTIME", "2026-08-04 08:55");
+                map.put("REQTIME", "2026-08-04 14:11");
+                map.put("REQLOCATION", "胃肠外一病区医生站");
+                map.put("REQUSER", "谢杰斌");
+                map.put("SAMPLECODE", "20260720G0023047");
+                map.put("TESTCODE", "肝功,肾功,电解质,");
+                map.put("RECUSER", "分拣机");
+                map.put("RECTIME", "2026-08-04 15:11");
+                map.put("ADDTIME", "ADDTIMEADDTIME");
+                map.put("INSPUSER", "王黎");
+                map.put("REMARK", "条码4042737910附加到4042737830");
+                list.add(map);
+                return list;
+            } else {
+                try {
+                    String sqlQry = "SELECT * FROM V_JT_AdditionalRequest WHERE TO_DATE(REGTIME, 'YY-MM-DD HH24:MI') BETWEEN SYSDATE - 20 AND SYSDATE - 1;";
+                    log.info("excute sql:" + sqlQry);
+                    retList = jdbcTemplate.queryForList(sqlQry);
+                    return retList;
+                } catch (Exception e) {
+                    log.error(e.getMessage());
+                    e.printStackTrace();
+                    return retList;
+                }
+            }
+
         }
         return retList;
     }