Browse Source

联合成本中心修改客户公司维度;

v1.0
Yen 2 years ago
parent
commit
16d6e45fc5
  1. 2
      src/main/java/com/qs/serve/modules/bir/entity/so/BirMonthCusCenterSo.java
  2. 32
      src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java
  3. 6
      src/main/java/com/qs/serve/modules/bir/service/impl/BirRoiRateServiceImpl.java
  4. 2
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java
  5. 12
      src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml

2
src/main/java/com/qs/serve/modules/bir/entity/so/BirMonthCusCenterSo.java

@ -1,6 +1,7 @@
package com.qs.serve.modules.bir.entity.so;
import lombok.Data;
import java.util.List;
/**
* @author YenHex
@ -14,5 +15,6 @@ public class BirMonthCusCenterSo {
String centerId;
Integer startYearMonth;
Integer endYearMonth;
List<String> supplierCodeList;
}

32
src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java

@ -71,6 +71,7 @@ public class BirCenterRateServiceImpl implements BirCenterRateService {
private BmsSupplierTargetMapper bmsSupplierTargetMapper;
private TbsScheduleItemMapper tbsScheduleItemMapper;
private TbsCostApplyMapper tbsCostApplyMapper;
private BmsSupplierMapper supplierMapper;
@Override
public List<TbsCostSubItem.CostCenterTranStr> findCostCenterDataByCostApplyId(Long costApplyId,Long policyId){
@ -250,22 +251,35 @@ public class BirCenterRateServiceImpl implements BirCenterRateService {
int startMonth = Integer.parseInt(curYear+"01");
int endMonth = Integer.parseInt(curYear+curMonthString);
int[] currQ = MonthValues.getQArr(curMonth);
//更变客户维度为总公司维度
List<String> supplierCode4Group = new ArrayList<>();
supplierCode4Group.add(supplierCode);
LambdaQueryWrapper<BmsSupplier> supplierLqw = new LambdaQueryWrapper<>();
supplierLqw.eq(BmsSupplier::getCode,supplierCode);
BmsSupplier supplier = supplierMapper.selectOne(supplierLqw);
if(supplier.getComRegionCode()!=null){
LambdaQueryWrapper<BmsSupplier> supplierLqw4Group = new LambdaQueryWrapper<>();
supplierLqw4Group.eq(BmsSupplier::getComRegionCode,supplier.getComRegionCode());
List<BmsSupplier> supplierList = supplierMapper.selectList(supplierLqw4Group);
for (BmsSupplier bmsSupplier : supplierList) {
supplierCode4Group.add(bmsSupplier.getCode());
}
}
BirMonthCusCenterSo queryCusCenterRate = new BirMonthCusCenterSo();
queryCusCenterRate.setSupplierCode(supplierCode);
queryCusCenterRate.setSupplierCodeList(supplierCode4Group);
queryCusCenterRate.setCenterType(centerType);
queryCusCenterRate.setCenterId(centerId);
queryCusCenterRate.setStartYearMonth(startMonth);
queryCusCenterRate.setEndYearMonth(endMonth);
//年目标费率
CusTargetRateDTO targetRateDTO = this.buildCusCenterTargetData(supplierCode);
CusTargetRateDTO targetRateDTO = this.buildCusCenterTargetData(supplierCode4Group);
List<BirActivityCenterGoodsMonthVo> centerGoodsMonthVoList = birActivityCenterGoodsMapper.listMonthCusCenterVo(queryCusCenterRate);
BigDecimal totalCostQty = BigDecimal.ZERO;
BigDecimal totalDispatchQty = BigDecimal.ZERO;
List<String> supplierCodeList = new ArrayList<>();
supplierCodeList.add(supplierCode);
List<ErpDispatchSumVo> dispatchSumVos = dispatchDataMapper.querySumCost(startMonth,endMonth,supplierCodeList);
List<ErpDispatchSumVo> dispatchSumVos = dispatchDataMapper.querySumCost(startMonth,endMonth,supplierCode4Group);
for (int monthNumber : currQ) {
String tmp = monthNumber>9?monthNumber+"":"0"+monthNumber;
int currYearMonth = Integer.parseInt(curYear+tmp);
@ -312,10 +326,10 @@ public class BirCenterRateServiceImpl implements BirCenterRateService {
/**
* 计算客户目标费率
* @param supplierCode
* @param supplierCodes
* @return
*/
public CusTargetRateDTO buildCusCenterTargetData(String supplierCode){
public CusTargetRateDTO buildCusCenterTargetData(List<String> supplierCodes){
String cusTargetRateQty=null;
String cusTargetRate=null;
LocalDate nowTime = LocalDate.now();
@ -324,7 +338,7 @@ public class BirCenterRateServiceImpl implements BirCenterRateService {
int[] currQ = MonthValues.getQArr(curMonth);
List<BmsSupplierTarget> supplierTargetList = bmsSupplierTargetMapper.selectList(
new LambdaQueryWrapper<BmsSupplierTarget>()
.in(BmsSupplierTarget::getSupplierCode, supplierCode)
.in(BmsSupplierTarget::getSupplierCode, supplierCodes)
);
List<Long> scheduleItemIds = supplierTargetList.stream().map(BmsSupplierTarget::getScheduleItemId).collect(Collectors.toList());
List<Long> scheduleIds = supplierTargetList.stream().map(BmsSupplierTarget::getScheduleId).collect(Collectors.toList());

6
src/main/java/com/qs/serve/modules/bir/service/impl/BirRoiRateServiceImpl.java

@ -196,7 +196,7 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa
private void buildRegionCostAndRate(BmsSupplier supplier, int currMonthNum, int startMonthNum, List<String> supplierCodeList, List<BirRoiCostItemVo> costItemVoList) {
//加载公司内所有客户的编码
LambdaQueryWrapper<BmsSupplier> regionSupplierLqw = new LambdaQueryWrapper<>();
regionSupplierLqw.eq(BmsSupplier::getComRegionCode, supplier.getComRegion());
regionSupplierLqw.eq(BmsSupplier::getRegionFirst, supplier.getRegionFirst());
regionSupplierLqw.select(BmsSupplier::getId,BmsSupplier::getCode);
List<BmsSupplier> regionSupplierList = bmsSupplierMapper.selectList(regionSupplierLqw);
List<String> regionSupplierIds = regionSupplierList.stream().map(BmsSupplier::getId).collect(Collectors.toList());
@ -444,7 +444,9 @@ public class BirRoiRateServiceImpl extends ServiceImpl<BirRoiRateMapper,BirRoiRa
}
}else if(loadType.equals(4)){
//4->公司维度统计
lqw.eq(BmsSupplier::getComRegionCode,bmsSupplier.getComRegionCode());
lqw.eq(BmsSupplier::getComRegionCode,bmsSupplier.getComRegionCode()==null?"-1":bmsSupplier.getComRegionCode());
//防止空值
supplierCodeList.add(bmsSupplier.getCode());
}
if (loadType.equals(2)||loadType.equals(3)||loadType.equals(4)){
List<BmsSupplier> supplierList = bmsSupplierMapper.selectList(lqw);

2
src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java

@ -68,11 +68,9 @@ public class TbsCostApplyController {
private final TbsActivityCenterGoodsService activityCenterGoodsService;
private final TbsActivityChannelService activityChannelService;
private final TbsActivityChannelPointService activityChannelPointService;
private TbsBudgetLogService tbsBudgetLogService;
private BmsSupplierService bmsSupplierService;
private BmsRegion2Service region2Service;
private SysUserService sysUserService;
private SeeYonRequestService seeYonService;
private TbsBudgetApplicationService budgetApplicationService;
private SysPostUserService postUserService;
private TbsCostApplyOperationServiceImpl tbsCostApplyOperationServiceImpl;

12
src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml

@ -158,7 +158,17 @@
sum(split_release_amount) as total_release_amt,
sum(split_used_amount) as total_used_amt
from bir_activity_center_goods
where supplier_code = #{query.supplierCode}
where
1=1
<if test="query.supplierCode!=null and query.supplierCode != ''">
and supplier_code = #{query.supplierCode}
</if>
<if test="query.supplierCodeList!=null and query.supplierCodeList.size > 0">
and supplier_code in
<foreach collection="query.supplierCodeList" item ="selectCode" index="i" open="(" close=")" separator=",">
#{selectCode}
</foreach>
</if>
and center_type = #{query.centerType}
and center_id = #{query.centerId}
and key_num &lt;=#{query.endYearMonth}

Loading…
Cancel
Save