|
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
+import thyyxxk.webserver.constants.HrgAddr;
|
|
|
import thyyxxk.webserver.constants.ResponceType;
|
|
|
import thyyxxk.webserver.dao.his.markmtfees.MarkMtFeesDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
@@ -129,25 +130,77 @@ public class MarkMtFeesService {
|
|
|
}
|
|
|
map.put("mzPatient", mzPatients.get(0));
|
|
|
map.put("mzVisit", mzVisit);
|
|
|
- List<MzReceipt> mzReceipts = dao.selectMzReceipts(patientId, times, mzVisit.getReceiptNo());
|
|
|
- mzReceipts.removeIf(item -> "TC".equals(item.getBillItemCode()) || item.getPayMark() != 5 || "BILL99".equals(item.getChargeItemCode()));
|
|
|
- Map<Integer, List<MzReceipt>> temp = new HashMap<>(Capacity.DEFAULT);
|
|
|
- mzReceipts.forEach(item -> {
|
|
|
- item.setChecked(true);
|
|
|
- if (!temp.containsKey(item.getOrderNo())) {
|
|
|
+ JSONObject queryMzChargeList = new JSONObject();
|
|
|
+ queryMzChargeList.put("patCardType", 21);
|
|
|
+ queryMzChargeList.put("patCardNo", patientId);
|
|
|
+ queryMzChargeList.put("hisOrdNum", "");
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ Map<String, Object> mzChargeListMap = template.postForObject(HrgAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeList, Map.class);
|
|
|
+ if (null == mzChargeListMap) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
|
|
|
+ }
|
|
|
+ if (0 != (int) mzChargeListMap.get("resultCode")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, mzChargeListMap.get("resultMessage").toString());
|
|
|
+ }
|
|
|
+ List<Map<String, String>> mzChargeList = FilterUtil.cast(mzChargeListMap.get("data"));
|
|
|
+ List<Map<String, Object>> mzChargeDetailList = new ArrayList<>();
|
|
|
+ mzChargeList.forEach(item -> {
|
|
|
+ String hisOrdNum = item.get("hisOrdNum");
|
|
|
+ if (null != hisOrdNum) {
|
|
|
+ String[] hisOrdNumParts = hisOrdNum.split("_");
|
|
|
+ if (Integer.parseInt(hisOrdNumParts[1]) == times) {
|
|
|
+ JSONObject queryMzChargeDetail = new JSONObject();
|
|
|
+ queryMzChargeDetail.put("patientId", patientId);
|
|
|
+ queryMzChargeDetail.put("times", times);
|
|
|
+ queryMzChargeDetail.put("receiptNo", hisOrdNumParts[2]);
|
|
|
+ Map<String, Object> mzChargeDetailMap = template.postForObject(HrgAddr.UN_PAID_TO_FULL_CHARGE_DETAIL,
|
|
|
+ queryMzChargeDetail, Map.class);
|
|
|
+ if (null != mzChargeDetailMap && 0 == (int) mzChargeDetailMap.get("resultCode")) {
|
|
|
+ List<Map<String, Object>> detail = FilterUtil.cast(mzChargeDetailMap.get("data"));
|
|
|
+ mzChargeDetailList.addAll(detail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mzChargeDetailList.removeIf(item -> "TC".equals(item.get("billItemCode")) ||
|
|
|
+ !"5".equals(item.get("payMark")) || "BILL99".equals(item.get("chargeItemCode")) ||
|
|
|
+ "四舍五入".equals(item.get("tcName")));
|
|
|
+ Map<Integer, List<MzReceipt>> orderReceiptsMap = new HashMap<>(Capacity.DEFAULT);
|
|
|
+ String doctorName = dao.selectDoctorName(mzChargeDetailList.get(0).get("doctorCode").toString());
|
|
|
+ mzChargeDetailList.forEach(item -> {
|
|
|
+ MzReceipt receipt = new MzReceipt();
|
|
|
+ receipt.setChecked(!item.get("tcName").toString().contains("外送艾迪康"));
|
|
|
+ receipt.setPatientId(patientId);
|
|
|
+ receipt.setTimes(times);
|
|
|
+ receipt.setReceiptNo((int) item.get("receiptNo"));
|
|
|
+ receipt.setOrderNo((int) item.get("orderNo"));
|
|
|
+ receipt.setItemNo((int) item.get("itemNo"));
|
|
|
+ receipt.setDrugName(item.get("tcName").toString());
|
|
|
+ receipt.setChargeItemCode(item.get("chargeItemCode").toString());
|
|
|
+ receipt.setPriceTime(DateUtil.formatPriceTime(item.get("priceTime").toString()));
|
|
|
+ receipt.setUnitPrice(new BigDecimal(item.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
|
|
+ receipt.setQuantity((double) item.get("quantity"));
|
|
|
+ receipt.setDrugWin((int) item.get("drugWin"));
|
|
|
+ receipt.setDoctorCode(item.get("doctorCode").toString());
|
|
|
+ receipt.setDoctorName(doctorName);
|
|
|
+ receipt.setSerialNo(item.get("serialNo").toString());
|
|
|
+ receipt.setGroupNo(item.get("groupNo").toString());
|
|
|
+ receipt.setBillItemCode(item.get("billItemCode").toString());
|
|
|
+ receipt.setChargeBillCode(item.get("chargeBillCode").toString());
|
|
|
+ if (!orderReceiptsMap.containsKey(receipt.getOrderNo())) {
|
|
|
List<MzReceipt> list = new ArrayList<>();
|
|
|
- list.add(item);
|
|
|
- temp.put(item.getOrderNo(), list);
|
|
|
+ list.add(receipt);
|
|
|
+ orderReceiptsMap.put(receipt.getOrderNo(), list);
|
|
|
} else {
|
|
|
- temp.get(item.getOrderNo()).add(item);
|
|
|
+ orderReceiptsMap.get(receipt.getOrderNo()).add(receipt);
|
|
|
}
|
|
|
});
|
|
|
List<OrderNo> orderNos = new ArrayList<>();
|
|
|
- for (Map.Entry<Integer, List<MzReceipt>> entry : temp.entrySet()) {
|
|
|
+ for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
|
|
|
OrderNo orderNo = new OrderNo();
|
|
|
orderNo.setPatientId(patientId);
|
|
|
orderNo.setTimes(times);
|
|
|
- orderNo.setReceiptNo(mzVisit.getReceiptNo());
|
|
|
+ orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
|
|
|
orderNo.setOrderNo(entry.getKey());
|
|
|
BigDecimal total = new BigDecimal("0.00");
|
|
|
for (MzReceipt item : entry.getValue()) {
|
|
@@ -159,7 +212,7 @@ public class MarkMtFeesService {
|
|
|
orderNos.add(orderNo);
|
|
|
}
|
|
|
map.put("orderNos", orderNos);
|
|
|
- map.put("mzReceipts", temp);
|
|
|
+ map.put("mzReceipts", orderReceiptsMap);
|
|
|
return ResultVoUtil.success(map);
|
|
|
}
|
|
|
|