|
@@ -61,7 +61,7 @@ public interface IotDeviceRunLogService {
|
|
|
*
|
|
|
* @return 设备运行数据记录
|
|
|
*/
|
|
|
- List<IotDeviceRunLogRespVO> distinctDevices(List<Long> ids);
|
|
|
+ List<IotDeviceRunLogRespVO> distinctDevices(List<Long> ids, List<Long> deviceCategoryIds);
|
|
|
|
|
|
/**
|
|
|
* 查询指定设备 运行记录模板属性对应的累计时长 累计里程
|
|
@@ -77,7 +77,41 @@ public interface IotDeviceRunLogService {
|
|
|
* @return 设备bom 关联 列表
|
|
|
*/
|
|
|
default Map<Long, IotDeviceRunLogRespVO> getDeviceRunLogMap(List<Long> ids){
|
|
|
- List<IotDeviceRunLogRespVO> list = distinctDevices(ids);
|
|
|
+ List<IotDeviceRunLogRespVO> list = distinctDevices(ids, null);
|
|
|
+ // 删除集合中的NULL元素
|
|
|
+ list.removeIf(deviceLog -> isAllFieldsNull(deviceLog));
|
|
|
+ // 暂时将查询出的2条记录设置为1条
|
|
|
+ // device_id total_run_time total_mileage point_name point_code
|
|
|
+ // 136 2444.00 0.00 台上发动机累计运转时长 sc
|
|
|
+ // 136 0.00 16510.00 底盘发动机累计公里数 gls
|
|
|
+ // 按 deviceId 分组并合并数据
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> mergedMap = new HashMap<>();
|
|
|
+ for (IotDeviceRunLogRespVO log : list) {
|
|
|
+ Long deviceId = log.getDeviceId();
|
|
|
+ // 跳过无效设备ID
|
|
|
+ if (deviceId == null) continue;
|
|
|
+
|
|
|
+ if (mergedMap.containsKey(deviceId)) {
|
|
|
+ // 合并已有记录
|
|
|
+ IotDeviceRunLogRespVO existing = mergedMap.get(deviceId);
|
|
|
+ mergeLogRecords(existing, log);
|
|
|
+ } else {
|
|
|
+ // 首次遇到该设备ID,直接放入Map
|
|
|
+ mergedMap.put(deviceId, log);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<IotDeviceRunLogRespVO> mergedList = new ArrayList<>(mergedMap.values());
|
|
|
+ return CollectionUtils.convertMap(mergedList, IotDeviceRunLogRespVO::getDeviceId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据设备id查询设备关联信息
|
|
|
+ *
|
|
|
+ * @param ids 设备id集合
|
|
|
+ * @return 设备bom 关联 列表
|
|
|
+ */
|
|
|
+ default Map<Long, IotDeviceRunLogRespVO> getDeviceRunLogMapAlone(List<Long> ids, List<Long> deviceCategoryIds){
|
|
|
+ List<IotDeviceRunLogRespVO> list = distinctDevices(ids, deviceCategoryIds);
|
|
|
// 删除集合中的NULL元素
|
|
|
list.removeIf(deviceLog -> isAllFieldsNull(deviceLog));
|
|
|
// 暂时将查询出的2条记录设置为1条
|