Browse Source

审批金额分摊修复

v1.0
Yen 2 years ago
parent
commit
c60d9db2df
  1. 12
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java
  2. 3
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java
  3. 94
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java

12
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<Long> 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();
}
/**

3
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java

@ -439,6 +439,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
if(centerBo.getCenterType().equals(tbsCenterDto.getCenterType())&&centerBo.getCenterId().equals(tbsCenterDto.getId())){
centerGoods.setCenterRate(centerBo.getCenterRate());
centerGoods.setCenterAmount(centerBo.getCenterAmount());
centerGoods.setOrgCenterAmount(centerBo.getCenterAmount());
break;
}
}
@ -451,6 +452,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
centerGoods.setSubjectCode(subject.getSubjectCode());
centerGoods.setSubjectName(subject.getSubjectName());
centerGoods.setCenterGoodsAmount(centerGoodsBo.getCenterGoodsAmount());
centerGoods.setOrgCenterGoodsAmount(centerGoods.getCenterGoodsAmount());
centerGoods.setCenterGoodsRate(centerGoodsBo.getCenterGoodsRate());
//设置活动时间
centerGoods.setActEndDate(activity.getActEndDate());
@ -534,6 +536,7 @@ public class TbsActivityServiceImpl extends ServiceImpl<TbsActivityMapper,TbsAct
activityCenter.setSubjectId(subjectBo.getSubjectId());
activityCenter.setCenterRate(centerBo.getCenterRate());
activityCenter.setCenterAmount(centerBo.getCenterAmount());
activityCenter.setOrgCenterAmount(centerBo.getCenterAmount());
activityCenter.setCenterType(centerBo.getCenterType());
totalAmount = totalAmount.add(centerBo.getCenterAmount());
totalRate = totalRate.add(centerBo.getCenterRate());

94
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyOperationServiceImpl.java

@ -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())
&&centerGoods.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);
}
}
}

Loading…
Cancel
Save