Prechádzať zdrojové kódy

Merge branch 'master' of https://gitlab.taihe.com/lighter/web-server

xiaochan 3 rokov pred
rodič
commit
babb1f2046

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

@@ -31,6 +31,8 @@ public enum FundPayType {
 
     HELP("610100", "医疗救助基金"),
 
+    HOSP_PAY("999996", "医院垫付"),
+
     OTHERS("999997", "其他基金");
 
     private final String code;

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

@@ -27,6 +27,8 @@ public enum PolItemCode {
 
     GWYBCDSD("GB03", "公务员补充第三段"),
 
+    GWYBCDSID("GB04", "公务员补充第四段"),
+
     BCDBQFBZ("PS01", "补充大病起付标准"),
 
     BCDBDYD("PL01", "补充大病第一段"),

+ 1 - 1
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiManageController.java

@@ -36,7 +36,7 @@ public class SiManageController {
     }
 
     @PostMapping("/institutionSettlementDetailCheck")
-    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(@RequestBody InsSetlDetlChkPrm prm) {
+    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(@RequestBody InsSetlDetlChk prm) {
         return service.institutionSettlementDetailCheck(prm);
     }
 

+ 30 - 1
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -4,7 +4,11 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.medicalinsurance.manage.InstSetlLdgChkBrf;
+import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -30,5 +34,30 @@ public interface SiManageDao {
     @Select("select name from t_region where code=#{code}")
     String selectRegion(@Param("code") String code);
 
-
+    @Select("select pat_no,times,ledger_sn,medfee_sumamt,acct_pay,fund_pay_sumamt, " +
+            "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 insutype=#{insutype} and " +
+            "setl_type=#{setlType} and revoked=0 and clr_optins=#{clrOptins} and setl_time>=#{start} and setl_time<=#{end}")
+    List<InstSetlLdgChkBrf> selectSetlChkBrfs(@Param("setlType") String setlType,
+                                              @Param("insutype") String insutype,
+                                              @Param("clrOptins") String clrOptins,
+                                              @Param("start") String start,
+                                              @Param("end") String end);
+
+    @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no,medfee_sumamt,acct_pay,fund_pay_sumamt,psn_cash_pay, " +
+            "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 setl_type=#{setlType} and revoked=0 and clr_optins=#{clrOptins} " +
+            "and setl_time>=#{start} and setl_time<=#{end}")
+    List<InstSetlLdgChkBrf> selectSetlChkBrfs(@Param("setlType") String setlType,
+                                              @Param("clrOptins") String clrOptins,
+                                              @Param("start") String start,
+                                              @Param("end") String end);
+
+    @Select("select fund_payamt from t_si_setldetail where pat_no=#{patNo} and times=#{times} and ledger_sn=#{sn} and " +
+            "(fund_pay_type='999996' or setl_proc_info='999996') ")
+    List<BigDecimal> selectSetlDetails(@Param("patNo") String patNo,
+                                       @Param("times") int times,
+                                       @Param("sn") int sn);
 }

+ 6 - 5
src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InsSetlDetlChk.java

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -46,25 +47,25 @@ public class InsSetlDetlChk {
      * 医疗费总额
      * */
     @JSONField(name = "medfee_sumamt")
-    private Double medfeeSumamt;
+    private BigDecimal medfeeSumamt;
     
     /**
      * 基金支付总额
      * */
     @JSONField(name = "fund_pay_sumamt")
-    private Double fundPaySumamt;
+    private BigDecimal fundPaySumamt;
     
     /**
      * 现金支付金额
      * */
     @JSONField(name = "cash_payamt")
-    private Double cashPayamt;
+    private BigDecimal cashPayamt;
     
     /**
      * 定点医药机构结算笔数
      * */
     @JSONField(name = "fixmedins_setl_cnt")
-    private Double fixmedinsSetlCnt;
+    private Integer fixmedinsSetlCnt;
     
     /**
      * 清算类别
@@ -76,5 +77,5 @@ public class InsSetlDetlChk {
      * 退费结算标志
      * */
     @JSONField(name = "refd_setl_flag")
-    private String refdSetlFlag;
+    private String refdSetlFlag = "0";
 }

+ 0 - 16
src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InsSetlDetlChkPrm.java

@@ -1,16 +0,0 @@
-package thyyxxk.webserver.entity.medicalinsurance.manage;
-
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @description: 明细对账入参
- * @author: DingJie
- * @create: 2021/7/3015:14
- */
-@Data
-public class InsSetlDetlChkPrm {
-    private InsSetlDetlChk data;
-    private List<InsSetlDetlChkFile> fsUploadIns;
-}

+ 7 - 9
src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InsSetlDetlChkFile.java → src/main/java/thyyxxk/webserver/entity/medicalinsurance/manage/InstSetlLdgChkBrf.java

@@ -4,19 +4,17 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 
-/**
- * @description: 明细对账输入文件
- * @author: DingJie
- * @create: 2021/7/3015:13
- */
 @Data
-public class InsSetlDetlChkFile {
+public class InstSetlLdgChkBrf {
+    private String patNo;
+    private Integer times;
+    private Integer ledgerSn;
     private String setlId;
     private String mdtrtId;
     private String psnNo;
     private BigDecimal medfeeSumamt;
-    private BigDecimal fundPaySumamt;
     private BigDecimal acctPay;
-
-    private String insuplcAdmdvs;
+    private BigDecimal fundPaySumamt;
+    private BigDecimal psnCashPay;
+    private BigDecimal hospPay;
 }

+ 4 - 3
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setlinfo/SiSetldetail.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.entity.medicalinsurance.setlinfo;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -34,17 +35,17 @@ public class SiSetldetail implements Serializable {
 	/**
 	 * 符合政策范围金额
 	 */
-	private Double inscpScpAmt;
+	private BigDecimal inscpScpAmt;
 
 	/**
 	 * 本次可支付限额金额
 	 */
-	private Double crtPaybLmtAmt;
+	private BigDecimal crtPaybLmtAmt;
 
 	/**
 	 * 基金支付金额
 	 */
-	private Double fundPayamt;
+	private BigDecimal fundPayamt;
 
 	/**
 	 * 基金支付类型名称

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

@@ -22,11 +22,11 @@ public class SlctSetlPrm {
     @NotNull(message = "开始日期不能为空!")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    private Date begndate;
+    private Date stmtBegndate;
     @NotNull(message = "结束日期不能为空!")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    private Date enddate;
+    private Date stmtEnddate;
 
     private Integer revoked;
 }

+ 48 - 24
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -11,19 +11,16 @@ import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.constants.sidicts.*;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao;
-import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
-import thyyxxk.webserver.dao.his.medicalinsurance.UpIdCollectionDao;
-import thyyxxk.webserver.dao.his.yibao.DismissDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.PureCodeName;
 import thyyxxk.webserver.entity.medicalinsurance.manage.*;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm;
-import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.*;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.*;
@@ -44,27 +41,15 @@ public class SiManageService {
     private final SiDownloadService dldService;
     private final SiManageDao dao;
     private final SiSetlinfoDao setlinfoDao;
-    private final SiQueryDao queryDao;
-
-    private final UpIdCollectionDao upIdCollectionDao;
-
-    private final DismissDao dismissDao;
-
-    private final PublicServer publicServer;
-
 
     @Autowired
     public SiManageService(ExecService exec, SiUploadService upldServcie,
-                           SiDownloadService dldService, SiManageDao dao, SiSetlinfoDao setlinfoDao, SiQueryDao queryDao, UpIdCollectionDao upIdCollectionDao, DismissDao dismissDao, PublicServer publicServer) {
+                           SiDownloadService dldService, SiManageDao dao, SiSetlinfoDao setlinfoDao) {
         this.exec = exec;
         this.upldServcie = upldServcie;
         this.dldService = dldService;
         this.dao = dao;
         this.setlinfoDao = setlinfoDao;
-        this.queryDao = queryDao;
-        this.upIdCollectionDao = upIdCollectionDao;
-        this.dismissDao = dismissDao;
-        this.publicServer = publicServer;
     }
 
     public ResultVo<String> uploadCatalogueContrast(CatalogueContrast prm) {
@@ -154,6 +139,25 @@ public class SiManageService {
     }
 
     public ResultVo<String> institutionSettlementLedgerCheck(InstStlLdgChk instStlLdgChk) {
+        String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate());
+        String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate());
+        List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
+                instStlLdgChk.getSetlOptins(), startdate, enddate);
+        BigDecimal medfeesum = new BigDecimal("0");
+        BigDecimal acctpaysum = new BigDecimal("0");
+        BigDecimal fundpaysum = new BigDecimal("0");
+        for (InstSetlLdgChkBrf brf : brfs) {
+            medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
+            acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
+            fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
+            if (null != brf.getHospPay()) {
+                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
+            }
+        }
+        instStlLdgChk.setMedfeeSumamt(medfeesum);
+        instStlLdgChk.setAcctPay(acctpaysum);
+        instStlLdgChk.setFundPaySumamt(fundpaysum);
+        instStlLdgChk.setFixmedinsSetlCnt(brfs.size());
         JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK);
         String ref = JSONObject.toJSONStringWithDateFormat(instStlLdgChk, "yyyy-MM-dd");
         input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
@@ -195,18 +199,38 @@ public class SiManageService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
-    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChkPrm prm) {
+    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk prm) {
         String snowId = SnowFlakeId.instance().nextId();
         String filename = snowId + ".txt";
         StringBuilder fsIn = new StringBuilder();
-        for (InsSetlDetlChkFile item : prm.getFsUploadIns()) {
+        String startdate = DateUtil.getDayStartTime(prm.getStmtBegndate());
+        String enddate = DateUtil.getDayEndTime(prm.getStmtEnddate());
+        List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(prm.getClrType(),
+                prm.getSetlOptins(), startdate, enddate);
+        BigDecimal medfeesum = new BigDecimal("0");
+        BigDecimal psnCashPay = new BigDecimal("0");
+        BigDecimal fundpaysum = new BigDecimal("0");
+        for (InstSetlLdgChkBrf brf : brfs) {
+            medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
+            psnCashPay = DecimalUtil.add(psnCashPay, brf.getPsnCashPay());
+            fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
+            if (null != brf.getHospPay()) {
+                fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
+                brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay()));
+            }
+        }
+        prm.setMedfeeSumamt(medfeesum);
+        prm.setCashPayamt(psnCashPay);
+        prm.setFundPaySumamt(fundpaysum);
+        prm.setFixmedinsSetlCnt(brfs.size());
+        for (InstSetlLdgChkBrf item : brfs) {
             fsIn.append(item.getSetlId()).append("\t")
                     .append(item.getMdtrtId()).append("\t")
                     .append(item.getPsnNo()).append("\t")
                     .append(item.getMedfeeSumamt()).append("\t")
                     .append(item.getFundPaySumamt()).append("\t")
                     .append(item.getAcctPay()).append("\t")
-                    .append(prm.getData().getRefdSetlFlag()).append("\n");
+                    .append(prm.getRefdSetlFlag()).append("\n");
         }
         try {
             Files.write(Paths.get(filename), fsIn.toString().getBytes());
@@ -217,13 +241,13 @@ public class SiManageService {
             ResultVo<String> uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename);
             ZipUtil.deleteFile(zipFile);
             if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
-                prm.getData().setFileQuryNo(uplRes.getData());
+                prm.setFileQuryNo(uplRes.getData());
             }
         } catch (IOException e) {
             log.error("医药机构费用结算对明细账出错", e);
         }
         JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
-        String ref = JSONObject.toJSONStringWithDateFormat(prm.getData(), "yyyy-MM-dd");
+        String ref = JSONObject.toJSONStringWithDateFormat(prm, "yyyy-MM-dd");
         input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
         JSONObject result = exec.executeTrade(input, SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
         log.info("【操作员:{}】,医药机构费用结算对明细账:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
@@ -259,8 +283,8 @@ public class SiManageService {
         if (StringUtil.notBlank(prm.getInsutype())) {
             wrapper.eq("insutype", prm.getInsutype());
         }
-        String begndate = DateUtil.formatDatetime(prm.getBegndate(), "yyyy-MM-dd") + " 00:00:00";
-        String enddate = DateUtil.formatDatetime(prm.getEnddate(), "yyyy-MM-dd") + " 23:59:59";
+        String begndate = DateUtil.formatDatetime(prm.getStmtBegndate(), "yyyy-MM-dd") + " 00:00:00";
+        String enddate = DateUtil.formatDatetime(prm.getStmtEnddate(), "yyyy-MM-dd") + " 23:59:59";
         wrapper.eq("setl_type", prm.getClrType());
         wrapper.eq("revoked", YesOrNo.NO.getCode());
         wrapper.apply("setl_time>='" + begndate + "'");

+ 10 - 0
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -64,6 +64,16 @@ public class DateUtil {
         return date + " 23:59:59.999";
     }
 
+    public static String getDayStartTime(Date date) {
+        SimpleDateFormat smdate = new SimpleDateFormat("yyyy-MM-dd");
+        return smdate.format(date) + " 00:00:00.000";
+    }
+
+    public static String getDayEndTime(Date date) {
+        SimpleDateFormat smdate = new SimpleDateFormat("yyyy-MM-dd");
+        return smdate.format(date) + " 23:59:59.999";
+    }
+
     public static Date getDatetimeAfterCentury(Date date) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);

+ 8 - 0
src/main/java/thyyxxk/webserver/utils/DecimalUtil.java

@@ -21,6 +21,14 @@ public class DecimalUtil {
         return ad.subtract(bd).setScale(2, RoundingMode.HALF_UP).toString();
     }
 
+    public static BigDecimal add(BigDecimal a, BigDecimal b) {
+        return a.add(b).setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public static BigDecimal minus(BigDecimal a, BigDecimal b) {
+        return a.subtract(b).setScale(2, RoundingMode.HALF_UP);
+    }
+
     public static String divide(String a, String b, int scale) {
         BigDecimal ad = new BigDecimal(a);
         BigDecimal bd = new BigDecimal(b);