|
|
@@ -1910,6 +1910,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
Set<Long> completedBomNodeIds = new HashSet<>();
|
|
|
// 每个保养项关联的物料集合
|
|
|
Map<Long, List<IotMainWorkOrderBomMaterialSaveReqVO>> bomMaterialsPair = new HashMap<>();
|
|
|
+ // key设备id-bomNodeId value保养时累计运行里程
|
|
|
+ Map<String, BigDecimal> mainMileagePair = new HashMap<>();
|
|
|
+ // key设备id-bomNodeId value保养时累计运行时长
|
|
|
+ Map<String, BigDecimal> mainRuntimePair = new HashMap<>();
|
|
|
// todo 先查询当前工单已经保养完成的保养项 避免重复更新 保养项的 上次保养时长...
|
|
|
// 统计保养项信息 是否保养完成 是否需要消耗物料
|
|
|
workOrderBOMs.forEach(bom -> {
|
|
|
@@ -1921,6 +1925,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
// 保养完成
|
|
|
completedBomNodeIds.add(bom.getBomNodeId());
|
|
|
}
|
|
|
+ // 组装每个保养项的 保养时累计运行里程 时长
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
+ mainMileagePair.put(uniqueKey, bom.getMainMileage());
|
|
|
+ mainRuntimePair.put(uniqueKey, bom.getMainRuntime());
|
|
|
});
|
|
|
// 只有保养完成的保养项关联的物料才会被统计出库(如果物料来源是 本地库存)
|
|
|
workOrderMaterials.forEach(material -> {
|
|
|
@@ -1998,7 +2006,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
tempBom.setStatus(1);
|
|
|
} */
|
|
|
}
|
|
|
- if ((ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) || bomMaterialsPair.containsKey(bom.getBomNodeId())) {
|
|
|
+ if ((ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) /* || bomMaterialsPair.containsKey(bom.getBomNodeId()) */) {
|
|
|
// 当前保养项已经保养完成 查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
|
deviceIds.add(bom.getDeviceId());
|
|
|
// 保养项下如果已经添加了物料 说明该保养项已经保养完成
|
|
|
@@ -2013,25 +2021,25 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
workOrderBomDOS.add(tempBom);
|
|
|
|
|
|
// 兼容APP未优化完的情况 所有保养项都设置了物料 设置保养工单 为 已执行
|
|
|
- if (!bomMaterialsPair.containsKey(bom.getBomNodeId())){
|
|
|
+ /* if (!bomMaterialsPair.containsKey(bom.getBomNodeId())){
|
|
|
// 存在未添加物料的保养项
|
|
|
appCompleted.set(false);
|
|
|
- }
|
|
|
+ } */
|
|
|
});
|
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
|
// 组装bom关联的设备信息
|
|
|
- Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(workOrderBOMs,
|
|
|
+ /* 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);
|
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
|
- if (mainCompleted.get() || appCompleted.get()) {
|
|
|
+ if (mainCompleted.get() /* || appCompleted.get() */) {
|
|
|
// 兼容APP未优化完成的情况 所有保养项都添加了物料 设置 保养工单 为 已执行
|
|
|
updateObj.setResult(2);
|
|
|
}
|
|
|
@@ -2051,22 +2059,22 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
boundedMultiAttrNames.add(bom.getType());
|
|
|
}
|
|
|
});
|
|
|
- List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
+ /* List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(boundedMultiAttrNames)) {
|
|
|
multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, boundedMultiAttrNames, null);
|
|
|
- }
|
|
|
+ } */
|
|
|
// key(设备id-累计时长属性名称) value时长属性累计时长数值
|
|
|
- Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
+ /* Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
|
multipleAccumulatedData.forEach(data -> {
|
|
|
String uniqueKey = StrUtil.join("-", data.getDeviceId(), data.getPointName());
|
|
|
tempTotalRunDataPair.put(uniqueKey, data.getTotalRunTime());
|
|
|
});
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
// 单一累计属性集合
|
|
|
- Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
- new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
|
|
|
+ /* Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
+ new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null); */
|
|
|
// 查询保养工单关联的保养计划 明细
|
|
|
IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
reqVO.setPlanId(updateObj.getPlanId());
|
|
|
@@ -2077,10 +2085,11 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (CollUtil.isNotEmpty(maintenanceBomS)) {
|
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
|
maintenanceBomS.forEach(bom -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
|
- BigDecimal totalMileage = BigDecimal.ZERO;
|
|
|
+ // BigDecimal totalMileage = BigDecimal.ZERO;
|
|
|
// 设置了 运行里程 保养规则
|
|
|
- if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
+ /* if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
totalMileage = deviceRunLog.getTotalMileage();
|
|
|
} else {
|
|
|
@@ -2089,15 +2098,15 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (tempTotalRunDataPair.containsKey(uniqueKeyType)) {
|
|
|
totalMileage = tempTotalRunDataPair.get(uniqueKeyType);
|
|
|
}
|
|
|
- }
|
|
|
- if (ObjUtil.isNotEmpty(totalMileage) && totalMileage.compareTo(BigDecimal.ZERO)>0) {
|
|
|
- bom.setLastRunningKilometers(totalMileage);
|
|
|
+ } */
|
|
|
+ if (mainMileagePair.containsKey(uniqueKey)) {
|
|
|
+ bom.setLastRunningKilometers(mainMileagePair.get(uniqueKey));
|
|
|
}
|
|
|
}
|
|
|
if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
|
- BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
|
+ // BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
|
// 设置了 运行时间 保养规则
|
|
|
- if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
+ /* if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
totalRunTime = deviceRunLog.getTotalRunTime();
|
|
|
} else {
|
|
|
@@ -2106,9 +2115,9 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
totalRunTime = tempTotalRunDataPair.get(uniqueKey);
|
|
|
}
|
|
|
- }
|
|
|
- if (ObjUtil.isNotEmpty(totalRunTime) && totalRunTime.compareTo(BigDecimal.ZERO)>0) {
|
|
|
- bom.setLastRunningTime(totalRunTime);
|
|
|
+ } */
|
|
|
+ if (mainRuntimePair.containsKey(uniqueKey)) {
|
|
|
+ bom.setLastRunningTime(mainRuntimePair.get(uniqueKey));
|
|
|
}
|
|
|
}
|
|
|
if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|