From 2a5ccbabcf8f0dd5eee3e4b0f1e1db192f77fdee Mon Sep 17 00:00:00 2001 From: x_z Date: Tue, 18 Oct 2022 18:06:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E8=87=AA?= =?UTF-8?q?=E5=8A=A9=E5=B9=B3=E5=8F=B0=E8=BF=9E=E9=80=9A=E6=80=A7=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/info/PlatformController.java | 17 +++++++++++- .../udi/admin/entity/info/PlatformEntity.java | 2 ++ .../admin/service/info/PlatformService.java | 26 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java index 0063026..6206c42 100644 --- a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java +++ b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java @@ -156,7 +156,7 @@ public class PlatformController { if (StrUtil.isBlank(platformId)) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } - return platformService.getTargetActions(platformId,invSubCode); + return platformService.getTargetActions(platformId, invSubCode); } @@ -179,4 +179,19 @@ public class PlatformController { return platformService.getTargetSubInv(platformId, invCode); } + /** + * 测试自助平台连通性 + * + * @param host + * @return + */ + @AuthRuleAnnotation("") + @GetMapping("udims/platform/testPlatformConnection") + public BaseResponse testPlatformConnection(String host) { + if (StrUtil.isBlank(host)) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + return platformService.testPlatformConnection(host); + } + } diff --git a/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java b/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java index f4fd976..87f4fb7 100644 --- a/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java +++ b/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java @@ -1,5 +1,6 @@ package com.glxp.udi.admin.entity.info; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -7,6 +8,7 @@ import lombok.Data; @TableName("auth_platform") public class PlatformEntity { + @TableId private String id; private String name; //平台名称 diff --git a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java index a7cb948..66620e2 100644 --- a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java +++ b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java @@ -4,10 +4,12 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.udi.admin.common.enums.ResultEnum; import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.dao.info.PlatformDao; import com.glxp.udi.admin.dao.inout.UnitMaintainDao; @@ -182,4 +184,28 @@ public class PlatformService { return ResultVOUtils.error(500, "获取自助平台接口异常"); } } + + /** + * 测试自助平台连通性 + * + * @param host + * @return + */ + public BaseResponse testPlatformConnection(String host) { + String testUrl = host + "/udiwms/auth/device/connect"; + String response = HttpUtil.get(testUrl); + if (StrUtil.isNotBlank(response)) { + try { + BaseResponse result = JSONUtil.toBean(response, BaseResponse.class); + if (result.getCode() == 20000) { + return ResultVOUtils.success(); + } + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } catch (Exception e) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + } else { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + } }