ADD: 新增可选标准设备接口
This commit is contained in:
@@ -160,5 +160,17 @@ public class PqStandardDevController extends BaseController {
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqDevVOList, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/canBindingList")
|
||||
@ApiOperation("查询可绑定的标准设备")
|
||||
public HttpResult<List<PqStandardDev>> canBindingList() {
|
||||
String methodDescribe = getMethodDescribe("canBindingList");
|
||||
LogUtil.njcnDebug(log, "{},查询可绑定的标准设备", methodDescribe);
|
||||
List<PqStandardDev> result = pqStandardDevService.canBindingList();
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,4 +91,12 @@ public interface IPqStandardDevService extends IService<PqStandardDev> {
|
||||
* @return
|
||||
*/
|
||||
List<PreDetection> listStandardDevPreDetection(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 查询可绑定的标准设备列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<PqStandardDev> canBindingList();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -23,6 +24,10 @@ import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanStandardDev;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanStandardDevService;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
@@ -58,6 +63,7 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
|
||||
private final IAdPlanStandardDevService adPlanStandardDevService;
|
||||
|
||||
@Override
|
||||
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
||||
@@ -300,4 +306,46 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqStandardDev> canBindingList() {
|
||||
// 获取所有已绑定的标准设备
|
||||
List<AdPlanStandardDev> boundList = adPlanStandardDevService.list();
|
||||
// 获取对应检测计划
|
||||
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> 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<String> excludePlanIds = new ArrayList<>();
|
||||
List<String> excludeStandardDevIds = 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);
|
||||
}
|
||||
// 子计划需要判断其主计划, 如果主计划未完成则排除
|
||||
if (CollectionUtil.isNotEmpty(subPlanList)) {
|
||||
List<String> fatherPlanIds = subPlanList.stream().map(plan -> plan.getFatherPlanId()).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());
|
||||
List<String> excludeSubPlanIds = subPlanList.stream()
|
||||
.filter(plan -> excludeFatherPlanIds.contains(plan.getFatherPlanId()))
|
||||
.map(plan -> plan.getId()).collect(Collectors.toList());
|
||||
excludePlanIds.addAll(excludeSubPlanIds);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(excludePlanIds)) {
|
||||
List<AdPlanStandardDev> excludeBoundList = boundList.stream()
|
||||
.filter(bound -> excludePlanIds.contains(bound.getPlanId()))
|
||||
.collect(Collectors.toList());
|
||||
excludeStandardDevIds = excludeBoundList.stream().map(AdPlanStandardDev::getStandardDevId).collect(Collectors.toList());
|
||||
}
|
||||
return this.lambdaQuery()
|
||||
.eq(PqStandardDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.notIn(CollectionUtil.isNotEmpty(excludeStandardDevIds), PqStandardDev::getId, excludeStandardDevIds)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user