浏览代码

科室刷新缓存和退费优化

lihong 1 年之前
父节点
当前提交
a911305d2a

+ 46 - 0
src/main/java/cn/hnthyy/thmz/Utils/Tools.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.Utils;
 
+import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DatePattern;
@@ -7,9 +8,13 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.formula.functions.T;
 
 import java.math.BigDecimal;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.sql.Struct;
 import java.util.Date;
 import java.util.List;
@@ -17,6 +22,7 @@ import java.util.List;
 /**
  * 按照字节数截取字符串
  */
+@Slf4j
 public class Tools {
     public Tools() {
     }
@@ -153,5 +159,45 @@ public class Tools {
         ++num;
         return str;
     }
+    /**
+     * @description: 发送集群其他的刷新缓存
+     * @author: lihong
+     * @date: 2023/12/27 11:32
+     * @param: config
+     * @param: apiAddress
+     **/
+    public static void sendRefreshCacheService(Config config,String apiAddress){
+        String localhost = null;
+        try {
+            localhost = InetAddress.getLocalHost().getHostAddress();
+        } catch (UnknownHostException e) {
+            e.printStackTrace();
+            return;
+        }
+        if (localhost == null || StringUtils.isBlank(localhost)) {
+            return;
+        }
+        if (config == null || config.getConfigValue() == null || StringUtils.isBlank(config.getConfigValue())) {
+            return;
+        }
+        String[] arr = config.getConfigValue().split(",");
+        if (arr == null || arr.length == 0) {
+            return;
+        }
+        for (int i = 0; i < arr.length; i++) {
+            String ip = arr[i];
+            if (ip == null || StringUtils.isBlank(ip)) {
+                continue;
+            }
+            if (localhost.equals(ip)) {
+                continue;
+            }
+            try {
+                HttpUtil.sendHttpGet(StrUtil.format("http://{}:8089/thmz/{}",ip,apiAddress), "utf-8", 3000);
+            } catch (Exception e) {
+                log.error("["+apiAddress+"]刷新服务集群缓存失败!",e);
+            }
+        }
+    }
 
 }

+ 13 - 0
src/main/java/cn/hnthyy/thmz/controller/zd/UnitCodeController.java

@@ -3,6 +3,7 @@ package cn.hnthyy.thmz.controller.zd;
 import cn.hnthyy.thmz.Utils.ExcelUtil;
 import cn.hnthyy.thmz.Utils.JsonUtil;
 import cn.hnthyy.thmz.Utils.PyWbUtil;
+import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.mz.Employee;
@@ -513,4 +514,16 @@ public class UnitCodeController {
         resultMap.put("data", zdUnitCode);
         return resultMap;
     }
+    @GetMapping("/refreshDeptCache")
+    public R refreshDeptCache(){
+        zdUnitCodeService.refreshDeptCache();
+        return R.ok();
+    }
+
+    @GetMapping("/sendRefreshDeptCache")
+    public R sendRefreshDeptCache(){
+        zdUnitCodeService.sendRefreshDeptCache();
+        return R.ok();
+    }
+
 }

+ 12 - 1
src/main/java/cn/hnthyy/thmz/service/his/zd/ZdUnitCodeService.java

@@ -184,5 +184,16 @@ public interface ZdUnitCodeService {
      **/
     List<ZdUnitCode> queryNightClinic();
 
-
+    /**
+     * @description: 刷新科室缓存
+     * @author: lihong
+     * @date: 2023/12/27 11:17
+     **/
+    void refreshDeptCache();
+    /**
+     * @description: 刷新其他服务器科室缓存
+     * @author: lihong
+     * @date: 2023/12/27 11:17
+     **/
+    void sendRefreshDeptCache();
 }

+ 1 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -6488,11 +6488,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         }
         List<MzDepositFile> result = new ArrayList<>();
         //测试数据
-        PayInfo payInfo = new PayInfo();
-        payInfo.setCode(0);
-        payInfo.setFundPay(new BigDecimal("41.60"));
-        payInfo.setAcctPay(new BigDecimal("10.67"));
-        payInfo.setCardType(2);
+        PayInfo payInfo = tsmzService.calculateCost(mzDepositFile.getOpId(),mzDepositFile.getPatientId(),mzDepositFile.getTimes(),mzDepositFile.getReceiptNo());
         if (payInfo == null) {
             log.info("退费失败,门诊统筹重新结算门诊号:{}就诊次数:{}", mzDepositFile.getPatientId(),mzDepositFile.getTimes());
             throw new BizException("退费失败,门诊统筹费用重新结算失败,错误原因:可能是医保网络问题;因本次需要退费的已经结算已经撤销成功,请找医保科重新手动结算,稍后再试!");

+ 25 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/ZdUnitCodeServiceImpl.java

@@ -4,10 +4,12 @@ import cn.hnthyy.thmz.Utils.Tools;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.zd.ZdMzClass;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
+import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hnthyy.thmz.enums.ClassCodeEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
 import cn.hnthyy.thmz.mapper.his.zd.ZdMzClassMapper;
 import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
+import cn.hnthyy.thmz.mapper.thmz.ConfigMapper;
 import cn.hnthyy.thmz.pageDto.ZdUnitCodePageDto;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.thmz.HaiCiAdapterService;
@@ -16,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -31,6 +34,8 @@ public class ZdUnitCodeServiceImpl implements ZdUnitCodeService {
     private ZdMzClassMapper zdMzClassMapper;
     @Autowired
     private HaiCiAdapterService haiCiAdapterService;
+    @Resource
+    private ConfigMapper configMapper ;
     //部门缓存数据集
     private Map<String, ZdUnitCode> map = new HashMap<>();
 
@@ -297,5 +302,25 @@ public class ZdUnitCodeServiceImpl implements ZdUnitCodeService {
         return zdUnitCodeMapper.selectNightClinic();
     }
 
+    /**
+     * @description: 刷新科室缓存
+     * @author: lihong
+     * @date: 2023/12/27 11:17
+     **/
+    @Override
+    public void refreshDeptCache() {
+        initMap(null,YesNoEnum.YES);
+        Config config = configMapper.selectConfigByKey("thmz_group");
+        Tools.sendRefreshCacheService(config,"sendRefreshDeptCache");
+    }
 
+    /**
+     * @description: 刷新其他服务器科室缓存
+     * @author: lihong
+     * @date: 2023/12/27 11:17
+     **/
+    @Override
+    public void sendRefreshDeptCache() {
+        initMap(null,YesNoEnum.YES);
+    }
 }

+ 3 - 3
src/main/java/cn/hnthyy/thmz/service/impl/thmz/TsmzServiceImpl.java

@@ -406,11 +406,11 @@ public class TsmzServiceImpl implements TsmzService {
         try {
             String result = HttpUtil.sendHttpPost(realUrl, jsonObj.toString(), 6000);
             if (StringUtils.isBlank(result)) {
-                throw new BizException("试算是否可以修改处方失败,请重试");
+                throw new BizException("试算是否可以修改处方失败");
             }
             JSONObject resultJSONO = new JSONObject(result);
             if (resultJSONO == null) {
-                throw new BizException("试算是否可以修改处方失败,请重试");
+                throw new BizException("试算是否可以修改处方失败");
             }
             if(Convert.toInt(resultJSONO.get("code")) == HttpStatus.HTTP_OK ){
                return true;
@@ -420,7 +420,7 @@ public class TsmzServiceImpl implements TsmzService {
             }
         }catch (Exception e){
             log.error("[queryModifyPermission]异常信息:",e);
-            throw new BizException("试算是否可以修改处方失败,请重试");
+            throw new BizException("试算是否可以修改处方失败");
         }
     }
 }

+ 17 - 0
src/main/resources/static/js/mz/unit_code.js

@@ -710,4 +710,21 @@ function mzFlagChange() {
         $("#ghChargeFlagPlusDiv").removeClass("in").addClass("hide");
         $("#unitNumPlusDiv").removeClass("in").addClass("hide");
     }
+}
+
+/**
+ * 刷新科室缓存
+ */
+function reDeptCache() {
+    getAjaxRequst("/thmz/refreshDeptCache",{},true,function (res) {
+        if (res.code == '401' || res.code == 401) {
+            window.location.href = '/thmz/login/view'
+            return;
+        }
+        if(res.code == 0){
+            successMesageSimaple("成功")
+        }else {
+            errorMesage(res)
+        }
+    })
 }

+ 7 - 0
src/main/resources/templates/mz/unit_code.html

@@ -53,11 +53,18 @@
                                     title="查询"><i class="fa fa-search"></i>
                             </button>
                         </div>
+                        <div class="col-sm-4" style="text-align:left;width: 5%;">
+                            <button type="button" style="margin-left:5px" id="btn_reCache" class="btn btn-primary" onclick="reDeptCache()"
+                                    title="刷新科室缓存"><i class="fa fa-rotate-right"></i>
+                            </button>
+                        </div>
+
                         <div class="col-sm-4" style="text-align:left;width: 5%;">
                             <button type="button" style="margin-left:5px" id="export_excel" class="btn btn-primary">
                                 导出EXCEL
                             </button>
                         </div>
+
                     </div>
                 </form>
             </div>