增加连通检测接口
parent
db3dd35a3c
commit
f7944790f3
@ -0,0 +1,36 @@
|
|||||||
|
package com.glxp.sale.admin.idc.controller;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.glxp.sale.admin.idc.service.ConnectService;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中继服务接口
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class ConnectController {
|
||||||
|
@Resource
|
||||||
|
ConnectService connectService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/spssync/common/connect")
|
||||||
|
@ResponseBody
|
||||||
|
public BaseResponse connect(HttpServletRequest request, @RequestBody Map<String, Object> params) {
|
||||||
|
|
||||||
|
return connectService.connectStatus(request,params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.glxp.sale.admin.idc.service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
|
||||||
|
|
||||||
|
/*连通状态服务*/
|
||||||
|
public interface ConnectService {
|
||||||
|
|
||||||
|
BaseResponse connectStatus(HttpServletRequest request,Map<String,Object> params);
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package com.glxp.sale.admin.idc.service.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.glxp.sale.admin.idc.dao.DbDao;
|
||||||
|
import com.glxp.sale.admin.idc.service.ConnectService;
|
||||||
|
import com.glxp.sale.admin.idc.utils.IDCUtils;
|
||||||
|
import com.glxp.sale.common.res.BaseResponse;
|
||||||
|
import com.glxp.sale.common.util.ResultVOUtils;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*连通检测*/
|
||||||
|
@Service
|
||||||
|
public class ConnectServiceImpl implements ConnectService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(IdcServiceImpl.class);
|
||||||
|
@Resource
|
||||||
|
private DbDao dbDao;
|
||||||
|
private static String NUM_STRS = "⊙①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯";
|
||||||
|
//⊙①②③④⑤⑥⑦⑧⑨⑩→⊗
|
||||||
|
@Override
|
||||||
|
public BaseResponse connectStatus(HttpServletRequest request,Map<String,Object> params) {
|
||||||
|
int level = 0;
|
||||||
|
if(params.get("level")!=null) {
|
||||||
|
level = Integer.valueOf(params.get("level").toString());
|
||||||
|
} else if(params.get("data")!=null) {
|
||||||
|
Map data = JSONObject.parseObject(JSON.toJSONString(params.get("data")), Map.class);
|
||||||
|
if(data.get("level")!=null) {
|
||||||
|
level = Integer.valueOf(data.get("level").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
Map<String,Object> map = new HashMap<String,Object>();
|
||||||
|
map.put("level", level);
|
||||||
|
Map<String,Object> config = new HashMap<>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
config = dbDao.get("select * from system_param_config where paramKey='upper_server_ip'");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
String msg = "管理系统";
|
||||||
|
for(int i=1;i<level+1;i++) {
|
||||||
|
msg+="→"+NUM_STRS.substring(i,i+1);
|
||||||
|
}
|
||||||
|
if(config!=null&&config.get("paramValue")!=null) {
|
||||||
|
String result = IDCUtils.post(config.get("paramValue") + "/spssync/common/connect", map);
|
||||||
|
if (IDCUtils.isJson(result)) {
|
||||||
|
BaseResponse object = JSON.parseObject(result, BaseResponse.class);
|
||||||
|
if(object.getCode()!=2000) {
|
||||||
|
map.replace("level", level +1);
|
||||||
|
msg+="→"+NUM_STRS.substring(level,level+1);
|
||||||
|
map.put("msg", msg);
|
||||||
|
return ResultVOUtils.success(map);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
} else {
|
||||||
|
msg+="→⊗";
|
||||||
|
map.put("failLevel", level+1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
map.put("successLevel", level);
|
||||||
|
}
|
||||||
|
map.put("msg", msg);
|
||||||
|
return ResultVOUtils.success(map);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue