|
@@ -1,7 +1,17 @@
|
|
package com.xy.service.factory;
|
|
package com.xy.service.factory;
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
+import com.xy.dto.DeviceTempSetDto;
|
|
import com.xy.dto.MqttDto;
|
|
import com.xy.dto.MqttDto;
|
|
|
|
+import com.xy.dto.PaterDto;
|
|
|
|
+import com.xy.entity.DeviceTempSet;
|
|
|
|
+import com.xy.service.DeviceTempSetServiceImpl;
|
|
|
|
+import com.xy.utils.DataTime;
|
|
|
|
+import com.xy.utils.LambdaUtils;
|
|
import com.xy.utils.R;
|
|
import com.xy.utils.R;
|
|
|
|
+import com.xy.utils.enums.SetsEnum;
|
|
|
|
+import com.xy.utils.enums.TaskEnum;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -10,15 +20,46 @@ import java.util.List;
|
|
* 设置指令 接口实现
|
|
* 设置指令 接口实现
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
|
|
+@AllArgsConstructor
|
|
public class SetsCmdServiceImpl implements CmdService {
|
|
public class SetsCmdServiceImpl implements CmdService {
|
|
|
|
|
|
|
|
+ private DeviceTempSetServiceImpl deviceTempSetService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public R senCommand(List<MqttDto> mqttDtos) {
|
|
public R senCommand(List<MqttDto> mqttDtos) {
|
|
|
|
+ for (MqttDto mqttDto : mqttDtos) {
|
|
|
|
+ PaterDto pater = mqttDto.getPater();
|
|
|
|
+ JSONObject data = pater.getData();
|
|
|
|
+ String type = data.getStr(LambdaUtils.getProperty(TaskEnum::getType));
|
|
|
|
+ //温度设置指令
|
|
|
|
+ if (type.equals(SetsEnum.TEMPERATURE.getType())) {
|
|
|
|
+ DeviceTempSetDto.Save save = new DeviceTempSetDto.Save()
|
|
|
|
+ .setDeviceId(mqttDto.getDeviceId())
|
|
|
|
+ .setWorkMode(data.getStr("workModel"))
|
|
|
|
+ .setTempValue(data.getInt("target"))
|
|
|
|
+ .setJob1StartTime(DataTime.toLocal(data.getStr("start1")).toLocalTime())
|
|
|
|
+ .setJob1StartEnd(DataTime.toLocal(data.getStr("end1")).toLocalTime())
|
|
|
|
+ .setJob2StartTime(DataTime.toLocal(data.getStr("start2")).toLocalTime())
|
|
|
|
+ .setJob2StartEnd(DataTime.toLocal(data.getStr("end2")).toLocalTime())
|
|
|
|
+ .setJob3StartTime(DataTime.toLocal(data.getStr("start3")).toLocalTime())
|
|
|
|
+ .setJob3EndTime(DataTime.toLocal(data.getStr("end3")).toLocalTime());
|
|
|
|
+ deviceTempSetService.save(save);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public R resultBack(MqttDto.ResultBack resultBack) {
|
|
public R resultBack(MqttDto.ResultBack resultBack) {
|
|
|
|
+ DeviceTempSetDto.DeviceTempResultBack deviceTempResultBack = resultBack.getDeviceTempResultBack();
|
|
|
|
+ //温度设置指令
|
|
|
|
+ if (resultBack.getCmdType().equals(SetsEnum.TEMPERATURE.getType())) {
|
|
|
|
+ DeviceTempSetDto.Vo deviceTempSetVo = deviceTempSetService.getLastOne(new DeviceTempSetDto.GetLastOneDto().setDeviceId(deviceTempResultBack.getDeviceId())).getData();
|
|
|
|
+ DeviceTempSet deviceTempSet = new DeviceTempSet()
|
|
|
|
+ .setId(deviceTempSetVo.getId())
|
|
|
|
+ .setStatus(deviceTempResultBack.getDeviceTempSetStatusEnum().getCode());
|
|
|
|
+ deviceTempSetService.updateById(deviceTempSet);
|
|
|
|
+ }
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
}
|
|
}
|