UPDATE: 完善。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
@@ -72,5 +73,8 @@ public class PqStandardDev extends BaseEntity implements Serializable {
|
||||
private String devKey;
|
||||
|
||||
private Integer state;
|
||||
|
||||
@TableField(exist = false)
|
||||
private boolean disabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.poi.PullDown;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.gather.device.mapper.PqStandardDevMapper;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||
@@ -316,27 +318,30 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
// 获取对应检测计划
|
||||
List<String> planIds = boundList.stream().map(AdPlanStandardDev::getPlanId).collect(Collectors.toList());
|
||||
IAdPlanService adPlanService = SpringUtil.getBean(IAdPlanService.class);
|
||||
List<AdPlan> planList = adPlanService.listByIds(planIds);
|
||||
List<AdPlan> planList = adPlanService.lambdaQuery().in(AdPlan::getId, planIds).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
// 区分主计划和子计划
|
||||
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().equals(CommonEnum.FATHER_ID.getValue())).collect(Collectors.toList());
|
||||
List<AdPlan> subPlanList = planList.stream().filter(plan -> !plan.getFatherPlanId().equals(CommonEnum.FATHER_ID.getValue())).collect(Collectors.toList());
|
||||
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());
|
||||
excludePlanIds.addAll(excludeMainPlanIds);
|
||||
List<String> excludeMainPlanIds = mainPlanList.stream().filter(plan -> !plan.getTestState().equals(CheckStateEnum.CHECKED.getValue())).map(AdPlan::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(excludeMainPlanIds)) {
|
||||
excludePlanIds.addAll(excludeMainPlanIds);
|
||||
}
|
||||
|
||||
}
|
||||
// 子计划需要判断其主计划, 如果主计划未完成则排除
|
||||
if (CollectionUtil.isNotEmpty(subPlanList)) {
|
||||
List<String> fatherPlanIds = subPlanList.stream().map(plan -> plan.getFatherPlanId()).collect(Collectors.toList());
|
||||
List<String> fatherPlanIds = subPlanList.stream().map(AdPlan::getFatherPlanId).distinct().collect(Collectors.toList());
|
||||
List<AdPlan> fatherPlanList = adPlanService.listByIds(fatherPlanIds);
|
||||
List<String> excludeFatherPlanIds = fatherPlanList.stream()
|
||||
.filter(plan -> plan.getTestState() != 2)
|
||||
.map(plan -> plan.getId()).collect(Collectors.toList());
|
||||
.filter(plan -> !plan.getTestState().equals(CheckStateEnum.CHECKED.getValue()))
|
||||
.map(AdPlan::getId).collect(Collectors.toList());
|
||||
List<String> excludeSubPlanIds = subPlanList.stream()
|
||||
.filter(plan -> excludeFatherPlanIds.contains(plan.getFatherPlanId()))
|
||||
.map(plan -> plan.getId()).collect(Collectors.toList());
|
||||
.map(AdPlan::getId).collect(Collectors.toList());
|
||||
excludePlanIds.addAll(excludeSubPlanIds);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(excludePlanIds)) {
|
||||
@@ -346,10 +351,12 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
excludeStandardDevIds = excludeBoundList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
return this.lambdaQuery()
|
||||
List<PqStandardDev> list = this.lambdaQuery()
|
||||
.eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.notIn(CollectionUtil.isNotEmpty(excludeStandardDevIds), PqStandardDev::getId, excludeStandardDevIds)
|
||||
.list();
|
||||
for (PqStandardDev pqStandardDev : list) {
|
||||
pqStandardDev.setDisabled(excludeStandardDevIds.contains(pqStandardDev.getId()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user