Browse Source

优化评价器接口

lighter 1 year ago
parent
commit
1e6477a8e9

+ 18 - 4
src/main/java/thyyxxk/webserver/controller/api/bjdeshun/EvaluatorController.java

@@ -34,6 +34,16 @@ public class EvaluatorController {
         this.redis = redis;
     }
 
+    @PassToken
+    @PostMapping("/signInWhenUserLogin")
+    public void signInWhenUserLogin (@RequestBody EvaluateRecord body) throws Exception {
+        String url = CLIENT.replace("{IP}", body.getClientIp())
+                .replace("{ACTION}", "SO");
+        String result = new RestTemplate().postForObject(url, null, String.class);
+        log.info("【{}】执行签退:{}", body.getClientIp(), result);
+        signIn(body);
+    }
+
     @PassToken
     @PostMapping("/start")
     public ResultVo<String> start(HttpServletRequest request, @RequestBody EvaluateRecord body) throws Exception {
@@ -60,7 +70,7 @@ public class EvaluatorController {
         String url = CLIENT.replace("{IP}", ip)
                 .replace("{ACTION}", "LS");
         String result = new RestTemplate().postForObject(url, null, String.class);
-        log.info("查询登录状态:{}", result);
+        log.info("【{}】查询登录状态:{}", ip, result);
         if (null == result) {
             return true;
         }
@@ -77,10 +87,14 @@ public class EvaluatorController {
         String url = CLIENT.replace("{IP}", body.getClientIp())
                 .replace("{ACTION}", "SS");
         String result = new RestTemplate().postForObject(url, params, String.class);
-        log.info("执行登录:{}", result);
+        log.info("【{}】执行登录:{}", body.getClientIp(), result);
         if (null == result) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
         }
+        JSONObject resultJson = JSONObject.parseObject(result.trim());
+        if (!resultJson.getString("code").equals("0")) {
+            throw new BizException(ExceptionEnum.NETWORK_ERROR, resultJson.getString("text"));
+        }
         boolean unSignedIn;
         do {
             TimeUnit.SECONDS.sleep(2);
@@ -92,7 +106,7 @@ public class EvaluatorController {
         String url = CLIENT.replace("{IP}", ip)
                 .replace("{ACTION}", "PR");
         String result = new RestTemplate().postForObject(url, null, String.class);
-        log.info("查询耗时操作进度:{}", result);
+        log.info("【{}】查询耗时操作进度:{}", ip, result);
         if (null == result) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
         }
@@ -108,7 +122,7 @@ public class EvaluatorController {
         String url = CLIENT.replace("{IP}", body.getClientIp())
                 .replace("{ACTION}", "ES");
         String result = new RestTemplate().postForObject(url, null, String.class);
-        log.info("评价结果:{}", result);
+        log.info("【{}】评价结果:{}", body.getClientIp(), result);
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }