Pārlūkot izejas kodu

支付宝设备更新

李进 1 gadu atpakaļ
vecāks
revīzija
cf84969efd

+ 7 - 5
device-api-service/src/main/java/com/xy/alipay/SpiDeviceServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xy.alipay;
 
 import cn.hutool.json.JSONObject;
+import com.xy.constants.SpiResponseConst;
 import com.xy.consumer.disconnect.DisconnectedMqttConfiguration;
 import com.xy.consumer.disconnect.DisconnectedProducer;
 import com.xy.dto.DeviceEventMsgDto;
@@ -24,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
-import java.util.Map;
 
 
 /**
@@ -49,7 +49,7 @@ public class SpiDeviceServiceImpl implements SpiDeviceService {
 
     @Override
     @ApiOperation("设备告警通知")
-    public void deviceAlarmNotify(Map<String, String> params, DeviceAlarmNotifyDTO deviceAlarmNotifyDTO) {
+    public String deviceAlarmNotify(DeviceAlarmNotifyDTO deviceAlarmNotifyDTO) {
         //查询设备信息
         DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(deviceAlarmNotifyDTO.getTerminalId()));
         String faultCode = deviceAlarmNotifyDTO.getFaultCode();
@@ -57,7 +57,7 @@ public class SpiDeviceServiceImpl implements SpiDeviceService {
                 : faultCode.equals("DoorOpenedOnNoTrade") ? DeviceErrorRecordTypesEnum.DOOR_LOCK
                 : null;
         if (deviceErrorRecordTypesEnum == null) {
-            return;
+            return SpiResponseConst.FAIL;
         }
         //添加设备异常记录
         DeviceEventMsgDto.Save save = new DeviceEventMsgDto.Save()
@@ -70,16 +70,17 @@ public class SpiDeviceServiceImpl implements SpiDeviceService {
             JSONObject jsonObject = new JSONObject().set("clientid", deviceInfo.getDeviceId());
             disconnectedProducer.sendToMqtt(jsonObject.toString(), DisconnectedMqttConfiguration.TOPIC, 1);
         }
+        return SpiResponseConst.SPI_SUCCESS;
     }
 
     @Override
     @ApiOperation("设备状态变更通知")
-    public void deviceStatusChangeNotify(Map<String, String> params, DeviceStatusChangeNotifyDTO deviceStatusChangeNotifyDTO) {
+    public String deviceStatusChangeNotify(DeviceStatusChangeNotifyDTO deviceStatusChangeNotifyDTO) {
         //查询设备信息
         DeviceInfo deviceInfo = deviceInfoService.getById(Long.valueOf(deviceStatusChangeNotifyDTO.getTerminalId()));
         Integer status = deviceStatusChangeNotifyDTO.getStatus();
         if (deviceInfo.getFreezeStatus().equals(status)) {
-            return;
+            return SpiResponseConst.FAIL;
         }
         //修改冻结状态、运营状态
         DeviceInfo updateDeviceInfo = new DeviceInfo()
@@ -106,5 +107,6 @@ public class SpiDeviceServiceImpl implements SpiDeviceService {
             }
         }
         deviceInfoService.updateById(updateDeviceInfo);
+        return SpiResponseConst.SPI_SUCCESS;
     }
 }