|
@@ -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();
|
|
|
}
|
|
|
}
|