lighter преди 3 години
родител
ревизия
0317f9aa8a

+ 79 - 0
src/main/java/thyyxxk/webserver/constants/sidicts/PolItemCode.java

@@ -0,0 +1,79 @@
+package thyyxxk.webserver.constants.sidicts;
+
+import thyyxxk.webserver.utils.StringUtil;
+
+/**
+ * 政策项
+ * */
+public enum PolItemCode {
+    
+    QZF("101", "全自费"),
+
+    YLXZF("102", "乙类先自付"),
+
+    CXEZF("103", "超限额自付"),
+
+    CJD("BS01", "冲减段"),
+
+    TCYD("C001", "统筹一段"),
+
+    TCED("C002", "统筹二段"),
+
+    BCYFQFBZ("S001", "本次应付起付标准"),
+
+    GWYBCDYD("GB01", "公务员补充第一段"),
+
+    GWYBCDED("GB02", "公务员补充第二段"),
+
+    GWYBCDSD("GB03", "公务员补充第三段"),
+
+    BCDBQFBZ("PS01", "补充大病起付标准"),
+
+    BCDBDYD("PL01", "补充大病第一段"),
+
+    BCDBDED("PL02", "补充大病第二段"),
+
+    BCDBDSD("PL03", "补充大病第三段"),
+
+    BCDBDSID("PL04", "补充大病第四段"),
+
+    EWBZDYD("AB01", "额外补助第一段"),
+
+    EWBZDED("AB02", "额外补助第二段"),
+
+    YLBZDYD("YB01", "医疗补助第一段"),
+
+    YLBZDED("YB02", "医疗补助第二段"),
+
+    CBFY("E000", "超标费用"),
+
+    JBYLCFDD("EC01", "基本医疗超封顶段");
+
+    private final String code;
+    private final String name;
+
+    PolItemCode(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static PolItemCode get(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        for (PolItemCode payLoc : PolItemCode.values()) {
+            if (code.trim().equals(payLoc.getCode())) {
+                return payLoc;
+            }
+        }
+        return null;
+    }
+}

+ 7 - 43
src/main/java/thyyxxk/webserver/controller/wxapi/SendWxInfoController.java

@@ -2,61 +2,29 @@ package thyyxxk.webserver.controller.wxapi;
 
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.client.RestTemplate;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.WeComTokens;
+import thyyxxk.webserver.service.wxapi.SendWxInfoService;
 import thyyxxk.webserver.utils.TokenUtil;
 
 @Slf4j
 @RestController
 @RequestMapping("/sendWxInfo")
 public class SendWxInfoController {
-    private static final String SEND_MSG_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN";
-    private static volatile boolean OVER_LIMIT = false;
-    private static final int AGENT_ID = 1000041;
-    private static final int OVER_LIMIT_CODE = 45009;
-    private static final int SAFE_MODE = 0;
-    private static final String OVER_LIMIT_MESSAGE = "企业微信消息推送接口调用超过限制,今日无法再做推送!";
+    private final SendWxInfoService service;
 
-    private static final JSONObject OVER_LIMIT_ALERT;
-
-    static {
-        OVER_LIMIT_ALERT = new JSONObject();
-        OVER_LIMIT_ALERT.put("errcode", OVER_LIMIT_CODE);
-        OVER_LIMIT_ALERT.put("errmsg", OVER_LIMIT_MESSAGE);
+    @Autowired
+    public SendWxInfoController(SendWxInfoService service) {
+        this.service = service;
     }
 
     @PassToken
     @GetMapping("/send")
     public JSONObject sendCorpWxMsg(@RequestParam("touser") String touser,
                                     @RequestParam("content") String content) {
-        if (OVER_LIMIT) {
-            log.info(OVER_LIMIT_MESSAGE);
-            return OVER_LIMIT_ALERT;
-        }
-        String requestUrl= SEND_MSG_URL.replace("ACCESS_TOKEN", TokenUtil.getWeComSendMsgToken());
-        JSONObject msgObj = new JSONObject();
-        msgObj.put("content", content);
-        JSONObject param = new JSONObject();
-        param.put("agentid", AGENT_ID);
-        param.put("touser", touser.replaceAll(",", "|"));
-        param.put("toparty", "");
-        param.put("totag", "");
-        param.put("msgtype", "text");
-        param.put("text", msgObj);
-        param.put("safe", SAFE_MODE);
-        log.info("推送企业信息消息 >>> {}", param);
-        RestTemplate restTemplate = new RestTemplate();
-        String response = restTemplate.postForObject(requestUrl, param, String.class);
-        JSONObject result = JSONObject.parseObject(response);
-        log.info("推送企业信息消息结果 >>> {}", result);
-        Integer errcode = result.getInteger("errcode");
-        if (null != errcode && errcode == OVER_LIMIT_CODE) {
-            OVER_LIMIT = true;
-        }
-        return result;
+        return service.sendCorpWxMsg(touser, content);
     }
 
     @PassToken
@@ -68,8 +36,4 @@ public class SendWxInfoController {
         return "success";
     }
 
-    @Scheduled(cron = "0 0 0 * * ?")
-    public void resetOverLimitFlag() {
-        OVER_LIMIT = false;
-    }
 }

+ 28 - 15
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiQueryService.java

@@ -17,6 +17,7 @@ import thyyxxk.webserver.entity.medicalinsurance.outpatient.SpcChrDiseAcct;
 import thyyxxk.webserver.entity.medicalinsurance.query.*;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
 import thyyxxk.webserver.entity.medicalinsurance.setllist.*;
+import thyyxxk.webserver.service.wxapi.SendWxInfoService;
 import thyyxxk.webserver.utils.*;
 
 import java.math.BigDecimal;
@@ -33,14 +34,16 @@ import java.util.*;
 public class SiQueryService {
     private final ExecService exec;
     private final SiQueryDao dao;
+    private final SendWxInfoService wxsrvc;
     private static final String RESULT_CODE = "infcode";
     private static final String ERROR_MESSAGE = "err_msg";
     private static final String OUTPUT = "output";
 
     @Autowired
-    public SiQueryService(ExecService exec, SiQueryDao dao) {
+    public SiQueryService(ExecService exec, SiQueryDao dao, SendWxInfoService wxsrvc) {
         this.exec = exec;
         this.dao = dao;
+        this.wxsrvc = wxsrvc;
     }
 
     public ResultVo<SiPatInfo> getSiPatInfo(QryPsnBsInfo qryPsnBsInfo) {
@@ -877,56 +880,66 @@ public class SiQueryService {
             BigDecimal polItemPaySum = BigDecimal.valueOf(itm.getDouble("polItemPaySum"));
             selfPaySum = selfPaySum.add(selfPayAmt);
             fundPaySum = fundPaySum.add(fundPayAmt);
-            switch (itm.getString("polItemName")) {
-                case "全自费":
+
+            if (itm.getString("polItemName").trim().equals("大额一段")) {
+                lst.setBigAmtFrstLvPsnAmt(selfPayAmt);
+                lst.setBigAmtFrstLvPsnProp(selfPayProp);
+                lst.setBigAmtFrstLvFundAmt(fundPayAmt);
+                lst.setBigAmtFrstLvFundProp(fundPayProp);
+                lst.setBigAmtFrstLvSum(polItemPaySum);
+            }
+
+            PolItemCode polItemCode = PolItemCode.get(itm.getString("polItemCode"));
+            if (null == polItemCode) {
+                String message = String.format("找到了字典缺失的政策项:%s", itm);
+                log.info(message);
+                wxsrvc.sendCorpWxMsg("2801", message);
+                continue;
+            }
+
+            switch (polItemCode) {
+                case QZF:
                     lst.setSelfPayPsnAmt(selfPayAmt);
                     lst.setSelfPayPsnProp(selfPayProp);
                     lst.setSelfPayFundAmt(fundPayAmt);
                     lst.setSelfPayFundProp(fundPayProp);
                     lst.setSelfPaySum(polItemPaySum);
                     break;
-                case "乙类先自付":
+                case YLXZF:
                     lst.setScndPrePayPsnAmt(selfPayAmt);
                     lst.setScndPrePayPsnProp(selfPayProp);
                     lst.setScndPrePayFundAmt(fundPayAmt);
                     lst.setScndPrePayFundProp(fundPayProp);
                     lst.setScndPrePaySum(polItemPaySum);
                     break;
-                case "超限额自付":
+                case CXEZF:
                     lst.setOvrlmtSelfPayPsnAmt(selfPayAmt);
                     lst.setOvrlmtSelfPayPsnProp(selfPayProp);
                     lst.setOvrlmtSelfPayFundAmt(fundPayAmt);
                     lst.setOvrlmtSelfPayFundProp(fundPayProp);
                     lst.setOvrlmtSelfPaySum(polItemPaySum);
                     break;
-                case "本次应付起付标准":
+                case BCYFQFBZ:
                     lst.setBegnlinePsnAmt(selfPayAmt);
                     lst.setBegnlinePsnProp(selfPayProp);
                     lst.setBegnlineFundAmt(fundPayAmt);
                     lst.setBegnlineFundProp(fundPayProp);
                     lst.setBegnlineSum(polItemPaySum);
                     break;
-                case "统筹一段":
+                case TCYD:
                     lst.setFundFrstLvPsnAmt(selfPayAmt);
                     lst.setFundFrstLvPsnProp(selfPayProp);
                     lst.setFundFrstLvFundAmt(fundPayAmt);
                     lst.setFundFrstLvFundProp(fundPayProp);
                     lst.setFundFrstLvSum(polItemPaySum);
                     break;
-                case "统筹二段":
+                case TCED:
                     lst.setFundScndLvPsnAmt(selfPayAmt);
                     lst.setFundScndLvPsnProp(selfPayProp);
                     lst.setFundScndLvFundAmt(fundPayAmt);
                     lst.setFundScndLvFundProp(fundPayProp);
                     lst.setFundScndLvSum(polItemPaySum);
                     break;
-                case "大额一段":
-                    lst.setBigAmtFrstLvPsnAmt(selfPayAmt);
-                    lst.setBigAmtFrstLvPsnProp(selfPayProp);
-                    lst.setBigAmtFrstLvFundAmt(fundPayAmt);
-                    lst.setBigAmtFrstLvFundProp(fundPayProp);
-                    lst.setBigAmtFrstLvSum(polItemPaySum);
-                    break;
             }
         }
         lst.setAllPsnAmt(selfPaySum);

+ 36 - 0
src/main/java/thyyxxk/webserver/service/wxapi/SendWxInfoService.java

@@ -0,0 +1,36 @@
+package thyyxxk.webserver.service.wxapi;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.utils.TokenUtil;
+
+@Service
+@Slf4j
+public class SendWxInfoService {
+
+    private static final String SEND_MSG_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN";
+    private static final int AGENT_ID = 1000041;
+    private static final int SAFE_MODE = 0;
+
+    public JSONObject sendCorpWxMsg(String touser, String content) {
+        String requestUrl= SEND_MSG_URL.replace("ACCESS_TOKEN", TokenUtil.getWeComSendMsgToken());
+        JSONObject msgObj = new JSONObject();
+        msgObj.put("content", content);
+        JSONObject param = new JSONObject();
+        param.put("agentid", AGENT_ID);
+        param.put("touser", touser.replaceAll(",", "|"));
+        param.put("toparty", "");
+        param.put("totag", "");
+        param.put("msgtype", "text");
+        param.put("text", msgObj);
+        param.put("safe", SAFE_MODE);
+        log.info("推送企业信息消息 >>> {}", param);
+        RestTemplate restTemplate = new RestTemplate();
+        String response = restTemplate.postForObject(requestUrl, param, String.class);
+        JSONObject result = JSONObject.parseObject(response);
+        log.info("推送企业信息消息结果 >>> {}", result);
+        return result;
+    }
+}