Ver Fonte

算法保存修改、参数管理、集群管理功能开发

zhaoyan há 3 anos atrás
pai
commit
fb6f830336
21 ficheiros alterados com 579 adições e 178 exclusões
  1. 33 0
      api-common/src/main/java/api/common/pojo/param/system/ClusterParam.java
  2. 3 0
      api-common/src/main/java/api/common/pojo/param/system/ParameterParam.java
  3. 17 0
      api-common/src/main/java/api/common/pojo/po/system/ClusterPO.java
  4. 0 1
      api-common/src/main/java/api/common/pojo/po/system/ParameterPO.java
  5. 20 0
      api-common/src/main/java/api/common/pojo/vo/system/ClusterVO.java
  6. 43 23
      simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java
  7. 1 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserDetails.java
  8. 10 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/common/utils/AuthUtil.java
  9. 4 1
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/FileDownService.java
  10. 24 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/SchedulerService.java
  11. 5 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/FileDownServiceFallback.java
  12. 13 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/SchedulerServiceFallback.java
  13. 127 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ClusterCtrl.java
  14. 5 43
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java
  15. 27 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java
  16. 2 10
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java
  17. 61 0
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java
  18. 14 40
      simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java
  19. 6 3
      simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml
  20. 135 0
      simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml
  21. 29 57
      simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

+ 33 - 0
api-common/src/main/java/api/common/pojo/param/system/ClusterParam.java

@@ -0,0 +1,33 @@
+package api.common.pojo.param.system;
+
+import api.common.pojo.common.PageVO;
+import lombok.Data;
+
+@Data
+public class ClusterParam extends PageVO {
+
+    //账户名
+    private String userName;
+
+    //账户id
+    private String userId;
+
+    //账户类型 2表示管理员账户查询的普通账户列表,3表示普通账户查询的普通账户子账号列表
+    private String roleCode;
+
+    //创建用户ID
+    private String createUserId;
+
+    //操作时间开始
+    private String modifyTimeStart;
+
+    //操作时间结束
+    private String modifyTimeEnd;
+
+    //到期时间开始
+    private String dueTimeStart;
+
+    //到期时间结束
+    private String dueTimeEnd;
+
+}

+ 3 - 0
api-common/src/main/java/api/common/pojo/param/system/ParameterParam.java

@@ -9,4 +9,7 @@ public class ParameterParam extends PageVO {
     //账户名
     private String userName;
 
+    //账户id
+    private String userId;
+
 }

+ 17 - 0
api-common/src/main/java/api/common/pojo/po/system/ClusterPO.java

@@ -0,0 +1,17 @@
+package api.common.pojo.po.system;
+
+import api.common.pojo.common.CommonPO;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ClusterPO extends CommonPO {
+
+    private String id;              // 用户主键(唯一)
+    private String userId;        // 账户id
+    private int numSimulationLicense;        // 仿真软件license数量
+    private Date dateSimulationLicense;       // 仿真软件license到期时间
+    private int numDynamicLicense;        // 动力学软件license数量
+    private Date dateDynamicLicense;       // 动力学软件license到期时间
+}

+ 0 - 1
api-common/src/main/java/api/common/pojo/po/system/ParameterPO.java

@@ -7,7 +7,6 @@ import lombok.Data;
 public class ParameterPO extends CommonPO {
 
     private String id;              // 用户主键(唯一)
-    private String userName;        // 账户名称
     private String userId;        // 账户id
     private int numCreateUser;        // 可创建子账户数量
     private int numCreateScenePackage;           // 最多可创建场景测试包数量

+ 20 - 0
api-common/src/main/java/api/common/pojo/vo/system/ClusterVO.java

@@ -0,0 +1,20 @@
+package api.common.pojo.vo.system;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ClusterVO {
+
+    private String id;              // 用户主键(唯一)
+    private String userName;        // 账户名称
+    private String userType;        // 占用类型
+    private String userId;        // 账户id
+    private int numSimulationLicense;        // 仿真软件license数量
+    private Date dateSimulationLicense;       // 仿真软件license到期时间
+    private int numDynamicLicense;        // 动力学软件license数量
+    private Date dateDynamicLicense;       // 动力学软件license到期时间
+    private Date modifyTime;        // 操作时间
+
+}

+ 43 - 23
simulation-resource-server/src/main/java/com/css/simulation/resource/algorithm/serviceImpl/AlgorithmServiceImpl.java

@@ -1,5 +1,6 @@
 package com.css.simulation.resource.algorithm.serviceImpl;
 import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.param.MinioParameter;
 import api.common.pojo.param.algorithm.AlgorithmParameter;
 import api.common.pojo.param.system.DictParam;
 import api.common.pojo.po.algorithm.AlgorithmPO;
@@ -12,12 +13,11 @@ import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
 import com.css.simulation.resource.algorithm.service.AlgorithmService;
 import com.css.simulation.resource.feign.AlgoPlatformService;
+import com.css.simulation.resource.feign.FileDownService;
+import com.css.simulation.resource.feign.SchedulerService;
 import com.css.simulation.resource.system.service.DictService;
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.github.pagehelper.PageInfo;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
+import feign.Response;
 import org.eclipse.jgit.lib.Ref;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -38,6 +38,12 @@ public class AlgorithmServiceImpl implements AlgorithmService {
     @Resource
     AlgoPlatformService algoPlatformService;
 
+    @Resource
+    SchedulerService schedulerService;
+
+    @Resource
+    FileDownService fileDownService;
+
     @Autowired
     private AlgorithmMapper algorithmMapper;
 
@@ -53,29 +59,43 @@ public class AlgorithmServiceImpl implements AlgorithmService {
         if(algorithmPOS != null && algorithmPOS.size() > 0){
             return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法名称已存在!");
         }else {
-            if(isEmpty(param.getId())){
-                //添加
-                String algorithmId = StringUtil.getRandomUUID();
-                param.setId(algorithmId);
-                String algorithmCode = StringUtil.getRandomCode();
-                param.setAlgorithmCode(algorithmCode);
-                AlgorithmPO po = setPo(param, false);
-                int add = algorithmMapper.add(po);
-                if(add > 0){
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+            String minioPath = param.getMinioPath();
+            ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
+            if(checkRes.isStatus()){
+                if(isEmpty(param.getId())){
+                    //添加
+                    String algorithmId = StringUtil.getRandomUUID();
+                    param.setId(algorithmId);
+                    String algorithmCode = StringUtil.getRandomCode();
+                    param.setAlgorithmCode(algorithmCode);
+                    AlgorithmPO po = setPo(param, false);
+                    int add = algorithmMapper.add(po);
+                    if(add > 0){
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    }else {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+                    }
                 }else {
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
+                    //编辑
+                    AlgorithmPO po = setPo(param, true);
+                    int add = algorithmMapper.update(po);
+                    if (add > 0) {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                    }else {
+                        return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
+                    }
                 }
             }else {
-                //编辑
-                AlgorithmPO po = setPo(param, true);
-                int add = algorithmMapper.update(po);
-                if (add > 0) {
-                    return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
+                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, "编辑失败");
+                    return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"该算法经校验不可用,无法保存,算法文件删除失败!");
                 }
             }
+
         }
     }
 
@@ -300,13 +320,13 @@ public class AlgorithmServiceImpl implements AlgorithmService {
 
         if(isEdit){
             po.setModifyTime(TimeUtil.getNowForMysql());
-            po.setCreateUserId(AuthUtil.getCurrentUserId());
+            po.setModifyUserId(AuthUtil.getCurrentUserId());
         }else {
             po.setIsDeleted("0");
             po.setCreateTime(TimeUtil.getNowForMysql());
             po.setModifyTime(TimeUtil.getNowForMysql());
             po.setCreateUserId(AuthUtil.getCurrentUserId());
-            po.setModifyTime(TimeUtil.getNowForMysql());
+            po.setModifyUserId(AuthUtil.getCurrentUserId());
         }
         return po;
 

+ 1 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/oauth/MyUserDetails.java

@@ -20,6 +20,7 @@ public class MyUserDetails implements UserDetails, Serializable {
     private String username;
     private String password;
     private String roleCode;
+    private String userType;
     private String createUserId;
     private Set<GrantedAuthority> authorities;
 

+ 10 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/common/utils/AuthUtil.java

@@ -29,4 +29,14 @@ public class AuthUtil {
         return roleCode;
     }
 
+    /**
+     * 获取当前登录人roleCode
+     */
+    public static String getCurrentUserType(){
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        MyUserDetails userDetails = (MyUserDetails)authentication.getPrincipal();
+        String userType = userDetails.getUserType();
+        return userType;
+    }
+
 }

+ 4 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/FileDownService.java

@@ -15,7 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.util.List;
 
 
-//@FeignClient(name = "test", url = "http://47.93.217.159",path = "/simulation/resource/common", fallback = FileDownServiceFallback.class, configuration = FeignConfiguration.class)
+//@FeignClient(name = "test", url = "http://10.15.12.72:8001",path = "/simulation/resource/common", fallback = FileDownServiceFallback.class, configuration = FeignConfiguration.class)
 @FeignClient(
         contextId = "file",
         value = "simulation-resource-common",
@@ -46,4 +46,7 @@ public interface FileDownService {
     @RequestMapping("/minio/getPreviewUrl")
     ResponseBodyVO<String> getPreviewUrl(@RequestBody @Validated MinioParameter minioParameter);
 
+    @PostMapping("/minio/remove")
+    Response remove(@RequestBody @Validated MinioParameter minioParameter);
+
 }

+ 24 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/SchedulerService.java

@@ -0,0 +1,24 @@
+package com.css.simulation.resource.feign;
+
+import api.common.pojo.common.ResponseBodyVO;
+import com.css.simulation.resource.common.config.FeignConfiguration;
+import com.css.simulation.resource.feign.fallback.SchedulerServiceFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+//@FeignClient(name = "scheduler", url = "http://47.94.105.148", path = "/simulation/resource/scheduler", fallback = SchedulerServiceFallback.class, configuration = FeignConfiguration.class)
+@FeignClient(
+        contextId = "scheduler",
+        value = "simulation-resource-scheduler",
+        path = "/simulation/resource/scheduler",
+        fallback = SchedulerServiceFallback.class,
+        configuration = FeignConfiguration.class
+)
+public interface SchedulerService {
+
+    @PostMapping(value = "/algorithm/check")
+    ResponseBodyVO<String> check(@RequestParam("minioPath") String minioPath);
+
+}

+ 5 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/FileDownServiceFallback.java

@@ -56,4 +56,9 @@ public class FileDownServiceFallback implements FileDownService {
         return null;
     }
 
+    @Override
+    public Response remove(@RequestBody @Validated MinioParameter minioParameter) {
+        log.error("------- 删除错误:" + minioParameter.getObjectName());
+        return null;
+    }
 }

+ 13 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/feign/fallback/SchedulerServiceFallback.java

@@ -0,0 +1,13 @@
+package com.css.simulation.resource.feign.fallback;
+
+import api.common.pojo.common.ResponseBodyVO;
+import com.css.simulation.resource.feign.SchedulerService;
+import org.springframework.web.bind.annotation.RequestParam;
+
+public class SchedulerServiceFallback implements SchedulerService {
+
+    @Override
+    public ResponseBodyVO<String> check(@RequestParam String minioPath){
+        return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE);
+    }
+}

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

@@ -0,0 +1,127 @@
+package com.css.simulation.resource.system.ctrl;
+
+import api.common.pojo.common.ResponseBodyVO;
+import api.common.pojo.constants.DictConstants;
+import api.common.pojo.param.system.ClusterParam;
+import api.common.pojo.po.system.ClusterPO;
+import api.common.pojo.vo.system.ClusterVO;
+import api.common.util.ObjectUtil;
+import com.css.simulation.resource.common.utils.AuthUtil;
+import com.css.simulation.resource.system.service.ClusterService;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+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 java.util.HashMap;
+
+
+@Controller()
+@RequestMapping("/cluster")
+public class ClusterCtrl {
+
+    @Autowired
+    ClusterService clusterService;
+
+
+    /**
+     * 查询集群列表
+     */
+    @RequestMapping("/getClusterList")
+    @ResponseBody
+    public ResponseBodyVO<PageInfo<ClusterVO>> getClusterList(@RequestBody ClusterParam clusterParam){
+
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        if(roleCode == null){
+            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
+        }
+        //当前账户为普通账户子账户,列表显示空
+        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            clusterParam.setRoleCode("-1");//查不到
+        }
+        //当前账户为管理员账户,需要查询普通账户,设置roleCode为2
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){
+            clusterParam.setRoleCode(DictConstants.ROLE_CODE_UESR);
+        }
+        // 当前账户为普通账户,需要查询该账户创建的普通账户子账户,设置roleCode为3及当前创建用户id
+        if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){
+            String userType = AuthUtil.getCurrentUserType();
+            if("1".equals(userType)){//独占
+                clusterParam.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
+                clusterParam.setCreateUserId(AuthUtil.getCurrentUserId());
+            }else {
+                clusterParam.setRoleCode("-1"); //查不到
+            }
+
+        }
+        ResponseBodyVO<PageInfo<ClusterVO>> response = new ResponseBodyVO<PageInfo<ClusterVO>>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(clusterService.getClusterList(clusterParam));
+        return response;
+    }
+
+    /**
+     * 新增、修改
+     */
+    @RequestMapping("/saveCluster")
+    @ResponseBody
+    public ResponseBodyVO<ClusterPO> saveCluster(@RequestBody ClusterPO clusterPO) throws Exception {
+        if(ObjectUtil.isNull(clusterPO)){
+            return new ResponseBodyVO(false, 400, "参数必传!",null);
+        }
+        ResponseBodyVO<ClusterPO> response = new ResponseBodyVO<ClusterPO>(ResponseBodyVO.Response.SUCCESS);
+        clusterPO = clusterService.saveCluster(clusterPO);
+        response.setInfo(clusterPO);
+        return response;
+    }
+
+    /**
+     * 查询集群修改历史记录
+     */
+    @RequestMapping("/getClusterHistory")
+    @ResponseBody
+    public ResponseBodyVO<PageInfo<ClusterVO>> getClusterHistory(@RequestBody ClusterParam clusterParam){
+
+        ResponseBodyVO<PageInfo<ClusterVO>> response = new ResponseBodyVO<PageInfo<ClusterVO>>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(clusterService.getClusterHistory(clusterParam));
+        return response;
+    }
+
+    /**
+     * 查询已分配未到期节点数量
+     */
+    @RequestMapping("/getClusterNum")
+    @ResponseBody
+    public ResponseBodyVO<HashMap<String, Integer>> getClusterNum() throws Exception {
+
+        ClusterParam clusterParam = new ClusterParam();
+        ResponseBodyVO<HashMap<String, Integer>> response = new ResponseBodyVO<HashMap<String, Integer>>(ResponseBodyVO.Response.SUCCESS);
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        if(roleCode == null){
+            return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE);
+        }
+        if(DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)){
+            response.setInfo(null);
+        }
+        //当前账户为管理员账户,需要查询普通账户,设置roleCode为2
+        if(DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)){
+            clusterParam.setRoleCode(DictConstants.ROLE_CODE_UESR);
+        }
+        // 当前账户为普通账户,需要查询该账户创建的普通账户子账户,设置roleCode为3及当前创建用户id
+        if(DictConstants.ROLE_CODE_UESR.equals(roleCode)){
+            String userType = AuthUtil.getCurrentUserType();
+            if("1".equals(userType)){//独占
+                clusterParam.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
+                clusterParam.setCreateUserId(AuthUtil.getCurrentUserId());
+            }else {
+                response.setInfo(null);
+            }
+
+        }
+        HashMap<String, Integer> resMap = clusterService.getClusterNum(clusterParam);
+        response.setInfo(resMap);
+        return response;
+    }
+
+}

+ 5 - 43
simulation-resource-server/src/main/java/com/css/simulation/resource/system/ctrl/ParameterCtrl.java

@@ -1,12 +1,9 @@
 package com.css.simulation.resource.system.ctrl;
 
 import api.common.pojo.common.ResponseBodyVO;
-import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.system.ParameterParam;
-import api.common.pojo.param.system.UserParam;
 import api.common.pojo.po.system.ParameterPO;
 import api.common.pojo.vo.system.ParameterVO;
-import api.common.pojo.vo.system.UserVO;
 import api.common.util.ObjectUtil;
 import com.css.simulation.resource.system.service.ParameterService;
 import com.github.pagehelper.PageInfo;
@@ -16,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.util.List;
-
 
 @Controller()
 @RequestMapping("/parameter")
@@ -49,51 +44,18 @@ public class ParameterCtrl {
         }
         ResponseBodyVO<ParameterPO> response = new ResponseBodyVO<ParameterPO>(ResponseBodyVO.Response.SUCCESS);
         parameterPO = parameterService.saveParameter(parameterPO);
-        if(ObjectUtil.isNull(parameterPO.getId())){
-            return new ResponseBodyVO(false, 400, "该账户名已存在一条参数配置信息,无法创建!",null);
-        }
         response.setInfo(parameterPO);
         return response;
     }
 
-
-    /**
-     * 查看参数配置详情
-     */
-    @RequestMapping("/getParamInfoById")
-    @ResponseBody
-    public ResponseBodyVO getParamInfoById(@RequestBody ParameterPO parameterPO) {
-        ResponseBodyVO<ParameterVO> response = new ResponseBodyVO<ParameterVO>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(parameterService.getParamInfoById(parameterPO));
-        return response;
-    }
-
     /**
-     * 删除算法
-     * @return
+     * 查询参数修改历史记录
      */
-    @RequestMapping("deleteById")
+    @RequestMapping("/getParamHistory")
     @ResponseBody
-    public ResponseBodyVO deleteById(@RequestBody ParameterPO parameterPO){
-        parameterPO.setIsDeleted(DictConstants.YES);
-        int i = parameterService.deleteById(parameterPO);
-        if(i>0){
-            return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
-        }else{
-            return new ResponseBodyVO(false, 500, "删除失败!",null);
-        }
-    }
-
-
-    /**
-     * 模糊查询普通账户
-     */
-    @RequestMapping("/getUserInfo")
-    @ResponseBody
-    public ResponseBodyVO<List<UserVO>> getUserInfo(@RequestBody UserParam userParam){
-        userParam.setRoleCode(DictConstants.ROLE_CODE_UESR);
-        ResponseBodyVO<List<UserVO>> response = new ResponseBodyVO<List<UserVO>>(ResponseBodyVO.Response.SUCCESS);
-        response.setInfo(parameterService.getUserInfo(userParam));
+    public ResponseBodyVO<PageInfo<ParameterVO>> getParamHistory(@RequestBody ParameterParam pageParam){
+        ResponseBodyVO<PageInfo<ParameterVO>> response = new ResponseBodyVO<PageInfo<ParameterVO>>(ResponseBodyVO.Response.SUCCESS);
+        response.setInfo(parameterService.getParamHistory(pageParam));
         return response;
     }
 

+ 27 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ClusterMapper.java

@@ -0,0 +1,27 @@
+package com.css.simulation.resource.system.mapper;
+
+import api.common.pojo.param.system.ClusterParam;
+import api.common.pojo.po.system.ClusterPO;
+import api.common.pojo.vo.system.ClusterVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.HashMap;
+import java.util.List;
+
+@Mapper
+@Repository
+public interface ClusterMapper {
+
+    List<ClusterVO> getClusterList(ClusterParam clusterParam);
+
+    void insert(ClusterPO clusterPO);
+
+    void deleteById(ClusterPO clusterPO);
+
+    List<ClusterVO> getClusterHistory(ClusterParam clusterParam);
+
+    HashMap<String, Integer> getClusterNum(ClusterParam clusterParam);
+
+}

+ 2 - 10
simulation-resource-server/src/main/java/com/css/simulation/resource/system/mapper/ParameterMapper.java

@@ -1,10 +1,8 @@
 package com.css.simulation.resource.system.mapper;
 
 import api.common.pojo.param.system.ParameterParam;
-import api.common.pojo.param.system.UserParam;
 import api.common.pojo.po.system.ParameterPO;
 import api.common.pojo.vo.system.ParameterVO;
-import api.common.pojo.vo.system.UserVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -17,16 +15,10 @@ public interface ParameterMapper {
 
     List<ParameterVO> getParameterList(ParameterParam pageParam);
 
-    ParameterVO getParamInfoById(@Param("paramId") String paramId);
-
     void insert(ParameterPO parameterPO);
 
-    void update(ParameterPO parameterPO);
-
-    List<ParameterPO> checkUsername(ParameterPO parameterPO);
-
-    int deleteById(ParameterPO parameterPO);
+    void deleteById(ParameterPO parameterPO);
 
-    List<UserVO> getUserInfo(UserParam userParam);
+    List<ParameterVO> getParamHistory(ParameterParam pageParam);
 
 }

+ 61 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ClusterService.java

@@ -0,0 +1,61 @@
+package com.css.simulation.resource.system.service;
+
+import api.common.pojo.param.system.ClusterParam;
+import api.common.pojo.po.system.ClusterPO;
+import api.common.pojo.vo.system.ClusterVO;
+import api.common.util.ObjectUtil;
+import api.common.util.StringUtil;
+import com.css.simulation.resource.common.utils.PageUtil;
+import com.css.simulation.resource.common.utils.PoUtil;
+import com.css.simulation.resource.system.mapper.ClusterMapper;
+import com.github.pagehelper.PageInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+
+
+@Service
+public class ClusterService {
+
+    @Autowired
+    ClusterMapper clusterMapper;
+
+
+    public PageInfo<ClusterVO> getClusterList(ClusterParam clusterParam) {
+        PageUtil.setPageInfo(clusterParam);
+        List<ClusterVO> list = clusterMapper.getClusterList(clusterParam);
+        return new PageInfo<>(list);
+    }
+
+
+    public ClusterPO saveCluster(ClusterPO clusterPO) {
+        String id = clusterPO.getId();
+        if(ObjectUtil.isNotNull(id)){
+            // 更新,将原纪录is_deleted置为1
+            ClusterPO deleteClusterPo = new ClusterPO();
+            deleteClusterPo.setId(id);
+            PoUtil.initDelPo(deleteClusterPo);
+            clusterMapper.deleteById(deleteClusterPo);
+        }
+        clusterPO.setId(StringUtil.getRandomUUID());
+        PoUtil.initAddPo(clusterPO);
+        clusterMapper.insert(clusterPO);
+        return clusterPO;
+    }
+
+
+    public PageInfo<ClusterVO> getClusterHistory(ClusterParam clusterParam) {
+        PageUtil.setPageInfo(clusterParam);
+        List<ClusterVO> list = clusterMapper.getClusterHistory(clusterParam);
+        return new PageInfo<>(list);
+    }
+
+
+    public HashMap<String, Integer> getClusterNum(ClusterParam clusterParam) {
+
+        HashMap<String, Integer> resMap = clusterMapper.getClusterNum(clusterParam);
+        return resMap;
+    }
+}

+ 14 - 40
simulation-resource-server/src/main/java/com/css/simulation/resource/system/service/ParameterService.java

@@ -1,17 +1,10 @@
 package com.css.simulation.resource.system.service;
 
-import api.common.pojo.constants.DictConstants;
 import api.common.pojo.param.system.ParameterParam;
-import api.common.pojo.param.system.UserParam;
 import api.common.pojo.po.system.ParameterPO;
 import api.common.pojo.vo.system.ParameterVO;
-import api.common.pojo.vo.system.UserVO;
-import api.common.util.EncryptUtil;
 import api.common.util.ObjectUtil;
 import api.common.util.StringUtil;
-import api.common.util.TimeUtil;
-import com.css.simulation.resource.common.oauth.OauthParameter;
-import com.css.simulation.resource.common.utils.AuthUtil;
 import com.css.simulation.resource.common.utils.PageUtil;
 import com.css.simulation.resource.common.utils.PoUtil;
 import com.css.simulation.resource.system.mapper.ParameterMapper;
@@ -19,7 +12,6 @@ import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.security.NoSuchAlgorithmException;
 import java.util.List;
 
 
@@ -37,44 +29,26 @@ public class ParameterService {
     }
 
 
-    public ParameterVO getParamInfoById(ParameterPO paramPO) {
-        String paramId = paramPO.getId();
-        ParameterVO parameterVO = parameterMapper.getParamInfoById(paramId);
-        return parameterVO;
-    }
-
     public ParameterPO saveParameter(ParameterPO paramPO) {
-        //重名校验param
-        List<ParameterPO> list = parameterMapper.checkUsername(paramPO);
-        if(ObjectUtil.isNotNull(list)){
-            paramPO.setId(null);
-            return paramPO;
-        }
         String id = paramPO.getId();
-        if(ObjectUtil.isNull(id)){//新增
-            PoUtil.initAddPo(paramPO);
-            paramPO.setId(StringUtil.getRandomUUID());
-            parameterMapper.insert(paramPO);
-        }else{ //更新
-            PoUtil.initUpdatePo(paramPO);
-            parameterMapper.update(paramPO);
+        if(ObjectUtil.isNotNull(id)){
+            // 更新,将原纪录is_deleted置为1
+            ParameterPO deleteParamPo = new ParameterPO();
+            deleteParamPo.setId(id);
+            PoUtil.initDelPo(deleteParamPo);
+            parameterMapper.deleteById(deleteParamPo);
         }
+        //新增一条纪录
+        paramPO.setId(StringUtil.getRandomUUID());
+        PoUtil.initAddPo(paramPO);
+        parameterMapper.insert(paramPO);
         return paramPO;
     }
 
-
-    public int deleteById(ParameterPO parameterPO) {
-        parameterPO.setIsDeleted(DictConstants.YES);
-        parameterPO.setModifyUserId(AuthUtil.getCurrentUserId());
-        parameterPO.setModifyTime(TimeUtil.getNowForMysql());
-        int i = parameterMapper.deleteById(parameterPO);
-        return i;
-    }
-
-
-    public List<UserVO> getUserInfo(UserParam userParam) {
-        List<UserVO> list = parameterMapper.getUserInfo(userParam);
-        return list;
+    public PageInfo<ParameterVO> getParamHistory(ParameterParam pageParam) {
+        PageUtil.setPageInfo(pageParam);
+        List<ParameterVO> list = parameterMapper.getParamHistory(pageParam);
+        return new PageInfo<>(list);
     }
 
 }

+ 6 - 3
simulation-resource-server/src/main/resources/mapper/algorithm/AlgorithmMapper.xml

@@ -14,7 +14,8 @@
         validation_status,
         upload_mode,
         git_url,
-        git_token,
+        git_user_name,
+        git_password,
         file_name,
         minio_path,
         share,
@@ -33,7 +34,8 @@
         #{validationStatus,jdbcType=VARCHAR},
         #{uploadMode,jdbcType=VARCHAR},
         #{gitUrl,jdbcType=VARCHAR},
-        #{gitToken,jdbcType=VARCHAR},
+        #{gitUserName,jdbcType=VARCHAR},
+        #{gitPassword,jdbcType=VARCHAR},
         #{fileName,jdbcType=VARCHAR},
         #{minioPath,jdbcType=VARCHAR},
         #{share,jdbcType=VARCHAR},
@@ -154,7 +156,8 @@
         validation_status=#{validationStatus,jdbcType=VARCHAR},
         upload_mode=#{uploadMode,jdbcType=VARCHAR},
         git_url=#{gitUrl,jdbcType=VARCHAR},
-        git_token=#{gitToken,jdbcType=VARCHAR},
+        git_user_name=#{gitUserName,jdbcType=VARCHAR},
+        git_password=#{gitPassword,jdbcType=VARCHAR},
         file_name=#{fileName,jdbcType=VARCHAR},
         minio_path=#{minioPath,jdbcType=VARCHAR},
         modify_time=#{modifyTime,jdbcType=VARCHAR},

+ 135 - 0
simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.css.simulation.resource.system.mapper.ClusterMapper" >
+
+
+    <!--查询集群列表-->
+    <select id="getClusterList" parameterType="api.common.pojo.param.system.ClusterParam" resultType="api.common.pojo.vo.system.ClusterVO">
+        select
+        p.id,
+        u.id as user_id,
+        u.username,
+        u.use_type,
+        IFNULL(p.num_simulation_license,0) as num_simulation_license,
+        IFNULL(p.num_dynamic_license,0) as num_dynamic_license,
+        p.date_simulation_license,
+        p.date_dynamic_license,
+        p.modify_time
+        from system_user u
+        left join system_cluster p on u.id = p.user_id
+        <where>
+            u.is_deleted = '0' and u.visible = '1'
+            and u.role_code = #{roleCode,jdbcType=VARCHAR}
+        </where>
+        <if test="createUserId != null and createUserId != ''">
+            and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
+        </if>
+        <if test="userName != null and userName != ''">
+            and u.username like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="modifyTimeStart != null and modifyTimeStart != ''">
+            and p.modify_time &gt;= #{modifyTimeStart}
+        </if>
+        <if test="modifyTimeEnd != null and modifyTimeEnd != ''">
+            and p.modify_time &lt;= #{modifyTimeEnd}
+        </if>
+        <if test="dueTimeStart != null and dueTimeStart != ''">
+            and (p.date_simulation_license &gt;= #{dueTimeStart} or p.date_dynamic_license &gt;= #{dueTimeStart})
+        </if>
+        <if test="dueTimeEnd != null and dueTimeEnd != ''">
+            and (p.date_simulation_license &lt;= #{dueTimeEnd} or p.date_dynamic_license &lt;= #{dueTimeEnd})
+        </if>
+        order by modify_time desc
+    </select>
+
+
+    <!--    新增集群配置信息-->
+    <insert id="insert" parameterType="api.common.pojo.po.system.ClusterPO">
+        INSERT INTO system_cluster(
+            id,
+            user_id,
+            num_simulation_license,
+            date_simulation_license,
+            num_dynamic_license,
+            date_dynamic_license,
+            create_time,
+            modify_time,
+            create_user_id,
+            modify_user_id,
+            is_deleted
+        )
+        VALUES(
+            #{id,jdbcType=VARCHAR},
+            #{userId,jdbcType=VARCHAR},
+            #{numSimulationLicense,jdbcType=INTEGER},
+            #{dateSimulationLicense,jdbcType=TIMESTAMP},
+            #{numDynamicLicense,jdbcType=INTEGER},
+            #{dateDynamicLicense,jdbcType=TIMESTAMP},
+            #{createTime,jdbcType=TIMESTAMP},
+            #{modifyTime,jdbcType=TIMESTAMP},
+            #{createUserId,jdbcType=VARCHAR},
+            #{modifyUserId,jdbcType=VARCHAR},
+            #{isDeleted,jdbcType=VARCHAR}
+        )
+    </insert>
+
+    <!--    修改参数配置信息-->
+    <update id="deleteById" parameterType="api.common.pojo.po.system.ClusterPO">
+        update system_cluster set
+            is_deleted = #{isDeleted,jdbcType=VARCHAR},
+            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
+            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
+        where id = #{id,jdbcType=VARCHAR}
+    </update>
+
+    <!--查询集群修改历史记录-->
+    <select id="getClusterHistory" parameterType="api.common.pojo.param.system.ClusterParam" resultType="api.common.pojo.vo.system.ClusterVO">
+        select
+        id,
+        IFNULL(num_simulation_license,0) as num_simulation_license,
+        IFNULL(num_dynamic_license,0) as num_dynamic_license,
+        date_simulation_license,
+        date_dynamic_license,
+        modify_time
+        from system_cluster
+        <where>
+            is_deleted = '1'
+        </where>
+        <if test="userId != null and userId != ''">
+            and  user_id = #{userId,jdbcType=VARCHAR}
+        </if>
+        order by modify_time desc
+    </select>
+
+    <!--查询已分配未到期节点数量-->
+    <select id="getClusterNum" parameterType="api.common.pojo.param.system.ClusterParam" resultType="java.util.HashMap">
+        select
+        (
+        select
+        sum(p.num_simulation_license)
+        from system_user u
+        left join system_cluster p on u.id = p.user_id
+        <where>
+            u.is_deleted = '0' and u.visible = '1'
+            and p.date_simulation_license >= NOW()
+            and u.role_code = #{roleCode,jdbcType=VARCHAR}
+        </where>
+        <if test="createUserId != null and createUserId != ''">
+            and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
+        </if>
+        ) as totalSimulation, (
+        select
+        sum(p.num_dynamic_license)
+        from system_user u
+        left join system_cluster p on u.id = p.user_id
+        <where>
+            u.is_deleted = '0' and u.visible = '1'
+            and p.date_dynamic_license >= NOW()
+            and u.role_code = #{roleCode,jdbcType=VARCHAR}
+        </where>
+        <if test="createUserId != null and createUserId != ''">
+            and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
+        </if>
+        ) as totalDynamic
+    </select>
+</mapper>

+ 29 - 57
simulation-resource-server/src/main/resources/mapper/system/ParameterMapper.xml

@@ -5,47 +5,30 @@
 
     <!--查询参数列表-->
     <select id="getParameterList" parameterType="api.common.pojo.param.system.ParameterParam" resultType="api.common.pojo.vo.system.ParameterVO">
-        select id, user_name, user_id, num_create_user, num_create_scene_package, num_scene_per_package, modify_time from system_parameter
+        select
+        p.id,
+        u.id as user_id,
+        u.username,
+        IFNULL(p.num_create_user,0) as num_create_user,
+        IFNULL(p.num_create_scene_package,0) as num_create_scene_package,
+        IFNULL(p.num_scene_per_package,0) as  num_scene_per_package,
+        p.modify_time
+        from system_user u
+        left join system_parameter p on u.id = p.user_id
         <where>
-            is_deleted = '0'
+            u.is_deleted = '0' and u.visible = '1' and u.role_code = '2'
         </where>
         <if test="userName != null and userName != ''">
-            and user_name like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
+            and u.username like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
         </if>
-        order by modify_time desc, create_time desc
-    </select>
-
-    <!--    查询参数配置详情-->
-    <select id="getParamInfoById" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ParameterVO">
-        SELECT
-            id,
-            user_name,
-            user_id,
-            num_create_user,
-            num_create_scene_package,
-            num_scene_per_package,
-            modify_time
-        FROM system_parameter WHERE id = #{paramId,jdbcType=VARCHAR}
+        order by modify_time desc
     </select>
 
-    <!--    检查该账户名是否已存在参数配置信息-->
-    <select id="checkUsername" parameterType="api.common.pojo.po.system.ParameterPO" resultType="api.common.pojo.po.system.ParameterPO">
-        select
-        id
-        from system_parameter
-        where is_deleted = '0'
-        and user_name = #{userName,jdbcType=VARCHAR}
-        and user_id = #{userId,jdbcType=VARCHAR}
-        <if test="id != null and id != ''">
-            and id &lt;&gt; #{id,jdbcType=VARCHAR}
-        </if>
-    </select>
 
     <!--    新增参数配置信息-->
     <insert id="insert" parameterType="api.common.pojo.po.system.ParameterPO">
         INSERT INTO system_parameter(
             id,
-            user_name,
             user_id,
             num_create_user,
             num_create_scene_package,
@@ -58,7 +41,6 @@
         )
         VALUES(
             #{id,jdbcType=VARCHAR},
-            #{userName,jdbcType=VARCHAR},
             #{userId,jdbcType=VARCHAR},
             #{numCreateUser,jdbcType=INTEGER},
             #{numCreateScenePackage,jdbcType=INTEGER},
@@ -71,21 +53,7 @@
         )
     </insert>
 
-    <!--    修改参数配置信息-->
-    <update id="update" parameterType="api.common.pojo.po.system.ParameterPO">
-        update system_parameter set
-            user_name = #{userName,jdbcType=VARCHAR},
-            user_id = #{userId,jdbcType=VARCHAR},
-            num_create_user = #{numCreateUser,jdbcType=INTEGER},
-            num_create_scene_package = #{numCreateScenePackage,jdbcType=INTEGER},
-            num_scene_per_package = #{numScenePerPackage,jdbcType=INTEGER},
-
-            modify_time = #{modifyTime,jdbcType=TIMESTAMP},
-            modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
-        where id = #{id,jdbcType=VARCHAR}
-    </update>
-
-
+    <!--    删除参数配置信息-->
     <update id="deleteById" parameterType="api.common.pojo.po.system.ParameterPO">
         update system_parameter set
           modify_time = #{modifyTime,jdbcType=TIMESTAMP},
@@ -94,21 +62,25 @@
         where id = #{id,jdbcType=VARCHAR}
     </update>
 
-
-    <!--查询普通账户-->
-    <select id="getUserInfo" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
-        select id, username from system_user
+    <!--查询参数修改历史记录-->
+    <select id="getParamHistory" parameterType="api.common.pojo.param.system.ParameterParam" resultType="api.common.pojo.vo.system.ParameterVO">
+        select
+        id,
+        IFNULL(num_create_user,0) as num_create_user,
+        IFNULL(num_create_scene_package,0) as num_create_scene_package,
+        IFNULL(num_scene_per_package,0) as num_scene_per_package,
+        modify_time
+        from system_parameter
         <where>
-            is_deleted = '0'
+            is_deleted = '1'
         </where>
-        <if test="username != null and username != ''">
-            and username like CONCAT('%',#{username,jdbcType=VARCHAR},'%')
+        <if test="userId != null and userId != ''">
+            and user_id = #{userId,jdbcType=VARCHAR}
         </if>
-        <if test="roleCode != null and roleCode != ''">
-            and role_code = #{roleCode,jdbcType=VARCHAR}
-        </if>
-        order by modify_time desc, create_time desc
+        order by modify_time desc
     </select>
 
 
+
+
 </mapper>