|
|
@@ -3,6 +3,9 @@ package cn.hnthyy.thmz.service.impl.thmz;
|
|
|
import cn.hnthyy.thmz.Utils.AssertUtil;
|
|
|
import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
import cn.hnthyy.thmz.Utils.JsonUtil;
|
|
|
+import cn.hnthyy.thmz.common.Constants;
|
|
|
+import cn.hnthyy.thmz.common.exception.BizException;
|
|
|
+import cn.hnthyy.thmz.entity.MzException;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.JcJyItemCharge;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzYjReq;
|
|
|
@@ -52,6 +55,9 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
@SuppressWarnings("all")
|
|
|
@Autowired
|
|
|
private ZdUnitCodeService zdUnitCodeService;
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ @Autowired
|
|
|
+ private JcJyItemChargeService jcJyItemChargeService;
|
|
|
|
|
|
/**
|
|
|
* 缓存
|
|
|
@@ -121,7 +127,13 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
|
|
|
@Override
|
|
|
public List<Discount> queryDiscountWithPage(Discount discount) {
|
|
|
- return discountMapper.selectDiscountWithPage(discount);
|
|
|
+ List<Discount> discounts = discountMapper.selectDiscountWithPage(discount);
|
|
|
+ for(Discount item :discounts){
|
|
|
+ if (item.getTemplateId() != null) {
|
|
|
+ item.setTcFee(getTcFee(item.getTemplateId(),item.getDiscountRate()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return discounts;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -352,14 +364,19 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<Discount> queryTcByDeptCode(Discount discount) {
|
|
|
- AssertUtil.isNotBlank(discount.getDeptType(),"科室类型不能为空");
|
|
|
+ AssertUtil.isNotBlank(discount.getDeptType(), "科室类型不能为空");
|
|
|
List<Discount> discounts = discountMapper.queryTcDiscunt();
|
|
|
if (CollUtil.isEmpty(discounts)) return discounts;
|
|
|
if (discount.getDeptType() == 2) {
|
|
|
- return discounts.stream().filter(item -> item.getDeptType() == 2).collect(Collectors.toList());
|
|
|
- }else {
|
|
|
- AssertUtil.isNotBlank(discount.getDeptNo(),"科室编码不能为空");
|
|
|
- return discounts.stream().filter(item -> (item.getDeptType() == 0 || item.getDeptType() == 1) && equalsDeptNo(item.getDeptNo(), discount.getDeptNo())).collect(Collectors.toList());
|
|
|
+ List<Discount> collect = discounts.stream().filter(item -> item.getDeptType() == 2).collect(Collectors.toList());
|
|
|
+ collect.forEach(item -> item.setTcFee(getTcFee(item.getTemplateId(), item.getDiscountRate())));
|
|
|
+ return collect;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ AssertUtil.isNotBlank(discount.getDeptNo(), "科室编码不能为空");
|
|
|
+ List<Discount> collect = discounts.stream().filter(item -> (item.getDeptType() == 0 || item.getDeptType() == 1) && equalsDeptNo(item.getDeptNo(), discount.getDeptNo())).collect(Collectors.toList());
|
|
|
+ collect.forEach(item -> item.setTcFee(getTcFee(item.getTemplateId(), item.getDiscountRate())));
|
|
|
+ return collect;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -373,6 +390,41 @@ public class DiscountServiceImpl implements DiscountService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public BigDecimal getTcFee(Long templateId,BigDecimal discountRate) {
|
|
|
+ BigDecimal yjTotalFee = BigDecimal.ZERO;
|
|
|
+ BigDecimal xmTotalFee = BigDecimal.ZERO;
|
|
|
+ Template template = templateService.queryById(templateId);
|
|
|
+ if (template != null && StrUtil.isNotBlank(template.getTemplateData())) {
|
|
|
+ MzPrescriptionVo mzPrescriptionVo = (MzPrescriptionVo) JsonUtil.jsontoObject(template.getTemplateData(), MzPrescriptionVo.class);
|
|
|
+ if(CollUtil.isNotEmpty(mzPrescriptionVo.getMzYjReqList())){
|
|
|
+ for(MzYjReq mzYjReq :mzPrescriptionVo.getMzYjReqList()){
|
|
|
+ List<ZdChargeItem> zdChargeItems = null;
|
|
|
+ try {
|
|
|
+ zdChargeItems = jcJyItemChargeService.queryJcJyItemChargeByCode(mzYjReq.getOrderCode(), Integer.valueOf(Convert.toInt(mzYjReq.getReqType())-1));
|
|
|
+ if(CollUtil.isNotEmpty(zdChargeItems)){
|
|
|
+ yjTotalFee = zdChargeItems.stream().map(item -> item.getTotalAmount().multiply(discountRate)).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
+ }catch (MzException e){
|
|
|
+ throw new BizException(e.getMessage(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(mzPrescriptionVo.getMzChargeDetailList())){
|
|
|
+ for(MzChargeDetail mzChargeDetail : mzPrescriptionVo.getMzChargeDetailList()){
|
|
|
+ if(mzChargeDetail.getBillItemCode().equals(Constants.TC)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal unitPrice = mzChargeDetail.getUnitPrice().multiply(discountRate);
|
|
|
+ xmTotalFee = unitPrice.multiply(BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BigDecimal totalFee = yjTotalFee.add(xmTotalFee);
|
|
|
+ return totalFee.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param templateId
|
|
|
* @description:根据模板id 查询项目明细
|