Commit e28b51ff LN

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

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