|
@ -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,32 +195,70 @@ 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 { |
|
|
//修改后为新增类型提交
|
|
|
//修改后为新增类型提交
|
|
|
|
|
|
this.toUpdateBudgetInfo(sysUser, scheduleMap, subjectMap, centerDtoMap, categoryMap, paramItem, budgetId); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//新增的生成为草稿
|
|
|
|
|
|
List<TbsBudgetBatchBo.BudgetMain> addBudgetList = paramBudgetList.stream() |
|
|
|
|
|
.filter(a->!StringUtils.hasText(a.getBudgetNumber())).collect(Collectors.toList()); |
|
|
|
|
|
for (TbsBudgetBatchBo.BudgetMain budgetMain : addBudgetList) { |
|
|
|
|
|
TbsBudget newBudget = new TbsBudget(); |
|
|
|
|
|
tbsBudgetService.save(newBudget); |
|
|
|
|
|
Long budgetId = newBudget.getId(); |
|
|
|
|
|
TbsSchedule schedule = scheduleMap.get(budgetMain.getScheduleName()); |
|
|
|
|
|
this.initBudget4Update(sysUser,schedule, subjectMap, centerDtoMap, budgetMain, newBudget); |
|
|
|
|
|
//创建新条件
|
|
|
|
|
|
List<TbsBudgetCondition> conditionList = this.createTbsBudgetConditions(categoryMap, budgetMain, budgetId); |
|
|
|
|
|
//创建新预算周期
|
|
|
|
|
|
List<TbsScheduleItemBudget> scheduleItemBudgetList = this.createTbsScheduleItemBudgetList(budgetMain, budgetId, schedule); |
|
|
|
|
|
//数据持久化
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(conditionList)){ |
|
|
|
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
|
|
|
} |
|
|
|
|
|
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); |
|
|
|
|
|
//保存后赋值
|
|
|
|
|
|
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); |
|
|
tbsBudgetService.removeById(budgetId); |
|
|
tbsBudgetConditionService.remove( |
|
|
tbsBudgetConditionService.remove( |
|
|
new LambdaQueryWrapper<TbsBudgetCondition>() |
|
|
new LambdaQueryWrapper<TbsBudgetCondition>() |
|
@ -246,33 +284,27 @@ public class TbsBudgetBatchServiceImpl extends ServiceImpl<TbsBudgetBatchMapper, |
|
|
} |
|
|
} |
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//新增的生成为草稿
|
|
|
|
|
|
List<TbsBudgetBatchBo.BudgetMain> addBudgetList = paramBudgetList.stream() |
|
|
|
|
|
.filter(a->!StringUtils.hasText(a.getBudgetNumber())).collect(Collectors.toList()); |
|
|
|
|
|
for (TbsBudgetBatchBo.BudgetMain budgetMain : addBudgetList) { |
|
|
|
|
|
TbsBudget newBudget = new TbsBudget(); |
|
|
|
|
|
tbsBudgetService.save(newBudget); |
|
|
|
|
|
Long budgetId = newBudget.getId(); |
|
|
|
|
|
TbsSchedule schedule = scheduleMap.get(budgetMain.getScheduleName()); |
|
|
|
|
|
this.initBudget4Update(sysUser,schedule, subjectMap, centerDtoMap, budgetMain, newBudget); |
|
|
|
|
|
//创建新条件
|
|
|
|
|
|
List<TbsBudgetCondition> conditionList = this.createTbsBudgetConditions(categoryMap, budgetMain, budgetId); |
|
|
|
|
|
//创建新预算周期
|
|
|
|
|
|
List<TbsScheduleItemBudget> scheduleItemBudgetList = this.createTbsScheduleItemBudgetList(budgetMain, budgetId, schedule); |
|
|
|
|
|
//数据持久化
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(conditionList)){ |
|
|
|
|
|
tbsBudgetConditionService.saveBatch(conditionList); |
|
|
|
|
|
} |
|
|
|
|
|
tbsScheduleItemBudgetService.saveBatch(scheduleItemBudgetList); |
|
|
|
|
|
} |
|
|
|
|
|
this.save(budgetBatch); |
|
|
|
|
|
//保存后赋值
|
|
|
|
|
|
Long budgetBatchId = budgetBatch.getId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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) { |
|
|