|
|
@ -29,10 +29,7 @@ import com.qs.serve.modules.tbs.common.dto.CompensateDTO; |
|
|
|
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil; |
|
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
|
import com.qs.serve.modules.tbs.entity.bo.*; |
|
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetScheduleWithAmount; |
|
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostBudgetRelateInfo; |
|
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostErrorBudgetDTO; |
|
|
|
import com.qs.serve.modules.tbs.entity.dto.*; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.CtpAffairVo; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsCostApplyVo; |
|
|
@ -532,10 +529,97 @@ public class TbsCostApplyController { |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("rebuildBudgetLog") |
|
|
|
public void dealCostBudget(Long costApplyId){ |
|
|
|
public R dealCostBudget(Long costApplyId){ |
|
|
|
if(costApplyId!=null){ |
|
|
|
rebuildBudgetLog(costApplyId); |
|
|
|
return R.ok(); |
|
|
|
} |
|
|
|
List<TbsCostErrorBudgetDTO> costErrorBudgetDTOList = tbsCostApplyMapper.selectCostErrorBudgetDTO(); |
|
|
|
for (TbsCostErrorBudgetDTO budgetDTO : costErrorBudgetDTOList) { |
|
|
|
Long costApplyId2 = budgetDTO.getId(); |
|
|
|
rebuildBudgetLog(costApplyId2); |
|
|
|
} |
|
|
|
return R.ok(); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("rebuildBudgetLog3") |
|
|
|
public void dealCostBudget3(){ |
|
|
|
List<TbsCostErrorBudgetDTO> costErrorBudgetDTOList = tbsCostApplyMapper.selectCostErrorBudgetDTO(); |
|
|
|
for (TbsCostErrorBudgetDTO budgetDTO : costErrorBudgetDTOList) { |
|
|
|
rebuildBudgetLog(budgetDTO.getId()); |
|
|
|
Long costApplyId = budgetDTO.getId(); |
|
|
|
centerGoodsAmtToBudgetLog(costApplyId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("flushActivityCenterGoodsAmount") |
|
|
|
public void flushActivityCenterGoodsAmount(){ |
|
|
|
//List<TbsCostErrorBudgetDTO> costErrorBudgetDTOList = tbsCostApplyMapper.selectCostErrorBudgetDTO();
|
|
|
|
//过滤大额错误订单
|
|
|
|
// costErrorBudgetDTOList = costErrorBudgetDTOList.stream().filter(a->a.getTotalActivityAmount()
|
|
|
|
// .subtract(a.getSumBudget())
|
|
|
|
// .abs()
|
|
|
|
// .compareTo(BigDecimal.ONE)<1).collect(Collectors.toList());
|
|
|
|
//List<Long> costApplyIds = costErrorBudgetDTOList.stream().map(TbsCostErrorBudgetDTO::getId).distinct().collect(Collectors.toList());
|
|
|
|
List<Long> costApplyIds = new ArrayList<>(); |
|
|
|
costApplyIds.add(263925L); |
|
|
|
costApplyIds.add(263930L); |
|
|
|
costApplyIds.add(270102L); |
|
|
|
List<TbsActNotMatchAmtCenterGoods> notMatchAmtCenterGoodsList = activityCenterGoodsService.listNotMatchAmtCenterGoods(costApplyIds); |
|
|
|
List<Long> activityIds = notMatchAmtCenterGoodsList.stream().map(a->a.getActivityId()).collect(Collectors.toList()); |
|
|
|
for (Long activityId : activityIds) { |
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsList = activityCenterGoodsService.listByActivityId(activityId); |
|
|
|
Map<String,List<TbsActivityCenterGoods>> stringListMap = activityCenterGoodsList.stream() |
|
|
|
.collect(Collectors.groupingBy(a->a.getSubjectId()+"_"+a.getCenterType()+"_"+a.getCenterId())); |
|
|
|
for (String key : stringListMap.keySet()) { |
|
|
|
List<TbsActivityCenterGoods> list = stringListMap.get(key); |
|
|
|
BigDecimal totalAmountOfCenter = list.get(0).getCenterAmount(); |
|
|
|
BigDecimal totalCenterGoods = BigDecimal.ZERO; |
|
|
|
for (TbsActivityCenterGoods centerGoods : list) { |
|
|
|
totalCenterGoods = totalCenterGoods.add(centerGoods.getCenterGoodsAmount()); |
|
|
|
} |
|
|
|
BigDecimal diff = totalAmountOfCenter.subtract(totalCenterGoods); |
|
|
|
if(diff.compareTo(BigDecimal.ZERO)!=0&&diff.compareTo(BigDecimal.ONE)<0){ |
|
|
|
TbsActivityCenterGoods centerGoods = list.get(0); |
|
|
|
centerGoods.setCenterGoodsAmount(centerGoods.getCenterGoodsAmount().add(diff)); |
|
|
|
activityCenterGoodsService.updateById(centerGoods); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void centerGoodsAmtToBudgetLog(Long costApplyId) { |
|
|
|
LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>(); |
|
|
|
logLqw.eq(TbsBudgetLog::getCostApplyId, costApplyId); |
|
|
|
logLqw.lt(TbsBudgetLog::getOptType,7); |
|
|
|
List<TbsBudgetLog> budgetLogList = tbsBudgetLogMapper.selectList(logLqw); |
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsList = activityCenterGoodsService.listByCostApplyId(costApplyId); |
|
|
|
if(budgetLogList.size()==activityCenterGoodsList.size()){ |
|
|
|
List<TbsBudgetLog> updBudgetLogList = new ArrayList<>(); |
|
|
|
for (TbsBudgetLog budgetLog : budgetLogList) { |
|
|
|
TbsBudgetLog tmpObject = null; |
|
|
|
for (TbsActivityCenterGoods centerGoods : activityCenterGoodsList) { |
|
|
|
if(budgetLog.getActivityId().equals(centerGoods.getActivityId()) |
|
|
|
&&budgetLog.getSubjectId().equals(centerGoods.getSubjectId()) |
|
|
|
&&budgetLog.getCenterType().equals(centerGoods.getCenterType()) |
|
|
|
&&budgetLog.getCenterId().equals(centerGoods.getCenterId()) |
|
|
|
&&budgetLog.getTargetId().equals(centerGoods.getTargetId()) |
|
|
|
//&&budgetLog.getScheduleItemBudgetId().equals(centerGoods.getScheduleItemBudgetId())
|
|
|
|
){ |
|
|
|
budgetLog.setAmount(centerGoods.getCenterGoodsAmount().negate()); |
|
|
|
tmpObject = budgetLog; |
|
|
|
//tbsBudgetLogMapper.updateById(budgetLog);
|
|
|
|
} |
|
|
|
} |
|
|
|
if(tmpObject==null){ |
|
|
|
break; |
|
|
|
} |
|
|
|
updBudgetLogList.add(tmpObject); |
|
|
|
} |
|
|
|
if(updBudgetLogList.size()== budgetLogList.size()){ |
|
|
|
for (TbsBudgetLog budgetLog : updBudgetLogList) { |
|
|
|
tbsBudgetLogMapper.updateById(budgetLog); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -594,28 +678,21 @@ public class TbsCostApplyController { |
|
|
|
log.error("{}金额错误",costApply.getId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
BigDecimal costAmountBudget = tbsCostApplyMapper.sumCostAmountBudget(costApplyId); |
|
|
|
|
|
|
|
//判断合计金额与预算是否有差距过大
|
|
|
|
boolean diffCostBudget = costAmt.subtract(costAmountBudget).intValue()!=0; |
|
|
|
if(diffCostBudget){ |
|
|
|
//判断是否有释放,没有直接清理(后续可修改为全部清理)
|
|
|
|
//BigDecimal costAmountBudget = tbsCostApplyMapper.sumCostAmountBudget(costApplyId);
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> budgetLogRmLqw = new LambdaQueryWrapper<>(); |
|
|
|
budgetLogRmLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); |
|
|
|
budgetLogRmLqw.ne(TbsBudgetLog::getOptType,1); |
|
|
|
tbsBudgetLogMapper.delete(budgetLogRmLqw); |
|
|
|
//判断是否有释放,没有直接清理(后续可修改为全部清理)
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> budgetLogLqw = new LambdaQueryWrapper<>(); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getOptType,1); |
|
|
|
List<TbsBudgetLog> budgetLogList = tbsBudgetLogMapper.selectList(budgetLogLqw); |
|
|
|
LambdaQueryWrapper<TbsBudgetLog> budgetLogLqw = new LambdaQueryWrapper<>(); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getOptType,1); |
|
|
|
List<TbsBudgetLog> budgetLogList = tbsBudgetLogMapper.selectList(budgetLogLqw); |
|
|
|
|
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsList = tbsActivityCenterGoodsService.listByCostApplyId(costApplyId); |
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsList = tbsActivityCenterGoodsService.listByCostApplyId(costApplyId); |
|
|
|
|
|
|
|
List<Long> updateLogIdsList = new ArrayList<>(); |
|
|
|
updateLogIdsList.add(0L); |
|
|
|
List<Long> updateLogIdsList = new ArrayList<>(); |
|
|
|
updateLogIdsList.add(0L); |
|
|
|
|
|
|
|
if(activityCenterGoodsList.size()==budgetLogList.size()){ |
|
|
|
for (TbsActivityCenterGoods centerGoods : activityCenterGoodsList) { |
|
|
|
for (TbsBudgetLog budgetLog : budgetLogList) { |
|
|
|
if( budgetLog.getActivityId().equals(centerGoods.getActivityId()) |
|
|
@ -631,9 +708,14 @@ public class TbsCostApplyController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
budgetLogLqw.notIn(TbsBudgetLog::getId,updateLogIdsList); |
|
|
|
tbsBudgetLogMapper.delete(budgetLogLqw); |
|
|
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> delBudgetLogLqw = new LambdaQueryWrapper<>(); |
|
|
|
delBudgetLogLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); |
|
|
|
delBudgetLogLqw.notIn(TbsBudgetLog::getId,updateLogIdsList); |
|
|
|
tbsBudgetLogMapper.delete(delBudgetLogLqw); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|