|
|
|
@ -3,7 +3,11 @@ package com.shxy.xymanager_admin.controller;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.base.BaseController;
|
|
|
|
|
import com.shxy.xymanager_common.base.ResponseReult;
|
|
|
|
|
import com.shxy.xymanager_common.exception.ApiException;
|
|
|
|
|
import com.shxy.xymanager_common.util.DingTalkPushUtil;
|
|
|
|
|
import com.shxy.xymanager_common.util.HttpRequestUtil;
|
|
|
|
|
import com.shxy.xymanager_common.util.JSONUtil;
|
|
|
|
|
import com.shxy.xymanager_common.util.StringUtils;
|
|
|
|
|
import com.shxy.xymanager_service.service.MntnService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
@ -26,13 +30,27 @@ public class MntnController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@PostMapping("")
|
|
|
|
|
@ApiOperation("上传心跳并返回命令")
|
|
|
|
|
public HashMap<String, Object> sync(@RequestBody HashMap<String, Object> data,
|
|
|
|
|
HttpServletRequest req, HttpServletResponse resp) throws Exception {
|
|
|
|
|
String ip = HttpRequestUtil.getRemoteIp(req);
|
|
|
|
|
String multi = req.getHeader("Accept-Cmds");
|
|
|
|
|
HashMap<String, Object> result = service.sync(ip, multi, data);
|
|
|
|
|
resp.setHeader("ResSyncTime", String.valueOf(System.currentTimeMillis()));
|
|
|
|
|
return result;
|
|
|
|
|
public HashMap<String, Object> sync(@RequestBody String data,
|
|
|
|
|
HttpServletRequest req, HttpServletResponse resp) {
|
|
|
|
|
try {
|
|
|
|
|
String ip = HttpRequestUtil.getRemoteIp(req);
|
|
|
|
|
String multi = req.getHeader("Accept-Cmds");
|
|
|
|
|
HashMap<String, Object> map = JSONUtil.json2Object(data, HashMap.class);
|
|
|
|
|
String cmdid = (String) map.get("id");
|
|
|
|
|
if (StringUtils.isBlank(cmdid)) {
|
|
|
|
|
throw new ApiException("id不能为空");
|
|
|
|
|
}
|
|
|
|
|
HashMap<String, Object> result = service.sync(cmdid, ip, multi, data);
|
|
|
|
|
resp.setHeader("ResSyncTime", String.valueOf(System.currentTimeMillis()));
|
|
|
|
|
return result;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
String str = ex.getMessage() + ", 数据:" + data;
|
|
|
|
|
DingTalkPushUtil.pushText("运维心跳", str);
|
|
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("code", "400");
|
|
|
|
|
result.put("msg", ex.getMessage());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("status")
|
|
|
|
|