Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

martin 3 tahun lalu
induk
melakukan
298f684b0e

+ 1 - 1
api-common/src/main/java/api/common/util/TimeUtil.java

@@ -66,7 +66,7 @@ public class TimeUtil {
 
     //获取间隔 n 秒的时间
     public static Timestamp getPostTimestamp(int secends) {
-        return new Timestamp(System.currentTimeMillis() + secends * 1000);
+        return new Timestamp(System.currentTimeMillis() + secends * 1000L);
     }
 
     //获取两个时间间隔

+ 3 - 1
simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/controller/SignController.java

@@ -14,6 +14,7 @@ import com.css.simulation.oauth.client.configuration.oauth.OauthParameter;
 import com.css.simulation.oauth.client.mapper.LogLoginMapper;
 import com.css.simulation.oauth.client.mapper.UserMapper;
 import com.css.simulation.oauth.client.util.EncodeUtil;
+import com.css.simulation.oauth.client.util.IpUtil;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.SneakyThrows;
@@ -236,7 +237,8 @@ public class SignController {
         LogLoginPO po = new LogLoginPO();
         po.setId(StringUtil.getRandomUUID());
         po.setCreateTime(TimeUtil.getNowForMysql());
-        po.setIp(request.getRemoteAddr());
+        String remoteAddress = IpUtil.getRemoteAddress(request);
+        po.setIp(remoteAddress);
         //登录逻辑判断
         if (userVO == null ) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "用户名或密码错误!");

+ 54 - 0
simulation-oauth-client/src/main/java/com/css/simulation/oauth/client/util/IpUtil.java

@@ -0,0 +1,54 @@
+package com.css.simulation.oauth.client.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class IpUtil {
+
+    //IP地址获取
+    public static String getRemoteAddress(HttpServletRequest headers) {
+        String ip = headers.getHeader("x-forwarded-for");
+        if(ip != null && ip.length() != 0){
+            if(ip.indexOf(",") != -1){
+                ip = ip.split(",")[0];
+            }
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getHeader("Proxy-Client-IP");
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getHeader("WL-Proxy-Client-IP");
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getHeader("HTTP_CLIENT_IP");
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getHeader("HTTP_X_FORWARDED_FOR");
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getHeader("X-Real-IP");
+        }
+        if(ip == null || ip.length() == 0){
+            ip = headers.getRemoteAddr();
+        }
+        if(isIpv4(ip)){
+            return ip;
+        }else{
+            return "Illegal IP address";
+        }
+
+    }
+
+    //IP地址验证,防止非法地址
+    public static boolean isIpv4(String ipAddress) {
+        String ip = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
+                +"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+                +"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+                +"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
+
+        Pattern pattern = Pattern.compile(ip);
+        Matcher matcher = pattern.matcher(ipAddress);
+        return matcher.matches();
+    }
+}

+ 3 - 0
simulation-oauth-client/src/main/resources/bootstrap.yaml

@@ -3,6 +3,9 @@ spring:
     name: simulation-oauth-client
   profiles:
     active: dev
+  jackson:
+    time-zone: GMT+8
+    date-format: yyyy-MM-dd HH:mm:ss
 
 mybatis:
   configuration:

+ 1 - 1
simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/feign/ProjectService.java

@@ -8,7 +8,7 @@ import java.util.Map;
 
 @FeignClient(contextId = "ProjectService",
         value = "simulation-resource-server",
-        url = "http://127.0.0.1:7003",
+        //url = "http://127.0.0.1:7003",
         path = "/simulation/resource/server",
         fallback = ProjectServiceFallback.class)
 public interface ProjectService {

+ 7 - 11
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -65,21 +65,17 @@ public class AlgorithmServiceImpl implements AlgorithmService {
             if(DictConstants.FILE.equals(uploadMode)){
                 String minioPath = param.getMinioPath();
                 ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
-                if(checkRes.isStatus()){
-                    return doAddOrUpdate(param);
-                }else {
+                if(ObjectUtil.isNull(checkRes)){
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"算法校验服务异常,请联系管理人员!");
+                }
+                if(!checkRes.isStatus()){//校验失败
                     MinioParameter minioParameter = new MinioParameter();
                     minioParameter.setObjectName(minioPath);
-                    Response remove =fileDownService.remove(minioParameter);
-                    if(remove.status() == 200){
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件已删除!");
-                    }else {
-                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
-                    }
+                    fileDownService.remove(minioParameter);
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存!");
                 }
-            }else {
-                 return doAddOrUpdate(param);
             }
+            return doAddOrUpdate(param);
         }
     }
 

+ 5 - 2
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/MonitorService.java

@@ -9,8 +9,11 @@ import org.springframework.web.bind.annotation.PostMapping;
 
 import java.util.List;
 
-@FeignClient(name = "MonitorService",
-        url = "http://127.0.0.1:7004",
+@FeignClient(
+        //name = "MonitorService",
+        //url = "http://127.0.0.1:7004",
+        contextId = "MonitorService",
+        value = "simulation-resource-monitor",
         path = "/simulation/resource/monitor",
         fallback = MonitorServiceFallback.class,
         configuration = FeignConfiguration.class)

+ 1 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ClusterCtrl.java

@@ -74,7 +74,7 @@ public class ClusterCtrl {
     }
 
     /**
-     * 查询已分配未到期节点数量
+     * 查询仿真软件license数量
      */
     @RequestMapping("/getLicenseNum")
     @ResponseBody

+ 0 - 3
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/SceneImportCtrl.java

@@ -14,9 +14,6 @@ import org.springframework.stereotype.Controller;
 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.context.request.RequestAttributes;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;

+ 3 - 0
simulation-resource-server/src/main/resources/bootstrap.yaml

@@ -3,6 +3,9 @@ spring:
     name: simulation-resource-server
   profiles:
     active: dev
+  jackson:
+    time-zone: GMT+8
+    date-format: yyyy-MM-dd HH:mm:ss
 
 # 分页插件配置
 pagehelper:

+ 10 - 10
simulation-resource-server/src/main/resources/mapper/system/SceneImportMapper.xml

@@ -72,16 +72,16 @@
 
     <select id="getSceneImporPagetList" parameterType="api.common.pojo.param.system.SceneImportPageParam" resultType="api.common.pojo.po.system.SceneImportPO">
         select
-        id,
-        name,
-        scene_type,
-        status,
-        success_num,
-        false_num,
-        error_message,
-        total_time,
-        create_time,
-        is_deleted
+          id,
+          name,
+          scene_type,
+          status,
+          success_num,
+          false_num,
+          error_message,
+          total_time,
+          create_time,
+          is_deleted
         from simulation.scene_import_task
         where
         is_deleted = '0'