瀏覽代碼

优化门诊模板保存吧的时候不需要校验库存

hurugang 3 年之前
父節點
當前提交
9790d525fb

+ 2 - 2
src/main/java/cn/hnthyy/thmz/Utils/PyWbUtil.java

@@ -89,7 +89,7 @@ public class PyWbUtil {
                 pinyinName += nameChar[i];
             }
         }
-        return pinyinName;
+        return pinyinName.replaceAll("\\(","").replaceAll("\\)","");
     }
 
 
@@ -134,7 +134,7 @@ public class PyWbUtil {
                 }
             }
         }
-        return result.toString();
+        return result.toString().replaceAll("\\(","").replaceAll("\\)","");
     }
 
     public static void main(String[] args) {

+ 8 - 8
src/main/java/cn/hnthyy/thmz/mapper/his/zd/JcJyItemChargeMapper.java

@@ -60,10 +60,10 @@ public interface JcJyItemChargeMapper {
             "    FROM jy_zd_item WITH(NOLOCK) ",
             "where  isnull(del_flag,'') <![CDATA[<>]]> '1' ",
             "<when test='commonParams!=null'>",
-            "and (py_code like #{commonParams} or ",
-            "         d_code  like #{commonParams} or ",
-            "         code    like #{commonParams} or ",
-            "         name    like #{commonParams})  ",
+            "and (py_code like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         d_code  like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         code    like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         name    like #{commonParams} collate Chinese_PRC_CI_AS )  ",
             "</when>",
             " UNION ALL ",
             "    SELECT ",
@@ -74,10 +74,10 @@ public interface JcJyItemChargeMapper {
             "    FROM jc_zd_item  WITH(NOLOCK) ",
             "where  isnull(del_flag,'') <![CDATA[<>]]> '1' ",
             "<when test='commonParams!=null'>",
-            "and (py_code like #{commonParams} or ",
-            "         d_code  like #{commonParams} or ",
-            "         code    like #{commonParams} or ",
-            "         name    like #{commonParams})  ",
+            "and (py_code like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         d_code  like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         code    like #{commonParams} collate Chinese_PRC_CI_AS or ",
+            "         name    like #{commonParams} collate Chinese_PRC_CI_AS )  ",
             "</when>",
             "</script>"})
     List<JyZdItem> selectJcJyItemByCommonParams(@Param("commonParams") String commonParams);

+ 10 - 12
src/main/java/cn/hnthyy/thmz/mapper/his/zd/ZdChargeItemMapper.java

@@ -31,7 +31,7 @@ public interface ZdChargeItemMapper {
             " and del_flag =#{zdChargeItem.delFlag}",
             "</when>",
             "<when test='zdChargeItem.name!=null'>",
-            " and (name like #{zdChargeItem.name} or code like #{zdChargeItem.name} or n_code like #{zdChargeItem.name})",
+            " and (name like #{zdChargeItem.name} collate Chinese_PRC_CI_AS or code like #{zdChargeItem.name} collate Chinese_PRC_CI_AS or n_code like #{zdChargeItem.name} collate Chinese_PRC_CI_AS or py_code like #{zdChargeItem.name} collate Chinese_PRC_CI_AS or d_code like #{zdChargeItem.name} collate Chinese_PRC_CI_AS )",
             "</when>",
 /*            "<when test='zdChargeItem.code!=null'>",
             " and code = #{zdChargeItem.code}",
@@ -68,7 +68,7 @@ public interface ZdChargeItemMapper {
             " and del_flag =#{delFlag}",
             "</when>",
             "<when test='name!=null'>",
-            " and (name like #{name} or code like #{name} or n_code like #{name})",
+            " and (name like #{name} collate Chinese_PRC_CI_AS or code like #{name} collate Chinese_PRC_CI_AS or n_code like #{name} collate Chinese_PRC_CI_AS or py_code like #{name} collate Chinese_PRC_CI_AS or d_code like #{name} collate Chinese_PRC_CI_AS )",
             "</when>",
     /*        "<when test='code!=null'>",
             " and code = #{code}",
@@ -171,6 +171,12 @@ public interface ZdChargeItemMapper {
             "<when test='ybCode!=null'>",
             ",e_code =#{ybCode}",
             "</when>",
+            "<when test='pyCode!=null'>",
+            ",py_code =#{pyCode}",
+            "</when>",
+            "<when test='wbCode!=null'>",
+            ",d_code =#{wbCode}",
+            "</when>",
             "<when test='xnhCode!=null'>",
             ",xnh_code =#{xnhCode}",
             "</when>",
@@ -301,8 +307,6 @@ public interface ZdChargeItemMapper {
     /**
      * 根据通用查询参数查询诊疗项目  诊查费 治疗费 手术费
      * @param commonParams
-     * @param letterParamsUpperCase 字母大写参数  因为老系统区分大小写,但是又不能改数据库结构,所以需要兼容
-     * @param letterParamsLowerCase 字母小写参数  因为老系统区分大小写,但是又不能改数据库结构,所以需要兼容
      * @param pageSize 查询的数据条数
      * @return
      */
@@ -316,18 +320,12 @@ public interface ZdChargeItemMapper {
             "    FROM zd_charge_item WITH(NOLOCK)   ",
             "where  class_code in ('C','D','E','G','F','J')",
             "<when test='commonParams!=null'>",
-            " and (py_code like #{commonParams} or d_code  like #{commonParams} or code like #{commonParams} or name like #{commonParams} or class_code like #{commonParams}",
-            "<when test='letterParamsLowerCase!=null'>",
-            " or py_code like #{letterParamsLowerCase} or d_code  like #{letterParamsLowerCase} or code like #{letterParamsLowerCase} or name like #{letterParamsLowerCase}  ",
-            "</when>",
-            "<when test='letterParamsUpperCase!=null'>",
-            " or py_code like #{letterParamsUpperCase} or d_code  like #{letterParamsUpperCase} or code like #{letterParamsUpperCase} or name like #{letterParamsUpperCase}  ",
-            "</when>",
+            " and (py_code like #{commonParams} collate Chinese_PRC_CI_AS or d_code  like #{commonParams} collate Chinese_PRC_CI_AS or code like #{commonParams} collate Chinese_PRC_CI_AS or name like #{commonParams} collate Chinese_PRC_CI_AS or class_code like #{commonParams} collate Chinese_PRC_CI_AS ",
             ") ",
             "</when>",
           /*  " order by stock_amount_virtual desc",*/
             "</script>"})
-    List<JyZdItem> selectZlByCommonParams(@Param("commonParams") String commonParams, @Param("letterParamsLowerCase") String letterParamsLowerCase, @Param("letterParamsUpperCase") String letterParamsUpperCase, @Param("pageSize") Integer pageSize);
+    List<JyZdItem> selectZlByCommonParams(@Param("commonParams") String commonParams, @Param("pageSize") Integer pageSize);
 
     /**
      * 取消延时改价

+ 26 - 22
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -1863,24 +1863,26 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 if (ypZdDict != null) {
                     //当前处方购药量
                     BigDecimal thisQuantity = BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin()));
-                    if (ypZdDict.getMzRestrict() != null) {
-                        //本月已经购买量
-                        Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getFirstSecondForMonth(new Date()));
-                        quantityDb = quantityDb == null ? 0 : quantityDb;
-                        BigDecimal totalQuantity = thisQuantity.add(BigDecimal.valueOf(quantityDb));
-                        if (totalQuantity.compareTo(BigDecimal.valueOf(ypZdDict.getMzRestrict())) == 1) {
-                            //当前还可以购药量,小于0时为0
-                            BigDecimal tempCount = BigDecimal.valueOf(ypZdDict.getMzRestrict()).subtract(BigDecimal.valueOf(quantityDb));
-                            if (tempCount.compareTo(BigDecimal.ZERO) == -1) {
-                                tempCount = BigDecimal.ZERO;
+                    if(needVerify){
+                        if (ypZdDict.getMzRestrict() != null) {
+                            //本月已经购买量
+                            Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getFirstSecondForMonth(new Date()));
+                            quantityDb = quantityDb == null ? 0 : quantityDb;
+                            BigDecimal totalQuantity = thisQuantity.add(BigDecimal.valueOf(quantityDb));
+                            if (totalQuantity.compareTo(BigDecimal.valueOf(ypZdDict.getMzRestrict())) == 1) {
+                                //当前还可以购药量,小于0时为0
+                                BigDecimal tempCount = BigDecimal.valueOf(ypZdDict.getMzRestrict()).subtract(BigDecimal.valueOf(quantityDb));
+                                if (tempCount.compareTo(BigDecimal.ZERO) == -1) {
+                                    tempCount = BigDecimal.ZERO;
+                                }
+                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最大购买量为【" + ypZdDict.getMzRestrict() + "】,本月已购买量为【" + quantityDb + "】,本次最大可购量为【" + tempCount + "】,当前处方购药数量【" + thisQuantity + "】请修改处方限制购药品种的数量");
                             }
-                            throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最大购买量为【" + ypZdDict.getMzRestrict() + "】,本月已购买量为【" + quantityDb + "】,本次最大可购量为【" + tempCount + "】,当前处方购药数量【" + thisQuantity + "】请修改处方限制购药品种的数量");
                         }
-                    }
-                    if (ypZdDict.getPrescriptionLimitDays() != null && ypZdDict.getPrescriptionLimitDays() > 0) {
-                        Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getDateFromNow(-ypZdDict.getPrescriptionLimitDays()));
-                        if (quantityDb != null && quantityDb > 0) {
-                            throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近"+ypZdDict.getPrescriptionLimitDays()+"天已经购买过该药品!");
+                        if (ypZdDict.getPrescriptionLimitDays() != null && ypZdDict.getPrescriptionLimitDays() > 0) {
+                            Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getDateFromNow(-ypZdDict.getPrescriptionLimitDays()));
+                            if (quantityDb != null && quantityDb > 0) {
+                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近"+ypZdDict.getPrescriptionLimitDays()+"天已经购买过该药品!");
+                            }
                         }
                     }
                     String chargeBillCode = Constants.BILL_ITEM_CODE_prev + ypZdDict.getBillItemMz().substring(1);
@@ -1899,12 +1901,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                         if (StringUtils.isBlank(mzChargeDetail.getFrequency())) {
                             throw new MzException("保存处方失败,第" + itemNo + "行药品频率不能为空");
                         }
-                        YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.XY_ZCY_GROUP_NO);
-                        if (ypBaseYf == null) {
-                            throw new MzException("无药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的库存信息!");
-                        }
-                        if(thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual()==null?BigDecimal.ZERO:BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual()))==1){
-                            throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存"+(ypBaseYf.getStockAmountVirtual()==null?0:ypBaseYf.getStockAmountVirtual())+"请调整该药品数量!");
+                        if(needVerify){
+                            YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.XY_ZCY_GROUP_NO);
+                            if (ypBaseYf == null) {
+                                throw new MzException("无药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的库存信息!");
+                            }
+                            if(thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual()==null?BigDecimal.ZERO:BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual()))==1){
+                                throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存"+(ypBaseYf.getStockAmountVirtual()==null?0:ypBaseYf.getStockAmountVirtual())+"请调整该药品数量!");
+                            }
                         }
                         if (Constants.CLF.equals(ypZdDict.getBillItemMz())) {
                             YpBaseYf ycBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.YC_GROUP_NO);

+ 5 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/JcJyItemChargeServiceImpl.java

@@ -79,14 +79,14 @@ public class JcJyItemChargeServiceImpl implements JcJyItemChargeService {
             commonParams = null;
             pageSize =20;
         }
-        if (SignUtil.isAlpha(commonParams)) {
-            commonParams = commonParams.toUpperCase();
-        }
+//        if (SignUtil.isAlpha(commonParams)) {
+//            commonParams = commonParams.toUpperCase();
+//        }
         if (StringUtils.isNotBlank(commonParams)) {
-            commonParams = "%" + commonParams.toUpperCase() + "%";
+            commonParams = "%" + commonParams + "%";
         }
         List<JyZdItem> jyZdItemList = jcJyItemChargeMapper.selectJcJyItemByCommonParams(commonParams);
-        List<JyZdItem> zlList = zdChargeItemMapper.selectZlByCommonParams(commonParams, null, null, pageSize);
+        List<JyZdItem> zlList = zdChargeItemMapper.selectZlByCommonParams(commonParams, pageSize);
         if (jyZdItemList == null) {
             jyZdItemList = zlList;
         } else {