387 lines
12 KiB
Java
387 lines
12 KiB
Java
package com.czlis.interfaceCommon.utils;
|
||
|
||
import com.czlis.common.core.domain.Result;
|
||
import com.czlis.common.core.domain.entity.lis.*;
|
||
import com.czlis.common.utils.ComDictUtils;
|
||
import com.czlis.common.utils.ComOptionUtils;
|
||
import com.czlis.interfaceCommon.mapper.*;
|
||
import com.sun.org.apache.bcel.internal.generic.RETURN;
|
||
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;
|
||
|
||
|
||
import java.util.*;
|
||
import java.util.stream.Collectors;
|
||
|
||
@Component
|
||
public class CommonUtil {
|
||
|
||
@Autowired
|
||
LabPatMapper labPatMapper;
|
||
@Autowired
|
||
ComOptMapper comOptMapper;
|
||
@Autowired
|
||
LabReqmainMapper labReqmainMapper;
|
||
@Autowired
|
||
CommonMapper commonMapper;
|
||
@Autowired
|
||
ComDictMapper comDictMapper;
|
||
@Autowired
|
||
LabResultMapper labResultMapper;
|
||
@Autowired
|
||
LabReqdetailMapper labReqdetailMapper;
|
||
@Autowired
|
||
ComUsrMapper comUsrMapper;
|
||
@Autowired
|
||
ComUsrpowerMapper comUsrpowerMapper;
|
||
@Autowired
|
||
XmInfoMapper xmInfoMapper;
|
||
@Autowired
|
||
XmRefMapper xmRefMapper;
|
||
@Autowired
|
||
XmValMapper xmValMapper;
|
||
@Autowired
|
||
LabInstrMapper labInstrMapper;
|
||
@Autowired
|
||
XmAlarmdetailMapper xmAlarmdetailMapper;
|
||
@Autowired
|
||
LabReqreportPdffileMapper labReqreportPdffileMapper;
|
||
@Autowired
|
||
LabReqsteplogMapper labReqsteplogMapper;
|
||
@Autowired
|
||
ComLogMapper comLogMapper;
|
||
@Autowired
|
||
LabRefusedMapper labRefusedMapper;
|
||
@Autowired
|
||
XmCalcMapper xmCalcMapper;
|
||
|
||
//====检验主表操作方法集合===
|
||
public LabPat getLabPatOne(Date jyrq, String yq, String ybh) {
|
||
return labPatMapper.getLabPatOne(jyrq, yq, ybh);
|
||
}
|
||
|
||
public List<LabPat> getLabPatListBySqh(String sqh) {
|
||
return labPatMapper.getLabPatListBySqh(sqh);
|
||
}
|
||
|
||
public List<LabPat> getLabPatList(LabPat labPat) {
|
||
return labPatMapper.getLabPat(labPat);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public int insertLabPat(LabPat labPat) {
|
||
return labPatMapper.updateLabPat(labPat);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public int delLabPat(LabPat labPat) {
|
||
return labPatMapper.updateLabPat(labPat);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public int updateLabPat(LabPat labPat) {
|
||
return labPatMapper.updateLabPat(labPat);
|
||
}
|
||
|
||
public int getCountByKey(Date jyrq, String yq, String ybh) {
|
||
return labPatMapper.getCountByKey(jyrq, yq, ybh);
|
||
}
|
||
|
||
public String getSqhByKey(Date jyrq, String yq, String ybh) {
|
||
return labPatMapper.getSqhByKey(jyrq, yq, ybh);
|
||
}
|
||
|
||
//申请单主表方法集合
|
||
public LabReqmain getLabReqmainOne(String sqh) {
|
||
return labReqmainMapper.getLabReqmainOne(sqh);
|
||
}
|
||
|
||
public int updateLabReqmain(LabReqmain labReqmain) {
|
||
return labReqmainMapper.updateLabReqmain(labReqmain);
|
||
}
|
||
|
||
public int deleteLabReqmain(String sqh) {
|
||
return labReqmainMapper.deleteLabReqmain(sqh);
|
||
}
|
||
|
||
public void insertLabReqmain(LabReqmain labReqmain) {
|
||
labReqmainMapper.insertLabReqmain(labReqmain);
|
||
}
|
||
|
||
public List<LabReqsteplog> getLabReqsteplog(String sqh) {
|
||
return labReqsteplogMapper.getLabReqsteplog(sqh);
|
||
}
|
||
|
||
public List<LabRefused> getLabRefusedList(LabRefused labRefused) {
|
||
return labRefusedMapper.getLabRefusedList(labRefused);
|
||
}
|
||
|
||
public int insertLabRefused(LabRefused labRefused) {
|
||
return labRefusedMapper.insertLabRefused(labRefused);
|
||
}
|
||
|
||
//申请单明细表集合
|
||
|
||
//====检验结果表操作方法集合===
|
||
public LabResult getLabResult(Date jyrq, String yq, String ybh, String xmdh) {
|
||
return labResultMapper.getLabResult(jyrq, yq, ybh, xmdh);
|
||
}
|
||
|
||
public List<LabResult> getLabResultList(Date jyrq, String yq, String ybh) {
|
||
return labResultMapper.getLabResultList(jyrq, yq, ybh);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void insertLabResult(LabResult labResult) {
|
||
labResultMapper.insertLabResult(labResult);
|
||
}
|
||
|
||
public List<LabResult> getresultinfo(Date jyrq, String yq, String ybh) {
|
||
return labResultMapper.getLabResultList(jyrq, yq, ybh);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public int delLabResult(LabResult labResult) {
|
||
return labResultMapper.delLabResult(labResult);
|
||
}
|
||
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public int delNullLabResult(Date jyrq, String yq, String ybh) {
|
||
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);
|
||
}
|
||
|
||
//=====项目字典查询=========
|
||
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 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);
|
||
}
|
||
|
||
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);
|
||
}
|
||
|
||
public List<XmAlarmdetail> getXmAlarmdetailList(String yq) {
|
||
return xmAlarmdetailMapper.getXmAlarmdetailList(yq);
|
||
}
|
||
|
||
public List<XmCalc> getXmCalcList(String yq) {
|
||
return xmCalcMapper.getXmCalcList(yq);
|
||
}
|
||
public Integer insertComLog(ComLog comLog) {
|
||
return comLogMapper.insertComLog(comLog);
|
||
}
|
||
|
||
|
||
public String getYqmc(String yq) {
|
||
return labInstrMapper.getYqmc(yq);
|
||
}
|
||
|
||
public String getYqdl(String yq) {
|
||
return labInstrMapper.getYqdl(yq);
|
||
}
|
||
|
||
public LabInstr getLabInstr(String yq) {
|
||
return labInstrMapper.getLabInstr(yq);
|
||
}
|
||
|
||
public List<LabInstr> getLabInstrList(LabInstr labInstr) {
|
||
return labInstrMapper.getLabInstrList(labInstr);
|
||
}
|
||
|
||
//服务器时间方法
|
||
public Date getCurrentTime() {
|
||
return commonMapper.getCurrentTime();
|
||
}
|
||
|
||
public String getCurrentDate() {
|
||
return getDateString(getCurrentTime());
|
||
}
|
||
|
||
public String getCurrentDateTime() {
|
||
return getDateTimeString(getCurrentTime());
|
||
}
|
||
|
||
public String getDateString(Date rq) {
|
||
return DateFormatUtils.format(rq, "yyyy-MM-dd");
|
||
}
|
||
|
||
public String getDateTimeString(Date rq) {
|
||
return DateFormatUtils.format(rq, "yyyy-MM-dd HH:mm:ss");
|
||
}
|
||
|
||
//字典查询单位名称
|
||
public String getCompany(String yljg) {
|
||
if (yljg == null || yljg.equals("")) return getCompany();
|
||
String zdmc = getComDictNameById("HOS", yljg);
|
||
if (zdmc == null || zdmc.equals("")) {
|
||
return yljg;
|
||
} else {
|
||
return zdmc;
|
||
}
|
||
}
|
||
|
||
public String getCompany() {
|
||
String zdmc = getComDictNameById("99", "COMPANY");
|
||
if (zdmc == null || zdmc.equals("")) {
|
||
return "";
|
||
} else {
|
||
return zdmc;
|
||
}
|
||
}
|
||
|
||
//字典查询方法集合
|
||
public String getComDictNameById(String zdlb, String zddh) {
|
||
List<ComDict> comDictList = getDictCache(zdlb);
|
||
if (comDictList != null) {
|
||
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值,
|
||
ComDictUtils.setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb));
|
||
return comDictMapper.getComDictNameById(zdlb, zddh);
|
||
}
|
||
|
||
public String getComDictIdByName(String zdlb, String zdmc) {
|
||
List<ComDict> comDictList = getDictCache(zdlb);
|
||
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).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值,
|
||
ComDictUtils.setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb));
|
||
return comDictMapper.getComDictIdByName(zdlb, zdmc);
|
||
}
|
||
|
||
public List<ComDict> getComDictList(String zdlb) {
|
||
List<ComDict> dictCacheList = getDictCache(zdlb);
|
||
if (dictCacheList != null) {
|
||
return dictCacheList;
|
||
} else {
|
||
return comDictMapper.getComDictListByZdlb(zdlb);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取本院设置全局参数yq=HISOPT
|
||
*
|
||
* @param xxdh
|
||
* @return
|
||
*/
|
||
public String getHISOPT(String xxdh) {
|
||
return getComOptValue("HISOPT", xxdh);
|
||
}
|
||
|
||
public String getComOptValue(String yq, String xxdh) {
|
||
ComOpt comOpt = getOptCache(yq, xxdh);
|
||
if (comOpt != null) {
|
||
//获取到缓存,直接返回缓存中的数据
|
||
return comOpt.getXxqz();
|
||
} else {
|
||
//没有获取到缓存,则先从数据库中查询数据,然后再进行缓存
|
||
ComOpt comOpt1 = comOptMapper.getComOptOne(yq, xxdh);
|
||
if (comOpt1 != null) {
|
||
ComOptionUtils.setOptCache(yq, xxdh, comOpt1);
|
||
return comOpt1.getXxqz();
|
||
}else{
|
||
ComOpt comOpt2=new ComOpt();
|
||
comOpt2.setBz("");
|
||
comOpt2.setXxdh(xxdh);
|
||
comOpt2.setYq(yq);
|
||
comOpt2.setXxqz("");
|
||
comOpt2.setXxlb("");
|
||
ComOptionUtils.setOptCache(yq, xxdh, comOpt2);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
}
|
||
|
||
public void setDictCache(String zdlb, List<ComDict> dictDatas) {
|
||
ComDictUtils.setDictCache(zdlb, dictDatas);
|
||
}
|
||
|
||
|
||
public List<LabReqdetail> getLabReqdetailList(String sqh) {
|
||
return labReqdetailMapper.getLabReqdetailList(sqh);
|
||
}
|
||
|
||
private List<ComDict> getDictCache(String zdlb) {
|
||
return ComDictUtils.getDictCache(zdlb);
|
||
}
|
||
|
||
private ComOpt getOptCache(String yq, String xxdh) {
|
||
return ComOptionUtils.getOptCache(yq, xxdh);
|
||
}
|
||
|
||
public Boolean getUserPower(String yq, String yhdh, int powerIdx) {
|
||
if ("LIS".equals(yhdh)) return true;
|
||
if ("lis".equals(yhdh)) return true;
|
||
//String yhjs= commonMapper.getyhjs(yhdh);
|
||
List<ComUsr> comUsrList = comUsrMapper.getComUsrList(yhdh);
|
||
String yhjs = comUsrList.get(0).getYhjs();
|
||
if ("S".equals(yhjs)) return true;
|
||
String userPower = comUsrpowerMapper.getUserPower(yq, yhdh);
|
||
if (userPower == null) return false;
|
||
if ("Y".equals(userPower.substring(powerIdx - 1, 1))) return true;
|
||
return false;
|
||
}
|
||
|
||
public List<LabReqreportPdffile> getLabReqreportPdffileList(String sqh) {
|
||
return labReqreportPdffileMapper.getLabReqreportPdffileList(sqh);
|
||
}
|
||
|
||
public LabReqreportPdffile getLabReqreportPdffileOne(Date jyrq, String yq, String ybh) {
|
||
return labReqreportPdffileMapper.getLabReqreportPdffileOne(jyrq, yq, ybh);
|
||
}
|
||
}
|