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); + } + } }