Browse Source

费用优先级调整:时间区间内,区间长度取最短

contract
Yen 2 years ago
parent
commit
e35503bdf1
  1. 26
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java
  2. 29
      src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetApplicationService.java

26
src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java

@ -1,6 +1,7 @@
package com.qs.serve.modules.tbs.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qs.serve.common.model.annotation.SysLog;
import com.qs.serve.common.model.consts.BudgetLogOptFlag;
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag;
@ -66,6 +67,12 @@ public class TbsCostApplyController {
private TbsCostApplyService tbsCostApplyService;
private TbsActivityService tbsActivityService;
private TbsActivityTemplateService tbsActivityTemplateService;
private final TbsActivityGoodsService activityGoodsService;
private final TbsActivitySubjectService activitySubjectService;
private final TbsActivityCenterService activityCenterService;
private final TbsActivityCenterGoodsService activityCenterGoodsService;
private final TbsActivityChannelService activityChannelService;
private final TbsActivityChannelPointService activityChannelPointService;
private TbsBudgetLogService tbsBudgetLogService;
private BmsSupplierService bmsSupplierService;
private SysUserService sysUserService;
@ -284,6 +291,25 @@ public class TbsCostApplyController {
@SysLog(module = SystemModule.Budget, title = "费用申请", biz = BizType.DELETE)
@PreAuthorize("hasRole('tbs:costApply:delete')")
public R<?> deleteById(@PathVariable("id") Long id){
TbsCostApply entity = tbsCostApplyService.getById(id);
if(!entity.getChargeState().equals(0)&&!entity.getChargeState().equals(4)){
return R.error("当前状态不支持删除");
}
//模板类直接删除
if(entity.getTemplateId()!=null){
tbsCostApplyService.removeById(id);
tbsActivityService.removeById(id);
//删除子表数据
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("activity_id",id);
activitySubjectService.remove(queryWrapper);
activityGoodsService.remove(queryWrapper);
activityChannelPointService.remove(queryWrapper);
activityChannelService.remove(queryWrapper);
activityCenterService.remove(queryWrapper);
activityCenterGoodsService.remove(queryWrapper);
return R.ok();
}
LambdaQueryWrapper<TbsActivity> lqw = new LambdaQueryWrapper<>();
lqw.eq(TbsActivity::getCostApplyId,id);
long count = tbsActivityService.count(lqw);

29
src/main/java/com/qs/serve/modules/tbs/service/TbsBudgetApplicationService.java

@ -462,9 +462,15 @@ public class TbsBudgetApplicationService {
return;
}
List<TbsBudget> budgetList = allBudgetList.stream().filter(obj->allowBudgetIds.contains(obj.getId())).collect(Collectors.toList());
//PS:排序规则:优先满足时间条件,其次匹配品牌条件
//按品类条件,提取可用预算(列表已按小维度到大维度排列)
List<TbsBudget> currentItemBudgetList = this.filterMatchGoodsCondition(budgetList, activityCostItem.getTargetLevelPathIds());
//排序
TbsActivity currentActivity = null;
for (TbsActivity activity : activityList) {
if(activityCostItem.getActivityId().equals(activity.getId())){
currentActivity = activity;
break;
}
}
List<TbsBudget> currentItemBudgetList = this.filterMatchGoodsCondition(budgetList, activityCostItem.getTargetLevelPathIds(),currentActivity);
//关联无条件预算
currentItemBudgetList.addAll(noConditionBudgetList);
//提取可用预算的考核期
@ -582,7 +588,7 @@ public class TbsBudgetApplicationService {
* @return
*/
@NotNull
public List<TbsBudget> filterMatchGoodsCondition(List<TbsBudget> budgetList,String targetLevelPathIds) {
public List<TbsBudget> filterMatchGoodsCondition(List<TbsBudget> budgetList,String targetLevelPathIds,TbsActivity currentActivity) {
String levelPath = targetLevelPathIds;
Set<String> levelPathSet = new LinkedHashSet<>();
levelPathSet.add(levelPath);
@ -608,6 +614,21 @@ public class TbsBudgetApplicationService {
Collections.sort(budgetConditionList, (o1, o2) -> {
int len1 = o1.getTargetLevelPathIds().split("_").length;
int len2 = o2.getTargetLevelPathIds().split("_").length;
if(len1==len2){
List<TbsScheduleItemBudget> scheduleItemBudgets = currentActivity.getScheduleItemBudgetList();
Long day1 = null;
Long day2 = null;
for (TbsScheduleItemBudget itemBudget : scheduleItemBudgets) {
if(itemBudget.getBudgetId().equals(o1.getBudgetId())){
day1 = Duration.between(itemBudget.getStartDate(), itemBudget.getEndDate()).toDays();
}else if (itemBudget.getBudgetId().equals(o2.getBudgetId())){
day2 = Duration.between(itemBudget.getStartDate(), itemBudget.getEndDate()).toDays();
}
}
if(day1!=null&&day2!=null){
return (int) (day1-day2);
}
}
return len2 - len1;
});
List<TbsBudget> currentItemBudgetList = new ArrayList<>();

Loading…
Cancel
Save