8 changed files with 166 additions and 11 deletions
@ -0,0 +1,27 @@ |
|||||
|
package com.qs.serve.modules.tbs.entity.vo; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/12/28 |
||||
|
*/ |
||||
|
public class TbsBudgetMatchMsgVo { |
||||
|
|
||||
|
/** 活动ID */ |
||||
|
private Long activityId; |
||||
|
|
||||
|
/** 活动编码 */ |
||||
|
private String activityCode; |
||||
|
|
||||
|
/** 活动标题 */ |
||||
|
private String activityTitle; |
||||
|
|
||||
|
/** 预算ID */ |
||||
|
private Long budgetId; |
||||
|
|
||||
|
/** 预算编码 */ |
||||
|
private String budgetCode; |
||||
|
|
||||
|
/** 预算标题 */ |
||||
|
private String budgetTitle; |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.qs.serve.modules.tbs.service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/12/28 |
||||
|
*/ |
||||
|
public interface TbsBudgetManagerService { |
||||
|
|
||||
|
/** |
||||
|
* 对比活动和预算进行条件匹配,返回不符合的内容(以Budget为参照物,全量匹配) |
||||
|
* @param activityIds |
||||
|
* @param budgetIds |
||||
|
* @return |
||||
|
*/ |
||||
|
Object compare(List<Long> activityIds, List<Long> budgetIds); |
||||
|
|
||||
|
} |
@ -0,0 +1,96 @@ |
|||||
|
package com.qs.serve.modules.tbs.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.qs.serve.modules.tbs.entity.*; |
||||
|
import com.qs.serve.modules.tbs.mapper.*; |
||||
|
import com.qs.serve.modules.tbs.service.TbsActivityCenterGoodsService; |
||||
|
import com.qs.serve.modules.tbs.service.TbsBudgetManagerService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/12/28 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class TbsBudgetManagerServiceImpl implements TbsBudgetManagerService { |
||||
|
|
||||
|
private final TbsActivityMapper activityMapper; |
||||
|
private final TbsActivityCenterMapper activityCenterMapper; |
||||
|
private final TbsActivitySubjectMapper activitySubjectMapper; |
||||
|
private final TbsActivityCenterGoodsMapper activityCenterGoodsMapper; |
||||
|
private final TbsBudgetMapper budgetMapper; |
||||
|
private final TbsBudgetConditionMapper budgetConditionMapper; |
||||
|
private final TbsScheduleItemBudgetMapper scheduleItemBudgetMapper; |
||||
|
|
||||
|
@Override |
||||
|
public Object compare(List<Long> activityIds, List<Long> budgetIds) { |
||||
|
//加载基础数据
|
||||
|
QueryWrapper acgLqw = new QueryWrapper<>(); |
||||
|
acgLqw.in("activity_id",activityIds); |
||||
|
|
||||
|
List<TbsBudget> budgetList = budgetMapper.selectBatchIds(budgetIds); |
||||
|
List<TbsActivity> activityList = activityMapper.selectBatchIds(activityIds); |
||||
|
List<TbsActivityCenter> allCenterList = activityCenterMapper.selectList(acgLqw); |
||||
|
List<TbsActivitySubject> allSubjectList = activitySubjectMapper.selectList(acgLqw); |
||||
|
List<TbsActivityCenterGoods> allCenterGoodsList = activityCenterGoodsMapper.selectList(acgLqw); |
||||
|
|
||||
|
Map<Long,List<TbsActivityCenter>> centerListMap = allCenterList.stream().collect(Collectors.groupingBy(TbsActivityCenter::getActivityId)); |
||||
|
Map<Long,List<TbsActivitySubject>> subjectListMap = allSubjectList.stream().collect(Collectors.groupingBy(TbsActivitySubject::getActivityId)); |
||||
|
Map<Long,List<TbsActivityCenterGoods>> centerGoodsListMap = allCenterGoodsList.stream().collect(Collectors.groupingBy(TbsActivityCenterGoods::getActivityId)); |
||||
|
|
||||
|
LambdaQueryWrapper<TbsBudgetCondition> conditionLqw = new LambdaQueryWrapper<>(); |
||||
|
conditionLqw.in(TbsBudgetCondition::getBudgetId,budgetIds); |
||||
|
List<TbsBudgetCondition> allConditionList = budgetConditionMapper.selectList(conditionLqw); |
||||
|
|
||||
|
|
||||
|
Map<Long,List<TbsBudgetCondition>> conditionListMap = allConditionList.stream().collect(Collectors.groupingBy(TbsBudgetCondition::getBudgetId)); |
||||
|
|
||||
|
//匹对
|
||||
|
for (TbsBudget budget : budgetList) { |
||||
|
for (TbsActivity activity : activityList) { |
||||
|
Long budgetId = budget.getId(); |
||||
|
Long activityId = activity.getId(); |
||||
|
//判断科目
|
||||
|
if(!budget.getSubjectId().equals(0L)){ |
||||
|
List<TbsActivitySubject> subjectList = subjectListMap.get(activityId); |
||||
|
for (TbsActivitySubject subject : subjectList) { |
||||
|
if(!subject.getSubjectId().equals(budget.getSubjectId())){ |
||||
|
String msg = "无法匹配科目"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
//判断成本中心
|
||||
|
List<TbsActivityCenter> centerList = centerListMap.get(activityId); |
||||
|
for (TbsActivityCenter center : centerList) { |
||||
|
if(!center.getCenterType().equals(budget.getCenterType())||center.getCenterId().equals(budget.getCenterId())){ |
||||
|
String msg = "无法匹配成本中心"; |
||||
|
} |
||||
|
} |
||||
|
//判断时间
|
||||
|
List<TbsBudgetCondition> budgetConditionList = conditionListMap.get(budgetId); |
||||
|
//判断品类
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
//
|
||||
|
|
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue