Browse Source

结算后自动对账。

lighter 3 years ago
parent
commit
e3b2ad01bd

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

@@ -39,18 +39,18 @@ public class SiManageController {
     }
 
     @PostMapping("/institutionSettlementDetailCheck")
-    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(@RequestBody InsSetlDetlChk prm) {
-        return service.institutionSettlementDetailCheck(prm);
+    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(@RequestBody InsSetlDetlChk insSetlDetlChk) {
+        return service.institutionSettlementDetailCheck(insSetlDetlChk);
     }
 
     @PostMapping("/uploadCatalogueContrast")
-    public ResultVo<String> uploadCatalogueContrast(@RequestBody CatalogueContrast prm) {
-        return service.uploadCatalogueContrast(prm);
+    public ResultVo<String> uploadCatalogueContrast(@RequestBody CatalogueContrast catalogueContrast) {
+        return service.uploadCatalogueContrast(catalogueContrast);
     }
 
     @PostMapping("/revokeCatalogueContrast")
-    public ResultVo<String> revokeCatalogueContrast(@RequestBody CatalogueContrast prm) {
-        return service.revokeCatalogueContrast(prm);
+    public ResultVo<String> revokeCatalogueContrast(@RequestBody CatalogueContrast catalogueContrast) {
+        return service.revokeCatalogueContrast(catalogueContrast);
     }
 
     @PostMapping("/autoRecoveryTrade")
@@ -59,8 +59,8 @@ public class SiManageController {
     }
 
     @PostMapping("/selectSetlinfos")
-    public ResultVo<Map<String, Object>> selectSetlinfos(@RequestBody @Validated SlctSetlPrm prm) {
-        return service.selectSetlinfos(prm);
+    public ResultVo<Map<String, Object>> selectSetlinfos(@RequestBody @Validated SlctSetlPrm slctSetlPrm) {
+        return service.selectSetlinfos(slctSetlPrm);
     }
 
     @PassToken

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

@@ -230,14 +230,14 @@ public class SiManageService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
-    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk prm) {
+    public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk insSetlDetlChk) {
         String snowId = SnowFlakeId.instance().nextId();
         String filename = snowId + ".txt";
         StringBuilder fsIn = new StringBuilder();
-        String startdate = DateUtil.getDayStartTime(prm.getStmtBegndate());
-        String enddate = DateUtil.getDayEndTime(prm.getStmtEnddate());
-        List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(prm.getClrType(),
-                prm.getSetlOptins(), startdate, enddate);
+        String startdate = DateUtil.getDayStartTime(insSetlDetlChk.getStmtBegndate());
+        String enddate = DateUtil.getDayEndTime(insSetlDetlChk.getStmtEnddate());
+        List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(insSetlDetlChk.getClrType(),
+                insSetlDetlChk.getSetlOptins(), startdate, enddate);
         BigDecimal medfeesum = new BigDecimal("0");
         BigDecimal psnCashPay = new BigDecimal("0");
         BigDecimal fundpaysum = new BigDecimal("0");
@@ -250,10 +250,10 @@ public class SiManageService {
                 brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay()));
             }
         }
-        prm.setMedfeeSumamt(medfeesum);
-        prm.setCashPayamt(psnCashPay);
-        prm.setFundPaySumamt(fundpaysum);
-        prm.setFixmedinsSetlCnt(brfs.size());
+        insSetlDetlChk.setMedfeeSumamt(medfeesum);
+        insSetlDetlChk.setCashPayamt(psnCashPay);
+        insSetlDetlChk.setFundPaySumamt(fundpaysum);
+        insSetlDetlChk.setFixmedinsSetlCnt(brfs.size());
         for (InstSetlLdgChkBrf item : brfs) {
             fsIn.append(item.getSetlId()).append("\t")
                     .append(item.getMdtrtId()).append("\t")
@@ -261,7 +261,7 @@ public class SiManageService {
                     .append(item.getMedfeeSumamt()).append("\t")
                     .append(item.getFundPaySumamt()).append("\t")
                     .append(item.getAcctPay()).append("\t")
-                    .append(prm.getRefdSetlFlag()).append("\n");
+                    .append(insSetlDetlChk.getRefdSetlFlag()).append("\n");
         }
         try {
             Files.write(Paths.get(filename), fsIn.toString().getBytes());
@@ -272,13 +272,13 @@ public class SiManageService {
             ResultVo<String> uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename);
             ZipUtil.deleteFile(zipFile);
             if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
-                prm.setFileQuryNo(uplRes.getData());
+                insSetlDetlChk.setFileQuryNo(uplRes.getData());
             }
         } catch (IOException e) {
             log.error("医药机构费用结算对明细账出错", e);
         }
         JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
-        String ref = JSONObject.toJSONStringWithDateFormat(prm, "yyyy-MM-dd");
+        String ref = JSONObject.toJSONStringWithDateFormat(insSetlDetlChk, "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);

+ 37 - 1
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -13,6 +13,9 @@ import thyyxxk.webserver.dao.his.medicalinsurance.*;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.*;
+import thyyxxk.webserver.entity.medicalinsurance.manage.InsSetlDetlChk;
+import thyyxxk.webserver.entity.medicalinsurance.manage.InsSetlDetlChkRslt;
+import thyyxxk.webserver.entity.medicalinsurance.manage.InstStlLdgChk;
 import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
@@ -54,11 +57,12 @@ public class SiZyService {
     private final ExecService exec;
     private final DismissService dismissService;
     private final SiZySrvc zySrvc;
+    private final SiManageService manageService;
 
     @Autowired
     public SiZyService(SiZyDao dao, SiQueryDao qrydao, SiSetlinfoDao setlinfoDao,
                        SiSetldetailDao setldetldao, SiChargeTempDao chrgtmpdao, SiLogDao logDao, ExecService exec,
-                       DismissService dismissService, SiZySrvc zySrvc) {
+                       DismissService dismissService, SiZySrvc zySrvc, SiManageService manageService) {
         this.dao = dao;
         this.qrydao = qrydao;
         this.setlinfodao = setlinfoDao;
@@ -68,6 +72,7 @@ public class SiZyService {
         this.exec = exec;
         this.dismissService = dismissService;
         this.zySrvc = zySrvc;
+        this.manageService = manageService;
     }
 
     public ResultVo<String> admissRegister(ZyPatientInfo p) {
@@ -463,6 +468,37 @@ public class SiZyService {
                 setldetailEntity.setLedgerSn(p.getLedgerSn());
                 setldetldao.insert(setldetailEntity);
             }
+
+            InstStlLdgChk ldgChk = new InstStlLdgChk();
+            ldgChk.setInsutype(setlEntity.getInsutype());
+            ldgChk.setClrType(ClrType.INPATIENT.getCode());
+            ldgChk.setSetlOptins(setlEntity.getClrOptins());
+            ldgChk.setStmtBegndate(setlEntity.getSetlTime());
+            ldgChk.setStmtEnddate(setlEntity.getSetlTime());
+            ResultVo<String> totalLedgerCheck = manageService.institutionSettlementLedgerCheck(ldgChk);
+            if (totalLedgerCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+                InsSetlDetlChk detlChk = new InsSetlDetlChk();
+                detlChk.setSetlOptins(ldgChk.getSetlOptins());
+                detlChk.setStmtBegndate(ldgChk.getStmtBegndate());
+                detlChk.setStmtEnddate(ldgChk.getStmtEnddate());
+                detlChk.setClrType(ldgChk.getClrType());
+                detlChk.setRefdSetlFlag(YesOrNo.NO.getCodeStr());
+                ResultVo<List<InsSetlDetlChkRslt>> detailLedgerCheck = manageService.institutionSettlementDetailCheck(detlChk);
+                if (detailLedgerCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+                    revokeSettlement(p);
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, detailLedgerCheck.getMessage());
+                }
+                for (InsSetlDetlChkRslt insSetlDetlChkRslt : detailLedgerCheck.getData()) {
+                    if (Objects.equals(insSetlDetlChkRslt.getSetlId(), setlEntity.getSetlId())) {
+                        if (!Objects.equals(insSetlDetlChkRslt.getStmtRslt(), "0")) {
+                            revokeSettlement(p);
+                            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, insSetlDetlChkRslt.getMemo());
+                        }
+                        break;
+                    }
+                }
+            }
+
             MedinsSettleFee settleFee = new MedinsSettleFee();
             if (p.getMidSetl()) {
                 settleFee.setZjdzDatetime(p.getZjdzDatetime());