Commit 68d7baf3 authored by pengxin's avatar pengxin

模型部署拆分。

parent cba217e2
package com.yice.webadmin.app.constant;
/**
* 模型管理类
*/
public class ModelConstant {
/**
* 部署状态
*/
public static final Integer DEPLOY_STATUS = 3;
}
package com.yice.webadmin.app.constant; package com.yice.webadmin.app.constant;
/**
* 插件编排常量管理类
*/
public class PluginConstant { public class PluginConstant {
/** /**
......
package com.yice.webadmin.app.controller; package com.yice.webadmin.app.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.page.PageMethod; import com.github.pagehelper.page.PageMethod;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yice.common.core.annotation.MyRequestBody; import com.yice.common.core.annotation.MyRequestBody;
...@@ -10,15 +12,18 @@ import com.yice.common.core.util.MyModelUtil; ...@@ -10,15 +12,18 @@ import com.yice.common.core.util.MyModelUtil;
import com.yice.common.core.util.MyPageUtil; import com.yice.common.core.util.MyPageUtil;
import com.yice.common.log.annotation.OperationLog; import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType; import com.yice.common.log.model.constant.SysOperationLogType;
import com.yice.webadmin.app.config.OtherConfig;
import com.yice.webadmin.app.dto.ModelInstanceDto; import com.yice.webadmin.app.dto.ModelInstanceDto;
import com.yice.webadmin.app.model.ModelInstance; import com.yice.webadmin.app.model.ModelInstance;
import com.yice.webadmin.app.service.ModelInstanceService; import com.yice.webadmin.app.service.ModelInstanceService;
import com.yice.webadmin.app.service.ProxyPythonService;
import com.yice.webadmin.app.vo.ModelInstanceVo; import com.yice.webadmin.app.vo.ModelInstanceVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -35,7 +40,10 @@ public class ModelInstanceController { ...@@ -35,7 +40,10 @@ public class ModelInstanceController {
@Autowired @Autowired
private ModelInstanceService modelInstanceService; private ModelInstanceService modelInstanceService;
@Autowired
private ProxyPythonService proxyPythonService;
@Autowired
private OtherConfig otherConfig;
/** /**
* 新增知识图谱管理数据。 * 新增知识图谱管理数据。
* *
...@@ -50,9 +58,43 @@ public class ModelInstanceController { ...@@ -50,9 +58,43 @@ public class ModelInstanceController {
if (errorMessage != null) { if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
} }
ModelInstance instance = MyModelUtil.copyTo(modelInstanceDto, ModelInstance.class);
CallResult callResult = modelInstanceService.verifyRelatedData(instance, null);
if (!callResult.isSuccess()) {
return ResponseResult.errorFrom(callResult);
}
ModelInstance filter = new ModelInstance();
filter.setVersionId(modelInstanceDto.getVersionId());
if(modelInstanceService.getCountByFilter(filter) > 0) {
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, "同一个模型只能部署一次!");
}
ModelInstance modelInstance = MyModelUtil.copyTo(modelInstanceDto, ModelInstance.class); ModelInstance modelInstance = MyModelUtil.copyTo(modelInstanceDto, ModelInstance.class);
modelInstance = modelInstanceService.saveNew(modelInstance); modelInstanceService.saveNew(modelInstance);
return ResponseResult.success(modelInstance.getDeployId()); return ResponseResult.success(modelInstance.getInstanceId());
}
/**
* 获取GPU信息。
*
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/getGpuInfo")
public ResponseResult<String> getGpuInfo() {
try {
String result = proxyPythonService.predictPost(
otherConfig.getOtherInterface() + otherConfig.getGetGpuInfo(), "");
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
if (code != null && code == 200) {
return ResponseResult.success(data);
} else {
return ResponseResult.create(ErrorCodeEnum.SERVER_INTERNAL_ERROR, msg, data);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
/** /**
...@@ -69,7 +111,7 @@ public class ModelInstanceController { ...@@ -69,7 +111,7 @@ public class ModelInstanceController {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
} }
ModelInstance modelInstance = MyModelUtil.copyTo(modelInstanceDto, ModelInstance.class); ModelInstance modelInstance = MyModelUtil.copyTo(modelInstanceDto, ModelInstance.class);
ModelInstance originalModelInstance = modelInstanceService.getById(modelInstance.getDeployId()); ModelInstance originalModelInstance = modelInstanceService.getById(modelInstance.getInstanceId());
if (originalModelInstance == null) { if (originalModelInstance == null) {
// NOTE: 修改下面方括号中的话述 // NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!"; errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
...@@ -84,16 +126,16 @@ public class ModelInstanceController { ...@@ -84,16 +126,16 @@ public class ModelInstanceController {
/** /**
* 删除知识图谱管理数据。 * 删除知识图谱管理数据。
* *
* @param deployId 删除对象主键Id。 * @param instanceId 删除对象主键Id。
* @return 应答结果对象。 * @return 应答结果对象。
*/ */
@OperationLog(type = SysOperationLogType.DELETE) @OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete") @PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long deployId) { public ResponseResult<Void> delete(@MyRequestBody Long instanceId) {
if (MyCommonUtil.existBlankArgument(deployId)) { if (MyCommonUtil.existBlankArgument(instanceId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
} }
return this.doDelete(deployId); return this.doDelete(instanceId);
} }
/** /**
......
...@@ -161,7 +161,6 @@ public class ModelServiceController { ...@@ -161,7 +161,6 @@ public class ModelServiceController {
// 验证关联Id的数据合法性 // 验证关联Id的数据合法性
ModelService originalModelService = modelServiceService.getById(serviceId); ModelService originalModelService = modelServiceService.getById(serviceId);
if (originalModelService == null) { if (originalModelService == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!"; errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
} }
......
package com.yice.webadmin.app.dao;
import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.PluginKnowledge;
import java.util.List;
/**
* 数据操作访问接口。
*
* @author linking
* @date 2023-04-13
*/
public interface PluginKnowledgeMapper extends BaseDaoMapper<PluginKnowledge> {
/**
* 批量插入对象列表。
*
* @param pluginKnowledgeList 新增对象列表。
*/
void insertList(List<PluginKnowledge> pluginKnowledgeList);
}
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yice.webadmin.app.dao.ModelInstanceMapper"> <mapper namespace="com.yice.webadmin.app.dao.ModelInstanceMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelInstance"> <resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelInstance">
<id column="deploy_id" jdbcType="BIGINT" property="deployId"/> <id column="instance_id" jdbcType="BIGINT" property="instanceId"/>
<result column="model_id" jdbcType="BIGINT" property="modelId"/> <result column="model_id" jdbcType="BIGINT" property="modelId"/>
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
<result column="model_version" jdbcType="TINYINT" property="modelVersion"/>
<result column="version_id" jdbcType="BIGINT" property="versionId"/> <result column="version_id" jdbcType="BIGINT" property="versionId"/>
<result column="version_name" jdbcType="VARCHAR" property="versionName"/> <result column="version_name" jdbcType="VARCHAR" property="versionName"/>
<result column="deploy_status" jdbcType="TINYINT" property="deployStatus"/> <result column="deploy_status" jdbcType="TINYINT" property="deployStatus"/>
...@@ -15,8 +17,10 @@ ...@@ -15,8 +17,10 @@
<insert id="insertList"> <insert id="insertList">
INSERT INTO lmp_model_instance INSERT INTO lmp_model_instance
(deploy_id, (instance_id,
model_id, model_id,
model_name,
model_version,
version_id, version_id,
version_name, version_name,
deploy_status, deploy_status,
...@@ -26,8 +30,10 @@ ...@@ -26,8 +30,10 @@
update_time) update_time)
VALUES VALUES
<foreach collection="list" index="index" item="item" separator="," > <foreach collection="list" index="index" item="item" separator="," >
(#{item.deployId}, (#{item.instanceId},
#{item.modelId}, #{item.modelId},
#{item.modelName},
#{item.modelVersion},
#{item.versionId}, #{item.versionId},
#{item.versionName}, #{item.versionName},
#{item.deployStatus}, #{item.deployStatus},
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<mapper namespace="com.yice.webadmin.app.dao.ModelServiceMapper"> <mapper namespace="com.yice.webadmin.app.dao.ModelServiceMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelService"> <resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelService">
<id column="service_id" jdbcType="BIGINT" property="serviceId"/> <id column="service_id" jdbcType="BIGINT" property="serviceId"/>
<result column="model_id" jdbcType="BIGINT" property="modelId"/> <result column="instance_id" jdbcType="BIGINT" property="instanceId"/>
<result column="service_name" jdbcType="VARCHAR" property="serviceName"/> <result column="service_name" jdbcType="VARCHAR" property="serviceName"/>
<result column="service_version" jdbcType="TINYINT" property="serviceVersion"/>
<result column="resource_info" jdbcType="VARCHAR" property="resourceInfo"/> <result column="resource_info" jdbcType="VARCHAR" property="resourceInfo"/>
<result column="api_url" jdbcType="VARCHAR" property="apiUrl"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/> <result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/> <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
<insert id="insertList"> <insert id="insertList">
INSERT INTO lmp_model_service INSERT INTO lmp_model_service
(service_id, (service_id,
model_id, instance_id,
service_name, service_name,
service_version,
resource_info, resource_info,
api_url,
remark, remark,
create_user_id, create_user_id,
create_time, create_time,
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
VALUES VALUES
<foreach collection="list" index="index" item="item" separator="," > <foreach collection="list" index="index" item="item" separator="," >
(#{item.serviceId}, (#{item.serviceId},
#{item.modelId}, #{item.instanceId},
#{item.serviceName}, #{item.serviceName},
#{item.serviceVersion},
#{item.resourceInfo}, #{item.resourceInfo},
#{item.apiUrl},
#{item.remark}, #{item.remark},
#{item.createUserId}, #{item.createUserId},
#{item.createTime}, #{item.createTime},
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yice.webadmin.app.dao.PluginKnowledgeMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.PluginKnowledge">
<id column="plugin_knowledge_id" jdbcType="BIGINT" property="pluginKnowledgeId"/>
<id column="config_id" jdbcType="BIGINT" property="configId"/>
<id column="knowledge_id" jdbcType="BIGINT" property="knowledgeId"/>
</resultMap>
<insert id="insertList">
INSERT INTO lmp_plugin_knowledge
(plugin_knowledge_id,
config_id,
knowledge_id)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.pluginKnowledgeId},
#{item.configId},
#{item.knowledgeId})
</foreach>
</insert>
</mapper>
package com.yice.webadmin.app.dto; package com.yice.webadmin.app.dto;
import com.yice.common.core.validator.UpdateGroup; import com.yice.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.*; import javax.validation.constraints.NotNull;
/** /**
* 知识图谱管理Dto对象。 * 知识图谱管理Dto对象。
...@@ -22,8 +21,8 @@ public class ModelInstanceDto { ...@@ -22,8 +21,8 @@ public class ModelInstanceDto {
* 部署ID。 * 部署ID。
*/ */
@ApiModelProperty(value = "部署ID", required = true) @ApiModelProperty(value = "部署ID", required = true)
@NotNull(message = "数据验证失败,部署ID不能为空!", groups = {UpdateGroup.class}) @NotNull(message = "数据验证失败,部署实例ID不能为空!", groups = {UpdateGroup.class})
private Long deployId; private Long instanceId;
/** /**
* 模型ID,外键。 * 模型ID,外键。
...@@ -48,4 +47,40 @@ public class ModelInstanceDto { ...@@ -48,4 +47,40 @@ public class ModelInstanceDto {
*/ */
@ApiModelProperty(value = "部署状态") @ApiModelProperty(value = "部署状态")
private Integer deployStatus; private Integer deployStatus;
/**
* 模型名称。
*/
@ApiModelProperty(value = "模型名称")
private String modelName;
/**
* 模型版本号。
*/
@ApiModelProperty(value = "模型版本号")
private Integer modelVersion;
/**
* 服务名称。
*/
@ApiModelProperty(value = "服务名称")
private String serviceName;
/**
* 资源信息。
*/
@ApiModelProperty(value = "资源信息")
private String resourceInfo;
/**
* 服务描述。
*/
@ApiModelProperty(value = "服务描述")
private String remark;
/**
* 服务地址。
*/
@ApiModelProperty(value = "服务地址")
private String apiUrl;
} }
...@@ -28,7 +28,7 @@ public class ModelServiceDto { ...@@ -28,7 +28,7 @@ public class ModelServiceDto {
* 模型实例ID,外键。 * 模型实例ID,外键。
*/ */
@ApiModelProperty(value = "模型实例ID,外键") @ApiModelProperty(value = "模型实例ID,外键")
private Long modelId; private Long instanceId;
/** /**
* 服务名称。 * 服务名称。
...@@ -36,12 +36,6 @@ public class ModelServiceDto { ...@@ -36,12 +36,6 @@ public class ModelServiceDto {
@ApiModelProperty(value = "服务名称") @ApiModelProperty(value = "服务名称")
private String serviceName; private String serviceName;
/**
* 服务版本。
*/
@ApiModelProperty(value = "服务版本")
private Integer serviceVersion;
/** /**
* 资源信息。 * 资源信息。
*/ */
...@@ -53,4 +47,10 @@ public class ModelServiceDto { ...@@ -53,4 +47,10 @@ public class ModelServiceDto {
*/ */
@ApiModelProperty(value = "服务描述") @ApiModelProperty(value = "服务描述")
private String remark; private String remark;
/**
* 服务地址。
*/
@ApiModelProperty(value = "服务地址")
private String apiUrl;
} }
...@@ -7,6 +7,7 @@ import lombok.Data; ...@@ -7,6 +7,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* 知识图谱管理Dto对象。 * 知识图谱管理Dto对象。
...@@ -67,6 +68,12 @@ public class PluginConfigDto { ...@@ -67,6 +68,12 @@ public class PluginConfigDto {
@ApiModelProperty(value = "插件编排知识库ID,外键") @ApiModelProperty(value = "插件编排知识库ID,外键")
private Long pluginKnowledgeId; private Long pluginKnowledgeId;
/**
* 多个知识库ids。
*/
@ApiModelProperty(value = "多个知识库ids")
private List<Long> knowledgeIds;
/** /**
* 最长上下文。 * 最长上下文。
*/ */
......
package com.yice.webadmin.app.model; package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yice.common.core.base.mapper.BaseModelMapper; import com.yice.common.core.base.mapper.BaseModelMapper;
...@@ -24,8 +25,8 @@ public class ModelInstance extends BaseModel { ...@@ -24,8 +25,8 @@ public class ModelInstance extends BaseModel {
/** /**
* 部署ID。 * 部署ID。
*/ */
@TableId(value = "deploy_id") @TableId(value = "instance_id")
private Long deployId; private Long instanceId;
/** /**
* 模型ID,外键。 * 模型ID,外键。
...@@ -42,11 +43,45 @@ public class ModelInstance extends BaseModel { ...@@ -42,11 +43,45 @@ public class ModelInstance extends BaseModel {
*/ */
private String versionName; private String versionName;
/**
* 模型名称。
*/
private String modelName;
/**
* 模型版本号。
*/
private Integer modelVersion;
/** /**
* 部署状态。 * 部署状态。
*/ */
private Integer deployStatus; private Integer deployStatus;
/**
* 服务名称。
*/
@TableField(exist = false)
private String serviceName;
/**
* 资源信息。
*/
@TableField(exist = false)
private String resourceInfo;
/**
* 服务地址。
*/
@TableField(exist = false)
private String apiUrl;
/**
* 服务描述。
*/
@TableField(exist = false)
private String remark;
@Mapper @Mapper
public interface ModelInstanceMapper extends BaseModelMapper<ModelInstanceVo, ModelInstance> { public interface ModelInstanceMapper extends BaseModelMapper<ModelInstanceVo, ModelInstance> {
} }
......
...@@ -30,7 +30,7 @@ public class ModelService extends BaseModel { ...@@ -30,7 +30,7 @@ public class ModelService extends BaseModel {
/** /**
* 模型实例ID,外键。 * 模型实例ID,外键。
*/ */
private Long modelId; private Long instanceId;
/** /**
* 服务名称。 * 服务名称。
...@@ -38,9 +38,9 @@ public class ModelService extends BaseModel { ...@@ -38,9 +38,9 @@ public class ModelService extends BaseModel {
private String serviceName; private String serviceName;
/** /**
* 服务版本 * 服务API
*/ */
private Integer serviceVersion; private String apiUrl;
/** /**
* 资源信息。 * 资源信息。
......
package com.yice.webadmin.app.model; package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yice.common.core.base.mapper.BaseModelMapper; import com.yice.common.core.base.mapper.BaseModelMapper;
...@@ -11,6 +12,7 @@ import org.mapstruct.Mapper; ...@@ -11,6 +12,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* 实体对象。 * 实体对象。
...@@ -79,6 +81,12 @@ public class PluginConfig extends BaseModel { ...@@ -79,6 +81,12 @@ public class PluginConfig extends BaseModel {
*/ */
private String remark; private String remark;
/**
* 多个知识库ids。
*/
@TableField(exist = false)
private List<Long> knowledgeIds;
@Mapper @Mapper
public interface PluginConfigMapper extends BaseModelMapper<PluginConfigVo, PluginConfig> { public interface PluginConfigMapper extends BaseModelMapper<PluginConfigVo, PluginConfig> {
} }
......
package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* 实体对象。
*
* @author linking
* @date 2023-04-13
*/
@Data
@TableName(value = "lmp_plugin_knowledge")
public class PluginKnowledge {
/**
* 主键Id。
*/
@TableId(value = "plugin_knowledge_id")
private Long pluginKnowledgeId;
/**
* 插件编排配置ID,外键。
*/
private Long configId;
/**
* 知识库ID,外键。
*/
private Long knowledgeId;
}
...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service; ...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 应用接入数据操作服务类。 * 应用接入数据操作服务类。
...@@ -66,25 +67,28 @@ public class ApiManageServiceImpl extends BaseService<ApiManage, Long> implement ...@@ -66,25 +67,28 @@ public class ApiManageServiceImpl extends BaseService<ApiManage, Long> implement
apiManageMapper.insert(this.buildDefaultValue(apiManage)); apiManageMapper.insert(this.buildDefaultValue(apiManage));
if(CollUtil.isNotEmpty(apiManage.getPlugins())) { if(CollUtil.isNotEmpty(apiManage.getPlugins())) {
apiManage.getPlugins().stream() List<ApiPlugin> filters = apiManage.getPlugins().stream()
.map(pluginId -> { .map(pluginId -> {
ApiPlugin filter = new ApiPlugin(); ApiPlugin filter = new ApiPlugin();
filter.setApiId(apiManage.getApiId()); filter.setApiId(apiManage.getApiId());
filter.setPluginId(pluginId); filter.setPluginId(pluginId);
return filter; return filter;
}) })
.forEach(apiPluginMapper::insert); .collect(Collectors.toList());
apiPluginMapper.insertList(filters);
} }
if(CollUtil.isNotEmpty(apiManage.getServices())) { if(CollUtil.isNotEmpty(apiManage.getServices())) {
apiManage.getServices().stream() List<ApiService> filters = apiManage.getServices().stream()
.map(serviceId -> { .map(serviceId -> {
ApiService filter = new ApiService(); ApiService filter = new ApiService();
filter.setApiId(apiManage.getApiId()); filter.setApiId(apiManage.getApiId());
filter.setServiceId(serviceId); filter.setServiceId(serviceId);
return filter; return filter;
}) })
.forEach(apiServiceMapper::insert); .collect(Collectors.toList());
apiServiceMapper.insertList(filters);
} }
return apiManage; return apiManage;
} }
......
...@@ -2,21 +2,28 @@ package com.yice.webadmin.app.service.impl; ...@@ -2,21 +2,28 @@ package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*; import com.github.pagehelper.Page;
import com.yice.webadmin.app.dao.*;
import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.dao.BaseDaoMapper; import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.common.core.object.MyRelationParam;
import com.yice.common.core.base.service.BaseService; import com.yice.common.core.base.service.BaseService;
import com.yice.common.core.object.MyRelationParam;
import com.yice.common.core.util.MyModelUtil; import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper; import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page; import com.yice.webadmin.app.constant.ModelConstant;
import com.yice.webadmin.app.dao.ModelInstanceMapper;
import com.yice.webadmin.app.dao.ModelServiceMapper;
import com.yice.webadmin.app.model.ModelInstance;
import com.yice.webadmin.app.model.ModelManage;
import com.yice.webadmin.app.model.ModelService;
import com.yice.webadmin.app.model.ModelVersion;
import com.yice.webadmin.app.service.ModelInstanceService;
import com.yice.webadmin.app.service.ModelManageService;
import com.yice.webadmin.app.service.ModelVersionService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.List;
/** /**
* 知识图谱管理数据操作服务类。 * 知识图谱管理数据操作服务类。
...@@ -31,7 +38,13 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i ...@@ -31,7 +38,13 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i
@Autowired @Autowired
private ModelInstanceMapper modelInstanceMapper; private ModelInstanceMapper modelInstanceMapper;
@Autowired @Autowired
private ModelServiceMapper modelServiceMapper;
@Autowired
private IdGeneratorWrapper idGenerator; private IdGeneratorWrapper idGenerator;
@Autowired
private ModelVersionService modelVersionService;
@Autowired
private ModelManageService modelManageService;
/** /**
* 返回当前Service的主表Mapper对象。 * 返回当前Service的主表Mapper对象。
...@@ -52,7 +65,24 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i ...@@ -52,7 +65,24 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public ModelInstance saveNew(ModelInstance modelInstance) { public ModelInstance saveNew(ModelInstance modelInstance) {
modelInstanceMapper.insert(this.buildDefaultValue(modelInstance)); ModelVersion modelVersion = this.modelVersionService.getById(modelInstance.getVersionId());
if (null != modelVersion) {
Long modelId = modelVersion.getModelId();
ModelManage modelManage = modelManageService.getById(modelId);
modelInstance.setDeployStatus(ModelConstant.DEPLOY_STATUS);
modelInstance.setModelId(modelId);
modelInstance.setVersionName(modelVersion.getVersionName());
modelInstance.setModelVersion(modelVersion.getModelVersion());
modelInstance.setModelName(modelManage.getModelName());
modelInstanceMapper.insert(this.buildDefaultValue(modelInstance));
ModelService modelService = new ModelService();
modelService.setInstanceId(modelInstance.getInstanceId());
modelService.setServiceName(modelInstance.getServiceName());
modelService.setResourceInfo(modelInstance.getResourceInfo());
modelService.setRemark(modelInstance.getRemark());
modelServiceMapper.insert(buildDefaultValue(modelService));
}
return modelInstance; return modelInstance;
} }
...@@ -82,7 +112,7 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i ...@@ -82,7 +112,7 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i
public boolean update(ModelInstance modelInstance, ModelInstance originalModelInstance) { public boolean update(ModelInstance modelInstance, ModelInstance originalModelInstance) {
MyModelUtil.fillCommonsForUpdate(modelInstance, originalModelInstance); MyModelUtil.fillCommonsForUpdate(modelInstance, originalModelInstance);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。 // 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<ModelInstance> uw = this.createUpdateQueryForNullValue(modelInstance, modelInstance.getDeployId()); UpdateWrapper<ModelInstance> uw = this.createUpdateQueryForNullValue(modelInstance, modelInstance.getInstanceId());
return modelInstanceMapper.update(modelInstance, uw) == 1; return modelInstanceMapper.update(modelInstance, uw) == 1;
} }
...@@ -131,10 +161,18 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i ...@@ -131,10 +161,18 @@ public class ModelInstanceServiceImpl extends BaseService<ModelInstance, Long> i
} }
private ModelInstance buildDefaultValue(ModelInstance modelInstance) { private ModelInstance buildDefaultValue(ModelInstance modelInstance) {
if (modelInstance.getDeployId() == null) { if (modelInstance.getInstanceId() == null) {
modelInstance.setDeployId(idGenerator.nextLongId()); modelInstance.setInstanceId(idGenerator.nextLongId());
} }
MyModelUtil.fillCommonsForInsert(modelInstance); MyModelUtil.fillCommonsForInsert(modelInstance);
return modelInstance; return modelInstance;
} }
private ModelService buildDefaultValue(ModelService modelService) {
if (modelService.getServiceId() == null) {
modelService.setServiceId(idGenerator.nextLongId());
}
MyModelUtil.fillCommonsForInsert(modelService);
return modelService;
}
} }
...@@ -9,7 +9,9 @@ import com.yice.common.core.object.MyRelationParam; ...@@ -9,7 +9,9 @@ import com.yice.common.core.object.MyRelationParam;
import com.yice.common.core.util.MyModelUtil; import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper; import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.yice.webadmin.app.dao.PluginConfigMapper; import com.yice.webadmin.app.dao.PluginConfigMapper;
import com.yice.webadmin.app.dao.PluginKnowledgeMapper;
import com.yice.webadmin.app.model.PluginConfig; import com.yice.webadmin.app.model.PluginConfig;
import com.yice.webadmin.app.model.PluginKnowledge;
import com.yice.webadmin.app.service.PluginConfigService; import com.yice.webadmin.app.service.PluginConfigService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service; ...@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 知识图谱管理数据操作服务类。 * 知识图谱管理数据操作服务类。
...@@ -32,7 +35,8 @@ public class PluginConfigServiceImpl extends BaseService<PluginConfig, Long> imp ...@@ -32,7 +35,8 @@ public class PluginConfigServiceImpl extends BaseService<PluginConfig, Long> imp
private PluginConfigMapper pluginConfigMapper; private PluginConfigMapper pluginConfigMapper;
@Autowired @Autowired
private IdGeneratorWrapper idGenerator; private IdGeneratorWrapper idGenerator;
@Autowired
private PluginKnowledgeMapper pluginKnowledgeMapper;
/** /**
* 返回当前Service的主表Mapper对象。 * 返回当前Service的主表Mapper对象。
* *
...@@ -53,6 +57,20 @@ public class PluginConfigServiceImpl extends BaseService<PluginConfig, Long> imp ...@@ -53,6 +57,20 @@ public class PluginConfigServiceImpl extends BaseService<PluginConfig, Long> imp
@Override @Override
public PluginConfig saveNew(PluginConfig pluginConfig) { public PluginConfig saveNew(PluginConfig pluginConfig) {
pluginConfigMapper.insert(this.buildDefaultValue(pluginConfig)); pluginConfigMapper.insert(this.buildDefaultValue(pluginConfig));
if(CollUtil.isNotEmpty(pluginConfig.getKnowledgeIds())) {
List<PluginKnowledge> filters = pluginConfig.getKnowledgeIds().stream()
.map(knowledgeId -> {
PluginKnowledge filter = new PluginKnowledge();
filter.setKnowledgeId(idGenerator.nextLongId());
filter.setConfigId(pluginConfig.getConfigId());
filter.setKnowledgeId(knowledgeId);
return filter;
})
.collect(Collectors.toList());
pluginKnowledgeMapper.insertList(filters);
}
return pluginConfig; return pluginConfig;
} }
......
...@@ -20,8 +20,8 @@ public class ModelInstanceVo extends BaseVo { ...@@ -20,8 +20,8 @@ public class ModelInstanceVo extends BaseVo {
/** /**
* 部署ID。 * 部署ID。
*/ */
@ApiModelProperty(value = "部署ID") @ApiModelProperty(value = "部署实例ID")
private Long deployId; private Long instanceId;
/** /**
* 模型ID,外键。 * 模型ID,外键。
...@@ -46,4 +46,40 @@ public class ModelInstanceVo extends BaseVo { ...@@ -46,4 +46,40 @@ public class ModelInstanceVo extends BaseVo {
*/ */
@ApiModelProperty(value = "部署状态") @ApiModelProperty(value = "部署状态")
private Integer deployStatus; private Integer deployStatus;
/**
* 模型名称。
*/
@ApiModelProperty(value = "模型名称")
private String modelName;
/**
* 模型版本号。
*/
@ApiModelProperty(value = "模型版本号")
private Integer modelVersion;
/**
* 服务名称。
*/
@ApiModelProperty(value = "服务名称")
private String serviceName;
/**
* 资源信息。
*/
@ApiModelProperty(value = "资源信息")
private String resourceInfo;
/**
* 服务描述。
*/
@ApiModelProperty(value = "服务描述")
private String remark;
/**
* 服务地址。
*/
@ApiModelProperty(value = "服务地址")
private String apiUrl;
} }
...@@ -29,7 +29,7 @@ public class ModelServiceVo extends BaseVo { ...@@ -29,7 +29,7 @@ public class ModelServiceVo extends BaseVo {
* 模型实例ID,外键。 * 模型实例ID,外键。
*/ */
@ApiModelProperty(value = "模型实例ID,外键") @ApiModelProperty(value = "模型实例ID,外键")
private Long modelId; private Long instanceId;
/** /**
* 服务名称。 * 服务名称。
...@@ -37,18 +37,18 @@ public class ModelServiceVo extends BaseVo { ...@@ -37,18 +37,18 @@ public class ModelServiceVo extends BaseVo {
@ApiModelProperty(value = "服务名称") @ApiModelProperty(value = "服务名称")
private String serviceName; private String serviceName;
/**
* 服务版本。
*/
@ApiModelProperty(value = "服务版本")
private Integer serviceVersion;
/** /**
* 资源信息。 * 资源信息。
*/ */
@ApiModelProperty(value = "资源信息") @ApiModelProperty(value = "资源信息")
private String resourceInfo; private String resourceInfo;
/**
* 服务地址。
*/
@ApiModelProperty(value = "服务地址")
private String apiUrl;
/** /**
* 服务描述。 * 服务描述。
*/ */
......
...@@ -7,6 +7,7 @@ import lombok.Data; ...@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
/** /**
* 知识图谱管理VO视图对象。 * 知识图谱管理VO视图对象。
...@@ -67,6 +68,12 @@ public class PluginConfigVo extends BaseVo { ...@@ -67,6 +68,12 @@ public class PluginConfigVo extends BaseVo {
@ApiModelProperty(value = "插件编排知识库ID,外键") @ApiModelProperty(value = "插件编排知识库ID,外键")
private Long pluginKnowledgeId; private Long pluginKnowledgeId;
/**
* 多个知识库ids。
*/
@ApiModelProperty(value = "多个知识库ids")
private List<Long> knowledgeIds;
/** /**
* 最长上下文。 * 最长上下文。
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment