|
@@ -1435,7 +1435,33 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
iotMainWorkOrderMapper.updateById(updateObj);
|
|
iotMainWorkOrderMapper.updateById(updateObj);
|
|
// 如果有保养项已经保养完成,根据保养项规则 实时更新 关联 的 保养计划 明细 保养项的 ‘上次保养运行时间、上次保养自然日期、上次保养公里数’
|
|
// 如果有保养项已经保养完成,根据保养项规则 实时更新 关联 的 保养计划 明细 保养项的 ‘上次保养运行时间、上次保养自然日期、上次保养公里数’
|
|
// 查询明细中所有设备的累计运行里程、累计运行时间
|
|
// 查询明细中所有设备的累计运行里程、累计运行时间
|
|
|
|
+ // 全部按照多个累计属性 来统计
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
|
+ // 运行记录模板中 多种 累计时长 公里数 属性名称集合
|
|
|
|
+ Set<String> boundedMultiAttrNames = new HashSet<>();
|
|
|
|
+ workOrderBomDOS.forEach(bom -> {
|
|
|
|
+ // 查询保养计划明细已经绑定的 多种 累计时长 公里数 属性名称
|
|
|
|
+ if (StrUtil.isNotBlank(bom.getCode())) {
|
|
|
|
+ boundedMultiAttrNames.add(bom.getCode());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank(bom.getType())) {
|
|
|
|
+ boundedMultiAttrNames.add(bom.getType());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(boundedMultiAttrNames)) {
|
|
|
|
+ multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, boundedMultiAttrNames);
|
|
|
|
+ }
|
|
|
|
+ // key(设备id-累计时长属性名称) value时长属性累计时长数值
|
|
|
|
+ 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),
|
|
Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
// 查询保养工单关联的保养计划 明细
|
|
// 查询保养工单关联的保养计划 明细
|
|
@@ -1449,24 +1475,38 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
maintenanceBomS.forEach(bom -> {
|
|
maintenanceBomS.forEach(bom -> {
|
|
if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
|
|
+ BigDecimal totalMileage = BigDecimal.ZERO;
|
|
// 设置了 运行里程 保养规则
|
|
// 设置了 运行里程 保养规则
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
- BigDecimal totalMileage = deviceRunLog.getTotalMileage();
|
|
|
|
- if (ObjUtil.isNotEmpty(totalMileage) && totalMileage.compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
- bom.setLastRunningKilometers(totalMileage);
|
|
|
|
|
|
+ totalMileage = deviceRunLog.getTotalMileage();
|
|
|
|
+ } else {
|
|
|
|
+ // 保养项绑定的 累计公里数类型的属性值
|
|
|
|
+ String uniqueKeyType = StrUtil.join("-", bom.getDeviceId(), bom.getType());
|
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKeyType)) {
|
|
|
|
+ totalMileage = tempTotalRunDataPair.get(uniqueKeyType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (ObjUtil.isNotEmpty(totalMileage) && totalMileage.compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
+ bom.setLastRunningKilometers(totalMileage);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
|
|
+ BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
// 设置了 运行时间 保养规则
|
|
// 设置了 运行时间 保养规则
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
- BigDecimal totalRunTime = deviceRunLog.getTotalRunTime();
|
|
|
|
- if (ObjUtil.isNotEmpty(totalRunTime) && totalRunTime.compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
- bom.setLastRunningTime(totalRunTime);
|
|
|
|
|
|
+ totalRunTime = deviceRunLog.getTotalRunTime();
|
|
|
|
+ } else {
|
|
|
|
+ // 保养项绑定的 累计时长 类型的属性值
|
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getCode());
|
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
|
+ totalRunTime = tempTotalRunDataPair.get(uniqueKey);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (ObjUtil.isNotEmpty(totalRunTime) && totalRunTime.compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
+ bom.setLastRunningTime(totalRunTime);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|
|
if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|
|
// 设置了 自然日期 保养规则
|
|
// 设置了 自然日期 保养规则
|