Merge remote-tracking branch 'lis8.0/master'
This commit is contained in:
commit
7aa126dbe5
@ -73,9 +73,11 @@ public class LabPat extends BaseEntity {
|
||||
private String wyh;
|
||||
private Integer shcs;
|
||||
private String lstd;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String slzq;
|
||||
private String checker;
|
||||
private String autojgbz;
|
||||
private String faultman;
|
||||
private String fault;
|
||||
private String faults;
|
||||
private Date faultdt;
|
||||
}
|
||||
|
||||
@ -37,4 +37,6 @@ public class LabResult extends BaseEntity {
|
||||
private String redoFlag;
|
||||
private String sqxmdh;
|
||||
private String xmmc;
|
||||
private String ygzd;
|
||||
private String ygzq;
|
||||
}
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
package com.czlis.common.core.domain.entity.lis;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XmInfo {
|
||||
|
||||
private String yq;
|
||||
private String xmdh;
|
||||
private String xmmc;
|
||||
private String zhbdh;
|
||||
private String bgdh;
|
||||
private Double cksx;
|
||||
private Double ckxx;
|
||||
private String dyckz;
|
||||
private String dylx;
|
||||
private Integer dyxh;
|
||||
private String zjf;
|
||||
private String xmlb;
|
||||
private Double xs;
|
||||
private Integer xsws;
|
||||
private String mrz;
|
||||
private Double jg;
|
||||
private Double cb;
|
||||
private String dw;
|
||||
private String jsxm;
|
||||
private String jsgs;
|
||||
private String zkxm;
|
||||
private Double sjx;
|
||||
private Double xjx;
|
||||
private String ygxb;
|
||||
private String ygnl;
|
||||
private String ygbb;
|
||||
private String lcyy;
|
||||
private String jgbz;
|
||||
private Integer jgjg;
|
||||
private Double jgz;
|
||||
private String csff;
|
||||
private String yymc;
|
||||
private Integer fzdyxh;
|
||||
private String clinicref;
|
||||
private Double llimit;
|
||||
private Double hlimit;
|
||||
private Double xsbs;
|
||||
private Double redoxx;
|
||||
private Double redosx;
|
||||
private String qcuselog;
|
||||
private String qcusepos;
|
||||
private String itemclass;
|
||||
private String whocode;
|
||||
private String germflag;
|
||||
private Double qccv;
|
||||
private String qcvs;
|
||||
private String knowledge;
|
||||
private String ygzq;
|
||||
private String ygzd;
|
||||
private String uflag;
|
||||
private String val2;
|
||||
private Integer id;
|
||||
private String val1;
|
||||
private String germclass;
|
||||
}
|
||||
@ -1,32 +1,33 @@
|
||||
package com.czlis.common.core.domain.entity.lis;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XmRef {
|
||||
private Integer xmid;
|
||||
|
||||
private String yq;
|
||||
private String xmdh;
|
||||
private Integer xh;
|
||||
private String xb;
|
||||
private BigDecimal nl1;
|
||||
private BigDecimal nl2;
|
||||
private Double nl1;
|
||||
private Double nl2;
|
||||
private String bblx;
|
||||
private BigDecimal cksx;
|
||||
private BigDecimal ckxx;
|
||||
private Double cksx;
|
||||
private Double ckxx;
|
||||
private String dyck;
|
||||
private String nldw;
|
||||
private BigDecimal redoxx;
|
||||
private BigDecimal redosx;
|
||||
private BigDecimal alterxx;
|
||||
private BigDecimal altersx;
|
||||
private Double redoxx;
|
||||
private Double redosx;
|
||||
private Double alterxx;
|
||||
private Double altersx;
|
||||
private String slzq;
|
||||
private String zd;
|
||||
private String instrid;
|
||||
private String yq;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -8,11 +8,13 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XmVal {
|
||||
private Integer xmid;
|
||||
|
||||
private String yq;
|
||||
private String xmdh;
|
||||
private String qz;
|
||||
private String srm;
|
||||
private Integer xh;
|
||||
private String jgbz;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.czlis.interfaceCommon.mapper;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.XmAlarmdetail;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface XmAlarmdetailMapper {
|
||||
List<XmAlarmdetail> getXmAlarmdetailList(String yq);
|
||||
List<XmAlarmdetail> getXmAlarmdetail(@Param("yq")String yq, @Param("xmdh")String xmdh);
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.czlis.interfaceCommon.mapper;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.XmInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface XmInfoMapper {
|
||||
List<XmInfo> getXmInfoList(String yq);
|
||||
XmInfo getXmInfo(@Param("yq")String yq, @Param("xmdh")String xmdh);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.czlis.interfaceCommon.mapper;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.XmRef;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface XmRefMapper {
|
||||
List<XmRef> getXmRefList(String yq);
|
||||
XmRef getXmRef(@Param("yq")String yq, @Param("xmdh")String xmdh);
|
||||
XmRef getXmRefValue(Map<String,Object> map);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.czlis.interfaceCommon.mapper;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.XmRef;
|
||||
import com.czlis.common.core.domain.entity.lis.XmVal;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface XmValMapper {
|
||||
List<XmVal> getXmValList(String yq);
|
||||
XmVal getXmVal(@Param("yq")String yq, @Param("xmdh")String xmdh);
|
||||
XmVal getXmValValue(@Param("yq")String yq, @Param("xmdh")String xmdh,@Param("csjg")String csjg);
|
||||
String getXmValJgbz(@Param("yq")String yq, @Param("xmdh")String xmdh,@Param("csjg")String csjg,@Param("csjg1")String csjg1,@Param("csjg2")String csjg2);
|
||||
}
|
||||
@ -65,14 +65,14 @@ public class CalcUtils {
|
||||
*/
|
||||
public static String getCalc(String CalcExpression){
|
||||
// 1. 替换逻辑运算符:and→&&,or→||
|
||||
String processed = CalcExpression.replaceAll("\\band\\b", "&&").replaceAll("\\bor\\b", "||");
|
||||
processed = processed.replaceAll("\\bAND\\b", "&&").replaceAll("\\bOR\\b", "||");
|
||||
String processed = CalcExpression.replaceAll("\\band|AND\\b", "&&").replaceAll("\\bor|OR\\b", "||");
|
||||
// 2. 替换变量格式:[a] → #a
|
||||
processed = processed.replaceAll("\\[(\\w+)\\]", "#$1");
|
||||
// 3. 替换len()函数为length()方法:len(xxx) → xxx.length()
|
||||
processed = replaceLenFunction(processed);
|
||||
//5.case表达式暂时不处理,后期看需要扩展
|
||||
//4. 递归处理if结构:if(cond, trueExpr, falseExpr) → cond?trueExpr:falseExpr
|
||||
//4.like '%aa'或者 like 'aa%'或者 like '%aa%'
|
||||
processed = replaceLikeExpressions(processed);
|
||||
//5. 递归处理if结构:if(cond, trueExpr, falseExpr) → cond?trueExpr:falseExpr
|
||||
return processIf(processed);
|
||||
}
|
||||
/**
|
||||
@ -210,6 +210,60 @@ public class CalcUtils {
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
/**
|
||||
* 处理like表达式转换
|
||||
* 支持:like '%xxx'、like 'xxx%'、like '%xxx%'、like 'xxx'(精确匹配)
|
||||
*/
|
||||
private static String replaceLikeExpressions(String expression) {
|
||||
// 正则匹配 like 表达式(支持空格变化和引号)
|
||||
// 分组说明:
|
||||
// group1: 左侧表达式(如字段或变量)
|
||||
// group2: 匹配模式(如'%aa%'、'aa%'等)
|
||||
Pattern pattern = Pattern.compile("(\\w+)\\s+like\\s+'([^']+)'", Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(expression);
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String leftExpr = matcher.group(1); // 左侧表达式(如 field1)
|
||||
String patternStr = matcher.group(2); // 匹配模式(如 %aa%)
|
||||
|
||||
// 根据模式生成对应的SpEL方法调用
|
||||
String replacement = generateLikeReplacement(leftExpr, patternStr);
|
||||
matcher.appendReplacement(result, replacement);
|
||||
}
|
||||
matcher.appendTail(result);
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
/**
|
||||
* 根据like模式生成对应的SpEL方法调用
|
||||
*/
|
||||
private static String generateLikeReplacement(String leftExpr, String patternStr) {
|
||||
boolean startsWithWildcard = patternStr.startsWith("%");
|
||||
boolean endsWithWildcard = patternStr.endsWith("%");
|
||||
String content = patternStr.replace("%", ""); // 提取实际匹配内容
|
||||
|
||||
// 处理三种like场景
|
||||
if (startsWithWildcard && endsWithWildcard) {
|
||||
// like '%xxx%' → 包含:xxx.contains('content')
|
||||
return String.format("%s.contains('%s')", leftExpr, escapeQuotes(content));
|
||||
} else if (startsWithWildcard) {
|
||||
// like '%xxx' → 以...结尾:xxx.endsWith('content')
|
||||
return String.format("%s.endsWith('%s')", leftExpr, escapeQuotes(content));
|
||||
} else if (endsWithWildcard) {
|
||||
// like 'xxx%' → 以...开头:xxx.startsWith('content')
|
||||
return String.format("%s.startsWith('%s')", leftExpr, escapeQuotes(content));
|
||||
} else {
|
||||
// like 'xxx' → 精确匹配:xxx.equals('content')
|
||||
return String.format("%s.equals('%s')", leftExpr, escapeQuotes(content));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 转义字符串中的单引号,避免SpEL语法错误
|
||||
*/
|
||||
private static String escapeQuotes(String str) {
|
||||
return str.replace("'", "\\'");
|
||||
}
|
||||
/**
|
||||
* 使用正则表达式判断字符串是否为数字
|
||||
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)
|
||||
@ -226,9 +280,10 @@ public class CalcUtils {
|
||||
// 测试
|
||||
public static void main(String[] args) {
|
||||
Map<String, String> variables = new HashMap<>();
|
||||
variables.put("ALB", "4.0"); // 示例值
|
||||
variables.put("RESULT", "4.0"); // 示例值
|
||||
// variables.put("TP", "6.0");
|
||||
String testCalc = "[ALB] /( [TP] - [ALB] )";
|
||||
String testCalc = "if(([结果]>7.12) ,1,0)";
|
||||
testCalc=testCalc.replace("[结果]", "[RESULT]");
|
||||
//System.out.println(getCalc(testCalc));
|
||||
System.out.println(getValueFromCalc(testCalc,variables));
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import com.czlis.common.utils.ComDictUtils;
|
||||
import com.czlis.common.utils.ComOptionUtils;
|
||||
import com.czlis.interfaceCommon.mapper.*;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -34,7 +35,14 @@ public class CommonUtil {
|
||||
ComUsrMapper comUsrMapper;
|
||||
@Autowired
|
||||
ComUsrpowerMapper comUsrpowerMapper;
|
||||
|
||||
@Autowired
|
||||
XmInfoMapper xmInfoMapper;
|
||||
@Autowired
|
||||
XmRefMapper xmRefMapper;
|
||||
@Autowired
|
||||
XmValMapper xmValMapper;
|
||||
@Autowired
|
||||
XmAlarmdetailMapper xmAlarmdetailMapper;
|
||||
//====检验主表操作方法集合===
|
||||
public LabPat getLabPatOne(Date jyrq, String yq, String ybh){
|
||||
return labPatMapper.getLabPatOne(jyrq, yq, ybh);
|
||||
@ -65,7 +73,14 @@ public class CommonUtil {
|
||||
public int delLabResult(LabResult labResult) {return labResultMapper.delLabResult(labResult);}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateLabResult(LabResult labResult) {return labResultMapper.updateLabResult(labResult);}
|
||||
|
||||
//=====项目字典查询=========
|
||||
public List<XmInfo> getXmInfoList(String yq) {return xmInfoMapper.getXmInfoList(yq);}
|
||||
public XmInfo getXmInfo(String yq,String xmdh) {return xmInfoMapper.getXmInfo(yq,xmdh);}
|
||||
public List<XmRef> getXmRefList(String yq) {return xmRefMapper.getXmRefList(yq);}
|
||||
public XmRef getXmRef(String yq,String xmdh) {return xmRefMapper.getXmRef(yq,xmdh);}
|
||||
public XmRef getXmRefValue(Map<String,Object> map) {return xmRefMapper.getXmRefValue(map);}
|
||||
public String getXmRefJgbz(String yq,String xmdh,String csjg,String csjg1,String csjg2) {return xmValMapper.getXmValJgbz(yq,xmdh,csjg,csjg1,csjg2);}
|
||||
public List<XmAlarmdetail> getXmAlarmdetail(String yq,String xmdh){return xmAlarmdetailMapper.getXmAlarmdetail(yq,xmdh);};
|
||||
|
||||
|
||||
//服务器时间方法
|
||||
|
||||
@ -68,4 +68,139 @@ public class LisUtil {
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
/**
|
||||
* 使用正则表达式判断字符串是否为数字
|
||||
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)
|
||||
*/
|
||||
public static boolean isNumber(String str) {
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 正则表达式:匹配正负整数、正负小数
|
||||
String regex = "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$";
|
||||
return str.matches(regex);
|
||||
}
|
||||
/**
|
||||
* 使用正则表达式判断字符串是否为数字
|
||||
* 支持:整数(123)、小数(123.45),不包括带正负号的情况
|
||||
*/
|
||||
public static boolean isTureNumber(String str) {
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 正则表达式:仅匹配正整数、正小数(不包含正负号)
|
||||
// 说明:
|
||||
// ^[0-9]+(\.[0-9]*)?$ 匹配整数(如123)或带整数部分的小数(如123.45)
|
||||
// |\.([0-9]+)$ 匹配纯小数(如.67)
|
||||
String regex = "^[0-9]+(\\.[0-9]*)?|\\.[0-9]+$";
|
||||
return str.matches(regex);
|
||||
}
|
||||
/**
|
||||
* 将包含比较运算符的字符串转换为特定格式的数值字符串
|
||||
* 不支持的格式或非数字内容将返回原值
|
||||
* @param input 输入字符串,如">=123", ">123", "<=123", "<123"
|
||||
* @return 转换后的字符串或原值
|
||||
*/
|
||||
public static String getOverNumber(String input) {
|
||||
// 输入为空时返回原值
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// 定义支持的运算符,按长度排序以便正确识别(先长后短)
|
||||
String[] operators = {">=", "<=", ">", "<"};
|
||||
String operator = null;
|
||||
String numberPart = null;
|
||||
|
||||
// 识别运算符和数字部分
|
||||
for (String op : operators) {
|
||||
if (input.startsWith(op)) {
|
||||
operator = op;
|
||||
numberPart = input.substring(op.length());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 未识别到支持的运算符,返回原值
|
||||
if (operator == null) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// 尝试将数字部分转换为double
|
||||
double number;
|
||||
try {
|
||||
number = Double.parseDouble(numberPart);
|
||||
} catch (NumberFormatException e) {
|
||||
// 数字部分格式不正确,返回原值
|
||||
return input;
|
||||
}
|
||||
|
||||
// 根据运算符进行转换
|
||||
switch (operator) {
|
||||
case ">=":
|
||||
case ">":
|
||||
return String.format("%.4f", number + 0.0001);
|
||||
case "<=":
|
||||
case "<":
|
||||
return String.format("%.4f", number - 0.0001);
|
||||
default:
|
||||
return input;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 保留指定小数位数
|
||||
* 支持比较符号(<=、>=、<、>)和负号(-)同时存在的情况
|
||||
* @param input 输入字符串,如"123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
|
||||
* @param decimalPlaces 要保留的小数位数,需为非负整数
|
||||
* @return 格式化后的字符串,无法处理时返回原值
|
||||
*/
|
||||
public static String round(String input, int decimalPlaces) {
|
||||
// 处理空输入或无效小数位数
|
||||
if (input == null || input.trim().isEmpty() || decimalPlaces < 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// 定义比较运算符前缀(按长度排序,确保正确识别)
|
||||
String[] comparisonPrefixes = {"<=", ">=", "<", ">"};
|
||||
String comparisonPrefix = "";
|
||||
String remainingPart = input;
|
||||
|
||||
// 提取比较运算符前缀
|
||||
for (String prefix : comparisonPrefixes) {
|
||||
if (remainingPart.startsWith(prefix)) {
|
||||
comparisonPrefix = prefix;
|
||||
remainingPart = remainingPart.substring(prefix.length());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试解析剩余部分为数字
|
||||
try {
|
||||
// 解析数字(包含可能的负号)
|
||||
double number = Double.parseDouble(remainingPart);
|
||||
|
||||
// 创建格式化模式(整数部分至少1位,小数部分固定位数)
|
||||
StringBuilder formatPattern = new StringBuilder();
|
||||
formatPattern.append("0");
|
||||
if (decimalPlaces > 0) {
|
||||
formatPattern.append(".");
|
||||
// 循环添加指定数量的0
|
||||
for (int i = 0; i < decimalPlaces; i++) {
|
||||
formatPattern.append("0");
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化数字并拼接比较前缀
|
||||
String formattedNumber = String.format(
|
||||
"%s%s",
|
||||
comparisonPrefix,
|
||||
String.format(formatPattern.toString(), number)
|
||||
);
|
||||
|
||||
return formattedNumber;
|
||||
} catch (NumberFormatException e) {
|
||||
// 数字部分无法解析时返回原值
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<select id="getLabResultList" parameterType="com.czlis.common.core.domain.entity.lis.LabResult" resultType="com.czlis.common.core.domain.entity.lis.LabResult">
|
||||
select
|
||||
lab_result.jyrq, lab_result.yq, lab_result.ybh, lab_result.xmdh, wyh, csjg, od, cutoff, lab_result.jgbz, bz1, bz2, yhdh, instrid, operdt,
|
||||
operna, refs, flag, lab_result.dw, result_flag, alarm_flag, redo_flag, sqxmdh, redo_text,xm_info.xmmc
|
||||
operna, refs, flag, lab_result.dw, result_flag, alarm_flag, redo_flag, sqxmdh, redo_text,xm_info.xmmc,xm_info.ygzq,xm_info.ygzd
|
||||
,textresult
|
||||
from lab_result join xm_info on xm_info.yq=lab_result.yq and xm_info.xmdh=lab_result.xmdh
|
||||
<where>
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.interfaceCommon.mapper.XmAlarmdetailMapper">
|
||||
|
||||
<select id="getXmAlarmdetailList" resultType="com.czlis.common.core.domain.entity.lis.XmAlarmdetail">
|
||||
select * from xm_alarmdetail where yq=#{yq}
|
||||
</select>
|
||||
<select id="getXmAlarmdetail" resultType="com.czlis.common.core.domain.entity.lis.XmAlarmdetail">
|
||||
select * from xm_alarmdetail where yq = #{yq} and xmdh = #{xmdh}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.interfaceCommon.mapper.XmInfoMapper">
|
||||
|
||||
<select id="getXmInfoList" resultType="com.czlis.common.core.domain.entity.lis.XmInfo">
|
||||
select * from xm_info where yq=#{yq}
|
||||
</select>
|
||||
<select id="getXmInfo" resultType="com.czlis.common.core.domain.entity.lis.XmInfo">
|
||||
select * from xm_info where yq = #{yq} and xmdh = #{xmdh}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.interfaceCommon.mapper.XmRefMapper">
|
||||
|
||||
<select id="getXmRefList" resultType="com.czlis.common.core.domain.entity.lis.XmRef">
|
||||
select * from xm_ref where yq=#{yq}
|
||||
</select>
|
||||
<select id="getXmRef" resultType="com.czlis.common.core.domain.entity.lis.XmRef">
|
||||
select * from xm_ref where yq = #{yq} and xmdh = #{xmdh}
|
||||
</select>
|
||||
|
||||
<select id="getXmRefValue" resultType="com.czlis.common.core.domain.entity.lis.XmRef">
|
||||
select TOP 1 * from xm_ref
|
||||
<where>
|
||||
<if test="yq != null and yq != ''">
|
||||
and yq = #{yq}
|
||||
</if>
|
||||
<if test="xmdh != null and xmdh != ''">
|
||||
and xmdh = #{xmdh}
|
||||
</if>
|
||||
<if test="bbtype != null and bbtype != ''">
|
||||
and bblx = #{bbtype}
|
||||
</if>
|
||||
<if test="sex != null and sex != ''">
|
||||
and xb = #{sex}
|
||||
</if>
|
||||
<if test="age != null and age != 0">
|
||||
and nl2 >= #{age} and #{age}>=nl1
|
||||
</if>
|
||||
<if test="zd != null ">
|
||||
and (isnull(zd,'') = #{zd} or (isnull(zd,'') != #{zd} and isnull(zd,'')=''))
|
||||
</if>
|
||||
<if test="slzq != null ">
|
||||
and (isnull(slzq,'') = #{slzq} or (isnull(slzq,'') != #{slzq} and isnull(slzq,'')=''))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.interfaceCommon.mapper.XmValMapper">
|
||||
|
||||
<select id="getXmValList" resultType="com.czlis.common.core.domain.entity.lis.XmVal">
|
||||
select * from xm_val where yq=#{yq}
|
||||
</select>
|
||||
<select id="getXmVal" resultType="com.czlis.common.core.domain.entity.lis.XmVal">
|
||||
select * from xm_val where yq = #{yq} and xmdh = #{xmdh}
|
||||
</select>
|
||||
|
||||
<select id="getXmValValue" resultType="com.czlis.common.core.domain.entity.lis.XmVal">
|
||||
select TOP 1 * from xm_val
|
||||
<where>
|
||||
<if test="yq != null and yq != ''">
|
||||
and yq = #{yq}
|
||||
</if>
|
||||
<if test="xmdh != null and xmdh != ''">
|
||||
and xmdh = #{xmdh}
|
||||
</if>
|
||||
<if test="csjg != null and csjg != ''">
|
||||
and qz = #{csjg}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getXmValJgbz" resultType="com.czlis.common.core.domain.entity.lis.XmVal">
|
||||
select TOP 1 jgbz from xm_val
|
||||
<where>
|
||||
<if test="yq != null and yq != ''">
|
||||
and yq = #{yq}
|
||||
</if>
|
||||
<if test="xmdh != null and xmdh != ''">
|
||||
and xmdh = #{xmdh}
|
||||
</if>
|
||||
<!-- 动态 OR 条件块:多条件时用 OR 连接,单条件时自动转为 AND -->
|
||||
<trim prefix="AND (" suffix=")" prefixOverrides="OR">
|
||||
<if test="csjg != null and csjg != ''">
|
||||
OR qz = #{csjg}
|
||||
</if>
|
||||
<if test="csjg1 != null and csjg1 != ''">
|
||||
OR qz = #{csjg1}
|
||||
</if>
|
||||
<if test="csjg2 != null and csjg2 != ''">
|
||||
OR qz = #{csjg2}
|
||||
</if>
|
||||
</trim>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -14,4 +14,5 @@ public interface LisWorkOperMapper {
|
||||
void updatelabresultsqxmdhall(@Param("jyrq") Date jyrq,@Param("yq") String yq,@Param("ybh") String ybh,@Param("sqxmdh") String sqxmdh);
|
||||
void updatelabresultsqxmdh(@Param("jyrq") Date jyrq,@Param("yq") String yq,@Param("ybh") String ybh,@Param("sqh") String sqh);
|
||||
List<ResultCalcDTO> getResultCalc(@Param("jyrq") Date jyrq, @Param("yq") String yq, @Param("ybh") String ybh);
|
||||
Integer getLimitCount(Map<String,Object> map);
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.czlis.liswork.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.*;
|
||||
import com.czlis.common.utils.StringUtils;
|
||||
import com.czlis.interfaceCommon.constants.LisinterfaceNameConstants;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.interfaceCommon.constants.SampleStatusConstants;
|
||||
@ -16,13 +16,12 @@ import com.czlis.liswork.mapper.LisWorkOperMapper;
|
||||
import com.czlis.liswork.mapper.dict.LabInstrvsreqclassMapper;
|
||||
import com.czlis.liswork.pojo.DTO.ResultCalcDTO;
|
||||
import com.czlis.liswork.service.LisWorkOperService;
|
||||
import com.czlis.liswork.utils.LisWorkUtil;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -264,7 +263,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
|
||||
}
|
||||
LabPat labPat=commonUtil.getLabPatOne(jyrq, yq, ybh);
|
||||
//计算项目更新
|
||||
calcsample(jyrq, yq, ybh, labPat);
|
||||
calcsample(labPat);
|
||||
String yqdl=lisWorkOperMapper.selectYqdl(yq);
|
||||
if(!"细菌仪".equals(yqdl)) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@ -279,7 +278,7 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
|
||||
String retMsg = String.valueOf(map.get("retmsg"));
|
||||
log.info("调用存储过程{}返回值:{},{}", "sp_setrefs", retCode, retMsg);
|
||||
if (retCode == null || "".equals(retCode) || "-1".equals(retCode)) return new Result("-1", "保存常规参考值失败!");
|
||||
int wjz=saverefs(jyrq, yq, ybh, labPat);
|
||||
int wjz=saverefs(labPat);
|
||||
if(wjz==1){
|
||||
//危急值处理过程
|
||||
}
|
||||
@ -321,11 +320,14 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
|
||||
*/
|
||||
public Result calcsample(Date jyrq, String yq, String ybh){
|
||||
LabPat labPat=commonUtil.getLabPatOne(jyrq, yq, ybh);
|
||||
calcsample(jyrq, yq, ybh, labPat);
|
||||
calcsample(labPat);
|
||||
return new Result("0","保存成功!");
|
||||
}
|
||||
//内部使用
|
||||
private void calcsample(Date jyrq, String yq, String ybh,LabPat labPat){
|
||||
private void calcsample(LabPat labPat){
|
||||
Date jyrq=labPat.getJyrq();
|
||||
String yq=labPat.getYq();
|
||||
String ybh=labPat.getYbh();
|
||||
List<ResultCalcDTO> resultCalcDTO=lisWorkOperMapper.getResultCalc(jyrq,yq,ybh);
|
||||
String xmdhold="";
|
||||
for (ResultCalcDTO resultCalc : resultCalcDTO) {
|
||||
@ -368,21 +370,267 @@ public class LisWorkOperServiceImpl implements LisWorkOperService {
|
||||
*/
|
||||
public Result saverefs(Date jyrq, String yq, String ybh){
|
||||
LabPat labPat=commonUtil.getLabPatOne(jyrq, yq, ybh);
|
||||
saverefs(jyrq, yq, ybh, labPat);
|
||||
saverefs(labPat);
|
||||
return new Result("0","保存成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算项目参考值结果异常标志(内部使用)
|
||||
* @param jyrq
|
||||
* @param yq
|
||||
* @param ybh
|
||||
* @param labPat
|
||||
* @return 返回值0正常,1有危急值明细存在
|
||||
*/
|
||||
private int saverefs(Date jyrq, String yq, String ybh,LabPat labPat){
|
||||
private int saverefs(LabPat labPat){
|
||||
Date jyrq=labPat.getJyrq();
|
||||
String yq=labPat.getYq();
|
||||
String ybh=labPat.getYbh();
|
||||
String yqdl=lisWorkOperMapper.selectYqdl(yq);
|
||||
boolean lb_setbj=true,lb_wjz=false;
|
||||
if(!"细菌仪".equals(yqdl)) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("jyrq", jyrq);
|
||||
map.put("yq", yq);
|
||||
map.put("ybh", ybh);
|
||||
map.put("settype", "1");
|
||||
map.put("retcode", "");
|
||||
map.put("retmsg", "");
|
||||
lisWorkOperMapper.sp_setrefs(map);
|
||||
String retCode = String.valueOf(map.get("retcode"));
|
||||
String retMsg = String.valueOf(map.get("retmsg"));
|
||||
log.info("调用存储过程{}返回值:{},{}", "sp_setrefs", retCode, retMsg);
|
||||
if (retCode == null || "".equals(retCode) || "-1".equals(retCode)) lb_setbj=false;
|
||||
List<LabResult> labResultList=commonUtil.getLabResultList(jyrq, yq, ybh);
|
||||
for (LabResult labResult : labResultList) {
|
||||
String csjg=labResult.getCsjg();
|
||||
boolean lb_nummode=LisUtil.isTureNumber(csjg);
|
||||
String ygzq = labResult.getYgzq();
|
||||
String ygzd = labResult.getYgzd();
|
||||
//当结果为数值并且与周期诊断无关,计算存储过程保存成功后,只进行危急值判断
|
||||
if(lb_nummode && lb_setbj && !"Y".equals(ygzd) && !"Y".equals(ygzq)){
|
||||
int wjz=alarmcondition(labPat,labResult);
|
||||
if(wjz==1)lb_wjz=true;
|
||||
}else {
|
||||
int wjz = setrefs( labPat, labResult);
|
||||
if (wjz == 1) lb_wjz = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(lb_wjz){
|
||||
//危急值处理过程
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 明细结果计算参考值异常标志危急值标志并更新
|
||||
* @param labPat
|
||||
* @param labResult
|
||||
* @return
|
||||
*/
|
||||
private int setrefs(LabPat labPat,LabResult labResult){
|
||||
String yq=labPat.getYq();
|
||||
String resultflag="M",wjzflag="";
|
||||
int wjz=0;
|
||||
String xmdh=labResult.getXmdh();
|
||||
String csjg=labResult.getCsjg();
|
||||
if (csjg == null || csjg.trim().isEmpty()) return 0;
|
||||
String csjgnew=LisUtil.getOverNumber(csjg.trim());
|
||||
boolean lb_nummode=LisUtil.isNumber(csjgnew);
|
||||
//当结果为数值时计算上下限
|
||||
if(lb_nummode) {
|
||||
XmInfo xmInfo = commonUtil.getXmInfo(yq, xmdh);
|
||||
String dw = xmInfo.getDw();
|
||||
String refs = xmInfo.getDyckz();
|
||||
Double ckxx = xmInfo.getCkxx();
|
||||
Double cksx = xmInfo.getCksx();
|
||||
Double llimit=xmInfo.getLlimit();
|
||||
Double hlimit=xmInfo.getHlimit();
|
||||
String ygxb = xmInfo.getYgxb();
|
||||
String ygnl = xmInfo.getYgnl();
|
||||
String ygbb = xmInfo.getYgbb();
|
||||
String ygzq = xmInfo.getYgzq();
|
||||
String ygzd = xmInfo.getYgzd();
|
||||
String sex = "";
|
||||
if ("Y".equals(ygxb)) {
|
||||
sex = labPat.getBrxb().trim();
|
||||
if (sex == null) sex = "";
|
||||
}
|
||||
String yblx = "";
|
||||
if ("Y".equals(ygbb)) {
|
||||
yblx = labPat.getYblx();
|
||||
String bb = commonUtil.getComDictIdByName("BT", yblx);
|
||||
if (bb != null && !bb.trim().isEmpty()) yblx = bb;
|
||||
}
|
||||
String zd = "";
|
||||
if ("Y".equals(ygzd)) {
|
||||
zd = labPat.getZd();
|
||||
String icd10 = commonUtil.getComDictIdByName("ICD10", zd);
|
||||
if (icd10 != null && !icd10.trim().isEmpty()) zd = icd10;
|
||||
}
|
||||
String slzq = "";
|
||||
if ("Y".equals(ygzq)) {
|
||||
slzq = labPat.getSlzq();
|
||||
String zq = commonUtil.getComDictIdByName("SLZQ", slzq);
|
||||
if (zq != null && !zq.trim().isEmpty()) slzq = zq;
|
||||
}
|
||||
double age = 0;
|
||||
if ("Y".equals(ygnl)) {
|
||||
age = AgeUtils.getDecimalAge(AgeUtils.getBirthDateByAge(labPat.getNl(), labPat.getNldw()));
|
||||
}
|
||||
XmRef xmRef = new XmRef();
|
||||
if ("Y".equals(ygxb) || "Y".equals(ygbb) || "Y".equals(ygnl) || "Y".equals(ygzd) || "Y".equals(ygzq)) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("yq", yblx);
|
||||
map.put("xmdh", sex);
|
||||
map.put("bbtype", yblx);
|
||||
map.put("sex", sex);
|
||||
map.put("age", age);
|
||||
map.put("zd", zd);
|
||||
map.put("slzq", slzq);
|
||||
xmRef = commonUtil.getXmRefValue(map);
|
||||
}
|
||||
if(xmRef !=null){
|
||||
ckxx=xmRef.getCkxx();
|
||||
cksx=xmRef.getCksx();
|
||||
refs=xmRef.getDyck();
|
||||
Double alterxx=xmRef.getAlterxx();
|
||||
Double altersx=xmRef.getAltersx();
|
||||
if(alterxx != null)llimit=alterxx;
|
||||
if(altersx != null)hlimit=altersx;
|
||||
}
|
||||
if(lb_nummode){
|
||||
//数值型结果判断
|
||||
Double csjgnum = Double.valueOf(csjgnew);
|
||||
if(ckxx != null)if(csjgnum<ckxx)resultflag="L";
|
||||
if(cksx != null)if(csjgnum>cksx)resultflag="H";
|
||||
int wjzf=alarmcondition(labPat,labResult);
|
||||
if(wjzf==-1) {
|
||||
if(llimit != null)if(csjgnum<llimit)wjzflag="L";
|
||||
if(hlimit != null)if(csjgnum>hlimit)wjzflag="H";
|
||||
}else if(wjzf==1) {
|
||||
wjzflag=resultflag;
|
||||
}
|
||||
if(!"".equals(wjzflag))wjz=1;
|
||||
}else{
|
||||
//文字型结果判断
|
||||
String jgbzold=labResult.getJgbz();
|
||||
String lmtflag =getitemlmtflag(yq,xmdh,csjg);
|
||||
if("P".equals(jgbzold) && (csjg.indexOf("阳")>=0 || csjg.indexOf("+")>=0 || csjg.indexOf(":")>=0 ) && (lmtflag == null || lmtflag.trim().isEmpty())) lmtflag="P";
|
||||
resultflag=lmtflag;
|
||||
if("J".equals(lmtflag))wjzflag = "H";
|
||||
int wjzf=alarmcondition(labPat,labResult);
|
||||
if(wjzf==1) wjzflag="H";
|
||||
|
||||
}
|
||||
//小数保留位数计算
|
||||
Integer xsws= xmInfo.getXsws();
|
||||
if(xsws>=0) csjg=LisUtil.round(csjg,xsws);
|
||||
labResult.setCsjg(csjg);
|
||||
labResult.setDw(dw);
|
||||
labResult.setRefs(refs);
|
||||
labResult.setResultFlag(resultflag);
|
||||
labResult.setJgbz(resultflag);
|
||||
labResult.setAlarmFlag(wjzflag);
|
||||
|
||||
commonUtil.updateLabResult(labResult);
|
||||
}
|
||||
if(!"".equals(wjzflag))wjz=1;
|
||||
return wjz;
|
||||
}
|
||||
/**
|
||||
*特定条件危急值判断
|
||||
* @param labPat
|
||||
* @param labResult
|
||||
* @return
|
||||
*/
|
||||
private int alarmcondition(LabPat labPat,LabResult labResult){
|
||||
boolean lb_fcb=false,lb_hasval=false;
|
||||
String csjg=labResult.getCsjg();
|
||||
if (csjg == null || csjg.trim().isEmpty()) return 0;
|
||||
String yq=labPat.getYq();
|
||||
String xmdh=labResult.getXmdh();
|
||||
String brxm="";
|
||||
String brdh="";
|
||||
String ksdh=labPat.getKsdh();
|
||||
String ksdh1=commonUtil.getComDictIdByName("BT",ksdh);
|
||||
if (ksdh1 != null && !ksdh1.trim().isEmpty()) ksdh=ksdh1;
|
||||
String ybzt=labPat.getYbzt();
|
||||
String ybzt1=commonUtil.getComDictIdByName("ST",ybzt);
|
||||
if (ybzt1 != null && !ybzt1.trim().isEmpty()) ybzt=ybzt1;
|
||||
String zd=labPat.getZd();
|
||||
|
||||
List<XmAlarmdetail> getXmAlarmdetail=commonUtil.getXmAlarmdetail(yq,xmdh);
|
||||
if(getXmAlarmdetail==null)return 0;
|
||||
for(XmAlarmdetail xmAlarmdetail :getXmAlarmdetail){
|
||||
String samplecondition=xmAlarmdetail.getSamplecondition();
|
||||
lb_fcb=false;
|
||||
if (samplecondition.toLowerCase().contains("[初报]")) {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("xmdh", xmdh);
|
||||
map.put("jyrq", labPat.getJyrq());
|
||||
if (samplecondition.toLowerCase().contains("brxm"))brxm=labPat.getBrxm();
|
||||
if (samplecondition.toLowerCase().contains("brdh"))brdh=labPat.getBrdh();
|
||||
map.put("brxm", brxm);
|
||||
map.put("brdh", brdh);
|
||||
int limitcount=lisWorkOperMapper.getLimitCount(map);
|
||||
if(limitcount>0)lb_fcb=true;
|
||||
samplecondition = samplecondition.replace("'brxm'", "1");
|
||||
samplecondition = samplecondition.replace("'brdh'", "1");
|
||||
samplecondition = samplecondition.replace("[初报]", "[CB]");
|
||||
}
|
||||
|
||||
labPat.setYblx(commonUtil.getComDictIdByName("BT",labPat.getYblx()));
|
||||
labPat.setKsdh(commonUtil.getComDictIdByName("DP",labPat.getKsdh()));
|
||||
samplecondition=samplecondition.replace("[科室]", "[DEPT]");
|
||||
samplecondition=samplecondition.replace("[诊断]", "[DIAG]");
|
||||
samplecondition=samplecondition.replace("[样本状态]", "[YBZT]");
|
||||
Map<String, String> variables = new HashMap<>();
|
||||
variables.put("ZB", "1");
|
||||
variables.put("DEPT", ksdh);
|
||||
variables.put("DIAG", zd);
|
||||
variables.put("YBZT", ybzt);
|
||||
samplecondition="if((" + samplecondition + ") ,1,0)";
|
||||
String result=CalcUtils.getValueFromCalc(samplecondition,variables);
|
||||
if("1".equals( result)){
|
||||
if(lb_fcb)return 0;
|
||||
lb_hasval=true;
|
||||
String resultcondition = xmAlarmdetail.getResultcondition();
|
||||
resultcondition=resultcondition.replace("[结果]", "[RESULT]");
|
||||
Map<String, String> variables1 = new HashMap<>();
|
||||
variables1.put("RESULT", csjg);
|
||||
resultcondition="if((" + resultcondition + ") ,1,0)";
|
||||
String result1=CalcUtils.getValueFromCalc(resultcondition,variables1);
|
||||
if("1".equals( result1))return 1;
|
||||
}
|
||||
}
|
||||
if( lb_hasval)return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取常用取值结果标志
|
||||
* @param yq
|
||||
* @param xmdh
|
||||
* @param csjg
|
||||
* @return
|
||||
*/
|
||||
public String getitemlmtflag(String yq,String xmdh,String csjg){
|
||||
String jgbz="";
|
||||
if (csjg == null || csjg.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
String csjg1="",csjg2="";
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\((.*?)\\)");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(csjg);
|
||||
if (matcher.find()) {
|
||||
csjg1=matcher.group(1);
|
||||
}
|
||||
int index = csjg.indexOf(",");
|
||||
if(index == -1)csjg2= StringUtils.substring(csjg,index+1);
|
||||
jgbz=commonUtil.getXmRefJgbz(yq,xmdh,csjg,csjg1,csjg2);
|
||||
if (jgbz == null) {
|
||||
return "";
|
||||
}
|
||||
return jgbz;
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,4 +40,22 @@
|
||||
( lab_result.yq =#{yq}) And
|
||||
( lab_result.ybh = #{ybh}) )
|
||||
</select>
|
||||
<select id="getLimitCount" resultType="Integer">
|
||||
select COUNT(1) from lab_resultwarning,lab_pat where lab_resultwarning.jyrq=lab_pat.jyrq
|
||||
and lab_resultwarning.yq=lab_pat.yq and lab_resultwarning.ybh=lab_pat.ybh and
|
||||
<where>
|
||||
<if test="xmdh != null and xmdh != ''">lab_resultwarning.xmdh = #{xmdh}</if>
|
||||
</where>
|
||||
<where>
|
||||
<if test="jyrq != null ">and lab_pat.jyrq = #{jyrq}</if>
|
||||
</where>
|
||||
<where>
|
||||
<if test="brdh != null and brdh != ''">and lab_pat.brdh = #{brdh}</if>
|
||||
</where>
|
||||
<where>
|
||||
<if test="brxm != null and brxm != ''">and lab_pat.brdh = #{brxm}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user