connect check
							parent
							
								
									1cd60dd170
								
							
						
					
					
						commit
						1e79ea6764
					
				| @ -0,0 +1,35 @@ | |||||||
|  | package com.glxp.api.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.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.idc.service.ConnectService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 中继服务接口 | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @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,12 @@ | |||||||
|  | package com.glxp.api.idc.service; | ||||||
|  | 
 | ||||||
|  | import java.util.Map; | ||||||
|  | 
 | ||||||
|  | import javax.servlet.http.HttpServletRequest; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | 
 | ||||||
|  | /*连通状态服务*/ | ||||||
|  | public interface ConnectService { | ||||||
|  |     BaseResponse connectStatus(HttpServletRequest request,Map<String,Object> params); | ||||||
|  | } | ||||||
| @ -0,0 +1,81 @@ | |||||||
|  | package com.glxp.api.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.fastjson2.JSON; | ||||||
|  | import com.alibaba.fastjson2.JSONObject; | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.common.util.ResultVOUtils; | ||||||
|  | import com.glxp.api.dao.idc.DbDao; | ||||||
|  | import com.glxp.api.idc.service.ConnectService; | ||||||
|  | import com.glxp.api.idc.utils.IDCUtils; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /*连通检测*/ | ||||||
|  | @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  | ||||||
|  |         { | ||||||
|  |             if(level==0) { | ||||||
|  |                 config = dbDao.get("select syncIp as paramValue from sync_data_set limit 1"); | ||||||
|  |             } else { | ||||||
|  |                 config = dbDao.get("select * from system_param_config where paramKey='upper_server_ip'"); | ||||||
|  |             } | ||||||
|  |         } catch (Exception ex) { | ||||||
|  |              | ||||||
|  |         } | ||||||
|  |         String msg = "UDI管理系统"; | ||||||
|  |         for(int i=1;i<level;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+1,level+2)+"正常"; | ||||||
|  |                     map.put("msg", msg); | ||||||
|  |                     return ResultVOUtils.success(map); | ||||||
|  |                 } | ||||||
|  |                 return object; | ||||||
|  |             } else { | ||||||
|  |                 msg+="→中继服务"+NUM_STRS.substring(level+1,level+2)+"连接异常"; | ||||||
|  |                 map.put("failLevel", level+1); | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             msg+="自助平台运行正常"; | ||||||
|  |             map.put("successLevel", level); | ||||||
|  |         } | ||||||
|  |         map.put("msg", msg); | ||||||
|  |         return ResultVOUtils.success(map); | ||||||
|  |     } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in New Issue