package com.czlis.interfaceCommon.utils; 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.czlis.interfaceCommon.pojo.entity.LastLabPatParam; import org.apache.commons.lang3.time.DateFormatUtils; 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 LabResultwarningMapper labResultwarningMapper; @Autowired LabPatwarningMapper labPatwarningMapper; @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; @Autowired LisPatlogMapper lisPatlogMapper; @Autowired LabResultlogMapper labResultlogMapper; @Autowired LabPatlogMapper labPatlogMapper; @Autowired LabResultMedMapper labResultMedMapper; @Autowired LabReportvsitemMapper labReportvsitemMapper; @Autowired LabInputcolMapper labInputcolMapper; @Autowired ComLocalconfigMapper comLocalconfigMapper; @Autowired LabPatfeeMapper labPatfeeMapper; @Autowired LabGraphMapper labGraphMapper; @Autowired ComPatMapper comPatMapper; @Autowired ComSeqMapper comSeqMapper; @Autowired LabReqpackMapper labReqpackMapper; @Autowired LabInputmdlMapper labInputmdlMapper; @Autowired LabInputmdlDetailMapper labInputmdlDetailMapper; //====检验主表操作方法集合=== public LabPat getLabPatOne(Date jyrq, String yq, String ybh) { return labPatMapper.getLabPatOne(jyrq, yq, ybh); } public List getLabPatListBySqh(String sqh) { return labPatMapper.getLabPatListBySqh(sqh); } public List getLabPatList(LabPat labPat) { return labPatMapper.getLabPat(labPat); } public List getsamplelist(Date jyrq, String yq){ return labPatMapper.getSampleList(jyrq,yq); } public List getSampleListday(String yq, Long days){ return labPatMapper.getSampleListday(yq,days); } public LabPatfee getLabPatfee(Date jyrq, String yq, String ybh) { return labPatfeeMapper.getLabPatfee(jyrq,yq,ybh); } public List getLabPatfeeBysqh(String sqh) { return labPatfeeMapper.getLabPatfeeBysqh(sqh); } @Transactional(rollbackFor = Exception.class) public int insertLabPatfee(LabPatfee labPatfee) { return labPatfeeMapper.insertLabPatfee(labPatfee); } @Transactional(rollbackFor = Exception.class) public int deleteLabPatfee(Date jyrq, String yq, String ybh) { return labPatfeeMapper.deleteLabPatfee(jyrq,yq,ybh); } @Transactional(rollbackFor = Exception.class) public int updateLabPatfee(LabPatfee labPatfee) { return labPatfeeMapper.updateLabPatfee(labPatfee); } public int getLabGraphCount(Date jyrq,String yq,String ybh) { return labGraphMapper.getLabGraphCount(jyrq,yq,ybh); } public LabGraph getLabGraph(Date jyrq,String yq,String ybh,String txmc) { return labGraphMapper.getLabGraph(jyrq,yq,ybh,txmc); } public List getLabGraphAll(Date jyrq,String yq,String ybh) { return labGraphMapper.getLabGraphAll(jyrq,yq,ybh); } @Transactional(rollbackFor = Exception.class) public int updateLabGraph(LabGraph labGraph) { return labGraphMapper.updateLabGraph(labGraph); } @Transactional(rollbackFor = Exception.class) public int updateLabGraphBlob(LabGraph labGraph) { return labGraphMapper.updateLabGraphBlob(labGraph); } @Transactional(rollbackFor = Exception.class) public int deleteLabGraphAll(Date jyrq,String yq,String ybh) { return labGraphMapper.deleteLabGraphAll(jyrq,yq,ybh); } @Transactional(rollbackFor = Exception.class) public int deleteLabGraph(Date jyrq,String yq,String ybh,String txmc) { return labGraphMapper.deleteLabGraph(jyrq,yq,ybh,txmc); } @Transactional(rollbackFor = Exception.class) public int insertLabGraph(LabGraph labGraph) { return labGraphMapper.insertLabGraph(labGraph); } @Transactional(rollbackFor = Exception.class) public int insertLabPat(LabPat labPat) { labPatMapper.insertLabPat(labPat); return 0; } @Transactional(rollbackFor = Exception.class) public int delLabPat(Date jyrq, String yq, String ybh) { return labPatMapper.delLabPat(jyrq, yq,ybh); } @Transactional(rollbackFor = Exception.class) public int updateLabPat(LabPat labPat) { return labPatMapper.updateLabPat(labPat); } @Transactional(rollbackFor = Exception.class) public int updateLabPatJgbz(Date jyrq, String yq, String ybh,String jgbz){return updateLabPatByColumn(jyrq,yq,ybh,"jgbz",jgbz);} public int updateLabPatByColumn(Date jyrq, String yq, String ybh,String column,String jgbz){return labPatMapper.updateLabPatByColumn(jyrq,yq,ybh,column,jgbz);} public int getCountByKey(Date jyrq, String yq, String ybh) { return labPatMapper.getCountByKey(jyrq, yq, ybh); } public String getLabPatJgbz(Date jyrq, String yq, String ybh){ return labPatMapper.getLabPatJgbz(jyrq, yq, ybh); } public List getlastLabPat(LastLabPatParam lastLabPatParam){ return labPatMapper.getlastLabPat(lastLabPatParam); } public String getSqhByKey(Date jyrq, String yq, String ybh) { return labPatMapper.getSqhByKey(jyrq, yq, ybh); } //ComPat public List getComPat(String brdh,String yljg){ return comPatMapper.getComPat(brdh,yljg); } @Transactional(rollbackFor = Exception.class) public int deleteComPat(String brdh,String yljg){ return comPatMapper.deleteComPat(brdh,yljg); } @Transactional(rollbackFor = Exception.class) public int insertComPat(ComPat comPat) { return comPatMapper.insertComPat(comPat); } //申请单主表方法集合 public LabReqmain getLabReqmainOne(String sqh) { return labReqmainMapper.getLabReqmainOne(sqh); } @Transactional(rollbackFor = Exception.class) public int updateLabReqmain(LabReqmain labReqmain) { return labReqmainMapper.updateLabReqmain(labReqmain); } @Transactional(rollbackFor = Exception.class) public int deleteLabReqmain(String sqh) { return labReqmainMapper.deleteLabReqmain(sqh); } @Transactional(rollbackFor = Exception.class) public void insertLabReqmain(LabReqmain labReqmain) { labReqmainMapper.insertLabReqmain(labReqmain); } @Transactional(rollbackFor = Exception.class) public void zxLabReqmain(String sqh,String userId){ labReqmainMapper.zxLabReqmain(sqh,userId); } @Transactional(rollbackFor = Exception.class) public void QXLabReqmain(Date jyrq, String yq, String ybh){ labReqmainMapper.QXLabReqmain(jyrq,yq,ybh); } public List getLabReqsteplog(String sqh) { return labReqsteplogMapper.getLabReqsteplog(sqh); } @Transactional(rollbackFor = Exception.class) public int insertLabReqsteplog(LabReqsteplog labReqsteplog) { return labReqsteplogMapper.insertLabReqsteplog(labReqsteplog); } public int getLabReqsteplogMax(String sqh) { return labReqsteplogMapper.getLabReqsteplogMax(sqh); } public List 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 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); } @Transactional(rollbackFor = Exception.class) public void insertLabResultByBarcode(Date jyrq, String yq, String ybh, String sqh){ labResultMapper.insertLabResultByBarcode(jyrq,yq,ybh,sqh); } @Transactional(rollbackFor = Exception.class) public int delLabResult(LabResult labResult) { return labResultMapper.delLabResult(labResult); } @Transactional(rollbackFor = Exception.class) public int delLabResultAll(Date jyrq, String yq, String ybh) { return labResultMapper.delLabResultAll(jyrq,yq,ybh); } @Transactional(rollbackFor = Exception.class) public int delNullLabResult(Date jyrq, String yq, String ybh) { return labResultMapper.delNullLabResult(jyrq, yq, ybh); } public List 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 getLabResultwarning(Date jyrq, String yq, String ybh) { return labResultwarningMapper.getLabResultwarning(jyrq, yq, ybh); } public LabPatwarning getLabPatwarning(Date jyrq, String yq, String ybh) { return labPatwarningMapper.getLabPatwarning(jyrq, yq, ybh); } @Transactional(rollbackFor = Exception.class) public void insertLabResultwarning(LabResultwarning labResultwarning) { labResultwarningMapper.insertLabResultwarning(labResultwarning); } @Transactional(rollbackFor = Exception.class) public void insertLabPatwarning(LabPatwarning labPatwarning) { labPatwarningMapper.insertLabPatwarning(labPatwarning); } @Transactional(rollbackFor = Exception.class) public void deleteLabPatwarning(Date jyrq, String yq, String ybh) { labPatwarningMapper.deleteLabPatwarning(jyrq, yq, ybh); } @Transactional(rollbackFor = Exception.class) public void deleteLabResultwarning(Date jyrq, String yq, String ybh) { labResultwarningMapper.deleteLabResultwarning(jyrq, yq, ybh); } @Transactional(rollbackFor = Exception.class) public void insertLabResultlog(Date jyrq, String yq, String ybh,Date xgrq,String xgyhdh,String ip) { labResultlogMapper.insertLabResultlog(jyrq, yq, ybh,xgrq,xgyhdh,ip); } public List getLabResultlog(Date jyrq, String yq, String ybh){ return labResultlogMapper.getLabResultlog(jyrq, yq, ybh); } public List getLabResultlogxmdh(Date jyrq, String yq, String ybh, String xmdh) { return labResultlogMapper.getLabResultlogxmdh(jyrq, yq, ybh,xmdh); } @Transactional(rollbackFor = Exception.class) public void insertLabPatlog(Date jyrq, String yq, String ybh,Date xgrq,String xgyhdh,String ip) { labPatlogMapper.insertLabPatlog(jyrq, yq, ybh,xgrq,xgyhdh,ip); } public LabPatlog getLabPatlog(Date jyrq, String yq, String ybh,Date xgrq) { return labPatlogMapper.getLabPatlog(jyrq, yq, ybh,xgrq); } public int getLabResultMedCount(Date jyrq, String yq, String ybh) { return labResultMedMapper.getLabResultMedCount(jyrq, yq, ybh); } public List getLabResultMed(Date jyrq, String yq, String ybh,String xmdh){ return labResultMedMapper.getLabResultMed(jyrq, yq, ybh,xmdh); } @Transactional(rollbackFor = Exception.class) public void delLabResultMed(Date jyrq, String yq, String ybh,String xmdh) { labResultMedMapper.delLabResultMed(jyrq, yq, ybh,xmdh); } @Transactional(rollbackFor = Exception.class) public void delLabResultMedAll(Date jyrq, String yq, String ybh) { labResultMedMapper.delLabResultMedAll(jyrq, yq, ybh); } //封箱 public List getLabReqpack(String packno){ return labReqpackMapper.getLabReqpack(packno); } public int getLabReqpackConut(String packno){ return labReqpackMapper.getLabReqpackConut(packno); } @Transactional(rollbackFor = Exception.class) public int insertLabReqpack(LabReqpack labReqpack){ return labReqpackMapper.insertLabReqpack(labReqpack); } @Transactional(rollbackFor = Exception.class) public int batchInsertLabReqpack(List labReqpackList){ return labReqpackMapper.batchInsertLabReqpack(labReqpackList); } //=====项目字典查询========= public List getXmInfoList(String yq) { return xmInfoMapper.getXmInfoList(yq); } public XmInfo getXmInfo(String yq, String xmdh) { return xmInfoMapper.getXmInfo(yq, xmdh); } public List getXmRefList(String yq) { return xmRefMapper.getXmRefList(yq); } public XmRef getXmRef(String yq, String xmdh) { return xmRefMapper.getXmRef(yq, xmdh); } public XmRef getXmRefValue(Map 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 getXmValJgbz(String yq, String xmdh, String csjg, String csjg1, String csjg2) { return xmValMapper.getXmValJgbz(yq, xmdh, csjg, csjg1, csjg2); } public List getXmVal(String yq,String xmdh) { return xmValMapper.getXmVal(yq,xmdh); } public List getLabInputmdl(String yq) { return labInputmdlMapper.getLabInputmdl(yq); } public LabInputmdl getLabInputmdlmbmc(String yq,String mbmc) { return labInputmdlMapper.getLabInputmdlmbmc(yq,mbmc); } public List getLabInputmdlzdsr(String yq) { return labInputmdlMapper.getLabInputmdlzdsr(yq); } public List getLabInputmdlzdsrybh(String yq,String ybh) { return labInputmdlMapper.getLabInputmdlzdsrybh(yq,ybh); } public List getLabInputmdlDetail(String yq,String mbmc) { return labInputmdlDetailMapper.getLabInputmdlDetail(yq,mbmc); } public List getXmAlarmdetail(String yq, String xmdh) { return xmAlarmdetailMapper.getXmAlarmdetail(yq, xmdh); } public List getXmAlarmdetailList(String yq) { return xmAlarmdetailMapper.getXmAlarmdetailList(yq); } public List getXmCalcList(String yq) { return xmCalcMapper.getXmCalcList(yq); } public List getXmCalcbyxmdh(String yq,String xmdh) { return xmCalcMapper.getXmCalcbyxmdh(yq,xmdh); } @Transactional(rollbackFor = Exception.class) public Integer insertComLog(ComLog comLog) { return comLogMapper.insertComLog(comLog); } @Transactional(rollbackFor = Exception.class) public Integer insertLisPatlog(LisPatlog lisPatlog) { return lisPatlogMapper.insertLisPatlog(lisPatlog); } public String getLisPatlogbz(Date jyrq, String yq, String ybh) { return lisPatlogMapper.getLisPatlogbz(jyrq, yq, ybh); } 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 getInstrdList(String lisgroup,String yljg,String useflag,String userno,String powerbit){ return labInstrMapper.getInstrdList(lisgroup, yljg, useflag, userno, powerbit); } public List querybylisgroup(String lisgroup,String yljg,String useflag){ return labInstrMapper.querybylisgroup(lisgroup, yljg, useflag); } public List getLabInstrList(LabInstr labInstr) { return labInstrMapper.getLabInstrList(labInstr); } public int getLabReport2(Date jyrq, String yq, String ybh) { return labReportvsitemMapper.getLabReport2(jyrq, yq, ybh); } //获取流水号种子 @Transactional(rollbackFor = Exception.class) public Long getNextSeq(String seqid) { Map param = new HashMap<>(); param.put("seqid", seqid); // 调用存储过程,出参将被设置到param的nextVal中 comSeqMapper.getNextSeq(param); return (Long) param.get("retcode"); } //服务器时间方法 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.isEmpty()) return getCompany(); String zdmc = getComDictNameById("HOS", yljg); if (zdmc == null || zdmc.isEmpty()) { return yljg; } else { return zdmc; } } public String getCompany() { String zdmc = getComDictNameById("99", "COMPANY"); if (zdmc == null || zdmc.isEmpty()) { return ""; } else { return zdmc; } } public List getLabInputcol(String yq){ return labInputcolMapper.getLabInputcol(yq); } //字典查询方法集合 public String getComDictNameById(String zdlb, String zddh) { List comDictList = getDictCache(zdlb); if (comDictList != null) { List collect = comDictList.stream().filter(comDict -> comDict.getZddh().equals(zddh)).collect(Collectors.toList()); if (!collect.isEmpty()) { return collect.get(0).getZdmc(); }else{ List collect0 = comDictList.stream().filter(comDict -> comDict.getZdmc().equals(zddh)).collect(Collectors.toList()); if (!collect0.isEmpty()) { 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 comDictList = getDictCache(zdlb); if (comDictList != null) { List collect = comDictList.stream().filter(comDict -> comDict.getZdmc().equals(zdmc)).collect(Collectors.toList()); if (!collect.isEmpty()) { return collect.get(0).getZddh(); }else{ List collect0 = comDictList.stream().filter(comDict -> comDict.getZddh().equals(zdmc)).collect(Collectors.toList()); if (!collect0.isEmpty()) { return collect0.get(0).getZddh(); } } } //如果redis当中没有查到数据,则先在设置redis值, ComDictUtils.setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb)); return comDictMapper.getComDictIdByName(zdlb, zdmc); } public List getComDictList(String zdlb) { List 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 dictDatas) { ComDictUtils.setDictCache(zdlb, dictDatas); } public List getLabReqdetailList(String sqh) { return labReqdetailMapper.getLabReqdetailList(sqh); } private List getDictCache(String zdlb) { return ComDictUtils.getDictCache(zdlb); } private ComOpt getOptCache(String yq, String xxdh) { return ComOptionUtils.getOptCache(yq, xxdh); } public List getComUsrList(String yhdh) { return comUsrMapper.getComUsrList(yhdh); } public Boolean getUserPower(String yq, String yhdh, int powerIdx) { if ("admin".equals(yhdh)) return true; if ("LIS".equals(yhdh)) return true; if ("lis".equals(yhdh)) return true; //String yhjs= commonMapper.getyhjs(yhdh); List 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; return "Y".equals(userPower.substring(powerIdx - 1, 1)); } public byte[] getComUsrdzqm(String yhdh) { return comUsrMapper.getComUsrdzqm(yhdh); } public String getComUsrName(String yhdh){ return comUsrMapper.getComUsrName(yhdh); } public List getLabReqreportPdffileList(String sqh) { return labReqreportPdffileMapper.getLabReqreportPdffileList(sqh); } public LabReqreportPdffile getLabReqreportPdffileOne(Date jyrq, String yq, String ybh) { return labReqreportPdffileMapper.getLabReqreportPdffileOne(jyrq, yq, ybh); } @Transactional(rollbackFor = Exception.class) public int deleteLabReqreportPdffile(Date jyrq, String yq, String ybh) { return labReqreportPdffileMapper.deleteLabReqreportPdffile(jyrq, yq, ybh); } public String getLocalconfig(String smac) { return comLocalconfigMapper.getLocalconfig(smac); } }