Bladeren bron

增加撤销退药

WANGJIALIANG 3 jaren geleden
bovenliggende
commit
fe51e51612

+ 40 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -259,6 +259,46 @@ public class MzPharmacyController {
         }
     }
 
+    /**
+     * 撤销退药处理
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/cancelRefundMedicineProcessing", method = {RequestMethod.GET})
+    public Map<String, Object> cancelRefundMedicineProcessing(@RequestParam("realNo") Integer realNo, @RequestParam("groupNo") String groupNo
+            , @RequestParam("orderNo") Integer orderNo, HttpServletRequest httpServletRequest) throws MzException {
+        User tokenUser = TokenUtil.getUser(httpServletRequest);
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (StringUtils.isBlank(groupNo)) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "撤销退药处理失败,参数为空");
+                return resultMap;
+            }
+            if (mzPharmacyService.queryRefundMoneyCount(-realNo, -1, groupNo, orderNo) > 0) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "该处方已存在退费记录");
+                return resultMap;
+            }
+            if(mzPharmacyService.cancelRefundMedicineProcessing(realNo, groupNo,orderNo) == 0){
+                resultMap.put("code", -1);
+                resultMap.put("message", "退回申请退药记录状态异常");
+            }else{
+                log.info("撤销退药记录状态成功,操作人:{},流水号:{},处方号:{}", tokenUser.getUserIdCode(), realNo, orderNo);
+                resultMap.put("code", 0);
+                resultMap.put("message", "撤销退药记录状态成功");
+            }
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("撤销退药处理失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "撤销退药处理失败");
+            return resultMap;
+        }
+    }
+
     /**
      * 发药处理查询发药处方信息
      *

+ 1 - 2
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpMzFytj.java

@@ -1,6 +1,5 @@
 package cn.hnthyy.thmz.entity.his.yp;
 
-import cn.hnthyy.thmz.enums.ConfirmFlagEnum;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -67,7 +66,7 @@ public class YpMzFytj implements Serializable {
     //1:医生处方
     private String doctorName;
     /**
-     * 标识:1确认发药 医技确认 2.打印药品清单 3.配药确认 5.  {@link ConfirmFlagEnum}
+     * 标识:1已发药 2.待退药 3.已退药
      */
     private Integer confirmFlag;
     //草药副数

+ 31 - 4
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzPharmacyMapper.java

@@ -4,10 +4,7 @@ import cn.hnthyy.thmz.entity.his.yp.YpMzFytj;
 import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
 import cn.hnthyy.thmz.entity.thmz.RadSendRecord;
 import cn.hnthyy.thmz.vo.*;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 
 import java.util.Date;
 import java.util.List;
@@ -1012,4 +1009,34 @@ public interface MzPharmacyMapper {
      */
     @Select("select top 1 confirm_flag from mz_charge_detail where real_no=${realNo} and group_no=#{groupNo} and order_no=#{orderNo}")
     int selectConfirmFlagByRealNo(@Param("realNo") Integer realNo, @Param("groupNo") String groupNo, @Param("orderNo") Integer orderNo);
+
+    /**
+     * 查询处方是否含有退费记录
+     *
+     * @param realNo
+     * @return
+     */
+    @Select("select count(1) from mz_charge_detail where real_no=${realNo} and receipt_no=#{receiptNo} and group_no=#{groupNo} and order_no=#{orderNo} and pay_mark=1")
+    int selectRefundMoneyCount(@Param("realNo") Integer realNo, @Param("receiptNo") Integer receiptNo, @Param("groupNo") String groupNo, @Param("orderNo") Integer orderNo);
+
+    /**
+     * 更新申请退药的记录状态
+     * @param confirmFlag
+     * @param realNo
+     * @param groupNo
+     * @param orderNo
+     * @return
+     */
+    @Update("update yp_mz_fytj set confirm_flag=#{confirmFlag} where real_no=${realNo}  and receipt_no=-1 and order_no=#{orderNo} and group_no=#{groupNo}")
+    int updateReFytjConfirmFlag(@Param("confirmFlag") Integer confirmFlag, @Param("realNo") Integer realNo, @Param("groupNo") String groupNo, @Param("orderNo") Integer orderNo);
+
+    /**
+     * 查询已退药
+     * @param realNo
+     * @param groupNo
+     * @param orderNo
+     * @return
+     */
+    @Select("select charge_item_code,serial,quantity,unit_price from yp_mz_fytj where real_no=${realNo} and receipt_no=-1 and order_no=#{orderNo} and group_no=#{groupNo} and quantity>0")
+    List<YpMzFytj> selectRefundDrug(@Param("realNo") Integer realNo, @Param("groupNo") String groupNo, @Param("orderNo") Integer orderNo);
 }

+ 12 - 4
src/main/java/cn/hnthyy/thmz/service/his/mz/MzPharmacyService.java

@@ -63,6 +63,15 @@ public interface MzPharmacyService {
      */
     Map<String, Object> refundMedicineProcessing(List<MzRefundMedicineVo> mzRefundMedicineVos,String userIdCode);
 
+    /**
+     * 撤销退药处理
+     * @param realNo
+     * @param groupNo
+     * @param orderNo
+     * @return
+     */
+    int cancelRefundMedicineProcessing(Integer realNo, String groupNo, Integer orderNo) throws MzException;
+
     /**
      * 发药处理查询未发药处方
      * @param chargeFeeParamsVo
@@ -186,12 +195,11 @@ public interface MzPharmacyService {
     int getIncludeWfyPrescription(String patientId);
 
     /**
-     * 查询处方状态
+     * 查询处方是否含有退费记录
      *
      * @param realNo
-     * @param groupNo
-     * @param orderNo
      * @return
      */
-    int queryConfirmFlagByRealNo(Integer realNo, String groupNo, Integer orderNo);
+    int queryRefundMoneyCount(Integer realNo, Integer receiptNo, String groupNo, Integer orderNo);
+
 }

+ 27 - 6
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzPharmacyServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.*;
 
@@ -133,6 +134,26 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
         return resultMap;
     }
 
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
+    public int cancelRefundMedicineProcessing(Integer realNo, String groupNo, Integer orderNo) throws MzException {
+        List<YpMzFytj> ypMzFytjs = mzPharmacyMapper.selectRefundDrug(realNo, groupNo, orderNo);
+        if (ypMzFytjs.size() > 0) {
+            for (int i = 0; i < ypMzFytjs.size(); i++) {
+                YpMzFytj ypMzFytj = ypMzFytjs.get(i);
+                int j = ypBaseYfMapper.updateStockAmount(ypMzFytj.getChargeItemCode(), ypMzFytj.getSerial(), groupNo, ypMzFytj.getQuantity(),
+                        BigDecimal.valueOf(ypMzFytj.getQuantity()).multiply(ypMzFytj.getUnitPrice()));
+                if (j != 1) {
+                    log.error("撤销退药失败,退回库存异常,错误信息{}", ypMzFytj.getChargeItemCode()+","+ypMzFytj.getSerial()+","+groupNo);
+                    throw new MzException("退回库存异常");
+                }
+            }
+        } else {
+            throw new MzException("未查询到已退药记录");
+        }
+        return mzPharmacyMapper.updateReFytjConfirmFlag(2, realNo, groupNo, orderNo);
+    }
+
     @Override
     public List<ChargeDetailInfoVo> getFyclWfyPrescriptionPage(ChargeFeeParamsVo chargeFeeParamsVo) {
         return mzPharmacyMapper.selectFyclWfyPrescriptionPage(chargeFeeParamsVo);
@@ -172,9 +193,9 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Map<String, Object> sendMedicineProcessing(MzChargeDetail mzChargeDetail, User user) throws MzException {
         Map<String, Object> resultMap = new HashMap<>();
-        int i = mzPharmacyMapper.selectConfirmFlagByRealNo(mzChargeDetail.getRealNo(),mzChargeDetail.getGroupNo(),mzChargeDetail.getOrderNo());
-        if(i != 0){
-            throw new MzException("发药失败,流水号"+mzChargeDetail.getRealNo()+"处方非待发药状态(已发药、退药或已退费)");
+        int i = mzPharmacyMapper.selectConfirmFlagByRealNo(mzChargeDetail.getRealNo(), mzChargeDetail.getGroupNo(), mzChargeDetail.getOrderNo());
+        if (i != 0) {
+            throw new MzException("发药失败,流水号" + mzChargeDetail.getRealNo() + "处方非待发药状态(已发药、退药或已退费)");
         }
         Date date = new Date();
         List<MzSendMedicineVo> cfxxList = mzPharmacyMapper.selectFyclPrescriptionDetail(mzChargeDetail);
@@ -337,7 +358,7 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
         String res = "";
         try {
             String encode = URLEncoder.encode(text, "UTF-8");
-            res = HttpUtil.sendHttpGet(audioServiceUrl + "?text=" + encode, "utf-8",3000);
+            res = HttpUtil.sendHttpGet(audioServiceUrl + "?text=" + encode, "utf-8", 3000);
         } catch (Exception e) {
             e.printStackTrace();
             log.info("语音生成失败,内容:{}", text);
@@ -351,8 +372,8 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
     }
 
     @Override
-    public int queryConfirmFlagByRealNo(Integer realNo, String groupNo, Integer orderNo) {
-        return mzPharmacyMapper.selectConfirmFlagByRealNo(realNo, groupNo, orderNo);
+    public int queryRefundMoneyCount(Integer realNo, Integer receiptNo, String groupNo, Integer orderNo) {
+        return mzPharmacyMapper.selectRefundMoneyCount(realNo, receiptNo, groupNo, orderNo);
     }
 
     @Override

+ 34 - 0
src/main/resources/static/js/mz/west_pharmacy_send.js

@@ -69,6 +69,9 @@ $(function () {
     $("#btn_ty").click(function (t) {
         saveRefundMedicine();
     });
+    $("#btn_cancel_ty").click(function (t) {
+        saveCancelRefundMedicine();
+    });
     $("#sendDispose").click(function (t) {
         let orderNo = $("#orderNoLabel").val();
         let receiptNo = $("#receiptNoLabel").val();
@@ -197,6 +200,7 @@ function sendRefundButtonChange(object, realIndex) {
         $("#tb_table_right_ty").css("display", "none");
         $("#return_total_amount").css("display", "none");
         $("#btn_ty").addClass("hidden");
+        $("#btn_cancel_ty").addClass("hidden");
         $("#btn_radiology_send").removeClass("hidden");
         $("#btn_batch_send").removeClass("hidden");
     } else {
@@ -206,6 +210,7 @@ function sendRefundButtonChange(object, realIndex) {
         $("#confirmFlagSearch").selectpicker('refresh');
         $("#tb_table_right_ty").css("display", "");
         $("#btn_ty").removeClass("hidden");
+        $("#btn_cancel_ty").removeClass("hidden");
         $("#btn_radiology_send").addClass("hidden");
         $("#btn_batch_send").addClass("hidden");
     }
@@ -435,6 +440,7 @@ function initTbTable(pageIndex) {
             }
         },
         responseHandler: function (res) {
+            console.log(res);
             if (res == '401' || res == 401) {
                 window.location.href = '/thmz/login/view'
                 return;
@@ -1498,6 +1504,34 @@ function saveRefundMedicine() {
     });
 }
 
+/**
+ * 撤销退药处理
+ */
+function saveCancelRefundMedicine() {
+    var row = $("#tb_table").bootstrapTable('getSelections');
+    if (row.length != 1) {
+        return errorMesageSimaple('请选择一条处方数据');
+    }
+    if (row[0].confirmFlag != 3) {
+        return errorMesageSimaple('请选择已退药记录');
+    }
+    if (!confirm("确定要撤销当前处方的退药吗?")) {
+        return;
+    }
+    request({
+        url: '/cancelRefundMedicineProcessing',
+        method: 'GET',
+        data: {
+            realNo: row[0].realNo,
+            groupNo: groupNo,
+            orderNo: row[0].orderNo
+        }
+    }).then((res) => {
+        successMesage(res);
+        initTbTable();
+    });
+}
+
 /**
  * 叫号
  * @param patientId

+ 5 - 1
src/main/resources/templates/mz/west_pharmacy_send.html

@@ -108,7 +108,11 @@
                         </button>
                         <button type="button" id="btn_ty"
                                 class="btn btn-primary hidden"
-                                title="退药完成"><i class="fa fa-check-square-o"></i>
+                                title="退药处理"><i class="fa fa-check-square-o">&nbsp;退药处理</i>
+                        </button>
+                        <button type="button" id="btn_cancel_ty"
+                                class="btn btn-primary hidden"
+                                title="撤销退药"><i class="fa fa-reply">&nbsp;撤销退药</i>
                         </button>
                     </div>
                 </form>