diff --git a/k8s/template-yaml/k8s-5auth.yaml b/k8s/template-yaml/k8s-5auth.yaml index 05a5f973..7eb52eaf 100644 --- a/k8s/template-yaml/k8s-5auth.yaml +++ b/k8s/template-yaml/k8s-5auth.yaml @@ -18,6 +18,11 @@ spec: image: ${k8s-5auth-image} ports: - containerPort: 9200 + env: + - name: TZ + value: Asia/Shanghai + - name: JAVA_TOOL_OPTIONS + value: "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005" --- apiVersion: v1 @@ -28,9 +33,15 @@ metadata: spec: type: NodePort ports: - - port: 9200 + - name: http + port: 9200 nodePort: 31206 protocol: TCP + - name: debug + nodePort: 31221 + port: 5005 + protocol: TCP + targetPort: 5005 selector: app: ci4s-auth diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java index 0c6be51e..f0bf9171 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/Constant.java @@ -19,8 +19,6 @@ public class Constant { public final static String Computing_Resource_CPU = "CPU"; // 计算资源_CPU public final static String Computing_Resource_GPU = "GPU"; // 计算资源_GPU - public final static int Git_Category_Id = 39; - public final static String Topic_Dataset = "dataset"; public final static String Topic_model = "model"; @@ -30,7 +28,7 @@ public class Constant { public final static String Source_Hand_Export = "hand_export"; public final static String Source_Add = "add"; - public final static String Building = "building"; + public final static String Building = "Building"; public final static String Running = "Running"; public final static String Failed = "Failed"; @@ -42,7 +40,10 @@ public class Constant { public final static String Error = "Error"; public final static String Unknown = "Unknown"; - public final static String Available = "available"; + public final static String Available = "Available"; + + public final static String Ready = "Ready"; + public final static String True = "True"; public final static String Type_Train = "train"; public final static String Type_Evaluate = "evaluate"; @@ -62,16 +63,20 @@ public class Constant { public final static String TaskType_ActiveLearn = "active_learn"; public final static String TaskType_Service = "service"; public final static String TaskType_ML = "machine_learn"; - public final static String TaskType_TextClassification = "text_classification"; public final static String ML_CSV = "auto_ml"; public final static String ML_TextClassification = "text_classification"; public final static String ML_VideoClassification = "video_classification"; + public final static String AL_PYTORCH = "pytorch"; + public final static String AL_SKLEARN = "sklearn"; + public final static String AL_KERAS = "keras"; + public final static String DelFlag = "2"; public final static String Code = "123123"; public final static String Sex_Men = "0"; + public final static String Admin = "admin"; } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java index 62df8b59..5b7cd85a 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java @@ -4,6 +4,8 @@ import java.util.Set; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; + +import com.ruoyi.system.api.constant.Constant; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; @@ -12,230 +14,225 @@ import com.ruoyi.common.core.web.domain.BaseEntity; /** * 角色表 sys_role - * + * * @author ruoyi */ -public class SysRole extends BaseEntity -{ +public class SysRole extends BaseEntity { private static final long serialVersionUID = 1L; - /** 角色ID */ + /** + * 角色ID + */ @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) private Long roleId; - /** 角色名称 */ + /** + * 角色名称 + */ @Excel(name = "角色名称") private String roleName; - /** 角色权限 */ + /** + * 角色权限 + */ @Excel(name = "角色权限") private String roleKey; - /** 角色排序 */ + /** + * 角色排序 + */ @Excel(name = "角色排序") private Integer roleSort; - /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ + /** + * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) + */ @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; - /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ + /** + * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) + */ private boolean menuCheckStrictly; - /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ + /** + * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) + */ private boolean deptCheckStrictly; - /** 角色状态(0正常 1停用) */ + /** + * 角色状态(0正常 1停用) + */ @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") private String status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private String delFlag; - /** 用户是否存在此角色标识 默认不存在 */ + /** + * 用户是否存在此角色标识 默认不存在 + */ private boolean flag = false; - /** 菜单组 */ + /** + * 菜单组 + */ private Long[] menuIds; - /** 部门组(数据权限) */ + /** + * 部门组(数据权限) + */ private Long[] deptIds; - /** 角色菜单权限 */ + /** + * 角色菜单权限 + */ private Set permissions; - public SysRole() - { + public SysRole() { } - public SysRole(Long roleId) - { + public SysRole(Long roleId) { this.roleId = roleId; } - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public boolean isAdmin() - { - return isAdmin(this.roleId); + public boolean isAdmin() { + return isAdmin(this.roleKey); } - public static boolean isAdmin(Long roleId) - { - return roleId != null && 1L == roleId; + public static boolean isAdmin(String roleKey) { + return Constant.Admin.equals(roleKey); } @NotBlank(message = "角色名称不能为空") @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") - public String getRoleName() - { + public String getRoleName() { return roleName; } - public void setRoleName(String roleName) - { + public void setRoleName(String roleName) { this.roleName = roleName; } @NotBlank(message = "权限字符不能为空") @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") - public String getRoleKey() - { + public String getRoleKey() { return roleKey; } - public void setRoleKey(String roleKey) - { + public void setRoleKey(String roleKey) { this.roleKey = roleKey; } @NotNull(message = "显示顺序不能为空") - public Integer getRoleSort() - { + public Integer getRoleSort() { return roleSort; } - public void setRoleSort(Integer roleSort) - { + public void setRoleSort(Integer roleSort) { this.roleSort = roleSort; } - public String getDataScope() - { + public String getDataScope() { return dataScope; } - public void setDataScope(String dataScope) - { + public void setDataScope(String dataScope) { this.dataScope = dataScope; } - public boolean isMenuCheckStrictly() - { + public boolean isMenuCheckStrictly() { return menuCheckStrictly; } - public void setMenuCheckStrictly(boolean menuCheckStrictly) - { + public void setMenuCheckStrictly(boolean menuCheckStrictly) { this.menuCheckStrictly = menuCheckStrictly; } - public boolean isDeptCheckStrictly() - { + public boolean isDeptCheckStrictly() { return deptCheckStrictly; } - public void setDeptCheckStrictly(boolean deptCheckStrictly) - { + public void setDeptCheckStrictly(boolean deptCheckStrictly) { this.deptCheckStrictly = deptCheckStrictly; } - public String getStatus() - { + public String getStatus() { return status; } - public void setStatus(String status) - { + public void setStatus(String status) { this.status = status; } - public String getDelFlag() - { + public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) - { + public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public boolean isFlag() - { + public boolean isFlag() { return flag; } - public void setFlag(boolean flag) - { + public void setFlag(boolean flag) { this.flag = flag; } - public Long[] getMenuIds() - { + public Long[] getMenuIds() { return menuIds; } - public void setMenuIds(Long[] menuIds) - { + public void setMenuIds(Long[] menuIds) { this.menuIds = menuIds; } - public Long[] getDeptIds() - { + public Long[] getDeptIds() { return deptIds; } - public void setDeptIds(Long[] deptIds) - { + public void setDeptIds(Long[] deptIds) { this.deptIds = deptIds; } - public Set getPermissions() - { + public Set getPermissions() { return permissions; } - public void setPermissions(Set permissions) - { + public void setPermissions(Set permissions) { this.permissions = permissions; } @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("roleName", getRoleName()) - .append("roleKey", getRoleKey()) - .append("roleSort", getRoleSort()) - .append("dataScope", getDataScope()) - .append("menuCheckStrictly", isMenuCheckStrictly()) - .append("deptCheckStrictly", isDeptCheckStrictly()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("menuCheckStrictly", isMenuCheckStrictly()) + .append("deptCheckStrictly", isDeptCheckStrictly()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java index 63faa450..a76466d7 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java @@ -155,13 +155,13 @@ public class SysUser extends BaseEntity { this.userId = userId; } - public boolean isAdmin() { - return isAdmin(this.userId); - } - - public static boolean isAdmin(Long userId) { - return userId != null && 1L == userId; - } +// public boolean isAdmin() { +// return isAdmin(this.userId); +// } +// +// public static boolean isAdmin(Long userId) { +// return userId != null && 1L == userId; +// } public Long getDeptId() { return deptId; diff --git a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java index d598ee3c..7ca0281a 100644 --- a/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java +++ b/ruoyi-common/ruoyi-common-datascope/src/main/java/com/ruoyi/common/datascope/aspect/DataScopeAspect.java @@ -70,12 +70,12 @@ public class DataScopeAspect { SysUser currentUser = loginUser.getSysUser(); // 如果是超级管理员,则不过滤数据 - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) - { +// if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) +// { String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission()); dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias(), permission); - } +// } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java index 09e5bee1..84141663 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java @@ -50,7 +50,7 @@ public class ActiveLearnController extends BaseController { @DeleteMapping("{id}") @ApiOperation("删除主动学习") - public GenericsAjaxResult deleteActiveLearn(@PathVariable("id") Long id) { + public GenericsAjaxResult deleteActiveLearn(@PathVariable("id") Long id) throws Exception { return genericsSuccess(this.activeLearnService.delete(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java index 282506b1..31854b72 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java @@ -35,6 +35,12 @@ public class ActiveLearnInsController extends BaseController { return genericsSuccess(this.activeLearnInsService.insert(activeLearnIns)); } + @PutMapping + @ApiOperation("编辑实验实例") + public GenericsAjaxResult update(@RequestBody ActiveLearnIns activeLearnIns) { + return genericsSuccess(this.activeLearnInsService.update(activeLearnIns)); + } + @DeleteMapping("{id}") @ApiOperation("删除实验实例") public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { @@ -59,10 +65,10 @@ public class ActiveLearnInsController extends BaseController { return genericsSuccess(this.activeLearnInsService.getDetailById(id)); } - @GetMapping("/getExpMetrics") + @PostMapping("/getExpMetrics") @ApiOperation("获取当前实验的指标对比地址") @ApiResponse - public GenericsAjaxResult getExpMetrics(@RequestParam(value = "experiment_ins_id") String experimentInsId) throws Exception { + public GenericsAjaxResult getExpMetrics(@RequestBody String experimentInsId) throws Exception { return genericsSuccess(activeLearnInsService.getExpMetrics(experimentInsId)); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlController.java deleted file mode 100644 index 64c419c6..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlController.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.ruoyi.platform.controller.autoML; - -import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.common.core.web.domain.GenericsAjaxResult; -import com.ruoyi.platform.domain.AutoMl; -import com.ruoyi.platform.service.AutoMlService; -import com.ruoyi.platform.vo.AutoMlVo; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import java.io.IOException; - -@RestController -@RequestMapping("autoML") -@Api("自动机器学习") -public class AutoMlController extends BaseController { - - @Resource - private AutoMlService autoMlService; - - @GetMapping - @ApiOperation("分页查询") - public GenericsAjaxResult> queryByPage(@RequestParam("page") int page, - @RequestParam("size") int size, - @RequestParam(value = "ml_name", required = false) String mlName) { - PageRequest pageRequest = PageRequest.of(page, size); - return genericsSuccess(this.autoMlService.queryByPage(mlName, pageRequest)); - } - - @PostMapping - @ApiOperation("新增自动机器学习") - public GenericsAjaxResult addAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { - return genericsSuccess(this.autoMlService.save(autoMlVo)); - } - - @PutMapping - @ApiOperation("编辑自动机器学习") - public GenericsAjaxResult editAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { - return genericsSuccess(this.autoMlService.edit(autoMlVo)); - } - - @GetMapping("/getAutoMlDetail") - @ApiOperation("获取自动机器学习详细信息") - public GenericsAjaxResult getAutoMlDetail(@RequestParam("id") Long id) throws IOException { - return genericsSuccess(this.autoMlService.getAutoMlDetail(id)); - } - - @DeleteMapping("{id}") - @ApiOperation("删除自动机器学习") - public GenericsAjaxResult deleteAutoMl(@PathVariable("id") Long id) { - return genericsSuccess(this.autoMlService.delete(id)); - } - - @CrossOrigin(origins = "*", allowedHeaders = "*") - @PostMapping("/upload") - @ApiOperation(value = "上传数据文件csv", notes = "上传数据文件csv,并将信息存入数据库。") - public AjaxResult upload(@RequestParam("file") MultipartFile file, @RequestParam("uuid") String uuid) throws Exception { - return AjaxResult.success(this.autoMlService.upload(file, uuid)); - } - - @PostMapping("/run/{id}") - @ApiOperation("运行自动机器学习实验") - public GenericsAjaxResult runAutoML(@PathVariable("id") Long id) throws Exception { - return genericsSuccess(this.autoMlService.runAutoMlIns(id)); - } -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlInsController.java deleted file mode 100644 index d57e7dd8..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/autoML/AutoMlInsController.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.ruoyi.platform.controller.autoML; - -import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.GenericsAjaxResult; -import com.ruoyi.platform.domain.AutoMlIns; -import com.ruoyi.platform.service.AutoMlInsService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.io.IOException; -import java.util.List; - -@RestController -@RequestMapping("autoMLIns") -@Api("自动机器学习实验实例") -public class AutoMlInsController extends BaseController { - - @Resource - private AutoMlInsService autoMLInsService; - - @GetMapping - @ApiOperation("分页查询") - public GenericsAjaxResult> queryByPage(AutoMlIns autoMlIns, int page, int size) throws IOException { - PageRequest pageRequest = PageRequest.of(page, size); - return genericsSuccess(this.autoMLInsService.queryByPage(autoMlIns, pageRequest)); - } - - @PostMapping - @ApiOperation("新增实验实例") - public GenericsAjaxResult add(@RequestBody AutoMlIns autoMlIns) { - return genericsSuccess(this.autoMLInsService.insert(autoMlIns)); - } - - @DeleteMapping("{id}") - @ApiOperation("删除实验实例") - public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { - return genericsSuccess(this.autoMLInsService.removeById(id)); - } - - @DeleteMapping("batchDelete") - @ApiOperation("批量删除实验实例") - public GenericsAjaxResult batchDelete(@RequestBody List ids) { - return genericsSuccess(this.autoMLInsService.batchDelete(ids)); - } - - @PutMapping("{id}") - @ApiOperation("终止实验实例") - public GenericsAjaxResult terminateAutoMlIns(@PathVariable("id") Long id) throws Exception { - return genericsSuccess(this.autoMLInsService.terminateAutoMlIns(id)); - } - - @GetMapping("{id}") - @ApiOperation("查看实验实例详情") - public GenericsAjaxResult getDetailById(@PathVariable("id") Long id) { - return genericsSuccess(this.autoMLInsService.getDetailById(id)); - } -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java index af405f84..5aa81559 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java @@ -30,12 +30,11 @@ public class CodeConfigController extends BaseController { @GetMapping public GenericsAjaxResult> queryByPage(@RequestParam("page") int page, @RequestParam("size") int size, - @RequestParam(value = "code_repo_name", required = false) String codeRepoName, - @RequestParam(value = "code_repo_vis", required = false)Integer codeRepoVis) { + @RequestParam(value = "code_repo_name", required = false) String codeRepoName + ) { PageRequest pageRequest = PageRequest.of(page, size); CodeConfig codeConfig = new CodeConfig(); codeConfig.setCodeRepoName(codeRepoName); - codeConfig.setCodeRepoVis(codeRepoVis); return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest)); } @@ -46,7 +45,7 @@ public class CodeConfigController extends BaseController { * @return 单条数据 */ @GetMapping("{id}") - public GenericsAjaxResult queryById(@PathVariable("id") Long id) { + public GenericsAjaxResult queryById(@PathVariable("id") Long id) throws Exception { return genericsSuccess(this.codeConfigService.queryById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java index a7fb7ec9..937bd7c9 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/component/ComponentController.java @@ -100,7 +100,7 @@ public class ComponentController { */ @DeleteMapping("{id}") @ApiOperation("根据id删除组件") - public AjaxResult deleteById(@PathVariable("id") Integer id) { + public AjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { return AjaxResult.success(this.componentService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetVersionController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetVersionController.java index f6e7c6e5..beda603a 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetVersionController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetVersionController.java @@ -118,7 +118,7 @@ public class DatasetVersionController extends BaseController { */ @DeleteMapping({"{id}"}) @ApiOperation("删除数据集版本") - public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) { + public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { return genericsSuccess(this.datasetVersionService.removeById(id)); } @@ -132,7 +132,7 @@ public class DatasetVersionController extends BaseController { @DeleteMapping("/deleteVersion") @ApiOperation(value = "逻辑删除模型版本", notes = "根据数据集ID和版本逻辑删除模型版本记录。") public GenericsAjaxResult> deleteDatasetVersion(@RequestParam("dataset_id") Integer datasetId, - @RequestParam("version") String version) { + @RequestParam("version") String version) throws Exception { return genericsSuccess(this.datasetVersionService.deleteDatasetVersion(datasetId, version)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java index 32ad25ce..e95aa2fe 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.IOException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -42,8 +43,8 @@ public class ExperimentInsController extends BaseController { @GetMapping @ApiOperation("分页查询") public GenericsAjaxResult> queryByPage(ExperimentIns experimentIns, int page, int size) throws IOException { - PageRequest pageRequest = PageRequest.of(page,size); - return genericsSuccess(this.experimentInsService.queryByPage(experimentIns, pageRequest)); + PageRequest pageRequest = PageRequest.of(page, size); + return genericsSuccess(this.experimentInsService.queryByPage(experimentIns, pageRequest)); } /** @@ -55,7 +56,7 @@ public class ExperimentInsController extends BaseController { @GetMapping("{id}") @ApiOperation("通过id查询实验实例") public GenericsAjaxResult queryById(@PathVariable("id") Integer id) throws IOException { - return genericsSuccess(this.experimentInsService.queryById(id)); + return genericsSuccess(this.experimentInsService.queryById(id)); } /** @@ -67,7 +68,7 @@ public class ExperimentInsController extends BaseController { @GetMapping("/queryByExperimentId/{Experiment_id}") @ApiOperation("通过实验id查询查询实验实例列表") public GenericsAjaxResult> queryByExperimentId(@PathVariable("Experiment_id") Integer experimentId) throws IOException { - return genericsSuccess(this.experimentInsService.getByExperimentId(experimentId)); + return genericsSuccess(this.experimentInsService.getByExperimentId(experimentId)); } /** @@ -79,7 +80,7 @@ public class ExperimentInsController extends BaseController { @PostMapping @ApiOperation("新增实验实例") public GenericsAjaxResult add(@RequestBody ExperimentIns experimentIns) { - return genericsSuccess(this.experimentInsService.insert(experimentIns)); + return genericsSuccess(this.experimentInsService.insert(experimentIns)); } /** @@ -91,7 +92,7 @@ public class ExperimentInsController extends BaseController { @PutMapping @ApiOperation("编辑实验实例") public GenericsAjaxResult edit(@RequestBody ExperimentIns experimentIns) throws IOException { - return genericsSuccess(this.experimentInsService.update(experimentIns)); + return genericsSuccess(this.experimentInsService.update(experimentIns)); } /** @@ -102,14 +103,14 @@ public class ExperimentInsController extends BaseController { */ @DeleteMapping("{id}") @ApiOperation("删除实验实例") - public GenericsAjaxResult deleteById( @PathVariable("id") Integer id) { - return genericsSuccess(this.experimentInsService.removeById(id)); + public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) { + return genericsSuccess(this.experimentInsService.removeById(id)); } @DeleteMapping("batchDelete") @ApiOperation("批量删除实验实例") - public GenericsAjaxResult batchDelete(@RequestBody List ids) throws Exception{ - return genericsSuccess(this.experimentInsService.batchDelete(ids)); + public GenericsAjaxResult batchDelete(@RequestBody List ids) throws Exception { + return genericsSuccess(this.experimentInsService.batchDelete(ids)); } /** @@ -133,8 +134,8 @@ public class ExperimentInsController extends BaseController { @GetMapping("/log") @ApiOperation("查询实例日志") public GenericsAjaxResult showExperimentInsLog(@RequestParam("id") Integer id, - @RequestParam("component_id") String componentId){ - return genericsSuccess(this.experimentInsService.showExperimentInsLog(id,componentId)); + @RequestParam("component_id") String componentId) { + return genericsSuccess(this.experimentInsService.showExperimentInsLog(id, componentId)); } /** @@ -146,14 +147,14 @@ public class ExperimentInsController extends BaseController { @GetMapping("/pods/log") @ApiOperation("获取pod实时日志请求") public GenericsAjaxResult> getRealtimePodLog(@RequestParam("pod_name") String podName, - @RequestParam("start_time") String startTime){ - return genericsSuccess(this.experimentInsService.getRealtimePodLog(podName,startTime)); + @RequestParam("start_time") String startTime) { + return genericsSuccess(this.experimentInsService.getRealtimePodLog(podName, startTime)); } @PostMapping("/pods/realTimeLog") @ApiOperation("获取pod实时日志请求") - public GenericsAjaxResult getRealtimePodLogFromPod(@RequestBody PodLogVo podLogVo){ + public GenericsAjaxResult getRealtimePodLogFromPod(@RequestBody PodLogVo podLogVo) { return genericsSuccess(this.experimentInsService.getRealtimePodLogFromPod(podLogVo)); } @@ -166,14 +167,11 @@ public class ExperimentInsController extends BaseController { @PostMapping("/realTimeLog") @ApiOperation("查询实验实例实时日志") - public GenericsAjaxResult> getRealtimeWorkflowLog(@RequestBody LogRequestVo logRequest){ + public GenericsAjaxResult> getRealtimeWorkflowLog(@RequestBody LogRequestVo logRequest) { return genericsSuccess(this.experimentInsService.getRealtimeWorkflowLog(logRequest)); } - - - /** * 查询实验节点结果 * @@ -184,8 +182,13 @@ public class ExperimentInsController extends BaseController { public GenericsAjaxResult getNodeResult(@RequestBody Map map) throws Exception { Integer id = Integer.parseInt((String) map.get("id")); String nodeId = (String) map.get("node_id"); - return genericsSuccess(this.experimentInsService.getNodeResult(id,nodeId)); + return genericsSuccess(this.experimentInsService.getNodeResult(id, nodeId)); } + @GetMapping("/time") + @ApiOperation("获取当前时间") + public GenericsAjaxResult getTime() { + return genericsSuccess(new Date()); + } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java index 0351dafc..c5b449a4 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/icon/AssetIconController.java @@ -114,7 +114,7 @@ public class AssetIconController extends BaseController { */ @DeleteMapping("{id}") @ApiOperation("删除图标") - public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) { + public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { return genericsSuccess(this.assetIconService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/knowledgeGraph/KnowledgeGraphController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/knowledgeGraph/KnowledgeGraphController.java new file mode 100644 index 00000000..24f83dfa --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/knowledgeGraph/KnowledgeGraphController.java @@ -0,0 +1,25 @@ +package com.ruoyi.platform.controller.knowledgeGraph; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("/knowledgeGraph") +@Api("knowledgeGraph service") +public class KnowledgeGraphController extends BaseController { + @Value("${knowledgeGraphUrl}") + private String url; + + @GetMapping(value = "/getURL") + @ApiOperation("得到访问地址") + public GenericsAjaxResult getURL() { + return genericsSuccess(url); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/labelStudio/labelStudioController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/labelStudio/labelStudioController.java index deda8542..290b6bc1 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/labelStudio/labelStudioController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/labelStudio/labelStudioController.java @@ -1,9 +1,7 @@ package com.ruoyi.platform.controller.labelStudio; import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.GenericsAjaxResult; -import com.ruoyi.platform.service.JupyterService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Value; @@ -11,12 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.annotation.Resource; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - @RestController @RequestMapping("/labelStudio") @Api("labelStudio service") @@ -25,7 +17,7 @@ public class labelStudioController extends BaseController { private String url; @GetMapping(value = "/getURL") @ApiOperation("得到访问地址") - public GenericsAjaxResult getURL() throws IOException { + public GenericsAjaxResult getURL() { return genericsSuccess(url); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java index c4e83c97..41c4b5ee 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/machineLearn/MachineLearnInsController.java @@ -34,6 +34,12 @@ public class MachineLearnInsController extends BaseController { return genericsSuccess(this.machineLearnInsService.insert(machineLearnIns)); } + @PutMapping + @ApiOperation("编辑实验实例") + public GenericsAjaxResult edit(@RequestBody MachineLearnIns machineLearnIns){ + return genericsSuccess(this.machineLearnInsService.update(machineLearnIns)); + } + @DeleteMapping("{id}") @ApiOperation("删除实验实例") public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelDependencyController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelDependencyController.java index a62e8c61..f49e7df7 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelDependencyController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelDependencyController.java @@ -101,7 +101,7 @@ public class ModelDependencyController extends BaseController { */ @DeleteMapping("{id}") @ApiOperation("删除模型依赖") - public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) { + public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { return genericsSuccess(this.modelDependencyService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsVersionController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsVersionController.java index 74a4ebf0..21104f05 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsVersionController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsVersionController.java @@ -130,7 +130,7 @@ public class ModelsVersionController extends BaseController { @DeleteMapping("/deleteVersion") @ApiOperation(value = "逻辑删除模型版本", notes = "根据模型ID和版本逻辑删除模型版本记录。") public GenericsAjaxResult> deleteModelsVersion(@RequestParam("models_id") Integer modelsId, - @RequestParam("version") String version) throws IOException { + @RequestParam("version") String version) throws Exception { return genericsSuccess(this.modelsVersionService.deleteModelsVersion(modelsId, version)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java index 78f8221b..4bb8f03b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/NewModelFromGitController.java @@ -1,6 +1,8 @@ package com.ruoyi.platform.controller.model; +import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; import com.ruoyi.platform.service.ModelsService; import com.ruoyi.platform.vo.ModelsVo; import com.ruoyi.platform.vo.QueryModelMetricsVo; @@ -19,15 +21,15 @@ import java.util.Map; @RestController @RequestMapping("newmodel") @Api(value = "新模型管理") -public class NewModelFromGitController { +public class NewModelFromGitController extends BaseController { @Resource private ModelsService modelsService; @PostMapping("/addModel") @ApiOperation("添加模型") - public AjaxResult addModelAndVersion(@RequestBody ModelsVo modelsVo) throws Exception { - return AjaxResult.success(this.modelsService.newCreateModel(modelsVo)); + public GenericsAjaxResult addModelAndVersion(@RequestBody ModelsVo modelsVo) { + return genericsSuccess(this.modelsService.newCreateModel(modelsVo)); } @PostMapping("/addVersion") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java index 4c8852f4..42f4077b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java @@ -50,7 +50,7 @@ public class RayController extends BaseController { @DeleteMapping("{id}") @ApiOperation("删除自动超参数寻优") - public GenericsAjaxResult deleteRay(@PathVariable("id") Long id) { + public GenericsAjaxResult deleteRay(@PathVariable("id") Long id) throws Exception { return genericsSuccess(this.rayService.delete(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayInsController.java index c13354a3..a22bea37 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayInsController.java @@ -35,6 +35,12 @@ public class RayInsController extends BaseController { return genericsSuccess(this.rayInsService.insert(rayIns)); } + @PutMapping + @ApiOperation("编辑实验实例") + public GenericsAjaxResult update(@RequestBody RayIns rayIns) { + return genericsSuccess(this.rayInsService.update(rayIns)); + } + @DeleteMapping("{id}") @ApiOperation("删除实验实例") public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/resources/ComputingResourceController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/resources/ComputingResourceController.java index d7fd42ca..7753924e 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/resources/ComputingResourceController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/resources/ComputingResourceController.java @@ -94,7 +94,7 @@ public class ComputingResourceController extends BaseController { */ @DeleteMapping("{id}") @ApiOperation("删除计算资源") - public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) { + public GenericsAjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { return genericsSuccess(this.computingResourceService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java index 8725334c..5c7c3831 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowParamController.java @@ -84,7 +84,7 @@ public class WorkflowParamController extends BaseController { */ @DeleteMapping @ApiOperation("删除流水线参数") - public GenericsAjaxResult deleteById(Integer id) { + public GenericsAjaxResult deleteById(Integer id) throws Exception { return genericsSuccess(this.workflowParamService.removeById(id)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMl.java deleted file mode 100644 index a0f130cc..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMl.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.ruoyi.platform.domain; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import com.ruoyi.platform.vo.VersionVo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.Date; -import java.util.Map; - -@Data -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -@ApiModel(description = "自动机器学习") -public class AutoMl { - private Long id; - - @ApiModelProperty(value = "实验名称") - private String mlName; - - @ApiModelProperty(value = "实验描述") - private String mlDescription; - - @ApiModelProperty(value = "任务类型:classification或regression") - private String taskType; - - @ApiModelProperty(value = "搜索合适模型的时间限制(以秒为单位)。通过增加这个值,auto-sklearn有更高的机会找到更好的模型。默认3600,非必传。") - private Integer timeLeftForThisTask; - - @ApiModelProperty(value = "单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合。将这个值设置得足够高,这样典型的机器学习算法就可以适用于训练数据。默认600,非必传。") - private Integer perRunTimeLimit; - - @ApiModelProperty(value = "集成模型数量,如果设置为0,则没有集成。默认50,非必传。") - private Integer ensembleSize; - - @ApiModelProperty(value = "设置为None将禁用集成构建,设置为SingleBest仅使用单个最佳模型而不是集成,设置为default,它将对单目标问题使用EnsembleSelection,对多目标问题使用MultiObjectiveDummyEnsemble。默认default,非必传。") - private String ensembleClass; - - @ApiModelProperty(value = "在构建集成时只考虑ensemble_nbest模型。这是受到了“最大限度地利用集成选择”中引入的库修剪概念的启发。这是独立于ensemble_class参数的,并且这个修剪步骤是在构造集成之前完成的。默认50,非必传。") - private Integer ensembleNbest; - - @ApiModelProperty(value = "定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除。由于这个变量的性质,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数。如果设置为None,则所有模型都保留在磁盘上。默认50,非必传。") - private Integer maxModelsOnDisc; - - @ApiModelProperty(value = "随机种子,将决定输出文件名。默认1,非必传。") - private Integer seed; - - @ApiModelProperty(value = "机器学习算法的内存限制(MB)。如果auto-sklearn试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072,非必传。") - private Integer memoryLimit; - - @ApiModelProperty(value = "如果为None,则使用所有可能的分类算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost\n" + - "bernoulli_nb\n" + - "decision_tree\n" + - "extra_trees\n" + - "gaussian_nb\n" + - "gradient_boosting\n" + - "k_nearest_neighbors\n" + - "lda\n" + - "liblinear_svc\n" + - "libsvm_svc\n" + - "mlp\n" + - "multinomial_nb\n" + - "passive_aggressive\n" + - "qda\n" + - "random_forest\n" + - "sgd") - private String includeClassifier; - - @ApiModelProperty(value = "如果为None,则使用所有可能的特征预处理算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:densifier\n" + - "extra_trees_preproc_for_classification\n" + - "extra_trees_preproc_for_regression\n" + - "fast_ica\n" + - "feature_agglomeration\n" + - "kernel_pca\n" + - "kitchen_sinks\n" + - "liblinear_svc_preprocessor\n" + - "no_preprocessing\n" + - "nystroem_sampler\n" + - "pca\n" + - "polynomial\n" + - "random_trees_embedding\n" + - "select_percentile_classification\n" + - "select_percentile_regression\n" + - "select_rates_classification\n" + - "select_rates_regression\n" + - "truncatedSVD") - private String includeFeaturePreprocessor; - - @ApiModelProperty(value = "如果为None,则使用所有可能的回归算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost,\n" + - "ard_regression,\n" + - "decision_tree,\n" + - "extra_trees,\n" + - "gaussian_process,\n" + - "gradient_boosting,\n" + - "k_nearest_neighbors,\n" + - "liblinear_svr,\n" + - "libsvm_svr,\n" + - "mlp,\n" + - "random_forest,\n" + - "sgd") - private String includeRegressor; - - private String excludeClassifier; - - private String excludeRegressor; - - private String excludeFeaturePreprocessor; - - @ApiModelProperty(value = "测试集的比率,0到1之间") - private Float testSize; - - @ApiModelProperty(value = "如何处理过拟合,如果使用基于“cv”的方法或Splitter对象,可能需要使用resampling_strategy_arguments。holdout或crossValid") - private String resamplingStrategy; - - @ApiModelProperty(value = "重采样划分训练集和验证集,训练集的比率,0到1之间") - private Float trainSize; - - @ApiModelProperty(value = "拆分数据前是否进行shuffle") - private Boolean shuffle; - - @ApiModelProperty(value = "交叉验证的折数,当resamplingStrategy为crossValid时,此项必填,为整数") - private Integer folds; - - @ApiModelProperty(value = "文件夹存放配置输出和日志文件,默认/tmp/automl") - private String tmpFolder; - - @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") - private String targetColumns; - - @ApiModelProperty(value = "自定义指标名称") - private String metricName; - - @ApiModelProperty(value = "模型优化目标指标及权重,json格式。分类的指标包含:accuracy\n" + - "balanced_accuracy\n" + - "roc_auc\n" + - "average_precision\n" + - "log_loss\n" + - "precision_macro\n" + - "precision_micro\n" + - "precision_samples\n" + - "precision_weighted\n" + - "recall_macro\n" + - "recall_micro\n" + - "recall_samples\n" + - "recall_weighted\n" + - "f1_macro\n" + - "f1_micro\n" + - "f1_samples\n" + - "f1_weighted\n" + - "回归的指标包含:mean_absolute_error\n" + - "mean_squared_error\n" + - "root_mean_squared_error\n" + - "mean_squared_log_error\n" + - "median_absolute_error\n" + - "r2") - private String metrics; - - @ApiModelProperty(value = "指标优化方向,是越大越好还是越小越好") - private Boolean greaterIsBetter; - - @ApiModelProperty(value = "模型计算并打印指标") - private String scoringFunctions; - - private Integer state; - - private String runState; - - private Double progress; - - private String createBy; - - private Date createTime; - - private String updateBy; - - private Date updateTime; - - private String dataset; - - @ApiModelProperty(value = "状态列表") - private String statusList; -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMlIns.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMlIns.java deleted file mode 100644 index 98df8125..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/AutoMlIns.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.ruoyi.platform.domain; - -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.Date; - -@Data -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -@ApiModel(description = "自动机器学习实验实例") -public class AutoMlIns { - private Long id; - - private Long autoMlId; - - private String resultPath; - - private String modelPath; - - private String imgPath; - - private String runHistoryPath; - - private Integer state; - - private String status; - - private String nodeStatus; - - private String nodeResult; - - private String param; - - private String source; - - @ApiModelProperty(value = "Argo实例名称") - private String argoInsName; - - @ApiModelProperty(value = "Argo命名空间") - private String argoInsNs; - - private Date createTime; - - private Date updateTime; - - private Date finishTime; -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/CodeConfig.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/CodeConfig.java index e5a0c680..9d00b8e6 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/CodeConfig.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/CodeConfig.java @@ -21,6 +21,9 @@ public class CodeConfig implements Serializable { @ApiModelProperty(name = "code_repo_vis", value = "代码仓库可见性(1-公开,0-私有)") private Integer codeRepoVis; + @ApiModelProperty(name = "is_public", value = "1-公开,0-私有)") + private Boolean isPublic; + @ApiModelProperty(name = "git_url", value = "Git地址") private String gitUrl; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearnIns.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearnIns.java index 120cf68d..c53d2d7b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearnIns.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/MachineLearnIns.java @@ -7,6 +7,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; +import java.util.List; +import java.util.Map; @Data @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) @@ -48,4 +50,6 @@ public class MachineLearnIns { private Date updateTime; private Date finishTime; + + private Map fileMap; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlDao.java deleted file mode 100644 index 188c14c8..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ruoyi.platform.mapper; - -import com.ruoyi.platform.domain.AutoMl; -import org.apache.ibatis.annotations.Param; -import org.springframework.data.domain.Pageable; - -import java.util.List; - -public interface AutoMlDao { - long count(@Param("mlName") String mlName); - - List queryByPage(@Param("mlName") String mlName, @Param("pageable") Pageable pageable); - - AutoMl getAutoMlById(@Param("id") Long id); - - AutoMl getAutoMlByName(@Param("mlName") String mlName); - - int save(@Param("autoMl") AutoMl autoMl); - - int edit(@Param("autoMl") AutoMl autoMl); - - List queryByDatasetId(@Param("datasetId") String datasetId); -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlInsDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlInsDao.java deleted file mode 100644 index 7fcc3ca9..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/AutoMlInsDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.ruoyi.platform.mapper; - -import com.ruoyi.platform.domain.AutoMlIns; -import org.apache.ibatis.annotations.Param; -import org.springframework.data.domain.Pageable; - -import java.util.List; - -public interface AutoMlInsDao { - long count(@Param("autoMlIns") AutoMlIns autoMlIns); - - List queryAllByLimit(@Param("autoMlIns") AutoMlIns autoMlIns, @Param("pageable") Pageable pageable); - - List getByAutoMlId(@Param("autoMlId") Long AutoMlId); - - int insert(@Param("autoMlIns") AutoMlIns autoMlIns); - - int update(@Param("autoMlIns") AutoMlIns autoMlIns); - - AutoMlIns queryById(@Param("id") Long id); - - List queryByAutoMlInsIsNotTerminated(); -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ActiveLearnInsStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ActiveLearnInsStatusTask.java index c08d6512..206d262a 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ActiveLearnInsStatusTask.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ActiveLearnInsStatusTask.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -31,9 +32,9 @@ public class ActiveLearnInsStatusTask { @Resource private ResourceOccupyService resourceOccupyService; - private List activeLearnIds = new ArrayList<>(); + private HashSet activeLearnIds = new HashSet<>(); - @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 public void executeActiveLearnInsStatus() { List activeLearnInsList = activeLearnInsService.queryActiveLearnInsIsNotTerminated(); @@ -52,7 +53,8 @@ public class ActiveLearnInsStatusTask { // 扣除积分 if (Constant.Running.equals(activeLearnIns.getStatus())) { resourceOccupyService.deducing(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); - } else if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Terminated.equals(activeLearnIns.getStatus()) + } + else if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Terminated.equals(activeLearnIns.getStatus()) || Constant.Succeeded.equals(activeLearnIns.getStatus())) { resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); } @@ -76,14 +78,16 @@ public class ActiveLearnInsStatusTask { } } - @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 public void executeActiveLearnStatus() { - if (activeLearnIds.size() == 0) { + if (activeLearnIds.isEmpty()) { return; } // 存储需要更新的实验对象列表 List updateActiveLearns = new ArrayList<>(); - for (Long activeLearnId : activeLearnIds) { + Iterator iterator1 = activeLearnIds.iterator(); + while (iterator1.hasNext()) { + Long activeLearnId = iterator1.next(); // 获取当前实验的所有实例列表 List insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); List statusList = new ArrayList<>(); @@ -93,10 +97,14 @@ public class ActiveLearnInsStatusTask { } String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); - if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { - activeLearn.setStatusList(subStatus); - updateActiveLearns.add(activeLearn); - activeLearnDao.edit(activeLearn); + if (activeLearn == null) { + iterator1.remove(); + } else { + if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { + activeLearn.setStatusList(subStatus); + updateActiveLearns.add(activeLearn); + activeLearnDao.edit(activeLearn); + } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/AutoMlInsStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/AutoMlInsStatusTask.java deleted file mode 100644 index c59d67fc..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/AutoMlInsStatusTask.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.ruoyi.platform.scheduling; - -import com.ruoyi.system.api.constant.Constant; -import com.ruoyi.platform.domain.AutoMl; -import com.ruoyi.platform.domain.AutoMlIns; -import com.ruoyi.platform.mapper.AutoMlDao; -import com.ruoyi.platform.mapper.AutoMlInsDao; -import com.ruoyi.platform.service.AutoMlInsService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -@Component() -public class AutoMlInsStatusTask { - - @Resource - private AutoMlInsService autoMlInsService; - - @Resource - private AutoMlInsDao autoMlInsDao; - - @Resource - private AutoMlDao autoMlDao; - - private List autoMlIds = new ArrayList<>(); - - @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 - public void executeAutoMlInsStatus() { - // 首先查到所有非终止态的实验实例 - List autoMlInsList = autoMlInsService.queryByAutoMlInsIsNotTerminated(); - - // 去argo查询状态 - List updateList = new ArrayList<>(); - if (autoMlInsList != null && autoMlInsList.size() > 0) { - for (AutoMlIns autoMlIns : autoMlInsList) { - //当原本状态为null或非终止态时才调用argo接口 - try { - autoMlIns = autoMlInsService.queryStatusFromArgo(autoMlIns); - } catch (Exception e) { - autoMlIns.setStatus(Constant.Failed); - } - // 线程安全的添加操作 - synchronized (autoMlIds) { - autoMlIds.add(autoMlIns.getAutoMlId()); - } - updateList.add(autoMlIns); - } - if (updateList.size() > 0) { - for (AutoMlIns autoMlIns : updateList) { - autoMlInsDao.update(autoMlIns); - } - } - } - } - - @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 - public void executeAutoMlStatus() { - if (autoMlIds.size() == 0) { - return; - } - // 存储需要更新的实验对象列表 - List updateAutoMls = new ArrayList<>(); - for (Long autoMlId : autoMlIds) { - // 获取当前实验的所有实例列表 - List insList = autoMlInsDao.getByAutoMlId(autoMlId); - List statusList = new ArrayList<>(); - // 更新实验状态列表 - for (int i = 0; i < insList.size(); i++) { - statusList.add(insList.get(i).getStatus()); - } - String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); - AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); - if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { - autoMl.setStatusList(subStatus); - updateAutoMls.add(autoMl); - autoMlDao.edit(autoMl); - } - } - - if (!updateAutoMls.isEmpty()) { - // 使用Iterator进行安全的删除操作 - Iterator iterator = autoMlIds.iterator(); - while (iterator.hasNext()) { - Long autoMlId = iterator.next(); - for (AutoMl autoMl : updateAutoMls) { - if (autoMl.getId().equals(autoMlId)) { - iterator.remove(); - } - } - } - } - } -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java index f1cf303a..bd93ee96 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java @@ -34,9 +34,9 @@ public class ExperimentInstanceStatusTask { @Resource private ResourceOccupyService resourceOccupyService; - private List experimentIds = new ArrayList<>(); + private HashSet experimentIds = new HashSet<>(); - @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 public void executeExperimentInsStatus() throws Exception { // 首先查到所有非终止态的实验实例 List experimentInsList = experimentInsService.queryByExperimentIsNotTerminated(); @@ -141,14 +141,17 @@ public class ExperimentInstanceStatusTask { } } - @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 public void executeExperimentStatus() throws IOException { - if (experimentIds.size() == 0) { + if (experimentIds.isEmpty()) { return; } // 存储需要更新的实验对象列表 List updateExperiments = new ArrayList<>(); - for (Integer experimentId : experimentIds) { + Iterator iterator1 = experimentIds.iterator(); + + while (iterator1.hasNext()) { + Integer experimentId = iterator1.next(); // 获取当前实验的所有实例列表 List insList = experimentInsService.getByExperimentId(experimentId); List statusList = new ArrayList<>(); @@ -158,10 +161,14 @@ public class ExperimentInstanceStatusTask { } String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); Experiment experiment = experimentDao.queryById(experimentId); - // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 - if (!StringUtils.equals(subStatus, experiment.getStatusList())) { - experiment.setStatusList(subStatus); - updateExperiments.add(experiment); + if (experiment == null) { + iterator1.remove(); + } else { + // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 + if (!StringUtils.equals(subStatus, experiment.getStatusList())) { + experiment.setStatusList(subStatus); + updateExperiments.add(experiment); + } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java index 905f6d2a..e10916c8 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/MLStatusTask.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -29,9 +30,9 @@ public class MLStatusTask { @Resource private ResourceOccupyService resourceOccupyService; - private List machineLearnIds = new ArrayList<>(); + private HashSet machineLearnIds = new HashSet<>(); - @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 public void executeMachineLearnInsStatus() { // 首先查到所有非终止态的实验实例 List insList = machineLearnInsService.queryNotTerminated(); @@ -53,7 +54,8 @@ public class MLStatusTask { // 扣除积分 if (Constant.Running.equals(ins.getStatus())) { resourceOccupyService.deducing(Constant.TaskType_ML, null, ins.getId(), null, null); - } else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus()) + } + else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus()) || Constant.Succeeded.equals(ins.getStatus())) { resourceOccupyService.endDeduce(Constant.TaskType_ML, null, ins.getId(), null, null); } @@ -80,14 +82,17 @@ public class MLStatusTask { } } - @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 public void executeMachineLearn() { - if (machineLearnIds.size() == 0) { + if (machineLearnIds.isEmpty()) { return; } // 存储需要更新的实验对象列表 List updateMLs = new ArrayList<>(); - for (Long machineLearnId : machineLearnIds) { + Iterator iterator1 = machineLearnIds.iterator(); + + while (iterator1.hasNext()) { + Long machineLearnId = iterator1.next(); // 获取当前实验的所有实例列表 List insList = machineLearnInsDao.getByMachineLearnId(machineLearnId); List statusList = new ArrayList<>(); @@ -97,10 +102,14 @@ public class MLStatusTask { } String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId); - if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { - machineLearn.setStatusList(subStatus); - updateMLs.add(machineLearn); - machineLearnDao.edit(machineLearn); + if (machineLearn == null) { + iterator1.remove(); + } else { + if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { + machineLearn.setStatusList(subStatus); + updateMLs.add(machineLearn); + machineLearnDao.edit(machineLearn); + } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/RayInsStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/RayInsStatusTask.java index f5b0b759..9c8abf42 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/RayInsStatusTask.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/RayInsStatusTask.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -31,9 +32,9 @@ public class RayInsStatusTask { @Resource private ResourceOccupyService resourceOccupyService; - private List rayIds = new ArrayList<>(); + private HashSet rayIds = new HashSet<>(); - @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 public void executeRayInsStatus() { List rayInsList = rayInsService.queryByRayInsIsNotTerminated(); @@ -52,12 +53,14 @@ public class RayInsStatusTask { // 扣除积分 if (Constant.Running.equals(rayIns.getStatus())) { resourceOccupyService.deducing(Constant.TaskType_Ray, null, rayIns.getId(), null, null); - } else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) + } + else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) || Constant.Succeeded.equals(rayIns.getStatus())) { resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); } } } catch (Exception e) { + System.out.println(e.getMessage()); rayIns.setStatus(Constant.Failed); // 结束扣除积分 resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); @@ -76,14 +79,17 @@ public class RayInsStatusTask { } } - @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 + @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 public void executeRayStatus() { - if (rayIds.size() == 0) { + if (rayIds.isEmpty()) { return; } // 存储需要更新的实验对象列表 List updateRays = new ArrayList<>(); - for (Long rayId : rayIds) { + Iterator iterator1 = rayIds.iterator(); + + while (iterator1.hasNext()) { + Long rayId = iterator1.next(); // 获取当前实验的所有实例列表 List insList = rayInsDao.getByRayId(rayId); List statusList = new ArrayList<>(); @@ -93,10 +99,14 @@ public class RayInsStatusTask { } String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); Ray ray = rayDao.getRayById(rayId); - if (!StringUtils.equals(ray.getStatusList(), subStatus)) { - ray.setStatusList(subStatus); - updateRays.add(ray); - rayDao.edit(ray); + if (ray == null) { + iterator1.remove(); + } else { + if (!StringUtils.equals(ray.getStatusList(), subStatus)) { + ray.setStatusList(subStatus); + updateRays.add(ray); + rayDao.edit(ray); + } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java index fa92becd..130fa462 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java @@ -13,6 +13,8 @@ public interface ActiveLearnInsService { ActiveLearnIns insert(ActiveLearnIns activeLearnIns); + ActiveLearnIns update(ActiveLearnIns activeLearnIns); + String deleteById(Long id); String batchDelete(List ids); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java index ccf8bea6..01791cb2 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java @@ -16,7 +16,7 @@ public interface ActiveLearnService { ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; - String delete(Long id); + String delete(Long id) throws Exception; String runActiveLearnIns (Long id) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AssetIconService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AssetIconService.java index 7aa8a4ac..4fc1dbec 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AssetIconService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AssetIconService.java @@ -64,7 +64,7 @@ public interface AssetIconService { */ boolean deleteById(Integer id); - String removeById(Integer id); + String removeById(Integer id) throws Exception; List queryByName(String name); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlInsService.java deleted file mode 100644 index 9776fa14..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlInsService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.ruoyi.platform.service; - -import com.ruoyi.platform.domain.AutoMlIns; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; - -import java.io.IOException; -import java.util.List; - -public interface AutoMlInsService { - - Page queryByPage(AutoMlIns autoMlIns, PageRequest pageRequest) throws IOException; - - AutoMlIns insert(AutoMlIns autoMlIns); - - String removeById(Long id); - - String batchDelete(List ids); - - List queryByAutoMlInsIsNotTerminated(); - - AutoMlIns queryStatusFromArgo(AutoMlIns autoMlIns); - - boolean terminateAutoMlIns(Long id) throws Exception; - - AutoMlIns getDetailById(Long id); - - void updateAutoMlStatus(Long autoMlId); -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlService.java deleted file mode 100644 index a2bad796..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/AutoMlService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ruoyi.platform.service; - -import com.ruoyi.platform.domain.AutoMl; -import com.ruoyi.platform.vo.AutoMlVo; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.Map; - -public interface AutoMlService { - Page queryByPage(String mlName, PageRequest pageRequest); - - AutoMl save(AutoMlVo autoMlVo) throws Exception; - - String edit(AutoMlVo autoMlVo) throws Exception; - - String delete(Long id); - - AutoMlVo getAutoMlDetail(Long id) throws IOException; - - Map upload(MultipartFile file, String uuid) throws Exception; - - String runAutoMlIns(Long id) throws Exception; -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/CodeConfigService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/CodeConfigService.java index 0a4d752c..6ff4f69f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/CodeConfigService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/CodeConfigService.java @@ -8,7 +8,7 @@ public interface CodeConfigService { Page queryByPage(CodeConfig codeConfig, PageRequest pageRequest); - CodeConfig queryById(Long id); + CodeConfig queryById(Long id) throws Exception; CodeConfig insert(CodeConfig codeConfig); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComponentService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComponentService.java index 1f29c543..255c3475 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComponentService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComponentService.java @@ -57,7 +57,7 @@ public interface ComponentService { */ boolean deleteById(Integer id); - String removeById(Integer id); + String removeById(Integer id) throws Exception; List queryAllGroupedByCategory() throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComputingResourceService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComputingResourceService.java index 781b304f..51f3bb0c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComputingResourceService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ComputingResourceService.java @@ -54,6 +54,6 @@ public interface ComputingResourceService { */ boolean deleteById(Integer id); - String removeById(Integer id); + String removeById(Integer id) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetVersionService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetVersionService.java index 31ec8ba2..a3db0779 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetVersionService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetVersionService.java @@ -58,7 +58,7 @@ public interface DatasetVersionService { */ boolean deleteById(Integer id); - String removeById(Integer id); + String removeById(Integer id) throws Exception; List queryByDatasetId(Integer datasetId); @@ -66,7 +66,7 @@ public interface DatasetVersionService { Map queryByDatasetIdAndVersion(Integer datasetId, String version); - Map deleteDatasetVersion(Integer datasetId, String version); + Map deleteDatasetVersion(Integer datasetId, String version) throws Exception; void checkDeclaredVersion(DatasetVersion insert) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java index bf788d3a..1fe39e39 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/GitService.java @@ -38,4 +38,8 @@ public interface GitService { void resetPhoneNum(SysUser sysUser) throws Exception; void deleteUser(SysUser sysUser) throws Exception; + + List> PersonalQueryGitByPage(String token, String login, String name, Integer page) throws Exception; + + List> PubilcQueryGitByPage(String token, String name, Integer page, Integer projectCategoryId) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnInsService.java index 66becd1f..16e3632c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/MachineLearnInsService.java @@ -12,6 +12,8 @@ public interface MachineLearnInsService { MachineLearnIns insert(MachineLearnIns machineLearnIns); + MachineLearnIns update(MachineLearnIns machineLearnIns); + String removeById(Long id); String batchDelete(List ids); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelDependencyService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelDependencyService.java index 049d87d1..c90bae79 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelDependencyService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelDependencyService.java @@ -57,7 +57,7 @@ public interface ModelDependencyService { */ boolean deleteById(Integer id); - String removeById(Integer id); + String removeById(Integer id) throws Exception; List queryByModelDependency(ModelDependency modelDependency) throws IOException; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java index 6bd90437..d8b47626 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsService.java @@ -89,7 +89,7 @@ public interface ModelsService { List> exportModels(String path, String uuid) throws Exception; - String newCreateModel(ModelsVo modelsVo) throws Exception; + String newCreateModel(ModelsVo modelsVo); String newCreateVersion(ModelsVo modelsVo) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsVersionService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsVersionService.java index 723bc745..f3626349 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsVersionService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ModelsVersionService.java @@ -69,7 +69,7 @@ public interface ModelsVersionService { Map queryByModelsIdAndVersion(Integer modelsId, String version); - Map deleteModelsVersion(Integer modelsId, String version) throws IOException; + Map deleteModelsVersion(Integer modelsId, String version) throws Exception; String addModelVersions(List modelsVersions) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayInsService.java index 4224599d..ba6d0e35 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayInsService.java @@ -10,6 +10,8 @@ public interface RayInsService { RayIns insert(RayIns rayIns); + RayIns update(RayIns rayIns); + String deleteById(Long id); String batchDelete(List ids); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java index b3659240..8f37140f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java @@ -16,7 +16,7 @@ public interface RayService { RayVo getRayDetail(Long id) throws IOException; - String delete(Long id); + String delete(Long id) throws Exception; String runRayIns(Long id) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java index 5606239e..18bad720 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ResourceOccupyService.java @@ -21,7 +21,7 @@ public interface ResourceOccupyService { Map queryCredit(); - void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas); + void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas, String taskName); void deleteTaskState(String taskType, Long taskId, Long taskInsId); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java index e20a7411..cf28c997 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowParamService.java @@ -45,7 +45,7 @@ public interface WorkflowParamService { */ WorkflowParam update(WorkflowParam workflowParam); - String removeById(Integer id); + String removeById(Integer id) throws Exception; /** * 通过主键删除数据 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java index 97743273..780fda8c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java @@ -62,6 +62,18 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { return activeLearnIns; } + @Override + public ActiveLearnIns update(ActiveLearnIns activeLearnIns) { + activeLearnIns.setUpdateTime(new Date()); + activeLearnIns = queryStatusFromArgo(activeLearnIns); + activeLearnInsDao.update(activeLearnIns); + updateActiveLearnStatus(activeLearnIns.getActiveLearnId()); + if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Succeeded.equals(activeLearnIns.getStatus())) { + resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); + } + return activeLearnIns; + } + @Override @Transactional public String deleteById(Long id) { @@ -154,6 +166,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { // 如果值不等于 Succeeded,则赋值为 Failed if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { innerMap.put("phase", Constant.Failed); + innerMap.put("finishedAt", new Date()); } } } @@ -290,9 +303,24 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { return aimUrl + "/metrics?select=" + decode; } - public void getTrialList(ActiveLearnIns ins) { + public void getTrialList(ActiveLearnIns ins) throws IOException { String directoryPath = ins.getResultPath(); - ins.setResultPath(endpoint + "/" + directoryPath + "/final_checkpoint/final_model_weights.pth"); + Map paramMap = JsonUtils.jsonToMap(ins.getParam()); + Map dataMap = (Map) paramMap.get("data"); + switch ((String) dataMap.get("framework_type")) { + case Constant.AL_PYTORCH: { + ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model_weights.pth"); + break; + } + case Constant.AL_SKLEARN: { + ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model.joblib"); + break; + } + case Constant.AL_KERAS: { + ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model.h5"); + break; + } + } try { String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java index bf3d607d..a1744e8b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java @@ -57,7 +57,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { @Override public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception { - if (activeLearnVo.getName().length() >= 64) { + if (activeLearnVo.getName().length() > 64) { throw new RuntimeException("实验名称大于最大长度"); } ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); @@ -117,15 +117,20 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { @Override @Transactional - public String delete(Long id) { + public String delete(Long id) throws Exception { ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); if (activeLearn == null) { - throw new RuntimeException("实验不存在"); + throw new Exception("实验不存在"); } String username = SecurityUtils.getLoginUser().getUsername(); String createBy = activeLearn.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { - throw new RuntimeException("无权限删除该实验"); + throw new Exception("无权限删除该实验"); + } + + List insList = activeLearnInsDao.getByActiveLearnId(id); + if (!insList.isEmpty()) { + throw new Exception("该实验存在实例,无法删除"); } activeLearn.setState(Constant.State_invalid); resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); @@ -157,6 +162,10 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { throw new RuntimeException("转换流水线失败"); } Map converMap = JsonUtils.jsonToMap(convertRes); + if (converMap.get("data") == null) { + throw new RuntimeException("转换流水线失败"); + } + // 组装运行接口json Map output = (Map) converMap.get("output"); Map runReqMap = new HashMap<>(); @@ -195,7 +204,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { // 记录开始扣除积分 resourceOccupyService.startDeduce(activeLearn.getComputingResourceId(), 1, Constant.TaskType_ActiveLearn, id, activeLearnIns.getId(), null, activeLearn.getName(), null, null); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } } return "执行成功"; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AssetIconServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AssetIconServiceImpl.java index 09610ce8..ed4be518 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AssetIconServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AssetIconServiceImpl.java @@ -101,10 +101,10 @@ public class AssetIconServiceImpl implements AssetIconService { } @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { AssetIcon assetIcon = this.assetIconDao.queryById(id); if (assetIcon == null){ - return "图标不存在"; + throw new Exception("图标不存在"); } //判断权限,只有admin和创建者本身可以删除 @@ -114,7 +114,7 @@ public class AssetIconServiceImpl implements AssetIconService { String createdBy = assetIcon.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该图标"; + throw new Exception("无权限删除该图标"); } assetIcon.setState(0); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java deleted file mode 100644 index 1294d426..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlInsServiceImpl.java +++ /dev/null @@ -1,257 +0,0 @@ -package com.ruoyi.platform.service.impl; - -import com.ruoyi.system.api.constant.Constant; -import com.ruoyi.platform.domain.AutoMl; -import com.ruoyi.platform.domain.AutoMlIns; -import com.ruoyi.platform.mapper.AutoMlDao; -import com.ruoyi.platform.mapper.AutoMlInsDao; -import com.ruoyi.platform.service.AutoMlInsService; -import com.ruoyi.platform.utils.DateUtils; -import com.ruoyi.platform.utils.HttpUtils; -import com.ruoyi.platform.utils.JsonUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.io.IOException; -import java.util.*; - -@Service -public class AutoMlInsServiceImpl implements AutoMlInsService { - @Value("${argo.url}") - private String argoUrl; - @Value("${argo.workflowStatus}") - private String argoWorkflowStatus; - @Value("${argo.workflowTermination}") - private String argoWorkflowTermination; - - @Resource - private AutoMlInsDao autoMlInsDao; - @Resource - private AutoMlDao autoMlDao; - - @Override - public Page queryByPage(AutoMlIns autoMlIns, PageRequest pageRequest) throws IOException { - long total = this.autoMlInsDao.count(autoMlIns); - List autoMlInsList = this.autoMlInsDao.queryAllByLimit(autoMlIns, pageRequest); - return new PageImpl<>(autoMlInsList, pageRequest, total); - } - - @Override - public AutoMlIns insert(AutoMlIns autoMlIns) { - this.autoMlInsDao.insert(autoMlIns); - return autoMlIns; - } - - @Override - public String removeById(Long id) { - AutoMlIns autoMlIns = autoMlInsDao.queryById(id); - if (autoMlIns == null) { - return "实验实例不存在"; - } - - if (StringUtils.isEmpty(autoMlIns.getStatus())) { - autoMlIns = queryStatusFromArgo(autoMlIns); - } - if (StringUtils.equals(autoMlIns.getStatus(), Constant.Running)) { - return "实验实例正在运行,不可删除"; - } - - autoMlIns.setState(Constant.State_invalid); - int update = autoMlInsDao.update(autoMlIns); - if (update > 0) { - updateAutoMlStatus(autoMlIns.getAutoMlId()); - return "删除成功"; - } else { - return "删除失败"; - } - } - - @Override - @Transactional - public String batchDelete(List ids) { - for (Long id : ids) { - String result = removeById(id); - if (!"删除成功".equals(result)) { - return result; - } - } - return "删除成功"; - } - - @Override - public List queryByAutoMlInsIsNotTerminated() { - return autoMlInsDao.queryByAutoMlInsIsNotTerminated(); - } - - @Override - public AutoMlIns queryStatusFromArgo(AutoMlIns ins) { - String namespace = ins.getArgoInsNs(); - String name = ins.getArgoInsName(); - - // 创建请求数据map - Map requestData = new HashMap<>(); - requestData.put("namespace", namespace); - requestData.put("name", name); - - // 创建发送数据map,将请求数据作为"data"键的值 - Map res = new HashMap<>(); - res.put("data", requestData); - - try { - // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON - String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); - // 检查响应是否为空或无内容 - if (req == null || StringUtils.isEmpty(req)) { - throw new RuntimeException("工作流状态响应为空"); - } - // 将响应的JSON字符串转换为Map对象 - Map runResMap = JsonUtils.jsonToMap(req); - // 从响应Map中获取"data"部分 - Map data = (Map) runResMap.get("data"); - if (data == null || data.isEmpty()) { - throw new RuntimeException("工作流数据为空"); - } - // 从"data"中获取"status"部分,并返回"phase"的值 - Map status = (Map) data.get("status"); - if (status == null || status.isEmpty()) { - throw new RuntimeException("工作流状态为空"); - } - - //解析流水线结束时间 - String finishedAtString = (String) status.get("finishedAt"); - if (finishedAtString != null && !finishedAtString.isEmpty()) { - Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); - ins.setFinishTime(finishTime); - } - - // 解析nodes字段,提取节点状态并转换为JSON字符串 - Map nodes = (Map) status.get("nodes"); - Map modifiedNodes = new LinkedHashMap<>(); - if (nodes != null) { - for (Map.Entry nodeEntry : nodes.entrySet()) { - Map nodeDetails = (Map) nodeEntry.getValue(); - String templateName = (String) nodeDetails.get("displayName"); - modifiedNodes.put(templateName, nodeDetails); - } - } - - String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes); - ins.setNodeStatus(nodeStatusJson); - - //终止态为终止不改 - if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { - ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); - } - if (StringUtils.equals(ins.getStatus(), Constant.Error)) { - ins.setStatus(Constant.Failed); - } - return ins; - } catch (Exception e) { - throw new RuntimeException("查询状态失败: " + e.getMessage(), e); - } - } - - @Override - public boolean terminateAutoMlIns(Long id) throws Exception { - AutoMlIns autoMlIns = autoMlInsDao.queryById(id); - if (autoMlIns == null) { - throw new IllegalStateException("实验实例未查询到,id: " + id); - } - - String currentStatus = autoMlIns.getStatus(); - String name = autoMlIns.getArgoInsName(); - String namespace = autoMlIns.getArgoInsNs(); - - // 获取当前状态,如果为空,则从Argo查询 - if (StringUtils.isEmpty(currentStatus)) { - currentStatus = queryStatusFromArgo(autoMlIns).getStatus(); - } - // 只有状态是"Running"时才能终止实例 - if (!currentStatus.equalsIgnoreCase(Constant.Running)) { - throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 - } - - // 创建请求数据map - Map requestData = new HashMap<>(); - requestData.put("namespace", namespace); - requestData.put("name", name); - // 创建发送数据map,将请求数据作为"data"键的值 - Map res = new HashMap<>(); - res.put("data", requestData); - - try { - // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON - String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); - // 检查响应是否为空或无内容 - if (StringUtils.isEmpty(req)) { - throw new RuntimeException("终止响应内容为空"); - - } - // 将响应的JSON字符串转换为Map对象 - Map runResMap = JsonUtils.jsonToMap(req); - // 从响应Map中直接获取"errCode"的值 - Integer errCode = (Integer) runResMap.get("errCode"); - if (errCode != null && errCode == 0) { - //更新autoMlIns,确保状态更新被保存到数据库 - AutoMlIns ins = queryStatusFromArgo(autoMlIns); - String nodeStatus = ins.getNodeStatus(); - Map nodeMap = JsonUtils.jsonToMap(nodeStatus); - - // 遍历 map - for (Map.Entry entry : nodeMap.entrySet()) { - // 获取每个 Map 中的值并强制转换为 Map - Map innerMap = (Map) entry.getValue(); - // 检查 phase 的值 - if (innerMap.containsKey("phase")) { - String phaseValue = (String) innerMap.get("phase"); - // 如果值不等于 Succeeded,则赋值为 Failed - if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { - innerMap.put("phase", Constant.Failed); - } - } - } - ins.setNodeStatus(JsonUtils.mapToJson(nodeMap)); - ins.setStatus(Constant.Terminated); - ins.setUpdateTime(new Date()); - ins.setFinishTime(new Date()); - this.autoMlInsDao.update(ins); - updateAutoMlStatus(autoMlIns.getAutoMlId()); - return true; - } else { - return false; - } - } catch (Exception e) { - throw new RuntimeException("终止实例错误: " + e.getMessage(), e); - } - } - - @Override - public AutoMlIns getDetailById(Long id) { - AutoMlIns autoMlIns = this.autoMlInsDao.queryById(id); - if(Constant.Running.equals(autoMlIns.getStatus()) || Constant.Pending.equals(autoMlIns.getStatus())){ - autoMlIns = queryStatusFromArgo(autoMlIns); - } - return autoMlIns; - } - - public void updateAutoMlStatus(Long autoMlId) { - List insList = autoMlInsDao.getByAutoMlId(autoMlId); - List statusList = new ArrayList<>(); - // 更新实验状态列表 - for (int i = 0; i < insList.size(); i++) { - statusList.add(insList.get(i).getStatus()); - } - String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); - AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); - if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { - autoMl.setStatusList(subStatus); - autoMlDao.edit(autoMl); - } - } -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java deleted file mode 100644 index 99354424..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.ruoyi.platform.service.impl; - -import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.api.constant.Constant; -import com.ruoyi.platform.domain.AutoMl; -import com.ruoyi.platform.domain.AutoMlIns; -import com.ruoyi.platform.mapper.AutoMlDao; -import com.ruoyi.platform.mapper.AutoMlInsDao; -import com.ruoyi.platform.service.AutoMlInsService; -import com.ruoyi.platform.service.AutoMlService; -import com.ruoyi.platform.utils.FileUtil; -import com.ruoyi.platform.utils.HttpUtils; -import com.ruoyi.platform.utils.JacksonUtil; -import com.ruoyi.platform.utils.JsonUtils; -import com.ruoyi.platform.vo.AutoMlParamVo; -import com.ruoyi.platform.vo.AutoMlVo; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Service("autoMLService") -public class AutoMlServiceImpl implements AutoMlService { - @Value("${git.localPath}") - String localPath; - - @Value("${argo.url}") - private String argoUrl; - @Value("${argo.convertAutoML}") - String convertAutoML; - @Value("${argo.workflowRun}") - private String argoWorkflowRun; - - @Value("${minio.endpointIp}") - private String minioEndpoint; - - @Resource - private AutoMlDao autoMlDao; - - @Resource - private AutoMlInsDao autoMlInsDao; - - @Resource - private AutoMlInsService autoMlInsService; - - @Override - public Page queryByPage(String mlName, PageRequest pageRequest) { - long total = autoMlDao.count(mlName); - List autoMls = autoMlDao.queryByPage(mlName, pageRequest); - return new PageImpl<>(autoMls, pageRequest, total); - } - - @Override - public AutoMl save(AutoMlVo autoMlVo) throws Exception { - if (autoMlVo.getMlName().length() >= 64) { - throw new RuntimeException("实验名称大于最大长度"); - } - AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); - if (autoMlByName != null) { - throw new RuntimeException("实验名称已存在"); - } - AutoMl autoMl = new AutoMl(); - BeanUtils.copyProperties(autoMlVo, autoMl); - String username = SecurityUtils.getLoginUser().getUsername(); - autoMl.setCreateBy(username); - autoMl.setUpdateBy(username); - String datasetJson = JacksonUtil.toJSONString(autoMlVo.getDataset()); - autoMl.setDataset(datasetJson); - autoMlDao.save(autoMl); - return autoMl; - } - - @Override - public String edit(AutoMlVo autoMlVo) throws Exception { - AutoMl oldAutoMl = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); - if (oldAutoMl != null && !oldAutoMl.getId().equals(autoMlVo.getId())) { - throw new RuntimeException("实验名称已存在"); - } - AutoMl autoMl = new AutoMl(); - BeanUtils.copyProperties(autoMlVo, autoMl); - String username = SecurityUtils.getLoginUser().getUsername(); - autoMl.setUpdateBy(username); - String datasetJson = JacksonUtil.toJSONString(autoMlVo.getDataset()); - autoMl.setDataset(datasetJson); - - autoMlDao.edit(autoMl); - return "修改成功"; - } - - @Override - public String delete(Long id) { - AutoMl autoMl = autoMlDao.getAutoMlById(id); - if (autoMl == null) { - throw new RuntimeException("实验不存在"); - } - - String username = SecurityUtils.getLoginUser().getUsername(); - String createBy = autoMl.getCreateBy(); - if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { - throw new RuntimeException("无权限删除该实验"); - } - - autoMl.setState(Constant.State_invalid); - return autoMlDao.edit(autoMl) > 0 ? "删除成功" : "删除失败"; - } - - @Override - public AutoMlVo getAutoMlDetail(Long id) throws IOException { - AutoMl autoMl = autoMlDao.getAutoMlById(id); - AutoMlVo autoMlVo = new AutoMlVo(); - BeanUtils.copyProperties(autoMl, autoMlVo); - if (StringUtils.isNotEmpty(autoMl.getDataset())) { - autoMlVo.setDataset(JsonUtils.jsonToMap(autoMl.getDataset())); - } - return autoMlVo; - } - - @Override - public Map upload(MultipartFile file, String uuid) throws Exception { - Map result = new HashMap<>(); - - String username = SecurityUtils.getLoginUser().getUsername(); - String fileName = file.getOriginalFilename(); - String path = localPath + "temp/" + username + "/automl_data/" + uuid; - long sizeInBytes = file.getSize(); - String formattedSize = FileUtil.formatFileSize(sizeInBytes); - File targetFile = new File(path, file.getOriginalFilename()); - // 确保目录存在 - targetFile.getParentFile().mkdirs(); - // 保存文件到目标路径 - FileUtils.copyInputStreamToFile(file.getInputStream(), targetFile); - // 返回上传文件的路径 - result.put("fileName", fileName); - result.put("url", path); // objectName根据实际情况定义 - result.put("fileSize", formattedSize); - return result; - } - - @Override - public String runAutoMlIns(Long id) throws Exception { - AutoMl autoMl = autoMlDao.getAutoMlById(id); - if (autoMl == null) { - throw new Exception("自动机器学习配置不存在"); - } - - AutoMlParamVo autoMlParam = new AutoMlParamVo(); - BeanUtils.copyProperties(autoMl, autoMlParam); - autoMlParam.setDataset(JsonUtils.jsonToMap(autoMl.getDataset())); - String param = JsonUtils.objectToJson(autoMlParam); - // 调argo转换接口 - try { - String convertRes = HttpUtils.sendPost(argoUrl + convertAutoML, param); - if (convertRes == null || StringUtils.isEmpty(convertRes)) { - throw new RuntimeException("转换流水线失败"); - } - Map converMap = JsonUtils.jsonToMap(convertRes); - // 组装运行接口json - Map output = (Map) converMap.get("output"); - Map runReqMap = new HashMap<>(); - runReqMap.put("data", converMap.get("data")); - // 调argo运行接口 - String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); - - if (runRes == null || StringUtils.isEmpty(runRes)) { - throw new RuntimeException("运行流水线失败"); - } - Map runResMap = JsonUtils.jsonToMap(runRes); - Map data = (Map) runResMap.get("data"); - //判断data为空 - if (data == null || MapUtils.isEmpty(data)) { - throw new RuntimeException("运行流水线失败"); - } - Map metadata = (Map) data.get("metadata"); - // 插入记录到实验实例表 - AutoMlIns autoMlIns = new AutoMlIns(); - autoMlIns.setAutoMlId(autoMl.getId()); - autoMlIns.setArgoInsNs((String) metadata.get("namespace")); - autoMlIns.setArgoInsName((String) metadata.get("name")); - autoMlIns.setParam(param); - autoMlIns.setStatus(Constant.Pending); - //替换argoInsName - String outputString = JsonUtils.mapToJson(output); - autoMlIns.setNodeResult(outputString.replace("{{workflow.name}}", (String) metadata.get("name"))); - - Map param_output = (Map) output.get("param_output"); - List output1 = (ArrayList) param_output.values().toArray()[0]; - Map output2 = (Map) output1.get(0); - String outputPath = minioEndpoint + "/" + output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/"; - autoMlIns.setModelPath(outputPath + "save_model.joblib"); - if (Constant.AutoMl_Classification.equals(autoMl.getTaskType())) { - autoMlIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "Train_Confusion_Matrix.png" + "," + outputPath + "Test_Confusion_Matrix.png"); - } else { - autoMlIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "regression.png"); - } - autoMlIns.setResultPath(outputPath + "result.txt"); - String seed = autoMl.getSeed() != null ? String.valueOf(autoMl.getSeed()) : "1"; - autoMlIns.setRunHistoryPath(outputPath + "smac3-output/run_" + seed + "/runhistory.json"); - autoMlInsDao.insert(autoMlIns); - autoMlInsService.updateAutoMlStatus(id); - } catch (Exception e) { - throw new RuntimeException(e); - } - return "执行成功"; - } -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java index 872b34b9..be026b3f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java @@ -10,6 +10,7 @@ import com.ruoyi.platform.domain.CodeConfig; import com.ruoyi.platform.service.CodeConfigService; import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; @@ -45,14 +46,19 @@ public class CodeConfigServiceImpl implements CodeConfigService { } @Override - public CodeConfig queryById(Long id) { - return this.codeConfigDao.queryById(id); + public CodeConfig queryById(Long id) throws Exception { + CodeConfig codeConfig = this.codeConfigDao.queryById(id); + if (codeConfig == null) { + throw new Exception("未查询到代码配置"); + } else { + return this.codeConfigDao.queryById(id); + } } @Override public CodeConfig insert(CodeConfig codeConfig) { Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); - if(id != null){ + if (id != null) { throw new IllegalStateException("代码仓库名称已存在"); } LoginUser loginUser = SecurityUtils.getLoginUser(); @@ -67,14 +73,14 @@ public class CodeConfigServiceImpl implements CodeConfigService { @Override public CodeConfig update(CodeConfig codeConfig) { Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); - if(id != null && !id.equals(codeConfig.getId())){ + if (id != null && !id.equals(codeConfig.getId())) { throw new IllegalStateException("代码仓库名称已存在"); } LoginUser loginUser = SecurityUtils.getLoginUser(); codeConfig.setUpdateBy(loginUser.getUsername()); - if (codeConfig.getCodeRepoVis().equals(Constant.Code_Repo_Pub)) { + if (codeConfig.getIsPublic()) { codeConfig.setVerifyMode(null); codeConfig.setGitUserName(null); codeConfig.setGitPassword(null); @@ -98,7 +104,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { } HashMap map = new HashMap<>(); - map.put("code_path", codeConfig.getGitUrl()); + map.put("id", String.valueOf(codeConfig.getId())); List rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); if (rayList != null && !rayList.isEmpty()) { String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); @@ -121,7 +127,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { String username = loginUser.getUsername(); String createBy = codeConfig.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { - return "无权限删除该代码配置"; + throw new Exception("无权限删除该代码配置"); } codeConfig.setState(Constant.State_invalid); return this.codeConfigDao.update(codeConfig) > 0 ? "删除成功" : "删除失败"; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java index a93628e3..d58694eb 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java @@ -47,7 +47,7 @@ public class ComponentServiceImpl implements ComponentService { @Override public Component queryById(Integer id) { Component component = this.componentDao.queryById(id); - if (component == null){ + if (component == null) { throw new RuntimeException("组件不存在"); } @@ -58,14 +58,14 @@ public class ComponentServiceImpl implements ComponentService { public List queryAllGroupedByCategory() throws Exception { List componentList = this.componentDao.queryAll(); List result = new ArrayList<>(); - if (componentList.isEmpty()){ + if (componentList.isEmpty()) { return result; } List categoryTypeList = DictUtils.getDictCache("category_type"); - Map> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); - for (Map.Entry > entry : groupedComponent.entrySet()) { + Map> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); + for (Map.Entry> entry : groupedComponent.entrySet()) { List categorys = categoryTypeList.stream().filter(sysDictData -> StringUtils.equals(sysDictData.getDictValue(), String.valueOf(entry.getKey()))).collect(Collectors.toList()); - if (categorys.size() ==0){ + if (categorys.size() == 0) { throw new Exception("组件类型不存在"); } Map map = new HashMap(); @@ -80,8 +80,8 @@ public class ComponentServiceImpl implements ComponentService { /** * 分页查询 * - * @param component 筛选条件 - * @param pageRequest 分页对象 + * @param component 筛选条件 + * @param pageRequest 分页对象 * @return 查询结果 */ @Override @@ -104,7 +104,7 @@ public class ComponentServiceImpl implements ComponentService { component.setControlStrategy(controlStrategy); //json转换,存数据库 - String inParameters= gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); + String inParameters = gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); component.setEnvVirables(envVariable); @@ -118,9 +118,9 @@ public class ComponentServiceImpl implements ComponentService { component.setState(1); // 检查相同category_id下的component_name是否已存在 - Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId()); + Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(), component.getCategoryId()); - if(existingCount != null && existingCount > 0) { + if (existingCount != null && existingCount > 0) { throw new RuntimeException("该类别下已有同名组件"); } @@ -139,15 +139,15 @@ public class ComponentServiceImpl implements ComponentService { Component component = this.queryById(componentVo.getId()); //只能更新当前存在的组件 - if (component == null){ + if (component == null) { throw new RuntimeException("组件不存在,无法更新"); } //将object转成string类型 - component = ConvertUtil.entityToVo(componentVo,Component.class); + component = ConvertUtil.entityToVo(componentVo, Component.class); Gson gson = new Gson(); - String inParameters= gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); + String inParameters = gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); @@ -174,24 +174,24 @@ public class ComponentServiceImpl implements ComponentService { } @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { Component component = this.componentDao.queryById(id); //先进行判断 组件是否存在 - if (component == null ){ - return "组件不存在"; + if (component == null) { + throw new Exception("组件不存在"); } //判断权限,只有admin和创建者本身可以删除该组件 LoginUser loginUser = SecurityUtils.getLoginUser(); String username = loginUser.getUsername(); String createdBy = component.getCreateBy(); - if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该组件"; + if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { + throw new Exception("无权限删除该组件"); } component.setState(0); - return this.componentDao.update(component)>0?"删除成功":"删除失败"; + return this.componentDao.update(component) > 0 ? "删除成功" : "删除失败"; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComputingResourceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComputingResourceServiceImpl.java index bf96b842..995460b9 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComputingResourceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComputingResourceServiceImpl.java @@ -92,10 +92,10 @@ public class ComputingResourceServiceImpl implements ComputingResourceService { } @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { ComputingResource computingResource = this.computingResourceDao.queryById(id); if (computingResource == null){ - return "计算资源不存在"; + throw new Exception("计算资源不存在"); } //判断权限,只有admin和创建者本身可以删除该数据集 @@ -103,7 +103,7 @@ public class ComputingResourceServiceImpl implements ComputingResourceService { String username = loginUser.getUsername(); String createdBy = computingResource.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该计算资源"; + throw new Exception("无权限删除该计算资源"); } computingResource.setState(0); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java index d4e99abc..d0a4a01a 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetVersionServiceImpl.java @@ -128,17 +128,17 @@ public class DatasetVersionServiceImpl implements DatasetVersionService { @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); if (datasetVersion == null){ - return "数据集版本信息不存在"; + throw new Exception("数据集版本信息不存在"); } //判断权限,只有admin和创建者本身可以删除该数据集版本信息 LoginUser loginUser = SecurityUtils.getLoginUser(); String username = loginUser.getUsername(); String createdBy = datasetVersion.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该数据集版本"; + throw new Exception("无权限删除该数据集版本"); } datasetVersion.setState(0); @@ -175,7 +175,7 @@ public class DatasetVersionServiceImpl implements DatasetVersionService { } @Override - public Map deleteDatasetVersion(Integer datasetId, String version) { + public Map deleteDatasetVersion(Integer datasetId, String version) throws Exception { Map results = new HashMap(); // 根据模型ID和版本查询所有模型版本 List versions = this.datasetVersionDao.queryAllByDatasetVersion(datasetId, version); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java index 82825cbe..4ecef87b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java @@ -109,8 +109,12 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { devEnvironment.setStandard(devEnvironmentVo.getStandard()); devEnvironment.setEnvVariable(devEnvironmentVo.getEnvVariable()); devEnvironment.setImage(JacksonUtil.toJSONString(devEnvironmentVo.getImage())); - devEnvironment.setDataset(JacksonUtil.toJSONString(devEnvironmentVo.getDataset())); - devEnvironment.setModel(JacksonUtil.toJSONString(devEnvironmentVo.getModel())); + if (devEnvironmentVo.getDataset() != null) { + devEnvironment.setDataset(JacksonUtil.toJSONString(devEnvironmentVo.getDataset())); + } + if (devEnvironmentVo.getModel() != null) { + devEnvironment.setModel(JacksonUtil.toJSONString(devEnvironmentVo.getModel())); + } devEnvironment.setCreateBy(loginUser.getUsername()); devEnvironment.setUpdateBy(loginUser.getUsername()); devEnvironment.setUpdateTime(new Date()); @@ -154,7 +158,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { public String removeById(Integer id) throws Exception { DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); if (devEnvironment == null) { - return "开发环境信息不存在"; + throw new RuntimeException("开发环境信息不存在"); } //判断权限,只有admin和创建者本身可以删除该数据集 @@ -162,7 +166,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { String username = loginUser.getUsername(); String createdBy = devEnvironment.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { - return "无权限删除该开发环境"; + throw new RuntimeException("无权限删除该开发环境"); } jupyterService.stopJupyterService(id); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java index b58e449b..27ee47fe 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java @@ -18,6 +18,8 @@ import com.ruoyi.platform.vo.PodLogVo; import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -27,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.*; /** @@ -37,6 +41,8 @@ import java.util.*; */ @Service("experimentInsService") public class ExperimentInsServiceImpl implements ExperimentInsService { + private static final Logger logger = LoggerFactory.getLogger(ExperimentInsServiceImpl.class); + @Resource private ExperimentInsDao experimentInsDao; @Resource @@ -200,8 +206,25 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { LoginUser loginUser = SecurityUtils.getLoginUser(); experimentIns.setUpdateBy(loginUser.getUsername()); experimentIns.setUpdateTime(new Date()); + experimentIns = queryStatusFromArgo(experimentIns); this.experimentInsDao.update(experimentIns); - return this.queryById(experimentIns.getId()); + updateExperimentStatus(experimentIns.getExperimentId()); + if (Constant.Failed.equals(experimentIns.getStatus()) || Constant.Succeeded.equals(experimentIns.getStatus())) { + if (StringUtils.isNotEmpty(experimentIns.getNodesStatus())) { + Map nodesStatusMap = JsonUtils.jsonToMap(experimentIns.getNodesStatus()); + for (String key : nodesStatusMap.keySet()) { + Map value = (Map) nodesStatusMap.get(key); + String startedAt = (String) value.get("startedAt"); + Instant instant = Instant.parse(startedAt); + Date startTime = Date.from(instant); + String finishedAt = (String) value.get("finishedAt"); + if (StringUtils.isNotEmpty(finishedAt)) { + resourceOccupyService.endDeduce(Constant.TaskType_Workflow, null, Long.valueOf(experimentIns.getId()), key, startTime); + } + } + } + } + return experimentIns; } @Override @@ -209,7 +232,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { public String removeById(Integer id) { ExperimentIns experimentIns = experimentInsDao.queryById(id); if (experimentIns == null) { - return "实验实例不存在"; + throw new RuntimeException("实验实例不存在"); } //判断权限,只有admin和创建者本身可以删除该实验实例 @@ -217,16 +240,16 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { String username = loginUser.getUsername(); String createdBy = experimentIns.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { - return "无权限删除该流水线"; + throw new RuntimeException("无权限删除该实验实例"); } if (StringUtils.isEmpty(experimentIns.getStatus())) { experimentIns = queryStatusFromArgo(experimentIns); } - if (StringUtils.equals(experimentIns.getStatus(), "Running")) { - return "实验实例正在运行,不可删除"; + if (StringUtils.equals(experimentIns.getStatus(), Constant.Running)) { + throw new RuntimeException("实验实例正在运行,不可删除"); } - experimentIns.setState(0); + experimentIns.setState(Constant.State_invalid); int update = this.experimentInsDao.update(experimentIns); if (update > 0) { resourceOccupyService.deleteTaskState(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getExperimentId()), Long.valueOf(id)); @@ -267,12 +290,10 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { @Override public ExperimentIns queryStatusFromArgo(ExperimentIns ins) { - String namespace = ins.getArgoInsNs(); String name = ins.getArgoInsName(); Integer id = ins.getId(); // 创建请求数据map - ExperimentIns experimentIns = this.experimentInsDao.queryById(id); Map requestData = new HashMap<>(); requestData.put("namespace", namespace); requestData.put("name", name); @@ -305,7 +326,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { String finishedAtString = (String) status.get("finishedAt"); if (finishedAtString != null && !finishedAtString.isEmpty()) { Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); - experimentIns.setFinishTime(finishTime); + ins.setFinishTime(finishTime); } // 解析nodes字段,提取节点状态并转换为JSON字符串 @@ -320,18 +341,16 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { } String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes); - experimentIns.setNodesStatus(nodeStatusJson); + ins.setNodesStatus(nodeStatusJson); //终止态为终止不改 - if (!StringUtils.equals(experimentIns.getStatus(), "Terminated")) { - experimentIns.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : "Pending"); + if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { + ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); } - if (StringUtils.equals(experimentIns.getStatus(), Constant.Error)) { - experimentIns.setStatus("Failed"); + if (StringUtils.equals(ins.getStatus(), Constant.Error)) { + ins.setStatus(Constant.Failed); } - - return experimentIns; - + return ins; } catch (Exception e) { throw new RuntimeException("查询状态失败: " + e.getMessage(), e); @@ -362,7 +381,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { } // 只有状态是"Running"时才能终止实例 - if (!currentStatus.equalsIgnoreCase("Running")) { + if (!currentStatus.equalsIgnoreCase(Constant.Running)) { throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 } @@ -404,6 +423,9 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { // 如果值不等于 Succeeded,则赋值为 Failed if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { innerMap.put("phase", Constant.Failed); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -8); + innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); } } } @@ -430,40 +452,51 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { } - void deleteExportVersion(ExperimentIns experimentIns) throws Exception { - LoginUser loginUser = SecurityUtils.getLoginUser(); - String ci4sUsername = loginUser.getUsername(); - - String nodesResult = experimentIns.getNodesResult(); - - if (StringUtils.isNotEmpty(nodesResult)) { - Map nodesResultMap = JsonUtils.jsonToMap(nodesResult); - Map paramOutput = (Map) nodesResultMap.get("param_output"); - - for (String key : paramOutput.keySet()) { - //删除导出模型版本 - if (key.contains("model-export")) { - HashMap queryMap = new HashMap(); - queryMap.put("insId", experimentIns.getId()); - ModelDependency1 modelDependency1 = modelDependency1Dao.queryByInsId(JSON.toJSONString(queryMap)); - if (modelDependency1 != null) { - if (StringUtils.isNotEmpty(modelDependency1.getVersion())) { - String relativePath = ci4sUsername + "/model/" + modelDependency1.getRepoId() + "/" + modelDependency1.getIdentifier() + "/" + modelDependency1.getVersion() + "/model"; - modelsService.deleteVersion(modelDependency1.getRepoId(), modelDependency1.getIdentifier(), modelDependency1.getOwner(), modelDependency1.getVersion(), relativePath); - } else { - modelDependency1Dao.deleteModelById(modelDependency1.getId()); + void deleteExportVersion(ExperimentIns experimentIns) { + try { + LoginUser loginUser = SecurityUtils.getLoginUser(); + String ci4sUsername = loginUser.getUsername(); + + String nodesResult = experimentIns.getNodesResult(); + + if (StringUtils.isNotEmpty(nodesResult)) { + Map nodesResultMap = JsonUtils.jsonToMap(nodesResult); + Map paramOutput = (Map) nodesResultMap.get("param_output"); + Map nodesStatusMap = JsonUtils.jsonToMap(experimentIns.getNodesStatus()); + + for (String key : paramOutput.keySet()) { + //删除导出模型版本 + if (key.contains("model-export")) { + Map modelExportMap = (Map) nodesStatusMap.get(key); + if (modelExportMap != null && (Constant.Running.equals(modelExportMap.get("phase")) || Constant.Succeeded.equals(modelExportMap.get("phase")))) { + HashMap queryMap = new HashMap(); + queryMap.put("insId", experimentIns.getId()); + ModelDependency1 modelDependency1 = modelDependency1Dao.queryByInsId(JSON.toJSONString(queryMap)); + if (modelDependency1 != null) { + if (StringUtils.isNotEmpty(modelDependency1.getVersion())) { + String relativePath = ci4sUsername + "/model/" + modelDependency1.getRepoId() + "/" + modelDependency1.getIdentifier() + "/" + modelDependency1.getVersion() + "/model"; + modelsService.deleteVersion(modelDependency1.getRepoId(), modelDependency1.getIdentifier(), modelDependency1.getOwner(), modelDependency1.getVersion(), relativePath); + } else { + modelDependency1Dao.deleteModelById(modelDependency1.getId()); + } + } + } + } + //删除导出数据集版本 + if (key.contains("dataset-export")) { + Map datasetExportMap = (Map) nodesStatusMap.get(key); + if (datasetExportMap != null && (Constant.Running.equals(datasetExportMap.get("phase")) || Constant.Succeeded.equals(datasetExportMap.get("phase")))) { + HashMap queryMap = new HashMap(); + queryMap.put("ins_id", experimentIns.getId()); + DatasetTempStorage datasetTempStorage = datasetTempStorageDao.queryByInsId(JSON.toJSONString(queryMap)); + String relativePath = ci4sUsername + "/datasets/" + datasetTempStorage.getRepoId() + "/" + datasetTempStorage.getName() + "/" + datasetTempStorage.getVersion() + "/dataset"; + newDatasetService.deleteDatasetVersionNew(datasetTempStorage.getRepoId(), datasetTempStorage.getName(), datasetTempStorage.getCreateBy(), datasetTempStorage.getVersion(), relativePath); } } - } - //删除导出数据集版本 - if (key.contains("dataset-export")) { - HashMap queryMap = new HashMap(); - queryMap.put("ins_id", experimentIns.getId()); - DatasetTempStorage datasetTempStorage = datasetTempStorageDao.queryByInsId(JSON.toJSONString(queryMap)); - String relativePath = ci4sUsername + "/datasets/" + datasetTempStorage.getRepoId() + "/" + datasetTempStorage.getName() + "/" + datasetTempStorage.getVersion() + "/dataset"; - newDatasetService.deleteDatasetVersionNew(datasetTempStorage.getRepoId(), datasetTempStorage.getName(), datasetTempStorage.getCreateBy(), datasetTempStorage.getVersion(), relativePath); } } + } catch (Exception e) { + logger.error(e.getMessage()); } } @@ -649,7 +682,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { // 定义终止态的列表,例如 "Succeeded", "Failed" 等 String status = ins.getStatus(); boolean flag = true; - List terminatedStates = Arrays.asList("Succeeded", "Failed"); + List terminatedStates = Arrays.asList("Succeeded", Constant.Failed); flag = terminatedStates.contains(status); if (StringUtils.equals(status, "Terminated")) { //如果跟node_status里面不一样,就要去更新node_status的信息 @@ -677,9 +710,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); Experiment experiment = experimentDao.queryById(experimentId); experiment.setStatusList(subStatus); - List updateExperiments = new ArrayList<>(); - updateExperiments.add(experiment); - experimentDao.insertOrUpdateBatch(updateExperiments); + experimentDao.update(experiment); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java index 96193527..d7b559da 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java @@ -149,9 +149,7 @@ public class ExperimentServiceImpl implements ExperimentService { checkDeclaredName(experiment); experiment.setCreateBy(loginUser.getUsername()); experiment.setUpdateBy(loginUser.getUsername()); - experiment.setUpdateTime(new Date()); - experiment.setCreateTime(new Date()); - experiment.setState(1); + experiment.setState(Constant.State_valid); this.experimentDao.insert(experiment); return experiment; } @@ -167,7 +165,6 @@ public class ExperimentServiceImpl implements ExperimentService { LoginUser loginUser = SecurityUtils.getLoginUser(); checkDeclaredName(experiment); experiment.setUpdateBy(loginUser.getUsername()); - experiment.setUpdateTime(new Date()); this.experimentDao.update(experiment); return this.queryById(experiment.getId()); } @@ -237,6 +234,9 @@ public class ExperimentServiceImpl implements ExperimentService { throw new Exception("转换流水线失败"); } Map converMap = JsonUtils.jsonToMap(convertRes); + if (converMap.get("data") == null) { + throw new RuntimeException("转换流水线失败"); + } // 判断积分和资源是否足够 Map> resourceInfo = (Map>) converMap.get("resource_info"); @@ -321,7 +321,7 @@ public class ExperimentServiceImpl implements ExperimentService { resourceOccupyService.startDeduce((Integer) node.get("computing_resource_id"), 1, Constant.TaskType_Workflow, Long.valueOf(id), Long.valueOf(insert.getId()), experiment.getWorkflowId(), experiment.getName(), entry.getKey(), Constant.State_building); } } catch (Exception e) { - throw new Exception(e); + throw new Exception(e.getMessage()); } List updatedExperimentInsList = experimentInsService.getByExperimentId(id); experiment.setExperimentInsList(updatedExperimentInsList); @@ -815,7 +815,7 @@ public class ExperimentServiceImpl implements ExperimentService { try { newExperiment = this.runExperiment(newExperiment.getId()); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } return newExperiment; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java index 684d8069..d81e234e 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/GitServiceImpl.java @@ -99,7 +99,7 @@ public class GitServiceImpl implements GitService { token = jedis.get(ci4sUsername + "_gitToken"); } } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } } return token; @@ -240,4 +240,27 @@ public class GitServiceImpl implements GitService { throw new Exception("用户不可删除:" + resultMap.get("message")); } } + + @Override + public List> PersonalQueryGitByPage(String token, String login, String name, Integer page) throws Exception { + // 拼接查询url + String url = gitendpoint + "/api/users/" + login + "/projects.json?page=" + page + "&limit=50&category=manage&sort_direction=praises_count&sort_by=desc"; + if (StringUtils.isNotEmpty(name)) { + url = url + "&search=" + name; + } + String req = httpUtils.sendGetWithToken(url, null, token); + Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); + return (List>) stringObjectMap.get("projects"); + } + + public List> PubilcQueryGitByPage(String token, String name, Integer page, Integer projectCategoryId) throws Exception { + // 拼接查询url + String url = gitendpoint + "/api/projects.json?page=" + page + "&limit=50sort_direction=praises_count&sort_by=desc&category_id=" + projectCategoryId; + if (StringUtils.isNotEmpty(name)) { + url = url + "&search=" + name; + } + String req = httpUtils.sendGetWithToken(url, null, token); + Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); + return (List>) stringObjectMap.get("projects"); + } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java index 0c52a9bb..eeb51915 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java @@ -275,7 +275,7 @@ public class ImageServiceImpl implements ImageService { imageVersion.setVersion(imageVo.getVersion()); imageVersion.setTagName(imageVo.getTagName()); imageVersion.setFileSize(imageVo.getFileSize()); - imageVersion.setDescription(imageVo.getDescription()); + imageVersion.setDescription(imageVo.getVersionDescription()); imageVersion.setStatus(Constant.Building); ImageVersion imageVersionInsert = this.imageVersionService.insert(imageVersion); if (imageVersionInsert == null) { @@ -302,7 +302,7 @@ public class ImageServiceImpl implements ImageService { String fileSize = resultMap.get("fileSize"); imageVersion.setUrl(imageUrl); imageVersion.setFileSize(fileSize); - imageVersion.setStatus("available"); + imageVersion.setStatus(Constant.Available); imageVersionService.update(imageVersion); } catch (Exception e) { System.err.println("更新数据库失败: " + e.getMessage()); @@ -466,7 +466,7 @@ public class ImageServiceImpl implements ImageService { imageVo.setValue(resultMap.get("imageName")); imageVo.setVersion(String.valueOf(imageVersion.getId())); - resultMap.put("id", String.valueOf(oldImage.getId())); + resultMap.put("id", String.valueOf(image.getId())); resultMap.put("version", String.valueOf(imageVersion.getId())); resultMap.put("value",resultMap.get("imageName")); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnInsServiceImpl.java index 2e353807..562acf9f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnInsServiceImpl.java @@ -9,8 +9,11 @@ import com.ruoyi.platform.service.ResourceOccupyService; import com.ruoyi.platform.utils.DateUtils; import com.ruoyi.platform.utils.HttpUtils; import com.ruoyi.platform.utils.JsonUtils; +import com.ruoyi.platform.utils.MinioUtil; import com.ruoyi.system.api.constant.Constant; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.data.domain.Page; @@ -19,10 +22,13 @@ import org.springframework.data.domain.PageRequest; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.text.SimpleDateFormat; import java.util.*; @Service public class MachineLearnInsServiceImpl implements MachineLearnInsService { + private static final Logger logger = LoggerFactory.getLogger(MachineLearnInsServiceImpl.class); + @Value("${argo.url}") private String argoUrl; @Value("${argo.workflowStatus}") @@ -36,6 +42,8 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { private MachineLearnDao machineLearnDao; @Resource private ResourceOccupyService resourceOccupyService; + @Resource + private MinioUtil minioUtil; @Override public Page queryByPage(Long machineLearnId, PageRequest pageRequest) { @@ -50,6 +58,18 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { return machineLearnIns; } + @Override + public MachineLearnIns update(MachineLearnIns machineLearnIns) { + machineLearnIns.setUpdateTime(new Date()); + machineLearnIns = queryStatusFromArgo(machineLearnIns); + machineLearnInsDao.update(machineLearnIns); + updateMLStatus(machineLearnIns.getMachineLearnId()); + if (Constant.Failed.equals(machineLearnIns.getStatus()) || Constant.Succeeded.equals(machineLearnIns.getStatus())) { + resourceOccupyService.endDeduce(Constant.TaskType_ML, null, machineLearnIns.getId(), null, null); + } + return machineLearnIns; + } + @Override @Transactional public String removeById(Long id) { @@ -211,6 +231,9 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { // 如果值不等于 Succeeded,则赋值为 Failed if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { innerMap.put("phase", Constant.Failed); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -8); + innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); } } } @@ -237,6 +260,9 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { if (Constant.Running.equals(machineLearnIns.getStatus()) || Constant.Pending.equals(machineLearnIns.getStatus())) { machineLearnIns = queryStatusFromArgo(machineLearnIns); } + if (Constant.ML_VideoClassification.equals(machineLearnIns.getType())) { + getFileList(machineLearnIns); + } return machineLearnIns; } @@ -256,4 +282,24 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { machineLearnDao.edit(machineLearn); } } + + public void getFileList(MachineLearnIns ins) { + String directoryPath = ins.getResultPath(); + + try { + String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); + String prefix = directoryPath.substring(directoryPath.indexOf("/") + 1, directoryPath.length()) + "/"; + List fileMaps = minioUtil.listRayFilesInDirectory(bucketName, prefix); + Map fileMap = new HashMap<>(); + fileMap.put("children", fileMaps); + fileMap.put("url", directoryPath); + fileMap.put("isDirectory", true); + fileMap.put("size", "0 B"); + fileMap.put("name", "result file"); + ins.setFileMap(fileMap); + } catch (Exception e) { + logger.error("未找到结果文件"); + } + + } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnServiceImpl.java index f61847ef..7f6fb600 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/MachineLearnServiceImpl.java @@ -63,7 +63,7 @@ public class MachineLearnServiceImpl implements MachineLearnService { @Override public MachineLearn add(MachineLearn machineLearn) { - if (machineLearn.getName().length() >= 64) { + if (machineLearn.getName().length() > 64) { throw new RuntimeException("实验名称大于最大长度"); } MachineLearn machineLearnByName = machineLearnDao.getMachineLearnByName(machineLearn.getName()); @@ -105,6 +105,12 @@ public class MachineLearnServiceImpl implements MachineLearnService { if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { throw new RuntimeException("无权限删除该实验"); } + + List insList = machineLearnInsDao.getByMachineLearnId(machineLearn.getId()); + if (!insList.isEmpty()) { + throw new RuntimeException("该实验存在实例,无法删除"); + } + machineLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); machineLearn.setState(Constant.State_invalid); resourceOccupyService.deleteTaskState(Constant.TaskType_ML, id, null); @@ -159,6 +165,12 @@ public class MachineLearnServiceImpl implements MachineLearnService { if (convertRes == null || StringUtils.isEmpty(convertRes)) { throw new RuntimeException("转换流水线失败"); } + + Map convertResMap = JsonUtils.jsonToMap(convertRes); + if (convertResMap.get("data")== null) { + throw new RuntimeException("转换流水线失败"); + } + Map converMap = JsonUtils.jsonToMap(convertRes); // 组装运行接口json Map output = (Map) converMap.get("output"); @@ -191,7 +203,8 @@ public class MachineLearnServiceImpl implements MachineLearnService { Map param_output = (Map) output.get("param_output"); List output1 = (ArrayList) param_output.values().toArray()[0]; Map output2 = (Map) output1.get(0); - String outputPath = minioEndpoint + "/" + output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/"; + String outputStr = output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")); + String outputPath = minioEndpoint + "/" + outputStr + "/"; switch (machineLearn.getType()) { case Constant.ML_CSV: { @@ -208,13 +221,13 @@ public class MachineLearnServiceImpl implements MachineLearnService { } case Constant.ML_TextClassification: { machineLearnIns.setModelPath(outputPath + "saved_dict/" + modelType + ".ckpt"); - machineLearnIns.setRunHistoryPath(output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")).substring("data/".length()) + "/log/" + modelType); + machineLearnIns.setRunHistoryPath(outputStr.substring("data/".length()) + "/log/" + modelType); machineLearnIns.setResultPath(outputPath + "log/" + modelType + "/result.txt"); break; } case Constant.ML_VideoClassification: { - machineLearnIns.setResultPath(outputPath); - machineLearnIns.setRunHistoryPath(output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")).substring("data/".length()) + "/log"); + machineLearnIns.setResultPath(outputStr); + machineLearnIns.setRunHistoryPath(outputStr.substring("data/".length()) + "/log"); break; } } @@ -225,7 +238,7 @@ public class MachineLearnServiceImpl implements MachineLearnService { resourceOccupyService.startDeduce(computingResourceId, 1, Constant.TaskType_ML, id, machineLearnIns.getId(), null, machineLearn.getName(), null, null); } } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } return "执行成功"; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelDependencyServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelDependencyServiceImpl.java index 572a66a5..56e97245 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelDependencyServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelDependencyServiceImpl.java @@ -245,7 +245,7 @@ public class ModelDependencyServiceImpl implements ModelDependencyService { } @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { ModelDependency modelDependency = this.modelDependencyDao.queryById(id); if (modelDependency == null){ return "模型依赖信息不存在"; @@ -256,7 +256,7 @@ public class ModelDependencyServiceImpl implements ModelDependencyService { String username = loginUser.getUsername(); String createdBy = modelDependency.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除"; + throw new Exception("无权限删除"); } modelDependency.setState(0); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index 71f02654..ad9a1ac7 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -112,6 +112,10 @@ public class ModelsServiceImpl implements ModelsService { String gitendpoint; @Value("${git.cloneEndpoint}") String gitCloneEndpoint; + @Value("${git.cloneEndpointIp}") + String gitCloneEndpointIp; + @Value("${git.projectModelId}") + Integer projectModelId; @Value("${git.localPath}") String localPath; @Value("${minio.accessKey}") @@ -578,7 +582,7 @@ public class ModelsServiceImpl implements ModelsService { ModelDependency1 modelDependency = new ModelDependency1(); List oldModelDependencys = modelDependency1Dao.queryModelDependency(modelsVo.getName(), null, gitLinkUsername); if (oldModelDependencys != null && !oldModelDependencys.isEmpty()) { - throw new Exception("创建模型失败:项目名称已被使用."); + throw new RuntimeException("创建模型失败:项目名称已被使用"); } //新建模型 @@ -589,13 +593,13 @@ public class ModelsServiceImpl implements ModelsService { gitProjectVo.setDescription(modelsVo.getDescription()); gitProjectVo.setPrivate(!modelsVo.getIsPublic()); gitProjectVo.setUserId(userId); - gitProjectVo.setProjectCategoryId(Constant.Git_Category_Id); + gitProjectVo.setProjectCategoryId(projectModelId); // 创建项目 Map project = gitService.createProject(token, gitProjectVo); Integer gitlinIid = (Integer) project.get("id"); if (gitlinIid == null) { - throw new Exception("创建模型失败:" + project.get("message")); + throw new RuntimeException("创建模型失败:" + project.get("message")); } String branchName = modelsVo.getVersion(); @@ -632,9 +636,10 @@ public class ModelsServiceImpl implements ModelsService { modelMetaVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); modelMetaVo.setCreateTime(DateUtils.getTime()); modelMetaVo.setUpdateTime(DateUtils.getTime()); + String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git"; modelMetaVo.setUsage("
" +
                     "# 克隆模型配置文件与存储参数到本地\n" +
-                    "git clone -b " + branchName + " " + projectUrl + "\n" +
+                    "git clone -b " + branchName + " " + projectUrlIp + "\n" +
                     "# 远程拉取配置文件\n" +
                     "dvc pull\n" +
                     "
"); @@ -678,7 +683,7 @@ public class ModelsServiceImpl implements ModelsService { dvcUtils.dvcPush(rootPath); } catch (Exception e) { logger.error(e.getMessage(), e); - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } return null; }); @@ -686,7 +691,7 @@ public class ModelsServiceImpl implements ModelsService { return "新增模型成功"; } catch (Exception e) { logger.error(e.getMessage()); - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } } @@ -931,55 +936,45 @@ public class ModelsServiceImpl implements ModelsService { LoginUser loginUser = SecurityUtils.getLoginUser(); String ci4sUsername = loginUser.getUsername(); String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); - Map userInfo = getUserInfo(ci4sUsername, gitLinkPassword); String token = (String) userInfo.get("token"); + String login = (String) userInfo.get("login"); - //拼接查询url - String modelTagName = modelsVo.getModelTag(); - String modelTypeName = modelsVo.getModelType(); - - String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; - - String name = modelsVo.getName(); - if (StringUtils.isNotEmpty(name)) { - url = url + "&search=" + name; + List collect = new ArrayList<>(); + for (int i = 1; ; i++) { + List> projects = gitService.PersonalQueryGitByPage(token, login, modelsVo.getName(), i); + if (projects.isEmpty()) { + break; + } else { + List collecti = convert(projects, Constant.Topic_model, modelsVo.getModelTag(), modelsVo.getModelType()); + collect.addAll(collecti); + } } - - String req = httpUtils.sendGetWithToken(url, null, token); - Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - List> projects = (List>) stringObjectMap.get("projects"); - List collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); - List result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). + List result = collect.stream().sorted(Comparator.comparing(ModelsVo::getPraisesCount).reversed()).skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). collect(Collectors.toList()); return new PageImpl<>(result, pageRequest, collect.size()); } + @Override public Page newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception { LoginUser loginUser = SecurityUtils.getLoginUser(); String ci4sUsername = loginUser.getUsername(); String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); - Map userInfo = getUserInfo(ci4sUsername, gitLinkPassword); String token = (String) userInfo.get("token"); - String modelTagName = modelsVo.getModelTag(); - String modelTypeName = modelsVo.getModelType(); - - //拼接查询url - String url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; - - String name = modelsVo.getName(); - if (StringUtils.isNotEmpty(name)) { - url = url + "&search=" + name; + List collect = new ArrayList<>(); + for (int i = 1; ; i++) { + List> projects = gitService.PubilcQueryGitByPage(token, modelsVo.getName(), i, projectModelId); + if (projects.isEmpty()) { + break; + } else { + List collecti = convert(projects, Constant.Topic_model, modelsVo.getModelTag(), modelsVo.getModelType()); + collect.addAll(collecti); + } } - - String req = httpUtils.sendGetWithToken(url, null, token); - Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - List> projects = (List>) stringObjectMap.get("projects"); - List collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); - List result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). + List result = collect.stream().sorted(Comparator.comparing(ModelsVo::getPraisesCount).reversed()).skip((long) pageRequest.getPageNumber() * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). collect(Collectors.toList()); return new PageImpl<>(result, pageRequest, collect.size()); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java index 24a6b636..ad81f1f5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsVersionServiceImpl.java @@ -194,7 +194,7 @@ public class ModelsVersionServiceImpl implements ModelsVersionService { } @Override - public Map deleteModelsVersion(Integer modelsId, String version) throws IOException { + public Map deleteModelsVersion(Integer modelsId, String version) throws Exception { Map results = new HashMap(); // 根据模型ID和版本查询所有模型版本 List versions = this.modelsVersionDao.queryAllByModelsVersion(modelsId, version); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java index 122fd26b..d238b7b4 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java @@ -73,6 +73,11 @@ public class NewDatasetServiceImpl implements NewDatasetService { String gitendpoint; @Value("${git.cloneEndpoint}") String gitCloneEndpoint; + @Value("${git.cloneEndpointIp}") + String gitCloneEndpointIp; + @Value("${git.projectDatasetId}") + Integer projectDatasetId; + @Value("${minio.dataReleaseBucketName}") private String bucketName; @Value("${git.localPath}") @@ -111,7 +116,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { gitProjectVo.setDescription(datasetVo.getDescription()); gitProjectVo.setPrivate(!datasetVo.getIsPublic()); gitProjectVo.setUserId(userId); - gitProjectVo.setProjectCategoryId(Constant.Git_Category_Id); + gitProjectVo.setProjectCategoryId(projectDatasetId); // 创建项目 Map project = gitService.createProject(token, gitProjectVo); Integer gitlinIid = (Integer) project.get("id"); @@ -183,7 +188,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { dvcUtils.dvcPush(localPath); } catch (Exception e) { logger.error(e.getMessage(), e); - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } return null; }); @@ -260,9 +265,10 @@ public class NewDatasetServiceImpl implements NewDatasetService { // 拼接生产的元数据后写入yaml文件 datasetVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); datasetVo.setUpdateTime(DateUtils.getTime()); + String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git"; datasetVo.setUsage("
" +
                 "# 克隆数据集配置文件与存储参数到本地\n" +
-                "git clone -b " + branchName + " " + projectUrl + "\n" +
+                "git clone -b " + branchName + " " + projectUrlIp + "\n" +
                 "# 远程拉取配置文件\n" +
                 "dvc pull\n" +
                 "
"); @@ -321,19 +327,18 @@ public class NewDatasetServiceImpl implements NewDatasetService { String ci4sUsername = loginUser.getUsername(); String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); Map userInfo = JsonUtils.jsonToMap(userReq); - // 拼接查询url - String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; - - String name = dataset.getName(); - if (StringUtils.isNotEmpty(name)) { - url = url + "&search=" + name; + String login = (String) userInfo.get("login"); + List collect = new ArrayList<>(); + for (int i = 1; ; i++) { + List> projects = gitService.PersonalQueryGitByPage(token, login, dataset.getName(), i); + if (projects.isEmpty()) { + break; + } else { + List collecti = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); + collect.addAll(collecti); + } } - String req = httpUtils.sendGetWithToken(url, null, token); - Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - List> projects = (List>) stringObjectMap.get("projects"); - - List collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); - List result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). + List result = collect.stream().sorted(Comparator.comparing(NewDatasetVo::getPraisesCount).reversed()).skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). collect(Collectors.toList()); return new PageImpl<>(result, pageRequest, collect.size()); } @@ -341,22 +346,18 @@ public class NewDatasetServiceImpl implements NewDatasetService { @Override public Page newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception { String token = gitService.checkoutToken(); - // 拼接查询url - String url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; - - String name = dataset.getName(); - if (StringUtils.isNotEmpty(name)) { - url = url + "&search=" + name; - } - String req = httpUtils.sendGetWithToken(url, null, token); - Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - List> projects = (List>) stringObjectMap.get("projects"); - if (projects == null) { - return new PageImpl<>(new ArrayList<>(), pageRequest, 0); + List collect = new ArrayList<>(); + for (int i = 1; ; i++) { + List> projects = gitService.PubilcQueryGitByPage(token, dataset.getName(), i, projectDatasetId); + if (projects.isEmpty()) { + break; + } else { + List collecti = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); + collect.addAll(collecti); + } } - List collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); - List result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). + List result = collect.stream().sorted(Comparator.comparing(NewDatasetVo::getPraisesCount).reversed()).skip((long) pageRequest.getPageNumber() * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). collect(Collectors.toList()); return new PageImpl<>(result, pageRequest, collect.size()); } @@ -646,7 +647,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { @Override public List convert(List> lst, String datasetTopic, String datasetTagName, String datasetTypeName) { - if (lst != null && lst.size() > 0) { + if (lst != null && !lst.isEmpty()) { List result = new ArrayList<>(); List newDatasetVos = ConvertUtil.convertListMapToObjectList(lst, NewDatasetVo.class); @@ -674,7 +675,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { } } - if (datasetTopicName != null && datasetTopic.equals(datasetTopicName)) { + if (datasetTopic.equals(datasetTopicName)) { if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasetTag)) { continue; } @@ -710,7 +711,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { sourceMap.remove("preprocess_code"); datasetVo.setTrainTask((HashMap) sourceMap); datasetVo.setProcessingCode((HashMap) preprocessCode); - datasetTempStorage.setState(0); + datasetTempStorage.setState(Constant.State_invalid); datasetTempStorageService.update(datasetTempStorage); } return datasetVo; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java index 9e757c0c..2587f4a5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayInsServiceImpl.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.net.URLEncoder; import java.nio.file.Path; import java.nio.file.Paths; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -69,6 +70,18 @@ public class RayInsServiceImpl implements RayInsService { return rayIns; } + @Override + public RayIns update(RayIns rayIns) { + rayIns.setUpdateTime(new Date()); + rayIns = queryStatusFromArgo(rayIns); + rayInsDao.update(rayIns); + updateRayStatus(rayIns.getRayId()); + if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Succeeded.equals(rayIns.getStatus())) { + resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); + } + return rayIns; + } + @Override @Transactional public String deleteById(Long id) { @@ -162,6 +175,9 @@ public class RayInsServiceImpl implements RayInsService { // 如果值不等于 Succeeded,则赋值为 Failed if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { innerMap.put("phase", Constant.Failed); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, -8); + innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java index 1a9c9770..be2f2bb0 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java @@ -63,7 +63,7 @@ public class RayServiceImpl implements RayService { @Override public Ray save(RayVo rayVo) throws Exception { - if (rayVo.getName().length() >= 64) { + if (rayVo.getName().length() > 64) { throw new RuntimeException("实验名称大于最大长度"); } Ray rayByName = rayDao.getRayByName(rayVo.getName()); @@ -137,15 +137,19 @@ public class RayServiceImpl implements RayService { @Override @Transactional - public String delete(Long id) { + public String delete(Long id) throws Exception { Ray ray = rayDao.getRayById(id); if (ray == null) { - throw new RuntimeException("实验不存在"); + throw new Exception("实验不存在"); } String username = SecurityUtils.getLoginUser().getUsername(); String createBy = ray.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { - throw new RuntimeException("无权限删除该实验"); + throw new Exception("无权限删除该实验"); + } + List insList = rayInsDao.getByRayId(id); + if (!insList.isEmpty()) { + throw new Exception("该实验存在实例,无法删除"); } ray.setState(Constant.State_invalid); resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null); @@ -175,7 +179,12 @@ public class RayServiceImpl implements RayService { if (convertRes == null || StringUtils.isEmpty(convertRes)) { throw new RuntimeException("转换流水线失败"); } + Map converMap = JsonUtils.jsonToMap(convertRes); + if (converMap.get("data") == null) { + throw new RuntimeException("转换流水线失败"); + } + // 组装运行接口json Map output = (Map) converMap.get("output"); Map runReqMap = new HashMap<>(); @@ -214,7 +223,7 @@ public class RayServiceImpl implements RayService { // 记录开始扣除积分 resourceOccupyService.startDeduce(ray.getComputingResourceId(), 1, Constant.TaskType_Ray, id, rayIns.getId(), null, ray.getName(), null, null); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } } return "执行成功"; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java index 3b63eb43..89fb07da 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ResourceOccupyServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -113,9 +114,10 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { } Double hours = (double) timeDifferenceMillis / (1000 * 60 * 60); Double deduceCredit = resourceOccupy.getCreditPerHour() * hours; + deduceCredit = deduceCredit > 0 ? deduceCredit : 0.01; resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); - resourceOccupy.setDeduceCredit(resourceOccupy.getDeduceCredit() + deduceCredit); + resourceOccupy.setDeduceCredit(new BigDecimal(resourceOccupy.getDeduceCredit() + deduceCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); resourceOccupy.setDeduceLastTime(now); resourceOccupy.setState(Constant.State_valid); resourceOccupyDao.edit(resourceOccupy); @@ -132,45 +134,51 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { public Map queryCredit() { Double userCredit = resourceOccupyDao.getUserCredit(SecurityUtils.getLoginUser().getUserid()); Double deduceCredit = resourceOccupyDao.getDeduceCredit(SecurityUtils.getLoginUser().getUserid()); + deduceCredit = deduceCredit != null ? deduceCredit : 0; HashMap result = new HashMap<>(); - result.put("userCredit", userCredit); - result.put("deduceCredit", deduceCredit); + result.put("userCredit", new BigDecimal(userCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + result.put("deduceCredit", new BigDecimal(deduceCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); return result; } @Override @Transactional - public void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas) { - ResourceOccupy resourceOccupy = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, taskInsId, null).get(0); - ComputingResource oldComputingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); - ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); + public void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas, String taskName) { + List resourceOccupyList = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, taskInsId, null); + if (resourceOccupyList.isEmpty()) { + startDeduce(computingResourceId, replicas, taskType, taskId, taskInsId, null, taskName, null, Constant.State_building); + } else { + ResourceOccupy resourceOccupy = resourceOccupyList.get(0); + ComputingResource oldComputingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); + ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); - int occupy_num = (int) (resourceOccupy.getCreditPerHour() / oldComputingResource.getCreditPerHour()); + int occupy_num = (int) (resourceOccupy.getCreditPerHour() / oldComputingResource.getCreditPerHour()); - if (Constant.Computing_Resource_GPU.equals(oldComputingResource.getComputingResource())) { - resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), oldComputingResource.getGpuNums() * occupy_num); - } else { - resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), computingResource.getCpuCores() * occupy_num); - } + if (Constant.Computing_Resource_GPU.equals(oldComputingResource.getComputingResource())) { + resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), oldComputingResource.getGpuNums() * occupy_num); + } else { + resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), computingResource.getCpuCores() * occupy_num); + } - if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { - resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getGpuNums() * replicas); - } else { - resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getCpuCores() * replicas); - } + if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { + resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getGpuNums() * replicas); + } else { + resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getCpuCores() * replicas); + } - if (replicas > 1) { - resourceOccupy.setDescription(replicas + " * [" + computingResource.getDescription() + "]"); - } else { - resourceOccupy.setDescription(computingResource.getDescription()); + if (replicas > 1) { + resourceOccupy.setDescription(replicas + " * [" + computingResource.getDescription() + "]"); + } else { + resourceOccupy.setDescription(computingResource.getDescription()); + } + resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour() * replicas); + resourceOccupy.setComputingResourceId(computingResourceId); + resourceOccupyDao.edit(resourceOccupy); } - resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour() * replicas); - resourceOccupy.setComputingResourceId(computingResourceId); - resourceOccupyDao.edit(resourceOccupy); } @Override public void deleteTaskState(String taskType, Long taskId, Long taskInsId) { - resourceOccupyDao.deleteTaskState(taskType,taskId,taskInsId); + resourceOccupyDao.deleteTaskState(taskType, taskId, taskInsId); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java index 14b58f2b..783f7976 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ServiceServiceImpl.java @@ -191,7 +191,7 @@ public class ServiceServiceImpl implements ServiceService { serviceVersionVo.setDocPath(baseUrl + "/redoc"); serviceVersionVo.setPagePath(baseUrl + "/gradio"); } catch (MalformedURLException e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getMessage()); } } return serviceVersionVo; @@ -351,7 +351,7 @@ public class ServiceServiceImpl implements ServiceService { if (reRun) { resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), serviceVersion.getReplicas(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, service.getServiceName(), null, Constant.State_building); } else if (Constant.Running.equals(serviceVersionById.getRunState()) || Constant.Pending.equals(serviceVersionById.getRunState())) { - resourceOccupyService.update(Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), serviceVersion.getComputingResourceId(), serviceVersion.getReplicas()); + resourceOccupyService.update(Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), serviceVersion.getComputingResourceId(), serviceVersion.getReplicas(), service.getServiceName()); } return "修改成功"; } else { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TensorBoardServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TensorBoardServiceImpl.java index 2931ebd4..94c3edb3 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TensorBoardServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/TensorBoardServiceImpl.java @@ -8,6 +8,7 @@ import com.ruoyi.platform.service.TensorBoardService; import com.ruoyi.platform.utils.K8sClientUtil; import com.ruoyi.platform.vo.FrameLogPathVo; import com.ruoyi.platform.vo.PodStatusVo; +import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -66,7 +67,7 @@ public class TensorBoardServiceImpl implements TensorBoardService { throw new Exception("存储路径为空"); } LoginUser loginUser = SecurityUtils.getLoginUser(); - String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[1]+ "-tensorboard-pod"; + String podName = loginUser.getUsername().toLowerCase() + "-" + frameLogPathVo.getPath().split("/")[1] + "-tensorboard-pod"; // Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image); Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), image); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java index 69043477..21a178a9 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowParamServiceImpl.java @@ -80,10 +80,10 @@ public class WorkflowParamServiceImpl implements WorkflowParamService { } @Override - public String removeById(Integer id) { + public String removeById(Integer id) throws Exception { WorkflowParam workflowParam = this.workflowParamDao.queryById(id); if (workflowParam == null){ - return "流水线参数不存在"; + throw new Exception("流水线参数不存在"); } //判断权限,只有admin和创建者本身可以删除 @@ -93,7 +93,7 @@ public class WorkflowParamServiceImpl implements WorkflowParamService { String createdBy = workflowParam.getCreateBy(); if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ - return "无权限删除该流水线参数"; + throw new Exception("无权限删除该流水线参数"); } workflowParam.setState(0); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index fbeb54a5..1708c4c3 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -105,7 +105,7 @@ public class WorkflowServiceImpl implements WorkflowService { workflow.setUpdateBy(loginUser.getUsername()); workflow.setUpdateTime(new Date()); workflow.setCreateTime(new Date()); - workflow.setState(1); + workflow.setState(Constant.State_valid); this.workflowDao.insert(workflow); saveAssetWorkFlow(workflow); return workflow; @@ -163,7 +163,7 @@ public class WorkflowServiceImpl implements WorkflowService { if (experimentList != null && experimentList.size() > 0) { throw new Exception("该流水线存在实验,无法删除"); } - workflow.setState(0); + workflow.setState(Constant.State_invalid); assetWorkflowDao.deleteByWorkFlowId(id); return this.workflowDao.update(workflow) > 0 ? "删除成功" : "删除失败"; } @@ -180,12 +180,13 @@ public class WorkflowServiceImpl implements WorkflowService { Workflow workflow = this.queryById(id); if (workflow != null) { try { - if (workflow.getName().length() >= 64) { + Workflow duplicateWorkflow = new Workflow(); + duplicateWorkflow.setName(workflow.getName() + "-copy-" + UUID.randomUUID().toString().substring(0, 6)); + + if (duplicateWorkflow.getName().length() > 64) { throw new RuntimeException("流水线名称大于最大长度"); } - Workflow duplicateWorkflow = new Workflow(); - duplicateWorkflow.setName(workflow.getName() + "-copy-" + UUID.randomUUID().toString().substring(0, 6)); String oldDag = workflow.getDag(); // 创建请求数据的Json(map) Map requestData = new HashMap<>(); @@ -334,7 +335,7 @@ public class WorkflowServiceImpl implements WorkflowService { Map image = (Map) paramMap.get("--image"); saveImageWorkFlow((String) image.get("value"), workflowId, workflowName); } catch (Exception e) { - throw new Exception(e); + throw new Exception(e.getMessage()); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java index 1bd00d36..1d4c43f1 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java @@ -4,16 +4,15 @@ import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.platform.domain.*; import com.ruoyi.platform.mapper.*; import com.ruoyi.platform.service.*; -import com.ruoyi.platform.utils.JacksonUtil; -import com.ruoyi.platform.utils.JsonUtils; import com.ruoyi.platform.utils.NewHttpUtils; import com.ruoyi.platform.vo.ModelsVo; import com.ruoyi.platform.vo.NewDatasetVo; import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; -import redis.clients.jedis.Jedis; import javax.annotation.Resource; import java.util.HashMap; @@ -36,20 +35,13 @@ public class WorkspaceServiceImpl implements WorkspaceService { @Resource private ComponentDao componentDao; @Resource - private GitService gitService; + private CodeConfigDao codeConfigDao; @Resource private NewDatasetService newDatasetService; @Resource private ModelsService modelsService; @Resource - private NewHttpUtils httpUtils; - - @Value("${git.endpoint}") - String gitendpoint; - @Value("${spring.redis.host}") - private String redisHost; - @Value("${spring.redis.port}") - private Integer redisPort; + private ServiceDao serviceDao; @Override public Map getOverview() { @@ -87,41 +79,32 @@ public class WorkspaceServiceImpl implements WorkspaceService { @Override public Map getAssetCount(Boolean isPublic) throws Exception { Map assetCountMap = new HashMap<>(); - String token = gitService.checkoutToken(); int availableRange = isPublic ? Constant.Image_Type_Pub : Constant.Image_Type_Pri; - String datasetUrl; - String modelUrl; + Page newDatasetVos; + Page modelsVos; if (isPublic) { // 数据集 - datasetUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; + newDatasetVos = newDatasetService.newPubilcQueryByPage(new Dataset(), PageRequest.of(0, Integer.MAX_VALUE)); // 模型 - modelUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; + modelsVos = modelsService.newPubilcQueryByPage(new ModelsVo(), PageRequest.of(0, Integer.MAX_VALUE)); } else { - Jedis jedis = new Jedis(redisHost, redisPort); - LoginUser loginUser = SecurityUtils.getLoginUser(); - String ci4sUsername = loginUser.getUsername(); - String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); - Map userInfo = JsonUtils.jsonToMap(userReq); - - datasetUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; - modelUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; + // 数据集 + newDatasetVos = newDatasetService.newPersonalQueryByPage(new Dataset(), PageRequest.of(0, Integer.MAX_VALUE)); + // 模型 + modelsVos = modelsService.newPersonalQueryByPage(new ModelsVo(), PageRequest.of(0, Integer.MAX_VALUE)); } - - String req = httpUtils.sendGetWithToken(datasetUrl, null, token); - Map stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - List> projects = (List>) stringObjectMap.get("projects"); - List collect1 = newDatasetService.convert(projects, Constant.Topic_Dataset, null, null); - assetCountMap.put("dataset", collect1.size()); - - req = httpUtils.sendGetWithToken(modelUrl, null, token); - stringObjectMap = JacksonUtil.parseJSONStr2Map(req); - projects = (List>) stringObjectMap.get("projects"); - List collect2 = modelsService.convert(projects, Constant.Topic_model, null, null); - assetCountMap.put("model", collect2.size()); + assetCountMap.put("dataset", (int) newDatasetVos.getTotalElements()); + assetCountMap.put("model", (int) modelsVos.getTotalElements()); // 镜像 Image image = new Image(); - image.setImageType(Constant.Image_Type_Pub); + if (isPublic) { + image.setImageType(Constant.Image_Type_Pub); + } else { + LoginUser loginUser = SecurityUtils.getLoginUser(); + image.setCreateBy(loginUser.getUsername()); + image.setImageType(Constant.Image_Type_Pri); + } Integer imageCount = (int) this.imageDao.count(image); assetCountMap.put("image", imageCount); //统计组件数量 @@ -133,7 +116,15 @@ public class WorkspaceServiceImpl implements WorkspaceService { Workflow workflow = new Workflow(); Integer workflowCount = (int) this.workflowDao.count(workflow); assetCountMap.put("workflow", workflowCount); - + // 统计代码配置数量 + CodeConfig codeConfig = new CodeConfig(); + codeConfig.setIsPublic(isPublic); + Integer codeConfigCount = (int) this.codeConfigDao.count(codeConfig); + assetCountMap.put("codeConfig", codeConfigCount); + // 统计服务数量 + com.ruoyi.platform.domain.Service service = new com.ruoyi.platform.domain.Service(); + Integer serviceCount = (int) serviceDao.countService(service); + assetCountMap.put("service", serviceCount); return assetCountMap; } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java index 5be79efa..f3052f16 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DVCUtils.java @@ -39,6 +39,7 @@ public class DVCUtils { @Value("${proxy.port}") private Integer port; + private class ProxyConfigCallback implements TransportConfigCallback { @Override public void configure(Transport transport) { @@ -259,6 +260,7 @@ public class DVCUtils { log.error("Error occurred while creating local branch", e); } } + /** * 删除本地分支 * @@ -440,17 +442,19 @@ public class DVCUtils { .forEach(ref -> { String fullBranchName = ref.getName(); String branchName = fullBranchName.replace("refs/remotes/origin/", ""); - try { - completionService.submit(() -> { - try { - processBranch(git, repository, credentialsProvider, fullBranchName, branchName); - } catch (Exception e) { - log.error("Failed to process branch: " + branchName, e); - } - return null; - }); - } catch (Exception e) { - log.error("Task submission rejected", e); + if (!"master".equals(branchName)) { + try { + completionService.submit(() -> { + try { + processBranch(git, repository, credentialsProvider, fullBranchName, branchName); + } catch (Exception e) { + log.error("Failed to process branch: " + branchName, e); + } + return null; + }); + } catch (Exception e) { + log.error("Task submission rejected", e); + } } }); @@ -523,8 +527,6 @@ public class DVCUtils { } - - public void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder.setGitDir(new File(localPath, ".git")) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java index cf6e8f07..d29ed668 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java @@ -355,6 +355,10 @@ public class K8sClientUtil { int lastIndex = hostPath.lastIndexOf('/'); String newPath = hostPath.substring(0, lastIndex); V1Pod pod; + + V1HTTPGetAction httpGetAction = new V1HTTPGetAction().path("/").port(new IntOrString(port)); + V1Probe readinessProbe = new V1Probe().httpGet(httpGetAction).initialDelaySeconds(10).periodSeconds(5).failureThreshold(2); + if (useProxy) { pod = new V1PodBuilder() .withNewMetadata() @@ -368,6 +372,7 @@ public class K8sClientUtil { .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() + .withReadinessProbe(readinessProbe) .addNewEnv() .withName("HTTP_PROXY") .withValue(proxyUrl) @@ -402,6 +407,7 @@ public class K8sClientUtil { .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() + .withReadinessProbe(readinessProbe) .addNewEnv() .withName("NO_PROXY") .withValue("localhost,kubernetes.default.svc") @@ -523,6 +529,8 @@ public class K8sClientUtil { //配置资源 V1ResourceRequirements v1ResourceRequirements = setPodResource(devEnvironment.getComputingResourceId()); + V1HTTPGetAction httpGetAction = new V1HTTPGetAction().path("/").port(new IntOrString(port)); + V1Probe readinessProbe = new V1Probe().httpGet(httpGetAction).initialDelaySeconds(10).periodSeconds(5).failureThreshold(2); String image = (String) JsonUtils.jsonToMap(devEnvironment.getImage()).get("value"); @@ -538,6 +546,7 @@ public class K8sClientUtil { .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) .withVolumeMounts(volumeMounts) .withResources(v1ResourceRequirements) + .withReadinessProbe(readinessProbe) .endContainer() .withVolumes(volumes) .withNodeSelector(nodeSelector) @@ -629,7 +638,23 @@ public class K8sClientUtil { public String getPodStatus(String podName, String namespace) throws Exception { CoreV1Api api = new CoreV1Api(apiClient); V1Pod pod = api.readNamespacedPod(podName, namespace, null, null, null); - return pod.getStatus().getPhase(); + String status = pod.getStatus().getPhase(); + Boolean podReady = false; + + List conditions = pod.getStatus().getConditions(); + if (conditions != null) { + for (V1PodCondition condition : conditions) { + if (Constant.Ready.equals(condition.getType()) && Constant.True.equals(condition.getStatus())) { + podReady = true; + break; + } + } + } + + if (Constant.Running.equals(status) && !podReady) { + return Constant.Pending; + } + return status; } /** diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/MinioUtil.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/MinioUtil.java index 606fcb46..103aedf4 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/MinioUtil.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/MinioUtil.java @@ -350,7 +350,7 @@ public class MinioUtil { map.put("name", fileName); map.put("size", formattedSize); - if ((fileName.startsWith("run") || fileName.startsWith("checkpoint")) && fileSize == 0) { + if ((fileName.startsWith("run") || fileName.startsWith("checkpoint") || fileName.equals("log")) && fileSize == 0) { map.put("isDirectory", true); map.put("children", listRayFilesInDirectory(bucketName, fullPath)); } else { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java index dc88ad0e..f48f48f5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java @@ -1,5 +1,7 @@ package com.ruoyi.platform.utils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.platform.vo.HttpDeleteWithBody; import org.apache.http.HttpHost; import org.apache.http.client.methods.*; import org.apache.http.client.utils.URIBuilder; @@ -80,7 +82,11 @@ public class NewHttpUtils { } public static String sendDeleteWithToken(String url, String param, String token, String body) throws Exception { - return sendRequest(new HttpDelete(), url, param, token, body); + if (StringUtils.isNotEmpty(body)) { + return sendRequest(new HttpDeleteWithBody(), url, param, token, body); + } else { + return sendRequest(new HttpDelete(), url, param, token, body); + } } public static String sendPatchWithToken(String url, String param, String token, String body) throws Exception { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/AutoMlVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/AutoMlVo.java deleted file mode 100644 index 3fbe5cc4..00000000 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/AutoMlVo.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.ruoyi.platform.vo; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.Date; -import java.util.Map; - -@Data -@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) -@ApiModel(description = "自动机器学习") -public class AutoMlVo { - private Long id; - - @ApiModelProperty(value = "实验名称") - private String mlName; - - @ApiModelProperty(value = "实验描述") - private String mlDescription; - - @ApiModelProperty(value = "任务类型:classification或regression") - private String taskType; - - @ApiModelProperty(value = "搜索合适模型的时间限制(以秒为单位)。通过增加这个值,auto-sklearn有更高的机会找到更好的模型。默认3600,非必传。") - private Integer timeLeftForThisTask; - - @ApiModelProperty(value = "单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合。将这个值设置得足够高,这样典型的机器学习算法就可以适用于训练数据。默认600,非必传。") - private Integer perRunTimeLimit; - - @ApiModelProperty(value = "集成模型数量,如果设置为0,则没有集成。默认50,非必传。") - private Integer ensembleSize; - - @ApiModelProperty(value = "设置为None将禁用集成构建,设置为SingleBest仅使用单个最佳模型而不是集成,设置为default,它将对单目标问题使用EnsembleSelection,对多目标问题使用MultiObjectiveDummyEnsemble。默认default,非必传。") - private String ensembleClass; - - @ApiModelProperty(value = "在构建集成时只考虑ensemble_nbest模型。这是受到了“最大限度地利用集成选择”中引入的库修剪概念的启发。这是独立于ensemble_class参数的,并且这个修剪步骤是在构造集成之前完成的。默认50,非必传。") - private Integer ensembleNbest; - - @ApiModelProperty(value = "定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除。由于这个变量的性质,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数。如果设置为None,则所有模型都保留在磁盘上。默认50,非必传。") - private Integer maxModelsOnDisc; - - @ApiModelProperty(value = "随机种子,将决定输出文件名。默认1,非必传。") - private Integer seed; - - @ApiModelProperty(value = "机器学习算法的内存限制(MB)。如果auto-sklearn试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072,非必传。") - private Integer memoryLimit; - - @ApiModelProperty(value = "如果为None,则使用所有可能的分类算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost\n" + - "bernoulli_nb\n" + - "decision_tree\n" + - "extra_trees\n" + - "gaussian_nb\n" + - "gradient_boosting\n" + - "k_nearest_neighbors\n" + - "lda\n" + - "liblinear_svc\n" + - "libsvm_svc\n" + - "mlp\n" + - "multinomial_nb\n" + - "passive_aggressive\n" + - "qda\n" + - "random_forest\n" + - "sgd") - private String includeClassifier; - - @ApiModelProperty(value = "如果为None,则使用所有可能的特征预处理算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:densifier\n" + - "extra_trees_preproc_for_classification\n" + - "extra_trees_preproc_for_regression\n" + - "fast_ica\n" + - "feature_agglomeration\n" + - "kernel_pca\n" + - "kitchen_sinks\n" + - "liblinear_svc_preprocessor\n" + - "no_preprocessing\n" + - "nystroem_sampler\n" + - "pca\n" + - "polynomial\n" + - "random_trees_embedding\n" + - "select_percentile_classification\n" + - "select_percentile_regression\n" + - "select_rates_classification\n" + - "select_rates_regression\n" + - "truncatedSVD") - private String includeFeaturePreprocessor; - - @ApiModelProperty(value = "如果为None,则使用所有可能的回归算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components//*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost,\n" + - "ard_regression,\n" + - "decision_tree,\n" + - "extra_trees,\n" + - "gaussian_process,\n" + - "gradient_boosting,\n" + - "k_nearest_neighbors,\n" + - "liblinear_svr,\n" + - "libsvm_svr,\n" + - "mlp,\n" + - "random_forest,\n" + - "sgd") - private String includeRegressor; - - private String excludeClassifier; - - private String excludeRegressor; - - private String excludeFeaturePreprocessor; - - @ApiModelProperty(value = "测试集的比率,0到1之间") - private Float testSize; - - @ApiModelProperty(value = "如何处理过拟合,如果使用基于“cv”的方法或Splitter对象,可能需要使用resampling_strategy_arguments。holdout或crossValid") - private String resamplingStrategy; - - @ApiModelProperty(value = "重采样划分训练集和验证集,训练集的比率,0到1之间") - private Float trainSize; - - @ApiModelProperty(value = "拆分数据前是否进行shuffle") - private Boolean shuffle; - - @ApiModelProperty(value = "交叉验证的折数,当resamplingStrategy为crossValid时,此项必填,为整数") - private Integer folds; - - @ApiModelProperty(value = "文件夹存放配置输出和日志文件,默认/tmp/automl") - private String tmpFolder; - - @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") - private String targetColumns; - - @ApiModelProperty(value = "自定义指标名称") - private String metricName; - - @ApiModelProperty(value = "模型优化目标指标及权重,json格式。分类的指标包含:accuracy\n" + - "balanced_accuracy\n" + - "roc_auc\n" + - "average_precision\n" + - "log_loss\n" + - "precision_macro\n" + - "precision_micro\n" + - "precision_samples\n" + - "precision_weighted\n" + - "recall_macro\n" + - "recall_micro\n" + - "recall_samples\n" + - "recall_weighted\n" + - "f1_macro\n" + - "f1_micro\n" + - "f1_samples\n" + - "f1_weighted\n" + - "回归的指标包含:mean_absolute_error\n" + - "mean_squared_error\n" + - "root_mean_squared_error\n" + - "mean_squared_log_error\n" + - "median_absolute_error\n" + - "r2") - private String metrics; - - @ApiModelProperty(value = "指标优化方向,是越大越好还是越小越好") - private Boolean greaterIsBetter; - - @ApiModelProperty(value = "模型计算并打印指标") - private String scoringFunctions; - - private Integer state; - - private String runState; - - private Double progress; - - private String createBy; - - private Date createTime; - - private String updateBy; - - private Date updateTime; - - /** - * 对应数据集 - */ - private Map dataset; -} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java new file mode 100644 index 00000000..340efa52 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java @@ -0,0 +1,25 @@ +package com.ruoyi.platform.vo; + +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; + +import java.net.URI; + +public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { + public static final String METHOD_NAME = "DELETE"; + + public HttpDeleteWithBody() { + } + + public HttpDeleteWithBody(URI uri) { + this.setURI(uri); + } + + public HttpDeleteWithBody(String uri) { + this.setURI(URI.create(uri)); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java index 7c4a7cc9..19fc319d 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ImageVo.java @@ -22,6 +22,10 @@ public class ImageVo implements Serializable { */ @ApiModelProperty(name = "description") private String description; + + @ApiModelProperty(name = "version_description") + private String versionDescription; + /** * 镜像类型 */ diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java index 9e0b7591..bbca5e1b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ModelMetaVo.java @@ -82,9 +82,12 @@ public class ModelMetaVo implements Serializable { @ApiModelProperty(value = "示例用法") private String usage; - @ApiModelProperty(name = "time_ago", value = "更新时间") + @ApiModelProperty(name = "time_ago", value = "创建时间") private String timeAgo; + @ApiModelProperty(name = "full_last_update_time",value = "更新时间") + private String fullLastUpdateTime; + @ApiModelProperty(name = "owner", value = "项目所有者") private String owner; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/NewDatasetVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/NewDatasetVo.java index 082df2a4..b7d06dc9 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/NewDatasetVo.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/NewDatasetVo.java @@ -44,8 +44,12 @@ public class NewDatasetVo implements Serializable { @ApiModelProperty(name = "dataset_version_vos",value = "文件列表") private List datasetVersionVos; - @ApiModelProperty(name = "time_ago",value = "更新时间") + @ApiModelProperty(name = "time_ago",value = "创建时间") private String timeAgo; + + @ApiModelProperty(name = "full_last_update_time",value = "更新时间") + private String fullLastUpdateTime; + @ApiModelProperty(name = "id",value = "数据集仓库id") private Integer id; @ApiModelProperty(name = "visits",value = "访问次数") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/PodStatusVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/PodStatusVo.java index 0a8c8c0a..d8a08029 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/PodStatusVo.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/PodStatusVo.java @@ -2,28 +2,14 @@ package com.ruoyi.platform.vo; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Data; import java.io.Serializable; @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@Data public class PodStatusVo implements Serializable { private String status; - private String url; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } + private String url; } diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml index 55c94dd6..d96af0e4 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml @@ -9,7 +9,7 @@ - select count(1) from auto_ml - - - - - - - - - - - - - - state = 1 - - and ml_name like concat('%', #{mlName}, '%') - - - - \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlInsDao.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlInsDao.xml deleted file mode 100644 index 26f9c20d..00000000 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlInsDao.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - insert into auto_ml_ins(auto_ml_id, result_path, model_path, img_path, run_history_path, node_status, - node_result, param, source, argo_ins_name, argo_ins_ns, status) - values (#{autoMlIns.autoMlId}, #{autoMlIns.resultPath}, #{autoMlIns.modelPath}, #{autoMlIns.imgPath}, - #{autoMlIns.runHistoryPath}, #{autoMlIns.nodeStatus}, - #{autoMlIns.nodeResult}, #{autoMlIns.param}, #{autoMlIns.source}, #{autoMlIns.argoInsName}, - #{autoMlIns.argoInsNs}, #{autoMlIns.status}) - - - - update auto_ml_ins - - - model_path = #{autoMlIns.modelPath}, - - - img_path = #{autoMlIns.imgPath}, - - - status = #{autoMlIns.status}, - - - node_status = #{autoMlIns.nodeStatus}, - - - node_result = #{autoMlIns.nodeResult}, - - - state = #{autoMlIns.state}, - - - update_time = #{autoMlIns.updateTime}, - - - finish_time = #{autoMlIns.finishTime}, - - - where id = #{autoMlIns.id} - - - - - - - - - - - - \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml index 9ae12b5b..7934debb 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml @@ -2,10 +2,10 @@ - - insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name, + + insert into code_config(code_repo_name, is_public, git_url, git_branch, verify_mode, git_user_name, git_password, ssh_key, create_by, create_time, update_by, update_time) - values (#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, + values (#{codeConfig.codeRepoName}, #{codeConfig.isPublic}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword}, #{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy}, #{codeConfig.updateTime}) @@ -17,8 +17,8 @@ code_repo_name = #{codeConfig.codeRepoName}, - - code_repo_vis = #{codeConfig.codeRepoVis}, + + is_public = #{codeConfig.isPublic}, git_url = #{codeConfig.gitUrl}, @@ -78,6 +78,7 @@ state = 1 + and code_repo_vis = 1 and id = #{codeConfig.id} @@ -85,7 +86,7 @@ and code_repo_name LIKE CONCAT('%', #{codeConfig.codeRepoName}, '%') - and code_repo_vis = #{codeConfig.codeRepoVis} + and is_public = #{codeConfig.isPublic} and git_url = #{codeConfig.gitUrl} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml index dded0f7f..01dfc703 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml @@ -65,7 +65,7 @@ and state = #{devEnvironment.state} - limit #{pageable.offset}, #{pageable.pageSize} + order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml index 99ee248a..f42ec06e 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml @@ -157,24 +157,24 @@ - insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) - values (#{experiment.name},#{experiment.workflowId}, #{experiment.globalParam},#{experiment.statusList}, #{experiment.description}, #{experiment.createBy}, #{experiment.createTime}, #{experiment.updateBy}, #{experiment.updateTime}, #{experiment.state}) + insert into experiment(name,workflow_id, global_param, status_list, description, create_by, update_by, state) + values (#{experiment.name},#{experiment.workflowId}, #{experiment.globalParam},#{experiment.statusList}, #{experiment.description}, #{experiment.createBy}, #{experiment.updateBy}, #{experiment.state}) - insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) + insert into experiment(name,workflow_id, global_param, status_list, description, create_by, update_by, state) values - (#{entity.name},#{entity.workflowId}, #{entity.globalParam},#{entity.statusList}, #{entity.description}, #{entity.createBy}, #{entity.createTime}, - #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) + (#{entity.name},#{entity.workflowId}, #{entity.globalParam},#{entity.statusList}, #{entity.description}, #{entity.createBy}, + #{entity.updateBy}, #{entity.state}) - insert into experiment (id, name, workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) + insert into experiment (id, name, workflow_id, global_param, status_list, description, create_by, update_by, state) values - (#{item.id}, #{item.name}, #{item.workflowId}, #{item.globalParam}, #{item.statusList}, #{item.description}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.state}) + (#{item.id}, #{item.name}, #{item.workflowId}, #{item.globalParam}, #{item.statusList}, #{item.description}, #{item.createBy}, #{item.updateBy}, #{item.state}) ON DUPLICATE KEY UPDATE name = VALUES(name), @@ -183,9 +183,7 @@ status_list = VALUES(status_list), description = VALUES(description), create_by = VALUES(create_by), - create_time = VALUES(create_time), update_by = VALUES(update_by), - update_time = VALUES(update_time), state = VALUES(state); @@ -203,27 +201,18 @@ global_param = #{globalParam}, - - status_list = #{statusList}, - description = #{description}, - - create_by = #{createBy}, - - - create_time = #{createTime}, - update_by = #{updateBy}, - - update_time = #{updateTime}, - state = #{state}, + + status_list = #{statusList}, + where id = #{id} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnDaoMapper.xml index 8f5cfe49..d4920405 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/MachineLearnDaoMapper.xml @@ -10,7 +10,7 @@ @@ -34,15 +34,15 @@ param = #{machineLearn.param}, - - status_list = #{machineLearn.statusList}, - state = #{machineLearn.state}, update_by = #{machineLearn.updateBy}, + + status_list = #{machineLearn.statusList}, + where id = #{machineLearn.id} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml index bd0e2c77..d804630c 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/RayDaoMapper.xml @@ -25,9 +25,6 @@ dataset = #{ray.dataset}, - - model = #{ray.model}, - code_config = #{ray.codeConfig}, @@ -49,12 +46,6 @@ storage_path = #{ray.storagePath}, - - search_alg = #{ray.searchAlg}, - - - scheduler = #{ray.scheduler}, - metric = #{ray.metric}, @@ -76,12 +67,15 @@ update_by = #{ray.updateBy}, - - status_list = #{ray.statusList}, - state = #{ray.state}, + + status_list = #{ray.statusList}, + + model = #{ray.model}, + scheduler = #{ray.scheduler}, + search_alg = #{ray.searchAlg}, where id = #{ray.id} @@ -94,7 +88,7 @@ diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java index 6cd9f24d..4666b37f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysMenuController.java @@ -1,6 +1,8 @@ package com.ruoyi.system.controller; import java.util.List; + +import com.ruoyi.system.api.constant.Constant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; @@ -41,8 +43,7 @@ public class SysMenuController extends BaseController @GetMapping("/list") public AjaxResult list(SysMenu menu) { - Long userId = SecurityUtils.getUserId(); - List menus = menuService.selectMenuList(menu, userId); + List menus = menuService.selectMenuList(menu); return success(menus); } @@ -62,8 +63,7 @@ public class SysMenuController extends BaseController @GetMapping("/treeselect") public AjaxResult treeselect(SysMenu menu) { - Long userId = SecurityUtils.getUserId(); - List menus = menuService.selectMenuList(menu, userId); + List menus = menuService.selectMenuList(menu); return success(menuService.buildMenuTreeSelect(menus)); } @@ -73,8 +73,7 @@ public class SysMenuController extends BaseController @GetMapping(value = "/roleMenuTreeselect/{roleId}") public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) { - Long userId = SecurityUtils.getUserId(); - List menus = menuService.selectMenuList(userId); + List menus = menuService.selectMenuList(new SysMenu()); AjaxResult ajax = AjaxResult.success(); ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); ajax.put("menus", menuService.buildMenuTreeSelect(menus)); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index eec43c76..f399e28c 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -210,7 +210,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysUser user) throws Exception { - userService.checkUserAllowed(user); + userService.checkUserAllowed(user.getUserId()); userService.checkUserDataScope(user.getUserId()); if (!userService.checkUserNameUnique(user)) { return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); @@ -243,7 +243,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") public AjaxResult resetPwd(@RequestBody SysUser user) throws Exception { - userService.checkUserAllowed(user); + userService.checkUserAllowed(user.getUserId()); userService.checkUserDataScope(user.getUserId()); return toAjax(userService.resetPwd(user)); } @@ -255,7 +255,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") public AjaxResult changeStatus(@RequestBody SysUser user) { - userService.checkUserAllowed(user); + userService.checkUserAllowed(user.getUserId()); userService.checkUserDataScope(user.getUserId()); user.setUpdateBy(SecurityUtils.getUsername()); return toAjax(userService.updateUserStatus(user)); @@ -271,7 +271,7 @@ public class SysUserController extends BaseController { SysUser user = userService.selectUserById(userId); List roles = roleService.selectRolesByUserId(userId); ajax.put("user", user); - ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); + ajax.put("roles", roles); return ajax; } @@ -282,6 +282,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.GRANT) @PutMapping("/authRole/{userId}") public AjaxResult insertAuthRole(@PathVariable("userId") Long userId, @RequestBody Long[] roleIds) { + userService.checkUserAllowed(userId); userService.checkUserDataScope(userId); userService.insertUserAuth(userId, roleIds); return success(); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java index 4de94195..05206080 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java @@ -13,13 +13,6 @@ import com.ruoyi.system.domain.vo.TreeSelect; */ public interface ISysMenuService { - /** - * 根据用户查询系统菜单列表 - * - * @param userId 用户ID - * @return 菜单列表 - */ - public List selectMenuList(Long userId); /** * 根据用户查询系统菜单列表 @@ -28,7 +21,7 @@ public interface ISysMenuService * @param userId 用户ID * @return 菜单列表 */ - public List selectMenuList(SysMenu menu, Long userId); + public List selectMenuList(SysMenu menu); /** * 根据用户ID查询权限 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index fe791ef2..62d0d1e8 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -89,6 +89,11 @@ public interface ISysRoleService */ public void checkRoleDataScope(Long roleId); + + public Boolean checkIsAdmin(); + + public Boolean checkIsAdmin(Long userId); + /** * 通过角色ID查询角色使用数量 * diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 2e76ee11..89c896fd 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -96,7 +96,7 @@ public interface ISysUserService * * @param user 用户信息 */ - public void checkUserAllowed(SysUser user); + public void checkUserAllowed(Long userId); /** * 校验用户是否有数据权限 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index d6e9722e..6fdf862a 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -190,8 +190,8 @@ public class SysDeptServiceImpl implements ISysDeptService @Override public void checkDeptDataScope(Long deptId) { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { +// if (!SysUser.isAdmin(SecurityUtils.getUserId())) +// { SysDept dept = new SysDept(); dept.setDeptId(deptId); List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); @@ -199,7 +199,7 @@ public class SysDeptServiceImpl implements ISysDeptService { throw new ServiceException("没有权限访问部门数据!"); } - } +// } } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index 9c32219e..a7fecdd2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -8,6 +8,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; + +import com.ruoyi.system.api.constant.Constant; +import com.ruoyi.system.service.ISysRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.Constants; @@ -27,12 +30,11 @@ import com.ruoyi.system.service.ISysMenuService; /** * 菜单 业务层处理 - * + * * @author ruoyi */ @Service -public class SysMenuServiceImpl implements ISysMenuService -{ +public class SysMenuServiceImpl implements ISysMenuService { public static final String PREMISSION_STRING = "perms[\"{0}\"]"; @Autowired @@ -44,36 +46,23 @@ public class SysMenuServiceImpl implements ISysMenuService @Autowired private SysRoleMenuMapper roleMenuMapper; - /** - * 根据用户查询系统菜单列表 - * - * @param userId 用户ID - * @return 菜单列表 - */ - @Override - public List selectMenuList(Long userId) - { - return selectMenuList(new SysMenu(), userId); - } + @Autowired + private ISysRoleService sysRoleService; /** * 查询系统菜单列表 - * + * * @param menu 菜单信息 * @return 菜单列表 */ @Override - public List selectMenuList(SysMenu menu, Long userId) - { - List menuList = null; + public List selectMenuList(SysMenu menu) { + List menuList; // 管理员显示所有菜单信息 - if (SysUser.isAdmin(userId)) - { + if (sysRoleService.checkIsAdmin()) { menuList = menuMapper.selectMenuList(menu); - } - else - { - menu.getParams().put("userId", userId); + } else { + menu.getParams().put("userId", SecurityUtils.getUserId()); menuList = menuMapper.selectMenuListByUserId(menu); } return menuList; @@ -81,19 +70,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @Override - public Set selectMenuPermsByUserId(Long userId) - { + public Set selectMenuPermsByUserId(Long userId) { List perms = menuMapper.selectMenuPermsByUserId(userId); Set permsSet = new HashSet<>(); - for (String perm : perms) - { - if (StringUtils.isNotEmpty(perm)) - { + for (String perm : perms) { + if (StringUtils.isNotEmpty(perm)) { permsSet.addAll(Arrays.asList(perm.trim().split(","))); } } @@ -102,19 +88,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据角色ID查询权限 - * + * * @param roleId 角色ID * @return 权限列表 */ @Override - public Set selectMenuPermsByRoleId(Long roleId) - { + public Set selectMenuPermsByRoleId(Long roleId) { List perms = menuMapper.selectMenuPermsByRoleId(roleId); Set permsSet = new HashSet<>(); - for (String perm : perms) - { - if (StringUtils.isNotEmpty(perm)) - { + for (String perm : perms) { + if (StringUtils.isNotEmpty(perm)) { permsSet.addAll(Arrays.asList(perm.trim().split(","))); } } @@ -123,50 +106,43 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 根据用户ID查询菜单 - * + * * @param userId 用户名称 * @return 菜单列表 */ @Override - public List selectMenuTreeByUserId(Long userId) - { - List menus = null; - if (SecurityUtils.isAdmin(userId)) - { - menus = menuMapper.selectMenuTreeAll(); - } - else - { + public List selectMenuTreeByUserId(Long userId) { + List menus; +// if (sysRoleService.checkIsAdmin()) { +// menus = menuMapper.selectMenuTreeAll(); +// } else { menus = menuMapper.selectMenuTreeByUserId(userId); - } +// } return getChildPerms(menus, 0); } /** * 根据角色ID查询菜单树信息 - * + * * @param roleId 角色ID * @return 选中菜单列表 */ @Override - public List selectMenuListByRoleId(Long roleId) - { + public List selectMenuListByRoleId(Long roleId) { SysRole role = roleMapper.selectRoleById(roleId); return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); } /** * 构建前端路由所需要的菜单 - * + * * @param menus 菜单列表 * @return 路由列表 */ @Override - public List buildMenus(List menus) - { + public List buildMenus(List menus) { List routers = new LinkedList(); - for (SysMenu menu : menus) - { + for (SysMenu menu : menus) { RouterVo router = new RouterVo(); router.setHidden("1".equals(menu.getVisible())); router.setName(getRouteName(menu)); @@ -175,14 +151,11 @@ public class SysMenuServiceImpl implements ISysMenuService router.setQuery(menu.getQuery()); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); List cMenus = menu.getChildren(); - if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) - { + if (StringUtils.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) { router.setAlwaysShow(true); router.setRedirect("noRedirect"); router.setChildren(buildMenus(cMenus)); - } - else if (isMenuFrame(menu)) - { + } else if (isMenuFrame(menu)) { router.setMeta(null); List childrenList = new ArrayList(); RouterVo children = new RouterVo(); @@ -193,9 +166,7 @@ public class SysMenuServiceImpl implements ISysMenuService children.setQuery(menu.getQuery()); childrenList.add(children); router.setChildren(childrenList); - } - else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) - { + } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) { router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); router.setPath("/"); List childrenList = new ArrayList(); @@ -215,27 +186,23 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 构建前端所需要树结构 - * + * * @param menus 菜单列表 * @return 树结构列表 */ @Override - public List buildMenuTree(List menus) - { + public List buildMenuTree(List menus) { List returnList = new ArrayList(); List tempList = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); - for (Iterator iterator = menus.iterator(); iterator.hasNext();) - { + for (Iterator iterator = menus.iterator(); iterator.hasNext(); ) { SysMenu menu = (SysMenu) iterator.next(); // 如果是顶级节点, 遍历该父节点的所有子节点 - if (!tempList.contains(menu.getParentId())) - { + if (!tempList.contains(menu.getParentId())) { recursionFn(menus, menu); returnList.add(menu); } } - if (returnList.isEmpty()) - { + if (returnList.isEmpty()) { returnList = menus; } return returnList; @@ -243,104 +210,95 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 构建前端所需要下拉树结构 - * + * * @param menus 菜单列表 * @return 下拉树结构列表 */ @Override - public List buildMenuTreeSelect(List menus) - { + public List buildMenuTreeSelect(List menus) { List menuTrees = buildMenuTree(menus); return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); } /** * 根据菜单ID查询信息 - * + * * @param menuId 菜单ID * @return 菜单信息 */ @Override - public SysMenu selectMenuById(Long menuId) - { + public SysMenu selectMenuById(Long menuId) { return menuMapper.selectMenuById(menuId); } /** * 是否存在菜单子节点 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public boolean hasChildByMenuId(Long menuId) - { + public boolean hasChildByMenuId(Long menuId) { int result = menuMapper.hasChildByMenuId(menuId); return result > 0; } /** * 查询菜单使用数量 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public boolean checkMenuExistRole(Long menuId) - { + public boolean checkMenuExistRole(Long menuId) { int result = roleMenuMapper.checkMenuExistRole(menuId); return result > 0; } /** * 新增保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public int insertMenu(SysMenu menu) - { + public int insertMenu(SysMenu menu) { return menuMapper.insertMenu(menu); } /** * 修改保存菜单信息 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public int updateMenu(SysMenu menu) - { + public int updateMenu(SysMenu menu) { return menuMapper.updateMenu(menu); } /** * 删除菜单管理信息 - * + * * @param menuId 菜单ID * @return 结果 */ @Override - public int deleteMenuById(Long menuId) - { + public int deleteMenuById(Long menuId) { return menuMapper.deleteMenuById(menuId); } /** * 校验菜单名称是否唯一 - * + * * @param menu 菜单信息 * @return 结果 */ @Override - public boolean checkMenuNameUnique(SysMenu menu) - { + public boolean checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); - if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -348,16 +306,14 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取路由名称 - * + * * @param menu 菜单信息 * @return 路由名称 */ - public String getRouteName(SysMenu menu) - { + public String getRouteName(SysMenu menu) { String routerName = StringUtils.capitalize(menu.getPath()); // 非外链并且是一级目录(类型为目录) - if (isMenuFrame(menu)) - { + if (isMenuFrame(menu)) { routerName = StringUtils.EMPTY; } return routerName; @@ -365,27 +321,23 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取路由地址 - * + * * @param menu 菜单信息 * @return 路由地址 */ - public String getRouterPath(SysMenu menu) - { + public String getRouterPath(SysMenu menu) { String routerPath = menu.getPath(); // 内链打开外网方式 - if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) - { + if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) { routerPath = innerLinkReplaceEach(routerPath); } // 非外链并且是一级目录(类型为目录) if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) - && UserConstants.NO_FRAME.equals(menu.getIsFrame())) - { + && UserConstants.NO_FRAME.equals(menu.getIsFrame())) { routerPath = "/" + menu.getPath(); } // 非外链并且是一级目录(类型为菜单) - else if (isMenuFrame(menu)) - { + else if (isMenuFrame(menu)) { routerPath = "/"; } return routerPath; @@ -393,23 +345,17 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 获取组件信息 - * + * * @param menu 菜单信息 * @return 组件信息 */ - public String getComponent(SysMenu menu) - { + public String getComponent(SysMenu menu) { String component = UserConstants.LAYOUT; - if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) - { + if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) { component = menu.getComponent(); - } - else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) - { + } else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) { component = UserConstants.INNER_LINK; - } - else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) - { + } else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) { component = UserConstants.PARENT_VIEW; } return component; @@ -417,54 +363,48 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 是否为菜单内部跳转 - * + * * @param menu 菜单信息 * @return 结果 */ - public boolean isMenuFrame(SysMenu menu) - { + public boolean isMenuFrame(SysMenu menu) { return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType()) && menu.getIsFrame().equals(UserConstants.NO_FRAME); } /** * 是否为内链组件 - * + * * @param menu 菜单信息 * @return 结果 */ - public boolean isInnerLink(SysMenu menu) - { + public boolean isInnerLink(SysMenu menu) { return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.ishttp(menu.getPath()); } /** * 是否为parent_view组件 - * + * * @param menu 菜单信息 * @return 结果 */ - public boolean isParentView(SysMenu menu) - { + public boolean isParentView(SysMenu menu) { return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()); } /** * 根据父节点的ID获取所有子节点 - * - * @param list 分类表 + * + * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ - public List getChildPerms(List list, int parentId) - { + public List getChildPerms(List list, int parentId) { List returnList = new ArrayList(); - for (Iterator iterator = list.iterator(); iterator.hasNext();) - { + for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { SysMenu t = (SysMenu) iterator.next(); // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 - if (t.getParentId() == parentId) - { + if (t.getParentId() == parentId) { recursionFn(list, t); returnList.add(t); } @@ -474,19 +414,16 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 递归列表 - * + * * @param list 分类表 - * @param t 子节点 + * @param t 子节点 */ - private void recursionFn(List list, SysMenu t) - { + private void recursionFn(List list, SysMenu t) { // 得到子节点列表 List childList = getChildList(list, t); t.setChildren(childList); - for (SysMenu tChild : childList) - { - if (hasChild(list, tChild)) - { + for (SysMenu tChild : childList) { + if (hasChild(list, tChild)) { recursionFn(list, tChild); } } @@ -495,15 +432,12 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 得到子节点列表 */ - private List getChildList(List list, SysMenu t) - { + private List getChildList(List list, SysMenu t) { List tlist = new ArrayList(); Iterator it = list.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); - if (n.getParentId().longValue() == t.getMenuId().longValue()) - { + if (n.getParentId().longValue() == t.getMenuId().longValue()) { tlist.add(n); } } @@ -513,19 +447,17 @@ public class SysMenuServiceImpl implements ISysMenuService /** * 判断是否有子节点 */ - private boolean hasChild(List list, SysMenu t) - { + private boolean hasChild(List list, SysMenu t) { return getChildList(list, t).size() > 0; } /** * 内链域名特殊字符替换 - * + * * @return 替换后的内链域名 */ - public String innerLinkReplaceEach(String path) - { - return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" }, - new String[] { "", "", "", "/", "/" }); + public String innerLinkReplaceEach(String path) { + return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"}, + new String[]{"", "", "", "/", "/"}); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java index ffc794ed..b24fa66b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPermissionServiceImpl.java @@ -3,6 +3,8 @@ package com.ruoyi.system.service.impl; import java.util.HashSet; import java.util.List; import java.util.Set; + +import com.ruoyi.system.api.constant.Constant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -14,7 +16,7 @@ import com.ruoyi.system.service.ISysRoleService; /** * 用户权限处理 - * + * * @author ruoyi */ @Service @@ -28,7 +30,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService /** * 获取角色数据权限 - * + * * @param userId 用户Id * @return 角色权限信息 */ @@ -37,9 +39,9 @@ public class SysPermissionServiceImpl implements ISysPermissionService { Set roles = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) + if (roleService.checkIsAdmin(user.getUserId())) { - roles.add("admin"); + roles.add(Constant.Admin); } else { @@ -50,7 +52,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService /** * 获取菜单数据权限 - * + * * @param userId 用户Id * @return 菜单权限信息 */ @@ -59,7 +61,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService { Set perms = new HashSet(); // 管理员拥有所有权限 - if (user.isAdmin()) + if (roleService.checkIsAdmin(user.getUserId())) { perms.add("*:*:*"); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 8b34e5c4..97c02cd9 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -5,7 +5,11 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; + +import com.ruoyi.system.api.constant.Constant; +import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.core.constant.UserConstants; @@ -27,12 +31,11 @@ import com.ruoyi.system.service.ISysRoleService; /** * 角色 业务层处理 - * + * * @author ruoyi */ @Service -public class SysRoleServiceImpl implements ISysRoleService -{ +public class SysRoleServiceImpl implements ISysRoleService { @Autowired private SysRoleMapper roleMapper; @@ -45,36 +48,34 @@ public class SysRoleServiceImpl implements ISysRoleService @Autowired private SysRoleDeptMapper roleDeptMapper; + @Autowired + @Lazy + private ISysUserService userService; /** * 根据条件分页查询角色数据 - * + * * @param role 角色信息 * @return 角色数据集合信息 */ @Override @DataScope(deptAlias = "d") - public List selectRoleList(SysRole role) - { + public List selectRoleList(SysRole role) { return roleMapper.selectRoleList(role); } /** * 根据用户ID查询角色 - * + * * @param userId 用户ID * @return 角色列表 */ @Override - public List selectRolesByUserId(Long userId) - { + public List selectRolesByUserId(Long userId) { List userRoles = roleMapper.selectRolePermissionByUserId(userId); List roles = selectRoleAll(); - for (SysRole role : roles) - { - for (SysRole userRole : userRoles) - { - if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) - { + for (SysRole role : roles) { + for (SysRole userRole : userRoles) { + if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { role.setFlag(true); break; } @@ -85,19 +86,16 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @Override - public Set selectRolePermissionByUserId(Long userId) - { + public Set selectRolePermissionByUserId(Long userId) { List perms = roleMapper.selectRolePermissionByUserId(userId); Set permsSet = new HashSet<>(); - for (SysRole perm : perms) - { - if (StringUtils.isNotNull(perm)) - { + for (SysRole perm : perms) { + if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } @@ -106,52 +104,47 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 查询所有角色 - * + * * @return 角色列表 */ @Override - public List selectRoleAll() - { + public List selectRoleAll() { return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); } /** * 根据用户ID获取角色选择框列表 - * + * * @param userId 用户ID * @return 选中角色ID列表 */ @Override - public List selectRoleListByUserId(Long userId) - { + public List selectRoleListByUserId(Long userId) { return roleMapper.selectRoleListByUserId(userId); } /** * 通过角色ID查询角色 - * + * * @param roleId 角色ID * @return 角色对象信息 */ @Override - public SysRole selectRoleById(Long roleId) - { + public SysRole selectRoleById(Long roleId) { return roleMapper.selectRoleById(roleId); } /** * 校验角色名称是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public boolean checkRoleNameUnique(SysRole role) - { + public boolean checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -159,17 +152,15 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 校验角色权限是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public boolean checkRoleKeyUnique(SysRole role) - { + public boolean checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -177,60 +168,68 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 校验角色是否允许操作 - * + * * @param role 角色信息 */ @Override - public void checkRoleAllowed(SysRole role) - { - if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) - { + public void checkRoleAllowed(SysRole role) { + Set roles = SecurityUtils.getLoginUser().getRoles(); + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin() && !roles.contains(Constant.Admin)) { throw new ServiceException("不允许操作超级管理员角色"); } } /** * 校验角色是否有数据权限 - * + * * @param roleId 角色id */ @Override - public void checkRoleDataScope(Long roleId) - { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { + public void checkRoleDataScope(Long roleId) { + if (!checkIsAdmin()) { SysRole role = new SysRole(); role.setRoleId(roleId); List roles = SpringUtils.getAopProxy(this).selectRoleList(role); - if (StringUtils.isEmpty(roles)) - { + if (StringUtils.isEmpty(roles)) { throw new ServiceException("没有权限访问角色数据!"); } } } + public Boolean checkIsAdmin() { + return SecurityUtils.getLoginUser().getRoles().contains(Constant.Admin); + } + + public Boolean checkIsAdmin(Long userId) { + List sysRoles = roleMapper.selectRolePermissionByUserId(userId); + for (SysRole role : sysRoles) { + if (role.isAdmin()) { + return true; + } + } + return false; + } + /** * 通过角色ID查询角色使用数量 - * + * * @param roleId 角色ID * @return 结果 */ @Override - public int countUserRoleByRoleId(Long roleId) - { + public int countUserRoleByRoleId(Long roleId) { return userRoleMapper.countUserRoleByRoleId(roleId); } /** * 新增保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int insertRole(SysRole role) - { + public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); @@ -238,14 +237,13 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 修改保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int updateRole(SysRole role) - { + public int updateRole(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与菜单关联 @@ -255,26 +253,24 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 修改角色状态 - * + * * @param role 角色信息 * @return 结果 */ @Override - public int updateRoleStatus(SysRole role) - { + public int updateRoleStatus(SysRole role) { return roleMapper.updateRole(role); } /** * 修改数据权限信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int authDataScope(SysRole role) - { + public int authDataScope(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与部门关联 @@ -285,23 +281,20 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 新增角色菜单信息 - * + * * @param role 角色对象 */ - public int insertRoleMenu(SysRole role) - { + public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List list = new ArrayList(); - for (Long menuId : role.getMenuIds()) - { + for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; @@ -312,20 +305,17 @@ public class SysRoleServiceImpl implements ISysRoleService * * @param role 角色对象 */ - public int insertRoleDept(SysRole role) - { + public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List list = new ArrayList(); - for (Long deptId : role.getDeptIds()) - { + for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; @@ -333,14 +323,13 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 通过角色ID删除角色 - * + * * @param roleId 角色ID * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleById(Long roleId) - { + public int deleteRoleById(Long roleId) { // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(roleId); // 删除角色与部门关联 @@ -350,21 +339,18 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 批量删除角色信息 - * + * * @param roleIds 需要删除的角色ID * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleByIds(Long[] roleIds) - { - for (Long roleId : roleIds) - { + public int deleteRoleByIds(Long[] roleIds) { + for (Long roleId : roleIds) { checkRoleAllowed(new SysRole(roleId)); checkRoleDataScope(roleId); SysRole role = selectRoleById(roleId); - if (countUserRoleByRoleId(roleId) > 0) - { + if (countUserRoleByRoleId(roleId) > 0) { throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } @@ -377,43 +363,45 @@ public class SysRoleServiceImpl implements ISysRoleService /** * 取消授权用户角色 - * + * * @param userRole 用户和角色关联信息 * @return 结果 */ @Override - public int deleteAuthUser(SysUserRole userRole) - { + public int deleteAuthUser(SysUserRole userRole) { + checkRoleAllowed(roleMapper.selectRoleById(userRole.getRoleId())); + userService.checkUserAllowed(userRole.getUserId()); return userRoleMapper.deleteUserRoleInfo(userRole); } /** * 批量取消授权用户角色 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param userIds 需要取消授权的用户数据ID * @return 结果 */ @Override - public int deleteAuthUsers(Long roleId, Long[] userIds) - { + public int deleteAuthUsers(Long roleId, Long[] userIds) { + checkRoleAllowed(roleMapper.selectRoleById(roleId)); + for (Long userId : userIds) { + userService.checkUserAllowed(userId); + } return userRoleMapper.deleteUserRoleInfos(roleId, userIds); } /** * 批量选择授权用户角色 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param userIds 需要授权的用户数据ID * @return 结果 */ @Override - public int insertAuthUsers(Long roleId, Long[] userIds) - { + public int insertAuthUsers(Long roleId, Long[] userIds) { // 新增用户与角色管理 List list = new ArrayList(); - for (Long userId : userIds) - { + for (Long userId : userIds) { SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 7e963223..26e95645 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -20,6 +20,7 @@ import com.ruoyi.system.domain.SysUserPost; import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,6 +75,9 @@ public class SysUserServiceImpl implements ISysUserService { @Autowired private TokenService tokenService; + @Autowired + private ISysRoleService roleService; + /** * 根据条件分页查询用户列表 * @@ -216,8 +220,8 @@ public class SysUserServiceImpl implements ISysUserService { * @param user 用户信息 */ @Override - public void checkUserAllowed(SysUser user) { - if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin() && !SecurityUtils.getUserId().equals(user.getUserId())) { + public void checkUserAllowed(Long userId) { + if (StringUtils.isNotNull(userId) && roleService.checkIsAdmin(userId) && !SecurityUtils.getUserId().equals(userId)) { throw new ServiceException("不允许操作超级管理员用户"); } } @@ -229,7 +233,7 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public void checkUserDataScope(Long userId) { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) { + if (!roleService.checkIsAdmin()) { SysUser user = new SysUser(); user.setUserId(userId); List users = SpringUtils.getAopProxy(this).selectUserList(user); @@ -518,7 +522,7 @@ public class SysUserServiceImpl implements ISysUserService { @Transactional(rollbackFor = Exception.class) public int deleteUserByIds(Long[] userIds) throws Exception { for (Long userId : userIds) { - checkUserAllowed(new SysUser(userId)); + checkUserAllowed(userId); checkUserDataScope(userId); } // 删除用户与角色关联 @@ -576,7 +580,7 @@ public class SysUserServiceImpl implements ISysUserService { successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); } else if (isUpdateSupport) { BeanValidators.validateWithException(validator, user); - checkUserAllowed(u); + checkUserAllowed(u.getUserId()); checkUserDataScope(u.getUserId()); user.setUserId(u.getUserId()); user.setUpdateBy(operName);