|
|
@@ -25,6 +25,7 @@ import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportServ
|
|
|
import cn.iocoder.yudao.module.pms.service.iotrydailyreport.IotRyDailyReportService;
|
|
|
import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.aliyun.tea.utils.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -311,6 +312,33 @@ public class IotOpeationFillController {
|
|
|
.flatMap(vo -> vo.getDeviceInfoList().stream())
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
+
|
|
|
+ // 1. 集合类型改为实体类列表
|
|
|
+ List<IotOpeationFillSaveReqVO > uniqueDeviceEntities = new ArrayList<>();
|
|
|
+
|
|
|
+ // 空值防护:先判断外层集合是否为null或空
|
|
|
+ if (createReqVO != null && !createReqVO.isEmpty()) {
|
|
|
+ uniqueDeviceEntities = createReqVO.stream()
|
|
|
+ // 1. 过滤外层集合中:内部 deviceInfoList 为 null 的元素
|
|
|
+ .filter(operationSaveInfo -> operationSaveInfo.getDeviceInfoList() != null)
|
|
|
+ // 2. 展开内层集合(合并为一个流)
|
|
|
+ .flatMap(operationSaveInfo -> operationSaveInfo.getDeviceInfoList().stream())
|
|
|
+ // 3. 过滤内层元素:deviceInfo 为 null 或 deviceId 为 null 的情况
|
|
|
+ .filter(deviceInfo -> deviceInfo != null && deviceInfo.getDeviceId() != null)
|
|
|
+ // 4. 核心修改:提取 deviceId 并创建实体类对象(而非转 String)
|
|
|
+ .map(deviceInfo -> {
|
|
|
+ IotOpeationFillSaveReqVO saveReqVO = new IotOpeationFillSaveReqVO();
|
|
|
+ saveReqVO.setDeviceId(deviceInfo.getDeviceId());
|
|
|
+ saveReqVO.setCreateTime(deviceInfo.getCreateTime());
|
|
|
+ return saveReqVO;
|
|
|
+ })
|
|
|
+ // 5. 去重:需重写实体类的 equals() 和 hashCode()(关键!)
|
|
|
+ .distinct()
|
|
|
+ // 6. 收集为实体类列表
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 验证数据不为空
|
|
|
if (CollectionUtils.isEmpty(allFillData)) {
|
|
|
return error(1, "设备数据不能为空");
|
|
|
@@ -339,10 +367,12 @@ public class IotOpeationFillController {
|
|
|
generateDailyReports(logDOList, deptMap, createDate,userId);
|
|
|
|
|
|
// 9. 批量更新工单填写状态
|
|
|
- iotOpeationFillService.batchUpdateFill(allFillData);
|
|
|
+ int a = iotOpeationFillService.batchUpdateFill(uniqueDeviceEntities);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 更新填写状态
|
|
|
+ updateFillOrderStatus(orderId, userId, createDate);
|
|
|
|
|
|
- // 5. 更新填写状态
|
|
|
- updateFillOrderStatus(orderId, userId, createDate);
|
|
|
|
|
|
return success(1);
|
|
|
|
|
|
@@ -681,7 +711,7 @@ public class IotOpeationFillController {
|
|
|
Map<String, Object> reportData = BeanUtil.beanToMap(saveReqVO);
|
|
|
|
|
|
for (IotDeviceRunLogDO log : deviceLogs) {
|
|
|
- IotDeviceRunLogDO descDO = descMap.get(log.getPointName()); // 从缓存获取,无数据库交互
|
|
|
+ IotDeviceRunLogDO descDO = iotOpeationFillService.getDesc(log);
|
|
|
if (descDO != null && reportData.containsKey(descDO.getPointName())) {
|
|
|
reportData.put(descDO.getPointName(), log.getFillContent());
|
|
|
}
|
|
|
@@ -703,11 +733,20 @@ public class IotOpeationFillController {
|
|
|
IotRyDailyReportSaveReqVO saveReqVO = new IotRyDailyReportSaveReqVO();
|
|
|
Map<String, Object> reportData = BeanUtil.beanToMap(saveReqVO);
|
|
|
|
|
|
+ IotOpeationFillDO reportDO = new IotOpeationFillDO();
|
|
|
for (IotDeviceRunLogDO log : deviceLogs) {
|
|
|
- IotDeviceRunLogDO descDO = descMap.get(log.getPointName()); // 从缓存获取,无数据库交互
|
|
|
+ //IotDeviceRunLogDO descDO = descMap.get(log.getPointName()); // 从缓存获取,无数据库交互
|
|
|
+ IotDeviceRunLogDO descDO = iotOpeationFillService.getDesc(log);
|
|
|
if (descDO != null && reportData.containsKey(descDO.getPointName())) {
|
|
|
reportData.put(descDO.getPointName(), log.getFillContent());
|
|
|
}
|
|
|
+
|
|
|
+ reportDO.setDeviceId(log.getDeviceId());
|
|
|
+ reportDO.setCreateTime(log.getCreateTime());
|
|
|
+ IotOpeationFillDO fillDO1 = iotOpeationFillService.isReport(reportDO);
|
|
|
+ if(fillDO1.getDeviceCategoryId()==228){
|
|
|
+ reportData.put("projectClassification","2");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 后续赋值和保存逻辑不变(建议日报也做批量保存,若存在多条设备)
|
|
|
@@ -715,6 +754,7 @@ public class IotOpeationFillController {
|
|
|
finalReport.setDeptId(fillStatus.getDeptId());
|
|
|
finalReport.setFillOrderCreateTime(createDate.atStartOfDay());
|
|
|
finalReport.setCreator(String.valueOf(fillStatus.getUserId()));
|
|
|
+
|
|
|
iotRyDailyReportService.createIotRyDailyReport(finalReport);
|
|
|
}
|
|
|
|