|
@@ -628,6 +628,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
AtomicBoolean mainCompleted = new AtomicBoolean(true);
|
|
|
// 已经完成保养的保养项关联的 设备id 集合
|
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
|
+ // 需要更新 运行时长周期 的设备id 集合
|
|
|
+ Set<Long> mctDeviceIds = new HashSet<>();
|
|
|
+ // 需要更新 运行时长周期 的保养项id 集合
|
|
|
+ Set<Long> mctBomNodeIds = new HashSet<>();
|
|
|
workOrderMaterials.forEach(material -> {
|
|
|
if (ObjUtil.isEmpty(material.getId())) {
|
|
|
// 兼容保养工单中部分保养项保养完成 部分保养项 延期保养的情况 这里只新增延期保养 或正常 保养的物料
|
|
@@ -662,8 +666,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
});
|
|
|
// 添加 工单消耗的物料记录
|
|
|
iotMainWorkOrderBomMaterialMapper.insertBatch(workOrderBomMaterialDOS);
|
|
|
+ // key设备id-保养项BOM节点id value保养工单明细对象 用于更新关联的保养计划保养项
|
|
|
+ Map<String, IotMainWorkOrderBomSaveReqVO> deviceBomPair = new HashMap<>();
|
|
|
workOrderBOMs.forEach(bom -> {
|
|
|
- if (0 == bom.getStatus()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getStatus()) && 0 == bom.getStatus()) {
|
|
|
// 兼容保养工单中部分保养项保养完成 部分保养项 延期保养的情况 这里只更新延期保养 或正常 保养的物料
|
|
|
IotMainWorkOrderBomDO tempBom = BeanUtils.toBean(bom, IotMainWorkOrderBomDO.class);
|
|
|
// 如果工单明细中任何一个保养项设置了 任何一种推迟保养规则 工单结果 不能设置为 已执行
|
|
@@ -681,6 +687,11 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
tempBom.setStatus(1);
|
|
|
}
|
|
|
workOrderBomDOS.add(tempBom);
|
|
|
+ // 设置需要更新 关联保养计划 保养项 运行时间周期(H) 的设备id 保养项id 集合
|
|
|
+ mctDeviceIds.add(bom.getDeviceId());
|
|
|
+ mctBomNodeIds.add(bom.getBomNodeId());
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
+ deviceBomPair.put(uniqueKey, bom);
|
|
|
}
|
|
|
});
|
|
|
iotMainWorkOrderBomMapper.updateBatch(workOrderBomDOS);
|
|
@@ -703,7 +714,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (CollUtil.isNotEmpty(maintenanceBomS)) {
|
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
|
maintenanceBomS.forEach(bom -> {
|
|
|
- if (0 == bom.getMileageRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
|
// 设置了 运行里程 保养规则
|
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
@@ -713,7 +724,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (0 == bom.getRunningTimeRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
|
// 设置了 运行时间 保养规则
|
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
@@ -723,7 +734,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (0 == bom.getNaturalDateRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|
|
|
// 设置了 自然日期 保养规则
|
|
|
bom.setLastNaturalDate(LocalDateTime.now());
|
|
|
}
|
|
@@ -734,6 +745,29 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 更新工单关联的保养计划 保养项 的 运行时间周期(H)
|
|
|
+ if (CollUtil.isNotEmpty(mctDeviceIds) && CollUtil.isNotEmpty(mctBomNodeIds)) {
|
|
|
+ IotMaintenanceBomPageReqVO mctReqVO = new IotMaintenanceBomPageReqVO();
|
|
|
+ mctReqVO.setPlanId(updateObj.getPlanId());
|
|
|
+ mctReqVO.setDeviceIds(new ArrayList<>(mctDeviceIds));
|
|
|
+ mctReqVO.setBomNodeIds(new ArrayList<>(mctBomNodeIds));
|
|
|
+ List<IotMaintenanceBomDO> mctMaintenanceBomS = iotMaintenanceBomService.getIotMainPlanBomList(mctReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(mctMaintenanceBomS)) {
|
|
|
+ List<IotMaintenanceBomDO> mctMainBomS = new ArrayList<>();
|
|
|
+ mctMaintenanceBomS.forEach(bom -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
+ if (deviceBomPair.containsKey(uniqueKey)) {
|
|
|
+ IotMainWorkOrderBomSaveReqVO workOrderBom = deviceBomPair.get(uniqueKey);
|
|
|
+ bom.setNextRunningTime(workOrderBom.getNextRunningTime());
|
|
|
+ mctMainBomS.add(bom);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (CollUtil.isNotEmpty(mctMainBomS)) {
|
|
|
+ iotMaintenanceBomMapper.updateBatch(mctMainBomS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 查询关联的保养工单
|
|
|
IotMainWorkOrderPageReqVO orderReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
orderReqVO.setOrderGroupId(updateObj.getOrderGroupId());
|
|
@@ -773,6 +807,9 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ // 如果在填报工单时 填写了 保养项 中的 ‘运行时间周期(H)’ 保存时需要同步到 保养工单 关联的 保养计划的 对应的保养项的 ‘运行时间周期(H)’
|
|
|
+ // 包含 延时保养 的情况
|
|
|
+
|
|
|
// 只扣减本地库存 不处理SAP库存
|
|
|
if (CollUtil.isNotEmpty(factoryIds) && CollUtil.isNotEmpty(costCenterIds) && CollUtil.isNotEmpty(materialCodes)) {
|
|
|
IotLockStockPageReqVO reqVO = new IotLockStockPageReqVO();
|