|
|
@ -359,6 +359,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> budgetLogLqw = new LambdaQueryWrapper<>(); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); |
|
|
|
budgetLogLqw.eq(TbsBudgetLog::getOptType,1); |
|
|
|
List<TbsBudgetLog> budgetLogList = tbsBudgetLogMapper.selectList(budgetLogLqw); |
|
|
|
for (TbsBudgetLog budgetLog : budgetLogList) { |
|
|
|
for (TbsActivityCenterGoods centerGoods : activityCenterGoodsList) { |
|
|
@ -366,49 +367,13 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
&&budgetLog.getSubjectId().equals(centerGoods.getSubjectId()) |
|
|
|
&& budgetLog.getCenterType().equals(centerGoods.getCenterType()) |
|
|
|
&& budgetLog.getCenterId().equals(centerGoods.getCenterId()) |
|
|
|
&& budgetLog.getTargetId().equals(centerGoods.getTargetId()) |
|
|
|
){ |
|
|
|
budgetLog.setAmount(centerGoods.getCenterGoodsAmount().negate()); |
|
|
|
tbsBudgetLogMapper.updateById(budgetLog); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// //修改预算占用
|
|
|
|
// TbsActivityCenterGoodsService tbsActivityCenterGoodsService = SpringUtils.getBean(TbsActivityCenterGoodsService.class);
|
|
|
|
// List<TbsActivityCenterGoods> activityCenterGoodsList = tbsActivityCenterGoodsService.listByCostApplyId(costApply.getId());
|
|
|
|
// //查询当前预算占用
|
|
|
|
// LambdaQueryWrapper<TbsBudgetLog> logLqw = new LambdaQueryWrapper<>();
|
|
|
|
// logLqw.eq(TbsBudgetLog::getRollbackFlag,BudgetLogRollbackFlag.State_0);
|
|
|
|
// logLqw.eq(TbsBudgetLog::getCostApplyId, costApply.getId());
|
|
|
|
// logLqw.and(qw->{
|
|
|
|
// qw.eq(TbsBudgetLog::getOptType,BudgetLogOptFlag.State_1.getCode()).or()
|
|
|
|
// .eq(TbsBudgetLog::getOptType,BudgetLogOptFlag.State_6.getCode());
|
|
|
|
// });
|
|
|
|
// //设置为回滚完成,防止出现多次查询
|
|
|
|
// List<TbsBudgetLog> budgetLogList = tbsBudgetLogService.list(logLqw);
|
|
|
|
// budgetLogList.forEach(bl->{
|
|
|
|
// bl.setRollbackFlag(BudgetLogRollbackFlag.State_2);
|
|
|
|
// });
|
|
|
|
// tbsBudgetLogService.updateBatchById(budgetLogList);
|
|
|
|
// //移除旧预算占用,即添预算
|
|
|
|
// budgetLogList.forEach(bl->{
|
|
|
|
// bl.setId(null);
|
|
|
|
// bl.setOptType(BudgetLogOptFlag.State_5.getCode());
|
|
|
|
// bl.setAmount(bl.getAmount().negate());
|
|
|
|
// bl.setCreateBy(null);
|
|
|
|
// bl.setCreateTime(null);
|
|
|
|
// bl.setUpdateTime(null);
|
|
|
|
// bl.setUpdateBy(null);
|
|
|
|
// });
|
|
|
|
// tbsBudgetLogService.saveBatch(budgetLogList);
|
|
|
|
// //保存新的预算占用
|
|
|
|
// SysUser sysUser = sysUserService.getById(costApply.getUserId());
|
|
|
|
// List<TbsBudgetCostItem> budgetCostItemList = tbsBudgetCostItemService.listByCostApplyId(costApply.getId());
|
|
|
|
// List<Long> budgetIds = budgetCostItemList.stream().map(TbsBudgetCostItem::getBudgetId).collect(Collectors.toList());
|
|
|
|
// List<TbsBudget> budgetList = tbsBudgetMapper.selectBatchIds(budgetIds);
|
|
|
|
// List<TbsBudgetLog> newBudgetLogList = this.createNewBudgetLogs(costApply, activityCenterGoodsList, sysUser, budgetCostItemList, budgetList);
|
|
|
|
// tbsBudgetLogService.saveBatch(newBudgetLogList);
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -481,7 +446,6 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
//初始化重新计算
|
|
|
|
activityList.forEach(a->a.setTotalAmount(BigDecimal.ZERO)); |
|
|
|
//先计算科目的费用
|
|
|
|
List<TbsActivitySubjectYarn> subjectYarnList = new ArrayList<>(); |
|
|
|
for (TbsActivitySubject subject : activitySubjectList) { |
|
|
|
for (TbsAffairCommitBo.AffairSubjectLine subjectLine : param.getAffairSubjectLines()) { |
|
|
|
if(subjectLine.getSubjectId().equals(subject.getId())){ |
|
|
@ -498,7 +462,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
TbsActivitySubjectYarn subjectYarn = this.createActivitySubjectYarn(param, sysUser, costApply, subject, subjectLine, currActivity); |
|
|
|
tbsActivitySubjectYarnMapper.insert(subjectYarn); |
|
|
|
if(noChanged){ |
|
|
|
//只对第一次赋值
|
|
|
|
//审批期间,只对第一次审批赋值
|
|
|
|
subject.setOrgAmount(subject.getAmount()); |
|
|
|
} |
|
|
|
subject.setAmount(subjectAmount); |
|
|
@ -563,7 +527,11 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
*/ |
|
|
|
private void changeActivityCenterGoodsAmt(boolean noChanged, List<TbsActivityCenter> activityCenterList, List<TbsActivityCenterGoods> activityCenterGoodsList, TbsActivitySubject subject, BigDecimal subjectAmount) { |
|
|
|
BigDecimal n100 = new BigDecimal("100"); |
|
|
|
for (TbsActivityCenter activityCenter : activityCenterList) { |
|
|
|
|
|
|
|
BigDecimal subjectAmountSpuir = subjectAmount; |
|
|
|
|
|
|
|
for (int ii = 0; ii < activityCenterList.size(); ii++) { |
|
|
|
TbsActivityCenter activityCenter = activityCenterList.get(ii); |
|
|
|
boolean eqActivity = activityCenter.getActivityId().equals(subject.getActivityId()); |
|
|
|
boolean eqSubject = activityCenter.getSubjectId().equals(subject.getSubjectId()); |
|
|
|
if(eqActivity&&eqSubject){ |
|
|
@ -573,32 +541,40 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
//只对第一次赋值
|
|
|
|
activityCenter.setOrgCenterAmount(activityCenter.getCenterAmount()); |
|
|
|
} |
|
|
|
activityCenter.setCenterAmount(centerAmt); |
|
|
|
if(ii+1 == activityCenterList.size()){ |
|
|
|
activityCenter.setCenterAmount(subjectAmountSpuir); |
|
|
|
}else { |
|
|
|
subjectAmountSpuir = subjectAmountSpuir.subtract(centerAmt); |
|
|
|
activityCenter.setCenterAmount(centerAmt); |
|
|
|
} |
|
|
|
activityCenterMapper.updateById(activityCenter); |
|
|
|
//计算成本中心下的商品
|
|
|
|
BigDecimal tmpCenterAmt = centerAmt; |
|
|
|
for (int i = 0; i < activityCenterGoodsList.size(); i++) { |
|
|
|
TbsActivityCenterGoods centerGoods = activityCenterGoodsList.get(i); |
|
|
|
BigDecimal tmpCenterAmt = activityCenter.getCenterAmount(); |
|
|
|
|
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsTmpList = activityCenterGoodsList.stream().filter(centerGoods->{ |
|
|
|
boolean eqActivity4Goods = centerGoods.getActivityId().equals(activityCenter.getActivityId()); |
|
|
|
boolean eqCenter4Goods = centerGoods.getCenterType().equals(activityCenter.getCenterType()) |
|
|
|
&¢erGoods.getCenterId().equals(activityCenter.getCenterId()); |
|
|
|
boolean eqSubject4Goods = centerGoods.getSubjectId().equals(activityCenter.getSubjectId()); |
|
|
|
if(eqActivity4Goods&&eqCenter4Goods&&eqSubject4Goods){ |
|
|
|
if(noChanged){ |
|
|
|
//只对第一次赋值
|
|
|
|
centerGoods.setOrgCenterAmount(activityCenter.getCenterAmount()); |
|
|
|
centerGoods.setOrgCenterGoodsAmount(centerGoods.getCenterGoodsAmount()); |
|
|
|
} |
|
|
|
centerGoods.setCenterAmount(centerAmt); |
|
|
|
BigDecimal centerGoodAmt = null; |
|
|
|
if(i+1== activityCenterGoodsList.size()){ |
|
|
|
centerGoodAmt = tmpCenterAmt; |
|
|
|
}else { |
|
|
|
centerGoodAmt = centerAmt.multiply(centerGoods.getCenterGoodsRate()).divide(n100,2,RoundingMode.HALF_DOWN); |
|
|
|
tmpCenterAmt = tmpCenterAmt.subtract(centerGoodAmt); |
|
|
|
} |
|
|
|
centerGoods.setCenterGoodsAmount(centerGoodAmt); |
|
|
|
return eqActivity4Goods&&eqCenter4Goods&&eqSubject4Goods; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
for (int i = 0; i < activityCenterGoodsTmpList.size(); i++) { |
|
|
|
TbsActivityCenterGoods centerGoods = activityCenterGoodsTmpList.get(i); |
|
|
|
if(noChanged){ |
|
|
|
//只对第一次赋值
|
|
|
|
centerGoods.setOrgCenterAmount(activityCenter.getCenterAmount()); |
|
|
|
centerGoods.setOrgCenterGoodsAmount(centerGoods.getCenterGoodsAmount()); |
|
|
|
} |
|
|
|
centerGoods.setCenterAmount(centerAmt); |
|
|
|
BigDecimal centerGoodAmt = null; |
|
|
|
if(i+1== activityCenterGoodsTmpList.size()){ |
|
|
|
centerGoodAmt = tmpCenterAmt; |
|
|
|
}else { |
|
|
|
centerGoodAmt = centerAmt.multiply(centerGoods.getCenterGoodsRate()).divide(n100,2,RoundingMode.HALF_DOWN); |
|
|
|
tmpCenterAmt = tmpCenterAmt.subtract(centerGoodAmt); |
|
|
|
} |
|
|
|
centerGoods.setCenterGoodsAmount(centerGoodAmt); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|