diff --git a/Readme.md b/Readme.md index 5584f4a0..1ff3747b 100644 --- a/Readme.md +++ b/Readme.md @@ -5,13 +5,16 @@ ----|---- Request URI|dispose/auth/login Content type|application/json;charset=UTF-8 - Body|{"ver":2,"cryptoType":0,"timeStamp":1587604296988,"msgContent":"{\"password\":\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\",\"userName\":\"admin\"}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1587604296988,"msgContent":"{\"password\":\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\",\"userName\":\"admin\"}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1587604296988, - "msgContent":"{\"password\":\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\",\"userName\":\"admin\"}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598580612302, + "msgContent": { + "password": "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58", + "userName": "admin" + } } ``` @@ -19,14 +22,23 @@ 字段|内容 ----|---- Content type|application/json;charset=UTF-8 - Body|{"ver":2,"cryptoType":0,"timeStamp":1589437655540,"code":200,"msgContent":"{\"userName\":\"admin\",\"token\":\"6ffd266820a338d95822657a2b4df2cc42f8ad783325eb684598e5ce9070d884\",\"logTime\":1589437655523,\"expireTime\":1589441255524,\"status\":0,\"message\":\"成功\"}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598580612302,"code":200,"msgContent":"{\"userName\":\"admin\",\"token\":\"ed42284a31337b41c2ba2cc061754c60b0f4e659601ecc5c06daab25bd041e17\",\"logTime\":1598580612302,\"expireTime\":1598580612302,\"status\":0,\"message\":[\"成功\"]}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589437655540, - "code": 200, - "msgContent":"{\"userName\":\"admin\",\"token\":\"6ffd266820a338d95822657a2b4df2cc42f8ad783325eb684598e5ce9070d884\",\"logTime\":1589437655523,\"expireTime\":1589441255524,\"status\":0,\"message\":\"成功\"}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598580612302, + "code": 200, + "msgContent": { + "userName": "admin", + "token": "ed42284a31337b41c2ba2cc061754c60b0f4e659601ecc5c06daab25bd041e17", + "logTime": 1598580612302, + "expireTime": 1598580612302, + "status": 0, + "message": [ + "成功" + ] + } } ``` @@ -37,27 +49,35 @@ Request URI|dispose/auth/logout Content type|application/json;charset=UTF-8 Authorization|"Bearer b8f01b8303cd9fcb7d3c9ed1b1c54d4a6e04bac3a66ab7df6ba81f690882ca2e" - Body|{"ver":2,"cryptoType":0,"timeStamp":1589438109410,"msgContent":"{\"userName\":\"admin\"}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598582999559,"msgContent":"{\"userName\":\"admin\"}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589438109410, - "msgContent": "{\"userName\":\"admin\"}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598582999559, + "msgContent": { + "userName": "admin" + } } ``` + 响应消息 字段|内容 ----|---- Content type|application/json;charset=UTF-8 - Body|{"ver":2,"cryptoType":0,"timeStamp":1589438109527,"code":200,"msgContent":"{\"userName\":\"admin\",\"status\":0,\"message\":\"成功\"}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598582999559,"code":200,"msgContent":"{\"userName\":\"admin\",\"status\":0,\"message\":[\"成功\"]}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589438109527, - "code": 200, - "msgContent":"{\"userName\":\"admin\",\"status\":0,\"message\":\"成功\"}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598582999559, + "code": 200, + "msgContent": { + "userName": "admin", + "status": 0, + "message": [ + "成功" + ] + } } ``` @@ -68,27 +88,67 @@ Request URI|dispose/manager/device Content type|application/json;charset=UTF-8 Authorization|"Bearer b8f01b8303cd9fcb7d3c9ed1b1c54d4a6e04bac3a66ab7df6ba81f690882ca2e" - Body|{"ver":2,"cryptoType":0,"timeStamp":1589437275258,"msgContent":"{\"items\":[{\"areaCode\":0,\"ipAddr\":\"10.88.77.15\",\"manufacturer\":\"DPTech\",\"model\":\"UMC\",\"name\":\"中移杭研实验室清洗设备\",\"readme\":\"实验室测试设备\",\"type\":0,\"version\":\"5.7.13\"}]}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596150287,"msgContent":"{\"items\":[{\"ipAddr\":\"10.88.77.15\",\"ipPort\":\"\", + \"deviceType\":0,\"areaCode\":0,\"deviceName\":\"中移杭研实验室迪普清洗设备\",\"manufacturer\":\"DPTech\",\"model\":\"UMC\", + \"version\":\"5.7.13\",\"userName\":\"admin\",\"password\":\"UMCAdministrator\",\"urlPath\":\"UMC/service/AbnormalFlowCleaningService\",\"urlType\":0,\"readme\":\"实验室测试设备\", \"capacity\":[{\"capacityType\":0,\"objectType\":1,\"ipType\":3,\"protectIp\":\"0.0.0.0\"}]}]}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589437275258, - "msgContent":"{\"items\":[{\"areaCode\":0,\"ipAddr\":\"10.88.77.15\",\"manufacturer\":\"DPTech\",\"model\":\"UMC\",\"name\":\"中移杭研实验室清洗设备\",\"readme\":\"实验室测试设备\",\"type\":0,\"version\":\"5.7.13\"}]}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596150287, + "msgContent":{ + "items": [ + { + "ipAddr": "10.88.77.15", + "ipPort": "", + "deviceType": 0, + "areaCode": 0, + "deviceName": "中移杭研实验室迪普清洗设备", + "manufacturer": "DPTech", + "model": "UMC", + "version": "5.7.13", + "userName": "admin", + "password": "UMCAdministrator", + "urlPath": "UMC/service/AbnormalFlowCleaningService", + "urlType": 0, + "readme": "实验室测试设备", + "capacity": [ + { + "capacityType": 0, + "objectType": 1, + "ipType": 3, + "protectIp": "0.0.0.0" + } + ] + } + ] + } } ``` + 响应消息 字段|内容 ----|---- Content type|application/json;charset=UTF-8 - Body|{"ver":2,"cryptoType":0,"timeStamp":1589437275451,"code":200,"msgContent":"{\"items\":[{\"ipAddr\":\"10.88.77.15\",\"devId\":\"1\",\"status\":20,\"message\":\"设备已经存在\"}]}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596150287,"code":200,"msgContent":"{\"items\":[{\"ipAddr\":\"10.88.77.15\",{\"ipPort\":\"\",\"devId\":\"572\",\"status\":0,\"message\":[\"成功\"]}]}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589437275451, - "code": 200, - "msgContent": "{\"items\":[{\"ipAddr\":\"10.88.77.15\",\"devId\":\"1\",\"status\":20,\"message\":\"设备已经存在\"}]}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596150287, + "code": 200, + "msgContent": { + "items": [ + { + "ipAddr": "10.88.77.15", + "ipPort": "", + "devId": "572", + "status": 0, + "message": [ + "成功" + ] + } + ] + } } ``` @@ -99,30 +159,201 @@ Request URI|dispose/manager/device Content type|application/json;charset=UTF-8 Authorization|"Bearer b8f01b8303cd9fcb7d3c9ed1b1c54d4a6e04bac3a66ab7df6ba81f690882ca2e" - Body|{"ver":2,"cryptoType":0,"timeStamp":1589437091399,"msgContent":"{\"id\":[\"1\"]}"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596120673,"msgContent":"{\"id\":[\"572\", \"36\"]}"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589437091399, - "msgContent":"{\"id\":[\"1\"]}" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596120673, + "msgContent": { + "id" : ["572", "36"] + } } ``` + 响应消息 字段|内容 ----|---- Content type|application/json;charset=UTF-8 - Body|{"ver":2,"cryptoType":0,"timeStamp":1589437091565,"code":200,"msgContent":"[{\"id\":\"1\",\"status\":0,\"message\":\"成功\"}]"} + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596120673,"code":200,"msgContent":"[{\"id\":\"572\",\"devStatus\":\"DELETED\",\"status\":0,\"message\":[\"成功\"]}, {\"id\":\"36\",\"devStatus\":\"NORMAL\",\"status\":19,\"message\":[\"没有这个设备\"]}]"} ```json { - "ver": 2, - "cryptoType": 0, - "timeStamp": 1589437091565, - "code": 200, - "msgContent":"[{\"id\":\"1\",\"status\":0,\"message\":\"成功\"}]" + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596120673, + "code": 200, + "msgContent": [ + { + "id": "572", + "devStatus": "DELETED", + "status": 0, + "message": [ + "成功" + ] + }, + { + "id": "36", + "devStatus": "NORMAL", + "status": 19, + "message": [ + "没有这个设备" + ] + } + ] } ``` +## 更新节点 ++ 请求命令 + 字段|内容 + ----|---- + Request URI|dispose/manager/upgrade + Content type|application/json;charset=UTF-8 + Authorization|"Bearer b8f01b8303cd9fcb7d3c9ed1b1c54d4a6e04bac3a66ab7df6ba81f690882ca2e" + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596022176,"msgContent":"{\"items\":[{\"ipAddr\":\"10.88.77.15\",\"ipPort\":\"\", + \"deviceType\":0,\"areaCode\":0,\"deviceName\":\"中移杭研实验室迪普清洗设备\",\"manufacturer\":\"DPTech\",\"model\":\"UMC\", + \"version\":\"5.7.16\",\"userName\":\"admin\",\"password\":\"UMCAdministrator\",\"urlPath\":\"UMC/service/AbnormalFlowCleaningService\",\"urlType\":0,\"readme\":\"实验室测试设备\", \"capacity\":[{\"capacityType\":0,\"objectType\":1,\"ipType\":3,\"protectIp\":\"192.168.1.5-192.168.1.20\"}]}]}"} +```json +{ + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596022176, + "msgContent":{ + "items": [ + { + "ipAddr": "10.88.77.15", + "ipPort": "", + "deviceType": 0, + "areaCode": 0, + "deviceName": "中移杭研实验室迪普清洗设备", + "manufacturer": "DPTech", + "model": "UMC", + "version": "5.7.16", + "userName": "admin", + "password": "UMCAdministrator", + "urlPath": "UMC/service/AbnormalFlowCleaningService", + "urlType": 0, + "readme": "实验室测试设备", + "capacity": [ + { + "capacityType": 0, + "objectType": 1, + "ipType": 3, + "protectIp": "192.168.1.5-192.168.1.20" + } + ] + } + ] + } +} +``` ++ 响应消息 + 字段|内容 + ----|---- + Content type|application/json;charset=UTF-8 + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596022176,"code":200,"msgContent":[{\"id\":\"572\",\"status\":0,\"message\":[\"成功\"]}]"} +```json +{ + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596022176, + "code": 200, + "msgContent": [ + { + "id": "572", + "status": 0, + "message": [ + "成功" + ] + } + ] +} +``` + +## 获取全部节点 ++ 请求命令 + 字段|内容 + ----|---- + Request URI|dispose/manager/device_list + Content type|application/json;charset=UTF-8 + Authorization|"Bearer b8f01b8303cd9fcb7d3c9ed1b1c54d4a6e04bac3a66ab7df6ba81f690882ca2e" + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596065234,"msgContent":"{\"startPage\":1,\"pageSize\":\"10\"}"} +```json +{ + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596065234, + "msgContent": { + "startPage": 1, + "pageSize": "10" + } +} +``` ++ 响应消息 + 字段|内容 + ----|---- + Content type|application/json;charset=UTF-8 + Body|{"ver":3,"cryptoType":0,"timeStamp":1598596065234,"code":200,"msgContent":{\"curPageNumber\":1,\"pageSize\":10,\"totalItems\":2,\"totalPages\":1,\"status\":0,\"message\":[\"成功\"],\"items\":[{\"id\":\"573\",\"ipAddr\":\"10.***.***.88\",\"ipPort\":\"18080\",\"deviceType\":1,\"areaCode\":0, \"deviceName\":\"中移杭研实验室浩瀚清洗设备\",\"manufacturer\":\"Haohan\",\"model\":\"Unknown\",\"version\":\"Unknown\",\"userName\":\"\",\"urlType\":0,\"readme\":\"实验室测试设备\",\"capacity\":[{\"capacityType\":0, \"objectType\":1,\"ipType\":3,\"protectIp\":\"0.0.0.0\"}],\"devStatus\":0}, {\"id\":\"572\",\"ipAddr\":\"10.***.***.15\",\"ipPort\":\"\",\"deviceType\":0,\"areaCode\":0,\"deviceName\":\"中移杭研实验室迪普清洗设备\",\"manufacturer\":\"DPTech\",\"model\":\"UMC\",\"version\":\"5.7.16\",\"userName\":\"adm****\",\"urlType\":0,\"readme\":\"实验室测试设备\",\"capacity\":[],\"devStatus\":0}]}"} +```json +{ + "ver": 3, + "cryptoType": 0, + "timeStamp": 1598596065234, + "code": 200, + "msgContent": { + "curPageNumber": 1, + "pageSize": 10, + "totalItems": 2, + "totalPages": 1, + "status": 0, + "message": [ + "成功" + ], + "items": [ + { + "id": "573", + "ipAddr": "10.***.***.88", + "ipPort": "18080", + "deviceType": 1, + "areaCode": 0, + "deviceName": "中移杭研实验室浩瀚清洗设备", + "manufacturer": "Haohan", + "model": "Unknown", + "version": "Unknown", + "userName": "", + "urlType": 0, + "readme": "实验室测试设备", + "capacity": [ + { + "capacityType": 0, + "objectType": 1, + "ipType": 3, + "protectIp": "0.0.0.0" + } + ], + "devStatus": 0 + }, + { + "id": "572", + "ipAddr": "10.***.***.15", + "ipPort": "", + "deviceType": 0, + "areaCode": 0, + "deviceName": "中移杭研实验室迪普清洗设备", + "manufacturer": "DPTech", + "model": "UMC", + "version": "5.7.16", + "userName": "adm****", + "urlType": 0, + "readme": "实验室测试设备", + "capacity": [], + "devStatus": 0 + } + ] + } +} +``` + + ## 获取节点版本信息 + 请求命令 字段|内容 @@ -417,7 +648,7 @@ "ver": 2, "cryptoType": 0, "timeStamp": 1587604296988, - "msgContent": "{\"id\":-1,\"type\":0, \"disposeIp\":\"192.168.3.2\", \"disposeTime\":120}" + "msgContent": "{\"id\":-1,\"type\":0, \"disposeIp\":\"192.168.3.2\", \"disposeTime\":120}"} } ``` + 响应消息 @@ -463,7 +694,7 @@ "cryptoType": 0, "timeStamp": 1589421779138, "code": 200, - "msgContent": "{\"items\":[{\"id\":\"1\",\"taskId\":\"60\",\"type\":0,\"disposeIp\":\"192.168.3.2\",\"leftTime\":120,\"status\":0,\"message\":\"成功\"},{\"id\":\"-1\",\"taskId\":\"2\",\"type\":0,\"status\":30,\"message\":\"没有该任务\"}]}" + "msgContent": :"{\"items\":[{\"id\":\"1\",\"taskId\":\"60\",\"type\":0,\"disposeIp\":\"192.168.3.2\",\"leftTime\":120,\"status\":0,\"message\":\"成功\"},{\"id\":\"-1\",\"taskId\":\"2\",\"type\":0,\"status\":30,\"message\":\"没有该任务\"}]}" } ``` @@ -542,7 +773,7 @@ "ver": 2, "cryptoType": 0, "timeStamp": 1587604296988, - "msgContent":"{\"type\":0}" + "msgContent":"{\"type\":0}"} } ``` + 响应消息 diff --git a/src/test/java/com/dispose/test/manager/DisposeDeviceManagerTest.java b/src/test/java/com/dispose/test/manager/DisposeDeviceManagerTest.java index 6c0092ec..dc33b9c1 100644 --- a/src/test/java/com/dispose/test/manager/DisposeDeviceManagerTest.java +++ b/src/test/java/com/dispose/test/manager/DisposeDeviceManagerTest.java @@ -206,4 +206,43 @@ public class DisposeDeviceManagerTest { } }); } + + /** + * A 4 gets pages of devices. + */ + @Test + public void a4_getPagesOfDevices() { + Integer startPage = 1; + Integer pageSize = 5; + + MulReturnType, List> ret = disposeDeviceManager.getPagesOfDevices(startPage, pageSize); + + PageInfo pageInfo = ret.getFirstParam(); + Assert.assertEquals(pageInfo.getPageNum(), (long) startPage); + Assert.assertEquals(pageInfo.getPageSize(), (long) pageSize); + + List deviceList = ret.getSecondParam(); + + if (pageInfo.getList().size() > 0) { + Assert.assertNotNull(deviceList); + } + } + + + /** + * A 5 all dispose devices. + */ + @Test + public void a5_getAllNormalDisposeDevices() throws JsonProcessingException { + long normalNumber = disposeDeviceMapper.selectAll().stream().filter(v -> v.getStatus() == ObjectStatus.NORMAL).count(); + log.info("normalNumber-->{}", normalNumber); + + if (normalNumber > 0) { + List disposeDeviceList = disposeDeviceManager.getAllNormalDisposeDevices(); + + log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(disposeDeviceList)); + + Assert.assertNotNull(disposeDeviceList); + } + } } diff --git a/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java b/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java index c80d600b..22f5b76e 100644 --- a/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java +++ b/src/test/java/com/dispose/test/service/DisposeAbilityRouterServiceTest.java @@ -4,6 +4,7 @@ import com.dispose.common.DisposeDeviceType; import com.dispose.common.ErrorCode; import com.dispose.common.HttpType; import com.dispose.common.ObjectStatus; +import com.dispose.manager.DisposeDeviceManager; import com.dispose.mapper.DisposeDeviceMapper; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.AbilityInfo; @@ -60,6 +61,11 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { */ @Resource private DisposeDeviceMapper disposeDeviceMapper; + /** + * The dispose device manager. + */ + @Resource + private DisposeDeviceManager disposeDeviceManager; /** * The Object mapper. */ @@ -68,6 +74,7 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { public static Integer VIRTUAL_DISPOSE = 999; + public static Integer DPTECH_UMC = 0; /** * User login test. @@ -188,4 +195,78 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { } }); } + /** + * A 5 Add dispose device list. + */ + @Test + public void a5_addDisposeAbilityDeviceTest() throws JsonProcessingException { + DisposeDevice dev = DisposeDevice.builder() + .ipAddr("192.168.1.1") + .ipPort("") + .deviceType(DisposeDeviceType.DPTECH_UMC) + .areaCode(0) + .deviceName("迪普设备添加测试") + .manufacturer("DP") + .model("UMC") + .version("5.7.13") + .userName("admin") + .password("") + .urlPath("UMC/service/AbnormalFlowCleaningService") + .urlType(HttpType.HTTP) + .readme("实验室测试设备") + .status(ObjectStatus.NORMAL) + .build(); + + Assert.assertEquals(ErrorCode.ERR_OK,disposeAbilityRouterService.addDisposeAbilityDevice(dev)); + Assert.assertEquals(dev.getDeviceType().getValue(), DPTECH_UMC); + + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(dev.getIpAddr(), dev.getIpPort()); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfo)); + } + + /** + * A 7 Gets ability device by ipAddr and ipPort. + */ + @Test + public void a7_getAbilityDeviceTest() throws JsonProcessingException { + List deviceList = disposeDeviceManager.getAllNormalDisposeDevices(); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList)); + + deviceList.forEach(v -> { + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort()); + + Assert.assertNotNull(abilityInfo); + Assert.assertNotNull(abilityInfo.getDb()); + Assert.assertNotNull(abilityInfo.getDev()); + + if(abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE){ + Assert.assertNull(abilityInfo.getFirewareInfo()); + Assert.assertFalse(abilityInfo.isLinkStatus()); + }else{ + Assert.assertNotNull(abilityInfo.getFirewareInfo()); + Assert.assertTrue(abilityInfo.isLinkStatus()); + } + }); + } + /** + * A 8 Gets ability device by id. + */ + @Test + public void a8_getAbilityDevice() throws JsonProcessingException { + List deviceList = disposeDeviceManager.getAllNormalDisposeDevices(); + log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(deviceList)); + + deviceList.forEach(v -> { + AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId()); + + Assert.assertNotNull(abilityInfo); + Assert.assertNotNull(abilityInfo.getDb()); + Assert.assertNotNull(abilityInfo.getDev()); + + if(abilityInfo.getDev().getDeviceType() == DisposeDeviceType.DPTECH_UMC){ + Assert.assertNotNull(abilityInfo.getFirewareInfo()); + Assert.assertTrue(abilityInfo.isLinkStatus()); + } + }); + } }