206 lines
8.1 KiB
Java
206 lines
8.1 KiB
Java
package com.czlisinterface.system.service;
|
||
|
||
import cn.hutool.core.date.DateUtil;
|
||
import cn.hutool.core.util.StrUtil;
|
||
import cn.hutool.json.JSONObject;
|
||
import cn.hutool.json.JSONUtil;
|
||
import com.czlisinterface.system.pojo.LabPatWarning;
|
||
import com.czlisinterface.system.pojo.LabReqmain;
|
||
import com.czlisinterface.system.pojo.Result;
|
||
import com.czlisinterface.system.utils.CommonUtil;
|
||
import com.czlisinterface.system.utils.LisWarningUtil;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
import org.springframework.stereotype.Component;
|
||
|
||
import javax.annotation.Resource;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
|
||
/**
|
||
* 通用外部接口
|
||
*/
|
||
@Component
|
||
@Slf4j
|
||
public class CommonExt {
|
||
|
||
|
||
@Resource
|
||
LisWarningUtil lisWarningUtil;
|
||
@Resource
|
||
CommonUtil commonUtil;
|
||
|
||
/**
|
||
* 修改危急值表数据
|
||
* {
|
||
* "method": "sampleaction",
|
||
* "rmmsg": {
|
||
* "actionflag": "1",
|
||
* "resultalertid": "20130201|XS500I|29",
|
||
* "userno": "9999",
|
||
* "actiontime": "2023-03-01 09:00:00",
|
||
* "actioninfo": ""
|
||
* }
|
||
* }
|
||
* @return
|
||
*/
|
||
public Result sampleaction(String json){
|
||
JSONObject jsonObject = JSONUtil.parseObj(json);
|
||
JSONObject rmmsg = (JSONObject) jsonObject.get("rmmsg");
|
||
String actionflag = String.valueOf(rmmsg.get("actionflag")); //处理标志 1: 已确认;2: 已处理
|
||
String resultalertid = String.valueOf(rmmsg.get("resultalertid")); //报告单号 LIS报告单主键
|
||
String userno = String.valueOf(rmmsg.get("userno")); //处理人
|
||
String actiontime = String.valueOf(rmmsg.get("actiontime")); //处理时间 yyyy-mm-dd HH:MM:SS
|
||
String type = "";
|
||
try{
|
||
type = String.valueOf(rmmsg.get("type")); //处理时间 yyyy-mm-dd HH:MM:SS
|
||
}catch (Exception e){
|
||
type = "";
|
||
}
|
||
|
||
Date confirmDate = null;
|
||
String actionMsg = null;
|
||
try{
|
||
confirmDate = DateUtil.parse(actiontime, "yyyy-MM-dd HH:mm:ss");
|
||
}catch (Exception e){
|
||
return new Result("-1","日期格式不合法");
|
||
}
|
||
String actioninfo = String.valueOf(rmmsg.get("actioninfo")); //处理意见
|
||
List<String> stringList = StrUtil.split(resultalertid, "|");
|
||
if(stringList.size() != 3){
|
||
return new Result("-1","resultalertid传值不正确!");
|
||
}
|
||
String jyrq = stringList.get(0);
|
||
String yq = stringList.get(1);
|
||
String ybh = stringList.get(2);
|
||
|
||
if(actioninfo == null || actioninfo.equals("")){
|
||
if(actionflag.equals("1")){
|
||
actionMsg = "已确认";
|
||
}else{
|
||
actionMsg = "已处理";
|
||
}
|
||
}else{
|
||
actionMsg = actioninfo;
|
||
}
|
||
|
||
if(type.equals("") || type.equals("1")){
|
||
LabPatWarning labPatWarning = new LabPatWarning();
|
||
labPatWarning.setQrr(userno);
|
||
labPatWarning.setQrsj(confirmDate);
|
||
labPatWarning.setBz(actionMsg);
|
||
int update = lisWarningUtil.updatePatWarning(labPatWarning, DateUtil.parse(jyrq, "yyyyMMdd"), yq, ybh);
|
||
if(update >= 0){
|
||
return new Result("0","修改数据成功!");
|
||
}else{
|
||
return new Result("-1","修改危急值表数据失败!");
|
||
}
|
||
}
|
||
if(type.equals("2")){
|
||
LabPatWarning labPatWarning1 = new LabPatWarning();
|
||
labPatWarning1.setQrr1(userno);
|
||
labPatWarning1.setQrsj1(confirmDate);
|
||
labPatWarning1.setBz(actionMsg);
|
||
int update = lisWarningUtil.updatePatWarning(labPatWarning1, DateUtil.parse(jyrq, "yyyyMMdd"), yq, ybh);
|
||
if(update >= 0){
|
||
return new Result("0","修改数据成功!");
|
||
}else{
|
||
return new Result("-1","修改危急值表数据失败!");
|
||
}
|
||
}
|
||
|
||
|
||
return new Result("-1","入参参数不对!");
|
||
|
||
}
|
||
|
||
/**
|
||
* 采样登记
|
||
* {
|
||
* "method": "getSamplingTime",
|
||
* "data": {
|
||
* "MuterID": "",
|
||
* "OperatorID": "",
|
||
* "OperatorName":"",
|
||
* "OperateTime": "",
|
||
* "bz":""
|
||
* }
|
||
* }
|
||
* @param json
|
||
* @return
|
||
*/
|
||
public Result getSamplingTime(String json){
|
||
JSONObject jsonObject = JSONUtil.parseObj(json);
|
||
JSONObject jsonObjectData = (JSONObject)jsonObject.get("data");
|
||
String muterID = jsonObjectData.getStr("MuterID");
|
||
String operatorID = jsonObjectData.getStr("OperatorID");
|
||
String operateTime = jsonObjectData.getStr("OperateTime");
|
||
LabReqmain labReqmain = new LabReqmain();
|
||
labReqmain.setCyr(operatorID);
|
||
labReqmain.setCysj(DateUtil.parse(operateTime,"yyyy-MM-dd HH:mm:ss"));
|
||
try{
|
||
LabReqmain labReqmainOne = commonUtil.getLabReqmainOne(muterID);
|
||
String zt = labReqmainOne.getZt();
|
||
if(!zt.equals("1") && !zt.equals("11") && !zt.equals("8") && !zt.equals("12")){
|
||
log.error("服务标识:getSamplingTime"+"\r\n入参:"+json+"\r\n出参:"+ new Result("-1","修改申请单状态失败,该标本:"+muterID+"已送检或者已上机或者已报告,不允许修改采样时间!") );
|
||
return new Result("-1","修改申请单状态失败,该标本:"+muterID+"已送检或者已上机或者已报告,不允许修改采样时间!");
|
||
}
|
||
|
||
//如果申请单状态是新开或者已打印 状态,则把状态变成已采样
|
||
if(zt.equals("1") || zt.equals("11")){
|
||
labReqmain.setZt("12");
|
||
}
|
||
commonUtil.updateLabReqmain(labReqmain,muterID);
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
log.error("服务标识:getSamplingTime"+"\r\n入参:"+json+"\r\n出参:"+ new Result("-1","修改LIS申请单状态失败:"+e));
|
||
return new Result("-1","修改LIS申请单状态失败:"+e.getMessage());
|
||
}
|
||
return new Result("0","修改状态成功!");
|
||
}
|
||
|
||
/**
|
||
* 标本送检
|
||
* {
|
||
* "method": "getInspectTime",
|
||
* "data": {
|
||
* "MuterID": "",
|
||
* "OperatorID": "",
|
||
* "OperatorName":"",
|
||
* "OperateTime": "",
|
||
* "bz":""
|
||
* }
|
||
* }
|
||
* @param json
|
||
* @return
|
||
*/
|
||
public Result getInspectTime(String json){
|
||
JSONObject jsonObject = JSONUtil.parseObj(json);
|
||
JSONObject jsonObjectData = (JSONObject)jsonObject.get("data");
|
||
String muterID = jsonObjectData.getStr("MuterID");
|
||
String operatorID = jsonObjectData.getStr("OperatorID");
|
||
String operateTime = jsonObjectData.getStr("OperateTime");
|
||
LabReqmain labReqmain = new LabReqmain();
|
||
labReqmain.setBbsjr(operatorID);
|
||
labReqmain.setBbsjsj(DateUtil.parse(operateTime,"yyyy-MM-dd HH:mm:ss"));
|
||
try{
|
||
LabReqmain labReqmainOne = commonUtil.getLabReqmainOne(muterID);
|
||
String zt = labReqmainOne.getZt();
|
||
if(!zt.equals("1") && !zt.equals("12") && !zt.equals("8") && !zt.equals("13")){
|
||
log.error("服务标识:getInspectTime"+"\r\n入参:"+json+"\r\n出参:"+ new Result("-1","修改申请单状态失败,该标本:"+muterID+"已送检或者已上机或者已报告,不允许修改送检时间!") );
|
||
return new Result("-1","修改申请单状态失败,该标本:"+muterID+"已送检或者已上机或者已报告,不允许修改送检时间!");
|
||
}
|
||
|
||
//如果申请单状态是新开或者已打印 状态,则把状态变成已送检
|
||
if(zt.equals("1") || zt.equals("12")){
|
||
labReqmain.setZt("13");
|
||
}
|
||
commonUtil.updateLabReqmain(labReqmain,muterID);
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
log.error("服务标识:getInspectTime"+"\r\n入参:"+json+"\r\n出参:"+ new Result("-1","修改LIS申请单状态失败:"+e));
|
||
return new Result("-1","修改LIS申请单状态失败:"+e.getMessage());
|
||
}
|
||
return new Result("0","修改状态成功!");
|
||
}
|
||
}
|