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 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.*; @Component public class CommonUtil { @Autowired LabPatMapper labPatMapper; @Autowired ComOptMapper comOptMapper; @Autowired LabReqmainMapper labReqmainMapper; @Autowired CommonMapper commonMapper; @Autowired ComDictMapper comDictMapper; @Autowired private LabResultMapper labResultMapper; @Autowired LabReqdetailMapper labReqdetailMapper; @Autowired ComUsrMapper comUsrMapper; @Autowired ComUsrpowerMapper comUsrpowerMapper; @Autowired XmInfoMapper xmInfoMapper; @Autowired XmRefMapper xmRefMapper; //====检验主表操作方法集合=== 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);} @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 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 int insertLabResult(LabResult labResult) {return labResultMapper.insertLabResult(labResult);} public List 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 updateLabResult(LabResult labResult) {return labResultMapper.updateLabResult(labResult);} //=====项目字典查询========= 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 Date getCurrentTime(){return commonMapper.getCurrentTime();} public String getCurrentDate(){return DateFormatUtils.format(commonMapper.getCurrentTime(), "yyyy-MM-dd");} public String getCurrentDateTime(){return DateFormatUtils.format(commonMapper.getCurrentTime(), "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 comDictList =getDictCache(zdlb); if(comDictList!=null){ for (ComDict dict : comDictList) { if (zddh.equals(dict.getZddh())) { return dict.getZdmc(); } }} return comDictMapper.getComDictNameById(zdlb,zddh); } public String getComDictIdByName(String zdlb,String zdmc) { List comDictList =getDictCache(zdlb); if(comDictList!=null){ for (ComDict dict : comDictList) { if (zdmc.equals(dict.getZdmc())) { return dict.getZddh(); } }} return comDictMapper.getComDictIdByName(zdlb,zdmc); } public String getComOptValue(String yq,String xxdh){ List comOptList =getOptCache(yq); if(comOptList!=null){ for (ComOpt opt : comOptList) { if (xxdh.equals(opt.getXxdh())) { return opt.getXxqz(); } }} return comOptMapper.getComOptValue(yq,xxdh); } public List getLabReqdetailList(String sqh){ return labReqdetailMapper.getLabReqdetailList(sqh); } private List getDictCache(String zdlb) { return ComDictUtils.getDictCache(zdlb); } private List getOptCache(String yq) { return ComOptionUtils.getOptCache(yq); } 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 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; } }