Browse Source

修改医嘱退费匹配 每100条的退。

xiaochan 4 years ago
parent
commit
ce3ec633ba

+ 34 - 6
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -537,15 +537,32 @@ public interface XiangMuLuRuDao {
                             @Param("tableName") String tableName);
 
 
+    /**
+     * 查看模板名称是否存在
+     *
+     * @param patternName 模板名字
+     * @param opIdCode    创建模板的人 code
+     * @return 返回条数
+     */
     @Select("select count(*) from zy_charge_pattern where pattern_name =  #{patternName} and op_id_code <> #{opIdCode} ")
     Integer chaKanMuBanMingChengSFcunZi(@Param("patternName") String patternName,
                                         @Param("opIdCode") String opIdCode);
 
+    /**
+     * 删除模板
+     *
+     * @param patternName 模板名字
+     * @param opIdCode    创建模板的人 code
+     */
     @Select("delete zy_charge_pattern where pattern_name = #{patternName} and op_id_code = #{opIdCode} ")
     void delMuBan(@Param("patternName") String patternName,
                   @Param("opIdCode") String opIdCode);
 
-
+    /**
+     * 保存模板
+     *
+     * @param param 保存的数据
+     */
     @Insert("<script>" +
             "INSERT INTO zy_charge_pattern ( charge_name, " +
             "                               pattern_name, " +
@@ -580,7 +597,14 @@ public interface XiangMuLuRuDao {
             "</script>")
     void baoCunMuBan(@Param("param") ZyDetailCharge param);
 
-
+    /**
+     * 获取医嘱的费用
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param ZF          正的费用还是负的费用
+     * @return 返回list 费用集合
+     */
     @Select("select charge_date,charge_fee,charge_amount,charge_code_mx,detail_sn,ori_detail_sn,ABS(order_no) order_no " +
             "from zy_detail_charge where  inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and  LEN(order_no)  > 2  and " +
             "ori_detail_sn is null and charge_amount ${ZF} 0 and charge_fee ${ZF} 0")
@@ -588,16 +612,20 @@ public interface XiangMuLuRuDao {
                                          @Param("admissTimes") Integer admissTimes,
                                          @Param("ZF") String ZF);
 
-
+    /**
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param yiZhuPiPei  需要匹配的流水信息
+     */
     @Update("<script>" +
             "<foreach collection='list' item='item' index='index' open='' close='' separator=';'>" +
             "update zy_detail_charge set ori_detail_sn = #{item.oriDetailSn} where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} " +
             "and detail_sn = #{item.detailSn} " +
             "</foreach>" +
             "</script>")
-    Integer yiZhuTuiFeiPiPei(@Param("inpatientNo") String inpatientNo,
-                             @Param("admissTimes") Integer admissTimes,
-                             @Param("list") List<ZyDetailCharge> yiZhuPiPei);
+    void yiZhuTuiFeiPiPei(@Param("inpatientNo") String inpatientNo,
+                          @Param("admissTimes") Integer admissTimes,
+                          @Param("list") List<ZyDetailCharge> yiZhuPiPei);
 
 
 }

+ 28 - 7
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -82,6 +82,9 @@ public class XiangMuLuRuService {
      */
     @Transactional
     public ResultVo<String> xiangMuTuiFei(ZyDetailCharge param) {
+        if (param.getList().size() >= 100) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "项目退费一次性大于100条数据");
+        }
         if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getLedgerSn() == null || param.getList().size() == 0) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全");
         }
@@ -90,8 +93,6 @@ public class XiangMuLuRuService {
         for (ZyDetailCharge charge : chaKanSFtuiFei) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:【%s】已退费,请勿重复退费", charge.getOriDetailSn()));
         }
-
-
         // 获取最大值
         Integer maxDetailSn = transferInOfExpensesDao.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
         // 获取原来的数据
@@ -104,7 +105,11 @@ public class XiangMuLuRuService {
         for (ZyDetailCharge pojo : yuanTuiFeiList) {
             // 判断患者的费用是否存在负数
             if (pojo.getChargeFee().signum() == -1 || pojo.getChargeAmount().signum() == -1) {
-                return ResultVoUtil.fail(ExceptionEnum.EXIST_NEGATIVE_FEES, "患者费用存在负数,该数据为退费数据");
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者费用存在负数,该数据为退费数据");
+            }
+
+            if (!param.getDeptCode().equals(pojo.getDeptCode())) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请录入的科室进行退费", pojo.getDetailSn()));
             }
             sum = sum.add(pojo.getChargeFee().multiply(pojo.getChargeAmount()));
             pojo.setChargeFee(pojo.getChargeFee().negate());
@@ -162,6 +167,10 @@ public class XiangMuLuRuService {
 
     @Transactional
     public ResultVo<String> xiangMuFeiYongShangChuan(ZyDetailCharge param) {
+
+        if (param.getList().size() >= 100) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "一次性项目录入大于100条");
+        }
         if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getLedgerSn() == null || param.getList().size() == 0
                 || StringUtil.isBlank(param.getWard()) || StringUtil.isBlank(param.getDept()) || StringUtil.isBlank(param.getZySerialNo())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全。");
@@ -187,10 +196,8 @@ public class XiangMuLuRuService {
                 return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "执行科室为空。");
             }
         }
-
         FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
         fy.setTotalCharge(sum);
-
         try {
             // 在此处 插入费用
             dao.chaRuFeiYong(param, param.getList());
@@ -200,7 +207,6 @@ public class XiangMuLuRuService {
         } catch (Exception e) {
             throw new RuntimeException("项目录入失败,可能导致原因同一时间操作该患者的费用,请确认是否还有其他操作员在操作该患者费用,在重新操作退费。");
         }
-
     }
 
     /**
@@ -221,6 +227,13 @@ public class XiangMuLuRuService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "保存模板成功。");
     }
 
+    /**
+     * 医嘱退费匹配
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @return 返回是否匹配成功
+     */
     public ResultVo<String> yiZhuTuiFeiPiPei(String inpatientNo, Integer admissTimes) {
         // 获取正的费用
         List<ZyDetailCharge> getYiZhuFeiYongZhenShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, ">");
@@ -243,8 +256,16 @@ public class XiangMuLuRuService {
             }
         }
         if (piPei.size() > 0) {
+            // 100 条的更新
             log.info("医嘱退费匹配 ==》 操作人:{} :住院号:{},住院次数:{}", TokenUtil.getTokenUserId(), inpatientNo, admissTimes);
-            dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, piPei);
+            List<ZyDetailCharge> fenDuanPiPei = new ArrayList<>();
+            for (ZyDetailCharge zyDetailCharge : piPei) {
+                fenDuanPiPei.add(zyDetailCharge);
+                if (fenDuanPiPei.size() == 100) {
+                    dao.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, fenDuanPiPei);
+                    fenDuanPiPei.clear();
+                }
+            }
             return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, String.format("医嘱退费匹配成功共匹配%d条", piPei.size()));
         } else {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者没有可以匹配的医嘱退费");