|
|
@@ -110,6 +110,15 @@ public class IotMainWorkOrderBomController {
|
|
|
return success(buildMainWorkOrderBomList(workOrderBOMs));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/maintenanceCumulativeValue")
|
|
|
+ @Operation(summary = "获得PMS 保养工单明细BOM列表 保养时累计公里数 时长")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-main-work-order-bom:query')")
|
|
|
+ public CommonResult<List<IotMainWorkOrderBomRespVO>> maintenanceCumulativeValue(@Valid IotMainWorkOrderBomPageReqVO reqVO) {
|
|
|
+ List<IotMainWorkOrderBomDO> workOrderBOMs = iotMainWorkOrderBomService.getIotMainWorkOrderBomList(reqVO);
|
|
|
+ // 组装bom关联的设备 保养时累计公里数 时长
|
|
|
+ return success(buildMaintenanceCumulativeValue(workOrderBOMs, reqVO.getActualStartTime()));
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/export-excel")
|
|
|
@Operation(summary = "导出PMS 保养计划明细BOM Excel")
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-main-work-order-bom:export')")
|
|
|
@@ -165,7 +174,7 @@ public class IotMainWorkOrderBomController {
|
|
|
}
|
|
|
});
|
|
|
Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(convertListByFlatMap(BOMs,
|
|
|
- bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair);
|
|
|
+ bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
|
|
|
// 查询 运行记录模板中包含多个累计 时长 公里数 属性的集合
|
|
|
List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
// key(设备id-累计时长属性名称) value多累计时长属性运行记录填报数值
|
|
|
@@ -231,4 +240,91 @@ public class IotMainWorkOrderBomController {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保养工单填报 查询各保养项指定时间的累计运行里程 时长 前端根据 bomNodeId 匹配
|
|
|
+ * @param BOMs
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<IotMainWorkOrderBomRespVO> buildMaintenanceCumulativeValue(List<IotMainWorkOrderBomDO> BOMs, String actualStartTime) {
|
|
|
+ if (CollUtil.isEmpty(BOMs) || StrUtil.isBlank(actualStartTime)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 组装bom关联的设备信息
|
|
|
+ Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(BOMs,
|
|
|
+ bom -> Stream.of(bom.getDeviceId())));
|
|
|
+
|
|
|
+ // 查询保养工单明细中继承自保养计划明细 的 code累计运行时长属性名称 type累计运行公里数属性名称
|
|
|
+ // 所有保养工单明细 已经 绑定了多个累计属性名称集合
|
|
|
+ Set<String> pointNames = new HashSet<>();
|
|
|
+ // 所有保养工单明细包含的设备id集合
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
+ Set<Long> deviceCategoryIds = new HashSet<>();
|
|
|
+ Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
+ // 保养j明细 保养项BOM节点id集合
|
|
|
+ Set<Long> bomNodeIds = new HashSet<>();
|
|
|
+ // 设备所属部门id集合
|
|
|
+ Set<Long> deptIds = new HashSet<>();
|
|
|
+ BOMs.forEach(bom -> {
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getDeviceId())) {
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
+ }
|
|
|
+ // 累计运行时长属性名称
|
|
|
+ if (StrUtil.isNotBlank(bom.getCode())) {
|
|
|
+ pointNames.add(bom.getCode());
|
|
|
+ }
|
|
|
+ // 累计运行公里数属性名称
|
|
|
+ if (StrUtil.isNotBlank(bom.getType())) {
|
|
|
+ pointNames.add(bom.getType());
|
|
|
+ }
|
|
|
+ bomNodeIds.add(bom.getBomNodeId());
|
|
|
+ // 组装bom关联的设备信息
|
|
|
+ if (CollUtil.isNotEmpty(deviceMap)) {
|
|
|
+ deviceMap.forEach((k,v) -> {
|
|
|
+ deviceCategoryIds.add(v.getAssetClass());
|
|
|
+ deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
+ deptIds.add(v.getDeptId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(convertListByFlatMap(BOMs,
|
|
|
+ bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair, actualStartTime);
|
|
|
+ // 查询 运行记录模板中包含多个累计 时长 公里数 属性的集合
|
|
|
+ List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
+ // key(设备id-累计时长属性名称) value多累计时长属性运行记录填报数值
|
|
|
+ Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
+ // 查询指定设备 指定 多累计属性名称 的设备运行记录数据集合数据
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(pointNames)) {
|
|
|
+ multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, pointNames);
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
|
+ multipleAccumulatedData.forEach(data -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", data.getDeviceId(), data.getPointName());
|
|
|
+ tempTotalRunDataPair.put(uniqueKey, data.getTotalRunTime());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return BeanUtils.toBean(BOMs, IotMainWorkOrderBomRespVO.class, bomVO -> {
|
|
|
+ MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
|
+ device -> bomVO.setMainMileage(device.getTotalMileage()));
|
|
|
+ MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
|
+ device -> bomVO.setMainRuntime(device.getTotalRunTime()));
|
|
|
+
|
|
|
+ // 运行记录模板中包含的多个累计类型属性
|
|
|
+ if (StrUtil.isNotBlank(bomVO.getCode())) {
|
|
|
+ // code 累计运行时长属性名称
|
|
|
+ String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getCode());
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
+ bomVO.setTempTotalRunTime(tempTotalRunDataPair.get(uniqueKey));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(bomVO.getType())) {
|
|
|
+ // type 累计运行公里数属性名称
|
|
|
+ String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getType());
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
+ bomVO.setTempTotalMileage(tempTotalRunDataPair.get(uniqueKey));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|