|
@@ -1,8 +1,5 @@
|
|
|
package com.xy.service;
|
|
|
|
|
|
-import cn.hutool.json.JSONArray;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -13,7 +10,6 @@ import com.xy.collections.map.JMap;
|
|
|
import com.xy.dto.CommandMqtt;
|
|
|
import com.xy.dto.DeviceQualityDto;
|
|
|
import com.xy.dto.DeviceQualityValueDto;
|
|
|
-import com.xy.dto.PaterDto;
|
|
|
import com.xy.entity.DeviceInfo;
|
|
|
import com.xy.entity.DeviceQuality;
|
|
|
import com.xy.entity.DeviceQualityValue;
|
|
@@ -35,7 +31,6 @@ import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
import static com.xy.utils.PlusBeans.*;
|
|
|
|
|
@@ -217,33 +212,13 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
saves.forEach(deviceQuality -> deviceQualityValueDtoVos.add(new DeviceQualityValueDto.Vo().setQualityId(deviceQuality.getQualityId())));
|
|
|
deviceQualityValueService.save(deviceQualityValueDtoVos);
|
|
|
//发送mqtt指令
|
|
|
- Map<String, SysDictRedis> sysDictRedisMap = SysDictUtils.get(DeviceEnum.MQTT_CMD_TEMPLET_QUALITY.getKey());
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- String wkSn = LambdaUtils.getProperty(PaterDto::getWkSn);
|
|
|
- String actionType = LambdaUtils.getProperty(PaterDto::getActionType);
|
|
|
- String cmdType = LambdaUtils.getProperty(PaterDto::getCmdType);
|
|
|
- String data = LambdaUtils.getProperty(PaterDto::getData);
|
|
|
- sysDictRedisMap.forEach((s, sysDictRedis) -> {
|
|
|
- JSONObject obj;
|
|
|
- try {
|
|
|
- obj = JSONUtil.parseObj(sysDictRedis.getValue());
|
|
|
- } catch (Exception e) {
|
|
|
- return;
|
|
|
- }
|
|
|
- jsonObject.set(wkSn, obj.get(wkSn))
|
|
|
- .set(cmdType, obj.get(cmdType))
|
|
|
- .set(actionType, obj.get(actionType));
|
|
|
- jsonArray.add(obj.get(data));
|
|
|
- });
|
|
|
- jsonObject.set(data, jsonArray.toString());
|
|
|
- List<CommandMqtt> commandMqtts = new ArrayList<>(saves.size());
|
|
|
- saves.forEach(deviceQuality -> {
|
|
|
+ List<CommandMqtt> commandMqtts = new ArrayList<>(deviceQualitySaves.size());
|
|
|
+ for (DeviceQualityDto.Save deviceQualitySave : deviceQualitySaves) {
|
|
|
CommandMqtt commandMqtt = new CommandMqtt()
|
|
|
- .setDeviceId(deviceQuality.getDeviceId())
|
|
|
- .setTemplet(jsonObject);
|
|
|
+ .setDeviceId(deviceQualitySave.getDeviceId())
|
|
|
+ .setTemplet(deviceQualitySave.getTemplet());
|
|
|
commandMqtts.add(commandMqtt);
|
|
|
- });
|
|
|
+ }
|
|
|
mqttService.senCommand(commandMqtts);
|
|
|
return R.ok();
|
|
|
}
|