主业务添加代码

This commit is contained in:
tangw 2025-09-04 18:35:55 +08:00
parent 4764a89ccb
commit e65f138de0
3 changed files with 69 additions and 58 deletions

View File

@ -5,6 +5,7 @@ import com.czlis.common.core.domain.entity.lis.*;
import com.czlis.interfaceCommon.mapper.CheckResultMapper;
import com.czlis.interfaceCommon.mapper.LabCheckrulesMapper;
import com.czlis.interfaceCommon.mapper.XmInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -32,10 +33,12 @@ public class CheckResultUtils {
Date jyrq = labPat.getJyrq();
String ybh = labPat.getYbh();
List<XmInfo> xmInfoList0 = commonUtil.getXmInfoList(yq);
if(xmInfoList0.size()==0) return errmsg;
List<XmInfo> xmInfoList = xmInfoList0.stream().filter(xmInfo -> xmInfo.getXjx()!=null||xmInfo.getSjx()!=null||xmInfo.getJgjg()!=null||xmInfo.getJgz()!=null||xmInfo.getJgbz()!=null).collect(Collectors.toList());
if(xmInfoList.size()>0) {
for (LabResult labResult : labResultList) {
String xmdh = labResult.getXmdh();
List<XmInfo> collect = xmInfoList.stream().filter(xmInfo -> xmInfo.getXmdh().equals(xmdh)).collect(Collectors.toList());
if (collect.size() > 0) {
XmInfo xmInfo = collect.get(0);
@ -73,17 +76,19 @@ public class CheckResultUtils {
lde_low = csjgnum - jgz;
}
List<LabResult> chkval = checkResultMapper.getChkvaList(brdh, ldt_startda, jyrq, yq, xmdh);
List<LabResult> collect0 = chkval.stream().filter(LabResult0 -> LisUtil.isNumber(LabResult0.getCsjg())).collect(Collectors.toList());
if (collect0.size() > 0) {
Double finalLde_up = lde_up;
Double finalLde_low = lde_low;
List<LabResult> collect1 = collect0.stream().filter(LabResult1 -> Double.parseDouble(LabResult1.getCsjg()) > finalLde_up && Double.parseDouble(LabResult1.getCsjg()) < finalLde_low).collect(Collectors.toList());
if (chkval != null && chkval.size() > 0) {
List<LabResult> collect0 = chkval.stream().filter(LabResult0 -> LisUtil.isNumber(LabResult0.getCsjg())).collect(Collectors.toList());
if (collect0.size() > 0) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果 (" + labResult.getCsjg() + ") 和 " +
DateFormatUtils.format(collect1.get(0).getJyrq(), "yyyy-MM-dd") + "日" +
collect1.get(0).getYbh() + " 号标本的结果 (" + collect1.get(0).getCsjg() + ") 相比超标";
}
Double finalLde_up = lde_up;
Double finalLde_low = lde_low;
List<LabResult> collect1 = collect0.stream().filter(LabResult1 -> Double.parseDouble(LabResult1.getCsjg()) > finalLde_up && Double.parseDouble(LabResult1.getCsjg()) < finalLde_low).collect(Collectors.toList());
if (collect1.size() > 0) {
errmsg = errmsg + LisUtil.LINE_SEPARATOR + xmdh + " 结果 (" + labResult.getCsjg() + ") 和 " +
DateFormatUtils.format(collect1.get(0).getJyrq(), "yyyy-MM-dd") + "日" +
collect1.get(0).getYbh() + " 号标本的结果 (" + collect1.get(0).getCsjg() + ") 相比超标";
}
}
}
}
}
@ -93,6 +98,7 @@ public class CheckResultUtils {
}
}
List<LabChk> labChkList = checkResultMapper.getLabChkList(yq);
if(labChkList.size()==0) return errmsg;
for (LabChk labChk : labChkList) {
String jsgs = labChk.getHdnr();
boolean setjgsg = true;
@ -177,14 +183,14 @@ public class CheckResultUtils {
String errmsg = checkcondition(labPat, labResultList, checkrules, ruledisplay);
if (!"".equals(errmsg)) {
if ("0".equals(checktype)) {
errmsg = "审核规则触发,未通过审核!,你是否要强行通过?" + ruledisplay + LisUtil.LINE_SEPARATOR + "审核规则触发,未通过审核!,你是否要强行通过?" + LisUtil.LINE_SEPARATOR + errmsg;
errmsg = errmsg+ LisUtil.LINE_SEPARATOR + "你是否要强行通过?" ;
params.put("code", "5");
params.put("msg", errmsg);
int ruleid0 = labCheckrules.getRuleid();
params.put("xh", i+1);
return params;
} else if ("3".equals(checktype)) {
errmsg = "审核规则触发,未通过审核!" + LisUtil.LINE_SEPARATOR + "设置的组合审核条件:" + errmsg + LisUtil.LINE_SEPARATOR + "审核规则触发,未通过审核!,不允许审核!";
errmsg = errmsg + LisUtil.LINE_SEPARATOR + "不允许审核!";
params.put("code", "1");
params.put("msg", errmsg);
params.put("xh", i+1);
@ -281,7 +287,7 @@ public class CheckResultUtils {
errmsg.replace("[" + itemcode + "]", csjg);
}
List<LabResult> labResultList0 = commonUtil.labResultMapper.getLabResultWithSql(labPat.getJyrq(), labPat.getYq(), labPat.getYbh(), errmsg);
List<LabResult> labResultList0 = commonUtil.getLabResultWithSql(labPat.getJyrq(), labPat.getYq(), labPat.getYbh(), errmsg);
if (labResultList0.size() > 0) flag = true;
}
if (flag = true) errmsg = "审核条件: " + ruledisplay + " 规则触发,未通过审核!";

View File

@ -55,6 +55,7 @@ public class CommonUtil {
ComLogMapper comLogMapper;
@Autowired
LabRefusedMapper labRefusedMapper;
//====检验主表操作方法集合===
public LabPat getLabPatOne(Date jyrq, String yq, String ybh) {
return labPatMapper.getLabPatOne(jyrq, yq, ybh);
@ -111,10 +112,12 @@ public class CommonUtil {
public List<LabReqsteplog> getLabReqsteplog(String sqh) {
return labReqsteplogMapper.getLabReqsteplog(sqh);
}
public List<LabRefused> getLabRefusedList(LabRefused labRefused){
public List<LabRefused> getLabRefusedList(LabRefused labRefused) {
return labRefusedMapper.getLabRefusedList(labRefused);
}
public int insertLabRefused(LabRefused labRefused){
public int insertLabRefused(LabRefused labRefused) {
return labRefusedMapper.insertLabRefused(labRefused);
}
@ -148,6 +151,10 @@ public class CommonUtil {
return labResultMapper.delNullLabResult(jyrq, yq, ybh);
}
public List<LabResult> getLabResultWithSql(Date jyrq, String yq, String ybh, String errmsg) {
return labResultMapper.getLabResultWithSql(jyrq, yq, ybh, errmsg);
}
@Transactional(rollbackFor = Exception.class)
public int updateLabResult(LabResult labResult) {
return labResultMapper.updateLabResult(labResult);
@ -173,7 +180,8 @@ public class CommonUtil {
public XmRef getXmRefValue(Map<String, Object> map) {
return xmRefMapper.getXmRefValue(map);
}
public XmRef getXmRefValue(String yq,String xmdh,String bbtype,String sex,Double age,String zd,String slzq) {
public XmRef getXmRefValue(String yq, String xmdh, String bbtype, String sex, Double age, String zd, String slzq) {
return xmRefMapper.getXmRefValue(yq, xmdh, bbtype, sex, age, zd, slzq);
}
@ -184,7 +192,10 @@ public class CommonUtil {
public List<XmAlarmdetail> getXmAlarmdetail(String yq, String xmdh) {
return xmAlarmdetailMapper.getXmAlarmdetail(yq, xmdh);
}
public Integer insertComLog(ComLog comLog) {return comLogMapper.insertComLog(comLog);}
public Integer insertComLog(ComLog comLog) {
return comLogMapper.insertComLog(comLog);
}
public String getYqmc(String yq) {
@ -251,6 +262,11 @@ public class CommonUtil {
List<ComDict> collect = comDictList.stream().filter(comDict -> comDict.getZddh().equals(zddh)).collect(Collectors.toList());
if (collect.size() > 0) {
return collect.get(0).getZdmc();
}else{
List<ComDict> collect0 = comDictList.stream().filter(comDict -> comDict.getZdmc().equals(zddh)).collect(Collectors.toList());
if (collect0.size() > 0) {
return collect0.get(0).getZdmc();
}
}
}
//如果redis当中没有查到数据,则先在设置redis值,
@ -263,7 +279,12 @@ public class CommonUtil {
if (comDictList != null) {
List<ComDict> collect = comDictList.stream().filter(comDict -> comDict.getZdmc().equals(zdmc)).collect(Collectors.toList());
if (collect.size() > 0) {
return collect.get(0).getZdmc();
return collect.get(0).getZddh();
}else{
List<ComDict> collect0 = comDictList.stream().filter(comDict -> comDict.getZddh().equals(zdmc)).collect(Collectors.toList());
if (collect0.size() > 0) {
return collect0.get(0).getZddh();
}
}
}
//如果redis当中没有查到数据,则先在设置redis值,

View File

@ -1,6 +1,8 @@
package com.czlis.interfaceCommon.utils;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
@ -149,59 +151,41 @@ public class LisUtil {
return input;
}
}
/**
* 保留指定小数位数
* 支持比较符号(<=、>=、<、>)和负号(-)同时存在的情况
* @param input 输入字符串,如"123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
* @param decimalPlaces 要保留的小数位数,需为非负整数
* @return 格式化后的字符串,无法处理时返回原值
保留指定小数位数(四舍五入)
支持比较符号 (<=、>=、<、>) 和负号 (-) 同时存在的情况
@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) {
public static String round (String input, int decimalPlaces) {
// 处理空输入或无效小数位数
if (input == null || input.trim ().isEmpty () || decimalPlaces < 0) {
return input;
}
// 定义比较运算符前缀(按长度排序,确保正确识别)
String[] comparisonPrefixes = {"<=", ">=", "<", ">"};
// 定义比较运算符前缀(按长度排序,确保正确识别)
String [] comparisonPrefixes = {"<=", ">=", "<", ">"};
String comparisonPrefix = "";
String remainingPart = input;
// 提取比较运算符前缀
String remainingPart = input.trim (); // 去除首尾空格
// 提取比较运算符前缀
for (String prefix : comparisonPrefixes) {
if (remainingPart.startsWith(prefix)) {
if (remainingPart.startsWith (prefix)) {
comparisonPrefix = prefix;
remainingPart = remainingPart.substring(prefix.length());
remainingPart = remainingPart.substring (prefix.length ()).trim (); // 去除前缀后的空格
break;
}
}
// 尝试解析剩余部分为数字
// 尝试解析剩余部分为数字(使用 BigDecimal 避免精度问题)
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;
// 解析为 BigDecimal(支持正负号和小数)
BigDecimal number = new BigDecimal (remainingPart);
// 设置四舍五入模式并保留指定小数位数
BigDecimal rounded = number.setScale (decimalPlaces, RoundingMode.HALF_UP);
// 拼接比较前缀和格式化后的数字
return comparisonPrefix + rounded.toPlainString (); //toPlainString 避免科学计数法
} catch (NumberFormatException e) {
// 数字部分无法解析时返回原值
// 数字部分无法解析时返回原值
return input;
}
}