|
|
@@ -1934,8 +1934,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
// 组装每个保养项的 保养时累计运行里程 时长
|
|
|
String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
- mainMileagePair.put(uniqueKey, bom.getMainMileage());
|
|
|
- mainRuntimePair.put(uniqueKey, bom.getMainRuntime());
|
|
|
+ mainMileagePair.put(uniqueKey, ObjUtil.isEmpty(bom.getMainMileage()) ? BigDecimal.ZERO : bom.getMainMileage());
|
|
|
+ mainRuntimePair.put(uniqueKey, ObjUtil.isEmpty(bom.getMainRuntime()) ? BigDecimal.ZERO : bom.getMainRuntime());
|
|
|
});
|
|
|
// 只有保养完成的保养项关联的物料才会被统计出库(如果物料来源是 本地库存)
|
|
|
workOrderMaterials.forEach(material -> {
|
|
|
@@ -2018,6 +2018,14 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
});
|
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
|
// 组装bom关联的设备信息
|
|
|
+ Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(workOrderBOMs,
|
|
|
+ bom -> Stream.of(bom.getDeviceId())));
|
|
|
+ if (CollUtil.isNotEmpty(deviceMap)) {
|
|
|
+ deviceMap.forEach((k,v) -> {
|
|
|
+ deviceCategoryIds.add(v.getAssetClass());
|
|
|
+ deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
iotMainWorkOrderBomMapper.updateBatch(workOrderBomDOS);
|
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
|
@@ -2029,7 +2037,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
// 如果有保养项已经保养完成,根据保养项规则 实时更新 关联 的 保养计划 明细 保养项的 ‘上次保养运行时间、上次保养自然日期、上次保养公里数’
|
|
|
// 查询明细中所有设备的累计运行里程、累计运行时间
|
|
|
// 全部按照多个累计属性 来统计
|
|
|
- if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
+ if (CollUtil.isNotEmpty(completedBomNodeIds) && CollUtil.isNotEmpty(deviceIds)) {
|
|
|
// 运行记录模板中 多种 累计时长 公里数 属性名称集合
|
|
|
Set<String> boundedMultiAttrNames = new HashSet<>();
|
|
|
workOrderBomDOS.forEach(bom -> {
|
|
|
@@ -2069,7 +2077,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
|
maintenanceBomS.forEach(bom -> {
|
|
|
String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
- if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule() && completedBomNodeIds.contains(bom.getBomNodeId())) {
|
|
|
BigDecimal totalMileage = BigDecimal.ZERO;
|
|
|
// 设置了 运行里程 保养规则
|
|
|
if (mainMileagePair.containsKey(uniqueKey)) {
|
|
|
@@ -2094,7 +2102,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule() && completedBomNodeIds.contains(bom.getBomNodeId())) {
|
|
|
BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
|
// 设置了 运行时间 保养规则
|
|
|
if (mainRuntimePair.containsKey(uniqueKey)) {
|
|
|
@@ -2118,7 +2126,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule() && completedBomNodeIds.contains(bom.getBomNodeId())) {
|
|
|
// 设置了 自然日期 保养规则
|
|
|
bom.setLastNaturalDate(LocalDateTime.now());
|
|
|
}
|