Browse Source

优化单病种费用生成。

lighter 4 years ago
parent
commit
53821e0525

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>5.9</version>
+    <version>6.0</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
 

+ 4 - 3
src/main/java/thyyxxk/webserver/controller/makedbzfees/MakeDzbFeesController.java

@@ -10,10 +10,11 @@ import thyyxxk.webserver.pojo.ResultVo;
 import thyyxxk.webserver.pojo.makedbzfees.GetMzFeesParam;
 import thyyxxk.webserver.pojo.makedbzfees.SaveZyFeesParam;
 import thyyxxk.webserver.service.makedbzfees.MakeDbzFeesService;
-
-import java.util.List;
 import java.util.Map;
 
+/**
+ * @author dj
+ */
 @RestController
 @RequestMapping("/makeDbzFees")
 public class MakeDzbFeesController {
@@ -25,7 +26,7 @@ public class MakeDzbFeesController {
     }
 
     @PostMapping("/getReceipts")
-    public ResultVo<List<Map<String, String>>> getReceipts(@RequestBody @Validated GetMzFeesParam param) {
+    public ResultVo<Map<String, Object>> getReceipts(@RequestBody @Validated GetMzFeesParam param) {
         return service.getReceipts(param);
     }
 

+ 7 - 12
src/main/java/thyyxxk/webserver/dao/his/makedbzfees/MakeDbzFeesDao.java

@@ -1,11 +1,14 @@
 package thyyxxk.webserver.dao.his.makedbzfees;
 
 import org.apache.ibatis.annotations.*;
-import thyyxxk.webserver.pojo.makedbzfees.InpatientInfoPojo;
-import thyyxxk.webserver.pojo.makedbzfees.ZyDetailChargePojo;
+import thyyxxk.webserver.pojo.makedbzfees.InpatientInfo;
+import thyyxxk.webserver.pojo.makedbzfees.ZyDetailCharge;
 
 import java.util.List;
 
+/**
+ * @author dj
+ */
 @Mapper
 public interface MakeDbzFeesDao {
 
@@ -27,7 +30,7 @@ public interface MakeDbzFeesDao {
             "maxDetailSn=(select max(detail_sn) from zy_detail_charge " +
             "where inpatient_no=a.inpatient_no and admiss_times=a.admiss_times) " +
             "from zy_actpatient a where inpatient_no=#{inpatientNo}")
-    InpatientInfoPojo getInpatientInfo(@Param("inpatientNo") String inpatientNo);
+    InpatientInfo getInpatientInfo(@Param("inpatientNo") String inpatientNo);
 
     @Insert("<script>" +
             "insert into zy_detail_charge (inpatient_no,admiss_times,ledger_sn,detail_sn,charge_date,op_id_code, " +
@@ -40,14 +43,6 @@ public interface MakeDbzFeesDao {
             "#{info.consultPhysician})" +
             "</foreach>" +
             "</script>")
-    void insertInfoZyDetailCharge(@Param("info") InpatientInfoPojo info, @Param("list")List<ZyDetailChargePojo> zyFees);
+    void insertInfoZyDetailCharge(@Param("info") InpatientInfo info, @Param("list")List<ZyDetailCharge> zyFees);
 
-    @Update("update mz_charge_detail set pay_mark=0, windows_no_yf='04' where patient_id=#{patientId} " +
-            "and times=#{times} and receipt_no=#{receiptNo} and order_no=#{orderNo} and item_no=#{itemNo}")
-    void updateFyPayMark(@Param("patientId") String patientId, @Param("times") Integer times,
-                         @Param("receiptNo") Integer receiptNo, @Param("orderNo") Integer orderNo,
-                         @Param("itemNo") Integer itemNo);
-
-    @Update("update mz_yj_req set pay_mark=0 where patient_id=#{patientId} and times=#{times} and req_no=#{reqNo}")
-    void updateYjPayMark(@Param("patientId") String patientId, @Param("times") Integer times, @Param("reqNo") Integer reqNo);
 }

+ 6 - 2
src/main/java/thyyxxk/webserver/pojo/makedbzfees/InpatientInfoPojo.java → src/main/java/thyyxxk/webserver/pojo/makedbzfees/InpatientInfo.java

@@ -1,9 +1,13 @@
 package thyyxxk.webserver.pojo.makedbzfees;
 
 import lombok.Data;
+import thyyxxk.webserver.utils.StringUtil;
 
+/**
+ * @author dj
+ */
 @Data
-public class InpatientInfoPojo {
+public class InpatientInfo {
     private String inpatientNo;
     private Integer admissTimes;
     private Integer ledgerSn;
@@ -16,7 +20,7 @@ public class InpatientInfoPojo {
     private String staffId;
 
     public String getOperation() {
-        return operation.equals("") ? "0" : operation;
+        return StringUtil.isBlank(operation) ? "0" : operation;
     }
 
     public Integer getMaxDetailSn() {

+ 6 - 9
src/main/java/thyyxxk/webserver/pojo/makedbzfees/MzChargeDetailPojo.java → src/main/java/thyyxxk/webserver/pojo/makedbzfees/MzChargeDetail.java

@@ -1,22 +1,22 @@
 package thyyxxk.webserver.pojo.makedbzfees;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
-import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
+/**
+ * @author dj
+ */
 @Data
-public class MzChargeDetailPojo {
+public class MzChargeDetail {
     private String patientId;
     private Integer times;
     private Integer receiptNo;
     private Integer orderNo;
     private Integer itemNo;
-    private Integer reqYj; // 医技标志
+    private Integer reqYj;
     private String chargeItemCode;
-    private String billItemCode; // !== TC
+    private String billItemCode;
     private Double quantity;
     private BigDecimal unitPrice;
     private Integer payMark;
@@ -24,9 +24,6 @@ public class MzChargeDetailPojo {
     private String serialNo;
     private String groupNo;
     private String name;
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date chargeDate;
     private Integer drugWin;
     private Integer reqNo;
     private String execDept;

+ 6 - 1
src/main/java/thyyxxk/webserver/pojo/makedbzfees/SaveZyFeesParam.java

@@ -4,6 +4,7 @@ import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
 import java.util.List;
 
 /**
@@ -14,6 +15,10 @@ public class SaveZyFeesParam {
     private Integer cardType;
     @NotBlank(message = "住院号/门诊id不能为空。")
     private String cardNo;
+    @NotBlank(message = "HIS单号不能为空。")
+    private String hisOrdNum;
     @NotEmpty(message = "费用列表不能为空。")
-    private List<MzChargeDetailPojo> list;
+    private List<MzChargeDetail> receipts;
+    @NotNull(message = "总金额不能为空。")
+    private Integer totalAmt;
 }

+ 4 - 1
src/main/java/thyyxxk/webserver/pojo/makedbzfees/ZyDetailChargePojo.java → src/main/java/thyyxxk/webserver/pojo/makedbzfees/ZyDetailCharge.java

@@ -4,8 +4,11 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 
+/**
+ * @author dj
+ */
 @Data
-public class ZyDetailChargePojo {
+public class ZyDetailCharge {
     private String chargeCode;
     private String chargeCodeMx;
     private Integer detailSn;

+ 44 - 24
src/main/java/thyyxxk/webserver/service/makedbzfees/MakeDbzFeesService.java

@@ -15,9 +15,7 @@ import thyyxxk.webserver.pojo.ResultVo;
 import thyyxxk.webserver.pojo.makedbzfees.*;
 import thyyxxk.webserver.utils.*;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -34,7 +32,7 @@ public class MakeDbzFeesService {
         this.dao = dao;
     }
 
-    public ResultVo<List<Map<String, String>>> getReceipts(GetMzFeesParam param) {
+    public ResultVo<Map<String, Object>> getReceipts(GetMzFeesParam param) {
         String patientId = param.getCardNo();
         if (1 == param.getCardType()) {
             patientId = dao.getPatientId(param.getCardNo());
@@ -54,10 +52,13 @@ public class MakeDbzFeesService {
         if (hrgRes.getResultCode() != 0) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgRes.getResultMessage());
         }
-        List<Map<String, String>> list = FilterUtil.cast(hrgRes.getData());
-        List<Map<String, String>> data = new ArrayList<>();
-        for (Map<String, String> item : list) {
-            String[] str = item.get("hisOrdNum").split("_");
+        List<Map<String, String>> hisOrdNums = FilterUtil.cast(hrgRes.getData());
+        Map<String, Object> resultMap = new HashMap<>(Capacity.TWO);
+        Map<String, Object> receiptMap = new HashMap<>(hisOrdNums.size());
+        for (Map<String, String> item : hisOrdNums) {
+            String hisOrdNum = item.get("hisOrdNum");
+            List<Map<String, String>> receipts = new ArrayList<>();
+            String[] str = hisOrdNum.split("_");
             JSONObject p = new JSONObject();
             p.put("patientId", str[0]);
             p.put("times", str[1]);
@@ -71,13 +72,16 @@ public class MakeDbzFeesService {
             }
             List<Map<String, String>> details = FilterUtil.cast(hrgResponse.getData());
             for (Map<String, String> pojo : details) {
-                if (!"TC".equals(pojo.get("billItemCode")) && "5".equals(pojo.get("payMark"))) {
+                if (!"TC".equals(pojo.get("billItemCode")) && "5".equals(pojo.get("payMark")) && !"舍尾金额".equals(pojo.get("tcName"))) {
                     pojo.replace("priceTime", DateUtil.formatPriceTime(pojo.get("priceTime")));
-                    data.add(pojo);
+                    receipts.add(pojo);
                 }
             }
+            receiptMap.put(hisOrdNum, receipts);
         }
-        return ResultVoUtil.success(data);
+        resultMap.put("hisOrdNums", hisOrdNums);
+        resultMap.put("receipts", receiptMap);
+        return ResultVoUtil.success(resultMap);
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -89,18 +93,18 @@ public class MakeDbzFeesService {
         if (StringUtil.isBlank(inpatientNo)) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的住院号!请确认患者有住院身份。");
         }
-        InpatientInfoPojo inpatientInfo = dao.getInpatientInfo(inpatientNo);
+        InpatientInfo inpatientInfo = dao.getInpatientInfo(inpatientNo);
         if (null == inpatientInfo) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的在院信息!请确认此患者已经办理住院。");
         }
         inpatientInfo.setStaffId(TokenUtil.getTokenUserId());
         AtomicInteger detailSn = new AtomicInteger(inpatientInfo.getMaxDetailSn());
-        List<ZyDetailChargePojo> zyFees = new ArrayList<>();
-        for (MzChargeDetailPojo mzFee : param.getList()) {
+        List<ZyDetailCharge> zyFees = new ArrayList<>();
+        for (MzChargeDetail mzFee : param.getReceipts()) {
             if ("TC".equalsIgnoreCase(mzFee.getBillItemCode())) {
                 continue;
             }
-            ZyDetailChargePojo zyFee = new ZyDetailChargePojo();
+            ZyDetailCharge zyFee = new ZyDetailCharge();
             zyFee.setChargeCodeMx(mzFee.getChargeItemCode());
             if ("00".equals(mzFee.getGroupNo())) {
                 zyFee.setChargeCode(mzFee.getChargeItemCode());
@@ -115,18 +119,35 @@ public class MakeDbzFeesService {
             zyFee.setSerial(mzFee.getSerial());
             zyFee.setDoctorCode(mzFee.getDoctorCode());
             zyFees.add(zyFee);
-            dao.updateFyPayMark(mzFee.getPatientId(), mzFee.getTimes(),
-                    mzFee.getReceiptNo(), mzFee.getOrderNo(), mzFee.getItemNo());
-            if (null != mzFee.getReqYj() && 1 == mzFee.getReqYj()) {
-                dao.updateYjPayMark(mzFee.getPatientId(), mzFee.getTimes(), mzFee.getReqNo());
-                log.info("update yj: {}, {}, {}", mzFee.getPatientId(), mzFee.getTimes(), mzFee.getReqNo());
-            }
         }
+        batchIntoZyDetailCharge(zyFees, inpatientInfo);
+        JSONObject pay = new JSONObject();
+        pay.put("patCardType", 1);
+        pay.put("patCardNo", param.getHisOrdNum().split("_")[0]);
+        pay.put("hisOrdNum", param.getHisOrdNum());
+        pay.put("psOrdNum", "dbz" + SnowFlakeId.instance().nextId());
+        pay.put("payMode", "WX");
+        pay.put("payAmt", param.getTotalAmt());
+        pay.put("agtOrdNum", SnowFlakeId.instance().nextId());
+        pay.put("payTime", DateUtil.formatDatetime(new Date()));
+        RestTemplate restTemplate = new RestTemplate();
+        HrgResponse hrgResponse = restTemplate.postForObject(HrgAddr.PAY_CHARGE_DETAIL_FORM_HAI_CI, pay, HrgResponse.class);
+        log.info("保存单病种缴费:{}", hrgResponse);
+        if (null == hrgResponse || null == hrgResponse.getResultCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络服务错误!");
+        }
+        if (hrgResponse.getResultCode() != 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getResultMessage());
+        }
+        return ResultVoUtil.success();
+    }
+
+    private void batchIntoZyDetailCharge(List<ZyDetailCharge> zyFees, InpatientInfo inpatientInfo) {
         if (zyFees.size() <= Capacity.TWENTY) {
             dao.insertInfoZyDetailCharge(inpatientInfo, zyFees);
         } else {
-            List<ZyDetailChargePojo> tempList = new ArrayList<>();
-            for (ZyDetailChargePojo item : zyFees) {
+            List<ZyDetailCharge> tempList = new ArrayList<>();
+            for (ZyDetailCharge item : zyFees) {
                 tempList.add(item);
                 if (tempList.size() == 20) {
                     dao.insertInfoZyDetailCharge(inpatientInfo, tempList);
@@ -137,6 +158,5 @@ public class MakeDbzFeesService {
                 dao.insertInfoZyDetailCharge(inpatientInfo, tempList);
             }
         }
-        return ResultVoUtil.success();
     }
 }