fix: 调整接口处理

dev
huangfeng 10 months ago
parent 48d7522555
commit 80643a81b7

@ -26,21 +26,20 @@ public class MntnController extends BaseController {
@PostMapping("")
@ApiOperation("上传心跳并返回命令")
public ResponseReult<HashMap<String, Object>> sync(@RequestParam("cmdid") String cmdid,
@RequestBody HashMap<String, Object> data,
HttpServletRequest req, HttpServletResponse resp) throws Exception {
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(cmdid, ip, multi, data);
HashMap<String, Object> result = service.sync(ip, multi, data);
resp.setHeader("ResSyncTime", String.valueOf(System.currentTimeMillis()));
return ResponseReult.success(result);
return result;
}
@GetMapping("status")
@ApiOperation("上传命令结果")
public ResponseReult<String> status(@RequestParam("cid") Integer cid,
@RequestParam("res") Integer res,
@RequestParam("content") String content) {
public ResponseReult status(@RequestParam("cid") Integer cid,
@RequestParam("res") Integer res,
@RequestParam("content") String content) {
service.result(cid, res, content);
ResponseReult resp = new ResponseReult();
resp.setCode(0);

@ -6,8 +6,8 @@ import org.apache.catalina.connector.ClientAbortException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.sql.SQLException;
@ -15,7 +15,7 @@ import java.sql.SQLException;
*
* Created by on 2023/5/8.
*/
@ControllerAdvice
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

@ -51,6 +51,9 @@ public class HttpRequestUtil {
return ip;
}
ip = req.getRemoteAddr();
if ("0:0:0:0:0:0:0:1".equals(ip)) {
ip = "127.0.0.1";
}
return ip;
}

@ -38,7 +38,8 @@ public class MntnServiceImpl implements MntnService {
CmdService cmdService;
@Override
public HashMap<String, Object> sync(String cmdid, String ip, String multi, HashMap<String, Object> data) throws Exception {
public HashMap<String, Object> sync(String ip, String multi, HashMap<String, Object> data) throws Exception {
String cmdid = (String) data.get("id");
Terminals term = terminalExtService.getByCmdid(cmdid);
if (term == null) {
throw new ApiException("该装置不存在");

@ -4,7 +4,7 @@ import java.util.HashMap;
public interface MntnService {
HashMap<String, Object> sync(String cmdid, String ip, String multi, HashMap<String, Object> data) throws Exception;
HashMap<String, Object> sync(String ip, String multi, HashMap<String, Object> data) throws Exception;
void result(Integer cid, Integer res, String content);
}

Loading…
Cancel
Save