diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java index c88835ec..d137129b 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java @@ -415,6 +415,11 @@ public class DeviceServiceImpl implements IDeviceService { DeviceInfo di=data.to(DeviceInfo.class); di.setLocate(new DeviceInfo.Locate(data.getLongitude(),data.getLatitude())); di.setState(data.getState()); + //同产品不可重复设备名 + DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName()); + if (deviceRepetition != null && !deviceRepetition.getDeviceId().equals(di.getDeviceId())) { + throw new BizException(ErrCode.MODEL_DEVICE_ALREADY); + } return deviceInfoData.save(di)!=null; } diff --git a/iot-module/iot-openapi/pom.xml b/iot-module/iot-openapi/pom.xml index 99c01bee..f694ef63 100644 --- a/iot-module/iot-openapi/pom.xml +++ b/iot-module/iot-openapi/pom.xml @@ -13,36 +13,13 @@ - - org.springframework.boot - spring-boot-starter-web - - - org.bouncycastle - bcprov-jdk15on - - - - com.aliyun.oss - aliyun-sdk-oss - joda-time joda-time - - it.ozimov - embedded-redis - - - slf4j-simple - org.slf4j - - - cc.iotkit @@ -59,20 +36,6 @@ iot-rule-engine - - cc.iotkit - iot-screen - - - - cc.iotkit - iot-component-server - - - - cc.iotkit - iot-component-converter - cc.iotkit diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java index 71d117f2..ed85fec2 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java @@ -38,7 +38,7 @@ public class OpenDeviceController { } @ApiOperation(value = "单个设备注册") - @PostMapping("/v1/registerDevice ") + @PostMapping("/v1/registerDevice") public boolean createDevice(@RequestBody @Validated Request bo) { return openDeviceService.addDevice(bo.getData()); } @@ -50,7 +50,7 @@ public class OpenDeviceController { } @ApiOperation(value = "设置设备的属性", notes = "设置设备的属性", httpMethod = "POST") - @PostMapping("/v1/setDeviceProperty ") + @PostMapping("/v1/setDeviceProperty") public InvokeResult setProperty(@RequestBody @Validated Request request) { return new InvokeResult(openDeviceService.setProperty(request.getData().getProductKey(), request.getData().getDeviceName(), request.getData().getArgs())); } diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java index d9dcce6b..c61b6bf8 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenBaseServiceImpl.java @@ -52,7 +52,8 @@ public class OpenBaseServiceImpl implements OpenBaseService { // 校验租户 checkTenant(bo.getTenantId()); - + System.out.println("boAppid + password + boTimeStamp = " + boAppid + password + boTimeStamp); + System.out.println("boIdentifier = " + boIdentifier); if (!CodecUtil.md5Str(boAppid + password + boTimeStamp).equals(boIdentifier)){ throw new BizException(ErrCode.IDENTIFIER_ERROR); }