diff --git a/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java b/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java index 668a2729..13b5a93b 100644 --- a/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java +++ b/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java @@ -57,6 +57,16 @@ public class TbsCostApplyCheckController { private TbsCostApplyService tbsCostApplyService; private TbsCostApplyOperationServiceImpl tbsCostApplyOperationServiceImpl; + /** + * 测试接口(正式环境无法调用) + * @return + */ + @GetMapping("devDoFinished") + public R devDoFinished(String costApplyId){ + TbsAffairCommitBo commitBo = new TbsAffairCommitBo(); + //commitBo.setTargetId(); + return R.ok(); + } /** * 统计即将逾期 @@ -111,6 +121,8 @@ public class TbsCostApplyCheckController { @PreAuthorize("hasRole('tbs:costApply:commit')") public R commitAffair(@RequestBody @Valid TbsAffairCommitBo affairCommit){ return tbsCostApplyOperationServiceImpl.commitAffair(affairCommit); + //tbsCostApplyOperationServiceImpl.doFinished(affairCommit); + //return R.ok(); } /** diff --git a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java index 9c71b9c7..ed780929 100644 --- a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java @@ -439,6 +439,7 @@ public class TbsActivityServiceImpl extends ServiceImpl budgetLogLqw = new LambdaQueryWrapper<>(); budgetLogLqw.eq(TbsBudgetLog::getCostApplyId,costApply.getId()); + budgetLogLqw.eq(TbsBudgetLog::getOptType,1); List 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 activityCenterGoodsList = tbsActivityCenterGoodsService.listByCostApplyId(costApply.getId()); -// //查询当前预算占用 -// LambdaQueryWrapper 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 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 budgetCostItemList = tbsBudgetCostItemService.listByCostApplyId(costApply.getId()); -// List budgetIds = budgetCostItemList.stream().map(TbsBudgetCostItem::getBudgetId).collect(Collectors.toList()); -// List budgetList = tbsBudgetMapper.selectBatchIds(budgetIds); -// List 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 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 activityCenterList, List 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 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); } } }