检测计划相关功能代码
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -123,7 +123,7 @@ public class AdPlanVO {
|
||||
/**
|
||||
* 标准设备ID列表
|
||||
*/
|
||||
private List<String> standardDevIds;
|
||||
private Map<String, Integer> standardDevMap;
|
||||
|
||||
/**
|
||||
* 标准设备名称
|
||||
|
||||
@@ -6,7 +6,6 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -179,14 +178,22 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
List<String> planIdList = new ArrayList<>();
|
||||
planIdList.add(adPlan.getId());
|
||||
List<PqStandardDev> pqStandardDevs = adPlanStandardDevMapper.listByPlanId(planIdList);
|
||||
adPlanVO.setStandardDevMap(pqStandardDevs.stream().collect(Collectors.toMap(PqStandardDev::getId, obj -> 0)));
|
||||
adPlanVO.setStandardDevNameStr(pqStandardDevs.stream().map(PqStandardDev::getName).reduce((a, b) -> a + "," + b).orElse(""));
|
||||
|
||||
if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) {
|
||||
List<AdPlan> childrenPlan = this.lambdaQuery().eq(AdPlan::getFatherPlanId, adPlan.getId()).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<String> childrenPlanIds = childrenPlan.stream().map(AdPlan::getId).collect(Collectors.toList());
|
||||
planIdList.addAll(childrenPlanIds);
|
||||
if (CollUtil.isNotEmpty(childrenPlanIds)) {
|
||||
pqStandardDevs = adPlanStandardDevMapper.listByPlanId(childrenPlanIds);
|
||||
} else {
|
||||
pqStandardDevs.clear();
|
||||
}
|
||||
Map<String, Integer> standardDevIds = adPlanVO.getStandardDevMap();
|
||||
standardDevIds.putAll(pqStandardDevs.stream().collect(Collectors.toMap(PqStandardDev::getId, obj -> 1)));
|
||||
adPlanVO.setStandardDevNameStr(adPlanVO.getStandardDevNameStr() + pqStandardDevs.stream().map(PqStandardDev::getName).reduce((a, b) -> a + "," + b).orElse(""));
|
||||
}
|
||||
List<PqStandardDev> pqStandardDevs = adPlanStandardDevMapper.listByPlanId(planIdList);
|
||||
adPlanVO.setStandardDevIds(pqStandardDevs.stream().map(PqStandardDev::getId).collect(Collectors.toList()));
|
||||
adPlanVO.setStandardDevNameStr(pqStandardDevs.stream().map(PqStandardDev::getName).reduce((a, b) -> a + "," + b).orElse(""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,23 +309,29 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<String> childrenPlanIds = childrenPlan.stream().map(AdPlan::getId).collect(Collectors.toList());
|
||||
|
||||
// 修改与标准设备的关联关系
|
||||
List<AdPlanStandardDev> adPlanStandardDevList = adPlanStandardDevService.lambdaQuery().in(CollectionUtil.isNotEmpty(childrenPlanIds), AdPlanStandardDev::getPlanId, childrenPlanIds).list();
|
||||
if (CollUtil.isNotEmpty(adPlanStandardDevList)) {
|
||||
throw new BusinessException(DetectionResponseEnum.PLEASE_UNASSIGN_STANDARD_DEV);
|
||||
List<AdPlanStandardDev> adPlanStandardDevList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(childrenPlanIds)) {
|
||||
adPlanStandardDevList.addAll(adPlanStandardDevService.lambdaQuery().in(AdPlanStandardDev::getPlanId, childrenPlanIds).list());
|
||||
}
|
||||
//List<String> standardDevIds = adPlanStandardDevList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
||||
//param.getStandardDevIds().removeAll(standardDevIds);
|
||||
|
||||
// if (CollUtil.isNotEmpty(adPlanStandardDevList)) {
|
||||
// throw new BusinessException(DetectionResponseEnum.PLEASE_UNASSIGN_STANDARD_DEV);
|
||||
// }
|
||||
List<String> standardDevIds = adPlanStandardDevList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
||||
param.getStandardDevIds().removeAll(standardDevIds);
|
||||
adPlanStandardDevService.updateAdPlanStandardDev(param.getId(), param.getStandardDevIds());
|
||||
|
||||
// 修改与被检设备的关联关系
|
||||
PqDevParam.QueryParam param1 = new PqDevParam.QueryParam();
|
||||
param1.setPlanIdList(childrenPlanIds);
|
||||
List<PqDevVO> pqDevVOList = pqDevService.listByPlanId(param1);
|
||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||
throw new BusinessException(DetectionResponseEnum.PLEASE_UNASSIGN_DEVICE);
|
||||
}
|
||||
// List<String> devIds = pqDevVOList.stream().map(PqDevVO::getId).collect(Collectors.toList());
|
||||
// param.getDevIds().removeAll(devIds);
|
||||
|
||||
// if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||
// throw new BusinessException(DetectionResponseEnum.PLEASE_UNASSIGN_DEVICE);
|
||||
// }
|
||||
|
||||
List<String> devIds = pqDevVOList.stream().map(PqDevVO::getId).collect(Collectors.toList());
|
||||
param.getDevIds().removeAll(devIds);
|
||||
plan2.setTestState(pqDevService.bind(param.getId(), param.getDevIds()));
|
||||
} else {
|
||||
// 修改检测计划、检测源关联
|
||||
|
||||
Reference in New Issue
Block a user