|
|
@@ -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<>();
|