|
@@ -16,10 +16,12 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo.IotMain
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.IotModelTemplateAttrsPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmaintenancebom.IotMaintenanceBomDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO;
|
|
|
import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicerunlog.IotDeviceRunLogService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotmaintenancebom.IotMaintenanceBomService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotmainworkorder.IotMainWorkOrderService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotmodeltemplateattrs.IotModelTemplateAttrsService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
@@ -33,6 +35,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -54,6 +57,8 @@ public class IotMaintenanceBomController {
|
|
|
private IotDeviceRunLogService iotDeviceRunLogService;
|
|
|
@Resource
|
|
|
private IotModelTemplateAttrsService iotModelTemplateAttrsService;
|
|
|
+ @Resource
|
|
|
+ private IotMainWorkOrderService iotMainWorkOrderService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建PMS 保养计划明细BOM")
|
|
@@ -117,6 +122,10 @@ public class IotMaintenanceBomController {
|
|
|
Set<String> pointNames = new HashSet<>();
|
|
|
// 多个累计类型属性名称集合
|
|
|
Set<String> multiPointNames = new HashSet<>();
|
|
|
+ // 查询保养计划保养项的上次保养时间 唯一键
|
|
|
+ Set<String> lastMaintenanceDateKey = new HashSet<>();
|
|
|
+ // 保养计划中保养项BOM节点id集合
|
|
|
+ Set<Long> bomNodeIds = new HashSet<>();
|
|
|
BOMs.forEach(bom -> {
|
|
|
if (StrUtil.isNotBlank(bom.getCode())) {
|
|
|
pointNames.add(bom.getCode());
|
|
@@ -124,7 +133,11 @@ public class IotMaintenanceBomController {
|
|
|
if (StrUtil.isNotBlank(bom.getType())) {
|
|
|
pointNames.add(bom.getType());
|
|
|
}
|
|
|
+ // 设置唯一健 标识 标识保养项的 历史保养工单中最新的上次保养时间
|
|
|
+ // lastMaintenanceDateKey.add(StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId()));
|
|
|
+ bomNodeIds.add(bom.getBomNodeId());
|
|
|
});
|
|
|
+
|
|
|
// 设备对应的设备分类 map
|
|
|
Map<Long, Long> deviceCategoryPair = new HashMap<>();
|
|
|
Set<Long> deviceCategoryIds = new HashSet<>();
|
|
@@ -138,6 +151,18 @@ public class IotMaintenanceBomController {
|
|
|
deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 查询所有保养项 历史保养记录 (保养项所有历史工单中最新的保养时间)
|
|
|
+ Map<String, LocalDateTime> latestMaintenanceDatePair = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(bomNodeIds)) {
|
|
|
+ List<IotMainWorkOrderBomDO> latestWorkOrderBomS = iotMainWorkOrderService.historyWorkOrderBoms(deviceIds, bomNodeIds);
|
|
|
+ if (CollUtil.isNotEmpty(latestWorkOrderBomS)) {
|
|
|
+ latestWorkOrderBomS.forEach(bom -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
+ latestMaintenanceDatePair.put(uniqueKey, bom.getUpdateTime());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
// k设备id v设备分类包含的模板中与累计运行时长、累计运行公里数相关的属性(正常属性)集合
|
|
|
Map<Long, List<IotModelTemplateAttrsDO>> deviceAttrsPair = new HashMap<>();
|
|
|
// k设备id v设备分类包含的模板中与累计运行时长、累计运行公里数相关的属性(多种累计属性)集合
|
|
@@ -313,7 +338,11 @@ public class IotMaintenanceBomController {
|
|
|
bomVO.setMileageAccumulatedAttrs(mileageRunLogs);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ // 设置保养项的上次保养时间
|
|
|
+ String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getBomNodeId());
|
|
|
+ if (latestMaintenanceDatePair.containsKey(uniqueKey)) {
|
|
|
+ bomVO.setLastMaintenanceDate(latestMaintenanceDatePair.get(uniqueKey));
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|