Commit e28b51ff LN

韩华配置界面,ip也可以检查

1 个父辈 61e97bd3
......@@ -28,6 +28,7 @@ import org.apache.logging.log4j.util.Strings;
import org.springframework.util.CollectionUtils;
import java.io.*;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
......@@ -703,5 +704,17 @@ public class HttpHelper {
stringBuffer.append(paramStr);
return stringBuffer.toString();
}
public static boolean pingIP(String ipAddress, int timeout) {
try {
InetAddress address = InetAddress.getByName(ipAddress);
if (address.isReachable(timeout)) {
return true;
}
} catch (Exception e) {
log.error(e.toString());
}
return false;
}
}
......@@ -55,9 +55,9 @@ public class ApiInteractionController {
List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.updateTime", locale, "时间")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.url", locale, "地址")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.request", locale, "参数")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.response", locale, "结果")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.url", locale, "地址")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.state", locale, "状态")));
return header;
}
......@@ -70,9 +70,9 @@ public class ApiInteractionController {
for (ApiInteraction obj : apiInfoList.getContent()) {
List<Object> data = new ArrayList<>();
data.add(DateUtil.toDateString(obj.getRequestDate()));
data.add(obj.getUrl());
data.add(obj.getParam());
data.add(obj.getResult());
data.add(obj.getUrl());
data.add(obj.getStatus());
dataList.add(data);
}
......
......@@ -2,6 +2,8 @@ package com.neotel.smfcore.core.equipment.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.rest.dto.EquipConfigInfoDto;
import com.neotel.smfcore.core.equipment.rest.mapstruct.EquipConfigInfoMapper;
......@@ -67,15 +69,15 @@ public class EquipConfigController {
if (configInfoDto.equipType.equals(EquipmentType.T_SOLUTION.name())) {
EquipConfigInfo config = equipConfigInfoMapper.toEntity(configInfoDto);
if (configInfoDto.apiTestKey.equals("webPort") ) {
String ip = config.GetConfigValue("host", "");
int webPort = config.GetConfigValue("webPort", 0);
String webUrl = String.format("ws://%s:%d/", ip, webPort);
if (ObjectUtil.isEmpty(ip)) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"host"});
}
if (ObjectUtil.isEmpty(webPort)||webPort==0) {
if (configInfoDto.apiTestKey.equals("webPort")) {
int webPort = config.GetConfigValue("webPort", 0);
String webUrl = String.format("ws://%s:%d/", ip, webPort);
if (ObjectUtil.isEmpty(webPort) || webPort == 0) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"webPort"});
}
if (TMSCommunicator.wsURL.equals(webUrl)) {
......@@ -83,22 +85,24 @@ public class EquipConfigController {
} else {
result = tmsApis.TestWebSocket(ip, webPort);
}
} else if (configInfoDto.apiTestKey.equals("host")) {
result = HttpHelper.pingIP(ip, 1000);
} else {
String ip = config.GetConfigValue("host", "");
int apiPort = config.GetConfigValue("apiPort", 0);
if (ObjectUtil.isEmpty(ip)) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"host"});
}
if (ObjectUtil.isEmpty(apiPort)||apiPort==0) {
if (ObjectUtil.isEmpty(apiPort) || apiPort == 0) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"apiPort"});
}
result=tmsApis.TestApi(ip,apiPort);
result = tmsApis.TestApi(ip, apiPort);
}
} else if (configInfoDto.equipType.equals(EquipmentType.PANACIMNEOLINK.name())) {
if (configInfoDto.apiTestKey.equals(Constants.Cache_PanaCIMIP)) {
result = panaApiController.TestIp(1000);
} else {
result = panaApiController.TestApi();
}
}
if (result) {
......
......@@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
......@@ -756,4 +757,20 @@ public class PanaApiController extends BaseSmfApiListener {
}
return false;
}
public boolean TestIp(int timeout) {
try {
if (timeout <= 0) {
timeout = 1000;
}
InetAddress address = InetAddress.getByName(PanaCIMIP);
if (address.isReachable(timeout)) {
return true;
}
} catch (Exception ex) {
log.error("TestIp" + PanaCIMIP + " error :" + ex.toString());
}
return false;
}
}
......@@ -399,8 +399,8 @@ smfcore.humiture.ntemperature3=Refrigeration zone temperature 3
smfcore.humiture.codetemperature2=Cooling Temperature 2
smfcore.humiture.wtemperature=Return temperature zone temperature
smfcore.equipconfig.connectTimeout=Connection Timeout
smfcore.equipApiMsg.url=URL
smfcore.equipApiMsg.url=URL/Source
smfcore.equipApiMsg.request=Parameter
smfcore.equipApiMsg.response=Result
smfcore.equipApiMsg.response=Result/Details
smfcore.equipApiMsg.updateTime=Time
smfcore.equipApiMsg.state=Type
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!