diff --git a/src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java b/src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java index 7a613c89..56d00570 100644 --- a/src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java @@ -34,8 +34,10 @@ import com.qs.serve.modules.tbs.entity.*; import com.qs.serve.modules.tbs.entity.dto.CusTargetRateDTO; import com.qs.serve.modules.tbs.entity.dto.TbsCostSubItem; import com.qs.serve.modules.tbs.mapper.*; +import com.qs.serve.modules.tzc.entity.TzcPolicy; import com.qs.serve.modules.tzc.entity.TzcPolicyItem; import com.qs.serve.modules.tzc.mapper.TzcPolicyItemMapper; +import com.qs.serve.modules.tzc.mapper.TzcPolicyMapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -64,9 +66,11 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { private BirActivityCenterGoodsMapper birActivityCenterGoodsMapper; private TbsActivityCenterMapper tbsActivityCenterMapper; private TzcPolicyItemMapper tzcPolicyItemMapper; + private TzcPolicyMapper tzcPolicyMapper; private TbsBudgetLogMapper tbsBudgetLogMapper; private BmsSupplierTargetMapper bmsSupplierTargetMapper; private TbsScheduleItemMapper tbsScheduleItemMapper; + private TbsCostApplyMapper tbsCostApplyMapper; @Override public List findCostCenterDataByCostApplyId(Long costApplyId,Long policyId){ @@ -78,11 +82,11 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { if (tbsActivityCenters.size() == 0) { return centerDataList; } - + TbsCostApply costApply = tbsCostApplyMapper.selectById(costApplyId); Map> centerMapList = tbsActivityCenters.stream().collect(Collectors.groupingBy(a -> a.getCenterType() + "-" + a.getCenterId())); List centerList = centerMapList.values().stream().map(a -> a.get(0)).collect(Collectors.toList()); for(TbsActivityCenter center : centerList) { - TbsCostSubItem.CostCenterTranStr costCenter = this.buildCostCenter(center.getCenterType(), center.getCenterId(), center.getCenterName()); + TbsCostSubItem.CostCenterTranStr costCenter = this.buildCostCenter(center.getCenterType(), center.getCenterId(), center.getCenterName(),costApply.getSupplierCode()); costCenter.setCenterId(center.getCenterId()); costCenter.setCentertype(center.getCenterType()); costCenter.setCenterCode(center.getCenterCode()); @@ -90,13 +94,14 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { } } if(policyId!=null) { + TzcPolicy policy = tzcPolicyMapper.selectById(policyId); LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(TzcPolicyItem::getPolicyId,policyId); List policyItems = tzcPolicyItemMapper.selectList(lqw); Map> centerMapList = policyItems.stream().collect(Collectors.groupingBy(a -> a.getCenterType() + "-" + a.getCenterId())); List centerList = centerMapList.values().stream().map(a -> a.get(0)).collect(Collectors.toList()); for(TzcPolicyItem center : centerList) { - TbsCostSubItem.CostCenterTranStr costCenter = this.buildCostCenter(center.getCenterType(), center.getCenterId(), center.getCenterName()); + TbsCostSubItem.CostCenterTranStr costCenter = this.buildCostCenter(center.getCenterType(), center.getCenterId(), center.getCenterName(),policy.getSupplierCode()); costCenter.setCenterId(center.getCenterId()); costCenter.setCentertype(center.getCenterType()); costCenter.setCenterCode(center.getCenterCode()); @@ -216,11 +221,12 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { } //创建客户的费率 if(StringUtils.hasText(supplierCode)){ - try { this.buildCustomerCenterTargetData(centerType, centerId, costCenter, supplierCode, dispatchSumVos); - } catch (Exception e) { - log.error("[{}]创建客户成本中心的费率出现异常:{}",supplierCode,e.getMessage()); - } +// try { +// this.buildCustomerCenterTargetData(centerType, centerId, costCenter, supplierCode, dispatchSumVos); +// } catch (Exception e) { +// log.error("[{}]创建客户成本中心的费率出现异常:{}",supplierCode,e.getMessage()); +// } } return costCenter; } @@ -285,11 +291,19 @@ public class BirCenterRateServiceImpl implements BirCenterRateService { //计算客户维度费率 costCenter.setQtdCusCenterCost(totalCostQty.toString()); costCenter.setQtdCusCenterSend(totalDispatchQty.toString()); - costCenter.setQtdCusCenterExpenseRate(totalCostQty.divide(totalDispatchQty,RoundingMode.DOWN).toString()); + String qtyCusCenterRateString = null; + if(totalDispatchQty.compareTo(BigDecimal.ZERO) != 0){ + qtyCusCenterRateString = totalCostQty.divide(totalDispatchQty,RoundingMode.DOWN).toString(); + } + costCenter.setQtdCusCenterExpenseRate(qtyCusCenterRateString); costCenter.setQtdCusCenterTargetExpenseRate(targetRateDTO.getCusTargetRateQty()); costCenter.setYtdCusCenterCost(totalCostYear.toString()); costCenter.setYtdCusCenterSend(totalDispatchYear.toString()); - costCenter.setYtdCusCenterExpenseRate(totalCostYear.divide(totalDispatchYear,RoundingMode.DOWN).toString()); + String ytdCusCenterRateString = null; + if(totalDispatchYear.compareTo(BigDecimal.ZERO) != 0){ + ytdCusCenterRateString = totalCostYear.divide(totalDispatchYear,RoundingMode.DOWN).toString(); + } + costCenter.setYtdCusCenterExpenseRate(ytdCusCenterRateString); costCenter.setYtdCusCenterTargetExpenseRate(targetRateDTO.getCusTargetRate()); } diff --git a/src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml b/src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml index 3a727155..ad391a56 100644 --- a/src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml +++ b/src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml @@ -160,11 +160,13 @@ key_num, sum(split_amount) as total_cost_amt, sum(split_release_amount) as total_release_amt, - sum(split_used_amount) as total_used_amt, + sum(split_used_amount) as total_used_amt from bir_activity_center_goods - where supplier_code = '' - and center_type = '' - and center_code = '' + where supplier_code = #{query.supplierCode} + and center_type = #{query.centerType} + and center_id = #{query.centerId} + and key_num <=#{query.endYearMonth} + and key_num >=#{query.startYearMonth} group by key_num diff --git a/src/main/resources/mapper/vtb/VtbVerReportMapper.xml b/src/main/resources/mapper/vtb/VtbVerReportMapper.xml index 87fdbb95..dcc27b6d 100644 --- a/src/main/resources/mapper/vtb/VtbVerReportMapper.xml +++ b/src/main/resources/mapper/vtb/VtbVerReportMapper.xml @@ -12,8 +12,8 @@ and tbs_cost_apply.cancel_flag = 0 and `tbs_activity`.`activity_code` like concat('%',#{query.activityCode},'%') and `tbs_activity`.`act_title` like concat('%',#{query.activityTitle},'%') - and `tbs_cost_apply`.`submit_time` >= #{query.queryStartSubmitTime} - and `tbs_cost_apply`.`submit_time` <= #{query.queryEndSubmitTime} + and `tbs_cost_apply`.`submit_time` >= #{query.queryStartSubmitTime} + and `tbs_cost_apply`.`submit_time` <= #{query.queryEndSubmitTime} and `tbs_cost_apply`.`supplier_code` like concat('%',#{query.supplierCode},'%') and `tbs_cost_apply`.`supplier_name` like concat('%',#{query.supplierName},'%') and `tbs_cost_apply`.`code` like concat('%',#{query.costApplyCode},'%')