Compare commits
11 Commits
1cf3944744
...
nh
Author | SHA1 | Date | |
---|---|---|---|
f18c4e4159 | |||
cf2eb689ca | |||
b926506ede | |||
0aff6e71ff | |||
94bfc4cc70 | |||
158fdca6e0 | |||
92b470e001 | |||
49851384c8 | |||
0619c7d184 | |||
5dd1cfcf9e | |||
77a4b86cb4 |
66
pom.xml
66
pom.xml
@ -38,7 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>2022.0.0.0</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
||||
<version>2022.0.0.0-RC2</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@ -59,19 +59,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.hibernate</groupId>-->
|
||||
<!-- <artifactId>hibernate-core</artifactId>-->
|
||||
<!-- <version>6.4.5.Final</version> <!– 推荐稳定版本:ml-citation{ref="5,8" data="citationList"} –>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.jboss.logging</groupId> <!– 常见冲突源:ml-citation{ref="7" data="citationList"} –>-->
|
||||
<!-- <artifactId>jboss-logging</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 数据库驱动 -->
|
||||
|
||||
<!-- 数据库驱动 -->
|
||||
<dependency>
|
||||
@ -116,10 +103,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试依赖 -->
|
||||
<dependency>
|
||||
@ -138,24 +121,11 @@
|
||||
<version>3.0.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.hibernate.javax.persistence</groupId>-->
|
||||
<!-- <artifactId>hibernate-jpa-2.1-api</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@ -172,7 +142,15 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<exclusions>
|
||||
<!-- 排除 RabbitMQ 自动配置 -->
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
@ -187,6 +165,30 @@
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--阿里OSS依赖-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
<!--如果使用的是Java 9及以上的版本,则需要添加JAXB相关依赖。添加JAXB相关依赖-->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- no more than 2.3.3-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version> <!-- 注意:版本不超过2.3.3 -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.properties.AliOssProperties;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.AliOssUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/*
|
||||
* 配置类,用于创建阿里云文件上传工具类对象
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class OssConfiguration {
|
||||
private final AliOssProperties aliOssProperties;
|
||||
public OssConfiguration(AliOssProperties aliOssProperties) {
|
||||
this.aliOssProperties = aliOssProperties;
|
||||
}
|
||||
@Bean
|
||||
public AliOssUtil aliOssUtil(){
|
||||
log.info("开始创建阿里云文件上传工具类对象...");
|
||||
return new AliOssUtil(
|
||||
aliOssProperties.getEndpoint(),
|
||||
aliOssProperties.getAccessKeyId(),
|
||||
aliOssProperties.getAccessKeySecret(),
|
||||
aliOssProperties.getBucketName());
|
||||
}
|
||||
}
|
@ -10,5 +10,10 @@ public class MessageConstant {
|
||||
public static final String ERROR_DEPLOYED_TO_DESIGNING = "已部署的模型不能直接调整成设计,需先下线再设计";
|
||||
public static final String ERROR_ABANDONED_CANNOT_UPDATE = "已废弃的模型只能查看信息,不能更新生命周期";
|
||||
public static final String ERROR_TRAINING_INVALID_TRANSITION = "训练中的模型只能调整成设计和评估";
|
||||
public static final String UPDATE_FAILURE = "更新模型生命周期失败";
|
||||
public static final String LIFECYCLE_UPDATE_FAILURE = "更新模型生命周期失败";
|
||||
public static final String LIFECYCLE_UPDATE_SUCCESS = "生命周期更新成功";
|
||||
|
||||
//文件上传常量
|
||||
public static final String UPLOAD_FAILURE = "上传文件失败";
|
||||
public static final String FILE_EMPTY= "文件为空";
|
||||
}
|
||||
|
@ -1,15 +1,20 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="算法创建相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/algorithm")
|
||||
@Slf4j
|
||||
public class AlgorithmInfoController {
|
||||
|
||||
@Autowired
|
||||
@ -57,4 +62,16 @@ public class AlgorithmInfoController {
|
||||
ResponseEntity.ok("Delete successful") :
|
||||
ResponseEntity.badRequest().body("Delete failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* 算法创建
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary ="算法创建")
|
||||
public OptResult save(@RequestBody AlgorithmInfo algorithmInfo){
|
||||
log.info("新增算法",algorithmInfo);
|
||||
algorithmInfoService.save(algorithmInfo);
|
||||
return OptResult.success("算法创建成功");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.AliOssUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/common")
|
||||
@Tag(name = "通用接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class CommonController {
|
||||
@Autowired
|
||||
private AliOssUtil aliOssUtil;
|
||||
// 默认上传的文件夹
|
||||
private static final String DEFAULT_FOLDER= "File/";
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "文件上传")
|
||||
@PostMapping("/upload")
|
||||
public OptResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
log.info("收到上传请求");
|
||||
if (file.isEmpty()){
|
||||
return OptResult.error(MessageConstant.FILE_EMPTY);
|
||||
}
|
||||
try {
|
||||
// 1.生成唯一文件名
|
||||
String originalFilename = file.getOriginalFilename(); // 原始文件名
|
||||
log.info("原始文件名:{}", originalFilename);
|
||||
String fileSuffix = originalFilename.substring(originalFilename.lastIndexOf(".")); // 文件后缀
|
||||
log.info("文件后缀:{}", fileSuffix);
|
||||
String fileName = UUID.randomUUID().toString() + fileSuffix; // 唯一文件名
|
||||
log.info("唯一文件名:{}", fileName);
|
||||
// 2.构建oss存储路径
|
||||
String objectName = DEFAULT_FOLDER + fileName;
|
||||
// 3.调用工具类上传文件
|
||||
String fileUrl = aliOssUtil.upload(file.getInputStream(), objectName);
|
||||
// 4.返回文件URL
|
||||
return OptResult.success(fileUrl);
|
||||
} catch (Exception e) {
|
||||
log.error(MessageConstant.UPLOAD_FAILURE +":{}", e.getMessage(), e);
|
||||
return OptResult.error(MessageConstant.UPLOAD_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,12 +7,10 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "模型评估相关接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
@RestController
|
||||
@RequestMapping("/evaluation")
|
||||
@Slf4j
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ModelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -52,14 +53,16 @@ public class ModelController {
|
||||
}
|
||||
|
||||
@Operation(summary = "模型更新")
|
||||
@PutMapping("/updateModel")
|
||||
public OptResult updateModel(@RequestBody ModelVersionDTO dto){
|
||||
log.info("模型更新");
|
||||
@PutMapping("/updateModel/{id}")
|
||||
public OptResult updateModel(@PathVariable("id") Long id, @RequestBody ModelVersionDTO dto) {
|
||||
log.info("模型更新,id: {}", id);
|
||||
dto.setId(id);
|
||||
modelService.updateModel(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "模型版本删除")
|
||||
@DeleteMapping("/deleteModelVersion")
|
||||
public OptResult deleteModelVersion(Long id){
|
||||
@ -70,10 +73,18 @@ public class ModelController {
|
||||
|
||||
@Operation(summary = "更新生命周期")
|
||||
@PutMapping("/updateLifeCycle")
|
||||
public OptResult updateLifeCycle(Long id,String lifeCycle){
|
||||
public OptResult updateLifeCycle(@RequestParam Long id, @RequestParam String lifeCycle){
|
||||
log.info("更新生命周期");
|
||||
modelService.updateLifeCycle(id,lifeCycle);
|
||||
return OptResult.success();
|
||||
try {
|
||||
modelService.updateLifeCycle(id,lifeCycle);
|
||||
return OptResult.success(MessageConstant.LIFECYCLE_UPDATE_SUCCESS);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (Exception e){
|
||||
return OptResult.error(MessageConstant.UNKNOWN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "查询生命周期列表")
|
||||
|
@ -21,8 +21,6 @@ public class PublishController {
|
||||
@Autowired
|
||||
private PublishService publishService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private NacosServiceUtil nacosServiceUtil;
|
||||
|
||||
|
@ -74,13 +74,16 @@ public class ServiceAPIController {
|
||||
return OptResult.success("资源释放成功");
|
||||
}
|
||||
|
||||
@PostMapping("/request")
|
||||
@PostMapping("/request/{modelId}")
|
||||
@Operation(summary = "请求调度")
|
||||
@Transactional
|
||||
public OptResult schedule(@PathVariable Long modelId) {
|
||||
// 1. 存储modelConfig到缓存
|
||||
String modelConfig = serviceAPIService.getByModelId(modelId);
|
||||
int requestMemorySize = parseGpuMemorySize(modelConfig);
|
||||
if (requestMemorySize == -1){
|
||||
return OptResult.error("解析配置失败,请检查模型:" + modelId +"是否存在");
|
||||
}
|
||||
String modelConfigKey = "modelConfig:" + modelId;
|
||||
redisTemplate.opsForValue().set(modelConfigKey, modelConfig);
|
||||
// 2. 获取Nacos实例IP列表
|
||||
|
@ -15,16 +15,12 @@ public class ApiRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
|
||||
// 检查请求路径和方法
|
||||
if (request.getURI().getPath().equals("/request") &&
|
||||
if (request.getURI().getPath().equals("/request/{id}") &&
|
||||
request.getMethod() == HttpMethod.POST) {
|
||||
|
||||
// 在此处添加拦截逻辑
|
||||
System.out.println("拦截到POST /request请求");
|
||||
|
||||
}
|
||||
|
||||
// 继续处理请求
|
||||
return chain.filter(exchange);
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AlgorithmInfo {
|
||||
private Long id;
|
||||
private String algorithmName;
|
||||
|
@ -11,7 +11,7 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelVersionDTO {
|
||||
private Long id; // 模型id
|
||||
private Long id; // 模型版本id
|
||||
private String version; // 模型版本
|
||||
private Integer datasetId; // 数据集id
|
||||
private String modelConfig; // 模型配置信息
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -18,6 +19,7 @@ public class ServicePublishDTO implements Serializable {
|
||||
private Long id;
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
private String ip;
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "aliyun.oss") // 读取以 aliyun.oss 开头的配置
|
||||
public class AliOssProperties {
|
||||
private String endpoint;
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private String bucketName;
|
||||
}
|
||||
|
@ -11,4 +11,7 @@ public interface AlgorithmInfoService {
|
||||
boolean update(AlgorithmInfo algorithmInfo);
|
||||
boolean delete(Long id);
|
||||
boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo);
|
||||
}
|
||||
|
||||
void save(AlgorithmInfo algorithmInfo);
|
||||
|
||||
}
|
@ -60,4 +60,23 @@ public class AlgorithmInfoServiceImpl implements AlgorithmInfoService {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 算法创建
|
||||
* @param algorithmInfo
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AlgorithmInfo algorithmInfo) {
|
||||
String algorithmName = algorithmInfo.getAlgorithmName();
|
||||
//查找表里是否有重复的算法,如果有则报错
|
||||
AlgorithmInfo duplicateName = algorithmInfoMapper.selectByName(algorithmName);
|
||||
if (duplicateName != null){
|
||||
throw new RuntimeException("算法已存在");
|
||||
}
|
||||
//todo 算法文件分布式存入分布式存储中
|
||||
|
||||
|
||||
algorithmInfoMapper.insert(algorithmInfo);
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
modelVersion.setModelId(modelInfo.getId());
|
||||
modelVersion.setCreateTime(LocalDateTime.now());
|
||||
modelVersion.setUpdateTime(LocalDateTime.now());
|
||||
modelVersion.setOperateUser("zs");
|
||||
modelVersion.setOperateUser("zs"); //这里的写死的,后续需要修改,应该是当前登录用户的id
|
||||
modelMapper.insertModelVersion(modelVersion);
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
|
||||
@Override
|
||||
public void updateModel(ModelVersionDTO dto) {
|
||||
// 更新模型还需要更新操作人和时间
|
||||
log.info("更新模型");
|
||||
modelMapper.update(dto);
|
||||
}
|
||||
@ -110,14 +111,14 @@ public class ModelServiceImpl implements ModelService {
|
||||
ModelLifecycle currentLifeCycle;
|
||||
ModelLifecycle targetLifeCycle;
|
||||
try {
|
||||
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
|
||||
targetLifeCycle = ModelLifecycle.fromDescription((lifeCycleDescription).trim()); // 前端传中文
|
||||
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
|
||||
targetLifeCycle = ModelLifecycle.valueOf(lifeCycleDescription.trim()); // 前端传英文代码,直接转换
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error(MessageConstant.LifeCycle_Undefined + ":{}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 2. 业务逻辑校验
|
||||
// 2. 业务逻辑校验(保持不变)
|
||||
switch (currentLifeCycle) {
|
||||
case DEPLOYED:
|
||||
if (targetLifeCycle == ModelLifecycle.DESIGNING) {
|
||||
@ -142,7 +143,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
int affectedRows = modelMapper.updateLifeCycleById(id, targetLifeCycle.getDbValue());
|
||||
if (affectedRows == 0) {
|
||||
log.error("更新模型生命周期失败");
|
||||
throw new RuntimeException(MessageConstant.UPDATE_FAILURE);
|
||||
throw new RuntimeException(MessageConstant.LIFECYCLE_UPDATE_FAILURE);
|
||||
}
|
||||
|
||||
log.info("模型生命周期更新成功,新状态为: {}", targetLifeCycle);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.impl;
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuMapper;
|
||||
@ -9,9 +9,9 @@ import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuReso
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.enums.ErrorCodeEnum;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.vo.ResponseVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,207 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.util;
|
||||
|
||||
import com.aliyun.oss.HttpMethod;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 阿里云OSS文件操作工具类
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AliOssUtil {
|
||||
|
||||
private final String endpoint;
|
||||
private final String accessKeyId;
|
||||
private final String accessKeySecret;
|
||||
private final String bucketName;
|
||||
|
||||
/**
|
||||
* 上传文件到OSS
|
||||
* @param file 文件对象
|
||||
* @param objectName 对象名称(OSS中的路径)
|
||||
* @return 文件URL
|
||||
*/
|
||||
public String upload(File file, String objectName) {
|
||||
try (InputStream inputStream = new FileInputStream(file)) {
|
||||
return upload(inputStream, objectName);
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("上传文件到OSS失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件流到OSS
|
||||
* @param inputStream 文件流
|
||||
* @param objectName 对象名称(OSS中的路径)
|
||||
* @return 文件URL
|
||||
*/
|
||||
public String upload(InputStream inputStream, String objectName) {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
// 创建PutObject请求
|
||||
PutObjectRequest request = new PutObjectRequest(bucketName, objectName, inputStream);
|
||||
|
||||
// 设置对象元数据
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
metadata.setContentType(getContentType(objectName));
|
||||
request.setMetadata(metadata);
|
||||
|
||||
// 上传文件
|
||||
ossClient.putObject(request);
|
||||
log.info("文件上传成功: {}", objectName);
|
||||
|
||||
// 构建文件URL
|
||||
return "https://" + bucketName + "." + endpoint + "/" + objectName;
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("上传文件到OSS失败", e);
|
||||
} finally {
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成临时签名URL,用于访问私有Bucket中的文件
|
||||
* @param objectName 对象名称
|
||||
* @param expirationMinutes 过期时间(分钟)
|
||||
* @return 签名URL
|
||||
*/
|
||||
public String generatePresignedUrl(String objectName, int expirationMinutes) {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
// 设置URL过期时间
|
||||
Date expiration = new Date(System.currentTimeMillis() + expirationMinutes * 60 * 1000);
|
||||
|
||||
// 生成签名URL
|
||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.GET);
|
||||
request.setExpiration(expiration);
|
||||
|
||||
URL url = ossClient.generatePresignedUrl(request);
|
||||
log.info("生成临时签名URL: {}", url);
|
||||
return url.toString();
|
||||
} catch (Exception e) {
|
||||
log.error("生成签名URL失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("生成签名URL失败", e);
|
||||
} finally {
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件到本地
|
||||
* @param objectName 对象名称
|
||||
* @param destinationFile 目标文件
|
||||
*/
|
||||
public void download(String objectName, File destinationFile) {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
// 下载OSS文件到本地文件
|
||||
ossClient.getObject(new GetObjectRequest(bucketName, objectName), destinationFile);
|
||||
log.info("文件下载成功: {}", objectName);
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("下载文件失败", e);
|
||||
} finally {
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除OSS中的文件
|
||||
* @param objectName 对象名称
|
||||
*/
|
||||
public void delete(String objectName) {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
// 删除文件
|
||||
ossClient.deleteObject(bucketName, objectName);
|
||||
log.info("文件删除成功: {}", objectName);
|
||||
} catch (Exception e) {
|
||||
log.error("删除文件失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("删除文件失败", e);
|
||||
} finally {
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件是否存在
|
||||
* @param objectName 对象名称
|
||||
* @return 文件是否存在
|
||||
*/
|
||||
public boolean doesObjectExist(String objectName) {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
return ossClient.doesObjectExist(bucketName, objectName);
|
||||
} catch (Exception e) {
|
||||
log.error("检查文件存在失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("检查文件存在失败", e);
|
||||
} finally {
|
||||
// 关闭OSSClient
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件扩展名确定Content-Type
|
||||
* @param fileName 文件名
|
||||
* @return Content-Type
|
||||
*/
|
||||
private String getContentType(String fileName) {
|
||||
if (fileName == null) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
|
||||
return "image/jpeg";
|
||||
} else if (fileName.endsWith(".png")) {
|
||||
return "image/png";
|
||||
} else if (fileName.endsWith(".gif")) {
|
||||
return "image/gif";
|
||||
} else if (fileName.endsWith(".txt")) {
|
||||
return "text/plain";
|
||||
} else if (fileName.endsWith(".pdf")) {
|
||||
return "application/pdf";
|
||||
} else if (fileName.endsWith(".doc")) {
|
||||
return "application/msword";
|
||||
} else if (fileName.endsWith(".docx")) {
|
||||
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
} else if (fileName.endsWith(".xls")) {
|
||||
return "application/vnd.ms-excel";
|
||||
} else if (fileName.endsWith(".xlsx")) {
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
} else if (fileName.endsWith(".html") || fileName.endsWith(".htm")) {
|
||||
return "text/html";
|
||||
} else if (fileName.endsWith(".css")) {
|
||||
return "text/css";
|
||||
} else if (fileName.endsWith(".js")) {
|
||||
return "application/javascript";
|
||||
} else if (fileName.endsWith(".json")) {
|
||||
return "application/json";
|
||||
} else if (fileName.endsWith(".xml")) {
|
||||
return "application/xml";
|
||||
} else if (fileName.endsWith(".mp4")) {
|
||||
return "video/mp4";
|
||||
} else if (fileName.endsWith(".mp3")) {
|
||||
return "audio/mpeg";
|
||||
} else {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
spring.application.name=intelligent-application-orchestration-service
|
||||
|
||||
|
||||
# ?????
|
||||
# 数据库配置
|
||||
spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
|
||||
spring.datasource.username=system
|
||||
spring.datasource.password=root
|
||||
@ -10,7 +10,7 @@ spring.datasource.hikari.maximum-pool-size=10
|
||||
spring.datasource.hikari.minimum-idle=5
|
||||
spring.datasource.hikari.connection-timeout=30000
|
||||
|
||||
# MyBatis??
|
||||
# MyBatis配置
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice.pojo
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
@ -22,17 +22,32 @@ spring.data.redis.host=116.205.121.200
|
||||
spring.data.redis.port=6379
|
||||
spring.data.redis.username=default
|
||||
spring.data.redis.password=Jbjhhzstsl97@
|
||||
spring.data.redis.database=0
|
||||
spring.data.redis.timeout=3000
|
||||
spring.data.redis.ssl.enabled=false
|
||||
|
||||
# ??????
|
||||
# 服务路由配置
|
||||
spring.cloud.gateway.routes[0].id=request-service-route
|
||||
spring.cloud.gateway.routes[0].uri=lb://intelligent-application-orchestration-service
|
||||
spring.cloud.gateway.routes[0].predicates[0]=Path=/request
|
||||
|
||||
|
||||
|
||||
#SQL ????????
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
|
||||
|
||||
#SQL语句日志输出配置
|
||||
logging.level.com.bipt.intelligentapplicationorchestrationservice.mapper=DEBUG
|
||||
mybatis.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
|
||||
#spring.jpa.database-platform=org.hibernate.dialect.Kingbase8Dialect
|
||||
management.health.rabbit.enabled=false
|
||||
|
||||
# 文件上传配置
|
||||
spring.servlet.multipart.enabled=true
|
||||
spring.servlet.multipart.max-file-size=100MB
|
||||
spring.servlet.multipart.max-request-size=100MB
|
||||
|
||||
# 激活开发环境!告诉 Spring:加载 application-dev.properties 里的配置
|
||||
spring.profiles.active=dev
|
||||
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
spring.application.name=intelligent-application-orchestration-service
|
||||
|
||||
# Nacos配置中心地址(引导阶段加载配置)
|
||||
spring.cloud.nacos.config.server-addr=192.168.100.1:8848
|
||||
spring.cloud.nacos.config.server-addr=113.44.217.169:8848
|
||||
spring.cloud.nacos.config.data-id=${spring.application.name}.properties
|
||||
spring.cloud.nacos.config.group=DEFAULT_GROUP
|
||||
|
||||
# Nacos服务注册地址(引导阶段注册服务)
|
||||
spring.cloud.nacos.discovery.server-addr=192.168.100.1:8848
|
||||
spring.cloud.nacos.discovery.server-addr=113.44.217.169:8848
|
@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.EvaluationMapper">
|
||||
<!--查询模型日志详细信息-->
|
||||
<select id="selectLogDetail" resultType="ModelLogVO">
|
||||
<select id="selectLogDetail" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO">
|
||||
select m1.*,
|
||||
m2.model_name,
|
||||
m3.model_config, m3.version
|
||||
@ -18,6 +18,6 @@
|
||||
<if test="status != null">
|
||||
status=#{status}
|
||||
</if>
|
||||
where model_id=#{id}
|
||||
where id=#{id}
|
||||
</update>
|
||||
</mapper>
|
@ -19,7 +19,7 @@
|
||||
</insert>
|
||||
|
||||
<!--查询模型列表-->
|
||||
<select id="list" resultType="modelVO">
|
||||
<select id="list" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVO">
|
||||
select t1.*,
|
||||
t2.id as versionId,t2.version, t2.version, t2.data_pre_handle_file, t2.operate_user, t2.update_time,
|
||||
t2.status
|
||||
@ -29,7 +29,7 @@
|
||||
</select>
|
||||
|
||||
<!--查询模型详细信息-->
|
||||
<select id="selectById" resultType="modelVersion">
|
||||
<select id="selectById" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion">
|
||||
SELECT
|
||||
t1.model_name,
|
||||
t2.version, t2.dataset_id, t2.model_config,
|
||||
@ -44,16 +44,22 @@
|
||||
<update id="update">
|
||||
UPDATE model_version
|
||||
<set>
|
||||
<if test="modelSize != null">
|
||||
model_size = #{modelSize},
|
||||
</if>
|
||||
<if test="modelSuperArgs != null">
|
||||
model_super_args = #{modelSuperArgs},
|
||||
</if>
|
||||
<if test="modelArgsSize != null">
|
||||
model_args_size = #{modelArgsSize},
|
||||
</if>
|
||||
<if test="datasetId != null">dataset_id = #{datasetId},</if>
|
||||
<if test="modelConfig != null">model_config = #{modelConfig},</if>
|
||||
<if test="modelPath != null">model_path = #{modelPath},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="modelSize != null">model_size = #{modelSize},</if>
|
||||
<if test="dataPreHandleFile != null">data_pre_handle_file = #{dataPreHandleFile},</if>
|
||||
<if test="modelSuperArgs != null">model_super_args = #{modelSuperArgs},</if>
|
||||
<if test="modelArgsSize != null">model_args_size = #{modelArgsSize},</if>
|
||||
<if test="modelSourceCodeUrl != null">model_source_code_url = #{modelSourceCodeUrl},</if>
|
||||
<if test="modelFile != null">model_file = #{modelFile},</if>
|
||||
<if test="modelDesignDocument != null">model_design_document = #{modelDesignDocument},</if>
|
||||
<if test="lifeCycle != null">life_cycle = #{lifeCycle},</if>
|
||||
<if test="operateUser != null">operate_user = #{operateUser},</if>
|
||||
</set>
|
||||
WHERE id = #{id
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
Reference in New Issue
Block a user