UPDATE: 优化可选标准设备接口
This commit is contained in:
@@ -309,40 +309,44 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PqStandardDev> canBindingList() {
|
public List<PqStandardDev> canBindingList() {
|
||||||
|
List<String> excludeStandardDevIds = new ArrayList<>();
|
||||||
// 获取所有已绑定的标准设备
|
// 获取所有已绑定的标准设备
|
||||||
List<AdPlanStandardDev> boundList = adPlanStandardDevService.list();
|
List<AdPlanStandardDev> boundList = adPlanStandardDevService.list();
|
||||||
// 获取对应检测计划
|
if (CollectionUtil.isNotEmpty(boundList)) {
|
||||||
List<String> planIds = boundList.stream().map(AdPlanStandardDev::getPlanId).collect(Collectors.toList());
|
// 获取对应检测计划
|
||||||
IAdPlanService adPlanService = SpringUtil.getBean(IAdPlanService.class);
|
List<String> planIds = boundList.stream().map(AdPlanStandardDev::getPlanId).collect(Collectors.toList());
|
||||||
List<AdPlan> planList = adPlanService.listByIds(planIds);
|
IAdPlanService adPlanService = SpringUtil.getBean(IAdPlanService.class);
|
||||||
// 区分主计划和子计划
|
List<AdPlan> planList = adPlanService.listByIds(planIds);
|
||||||
List<AdPlan> mainPlanList = planList.stream().filter(plan -> plan.getFatherPlanId() == null).collect(Collectors.toList());
|
// 区分主计划和子计划
|
||||||
List<AdPlan> subPlanList = planList.stream().filter(plan -> plan.getFatherPlanId() != null).collect(Collectors.toList());
|
List<AdPlan> mainPlanList = planList.stream().filter(plan -> plan.getFatherPlanId() == null).collect(Collectors.toList());
|
||||||
List<String> excludePlanIds = new ArrayList<>();
|
List<AdPlan> subPlanList = planList.stream().filter(plan -> plan.getFatherPlanId() != null).collect(Collectors.toList());
|
||||||
List<String> excludeStandardDevIds = new ArrayList<>();
|
List<String> excludePlanIds = new ArrayList<>();
|
||||||
// 主计划直接排除
|
|
||||||
if (CollectionUtil.isNotEmpty(mainPlanList)) {
|
// 主计划直接排除
|
||||||
List<String> excludeMainPlanIds = mainPlanList.stream().filter(plan -> plan.getTestState() != 2).map(plan -> plan.getId()).collect(Collectors.toList());
|
if (CollectionUtil.isNotEmpty(mainPlanList)) {
|
||||||
excludePlanIds.addAll(excludeMainPlanIds);
|
List<String> excludeMainPlanIds = mainPlanList.stream().filter(plan -> plan.getTestState() != 2).map(plan -> plan.getId()).collect(Collectors.toList());
|
||||||
}
|
excludePlanIds.addAll(excludeMainPlanIds);
|
||||||
// 子计划需要判断其主计划, 如果主计划未完成则排除
|
}
|
||||||
if (CollectionUtil.isNotEmpty(subPlanList)) {
|
// 子计划需要判断其主计划, 如果主计划未完成则排除
|
||||||
List<String> fatherPlanIds = subPlanList.stream().map(plan -> plan.getFatherPlanId()).collect(Collectors.toList());
|
if (CollectionUtil.isNotEmpty(subPlanList)) {
|
||||||
List<AdPlan> fatherPlanList = adPlanService.listByIds(fatherPlanIds);
|
List<String> fatherPlanIds = subPlanList.stream().map(plan -> plan.getFatherPlanId()).collect(Collectors.toList());
|
||||||
List<String> excludeFatherPlanIds = fatherPlanList.stream()
|
List<AdPlan> fatherPlanList = adPlanService.listByIds(fatherPlanIds);
|
||||||
.filter(plan -> plan.getTestState() != 2)
|
List<String> excludeFatherPlanIds = fatherPlanList.stream()
|
||||||
.map(plan -> plan.getId()).collect(Collectors.toList());
|
.filter(plan -> plan.getTestState() != 2)
|
||||||
List<String> excludeSubPlanIds = subPlanList.stream()
|
.map(plan -> plan.getId()).collect(Collectors.toList());
|
||||||
.filter(plan -> excludeFatherPlanIds.contains(plan.getFatherPlanId()))
|
List<String> excludeSubPlanIds = subPlanList.stream()
|
||||||
.map(plan -> plan.getId()).collect(Collectors.toList());
|
.filter(plan -> excludeFatherPlanIds.contains(plan.getFatherPlanId()))
|
||||||
excludePlanIds.addAll(excludeSubPlanIds);
|
.map(plan -> plan.getId()).collect(Collectors.toList());
|
||||||
}
|
excludePlanIds.addAll(excludeSubPlanIds);
|
||||||
if (CollectionUtil.isNotEmpty(excludePlanIds)) {
|
}
|
||||||
List<AdPlanStandardDev> excludeBoundList = boundList.stream()
|
if (CollectionUtil.isNotEmpty(excludePlanIds)) {
|
||||||
.filter(bound -> excludePlanIds.contains(bound.getPlanId()))
|
List<AdPlanStandardDev> excludeBoundList = boundList.stream()
|
||||||
.collect(Collectors.toList());
|
.filter(bound -> excludePlanIds.contains(bound.getPlanId()))
|
||||||
excludeStandardDevIds = excludeBoundList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
excludeStandardDevIds = excludeBoundList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode())
|
.eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.notIn(CollectionUtil.isNotEmpty(excludeStandardDevIds), PqStandardDev::getId, excludeStandardDevIds)
|
.notIn(CollectionUtil.isNotEmpty(excludeStandardDevIds), PqStandardDev::getId, excludeStandardDevIds)
|
||||||
|
|||||||
Reference in New Issue
Block a user