|
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.YearMonth;
|
|
import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -35,6 +36,10 @@ public class HandleData {
|
|
|
|
|
|
|
|
public static final Map<String, String> RerunSampleField = new HashMap<>();
|
|
public static final Map<String, String> RerunSampleField = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
+ public static final Map<String, String> UnControlReportField = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ public static final Map<String, String> PositionTransferField = new HashMap<>();
|
|
|
|
|
+
|
|
|
static {
|
|
static {
|
|
|
// 静态初始化块中填充数据
|
|
// 静态初始化块中填充数据
|
|
|
RerunSampleField.put("CREATEBY", "bian_zhi_ren_");
|
|
RerunSampleField.put("CREATEBY", "bian_zhi_ren_");
|
|
@@ -51,6 +56,38 @@ public class HandleData {
|
|
|
RerunSampleField.put("PATNAME", "xing_ming_");
|
|
RerunSampleField.put("PATNAME", "xing_ming_");
|
|
|
RerunSampleField.put("RERUNMETHOD", "fu_jian_fang_shi_");
|
|
RerunSampleField.put("RERUNMETHOD", "fu_jian_fang_shi_");
|
|
|
RerunSampleField.put("UNIT", "dan_wei_");
|
|
RerunSampleField.put("UNIT", "dan_wei_");
|
|
|
|
|
+
|
|
|
|
|
+ UnControlReportField.put("TestCode","");
|
|
|
|
|
+ UnControlReportField.put("QCName","zhi_kong_pin_ming");
|
|
|
|
|
+ UnControlReportField.put("QCLot","");
|
|
|
|
|
+ UnControlReportField.put("QCDate","");
|
|
|
|
|
+ UnControlReportField.put("QCResult","");
|
|
|
|
|
+ UnControlReportField.put("SD","");
|
|
|
|
|
+ UnControlReportField.put("Quant","");
|
|
|
|
|
+ UnControlReportField.put("Qual","");
|
|
|
|
|
+ UnControlReportField.put("ErrorType","");
|
|
|
|
|
+ UnControlReportField.put("Reason","");
|
|
|
|
|
+ UnControlReportField.put("Action","");
|
|
|
|
|
+ UnControlReportField.put("QCFinalResult","");
|
|
|
|
|
+ UnControlReportField.put("IsInControl","");
|
|
|
|
|
+ UnControlReportField.put("AffectsPatientSamples","");
|
|
|
|
|
+ UnControlReportField.put("AffectsResultReporting","");
|
|
|
|
|
+ UnControlReportField.put("Notes","");
|
|
|
|
|
+ UnControlReportField.put("QCFinalResult","");
|
|
|
|
|
+
|
|
|
|
|
+ PositionTransferField.put("G002","生化免疫组"); //茂源生化
|
|
|
|
|
+ PositionTransferField.put("G004","生化免疫组"); //茂源免疫
|
|
|
|
|
+ PositionTransferField.put("G032","临检组"); //茂源临检
|
|
|
|
|
+ PositionTransferField.put("G009",""); //茂源急诊
|
|
|
|
|
+ PositionTransferField.put("G007","分子组"); //茂源分子
|
|
|
|
|
+ PositionTransferField.put("G031","微生物组"); //茂源微生物
|
|
|
|
|
+ PositionTransferField.put("G036","文化路院区"); //文化大检验
|
|
|
|
|
+ PositionTransferField.put("G014","文化路院区"); //文化微生物
|
|
|
|
|
+ PositionTransferField.put("Y032","临检组"); //茂源临检(夜班)
|
|
|
|
|
+ PositionTransferField.put("Y009",""); //茂源急诊(夜班)
|
|
|
|
|
+ PositionTransferField.put("Y036","文化路院区"); //文化大检验(夜班)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -59,13 +96,17 @@ public class HandleData {
|
|
|
retList = cleanExistData(lisTable,retList,existList);
|
|
retList = cleanExistData(lisTable,retList,existList);
|
|
|
log.info("table:"+lisTable+" get data:"+retList.size());
|
|
log.info("table:"+lisTable+" get data:"+retList.size());
|
|
|
if (lisTable.equals("V_JT_TestCodeRerunRecord")){
|
|
if (lisTable.equals("V_JT_TestCodeRerunRecord")){
|
|
|
- log.info("ready to get rerun testcode");
|
|
|
|
|
|
|
+ log.info("ready to analyse rerun testcode");
|
|
|
HandleRerunSample(retList);
|
|
HandleRerunSample(retList);
|
|
|
}
|
|
}
|
|
|
if (lisTable.equals("V_JT_QCMonthReport")){
|
|
if (lisTable.equals("V_JT_QCMonthReport")){
|
|
|
- log.info("ready to get QC month report");
|
|
|
|
|
|
|
+ log.info("ready to analyse QC month report");
|
|
|
HandleMonthReport(retList);
|
|
HandleMonthReport(retList);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (lisTable.equals("V_JT_OutOfControlReport")){
|
|
|
|
|
+ log.info("ready to analyse UnControl report");
|
|
|
|
|
+ HandleUnControlReport(retList);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String, Object>> cleanExistData(String lisTable, List<Map<String, Object>> lisList, List<Map<String, Object>> existList) {
|
|
public List<Map<String, Object>> cleanExistData(String lisTable, List<Map<String, Object>> lisList, List<Map<String, Object>> existList) {
|
|
@@ -108,6 +149,24 @@ public class HandleData {
|
|
|
}
|
|
}
|
|
|
return resultList;
|
|
return resultList;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (lisTable.equals("V_JT_OutOfControlReport")) {
|
|
|
|
|
+ // 1. 创建Set存储existList中所有 bian_zhi_shi_jian 的值(转换为字符串形式)
|
|
|
|
|
+ Set<String> existIdSet = new HashSet<>();
|
|
|
|
|
+ for (Map<String, Object> existMap : existList) {
|
|
|
|
|
+ Object idObj = existMap.get("bian_zhi_shi_jian");
|
|
|
|
|
+ existIdSet.add(idObj == null ? null : idObj.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 2. 过滤lisList:只保留 bian_zhi_shi_jian 不在 existIdSet 中的元素
|
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
+ for (Map<String, Object> testMap : lisList) {
|
|
|
|
|
+ Object idObj = testMap.get("CREATETIME");
|
|
|
|
|
+ String idStr = idObj == null ? null : idObj.toString();
|
|
|
|
|
+ if (!existIdSet.contains(idStr)) {
|
|
|
|
|
+ resultList.add(testMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return resultList;
|
|
|
|
|
+ }
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -134,11 +193,11 @@ public class HandleData {
|
|
|
String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("CREATEBY")));
|
|
String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("CREATEBY")));
|
|
|
String auditUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("AUDITUSER")));
|
|
String auditUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(entityMap.get("AUDITUSER")));
|
|
|
if (createUserInfo.split("\\^")[0].equals("-1")) {
|
|
if (createUserInfo.split("\\^")[0].equals("-1")) {
|
|
|
- log.info("error userInfo,skip to insert:"+createUserInfo);
|
|
|
|
|
|
|
+ log.warn("error userInfo,skip to insert:"+createUserInfo);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
if (auditUserInfo.split("\\^")[0].equals("-1")) {
|
|
if (auditUserInfo.split("\\^")[0].equals("-1")) {
|
|
|
- log.info("error auditUserInfo,skip to insert:"+auditUserInfo);
|
|
|
|
|
|
|
+ log.warn("error auditUserInfo,skip to insert:"+auditUserInfo);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
|
@@ -160,6 +219,8 @@ public class HandleData {
|
|
|
} else {
|
|
} else {
|
|
|
log.info("fail insert");
|
|
log.info("fail insert");
|
|
|
}
|
|
}
|
|
|
|
|
+ }else{
|
|
|
|
|
+ log.info("No New Rerun Sample exist!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -201,6 +262,8 @@ public class HandleData {
|
|
|
log.info("fail insert t_dlxmsnzkyfx");
|
|
log.info("fail insert t_dlxmsnzkyfx");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ log.info("No New MonthReport exist!");
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -281,6 +344,103 @@ public class HandleData {
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void HandleUnControlReport(List<Map<String, Object>> retList){
|
|
|
|
|
+ if (retList.size() > 0) {
|
|
|
|
|
+ LocalDateTime currentDateTime = LocalDateTime.now();
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ String formattedDateTime = currentDateTime.format(formatter);
|
|
|
|
|
+ Timestamp currentTimestamp = Timestamp.valueOf(currentDateTime);
|
|
|
|
|
+ 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("id_", retMap.get("RESULT_NO"));
|
|
|
|
|
+ insertMap.put("create_time_", currentTimestamp); // 直接使用Timestamp,避免字符串转换
|
|
|
|
|
+ String createUserInfo = ibpsRepository.getUserInfoByName(String.valueOf(retMap.get("CREATEUSER")));
|
|
|
|
|
+ if(createUserInfo.contains("未找到")){
|
|
|
|
|
+ log.warn(createUserInfo);
|
|
|
|
|
+ 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("CREATETIME")));
|
|
|
|
|
+ insertMap.put("di_dian_", ibpsRepository.getPosiByCode("LOCAL"));
|
|
|
|
|
+ insertMap.put("shi_fou_guo_shen_", "待推送");
|
|
|
|
|
+ insertMap.put("zhuan_ye_zu_", ibpsRepository.getPosiByCode(retMap.get("GROUP_ID").toString()));
|
|
|
|
|
+ insertMap.put("cao_zuo_zhe_", createUserInfo.split("@")[0]);
|
|
|
|
|
+ insertMap.put("yi_qi_ming_", retMap.get("TESTCODE"));
|
|
|
|
|
+ insertMap.put("xiang_mu_ming_", retMap.get("DEVICECODE"));
|
|
|
|
|
+ insertMap.put("zhi_kong_pin_ming", retMap.get("QCNAME"));
|
|
|
|
|
+ insertMap.put("zhi_kong_pi_hao_", retMap.get("QCLOT"));
|
|
|
|
|
+ String qcDate = (String) retMap.get("QCDATE");
|
|
|
|
|
+ String formatted = qcDate == null ? null :
|
|
|
|
|
+ LocalDate.parse(qcDate, DateTimeFormatter.ofPattern("yyyyMMdd"))
|
|
|
|
|
+ .format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
+ insertMap.put("shi_kong_ri_qi_", formatted);
|
|
|
|
|
+ insertMap.put("shi_kong_de_zhi_k", retMap.get("QCRESULT"));
|
|
|
|
|
+ insertMap.put("she_ding_ba_zhi_", retMap.get("STANDARD_SD"));
|
|
|
|
|
+ //定量解析
|
|
|
|
|
+ // 获取原始 QUANT 值
|
|
|
|
|
+ String quant = (String) retMap.get("QUANT");
|
|
|
|
|
+ Set<String> dingLiangSet = new LinkedHashSet<>(); // 用 LinkedHashSet 保持插入顺序,同时去重
|
|
|
|
|
+ List<String> qiTaList = new ArrayList<>();
|
|
|
|
|
+ if (quant != null && !quant.trim().isEmpty()) {
|
|
|
|
|
+ String[] parts = quant.split(",");
|
|
|
|
|
+ for (String part : parts) {
|
|
|
|
|
+ String item = part.trim();
|
|
|
|
|
+ if (item.isEmpty()) continue;
|
|
|
|
|
+ if ("1-3s".equals(item)) {
|
|
|
|
|
+ dingLiangSet.add("1");
|
|
|
|
|
+ } else if ("2-2s".equals(item)) {
|
|
|
|
|
+ dingLiangSet.add("2");
|
|
|
|
|
+ } else if ("R-4s".equals(item)) {
|
|
|
|
|
+ dingLiangSet.add("3");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 其他情况:归为 4,并记录到 qi_ta_shuo_ming_
|
|
|
|
|
+ dingLiangSet.add("4");
|
|
|
|
|
+ qiTaList.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 拼接 ding_liang_
|
|
|
|
|
+ String dingLiangStr = String.join(",", dingLiangSet);
|
|
|
|
|
+ // 拼接 qi_ta_shuo_ming_(去重?按需。这里保留所有出现的“其他”项,也可用 Set 去重)
|
|
|
|
|
+ String qiTaStr = String.join(",", qiTaList);
|
|
|
|
|
+ // 放入 insertMap
|
|
|
|
|
+ insertMap.put("ding_liang_", dingLiangStr);
|
|
|
|
|
+ insertMap.put("qi_ta_shuo_ming_", qiTaStr);
|
|
|
|
|
+
|
|
|
|
|
+ insertMap.put("qi_ta_miao_shu_", retMap.get("REASON"));
|
|
|
|
|
+ insertMap.put("chu_li_cuo_shi_", "6");
|
|
|
|
|
+ insertMap.put("qi_ta_cuo_shi_", retMap.get("ACTION"));
|
|
|
|
|
+ insertMap.put("chu_li_hou_zhi_ko", retMap.get("QCFINALRESULT"));
|
|
|
|
|
+ insertMap.put("shi_fou_zai_kong_", "是".equals(retMap.get("ISINCONTROL")) ? "2" : "1");
|
|
|
|
|
+ insertMap.put("shi_kong_shi_fou_","是".equals(retMap.get("AFFECTSPATIENTSAMPLES")) ? "2" : "1");
|
|
|
|
|
+ insertMap.put("shi_fou_ying_xian", "是".equals(retMap.get("AFFECTSRESULTREPORTING")) ? "2" : "1");
|
|
|
|
|
+ insertMap.put("shuo_ming_", retMap.get("NOTES"));
|
|
|
|
|
+ insertMap.put("fen_xi_yu_zhi_xin", retMap.get("ANALYSIS"));
|
|
|
|
|
+ insertList.add(insertMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!insertList.isEmpty()) {
|
|
|
|
|
+ String res = ibpsRepository.saveToTable(insertList, "t_snzkskbgvb", "1");
|
|
|
|
|
+// String res = "1";
|
|
|
|
|
+ if ("success".equals(res)) {
|
|
|
|
|
+ log.info("table:t_snzkskbgvb success insert: {} datas", insertList.size());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("fail insert t_snzkskbgvb");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("No New Uncontrol Report exist!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 辅助方法:安全获取字符串值,避免空指针异常
|
|
// 辅助方法:安全获取字符串值,避免空指针异常
|
|
|
private String getStringValue(Map<String, Object> map, String key) {
|
|
private String getStringValue(Map<String, Object> map, String key) {
|
|
|
Object value = map.get(key);
|
|
Object value = map.get(key);
|