|
@@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMa
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
|
|
|
import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicematerial.IotDeviceMaterialService;
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicematerial.IotDeviceMaterialService;
|
|
@@ -35,7 +36,9 @@ import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
@@ -136,6 +139,9 @@ public class IotMainWorkOrderBomController {
|
|
|
if (CollUtil.isEmpty(BOMs)) {
|
|
if (CollUtil.isEmpty(BOMs)) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
+ // 保养工单都是基于单设备 查询 保养工单主表信息 获取 保养开始时间
|
|
|
|
|
+ // 如果 保养开始时间 有值,根据保养开始时间查询对应的保养时累计时长/里程
|
|
|
|
|
+
|
|
|
// 组装bom关联的设备信息
|
|
// 组装bom关联的设备信息
|
|
|
Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(BOMs,
|
|
Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(BOMs,
|
|
|
bom -> Stream.of(bom.getDeviceId())));
|
|
bom -> Stream.of(bom.getDeviceId())));
|
|
@@ -151,6 +157,7 @@ public class IotMainWorkOrderBomController {
|
|
|
Set<Long> bomNodeIds = new HashSet<>();
|
|
Set<Long> bomNodeIds = new HashSet<>();
|
|
|
// 设备所属部门id集合
|
|
// 设备所属部门id集合
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
+ AtomicReference<Long> workOrderId = new AtomicReference<>(); // 保养工单id
|
|
|
BOMs.forEach(bom -> {
|
|
BOMs.forEach(bom -> {
|
|
|
if (ObjUtil.isNotEmpty(bom.getDeviceId())) {
|
|
if (ObjUtil.isNotEmpty(bom.getDeviceId())) {
|
|
|
deviceIds.add(bom.getDeviceId());
|
|
deviceIds.add(bom.getDeviceId());
|
|
@@ -172,7 +179,20 @@ public class IotMainWorkOrderBomController {
|
|
|
deptIds.add(v.getDeptId());
|
|
deptIds.add(v.getDeptId());
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ workOrderId.set(bom.getWorkOrderId());
|
|
|
});
|
|
});
|
|
|
|
|
+ // 如果 保养开始时间 有值,根据保养开始时间查询对应的保养时累计时长/里程
|
|
|
|
|
+ IotMainWorkOrderDO workOrder = iotMainWorkOrderService.getIotMainWorkOrder(workOrderId.get());
|
|
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> specifiedDateDeviceRunLogMap = new HashMap<>();
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(workOrder.getActualStartTime())) {
|
|
|
|
|
+ // 定义格式化器(线程安全,可直接复用)
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ // 转换 LocalDateTime 为指定格式的字符串
|
|
|
|
|
+ String actualStartDate = workOrder.getActualStartTime().format(formatter);
|
|
|
|
|
+ specifiedDateDeviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(convertListByFlatMap(BOMs,
|
|
|
|
|
+ bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair, actualStartDate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(convertListByFlatMap(BOMs,
|
|
Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(convertListByFlatMap(BOMs,
|
|
|
bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
|
|
bom -> Stream.of(bom.getDeviceId())), new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
|
|
|
// 查询 运行记录模板中包含多个累计 时长 公里数 属性的集合
|
|
// 查询 运行记录模板中包含多个累计 时长 公里数 属性的集合
|
|
@@ -181,7 +201,7 @@ public class IotMainWorkOrderBomController {
|
|
|
Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
// 查询指定设备 指定 多累计属性名称 的设备运行记录数据集合数据
|
|
// 查询指定设备 指定 多累计属性名称 的设备运行记录数据集合数据
|
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(pointNames)) {
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(pointNames)) {
|
|
|
- multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, pointNames);
|
|
|
|
|
|
|
+ multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, pointNames, null);
|
|
|
}
|
|
}
|
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
|
multipleAccumulatedData.forEach(data -> {
|
|
multipleAccumulatedData.forEach(data -> {
|
|
@@ -204,12 +224,19 @@ public class IotMainWorkOrderBomController {
|
|
|
// key设备id-bom节点id value设备物料集合
|
|
// key设备id-bom节点id value设备物料集合
|
|
|
Map<String, List<IotDeviceMaterialRespVO>> deviceBomMaterialPair = iotDeviceMaterialService.bomMaterials(deptIds, deviceIds, bomNodeIds);
|
|
Map<String, List<IotDeviceMaterialRespVO>> deviceBomMaterialPair = iotDeviceMaterialService.bomMaterials(deptIds, deviceIds, bomNodeIds);
|
|
|
|
|
|
|
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> finalSpecifiedDateDeviceRunLogMap = specifiedDateDeviceRunLogMap;
|
|
|
return BeanUtils.toBean(BOMs, IotMainWorkOrderBomRespVO.class, bomVO -> {
|
|
return BeanUtils.toBean(BOMs, IotMainWorkOrderBomRespVO.class, bomVO -> {
|
|
|
// 设置设备相关信息
|
|
// 设置设备相关信息
|
|
|
MapUtils.findAndThen(deviceMap, bomVO.getDeviceId(),
|
|
MapUtils.findAndThen(deviceMap, bomVO.getDeviceId(),
|
|
|
device -> bomVO.setDeviceName(device.getDeviceName()));
|
|
device -> bomVO.setDeviceName(device.getDeviceName()));
|
|
|
MapUtils.findAndThen(deviceMap, bomVO.getDeviceId(),
|
|
MapUtils.findAndThen(deviceMap, bomVO.getDeviceId(),
|
|
|
device -> bomVO.setDeviceCode(device.getDeviceCode()));
|
|
device -> bomVO.setDeviceCode(device.getDeviceCode()));
|
|
|
|
|
+
|
|
|
|
|
+ MapUtils.findAndThen(finalSpecifiedDateDeviceRunLogMap, bomVO.getDeviceId(),
|
|
|
|
|
+ device -> bomVO.setMainRuntime(device.getTotalRunTime()));
|
|
|
|
|
+ MapUtils.findAndThen(finalSpecifiedDateDeviceRunLogMap, bomVO.getDeviceId(),
|
|
|
|
|
+ device -> bomVO.setMainMileage(device.getTotalMileage()));
|
|
|
|
|
+
|
|
|
MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
|
device -> bomVO.setTotalMileage(device.getTotalMileage()));
|
|
device -> bomVO.setTotalMileage(device.getTotalMileage()));
|
|
|
MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
MapUtils.findAndThen(deviceRunLogMap, bomVO.getDeviceId(),
|
|
@@ -295,7 +322,7 @@ public class IotMainWorkOrderBomController {
|
|
|
Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
// 查询指定设备 指定 多累计属性名称 的设备运行记录数据集合数据
|
|
// 查询指定设备 指定 多累计属性名称 的设备运行记录数据集合数据
|
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(pointNames)) {
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(pointNames)) {
|
|
|
- multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, pointNames);
|
|
|
|
|
|
|
+ multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, pointNames, actualStartTime);
|
|
|
}
|
|
}
|
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
|
multipleAccumulatedData.forEach(data -> {
|
|
multipleAccumulatedData.forEach(data -> {
|
|
@@ -315,14 +342,14 @@ public class IotMainWorkOrderBomController {
|
|
|
// code 累计运行时长属性名称
|
|
// code 累计运行时长属性名称
|
|
|
String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getCode());
|
|
String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getCode());
|
|
|
if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
- bomVO.setTempTotalRunTime(tempTotalRunDataPair.get(uniqueKey));
|
|
|
|
|
|
|
+ bomVO.setTempMainRunTime(tempTotalRunDataPair.get(uniqueKey));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (StrUtil.isNotBlank(bomVO.getType())) {
|
|
if (StrUtil.isNotBlank(bomVO.getType())) {
|
|
|
// type 累计运行公里数属性名称
|
|
// type 累计运行公里数属性名称
|
|
|
String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getType());
|
|
String uniqueKey = StrUtil.join("-", bomVO.getDeviceId(), bomVO.getType());
|
|
|
if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
- bomVO.setTempTotalMileage(tempTotalRunDataPair.get(uniqueKey));
|
|
|
|
|
|
|
+ bomVO.setTempMainMileage(tempTotalRunDataPair.get(uniqueKey));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|