|
@@ -29,8 +29,7 @@ import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
-import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAINTENANCE_PLAN_NOT_EXISTS;
|
|
|
|
-import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAINTENANCE_PLAN_NO_EXISTS;
|
|
|
|
|
|
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 保养计划 Service 实现类
|
|
* 保养计划 Service 实现类
|
|
@@ -65,6 +64,18 @@ public class IotMaintenancePlanServiceImpl implements IotMaintenancePlanService
|
|
if (ObjectUtil.isEmpty(deviceBOMs)) {
|
|
if (ObjectUtil.isEmpty(deviceBOMs)) {
|
|
throw exception(IOT_MAINTENANCE_PLAN_NOT_EXISTS);
|
|
throw exception(IOT_MAINTENANCE_PLAN_NOT_EXISTS);
|
|
}
|
|
}
|
|
|
|
+ // 校验保养计划明细中的设备只能出现在1个保养计划中
|
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
|
+ // 查验保养计划明细中的设备 只存在于1个保养计划中
|
|
|
|
+ deviceBOMs.forEach(bom -> {
|
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
|
+ });
|
|
|
|
+ IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
|
+ reqVO.setDeviceIds(new ArrayList<>(deviceIds));
|
|
|
|
+ List<IotMaintenanceBomDO> boms = iotMaintenanceBomMapper.selectList(reqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(boms)) {
|
|
|
|
+ throw exception(IOT_MAINTENANCE_SAME_DEVICE_EXISTS);
|
|
|
|
+ }
|
|
// 先保存保养计划主表 再根据主表id更新明细
|
|
// 先保存保养计划主表 再根据主表id更新明细
|
|
IotMaintenancePlanSaveReqVO mainPlanSaveVO = createReqVO.getMainPlan();
|
|
IotMaintenancePlanSaveReqVO mainPlanSaveVO = createReqVO.getMainPlan();
|
|
// 自动生成保养计划编号 BYJH202504300001
|
|
// 自动生成保养计划编号 BYJH202504300001
|
|
@@ -182,6 +193,18 @@ public class IotMaintenancePlanServiceImpl implements IotMaintenancePlanService
|
|
if (ObjectUtil.isEmpty(existPlan)) {
|
|
if (ObjectUtil.isEmpty(existPlan)) {
|
|
throw exception(IOT_MAINTENANCE_PLAN_NOT_EXISTS);
|
|
throw exception(IOT_MAINTENANCE_PLAN_NOT_EXISTS);
|
|
}
|
|
}
|
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
|
+ // 查验保养计划明细中的设备 只存在于1个保养计划中
|
|
|
|
+ deviceBOMs.forEach(bom -> {
|
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
|
+ });
|
|
|
|
+ IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
|
+ reqVO.setNotPlanId(updateReqVO.getMainPlan().getId());
|
|
|
|
+ reqVO.setDeviceIds(new ArrayList<>(deviceIds));
|
|
|
|
+ List<IotMaintenanceBomDO> boms = iotMaintenanceBomMapper.selectList(reqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(boms)) {
|
|
|
|
+ throw exception(IOT_MAINTENANCE_SAME_DEVICE_EXISTS);
|
|
|
|
+ }
|
|
IotMaintenancePlanSaveReqVO mainPlanSaveVO = updateReqVO.getMainPlan();
|
|
IotMaintenancePlanSaveReqVO mainPlanSaveVO = updateReqVO.getMainPlan();
|
|
IotMaintenancePlanDO iotMaintenancePlan = BeanUtils.toBean(mainPlanSaveVO, IotMaintenancePlanDO.class);
|
|
IotMaintenancePlanDO iotMaintenancePlan = BeanUtils.toBean(mainPlanSaveVO, IotMaintenancePlanDO.class);
|
|
iotMaintenancePlanMapper.updateById(iotMaintenancePlan);
|
|
iotMaintenancePlanMapper.updateById(iotMaintenancePlan);
|