Procházet zdrojové kódy

重新计算基金

yeguodong před 8 hodinami
rodič
revize
8a60fe3f18

+ 12 - 0
src/main/java/thyyxxk/webserver/constants/sidicts/FundPayType.java

@@ -83,6 +83,18 @@ public enum FundPayType {
         return null;
     }
 
+    public static String getCode(String name) {
+        if (StringUtil.isBlank(name)) {
+            return null;
+        }
+        for (FundPayType fundPayType : FundPayType.values()) {
+            if (name.trim().equals(fundPayType.getName())) {
+                return fundPayType.getCode();
+            }
+        }
+        return null;
+    }
+
     public String getCode() {
         return code;
     }

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/reconciliation/ReconciliationController.java

@@ -256,4 +256,9 @@ public class ReconciliationController {
     public void importYbCode() throws Exception {
         service.importYbCode();
     }
+
+    @GetMapping("/updateFund")
+    public void updateFund(@RequestParam String setlMon) {
+        service.updateFund(setlMon);
+    }
 }

+ 14 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiSetlinfoDao.java

@@ -232,4 +232,18 @@ public interface SiSetlinfoDao extends BaseMapper<SiSetlinfo> {
             "where setl_id=#{setlId} " +
             "</script>")
     SiSetlinfo selectSetlinfoBySetlId(String setlId);
+
+    @Select("select b.* from t_si_setldetail b left join t_si_setlinfo a on a.setl_id=b.setl_id " +
+            "where a.insutype = #{insutype} AND a.med_type = #{medType} and b.fund_pay_type=#{fundPayType} and a.setl_time >= #{startDate} and a.setl_time <= #{endDate} " +
+            "AND a.insuplc_admdvs IN ('321323', '321324', '321322', '321311', '321302', '321399', '321307')")
+    List<SiSetldetail> selectSiSetldetailByFund(String insutype, String medType, String fundPayType, String startDate, String endDate);
+
+    @Select("select b.* from t_si_setldetail_old b left join t_si_setlinfo_old a on a.setl_id=b.setl_id " +
+            "where a.insutype = #{insutype} AND a.med_type = #{medType} and b.fund_pay_type=#{fundPayType} and a.setl_time >= #{startDate} and a.setl_time <= #{endDate} " +
+            "AND a.insuplc_admdvs IN ('321323', '321324', '321322', '321311', '321302', '321399', '321307')")
+    List<SiSetldetail> selectSiSetldetailOldByFund(String insutype, String medType, String fundPayType, String startDate, String endDate);
+
+    @Update("update ${tableName} set fund_payamt=#{newFundPayamt} " +
+            "where pat_no=#{patNo} and fund_pay_type=#{fundPayType} and fund_payamt=#{fundPayamt} and setl_id=#{setlId}")
+    void updateSiSetldetail(String tableName, String patNo, String fundPayType, BigDecimal fundPayamt, String setlId, BigDecimal newFundPayamt);
 }

+ 66 - 1
src/main/java/thyyxxk/webserver/service/reconciliation/ReconciliationService.java

@@ -488,6 +488,10 @@ public class ReconciliationService {
      * @return
      */
     public ResultVo<JSONObject> queryReconciliation(String setlMon, String upldBtch) {
+        return SiUtil.makeReturnWithoutOutputOfElseInfo(getQueryReconciliation(setlMon, upldBtch));
+    }
+
+    private JSONObject getQueryReconciliation(String setlMon, String upldBtch) {
         JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_MONTH_DZ_3267);
         JSONObject inputInput = input.getJSONObject("input");
         inputInput.put("fixmedins_code", cfg.getHospId());
@@ -499,7 +503,7 @@ public class ReconciliationService {
         if(result.getJSONObject("output") != null) {
             result.put("errorList", processMedicalData(result.getJSONObject("output").getString("memo"), setlMon, upldBtch));
         }
-        return SiUtil.makeReturnWithoutOutputOfElseInfo(result);
+        return result;
     }
 
     /**
@@ -930,8 +934,11 @@ public class ReconciliationService {
                             JSONObject obj = (JSONObject) d;
                             if(obj.getString("solidify_id").equals(map.get("solid"))) {
                                 map.put("fund_name", obj.getString("fund_name"));
+                                map.put("fund_code", FundPayType.getCode(obj.getString("fund_name")));
                                 map.put("insutype", Insutype.getName(obj.getString("insutype")));
+                                map.put("insutype_code", obj.getString("insutype"));
                                 map.put("med_type", MedType.getName(obj.getString("med_type")));
+                                map.put("med_type_code", obj.getString("med_type"));
                                 map.put("medfee_sumamt", obj.get("medfee_sumamt"));
                                 map.put("inscp_amt", obj.get("inscp_amt"));
                                 map.put("fund_pay_sumamt", obj.get("fund_pay_sumamt"));
@@ -1448,4 +1455,62 @@ public class ReconciliationService {
 
         }
     }
+
+    public void updateFund(String setlMon) {
+        JSONObject result = getQueryReconciliation(setlMon, "0");
+        JSONArray errorList = result.getJSONArray("errorList");
+        for (int i = 0; i < errorList.size(); i++) {
+            JSONObject error = errorList.getJSONObject(i);
+            String fullData = error.getString("fullData");
+            BigDecimal fundAmt = error.getBigDecimal("fund_amt");
+            if(StringUtils.isNotBlank(fullData) && fullData.contains("基金)与医保中心数据不一致,中心金额为")){
+                String[] split1 = fullData.split("中心金额为:");
+                if(split1.length == 2){
+                    String[] split2 = split1[1].split(";");
+                    if(split2.length > 0){
+                        BigDecimal total = new BigDecimal(split2[0]);
+                        if(total.compareTo(fundAmt) >= 0){
+                            BigDecimal subtract = total.subtract(fundAmt);
+                            Map<String, String> currentBeginAndEndTime = DateUtil.getCurrentBeginAndEndTime(setlMon);
+                            List<SiSetldetail> siSetldetails = siSetlinfoDao.selectSiSetldetailOldByFund(error.getString("insutype_code"),
+                                    error.getString("med_type_code"), error.getString("fund_code"),
+                                    currentBeginAndEndTime.get("start"), currentBeginAndEndTime.get("end"));
+                            boolean isOld = true;
+                            if(siSetldetails == null || siSetldetails.isEmpty()){
+                                siSetldetails = siSetlinfoDao.selectSiSetldetailByFund(error.getString("insutype_code"),
+                                        error.getString("med_type_code"), error.getString("fund_code"),
+                                        currentBeginAndEndTime.get("start"), currentBeginAndEndTime.get("end"));
+                                isOld = false;
+                            }
+                            if(siSetldetails != null && siSetldetails.size() > 0){
+                                SiSetldetail siSetldetail = siSetldetails.get(0);
+                                BigDecimal newFundPayamt = siSetldetail.getFundPayamt().add(subtract);
+                                String tableName = isOld ? "t_si_setldetail_old" : "t_si_setldetail";
+                                siSetlinfoDao.updateSiSetldetail(tableName, siSetldetail.getPatNo(),
+                                        siSetldetail.getFundPayType(), siSetldetail.getFundPayamt(), siSetldetail.getSetlId(), newFundPayamt);
+
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        String fullData = "固化ID:(068b5998-39aa-4a6b-a2da-7939a4de7ace)中(城乡居民基本医疗保险基金)与医保中心数据不一致,中心金额为:83464.98;";
+
+        if(StringUtils.isNotBlank(fullData) && fullData.contains("基金)与医保中心数据不一致,中心金额为")){
+            String[] split1 = fullData.split("中心金额为:");
+            if(split1.length == 2){
+                String[] split2 = split1[1].split(";");
+                if(split2.length > 0){
+                    BigDecimal money = new BigDecimal(split2[0]);
+                    System.out.println(money);
+                }
+            }
+
+        }
+    }
 }