|
@@ -162,6 +162,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
Set<String> boundedMultiAttrNames = new HashSet<>();
|
|
|
// 工单保养项中包含的设备id集合
|
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
|
+ Set<Long> deviceCategoryIds = new HashSet<>();
|
|
|
+ Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(workOrderBomS)) {
|
|
|
// 查询所有保养计划 保养项 中已经绑定的 多个累计时长 公里数 属性名称值
|
|
|
workOrderBomS.forEach(bom -> {
|
|
@@ -177,7 +179,17 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
deviceIds.add(bom.getDeviceId());
|
|
|
}
|
|
|
});
|
|
|
+ // 组装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());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 查询 运行记录模板中包含多个累计 时长 公里数 属性的集合
|
|
|
List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(boundedMultiAttrNames)) {
|
|
@@ -192,7 +204,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
});
|
|
|
}
|
|
|
// 查询 运行记录模板中 正常的累计时长 公里数集合
|
|
|
- Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMap(new ArrayList<>(deviceIds));
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
+ new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
|
// 以保养工单为维度 统计每个工单相关的保养项的最近保养距离 key保养工单id value保养工单下每个保养项的的最小保养距离集合
|
|
|
Map<Long, List<Map<String, Object>>> orderDistancePair = new HashMap<>();
|
|
|
// key保养工单id value设备保养工单明细下所有保养规则数据最小值
|
|
@@ -318,12 +331,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
reqVO.setResult(1);
|
|
|
reqVO.setType(1);
|
|
|
List<Long> workOrderIds = new ArrayList<>();
|
|
|
- // List<IotMainWorkOrderDO> workOrders = iotMainWorkOrderMapper.selectList(reqVO);
|
|
|
- /* if (CollUtil.isNotEmpty(workOrders)) {
|
|
|
- workOrders.forEach(order -> {
|
|
|
- workOrderIds.add(order.getId());
|
|
|
- });
|
|
|
- } */
|
|
|
+
|
|
|
List<IotMainWorkOrderBomDO> workOrderBomS = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(workOrderIds)) {
|
|
|
bomReqVO.setWorkOrderIds(workOrderIds);
|
|
@@ -348,6 +356,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
mainBomS = iotMaintenanceBomMapper.selectList(mainBomReqVO);
|
|
|
}
|
|
|
Set<String> boundedMultiAttrNames = new HashSet<>();
|
|
|
+ Set<Long> deviceCategoryIds = new HashSet<>();
|
|
|
+ Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(mainBomS)) {
|
|
|
mainBomDeviceIds = CollUtil.isEmpty(mainBomS)
|
|
|
? Collections.emptySet()
|
|
@@ -366,6 +376,16 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
boundedMultiAttrNames.add(bom.getCode());
|
|
|
}
|
|
|
});
|
|
|
+ // 查询所有设备类别id
|
|
|
+ // 组装bom关联的设备信息
|
|
|
+ Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(mainBomS,
|
|
|
+ bom -> Stream.of(bom.getDeviceId())));
|
|
|
+ if (CollUtil.isNotEmpty(deviceMap)) {
|
|
|
+ deviceMap.forEach((k,v) -> {
|
|
|
+ deviceCategoryIds.add(v.getAssetClass());
|
|
|
+ deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
deviceIds.addAll(mainBomDeviceIds);
|
|
|
if (CollUtil.isEmpty(deviceIds)){
|
|
@@ -387,14 +407,16 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
|
|
|
// 查询 运行记录模板中 正常的累计时长 公里数集合
|
|
|
- Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMap(new ArrayList<>(deviceIds));
|
|
|
+ // Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMap(new ArrayList<>(deviceIds));
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap =
|
|
|
+ iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds), new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
|
// 以设备为维度统计每个设备相关的保养项的最近保养距离 key设备id value设备下每个保养项的的最小保养距离集合
|
|
|
Map<Long, List<Map<String, Object>>> orderDistancePair = new HashMap<>();
|
|
|
// 设备保养明细 key设备id value设备保养工单明细下所有保养规则数据最小值
|
|
|
Map<Long, String> resultMap = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(mainBomS)) {
|
|
|
// 遍历保养计划明细 计算 保养计划中的设备 的最近的保养时间
|
|
|
- mainBomS.forEach(bom -> {
|
|
|
+ for (IotMaintenanceBomDO bom : mainBomS) {
|
|
|
BigDecimal runningTimeDistance = null;
|
|
|
BigDecimal runningKiloDistance = null;
|
|
|
BigDecimal naturalDateDistance = null;
|
|
@@ -468,6 +490,9 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
tempDistances.add(tempDistance);
|
|
|
orderDistancePair.put(bom.getDeviceId(), tempDistances);
|
|
|
}
|
|
|
+ }
|
|
|
+ mainBomS.forEach(bom -> {
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
// 计算出每个保养工单明细的不同保养规则的保养距离最小值
|
|
@@ -589,6 +614,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
public PageResult<IotDeviceRespVO> maintenanceSearch(IotMainWorkOrderPageReqVO pageReqVO) {
|
|
|
// 所有保养计划 明细中待保养的最近距离 里程/时间/自然日
|
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
|
+ Set<Long> deviceCategoryIds = new HashSet<>();
|
|
|
+ Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
Set<Long> orderDeviceIds = new HashSet<>();
|
|
|
// 查询保养计划明细中不包含 deviceIds 的设备id集合
|
|
|
List<IotMaintenanceBomDO> mainBomS = new ArrayList<>();
|
|
@@ -615,6 +642,15 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
boundedMultiAttrNames.add(bom.getCode());
|
|
|
}
|
|
|
});
|
|
|
+ // 组装bom关联的设备信息
|
|
|
+ Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(mainBomS,
|
|
|
+ bom -> Stream.of(bom.getDeviceId())));
|
|
|
+ if (CollUtil.isNotEmpty(deviceMap)) {
|
|
|
+ deviceMap.forEach((k,v) -> {
|
|
|
+ deviceCategoryIds.add(v.getAssetClass());
|
|
|
+ deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
deviceIds.addAll(mainBomDeviceIds);
|
|
|
if (CollUtil.isEmpty(deviceIds)){
|
|
@@ -636,7 +672,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
|
|
|
// 查询 运行记录模板中 正常的累计时长 公里数集合
|
|
|
- Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMap(new ArrayList<>(deviceIds));
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
+ new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
|
// 以设备为维度统计每个设备相关的保养项的最近保养距离 key设备id value设备下每个保养项的的最小保养距离集合
|
|
|
Map<Long, List<Map<String, Object>>> orderDistancePair = new HashMap<>();
|
|
|
// 设备保养明细 key设备id value设备保养工单明细下所有保养规则数据最小值
|
|
@@ -1204,6 +1241,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
AtomicBoolean mainCompleted = new AtomicBoolean(true);
|
|
|
// 已经完成保养的保养项关联的 设备id 集合
|
|
|
Set<Long> deviceIds = new HashSet<>();
|
|
|
+ Set<Long> deviceCategoryIds = new HashSet<>();
|
|
|
+ Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
// 需要更新 运行时长周期 的设备id 集合
|
|
|
Set<Long> mctDeviceIds = new HashSet<>();
|
|
|
// 需要更新 运行时长周期 的保养项id 集合
|
|
@@ -1270,6 +1309,17 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
deviceBomPair.put(uniqueKey, bom);
|
|
|
}
|
|
|
});
|
|
|
+ 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);
|
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
|
if (mainCompleted.get()) {
|
|
@@ -1279,7 +1329,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
// 如果有保养项已经保养完成,根据保养项规则 实时更新 关联 的 保养计划 明细 保养项的 ‘上次保养运行时间、上次保养自然日期、上次保养公里数’
|
|
|
// 查询明细中所有设备的累计运行里程、累计运行时间
|
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
- Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMap(new ArrayList<>(deviceIds));
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
+ new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
|
// 查询保养工单关联的保养计划 明细
|
|
|
IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
reqVO.setPlanId(updateObj.getPlanId());
|