|
@@ -1291,6 +1291,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
// 标识保养项是否已经添加了物料
|
|
// 标识保养项是否已经添加了物料
|
|
Set<Long> bomNodeIds = new HashSet<>();
|
|
Set<Long> bomNodeIds = new HashSet<>();
|
|
AtomicBoolean mainCompleted = new AtomicBoolean(true);
|
|
AtomicBoolean mainCompleted = new AtomicBoolean(true);
|
|
|
|
+ // 兼容APP未优化完成的情况 所有保养项都添加了物料 设置工单 为 已执行
|
|
|
|
+ AtomicBoolean appCompleted = new AtomicBoolean(true);
|
|
// 已经完成保养的保养项关联的 设备id 集合
|
|
// 已经完成保养的保养项关联的 设备id 集合
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
Set<Long> deviceCategoryIds = new HashSet<>();
|
|
Set<Long> deviceCategoryIds = new HashSet<>();
|
|
@@ -1303,6 +1305,9 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
Set<Long> materialBomNodeIds = new HashSet<>();
|
|
Set<Long> materialBomNodeIds = new HashSet<>();
|
|
// 保养完成的保养项id集合
|
|
// 保养完成的保养项id集合
|
|
Set<Long> completedBomNodeIds = new HashSet<>();
|
|
Set<Long> completedBomNodeIds = new HashSet<>();
|
|
|
|
+ // 每个保养项关联的物料集合
|
|
|
|
+ Map<Long, List<IotMainWorkOrderBomMaterialSaveReqVO>> bomMaterialsPair = new HashMap<>();
|
|
|
|
+ // todo 先查询当前工单已经保养完成的保养项 避免重复更新 保养项的 上次保养时长...
|
|
// 统计保养项信息 是否保养完成 是否需要消耗物料
|
|
// 统计保养项信息 是否保养完成 是否需要消耗物料
|
|
workOrderBOMs.forEach(bom -> {
|
|
workOrderBOMs.forEach(bom -> {
|
|
if ("0".equals(bom.getRule())) {
|
|
if ("0".equals(bom.getRule())) {
|
|
@@ -1323,6 +1328,17 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
workOrderBomMaterialDOS.add(tempMaterial);
|
|
workOrderBomMaterialDOS.add(tempMaterial);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 兼容 APP 未更新的情况 暂定 所有保养项都添加了物料 设置 保养工单 为已执行
|
|
|
|
+ if (bomMaterialsPair.containsKey(material.getBomNodeId())) {
|
|
|
|
+ List<IotMainWorkOrderBomMaterialSaveReqVO> tempBomMaterials = bomMaterialsPair.get(material.getBomNodeId());
|
|
|
|
+ tempBomMaterials.add(material);
|
|
|
|
+ bomMaterialsPair.put(material.getBomNodeId(), tempBomMaterials);
|
|
|
|
+ } else {
|
|
|
|
+ List<IotMainWorkOrderBomMaterialSaveReqVO> tempBomMaterials = new ArrayList<>();
|
|
|
|
+ tempBomMaterials.add(material);
|
|
|
|
+ bomMaterialsPair.put(material.getBomNodeId(), tempBomMaterials);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (completedBomNodeIds.contains(material.getBomNodeId()) && "本地库存".equals(material.getMaterialSource())) {
|
|
if (completedBomNodeIds.contains(material.getBomNodeId()) && "本地库存".equals(material.getMaterialSource())) {
|
|
if (ObjUtil.isNotEmpty(material.getFactoryId())) {
|
|
if (ObjUtil.isNotEmpty(material.getFactoryId())) {
|
|
factoryIds.add(material.getFactoryId());
|
|
factoryIds.add(material.getFactoryId());
|
|
@@ -1378,7 +1394,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
bomNodeIds.add(bom.getBomNodeId());
|
|
bomNodeIds.add(bom.getBomNodeId());
|
|
tempBom.setStatus(1);
|
|
tempBom.setStatus(1);
|
|
} */
|
|
} */
|
|
- } else if (ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) {
|
|
|
|
|
|
+ }
|
|
|
|
+ if ((ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) || bomMaterialsPair.containsKey(bom.getBomNodeId())) {
|
|
// 当前保养项已经保养完成 查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
// 当前保养项已经保养完成 查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
deviceIds.add(bom.getDeviceId());
|
|
deviceIds.add(bom.getDeviceId());
|
|
// 保养项下如果已经添加了物料 说明该保养项已经保养完成
|
|
// 保养项下如果已经添加了物料 说明该保养项已经保养完成
|
|
@@ -1391,6 +1408,12 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
deviceBomPair.put(uniqueKey, bom);
|
|
deviceBomPair.put(uniqueKey, bom);
|
|
}
|
|
}
|
|
workOrderBomDOS.add(tempBom);
|
|
workOrderBomDOS.add(tempBom);
|
|
|
|
+
|
|
|
|
+ // 兼容APP未优化完的情况 所有保养项都设置了物料 设置保养工单 为 已执行
|
|
|
|
+ if (!bomMaterialsPair.containsKey(bom.getBomNodeId())){
|
|
|
|
+ // 存在未添加物料的保养项
|
|
|
|
+ appCompleted.set(false);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
// 组装bom关联的设备信息
|
|
// 组装bom关联的设备信息
|
|
@@ -1405,7 +1428,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
}
|
|
}
|
|
iotMainWorkOrderBomMapper.updateBatch(workOrderBomDOS);
|
|
iotMainWorkOrderBomMapper.updateBatch(workOrderBomDOS);
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
- if (mainCompleted.get()) {
|
|
|
|
|
|
+ if (mainCompleted.get() || appCompleted.get()) {
|
|
|
|
+ // 兼容APP未优化完成的情况 所有保养项都添加了物料 设置 保养工单 为 已执行
|
|
updateObj.setResult(2);
|
|
updateObj.setResult(2);
|
|
}
|
|
}
|
|
iotMainWorkOrderMapper.updateById(updateObj);
|
|
iotMainWorkOrderMapper.updateById(updateObj);
|
|
@@ -1729,8 +1753,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
// 记录出库 需要保养项id
|
|
// 记录出库 需要保养项id
|
|
bomMaterialPair.put(uniqueKey, material);
|
|
bomMaterialPair.put(uniqueKey, material);
|
|
}
|
|
}
|
|
|
|
+ iotMainWorkOrderBomMaterialMapper.insert(tempMaterial);
|
|
});
|
|
});
|
|
- iotMainWorkOrderBomMaterialMapper.insertBatch(workOrderBomMaterialDOS);
|
|
|
|
|
|
+ // 暂时不用 insertBatch 看看是否能避免 java.sql.BatchUpdateException: Duplicate entry 异常
|
|
|
|
+ // iotMainWorkOrderBomMaterialMapper.insertBatch(workOrderBomMaterialDOS);
|
|
// 只扣减本地库存 不处理SAP库存 同时 记录出库
|
|
// 只扣减本地库存 不处理SAP库存 同时 记录出库
|
|
if (CollUtil.isNotEmpty(factoryIds) && CollUtil.isNotEmpty(costCenterIds) && CollUtil.isNotEmpty(materialCodes)) {
|
|
if (CollUtil.isNotEmpty(factoryIds) && CollUtil.isNotEmpty(costCenterIds) && CollUtil.isNotEmpty(materialCodes)) {
|
|
IotLockStockPageReqVO reqVO = new IotLockStockPageReqVO();
|
|
IotLockStockPageReqVO reqVO = new IotLockStockPageReqVO();
|