Просмотр исходного кода

增加质量指标统计功能

huangws 5 месяцев назад
Родитель
Сommit
07cd45ee99

+ 3 - 0
GetDataByRESTful/src/main/java/com/jyxt/getdatabyrestful/service/impl/IBPSServiceImpl.java

@@ -34,6 +34,9 @@ public class IBPSServiceImpl implements IBPSService {
     public int UpdateActualCount() {
         log.info("ready to update records");
         int retVal = 1;
+        if(1==2){
+           return retVal;
+        }
         // 获取LIS实际保存数量
         List<Map<String, Object>> actualList = lisService.geteActualCountList(qryDays);
         // 查询系统中待弃置列表

+ 73 - 69
GetDataByRESTful/src/main/java/com/jyxt/getdatabyrestful/service/impl/LISServiceImpl.java

@@ -31,35 +31,37 @@ public class LISServiceImpl implements LISService {
 
     public List<Map<String, Object>> GetGroupConfig() {
 //        //----------以下为测试用----------
-//        // 1. 创建最外层的List
-//        List<Map<String, Object>> list = new ArrayList<>();
-//        // 2. 创建内层Map
-//        Map<String, Object> map = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map.put("SORTID", "001");
-//        map.put("GROUPCODE", "G002");
-//        map.put("GROUPNAME", "茂源生化");
-//        map.put("SAVEDAY", "7");
-//        map.put("OPRATIONTYPE", "直接转交公司统一焚烧");
-//        list.add(map);
-//        Map<String, Object> map2 = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map2.put("SORTID", "002");
-//        map2.put("GROUPCODE", "G004");
-//        map2.put("GROUPNAME", "茂源免疫");
-//        map2.put("SAVEDAY", "14");
-//        map2.put("OPRATIONTYPE", "直接转交公司统一焚烧");
-//        list.add(map2);
-//
-//        Map<String, Object> map3 = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map3.put("SORTID", "003");
-//        map3.put("GROUPCODE", "G032");
-//        map3.put("GROUPNAME", "茂源临检");
-//        map3.put("SAVEDAY", "7");
-//        map3.put("OPRATIONTYPE", "灭菌后转交公司统一焚烧");
-//        list.add(map3);
-//        return list;
+        if(1==1){
+            // 1. 创建最外层的List
+            List<Map<String, Object>> list = new ArrayList<>();
+            // 2. 创建内层Map
+            Map<String, Object> map = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map.put("SORTID", "001");
+            map.put("GROUPCODE", "G002");
+            map.put("GROUPNAME", "茂源生化");
+            map.put("SAVEDAY", "7");
+            map.put("OPRATIONTYPE", "直接转交公司统一焚烧");
+            list.add(map);
+            Map<String, Object> map2 = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map2.put("SORTID", "002");
+            map2.put("GROUPCODE", "G004");
+            map2.put("GROUPNAME", "茂源免疫");
+            map2.put("SAVEDAY", "14");
+            map2.put("OPRATIONTYPE", "直接转交公司统一焚烧");
+            list.add(map2);
+
+            Map<String, Object> map3 = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map3.put("SORTID", "003");
+            map3.put("GROUPCODE", "G032");
+            map3.put("GROUPNAME", "茂源临检");
+            map3.put("SAVEDAY", "7");
+            map3.put("OPRATIONTYPE", "灭菌后转交公司统一焚烧");
+            list.add(map3);
+            return list;
+        }
 //        //----------以上为测试用----------
         List<Map<String, Object>> resultList = null;
         String SqlQry = "select SORTID,GROUPCODE,GROUPNAME,SAVEDAY,OPRATIONTYPE from v_jt_lisgroupcustom";
@@ -70,38 +72,40 @@ public class LISServiceImpl implements LISService {
 
     public List<Map<String, Object>> GetSampleList(List<Map<String, Object>> inputList){
 //        //----------以下为测试用----------
-//        // 1. 创建最外层的List
-//        List<Map<String, Object>> list = new ArrayList<>();
-//        // 2. 创建内层Map
-//        Map<String, Object> map = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map.put("STATE", "1");
-//        map.put("SAVE_DATE", "20250720");
-//        map.put("INSPECTION_ID", "20250720G0364061112");
-//        map.put("PATIENT_NAME", "赵春香11");
-//        map.put("TEST_ORDER_NAME", "血常规11");
-//        map.put("DESTROY_DATE", "20250727");
-//        list.add(map);
-//        Map<String, Object> map2 = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map2.put("STATE", "1");
-//        map2.put("SAVE_DATE", "20250720");
-//        map2.put("INSPECTION_ID", "20250720G036123124062");
-//        map2.put("PATIENT_NAME", "赵春香22");
-//        map2.put("TEST_ORDER_NAME", "血常规22");
-//        map2.put("DESTROY_DATE", "20250727");
-//        list.add(map2);
-//
-//        Map<String, Object> map3 = new HashMap<>(); // 保持插入顺序
-//        // 3. 向Map中添加数据
-//        map3.put("STATE", "1");
-//        map3.put("SAVE_DATE", "20250720");
-//        map3.put("INSPECTION_ID", "2020G03123312364062");
-//        map3.put("PATIENT_NAME", "赵春香33");
-//        map3.put("TEST_ORDER_NAME", "血常规33");
-//        map3.put("DESTROY_DATE", "20250727");
-//        list.add(map3);
-//        return list;
+        if(1==2) {
+            // 1. 创建最外层的List
+            List<Map<String, Object>> list = new ArrayList<>();
+            // 2. 创建内层Map
+            Map<String, Object> map = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map.put("STATE", "1");
+            map.put("SAVE_DATE", "20250720");
+            map.put("INSPECTION_ID", "20250720G0364061112");
+            map.put("PATIENT_NAME", "赵春香11");
+            map.put("TEST_ORDER_NAME", "血常规11");
+            map.put("DESTROY_DATE", "20250727");
+            list.add(map);
+            Map<String, Object> map2 = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map2.put("STATE", "1");
+            map2.put("SAVE_DATE", "20250720");
+            map2.put("INSPECTION_ID", "20250720G036123124062");
+            map2.put("PATIENT_NAME", "赵春香22");
+            map2.put("TEST_ORDER_NAME", "血常规22");
+            map2.put("DESTROY_DATE", "20250727");
+            list.add(map2);
+
+            Map<String, Object> map3 = new HashMap<>(); // 保持插入顺序
+            // 3. 向Map中添加数据
+            map3.put("STATE", "1");
+            map3.put("SAVE_DATE", "20250720");
+            map3.put("INSPECTION_ID", "2020G03123312364062");
+            map3.put("PATIENT_NAME", "赵春香33");
+            map3.put("TEST_ORDER_NAME", "血常规33");
+            map3.put("DESTROY_DATE", "20250727");
+            list.add(map3);
+            return list;
+        }
 //        //----------以上为测试用----------
         List<Map<String, Object>> resultList = new ArrayList<>();
         for(Map<String, Object> inputMap : inputList) {
@@ -299,9 +303,9 @@ public class LISServiceImpl implements LISService {
         String OperationName = null;
         int ret = -1;
 //        //----------以下为测试用----------
-//        if(1==1){
-//            return 0;
-//        }
+        if(1==2){
+            return 0;
+        }
 //        //----------以上为测试用----------
         List<String> RemoveSampleList = new ArrayList<>();
         for(Map<String, Object> inputMap : inputList) {
@@ -370,9 +374,9 @@ public class LISServiceImpl implements LISService {
         String OperationName = null;
         int ret = -1;
 //        //----------以下为测试用----------
-//        if(1==1){
-//            return 0;
-//        }
+        if(1==2){
+            return 0;
+        }
 //        //----------以上为测试用----------
         List<String> RemoveSampleList = new ArrayList<>();
         for(Map<String, Object> inputMap : inputList) {
@@ -427,9 +431,9 @@ public class LISServiceImpl implements LISService {
         Map<String, Object> out = jdbcCall.execute(inParams);
         ret = Integer.parseInt((String) out.get("a_result"));
         if(!(ret ==0)){
-            log.info("---------------call process:Save-> fail!---------------");
+            log.info("---------------call process:Destory-> fail!---------------");
         }else{
-            log.info("call process:Save-> success!");
+            log.info("call process:Destory-> success!");
         }
         return ret;
     }

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

@@ -47,7 +47,7 @@ public class DateRangeUtil {
 
 
     private static String formatDate(LocalDate start, LocalDate end) {
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         return start.format(formatter) + "|" + end.format(formatter);
     }
 

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

@@ -51,8 +51,8 @@ public class GetDataByViewApplication implements CommandLineRunner{
             }
         }
         //质量指标接口
-//         List<Map<String, Object>>qualityIndicatorList  = ibpsRepository.getUndoQualityIndicator();
-//        handleData.HandQIData(qualityIndicatorList);
+         List<Map<String, Object>>qualityIndicatorList  = ibpsRepository.getUndoQualityIndicator();
+        handleData.HandQIData(qualityIndicatorList);
 
         log.info("<-- -----------this turn finish...------------->");
         context.close(); // 直接关闭上下文

+ 110 - 18
GetDataByView/src/main/java/com/jyxt/getdatabyview/HandleData.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
 
 import java.sql.Timestamp;
 import java.time.LocalDateTime;
+import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 
@@ -26,6 +27,9 @@ public class HandleData {
     @Value("${showTestCodeName}")
     private String showTestCodeName;
 
+    @Value("${manualQryMonth}")
+    private String manualQryMonth;
+
     public static final Map<String, String> RerunSampleField = new HashMap<>();
 
     static {
@@ -147,7 +151,7 @@ public class HandleData {
                 insertList.add(insertMap);
             }
             //            insertList = lisViewRepository.query2("ss");
-            String res = ibpsRepository.saveToTable(insertList, "t_fjbbjlb");
+            String res = ibpsRepository.saveToTable(insertList, "t_fjbbjlb","1");
             if(res.equals("success")){
                 log.info("success insert:"+insertList.size()+" datas");
             } else {
@@ -186,7 +190,7 @@ public class HandleData {
                 insertReportMap.put("ji_lu_bian_hao_", entityMap.get("CREATETIME").toString().substring(0, 4) + "-" + entityMap.get("CREATETIME").toString().substring(4));
                 insertList.add(insertReportMap);
             }
-            String res = ibpsRepository.saveToTable(insertList, "t_dlxmsnzkyfx");
+            String res = ibpsRepository.saveToTable(insertList, "t_dlxmsnzkyfx", "1");
             if(res.equals("success")){
                 log.info("table:t_dlxmsnzkyfx success insert:"+insertList.size()+" datas");
                 handQCTestCode(insertList);
@@ -263,7 +267,7 @@ public class HandleData {
             }
 
             if (!insertList.isEmpty()) {
-                String res = ibpsRepository.saveToTable(insertList, "t_dlxmsnzkyfxzb");
+                String res = ibpsRepository.saveToTable(insertList, "t_dlxmsnzkyfxzb", "1");
                 if ("success".equals(res)) {
                     log.info("table:t_dlxmsnzkyfxzb success insert: {} datas", insertList.size());
                 } else {
@@ -306,21 +310,109 @@ public class HandleData {
     public void HandQIData(List<Map<String, Object>>qualityIndicatorList){
         // 创建用于存储更新数据的列表
         List<Map<String, Object>> updateDataList = new ArrayList<>();
-        for (Map<String, Object> qualityIndicatorMap : qualityIndicatorList) {
-            log.info(qualityIndicatorMap.toString());
-            String DateRange = DateRangeUtil.getDateRange(qualityIndicatorMap.get("bian_zhi_shi_jian").toString());
-            String QryItem = qualityIndicatorMap.get("bei_zhu_").toString().split(":")[1];
-            String retVal = lisViewRepository.GetLISRes(DateRange, QryItem);
-            String id = qualityIndicatorMap.get("id_").toString();
-            String compareRes = ValueEvaluator.evaluateValue(retVal,qualityIndicatorMap.get("yuan_shi_shu_ju_").toString());
-            // 将数据添加到更新列表
-            Map<String, Object> updateData = new HashMap<>();
-            updateData.put("id", id);
-            updateData.put("retVal", retVal);
-            updateData.put("compareRes", compareRes);
-            updateDataList.add(updateData);
+        if (qualityIndicatorList == null || qualityIndicatorList.isEmpty()) {
+            // 执行退出操作
+            return;
+        }
+//        Set<String> distinctSet = new HashSet<>();
+//        for (Map<String, Object> item : qualityIndicatorList) {
+//            Object value = item.get("bian_zhi_shi_jian");
+//            if (value != null) {
+//                distinctSet.add(value.toString());
+//            }
+//        }
+//        // 转换为List
+//        List<String> distinctList = new ArrayList<>(distinctSet);
+
+        LocalDateTime currentDateTime = LocalDateTime.now();
+        DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String formattedDateTime = currentDateTime.format(formatter2);
+
+
+        YearMonth currentYearMonth = YearMonth.now();
+        YearMonth previousMonth = currentYearMonth.minusMonths(1);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年M月份", Locale.CHINA);
+        String DateRange = DateRangeUtil.getDateRange(previousMonth.format(formatter));
+        if(!manualQryMonth.equals("")){
+            DateRange = DateRangeUtil.getDateRange(manualQryMonth);
+        } else {
+            manualQryMonth = previousMonth.format(formatter);
+        }
+        List<Map<String, Object>> lisRetList = lisViewRepository.GetLISRes(DateRange);
+        List<Map<String, Object>> matchList = new ArrayList<>();
+        for (Map<String, Object> undoQIMap : qualityIndicatorList) {
+            String editTime = undoQIMap.get("bian_zhi_shi_jian").toString();
+            //如果不是当前月份退出
+            if(!editTime.equals(manualQryMonth)){
+                continue;
+            }
+            matchList = MatchLISRes(undoQIMap, lisRetList, matchList, formattedDateTime);
+        }
+        if (matchList == null) {
+            log.info("no match data found");
+            return;
+        }
+        //测试输出matchList
+        StringBuilder outString = new StringBuilder("current matchList:\n");
+        for(Map<String, Object> retMap : matchList){
+            outString.append(retMap.toString()).append("\n");
+        }
+        log.info(outString.toString());
+        String retValue = ibpsRepository.saveToTable(matchList,"t_zlzbpjzb","2");
+        if(retValue.equals("success")){
+            log.info("success update:"+matchList.size()+" datas");
+        } else {
+            log.info("fail update");
+        }
+
+
+//        for (Map<String, Object> qualityIndicatorMap : qualityIndicatorList) {
+//            log.info(qualityIndicatorMap.toString());
+//            String DateRange = DateRangeUtil.getDateRange(qualityIndicatorMap.get("bian_zhi_shi_jian").toString());
+//            String QryItem = qualityIndicatorMap.get("bei_zhu_").toString().split(":")[1];
+//
+//            String id = qualityIndicatorMap.get("id_").toString();
+//            String compareRes = ValueEvaluator.evaluateValue(retVal,qualityIndicatorMap.get("yuan_shi_shu_ju_").toString());
+//            // 将数据添加到更新列表
+//            Map<String, Object> updateData = new HashMap<>();
+//            updateData.put("id", id);
+//            updateData.put("retVal", retVal);
+//            updateData.put("compareRes", compareRes);
+//            updateDataList.add(updateData);
+//        }
+//        // 调用抽离的保存方法
+//        ibpsRepository.updateQualityIndicatorData(updateDataList);
+    }
+
+    public List<Map<String, Object>> MatchLISRes(Map<String, Object> undoQIMap, List<Map<String, Object>> lisRetList, List<Map<String, Object>> matchList, String formattedDateTime) {
+        // 如果 matchList 为 null,则初始化
+        if (matchList == null) {
+            matchList = new ArrayList<>();
+        }
+
+        // 获取 bei_zhu_ 字段值
+        String beiZhu = (String) undoQIMap.get("bei_zhu_");
+
+        // 在 lisRetList 中查找匹配的记录
+        for (Map<String, Object> lisMap : lisRetList) {
+            String currentLisFlag = (String) lisMap.get("lisFlag");
+            if (beiZhu.equals(currentLisFlag)) {
+                // 找到匹配项,创建新的匹配记录
+                Map<String, Object> matchRecord = new HashMap<>();
+                matchRecord.put("id_", undoQIMap.get("id_")); // 从 undoQIMap 取 id_
+                matchRecord.put("shi_ji_shu_zhi_", lisMap.get("percentage")); // 从 lisRetList 取 percentage
+                //计算是否达标
+                String curValue = lisMap.get("percentage").toString();
+                String compChar = undoQIMap.get("yuan_shi_shu_ju_").toString();
+                String compRes = ValueEvaluator.evaluateValue(curValue, compChar);
+                matchRecord.put("da_biao_qing_kuan", compRes);
+                matchRecord.put("zhuang_tai_", "已完成");
+                matchRecord.put("update_time_", Timestamp.valueOf(String.valueOf(formattedDateTime)));
+                log.info("curValue:"+curValue+", compChar:"+compChar+", cpmpare result:"+compRes);
+                matchList.add(matchRecord);
+                break; // 找到匹配后跳出内层循环
+            }
         }
-        // 调用抽离的保存方法
-        ibpsRepository.updateQualityIndicatorData(updateDataList);
+        return matchList;
     }
 }

+ 134 - 47
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/IBPSRepository.java

@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Repository
@@ -50,64 +51,148 @@ public class IBPSRepository {
     }
 
 
-    public String saveToTable(List<Map<String, Object>> inputList, String TableName) {
+    public String saveToTable(List<Map<String, Object>> inputList, String TableName, String saveType) {
         String retValue = "fail";
         if (inputList == null || inputList.isEmpty() || TableName == null || TableName.trim().isEmpty()) {
             return retValue;
         }
+
+        // 验证 saveType 参数
+        if (!"1".equals(saveType) && !"2".equals(saveType)) {
+            return "invalid saveType, must be '1' or '2'";
+        }
+
         try {
-            // 获取第一个Map的字段名作为表字段
-            Map<String, Object> firstRow = inputList.get(0);
-            String columns = String.join(",", firstRow.keySet());
-
-            // 构建占位符部分 (?,?,...)
-            String placeholders = String.join(",", Collections.nCopies(firstRow.size(), "?"));
-
-            // 构建完整SQL语句
-            String sql = String.format("INSERT INTO %s (%s) VALUES (%s)", TableName, columns, placeholders);
-            log.info("executing sql: " + sql);
-            if(qryMode.equals("0")){
-                log.info("ready to insert:");
-                // 批量执行
-                jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
-                    @Override
-                    public void setValues(PreparedStatement ps, int i) throws SQLException {
-                        Map<String, Object> row = inputList.get(i);
-                        int index = 1;
-                        for (Map.Entry<String, Object> entry : row.entrySet()) {
-                            String key = entry.getKey();
-                            Object value = entry.getValue();
-
-                            if (key.contains("Time") && value instanceof Timestamp) {
-                                ps.setTimestamp(index++, (Timestamp) value);
-                            } else {
-                                ps.setString(index++, value.toString());
-                            }
-                        }
-                    }
-                    @Override
-                    public int getBatchSize() {
-                        return inputList.size();
-                    }
-                });
-            }
-            else{
-                log.info("------qry mode,pretent to insert-------");
-                inputList.forEach(map -> {
-                    StringBuilder sb = new StringBuilder();
-                    map.forEach((k, v) -> sb.append(k).append(":").append(v).append(","));
-                    if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
-                    log.info(sb.toString());
-                });
+            if ("1".equals(saveType)) {
+                // 原有插入逻辑
+                retValue = executeInsert(inputList, TableName);
+            } else if ("2".equals(saveType)) {
+                // 新增更新逻辑
+                retValue = executeUpdate(inputList, TableName);
             }
-            retValue = "success";
         } catch (Exception e) {
             e.printStackTrace();
-            return "insert failed:"+e.getMessage().split(";")[2];
+            String errorMsg = "1".equals(saveType) ? "insert" : "update";
+            return errorMsg + " failed:" + (e.getMessage() != null ? e.getMessage().split(";")[0] : e.getMessage());
         }
         return retValue;
     }
 
+    /**
+     * 执行插入操作
+     */
+    private String executeInsert(List<Map<String, Object>> inputList, String TableName) {
+        Map<String, Object> firstRow = inputList.get(0);
+        String columns = String.join(",", firstRow.keySet());
+        String placeholders = String.join(",", Collections.nCopies(firstRow.size(), "?"));
+        String sql = String.format("INSERT INTO %s (%s) VALUES (%s)", TableName, columns, placeholders);
+
+        log.info("executing insert sql: " + sql);
+
+        if (qryMode.equals("0")) {
+            log.info("ready to insert " + inputList.size() + " records");
+            jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
+                @Override
+                public void setValues(PreparedStatement ps, int i) throws SQLException {
+                    Map<String, Object> row = inputList.get(i);
+                    int index = 1;
+                    for (Map.Entry<String, Object> entry : row.entrySet()) {
+                        String key = entry.getKey();
+                        Object value = entry.getValue();
+
+                        if (key.contains("Time") && value instanceof Timestamp) {
+                            ps.setTimestamp(index++, (Timestamp) value);
+                        } else {
+                            ps.setString(index++, value.toString());
+                        }
+                    }
+                }
+                @Override
+                public int getBatchSize() {
+                    return inputList.size();
+                }
+            });
+            log.info("insert completed successfully");
+        } else {
+            log.info("------qry mode, pretend to insert " + inputList.size() + " records-------");
+            inputList.forEach(map -> {
+                StringBuilder sb = new StringBuilder();
+                map.forEach((k, v) -> sb.append(k).append(":").append(v).append(","));
+                if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
+                log.info("Insert data: " + sb.toString());
+            });
+        }
+        return "success";
+    }
+
+    /**
+     * 执行更新操作
+     */
+    private String executeUpdate(List<Map<String, Object>> inputList, String TableName) {
+        // 检查是否包含 id_ 字段
+        Map<String, Object> firstRow = inputList.get(0);
+        if (!firstRow.containsKey("id_")) {
+            return "update failed: missing 'id_' field in input data";
+        }
+
+        // 构建更新SQL (排除id_字段,因为它作为WHERE条件)
+        List<String> columns = firstRow.keySet().stream()
+                .filter(key -> !"id_".equals(key))
+                .collect(Collectors.toList());
+
+        String setClause = columns.stream()
+                .map(column -> column + " = ?")
+                .collect(Collectors.joining(","));
+
+        String sql = String.format("UPDATE %s SET %s WHERE id_ = ?", TableName, setClause);
+
+        log.info("executing update sql: " + sql);
+
+        if (qryMode.equals("0")) {
+            log.info("ready to update " + inputList.size() + " records");
+            jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
+                @Override
+                public void setValues(PreparedStatement ps, int i) throws SQLException {
+                    Map<String, Object> row = inputList.get(i);
+                    int index = 1;
+
+                    // 设置SET部分的参数
+                    for (String column : columns) {
+                        Object value = row.get(column);
+                        if (column.contains("Time") && value instanceof Timestamp) {
+                            ps.setTimestamp(index++, (Timestamp) value);
+                        } else {
+                            ps.setString(index++, value != null ? value.toString() : null);
+                        }
+                    }
+
+                    // 设置WHERE条件的id_参数
+                    Object idValue = row.get("id_");
+                    if (idValue instanceof Timestamp) {
+                        ps.setTimestamp(index, (Timestamp) idValue);
+                    } else {
+                        ps.setString(index, idValue != null ? idValue.toString() : null);
+                    }
+                }
+
+                @Override
+                public int getBatchSize() {
+                    return inputList.size();
+                }
+            });
+            log.info("update completed successfully");
+        } else {
+            log.info("------qry mode, pretend to update " + inputList.size() + " records-------");
+            inputList.forEach(map -> {
+                StringBuilder sb = new StringBuilder();
+                map.forEach((k, v) -> sb.append(k).append(":").append(v).append(","));
+                if (sb.length() > 0) sb.deleteCharAt(sb.length() - 1);
+                log.info("Update data (id_=" + map.get("id_") + "): " + sb.toString());
+            });
+        }
+        return "success";
+    }
+
     /**
      * 获取基础数据:
      * LIS系统用户名对应金通用户信息
@@ -170,7 +255,8 @@ public class IBPSRepository {
 
     public List<Map<String, Object>> getUndoQualityIndicator(){
         List<Map<String, Object>> retList = new ArrayList<>();
-        String sqlStr = "select id_,bian_zhi_shi_jian,zhi_liang_zhi_bia,yuan_shi_shu_ju_,bei_zhu_ from t_zlzbpjzb where zhuang_tai_='待处理' and bei_zhu_ like 'LIS导入%'";
+        String sqlStr = "select id_,bian_zhi_shi_jian,zhi_liang_mu_biao,zhi_liang_zhi_bia,yuan_shi_shu_ju_,bei_zhu_ from t_zlzbpjzb where zhuang_tai_='待处理' and bei_zhu_ like 'LIS导入%'";
+        log.info("excute sql:"+sqlStr);
         retList = jdbcTemplate.queryForList(sqlStr);
         return retList;
     }
@@ -182,6 +268,7 @@ public class IBPSRepository {
         }
 
         String sql = "UPDATE t_zlzbpjzb SET shi_ji_shu_zhi_ = ?, da_biao_qing_kuan = ?, zhuang_tai_ = ?, bei_zhu_ = ? WHERE id_ = ?";
+        log.info("excute sql:"+sql);
         log.info("Ready to update data into table t_zlzbpjzb");
         try {
             List<Object[]> batchArgs = new ArrayList<>();

+ 539 - 3
GetDataByView/src/main/java/com/jyxt/getdatabyview/view/repository/LISViewRepository.java

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Repository;
 
 import java.sql.Timestamp;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 
@@ -26,6 +27,9 @@ public class LISViewRepository {
     @Value("${onlyQrySecondDay}")
     private String onlyQrySecondDay;
 
+    @Value("${delayLimit}")
+    private String delayLimit;
+
     public List<Map<String, Object>> query(String tableName) {
         List<Map<String, Object>> retList = null;
         //复查样本记录
@@ -81,14 +85,546 @@ public class LISViewRepository {
         return retList;
     }
 
-    public String GetLISRes(String DateRange, String QryItem){
-        log.info("try to get LIS res:"+QryItem);
-        return "0.07";
+    public List<Map<String, Object>> GetLISRes(String DateRange){
+        log.info("try to get LIS res:"+DateRange);
+        String startDate = DateRange.split("\\|")[0];
+        String endDate = DateRange.split("\\|")[1];
+        // 创建结果列表
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        if ("1".equals(onlyQrySecondDay)) {
+            Calendar calendar = Calendar.getInstance();
+            int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
+            if (currentDay != 2) {
+                log.info("非当月第二日,跳过查询");
+                return resultList;  // 非1号直接返回空列表
+            }
+        }
+        if(1==2){
+            Map<String, Object> bloodCultureMap = new HashMap<>();
+            bloodCultureMap.put("name", "血培养污染率");
+            bloodCultureMap.put("count", 95);
+            bloodCultureMap.put("percentage", String.format("%.2f", 95.0));
+            bloodCultureMap.put("totalCount", 100);
+            bloodCultureMap.put("lisFlag", "LIS导入:7");
+            // 添加到结果列表
+            resultList.add(bloodCultureMap);
+            return resultList;
+        }
+        //------------1.标本合格率相关------------
+        resultList = GetSampleQualify(startDate, endDate, resultList);
+        //------------2.血培养污染率------------
+        resultList = GetBloodCulture(startDate, endDate, resultList);
+        //------------3.TAT相关------------
+        resultList = GetTATStat(startDate, endDate, resultList);
+        //------------4.报告准确率------------
+        resultList = GetCancelReportStat(startDate, endDate, resultList);
+        //------------5.危急值相关------------
+        resultList = GetAlarmReportStat(startDate, endDate, resultList);
+        StringBuilder outString = new StringBuilder("current resultList:\n");
+        for(Map<String, Object> retMap : resultList){
+            outString.append(retMap.toString()).append("\n");
+        }
+        log.info(outString.toString());
+        return resultList;
+    }
+
+    //------------1.标本合格率相关------------
+    public List<Map<String, Object>> GetSampleQualify(String startDate, String endDate, List<Map<String, Object>> resultList){
+        String sqlQry="select REJECTDESC,count(*) as total from V_JT_ZLLISRequest where sampledate BETWEEN '"+startDate+"' AND '"+endDate+"' group by REJECTDESC ";
+        log.info("excute sql:"+sqlQry);
+        List<Map<String, Object>> qryList = jdbcTemplate.queryForList(sqlQry);
+        // 计算总数
+        int totalCount = 0;
+        for (Map<String, Object> map : qryList) {
+            Object totalObj = map.get("total");
+            if (totalObj != null) {
+                totalCount += Integer.parseInt(totalObj.toString());
+            }
+        }
+        // 初始化各项统计值
+        int qualifiedCount = 0;          // 合格标本数
+        int rejectedCount = 0;           // 拒收标本数
+        int clottedCount = 0;            // 凝集标本数
+        int typeErrorCount = 0;          // 类型错误数
+        int tubeErrorCount = 0;     // 容器错误数
+        int volumeErrorCount = 0;        // 采集量错误数
+
+        // 遍历查询结果进行统计
+        for (Map<String, Object> map : qryList) {
+            Object rejectDescObj = map.get("REJECTDESC");
+            Object totalObj = map.get("total");
+            if (totalObj == null) continue;
+            int count = Integer.parseInt(totalObj.toString());
+            String rejectDesc = rejectDescObj == null ? null : rejectDescObj.toString();
+            // 统计合格标本(REJECTDESC为空)
+            if (rejectDesc == null || rejectDesc.trim().isEmpty()) {
+                qualifiedCount += count;
+            } else {
+                rejectedCount += count;
+
+                // 统计具体拒收原因
+                switch (rejectDesc) {
+                    case "抗凝标本凝集":
+                        clottedCount += count;
+                        break;
+                    case "标本类型错误":
+                        typeErrorCount += count;
+                        break;
+                    case "标本容器错误":
+                        tubeErrorCount += count;
+                        break;
+                    case "标本采集量错误":
+                    case "标本量过多":
+                    case "标本量过少":
+                        volumeErrorCount += count;
+                        break;
+                }
+            }
+        }
+
+        // 总标本合格率
+        Map<String, Object> qualifiedMap = new HashMap<>();
+        qualifiedMap.put("name", "总标本合格率");
+        qualifiedMap.put("count", qualifiedCount);
+        qualifiedMap.put("percentage", String.format("%.2f", (qualifiedCount * 100.0 / totalCount)));
+        qualifiedMap.put("totalCount", totalCount);
+        qualifiedMap.put("lisFlag", "LIS导入:1");
+        resultList.add(qualifiedMap);
+        log.info("add to resultList:"+qualifiedMap.toString());
+        // 不符合实验室标本接收条件而拒收的标本数
+        Map<String, Object> rejectedMap = new HashMap<>();
+        rejectedMap.put("name", "不符合实验室标本接收条件而拒收的标本数");
+        rejectedMap.put("count", rejectedCount);
+        rejectedMap.put("percentage", String.format("%.2f", (rejectedCount * 100.0 / totalCount)));
+        rejectedMap.put("totalCount", totalCount);
+        rejectedMap.put("lisFlag", "LIS导入:2");
+        resultList.add(rejectedMap);
+        log.info("add to resultList:"+rejectedMap.toString());
+        // 凝集的标本数
+        Map<String, Object> clottedMap = new HashMap<>();
+        clottedMap.put("name", "凝集的标本数");
+        clottedMap.put("count", clottedCount);
+        clottedMap.put("percentage", String.format("%.2f", (clottedCount * 100.0 / totalCount)));
+        clottedMap.put("totalCount", totalCount);
+        clottedMap.put("lisFlag", "LIS导入:3");
+        resultList.add(clottedMap);
+        log.info("add to resultList:"+clottedMap.toString());
+        // 类型不符合要求的标本数
+        Map<String, Object> typeErrorMap = new HashMap<>();
+        typeErrorMap.put("name", "类型不符合要求的标本数");
+        typeErrorMap.put("count", typeErrorCount);
+        typeErrorMap.put("percentage", String.format("%.2f", (typeErrorCount * 100.0 / totalCount)));
+        typeErrorMap.put("totalCount", totalCount);
+        typeErrorMap.put("lisFlag", "LIS导入:4");
+        resultList.add(typeErrorMap);
+        log.info("add to resultList:"+typeErrorMap.toString());
+        // 采集容器不符合要求的标本数
+        Map<String, Object> containerErrorMap = new HashMap<>();
+        containerErrorMap.put("name", "采集容器不符合要求的标本数");
+        containerErrorMap.put("count", tubeErrorCount);
+        containerErrorMap.put("percentage", String.format("%.2f", (tubeErrorCount * 100.0 / totalCount)));
+        containerErrorMap.put("totalCount", totalCount);
+        containerErrorMap.put("lisFlag", "LIS导入:5");
+        resultList.add(containerErrorMap);
+        log.info("add to resultList:"+containerErrorMap.toString());
+        // 采集量不符合要求的标本数
+        Map<String, Object> volumeErrorMap = new HashMap<>();
+        volumeErrorMap.put("name", "采集量不符合要求的标本数");
+        volumeErrorMap.put("count", volumeErrorCount);
+        volumeErrorMap.put("percentage", String.format("%.2f", (volumeErrorCount * 100.0 / totalCount)));
+        volumeErrorMap.put("totalCount", totalCount);
+        volumeErrorMap.put("lisFlag", "LIS导入:6");
+        resultList.add(volumeErrorMap);
+        log.info("add to resultList:"+volumeErrorMap.toString());
+        return resultList;
+    }
+
+    //------------2.血培养污染率------------
+    public List<Map<String, Object>> GetBloodCulture(String startDate, String endDate, List<Map<String, Object>> resultList) {
+        String sqlQry = "select P1,P2,WR2,WR3,WR4 from V_JT_ZLBloodCulture where sampledate BETWEEN '" + startDate + "' AND '" + endDate + "'";
+        log.info("excute sql:"+sqlQry);
+        List<Map<String, Object>> qryList = jdbcTemplate.queryForList(sqlQry);
+        // 计算总数
+        int totalCount = qryList.size();
+        // 如果总数为0,直接返回原结果列表
+        if (totalCount == 0) {
+            return resultList;
+        }
+        // 统计污染数量
+        int contaminatedCount = 0;
+        for (Map<String, Object> record : qryList) {
+            // 获取P1、P2的值
+            Object p1Obj = record.get("P1");
+            Object p2Obj = record.get("P2");
+            // 转换为整数,如果为null则默认为0
+            int p1 = p1Obj != null ? Integer.parseInt(p1Obj.toString()) : 0;
+            int p2 = p2Obj != null ? Integer.parseInt(p2Obj.toString()) : 0;
+            // 根据规则判断是否污染
+            if (isContaminated(p1, p2, record)) {
+                contaminatedCount++;
+            }
+        }
+        // 计算污染率
+        double contaminationRate = (contaminatedCount * 100.0) / totalCount;
+        // 创建血培养污染率的统计结果
+        Map<String, Object> bloodCultureMap = new HashMap<>();
+        bloodCultureMap.put("name", "血培养污染率");
+        bloodCultureMap.put("count", contaminatedCount);
+        bloodCultureMap.put("percentage", String.format("%.2f", contaminationRate));
+        bloodCultureMap.put("totalCount", totalCount);
+        bloodCultureMap.put("lisFlag", "LIS导入:7");
+        // 添加到结果列表
+        resultList.add(bloodCultureMap);
+        log.info("add to resultList:"+bloodCultureMap.toString());
+        return resultList;
     }
 
+    /**
+     * 判断血培养记录是否污染
+     * @param p1 P1字段值
+     * @param p2 P2字段值
+     * @param record 数据记录
+     * @return true表示污染,false表示未污染
+     */
+    private boolean isContaminated(int p1, int p2, Map<String, Object> record) {
+        // 获取WR字段的值
+        int wr1 = getIntValue(record.get("WR1"));
+        int wr2 = getIntValue(record.get("WR2"));
+        int wr3 = getIntValue(record.get("WR3"));
+        int wr4 = getIntValue(record.get("WR4"));
 
+        // 根据规则判断
+        if (p1 == 1 && p2 == 1) {
+            // P1=1, P2=1: 检查WR1,WR2,WR3,WR4,有且只有一个是1表示污染
+            int wrSum = wr1 + wr2 + wr3 + wr4;
+            return wrSum == 1;
+        } else if (p1 == 1 && p2 == 0) {
+            // P1=1, P2=0: 检查WR1,WR2,有且只有一个是1表示污染
+            int wrSum = wr1 + wr2;
+            return wrSum == 1;
+        }
 
+        // 其他情况视为未污染
+        return false;
+    }
 
+    /**
+     * 将对象值转换为整数,如果为null则返回0
+     */
+    private int getIntValue(Object value) {
+        if (value == null) {
+            return 0;
+        }
+        try {
+            return Integer.parseInt(value.toString());
+        } catch (NumberFormatException e) {
+            return 0;
+        }
+    }
+
+    //------------3.TAT相关------------
+    public List<Map<String, Object>> GetTATStat(String startDate, String endDate, List<Map<String, Object>> resultList){
+        String sqlQry = "select DUEREPORTTIME,ACTREPORTTIME,TARGETTAT,ACTTAT from V_JT_ZLTAT where ReportDate BETWEEN '" + startDate + "' AND '" + endDate + "' and DUEREPORTTIME is not null";
+        log.info("excute sql:"+sqlQry);
+        List<Map<String, Object>> qryList = jdbcTemplate.queryForList(sqlQry);
+
+        // 计算总数
+        int totalCount = qryList.size();
+        // 如果总数为0,直接返回原结果列表
+        if (totalCount == 0) {
+            return resultList;
+        }
+
+        // 1. 统计TAT时间合格率
+        int qualifiedCount = 0;
+        for (Map<String, Object> record : qryList) {
+            Object dueTimeObj = record.get("DUEREPORTTIME");
+            Object actTimeObj = record.get("ACTREPORTTIME");
+
+            if (dueTimeObj != null && actTimeObj != null) {
+                String dueTimeStr = dueTimeObj.toString();
+                String actTimeStr = actTimeObj.toString();
+
+                if (isTimeBefore(actTimeStr, dueTimeStr)) {
+                    qualifiedCount++;
+                }
+            }
+        }
+        double qualifiedRate = (qualifiedCount * 100.0) / totalCount;
+
+        // 创建TAT时间合格率的统计结果
+        Map<String, Object> qualifiedMap = new HashMap<>();
+        qualifiedMap.put("name", "TAT时间合格率");
+        qualifiedMap.put("count", qualifiedCount);
+        qualifiedMap.put("percentage", String.format("%.2f", qualifiedRate));
+        qualifiedMap.put("totalCount", totalCount);
+        qualifiedMap.put("lisFlag", "LIS导入:8");
+        resultList.add(qualifiedMap);
+        log.info("add to resultList:"+qualifiedMap.toString());
+
+        // 2-4. 统计不同TARGETTAT的第90百分位数
+        addPercentileStat(resultList, qryList, 30, "TAT设定30分钟的检验标本检验总周转时间第90百分位数","9");
+        addPercentileStat(resultList, qryList, 120, "TAT设定2小时的检验标本检验总周转时间第90百分位数","10");
+        addPercentileStat(resultList, qryList, 240, "TAT设定4小时的检验标本检验总周转时间第90百分位数","11");
+
+        return resultList;
+    }
+
+    /**
+     * 辅助方法:添加百分位数统计
+     */
+    private void addPercentileStat(List<Map<String, Object>> resultList,List<Map<String, Object>> qryList,int targetTat,String statName, String lisFlag) {
+        // 过滤出指定TARGETTAT的记录
+        List<Double> actTatValues = new ArrayList<>();
+        for (Map<String, Object> record : qryList) {
+            Object targetTatObj = record.get("TARGETTAT");
+            Object actTatObj = record.get("ACTTAT");
+
+            if (targetTatObj != null && actTatObj != null) {
+                try {
+                    int currentTargetTat = Integer.parseInt(targetTatObj.toString());
+                    double actTat = Double.parseDouble(actTatObj.toString());
+
+                    if (currentTargetTat == targetTat) {
+                        actTatValues.add(actTat);
+                    }
+                } catch (NumberFormatException e) {
+                    // 忽略格式错误的数据
+                }
+            }
+        }
+
+        // 计算第90百分位数
+        double percentile90 = calculatePercentile(actTatValues, 90);
+        int dataCount = actTatValues.size();
+
+        // 创建统计结果
+        Map<String, Object> statMap = new HashMap<>();
+        statMap.put("name", statName);
+        statMap.put("count", Math.round(percentile90)); // 四舍五入取整
+        statMap.put("percentage", String.format("%.2f", percentile90));
+        statMap.put("totalCount", dataCount);
+        statMap.put("lisFlag", "LIS导入:"+lisFlag);
+        resultList.add(statMap);
+        log.info("add to resultList:"+statMap.toString());
+    }
+
+    /**
+     * 计算百分位数
+     * @param values 数据列表
+     * @param percentile 百分位(0-100)
+     * @return 百分位数
+     */
+    private double calculatePercentile(List<Double> values, double percentile) {
+        if (values == null || values.isEmpty()) {
+            return 0.0;
+        }
+
+        // 排序
+        List<Double> sortedValues = new ArrayList<>(values);
+        Collections.sort(sortedValues);
+
+        // 计算位置
+        double position = (percentile / 100.0) * (sortedValues.size() - 1);
+        int lowerIndex = (int) Math.floor(position);
+        int upperIndex = (int) Math.ceil(position);
+
+        if (lowerIndex == upperIndex) {
+            // 位置是整数,直接返回该位置的值
+            return sortedValues.get(lowerIndex);
+        } else {
+            // 位置不是整数,进行线性插值
+            double lowerValue = sortedValues.get(lowerIndex);
+            double upperValue = sortedValues.get(upperIndex);
+            double weight = position - lowerIndex;
+            return lowerValue + (upperValue - lowerValue) * weight;
+        }
+    }
+
+    /**
+     * 判断实际报告时间是否早于应报告时间
+     * @param actTimeStr 实际报告时间字符串
+     * @param dueTimeStr 应报告时间字符串
+     * @return 如果实际时间早于应报告时间返回true
+     */
+    private boolean isTimeBefore(String actTimeStr, String dueTimeStr) {
+        try {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+            LocalDateTime actTime = LocalDateTime.parse(actTimeStr, formatter);
+            LocalDateTime dueTime = LocalDateTime.parse(dueTimeStr, formatter);
+            return actTime.isBefore(dueTime);
+        } catch (Exception e) {
+            // 如果时间格式解析失败,返回false
+            return false;
+        }
+    }
+
+    //------------4.报告准确率------------
+    public List<Map<String, Object>> GetCancelReportStat(String startDate, String endDate, List<Map<String, Object>> resultList){
+        String sqlQry = "SELECT CANELDESC, COUNT(*) as total FROM V_JT_ZLCancelReport WHERE ReportDate BETWEEN '" + startDate + "' AND '" + endDate + "' group by CANELDESC ";
+        log.info("excute sql:" + sqlQry);
+        List<Map<String, Object>> qryList = jdbcTemplate.queryForList(sqlQry);
+
+        // 计算总数
+        int totalCount = 0;
+        for (Map<String, Object> map : qryList) {
+            Object totalObj = map.get("total");
+            if (totalObj != null) {
+                totalCount += Integer.parseInt(totalObj.toString());
+            }
+        }
+
+        // 如果总数为0,直接返回原结果列表
+        if (totalCount == 0) {
+            return resultList;
+        }
+
+        // 初始化统计变量
+        int accurateCount = 0;  // CANELDESC为0或1的数量
+        int incorrectCount = 0; // CANELDESC为2的数量
+
+        // 遍历查询结果进行统计
+        for (Map<String, Object> map : qryList) {
+            Object canelDescObj = map.get("CANELDESC");
+            Object totalObj = map.get("total");
+
+            if (totalObj == null) continue;
+
+            int count = Integer.parseInt(totalObj.toString());
+
+            // 将CANELDESC转换为字符串进行比较
+            String canelDesc = canelDescObj != null ? canelDescObj.toString() : "";
+
+            // 统计报告准确率(CANELDESC为0或1)
+            if ("0".equals(canelDesc) || "1".equals(canelDesc)) {
+                accurateCount += count;
+            }
+            // 统计检验报告不正确率(CANELDESC为2)
+            else if ("2".equals(canelDesc)) {
+                incorrectCount += count;
+            }
+            // 其他CANELDESC值不参与统计
+        }
+
+        // 计算百分比
+        double accurateRate = (accurateCount * 100.0) / totalCount;
+        double incorrectRate = (incorrectCount * 100.0) / totalCount;
+
+        // 创建报告准确率的统计结果
+        Map<String, Object> accurateMap = new HashMap<>();
+        accurateMap.put("name", "报告准确率");
+        accurateMap.put("count", accurateCount);
+        accurateMap.put("percentage", String.format("%.2f", accurateRate));
+        accurateMap.put("totalCount", totalCount);
+        accurateMap.put("lisFlag", "LIS导入:12");
+        resultList.add(accurateMap);
+        log.info("add to resultList:"+accurateMap.toString());
+        // 创建检验报告不正确率的统计结果
+        Map<String, Object> incorrectMap = new HashMap<>();
+        incorrectMap.put("name", "检验报告不正确率");
+        incorrectMap.put("count", incorrectCount);
+        incorrectMap.put("percentage", String.format("%.2f", incorrectRate));
+        incorrectMap.put("totalCount", totalCount);
+        incorrectMap.put("lisFlag", "LIS导入:13");
+        resultList.add(incorrectMap);
+        log.info("add to resultList:"+incorrectMap.toString());
+        return resultList;
+    }
+
+    //------------5.危急值相关------------
+    public List<Map<String, Object>> GetAlarmReportStat(String startDate, String endDate, List<Map<String, Object>> resultList) {
+        String sqlQry = "select ALARMSTATE,USEMINUTES from V_JT_ZLAlarmReport WHERE ReportDate BETWEEN '" + startDate + "' AND '" + endDate + "'";
+        log.info("excute sql:" + sqlQry);
+        List<Map<String, Object>> qryList = jdbcTemplate.queryForList(sqlQry);
+
+        // 计算总数
+        int totalCount = qryList.size();
+        // 如果总数为0,直接返回原结果列表
+        if (totalCount == 0) {
+            return resultList;
+        }
+
+        // 初始化统计变量
+        int qualifiedCount = 0;  // 危急值通报合格数量
+        int reportedCount = 0;   // 危急值通报数量(ALARMSTATE=2)
+        int timelyCount = 0;     // 危急值通报及时数量
+
+        // 遍历查询结果进行统计
+        for (Map<String, Object> record : qryList) {
+            Object alarmStateObj = record.get("ALARMSTATE");
+            Object useMinutesObj = record.get("USEMINUTES");
+
+            // 转换ALARMSTATE为整数
+            int alarmState = 0;
+            if (alarmStateObj != null) {
+                try {
+                    alarmState = Integer.parseInt(alarmStateObj.toString());
+                } catch (NumberFormatException e) {
+                    // 转换失败,默认为0
+                }
+            }
+
+            // 转换USEMINUTES为整数
+            int useMinutes = 0;
+            if (useMinutesObj != null) {
+                try {
+                    useMinutes = Integer.parseInt(useMinutesObj.toString());
+                } catch (NumberFormatException e) {
+                    // 转换失败,默认为0
+                }
+            }
+
+            // 统计危急值通报数量(ALARMSTATE=2)
+            if (alarmState == 2) {
+                reportedCount++;
+            }
+
+            // 根据需求,这里假设delayLimit是一个预定义的延迟限制值
+            // 如果没有提供,我们需要从其他地方获取或使用默认值
+            // 这里假设delayLimit=30分钟作为示例
+            int delayLimit = 30; // 这个值应该根据实际业务需求确定
+
+            // 统计危急值通报合格数量和及时数量
+            if (useMinutes < delayLimit) {
+                qualifiedCount++;
+                timelyCount++;
+            }
+        }
+
+        // 计算百分比
+        double qualifiedRate = (qualifiedCount * 100.0) / totalCount;
+        double reportedRate = (reportedCount * 100.0) / totalCount;
+        double timelyRate = (timelyCount * 100.0) / totalCount;
+
+        // 创建危急值通报合格率的统计结果
+        Map<String, Object> qualifiedMap = new HashMap<>();
+        qualifiedMap.put("name", "危急值通报合格率");
+        qualifiedMap.put("count", qualifiedCount);
+        qualifiedMap.put("percentage", String.format("%.2f", qualifiedRate));
+        qualifiedMap.put("totalCount", totalCount);
+        qualifiedMap.put("lisFlag", "LIS导入:14");
+        resultList.add(qualifiedMap);
+        log.info("add to resultList:"+qualifiedMap.toString());
+        // 创建危急值通报率的统计结果
+        Map<String, Object> reportedMap = new HashMap<>();
+        reportedMap.put("name", "危急值通报率");
+        reportedMap.put("count", reportedCount);
+        reportedMap.put("percentage", String.format("%.2f", reportedRate));
+        reportedMap.put("totalCount", totalCount);
+        reportedMap.put("lisFlag", "LIS导入:15");
+        resultList.add(reportedMap);
+        log.info("add to resultList:"+reportedMap.toString());
+        // 创建危急值通报及时率的统计结果
+        Map<String, Object> timelyMap = new HashMap<>();
+        timelyMap.put("name", "危急值通报及时率");
+        timelyMap.put("count", timelyCount);
+        timelyMap.put("percentage", String.format("%.2f", timelyRate));
+        timelyMap.put("totalCount", totalCount);
+        timelyMap.put("lisFlag", "LIS导入:16");
+        resultList.add(timelyMap);
+        log.info("add to resultList:"+timelyMap.toString());
+        return resultList;
+    }
 
     public List<Map<String, Object>> query2(String tableName) {
         List<Map<String, Object>> retList = new ArrayList<>();

+ 4 - 0
GetDataByView/src/main/resources/application.properties

@@ -20,3 +20,7 @@ config.qryMode=0
 onlyQrySecondDay=0
 #1 means Chinese name,0 means code
 showTestCodeName=1
+#AlarmReport delay limit
+delayLimit=10
+#yyyy?M??
+manualQryMonth=