Browse Source

bug修复

lihui001 3 years ago
parent
commit
3d0571e0fe

+ 9 - 3
zoniot-common/zoniot-iot-sync/src/main/java/com/bz/zoneiot/iot/sync/config/SyncDeviceConfig.java

@@ -19,18 +19,24 @@ public class SyncDeviceConfig {
     /**
      * 添加url
      */
-    @Value("${sync.service.device.addUrl:http://114.135.61.189:18081/app/sec/v1.0/deviceRegist}")
+    @Value("${sync.service.device.addUrl:http://114.135.61.189:18081/app/device/v1.0/deviceRegist}")
     private String addDeviceUrl;
 
     /**
      * 删除url
      */
-    @Value("${sync.service.device.deleteUrl:http://114.135.61.189:18081/app/sec/v1.0/delete}")
+    @Value("${sync.service.device.deleteUrl:http://114.135.61.189:18081/app/device/v1.0/delete}")
     private String deleteDeviceUrl;
 
     /**
      * 更新url
      */
-    @Value("${sync.service.device.updateUrl:http://114.135.61.189:18081/app/sec/v1.0/update}")
+    @Value("${sync.service.device.updateUrl:http://114.135.61.189:18081/app/device/v1.0/update}")
     private String updateDeviceUrl;
+
+    /**
+     * 更新状态
+     */
+    @Value("${sync.service.device.updateStatusUrl:http://114.135.61.189:18081/app/device/v1.0/updateDeviceStatus}")
+    private String updateDeviceStatusUrl;
 }

+ 26 - 16
zoniot-common/zoniot-iot-sync/src/main/java/com/bz/zoneiot/iot/sync/service/SyncDeviceService.java

@@ -11,30 +11,40 @@ import com.bz.zoneiot.iot.sync.dto.DeviceDTO;
 public interface SyncDeviceService {
 
     /**
-    * 添加设备
-    * @author Andy
-    * @date 15:58 2021/10/14
-    * @param dto:
-    * @return java.lang.Long
-    **/
+     * 添加设备
+     * @author Andy
+     * @date 15:58 2021/10/14
+     * @param dto:
+     * @return java.lang.Long
+     **/
     Long addDevice(DeviceDTO dto);
 
     /**
-    * 删除设备
-    * @author Andy
-    * @date 15:58 2021/10/14
-    * @param deviceId:
-    * @return java.lang.Long
-    **/
+     * 删除设备
+     * @author Andy
+     * @date 15:58 2021/10/14
+     * @param deviceId:
+     * @return java.lang.Long
+     **/
     Long deleteDevice(Long deviceId);
 
     /**
-    * 更新设备信息
+     * 更新设备信息
+     * @author Andy
+     * @date 15:59 2021/10/14
+     * @param dto:
+     * @return java.lang.Long
+     **/
+    Long updateDevice(DeviceDTO dto);
+
+    /**
+    * 更新设备状态
     * @author Andy
-    * @date 15:59 2021/10/14
-    * @param dto:
+    * @date 15:31 2021/11/4
+    * @param deviceId:
+    * @param deviceStatus:
     * @return java.lang.Long
     **/
-    Long updateDevice(DeviceDTO dto);
+    Long updateDeviceStatus(Long deviceId, int deviceStatus );
 
 }

+ 13 - 0
zoniot-common/zoniot-iot-sync/src/main/java/com/bz/zoneiot/iot/sync/service/impl/SyncDeviceServiceImpl.java

@@ -54,4 +54,17 @@ public class SyncDeviceServiceImpl extends AuthIotService implements SyncDeviceS
         return HttpUtil.postParamsBody(url, dto, super.getToken(), DeviceVo.class).getDeviceId();
     }
 
+    @Override
+    public Long updateDeviceStatus(Long deviceId, int deviceStatus ){
+        if (deviceId != null) {
+            return 0L;
+        }
+        String url   = deviceConfig.getUpdateDeviceUrl();
+        Map<String, Object> map = new HashMap<>(1);
+        map.put("deviceId", deviceId);
+        map.put("deviceStatus", deviceStatus);
+        HttpUtil.postParamsBody(url, map, super.getToken(), null);
+        return 1L;
+    }
+
 }

+ 5 - 2
zoniot-common/zoniot-iot-sync/src/main/java/com/bz/zoneiot/iot/sync/utils/HttpUtil.java

@@ -142,12 +142,15 @@ public class HttpUtil {
     **/
     private static <T> T convertObject(String result, Class<T> clazz){
         HttpContentVo<T> httpContentVo = JSONObject.parseObject(result, HttpContentVo.class);
+        if (httpContentVo == null) {
+            throw BusinessException.builder(SyncErrorEnum.FAIL.getStatus(), "服务器访问繁忙,请稍后重试");
+        }
         // 没有权限
         if (httpContentVo.getStatus() == AUTH_FAIL) {
-            throw BusinessException.builder(SyncErrorEnum.AUTH_FAIL.getStatus(), "访问繁忙,请稍后重试");
+            throw BusinessException.builder(SyncErrorEnum.AUTH_FAIL.getStatus(), "服务器访问繁忙,请稍后重试");
         }
         if (httpContentVo.getStatus() != 0 ) {
-            throw BusinessException.builder(SyncErrorEnum.FAIL.getStatus(), "同步物联网出错:" + httpContentVo.getMsg());
+            throw BusinessException.builder(SyncErrorEnum.FAIL.getStatus(), "同步物联网出错,code" + httpContentVo.getStatus() + ",msg:" + httpContentVo.getMsg());
         }
         T t = httpContentVo.getData();
         if (t == null || clazz == null) {