|
@ -66,6 +66,7 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper, |
|
|
private final TbsBudgetChangeConditionService tbsBudgetChangeConditionService; |
|
|
private final TbsBudgetChangeConditionService tbsBudgetChangeConditionService; |
|
|
private final TbsScheduleItemBudgetMapper tbsScheduleItemBudgetMapper; |
|
|
private final TbsScheduleItemBudgetMapper tbsScheduleItemBudgetMapper; |
|
|
private final TbsBudgetChangeScheduleItemService tbsBudgetChangeScheduleItemService; |
|
|
private final TbsBudgetChangeScheduleItemService tbsBudgetChangeScheduleItemService; |
|
|
|
|
|
private final TbsBudgetBatchItemService tbsBudgetBatchItemService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
@ -136,7 +137,6 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper, |
|
|
budgetBatch.setUserName(sysUser.getName()); |
|
|
budgetBatch.setUserName(sysUser.getName()); |
|
|
budgetBatch.setSubmitTime(LocalDateTime.now()); |
|
|
budgetBatch.setSubmitTime(LocalDateTime.now()); |
|
|
budgetBatch.setRemark(param.getRemark()); |
|
|
budgetBatch.setRemark(param.getRemark()); |
|
|
|
|
|
|
|
|
//构建BatchItems
|
|
|
//构建BatchItems
|
|
|
List<TbsBudgetBatchItem> batchItems = new ArrayList<>(); |
|
|
List<TbsBudgetBatchItem> batchItems = new ArrayList<>(); |
|
|
//加载 周期信息
|
|
|
//加载 周期信息
|
|
@ -195,56 +195,31 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper, |
|
|
tbsBudgetChangeService.save(budgetChange); |
|
|
tbsBudgetChangeService.save(budgetChange); |
|
|
Long changeId = budgetChange.getId(); |
|
|
Long changeId = budgetChange.getId(); |
|
|
//添加品类条件
|
|
|
//添加品类条件
|
|
|
if(budget.getConditionFlag().equals(1)){ |
|
|
this.toSaveChangeCondition(categoryMap, budget, paramItem, budgetId, changeId); |
|
|
List<TbsBudgetCondition> existingConditionList = tbsBudgetConditionService |
|
|
|
|
|
.list(new LambdaQueryWrapper<TbsBudgetCondition>() |
|
|
|
|
|
.eq(TbsBudgetCondition::getBudgetId,budgetId)); |
|
|
|
|
|
String bandNames = paramItem.getBandNames(); |
|
|
|
|
|
String categoryNames = paramItem.getCategoryNames(); |
|
|
|
|
|
String seriesNames = paramItem.getSeriesNames(); |
|
|
|
|
|
//设置changeConditionList参数
|
|
|
|
|
|
List<TbsBudgetChangeCondition> changeConditionList = new ArrayList<>(); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
bandNames, TbsGoodsType.brand.name()); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
categoryNames, TbsGoodsType.category.name()); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
seriesNames, TbsGoodsType.series.name()); |
|
|
|
|
|
if(CollUtil.isNotEmpty(changeConditionList)){ |
|
|
|
|
|
tbsBudgetChangeConditionService.saveBatch(changeConditionList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
List<TbsBudgetChangeScheduleItem> changeScheduleItemList = new ArrayList<>(); |
|
|
List<TbsBudgetChangeScheduleItem> changeScheduleItemList = new ArrayList<>(); |
|
|
this.buildChangeSchduleBudgetList(paramItem, budgetId, changeId, changeScheduleItemList); |
|
|
this.buildChangeSchduleBudgetList(paramItem, budgetId, changeId, changeScheduleItemList); |
|
|
if(CollUtil.isNotEmpty(changeScheduleItemList)){ |
|
|
if(CollUtil.isNotEmpty(changeScheduleItemList)){ |
|
|
tbsBudgetChangeScheduleItemService.saveBatch(changeScheduleItemList); |
|
|
tbsBudgetChangeScheduleItemService.saveBatch(changeScheduleItemList); |
|
|
} |
|
|
} |
|
|
|
|
|
TbsBudgetBatchItem batchItem = new TbsBudgetBatchItem(); |
|
|
|
|
|
batchItem.setBudgetId(budgetId); |
|
|
|
|
|
batchItem.setChangeId(changeId); |
|
|
|
|
|
batchItem.setBatchState(TbsBudgetCheckState.State_1_apply); |
|
|
|
|
|
batchItem.setUserId(sysUser.getId()); |
|
|
|
|
|
batchItem.setUserCode(sysUser.getCode()); |
|
|
|
|
|
batchItem.setUserName(sysUser.getName()); |
|
|
|
|
|
batchItems.add(batchItem); |
|
|
|
|
|
|
|
|
}else { |
|
|
}else { |
|
|
//修改后为新增类型提交
|
|
|
//修改后为新增类型提交
|
|
|
tbsBudgetService.removeById(budgetId); |
|
|
this.toUpdateBudgetInfo(sysUser, scheduleMap, subjectMap, centerDtoMap, categoryMap, paramItem, budgetId); |
|
|
tbsBudgetConditionService.remove( |
|
|
TbsBudgetBatchItem batchItem = new TbsBudgetBatchItem(); |
|
|
new LambdaQueryWrapper<TbsBudgetCondition>() |
|
|
batchItem.setBudgetId(budgetId); |
|
|
.eq(TbsBudgetCondition::getBudgetId,budgetId) |
|
|
batchItem.setBatchState(TbsBudgetCheckState.State_1_apply); |
|
|
); |
|
|
batchItem.setUserId(sysUser.getId()); |
|
|
tbsScheduleItemBudgetService.remove( |
|
|
batchItem.setUserCode(sysUser.getCode()); |
|
|
new LambdaQueryWrapper<TbsScheduleItemBudget>() |
|
|
batchItem.setUserName(sysUser.getName()); |
|
|
.eq(TbsScheduleItemBudget::getBudgetId,budgetId) |
|
|
batchItems.add(batchItem); |
|
|
); |
|
|
|
|
|
//设置新的值
|
|
|
|
|
|
TbsBudget newBudget = new TbsBudget(); |
|
|
|
|
|
newBudget.setId(budgetId); |
|
|
|
|
|
TbsSchedule schedule = scheduleMap.get(paramItem.getScheduleName()); |
|
|
|
|
|
this.initBudget4Update(sysUser,schedule, subjectMap, centerDtoMap, paramItem, newBudget); |
|
|
|
|
|
//创建新条件
|
|
|
|
|
|
List<TbsBudgetCondition> conditionList = this.createTbsBudgetConditions(categoryMap, paramItem, budgetId); |
|
|
|
|
|
//创建新预算周期
|
|
|
|
|
|
List<TbsScheduleItemBudget> scheduleItemBudgetList = this.createTbsScheduleItemBudgetList(paramItem, budgetId, schedule); |
|
|
|
|
|
//数据持久化
|
|
|
|
|
|
tbsBudgetService.updateById(newBudget); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(conditionList)){ |
|
|
|
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
|
|
|
} |
|
|
|
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -266,13 +241,70 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper, |
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
} |
|
|
} |
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
|
|
|
|
|
|
|
|
|
TbsBudgetBatchItem batchItem = new TbsBudgetBatchItem(); |
|
|
|
|
|
batchItem.setBudgetId(budgetId); |
|
|
|
|
|
batchItem.setBatchState(TbsBudgetCheckState.State_1_apply); |
|
|
|
|
|
batchItem.setUserId(sysUser.getId()); |
|
|
|
|
|
batchItem.setUserCode(sysUser.getCode()); |
|
|
|
|
|
batchItem.setUserName(sysUser.getName()); |
|
|
|
|
|
batchItems.add(batchItem); |
|
|
} |
|
|
} |
|
|
this.save(budgetBatch); |
|
|
this.save(budgetBatch); |
|
|
//保存后赋值
|
|
|
//保存后赋值
|
|
|
Long budgetBatchId = budgetBatch.getId(); |
|
|
Long batchId = budgetBatch.getId(); |
|
|
|
|
|
batchItems.forEach(batchItem->batchItem.setBatchId(batchId)); |
|
|
|
|
|
tbsBudgetBatchItemService.saveBatch(batchItems); |
|
|
|
|
|
return budgetBatch; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void toUpdateBudgetInfo(SysUser sysUser, Map<String, TbsSchedule> scheduleMap, Map<String, BmsSubject> subjectMap, Map<String, TbsCenterDto> centerDtoMap, Map<String, GoodsCategory> categoryMap, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId) { |
|
|
|
|
|
tbsBudgetService.removeById(budgetId); |
|
|
|
|
|
tbsBudgetConditionService.remove( |
|
|
|
|
|
new LambdaQueryWrapper<TbsBudgetCondition>() |
|
|
|
|
|
.eq(TbsBudgetCondition::getBudgetId, budgetId) |
|
|
|
|
|
); |
|
|
|
|
|
tbsScheduleItemBudgetService.remove( |
|
|
|
|
|
new LambdaQueryWrapper<TbsScheduleItemBudget>() |
|
|
|
|
|
.eq(TbsScheduleItemBudget::getBudgetId, budgetId) |
|
|
|
|
|
); |
|
|
|
|
|
//设置新的值
|
|
|
|
|
|
TbsBudget newBudget = new TbsBudget(); |
|
|
|
|
|
newBudget.setId(budgetId); |
|
|
|
|
|
TbsSchedule schedule = scheduleMap.get(paramItem.getScheduleName()); |
|
|
|
|
|
this.initBudget4Update(sysUser,schedule, subjectMap, centerDtoMap, paramItem, newBudget); |
|
|
|
|
|
//创建新条件
|
|
|
|
|
|
List<TbsBudgetCondition> conditionList = this.createTbsBudgetConditions(categoryMap, paramItem, budgetId); |
|
|
|
|
|
//创建新预算周期
|
|
|
|
|
|
List<TbsScheduleItemBudget> scheduleItemBudgetList = this.createTbsScheduleItemBudgetList(paramItem, budgetId, schedule); |
|
|
|
|
|
//数据持久化
|
|
|
|
|
|
tbsBudgetService.updateById(newBudget); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(conditionList)){ |
|
|
|
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
|
|
|
} |
|
|
|
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return null; |
|
|
private void toSaveChangeCondition(Map<String, GoodsCategory> categoryMap, TbsBudget budget, TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId, Long changeId) { |
|
|
|
|
|
if(budget.getConditionFlag().equals(1)){ |
|
|
|
|
|
List<TbsBudgetCondition> existingConditionList = tbsBudgetConditionService |
|
|
|
|
|
.list(new LambdaQueryWrapper<TbsBudgetCondition>() |
|
|
|
|
|
.eq(TbsBudgetCondition::getBudgetId, budgetId)); |
|
|
|
|
|
String bandNames = paramItem.getBandNames(); |
|
|
|
|
|
String categoryNames = paramItem.getCategoryNames(); |
|
|
|
|
|
String seriesNames = paramItem.getSeriesNames(); |
|
|
|
|
|
//设置changeConditionList参数
|
|
|
|
|
|
List<TbsBudgetChangeCondition> changeConditionList = new ArrayList<>(); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
bandNames, TbsGoodsType.brand.name()); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
categoryNames, TbsGoodsType.category.name()); |
|
|
|
|
|
this.buildChangeConditionList(categoryMap, budgetId, changeId, changeConditionList, existingConditionList, |
|
|
|
|
|
seriesNames, TbsGoodsType.series.name()); |
|
|
|
|
|
if(CollUtil.isNotEmpty(changeConditionList)){ |
|
|
|
|
|
tbsBudgetChangeConditionService.saveBatch(changeConditionList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void buildChangeSchduleBudgetList(TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId, Long changeId, List<TbsBudgetChangeScheduleItem> changeScheduleItemList) { |
|
|
private void buildChangeSchduleBudgetList(TbsBudgetBatchBo.BudgetMain paramItem, Long budgetId, Long changeId, List<TbsBudgetChangeScheduleItem> changeScheduleItemList) { |
|
|