|
@@ -1,7 +1,9 @@
|
|
|
package com.xy.service.factory.device.impl.alipay;
|
|
|
|
|
|
+import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.xy.alipay.SpiDeviceService;
|
|
|
import com.xy.annotate.Factory;
|
|
|
import com.xy.config.DeviceThreadPoolConfig;
|
|
@@ -13,6 +15,8 @@ import com.xy.consumer.disconnect.DisconnectedProducer;
|
|
|
import com.xy.device.EnumDeviceOnlineStatus;
|
|
|
import com.xy.dto.*;
|
|
|
import com.xy.dto.spi.DeviceAlarmNotifyDTO;
|
|
|
+import com.xy.dto.spi.DeviceAttributesNotifyDTO;
|
|
|
+import com.xy.dto.spi.DeviceSetAttributesNotifyDTO;
|
|
|
import com.xy.dto.spi.DeviceStatusChangeNotifyDTO;
|
|
|
import com.xy.entity.DeviceInfo;
|
|
|
import com.xy.entity.DeviceStatus;
|
|
@@ -28,6 +32,7 @@ import com.xy.vo.DeviceDetailVO;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
@@ -37,6 +42,7 @@ import java.util.List;
|
|
|
/**
|
|
|
* 支付宝开门柜设备 接口实现
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Factory(type = "2")
|
|
|
@AllArgsConstructor
|
|
|
@Api(tags = "支付宝开门柜设备")
|
|
@@ -200,6 +206,88 @@ public class AliPayOpenDeviceFatoryImpl implements DeviceFactory, SpiDeviceServi
|
|
|
return SpiResponseConst.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String deviceAttrNotify(DeviceAttributesNotifyDTO dto) {
|
|
|
+ log.info("温度、音量查询SPI通知:{}", JSONUtil.toJsonPrettyStr(dto));
|
|
|
+ String terminalId = dto.getTerminalId();
|
|
|
+ Boolean success = dto.getSuccess();
|
|
|
+ String type = dto.getType();
|
|
|
+ String value = dto.getValue();
|
|
|
+
|
|
|
+ //查询设备信息
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(terminalId));
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ log.warn("温度、音量查询SPI通知,无设备信息");
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+ DeviceStatus deviceStatus = deviceStatusService.getById(deviceInfo.getDeviceId());
|
|
|
+ if (deviceStatus == null) {
|
|
|
+ log.warn("温度、音量查询SPI通知,无设备状态记录");
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+ //音量更新
|
|
|
+ FunctionUtils.NoParamsNoResult updateVoice = () -> {
|
|
|
+ deviceStatus.setVoiceVolume(Integer.valueOf(value));
|
|
|
+ deviceStatusService.updateById(deviceStatus);
|
|
|
+ };
|
|
|
+ //温度更新
|
|
|
+ FunctionUtils.NoParamsNoResult updateTmp = () -> {
|
|
|
+ deviceStatus.setTempState(Integer.valueOf(value));
|
|
|
+ deviceStatusService.updateById(deviceStatus);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (BooleanUtil.isTrue(success)) {
|
|
|
+ //温度:TEMP 音量:VOL
|
|
|
+ if ("VOL".equals(type)) {
|
|
|
+ updateVoice.run();
|
|
|
+ } else if ("TEMP".equals(type)) {
|
|
|
+ updateTmp.run();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String deviceAttrSetNotify(DeviceSetAttributesNotifyDTO dto) {
|
|
|
+ log.info("温度、音量设置SPI通知:{}", JSONUtil.toJsonPrettyStr(dto));
|
|
|
+ String terminalId = dto.getTerminalId();
|
|
|
+ Boolean success = dto.getSuccess();
|
|
|
+ String type = dto.getType();
|
|
|
+ String value = dto.getValue();
|
|
|
+
|
|
|
+ //查询设备信息
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(terminalId));
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ log.warn("温度、音量设置SPI通知,无设备信息");
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+ DeviceStatus deviceStatus = deviceStatusService.getById(deviceInfo.getDeviceId());
|
|
|
+ if (deviceStatus == null) {
|
|
|
+ log.warn("温度、音量设置SPI通知,无设备状态记录");
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+ //音量更新
|
|
|
+ FunctionUtils.NoParamsNoResult updateVoice = () -> {
|
|
|
+ deviceStatus.setVoiceVolume(Integer.valueOf(value));
|
|
|
+ deviceStatusService.updateById(deviceStatus);
|
|
|
+ };
|
|
|
+ //温度更新
|
|
|
+ FunctionUtils.NoParamsNoResult updateTmp = () -> {
|
|
|
+ deviceStatus.setTempState(Integer.valueOf(value));
|
|
|
+ deviceStatusService.updateById(deviceStatus);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (BooleanUtil.isTrue(success)) {
|
|
|
+ //温度:TEMP 音量:VOL
|
|
|
+ if ("VOL".equals(type)) {
|
|
|
+ updateVoice.run();
|
|
|
+ } else if ("TEMP".equals(type)) {
|
|
|
+ updateTmp.run();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SpiResponseConst.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation("刷新设备联网状态API")
|
|
|
@PostMapping("refurbishDeviceNetWork")
|
|
|
public R refurbishDeviceNetWork(@RequestBody List<Long> deviceIds) {
|