From d745ed77e49223ea0d07c049a7f755dfabfa180e Mon Sep 17 00:00:00 2001 From: jiangs <373297395@qq.com> Date: Tue, 19 Aug 2025 17:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AD=97=E5=85=B8=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=BC=82=E6=AD=A5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/czlis/common/utils/ComDictUtils.java | 17 +- .../interfaceCommon/utils/CommonUtil.java | 210 ++++++++++++------ 2 files changed, 155 insertions(+), 72 deletions(-) diff --git a/lis-common/src/main/java/com/czlis/common/utils/ComDictUtils.java b/lis-common/src/main/java/com/czlis/common/utils/ComDictUtils.java index cdf89ac..e3bd91f 100644 --- a/lis-common/src/main/java/com/czlis/common/utils/ComDictUtils.java +++ b/lis-common/src/main/java/com/czlis/common/utils/ComDictUtils.java @@ -15,16 +15,17 @@ import java.util.List; public class ComDictUtils { /** - * 设置字典缓存 + * 设置代码字典缓存 * - * @param key 参数键 + * @param zdlb 字典类别 * @param dictDatas 字典数据列表 */ - public static void setDictCache(String key, List dictDatas) { + public static void setDictCache(String zdlb, List dictDatas) { //先清除该key的所有缓存,然后再重新设置该key的缓存 - SpringUtils.getBean(RedisCache.class).deleteObject(key); - SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); + SpringUtils.getBean(RedisCache.class).deleteObject(zdlb); + SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(zdlb), dictDatas); } + /** * 清空字典缓存 */ @@ -35,11 +36,11 @@ public class ComDictUtils { /** * 获取字典缓存 * - * @param key 参数键 + * @param zdlb 字典类别 * @return dictDatas 字典数据列表 */ - public static List getDictCache(String key) { - JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); + public static List getDictCache(String zdlb) { + JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(zdlb)); if (StringUtils.isNotNull(arrayCache)) { return arrayCache.toList(ComDict.class); } diff --git a/lis-interfaceCommon/src/main/java/com/czlis/interfaceCommon/utils/CommonUtil.java b/lis-interfaceCommon/src/main/java/com/czlis/interfaceCommon/utils/CommonUtil.java index 9d8ba57..32b3e3a 100644 --- a/lis-interfaceCommon/src/main/java/com/czlis/interfaceCommon/utils/CommonUtil.java +++ b/lis-interfaceCommon/src/main/java/com/czlis/interfaceCommon/utils/CommonUtil.java @@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; @Component public class CommonUtil { @@ -43,129 +44,210 @@ public class CommonUtil { XmValMapper xmValMapper; @Autowired XmAlarmdetailMapper xmAlarmdetailMapper; - //====检验主表操作方法集合=== - public LabPat getLabPatOne(Date jyrq, String yq, String ybh){ + + //====检验主表操作方法集合=== + 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 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);} + public int insertLabPat(LabPat labPat) { + return labPatMapper.updateLabPat(labPat); + } + @Transactional(rollbackFor = Exception.class) - public int delLabPat(LabPat labPat){return labPatMapper.updateLabPat(labPat);} + 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 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){ + 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);} + 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);} + 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);} + 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 int delNullLabResult(Date jyrq, String yq, String ybh) { + return labResultMapper.delNullLabResult(jyrq, yq, ybh); + } + @Transactional(rollbackFor = Exception.class) - public int updateLabResult(LabResult labResult) {return labResultMapper.updateLabResult(labResult);} + 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 String getXmRefJgbz(String yq,String xmdh,String csjg,String csjg1,String csjg2) {return xmValMapper.getXmValJgbz(yq,xmdh,csjg,csjg1,csjg2);} - public List getXmAlarmdetail(String yq,String xmdh){return xmAlarmdetailMapper.getXmAlarmdetail(yq,xmdh);}; + 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 String getXmRefJgbz(String yq, String xmdh, String csjg, String csjg1, String csjg2) { + return xmValMapper.getXmValJgbz(yq, xmdh, csjg, csjg1, csjg2); + } + + public List getXmAlarmdetail(String yq, String xmdh) { + return xmAlarmdetailMapper.getXmAlarmdetail(yq, xmdh); + } + + ; //服务器时间方法 - 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 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("")){ + 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{ + } else { return zdmc; } } - public String getCompany(){ - String zdmc=getComDictNameById("99","COMPANY"); - if(zdmc == null || zdmc.equals("")){ + + public String getCompany() { + String zdmc = getComDictNameById("99", "COMPANY"); + if (zdmc == null || zdmc.equals("")) { return ""; - }else{ + } 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(); + List comDictList = getDictCache(zdlb); + if (comDictList != null) { + List collect = comDictList.stream().filter(comDict -> comDict.getZddh().equals(zddh)).collect(Collectors.toList()); + if(collect.size() > 0){ + return collect.get(0).getZdmc(); } - }} - return comDictMapper.getComDictNameById(zdlb,zddh); + } + //如果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){ - for (ComDict dict : comDictList) { - if (zdmc.equals(dict.getZdmc())) { - return dict.getZddh(); + 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.size() > 0){ + return collect.get(0).getZdmc(); } - }} - return comDictMapper.getComDictIdByName(zdlb,zdmc); + } + //如果redis当中没有查到数据,则先在设置redis值, + ComDictUtils.setDictCache(zdlb,comDictMapper.getComDictListByZdlb(zdlb)); + return comDictMapper.getComDictIdByName(zdlb, zdmc); } - public String getComOptValue(String yq,String xxdh){ - ComOpt comOpt =getOptCache(yq,xxdh); - if(comOpt != null) { + + public String getComOptValue(String yq, String xxdh) { + ComOpt comOpt = getOptCache(yq, xxdh); + if (comOpt != null) { //获取到缓存,直接返回缓存中的数据 return comOpt.getXxqz(); - }else{ + } else { //没有获取到缓存,则先从数据库中查询数据,然后再进行缓存 ComOpt comOpt1 = comOptMapper.getComOptOne(yq, xxdh); - ComOptionUtils.setOptCache(yq,xxdh,comOpt1); + ComOptionUtils.setOptCache(yq, xxdh, comOpt1); return comOpt1.getXxqz(); } } - public List getLabReqdetailList(String sqh){ + public List getLabReqdetailList(String sqh) { return labReqdetailMapper.getLabReqdetailList(sqh); } - private List getDictCache(String zdlb) { + private List getDictCache(String zdlb) { return ComDictUtils.getDictCache(zdlb); } - private ComOpt getOptCache(String yq,String xxdh) { - return ComOptionUtils.getOptCache(yq,xxdh); + private ComOpt getOptCache(String yq, String xxdh) { + return ComOptionUtils.getOptCache(yq, xxdh); } - public Boolean getUserPower(String yq,String yhdh,int powerIdx){ + 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; + String userPower = comUsrpowerMapper.getUserPower(yq, yhdh); + if (userPower == null) return false; + if ("Y".equals(userPower.substring(powerIdx - 1, 1))) return true; return false; } }