Przeglądaj źródła

扩展结算统计功能

lighter 3 lat temu
rodzic
commit
0203115474

+ 7 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiQueryController.java

@@ -8,6 +8,7 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.InHspPsnInfo;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.SpcChrDiseAcct;
 import thyyxxk.webserver.entity.medicalinsurance.query.*;
+import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.service.medicalinsurance.SiQueryService;
 
 import java.util.List;
@@ -129,4 +130,10 @@ public class SiQueryController {
     public ResultVo<List<SetlStatisticResult>> selectSetlinfoStatistics(@RequestBody @Validated SetlCondition condition) {
         return service.selectSetlinfoStatistics(condition);
     }
+
+    @PostMapping("/selectSetldetailStatistics")
+    public ResultVo<List<SiSetlinfo>> selectSetldetailStatistics(@RequestBody @Validated SetlCondition condition) {
+        return service.selectSetldetailStatistics(condition);
+    }
+
 }

+ 38 - 5
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiQueryDao.java

@@ -275,6 +275,28 @@ public interface SiQueryDao {
                           @Param("mdtrtId") String mdtrtId,
                           @Param("insutype") String insutype);
 
+    @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay, " +
+            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn), " +
+            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
+            "from t_si_setlinfo a where revoked=0 and setl_type=21 and insutype=#{insutype} and setl_time>=#{begntime} " +
+            "and setl_time<=#{endtime} and insuplc_admdvs='439900' ")
+    List<BaseSetlStatistics> selectBaseSetlStatisticsInProvinceLevel(@Param("begntime") String begntime,
+                                                                           @Param("endtime") String endtime,
+                                                                           @Param("insutype") String insutype);
+
+    @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay, " +
+            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn), " +
+            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
+            "from t_si_setlinfo a where revoked=0 and setl_type=21 and insutype=#{insutype} and setl_time>=#{begntime} " +
+            "and setl_time<=#{endtime} and insuplc_admdvs!='439900' and insuplc_admdvs like '4301%' ")
+    List<BaseSetlStatistics> selectBaseSetlStatisticsInChangshaCity(@Param("begntime") String begntime,
+                                                                           @Param("endtime") String endtime,
+                                                                           @Param("insutype") String insutype);
+
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
             "and b.times=a.times and b.ledger_sn=a.ledger_sn), " +
@@ -282,9 +304,9 @@ public interface SiQueryDao {
             "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
             "from t_si_setlinfo a where revoked=0 and setl_type=21 and insutype=#{insutype} and setl_time>=#{begntime} " +
             "and setl_time<=#{endtime} and insuplc_admdvs!='439900' and insuplc_admdvs like '43%' and insuplc_admdvs not like '4301%' ")
-    List<BaseSetlStatistics> selectBaseSetlStatisticsInProvince(@Param("begntime") String begntime,
-                                                                @Param("endtime") String endtime,
-                                                                @Param("insutype") String insutype);
+    List<BaseSetlStatistics> selectBaseSetlStatisticsInProvinceOtherCities(@Param("begntime") String begntime,
+                                                                           @Param("endtime") String endtime,
+                                                                           @Param("insutype") String insutype);
 
     @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay, " +
             "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
@@ -297,10 +319,21 @@ public interface SiQueryDao {
                                                                 @Param("endtime") String endtime,
                                                                 @Param("insutype") String insutype);
 
+    @Select("select pat_no,times,ledger_sn,insuplc_admdvs,medfee_sumamt,insutype,hifmi_pay,hifp_pay,cvlserv_pay, " +
+            "fundPaySumamt=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn), " +
+            "hospPay=(select sum(b.fund_payamt) from t_si_setldetail b where b.pat_no=a.pat_no " +
+            "and b.times=a.times and b.ledger_sn=a.ledger_sn and (b.fund_pay_type='999996' or b.setl_proc_info='999996')) " +
+            "from t_si_setlinfo a where revoked=0 and setl_type=21 and insutype=#{insutype} and setl_time>=#{begntime} " +
+            "and setl_time<=#{endtime} ")
+    List<BaseSetlStatistics> selectBaseSetlStatisticsInAllPlaces(@Param("begntime") String begntime,
+                                                                 @Param("endtime") String endtime,
+                                                                 @Param("insutype") String insutype);
+
     @Select("select code=(select b.name from t_region b where b.code=a.parent_code),a.name from t_region a where code=#{code}")
     PureCodeName selectAdmdvsNameAndParentName(@Param("code") String code);
 
-    @Select("select name from t_si_admdvs where code=#{code}")
-    String selectAdmdvsName(@Param("code") String code);
+    @Select("select name,code='' from t_si_admdvs where code=#{code}")
+    PureCodeName selectAdmdvsName(@Param("code") String code);
 
 }

+ 3 - 2
src/main/java/thyyxxk/webserver/entity/medicalinsurance/query/SetlCondition.java

@@ -11,6 +11,7 @@ public class SetlCondition {
     private String month;
     @NotBlank(message = "请选择险种类型!")
     private String insutype;
-    @NotNull(message = "请选择参保地!")
-    private Integer admdvs;
+    @NotNull(message = "请选择参保地归属!")
+    private Integer admdvsType;
+    private String insuplcAdmdvs;
 }

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/query/SetlStatisticResult.java

@@ -5,6 +5,7 @@ import lombok.Data;
 @Data
 public class SetlStatisticResult {
     private String admdvsName;
+    private String insuplcAdmdvs;
     private Integer psnSumamt;
     private String medfeeSumamt;
     private String baseMedFundpaySumamt;

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setlinfo/SiSetlinfo.java

@@ -273,4 +273,6 @@ public class SiSetlinfo implements Serializable {
 	private String medTypeName;
 	@TableField(exist = false)
 	private String clrOptinsName;
+	@TableField(exist = false)
+	private String insuplcAdmdvsName;
 }

+ 1 - 13
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -315,19 +315,7 @@ public class SiManageService {
             if (!optinsMap.containsKey(item.getClrOptins())) {
                 optinsMap.put(item.getClrOptins(), item.getClrOptinsName());
             }
-            item.setGendName(Gend.get(item.getGend()).getName());
-            Insutype insutype = Insutype.get(item.getInsutype());
-            if (null != insutype) {
-                item.setInsutypeName(insutype.getName());
-            }
-            PsnType psnType = PsnType.get(item.getPsnType());
-            if (null != psnType) {
-                item.setPsnTypeName(psnType.getName());
-            }
-            MedType medType = MedType.get(item.getMedType());
-            if (null != medType) {
-                item.setMedTypeName(medType.getName());
-            }
+            FilterUtil.filterCodeToName(item);
         });
         map.put("list", list);
         for (Map.Entry<String, String> entry : optinsMap.entrySet()) {

+ 59 - 8
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiQueryService.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.service.medicalinsurance;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -10,12 +11,14 @@ import thyyxxk.webserver.constants.sidicts.SiFunction;
 import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.constants.sidicts.*;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
+import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.PureCodeName;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.InHspPsnInfo;
 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.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.medicalinsurance.setllist.*;
 import thyyxxk.webserver.service.wxapi.SendWxInfoService;
 import thyyxxk.webserver.utils.*;
@@ -35,15 +38,17 @@ public class SiQueryService {
     private final ExecService exec;
     private final SiQueryDao dao;
     private final SendWxInfoService wxsrvc;
+    private final SiSetlinfoDao setlinfoDao;
     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, SendWxInfoService wxsrvc) {
+    public SiQueryService(ExecService exec, SiQueryDao dao, SendWxInfoService wxsrvc, SiSetlinfoDao setlinfoDao) {
         this.exec = exec;
         this.dao = dao;
         this.wxsrvc = wxsrvc;
+        this.setlinfoDao = setlinfoDao;
     }
 
     public ResultVo<SiPatInfo> getSiPatInfo(QryPsnBsInfo qryPsnBsInfo) {
@@ -1188,11 +1193,24 @@ public class SiQueryService {
         String begntime = condition.getMonth() + "-01 00:00:00.000";
         String endtime = DateUtil.getMonthEndtime(condition.getMonth());
         List<BaseSetlStatistics> baseStatistics;
-        if (condition.getAdmdvs() == 1) {
-            baseStatistics = dao.selectBaseSetlStatisticsInProvince(begntime, endtime, condition.getInsutype());
-        } else {
-            baseStatistics = dao.selectBaseSetlStatisticsOutProvince(begntime, endtime, condition.getInsutype());
+
+        switch (condition.getAdmdvsType()) {
+            case 1:
+                baseStatistics = dao.selectBaseSetlStatisticsInProvinceLevel(begntime, endtime, condition.getInsutype());
+                break;
+            case 2:
+                baseStatistics = dao.selectBaseSetlStatisticsInChangshaCity(begntime, endtime, condition.getInsutype());
+                break;
+            case 3:
+                baseStatistics = dao.selectBaseSetlStatisticsInProvinceOtherCities(begntime, endtime, condition.getInsutype());
+                break;
+            case 4:
+                baseStatistics = dao.selectBaseSetlStatisticsOutProvince(begntime, endtime, condition.getInsutype());
+                break;
+            default:
+                baseStatistics = dao.selectBaseSetlStatisticsInAllPlaces(begntime, endtime, condition.getInsutype());
         }
+
         if (null == baseStatistics || baseStatistics.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
@@ -1209,10 +1227,9 @@ public class SiQueryService {
             if (null == admdvsName) {
                 PureCodeName region = dao.selectAdmdvsNameAndParentName(key);
                 if (null == region) {
-                    admdvsName = dao.selectAdmdvsName(key);
-                } else {
-                    admdvsName = region.getCode() + region.getName();
+                    region = dao.selectAdmdvsName(key);
                 }
+                admdvsName = region.getCode() + region.getName();
                 regionMap.put(key, admdvsName);
             }
             if (tempMap.containsKey(admdvsName)) {
@@ -1229,6 +1246,7 @@ public class SiQueryService {
             List<BaseSetlStatistics> mapStatistics = entry.getValue();
             SetlStatisticResult resultItem = new SetlStatisticResult();
             resultItem.setAdmdvsName(entry.getKey());
+            resultItem.setInsuplcAdmdvs(entry.getValue().get(0).getInsuplcAdmdvs().substring(0, 4) + "00");
             resultItem.setPsnSumamt(mapStatistics.size());
             String medfeeSumamt = "0";
             String baseMedFundpaySumamt = "0";
@@ -1256,4 +1274,37 @@ public class SiQueryService {
         }
         return ResultVoUtil.success(resultList);
     }
+
+    public ResultVo<List<SiSetlinfo>> selectSetldetailStatistics(SetlCondition condition) {
+        String begntime = condition.getMonth() + "-01 00:00:00.000";
+        String endtime = DateUtil.getMonthEndtime(condition.getMonth());
+        String insuplcAdmdvs = condition.getInsuplcAdmdvs().substring(0, 4) + "%";
+        QueryWrapper<SiSetlinfo> wrapper = new QueryWrapper<>();
+        wrapper.eq("insutype", condition.getInsutype());
+        wrapper.eq("setl_type", ClrType.INPATIENT.getCode());
+        wrapper.eq("revoked", YesOrNo.NO.getCode());
+        wrapper.apply("setl_time>='" + begntime + "'");
+        wrapper.apply("setl_time<='" + endtime + "'");
+        wrapper.apply("insuplc_admdvs like'" + insuplcAdmdvs + "'");
+        List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
+        Map<String, String> regionMap = new HashMap<>();
+        list.forEach(item -> {
+            String admdvsName = regionMap.get(item.getInsuplcAdmdvs());
+            if (null == admdvsName) {
+                PureCodeName region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs());
+                if (null == region) {
+                    region = dao.selectAdmdvsName(item.getInsuplcAdmdvs());
+                    if (null == region) {
+                        region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs().substring(0, 4) + "00");
+                    }
+                }
+                admdvsName = region.getCode() + region.getName();
+                regionMap.put(item.getInsuplcAdmdvs(), admdvsName);
+            }
+            item.setInsuplcAdmdvsName(admdvsName);
+            FilterUtil.filterCodeToName(item);
+        });
+        return ResultVoUtil.success(list);
+    }
+
 }

+ 12 - 11
src/main/java/thyyxxk/webserver/utils/DecimalUtil.java

@@ -40,6 +40,18 @@ public class DecimalUtil {
     }
 
     public static String minusLink(String a, String b, String c, String d) {
+        if (StringUtil.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtil.isBlank(b)) {
+            b = "0";
+        }
+        if (StringUtil.isBlank(c)) {
+            c = "0";
+        }
+        if (StringUtil.isBlank(d)) {
+            d = "0";
+        }
         BigDecimal ad = new BigDecimal(a);
         BigDecimal bd = new BigDecimal(b);
         BigDecimal cd = new BigDecimal(c);
@@ -61,12 +73,6 @@ public class DecimalUtil {
         return ad.divide(bd, scale, RoundingMode.DOWN).toString();
     }
 
-    public static boolean negativeAndPositive(String a, String b) {
-        BigDecimal ad = new BigDecimal(a);
-        BigDecimal bd = new BigDecimal(b);
-        return ad.add(bd).compareTo(new BigDecimal("0")) == 0;
-    }
-
     public static String moneyYuanToFen(BigDecimal fee) {
         BigDecimal hundred = new BigDecimal("100");
         return fee.multiply(hundred).setScale(0, RoundingMode.CEILING).toPlainString();
@@ -80,11 +86,6 @@ public class DecimalUtil {
         return result;
     }
 
-    public static boolean feeDiffsOverOneRmb(String hisFee, String ybFee) {
-        double offset = Double.parseDouble(minus(hisFee, ybFee));
-        return Math.abs(offset) > 1;
-    }
-
     public static int compare(String a, String b) {
         BigDecimal d1 = new BigDecimal(a);
         BigDecimal d2 = new BigDecimal(b);

+ 22 - 0
src/main/java/thyyxxk/webserver/utils/FilterUtil.java

@@ -1,5 +1,11 @@
 package thyyxxk.webserver.utils;
 
+import thyyxxk.webserver.constants.sidicts.Gend;
+import thyyxxk.webserver.constants.sidicts.Insutype;
+import thyyxxk.webserver.constants.sidicts.MedType;
+import thyyxxk.webserver.constants.sidicts.PsnType;
+import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
+
 /**
  * @author dj
  */
@@ -249,4 +255,20 @@ public class FilterUtil {
                 return "未知状态";
         }
     }
+
+    public static void filterCodeToName(SiSetlinfo item) {
+        item.setGendName(Gend.get(item.getGend()).getName());
+        Insutype insutype = Insutype.get(item.getInsutype());
+        if (null != insutype) {
+            item.setInsutypeName(insutype.getName());
+        }
+        PsnType psnType = PsnType.get(item.getPsnType());
+        if (null != psnType) {
+            item.setPsnTypeName(psnType.getName());
+        }
+        MedType medType = MedType.get(item.getMedType());
+        if (null != medType) {
+            item.setMedTypeName(medType.getName());
+        }
+    }
 }