Commit 1b77ba51 authored by linpeiqin's avatar linpeiqin

模型精调代码初始化

parent c1628ebf
...@@ -49,7 +49,7 @@ public class DatasetManageController { ...@@ -49,7 +49,7 @@ public class DatasetManageController {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
} }
DatasetManage datasetManage = MyModelUtil.copyTo(datasetManageDto, DatasetManage.class); DatasetManage datasetManage = MyModelUtil.copyTo(datasetManageDto, DatasetManage.class);
// datasetManage = datasetManageService.saveNew(datasetManage); // datasetManage = datasetManageService.saveNew(datasetManage);
datasetManage = datasetManageService.saveAndCreateVersion(datasetManage); datasetManage = datasetManageService.saveAndCreateVersion(datasetManage);
return ResponseResult.success(datasetManage.getDatasetId()); return ResponseResult.success(datasetManage.getDatasetId());
} }
...@@ -99,10 +99,10 @@ public class DatasetManageController { ...@@ -99,10 +99,10 @@ public class DatasetManageController {
/** /**
* 列出符合过滤条件的数据集管理列表。 * 列出符合过滤条件的数据集管理列表。
* *
* @param datasetManageDtoFilter 过滤对象。 * @param datasetManageDtoFilter 过滤对象。
* @param datasetVersionDtoFilter 一对多从表过滤对象。 * @param datasetVersionDtoFilter 一对多从表过滤对象。
* @param orderParam 排序参数。 * @param orderParam 排序参数。
* @param pageParam 分页参数。 * @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。 * @return 应答结果对象,包含查询结果集。
*/ */
@PostMapping("/list") @PostMapping("/list")
...@@ -122,6 +122,18 @@ public class DatasetManageController { ...@@ -122,6 +122,18 @@ public class DatasetManageController {
return ResponseResult.success(MyPageUtil.makeResponseData(datasetManageList, DatasetManage.INSTANCE)); return ResponseResult.success(MyPageUtil.makeResponseData(datasetManageList, DatasetManage.INSTANCE));
} }
/**
* 列出符合过滤条件的数据集管理列表。
*
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/listForTree")
public ResponseResult<List<DatasetManageVo>> listForTree() {
List<DatasetManage> datasetManageList =
datasetManageService.getDatasetManageListWithRelation(new DatasetManage(), new DatasetVersion(), "");
return ResponseResult.success(DatasetManage.INSTANCE.fromModelList(datasetManageList));
}
/** /**
* 查看指定数据集管理对象详情。 * 查看指定数据集管理对象详情。
* *
......
package com.yice.webadmin.app.controller;
import com.alibaba.fastjson.JSONObject;
import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.yice.webadmin.app.vo.*;
import com.yice.webadmin.app.dto.*;
import com.yice.webadmin.app.model.*;
import com.yice.webadmin.app.service.*;
import com.yice.common.core.object.*;
import com.yice.common.core.util.*;
import com.yice.common.core.constant.*;
import com.yice.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 模型压缩操作控制器类。
*
* @author linking
* @date 2023-04-13
*/
@Api(tags = "模型压缩管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/modelCompress")
public class ModelCompressController {
@Autowired
private ModelCompressService modelCompressService;
@Autowired
private ModelTaskService modelTaskService;
@Autowired
private ModelVersionService modelVersionService;
/**
* 新增模型压缩数据,及其关联的从表数据。
*
* @param modelCompressDto 新增主表对象。
* @param modelTaskDto 一对一模型任务从表Dto。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"modelCompressDto.taskId", "modelCompressDto.searchString"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(
@MyRequestBody ModelCompressDto modelCompressDto,
@MyRequestBody ModelTaskDto modelTaskDto) {
Long modelVersionId = modelCompressDto.getSourceVersionId();
ModelVersion modelVersion = this.modelVersionService.getById(modelVersionId);
modelTaskDto.setVersionId(modelVersion.getVersionId());
modelTaskDto.setTaskType(2);
modelTaskDto.setModelId(modelVersion.getModelId());
modelTaskDto.setModelVersion(modelVersion.getModelVersion());
modelTaskDto.setVersionName(modelVersion.getVersionName());
ResponseResult<Tuple2<ModelCompress, JSONObject>> verifyResult =
this.doBusinessDataVerifyAndConvert(modelCompressDto, false, modelTaskDto);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
Tuple2<ModelCompress, JSONObject> bizData = verifyResult.getData();
ModelCompress modelCompress = bizData.getFirst();
modelCompress = modelCompressService.saveNewWithRelation(modelCompress, bizData.getSecond());
return ResponseResult.success(modelCompress.getTaskId());
}
/**
* 修改模型压缩数据,及其关联的从表数据。
*
* @param modelCompressDto 修改后的对象。
* @param modelTaskDto 一对一模型任务从表Dto。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"modelCompressDto.taskId", "modelCompressDto.searchString"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Long> update(
@MyRequestBody ModelCompressDto modelCompressDto,
@MyRequestBody ModelTaskDto modelTaskDto) {
String errorMessage;
ResponseResult<Tuple2<ModelCompress, JSONObject>> verifyResult =
this.doBusinessDataVerifyAndConvert(modelCompressDto, true, modelTaskDto);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
Tuple2<ModelCompress, JSONObject> bizData = verifyResult.getData();
ModelCompress originalModelCompress = bizData.getSecond().getObject("originalData", ModelCompress.class);
ModelCompress modelCompress = bizData.getFirst();
if (!modelCompressService.updateWithRelation(modelCompress, originalModelCompress, bizData.getSecond())) {
errorMessage = "数据验证失败,[ModelCompress] 数据不存在!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success(modelCompress.getTaskId());
}
/**
* 删除模型压缩数据。
*
* @param taskId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long taskId) {
if (MyCommonUtil.existBlankArgument(taskId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(taskId);
}
/**
* 列出符合过滤条件的模型压缩列表。
*
* @param modelCompressDtoFilter 过滤对象。
* @param modelTaskDtoFilter 一对一从表过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<ModelCompressVo>> list(
@MyRequestBody ModelCompressDto modelCompressDtoFilter,
@MyRequestBody ModelTaskDto modelTaskDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
ModelCompress modelCompressFilter = MyModelUtil.copyTo(modelCompressDtoFilter, ModelCompress.class);
ModelTask modelTaskFilter = MyModelUtil.copyTo(modelTaskDtoFilter, ModelTask.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, ModelCompress.class);
List<ModelCompress> modelCompressList =
modelCompressService.getModelCompressListWithRelation(modelCompressFilter, modelTaskFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(modelCompressList, ModelCompress.INSTANCE));
}
/**
* 查看指定模型压缩对象详情。
*
* @param taskId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<ModelCompressVo> view(@RequestParam Long taskId) {
ModelCompress modelCompress = modelCompressService.getByIdWithRelation(taskId, MyRelationParam.full());
if (modelCompress == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
ModelCompressVo modelCompressVo = ModelCompress.INSTANCE.fromModel(modelCompress);
return ResponseResult.success(modelCompressVo);
}
private ResponseResult<Tuple2<ModelCompress, JSONObject>> doBusinessDataVerifyAndConvert(
ModelCompressDto modelCompressDto,
boolean forUpdate,
ModelTaskDto modelTaskDto) {
ErrorCodeEnum errorCode = ErrorCodeEnum.DATA_VALIDATED_FAILED;
String errorMessage = MyCommonUtil.getModelValidationError(modelCompressDto, false);
if (errorMessage != null) {
return ResponseResult.error(errorCode, errorMessage);
}
errorMessage = MyCommonUtil.getModelValidationError(modelTaskDto);
if (errorMessage != null) {
return ResponseResult.error(errorCode, "参数 [modelTaskDto] " + errorMessage);
}
// 全部关联从表数据的验证和转换
JSONObject relationData = new JSONObject();
CallResult verifyResult;
// 下面是输入参数中,主表关联数据的验证。
ModelCompress modelCompress = MyModelUtil.copyTo(modelCompressDto, ModelCompress.class);
ModelCompress originalData;
if (forUpdate && modelCompress != null) {
originalData = modelCompressService.getById(modelCompress.getTaskId());
if (originalData == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
relationData.put("originalData", originalData);
}
// 处理主表的一对一关联 [ModelTask]
ModelTask modelTask = MyModelUtil.copyTo(modelTaskDto, ModelTask.class);
verifyResult = modelTaskService.verifyRelatedData(modelTask);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
relationData.put("modelTask", modelTask);
return ResponseResult.success(new Tuple2<>(modelCompress, relationData));
}
private ResponseResult<Void> doDelete(Long taskId) {
String errorMessage;
// 验证关联Id的数据合法性
ModelCompress originalModelCompress = modelCompressService.getById(taskId);
if (originalModelCompress == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!modelCompressService.remove(taskId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
}
package com.yice.webadmin.app.controller;
import com.alibaba.fastjson.JSONObject;
import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.yice.webadmin.app.vo.*;
import com.yice.webadmin.app.dto.*;
import com.yice.webadmin.app.model.*;
import com.yice.webadmin.app.service.*;
import com.yice.common.core.object.*;
import com.yice.common.core.util.*;
import com.yice.common.core.constant.*;
import com.yice.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 模型评估操作控制器类。
*
* @author linking
* @date 2023-04-13
*/
@Api(tags = "模型评估管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/modelEstimate")
public class ModelEstimateController {
@Autowired
private ModelEstimateService modelEstimateService;
@Autowired
private ModelTaskService modelTaskService;
@Autowired
private ModelVersionService modelVersionService;
/**
* 新增模型评估数据,及其关联的从表数据。
*
* @param modelEstimateDto 新增主表对象。
* @param modelTaskDto 一对一模型任务从表Dto。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"modelEstimateDto.taskId", "modelEstimateDto.searchString"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(
@MyRequestBody ModelEstimateDto modelEstimateDto,
@MyRequestBody ModelTaskDto modelTaskDto) {
Long modelVersionId = modelEstimateDto.getModelVersionId();
ModelVersion modelVersion = this.modelVersionService.getById(modelVersionId);
modelTaskDto.setVersionId(modelVersion.getVersionId());
modelTaskDto.setTaskType(1);
modelTaskDto.setModelId(modelVersion.getModelId());
modelTaskDto.setModelVersion(modelVersion.getModelVersion());
modelTaskDto.setVersionName(modelVersion.getVersionName());
ResponseResult<Tuple2<ModelEstimate, JSONObject>> verifyResult =
this.doBusinessDataVerifyAndConvert(modelEstimateDto, false, modelTaskDto);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
Tuple2<ModelEstimate, JSONObject> bizData = verifyResult.getData();
ModelEstimate modelEstimate = bizData.getFirst();
modelEstimate = modelEstimateService.saveNewWithRelation(modelEstimate, bizData.getSecond());
return ResponseResult.success(modelEstimate.getTaskId());
}
/**
* 修改模型评估数据,及其关联的从表数据。
*
* @param modelEstimateDto 修改后的对象。
* @param modelTaskDto 一对一模型任务从表Dto。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"modelEstimateDto.taskId", "modelEstimateDto.searchString"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Long> update(
@MyRequestBody ModelEstimateDto modelEstimateDto,
@MyRequestBody ModelTaskDto modelTaskDto) {
String errorMessage;
ResponseResult<Tuple2<ModelEstimate, JSONObject>> verifyResult =
this.doBusinessDataVerifyAndConvert(modelEstimateDto, true, modelTaskDto);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
Tuple2<ModelEstimate, JSONObject> bizData = verifyResult.getData();
ModelEstimate originalModelEstimate = bizData.getSecond().getObject("originalData", ModelEstimate.class);
ModelEstimate modelEstimate = bizData.getFirst();
if (!modelEstimateService.updateWithRelation(modelEstimate, originalModelEstimate, bizData.getSecond())) {
errorMessage = "数据验证失败,[ModelEstimate] 数据不存在!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success(modelEstimate.getTaskId());
}
/**
* 删除模型评估数据。
*
* @param taskId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long taskId) {
if (MyCommonUtil.existBlankArgument(taskId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(taskId);
}
/**
* 列出符合过滤条件的模型评估列表。
*
* @param modelEstimateDtoFilter 过滤对象。
* @param modelTaskDtoFilter 一对一从表过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<ModelEstimateVo>> list(
@MyRequestBody ModelEstimateDto modelEstimateDtoFilter,
@MyRequestBody ModelTaskDto modelTaskDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
ModelEstimate modelEstimateFilter = MyModelUtil.copyTo(modelEstimateDtoFilter, ModelEstimate.class);
ModelTask modelTaskFilter = MyModelUtil.copyTo(modelTaskDtoFilter, ModelTask.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, ModelEstimate.class);
List<ModelEstimate> modelEstimateList =
modelEstimateService.getModelEstimateListWithRelation(modelEstimateFilter, modelTaskFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(modelEstimateList, ModelEstimate.INSTANCE));
}
/**
* 查看指定模型评估对象详情。
*
* @param taskId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<ModelEstimateVo> view(@RequestParam Long taskId) {
ModelEstimate modelEstimate = modelEstimateService.getByIdWithRelation(taskId, MyRelationParam.full());
if (modelEstimate == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
ModelEstimateVo modelEstimateVo = ModelEstimate.INSTANCE.fromModel(modelEstimate);
return ResponseResult.success(modelEstimateVo);
}
private ResponseResult<Tuple2<ModelEstimate, JSONObject>> doBusinessDataVerifyAndConvert(
ModelEstimateDto modelEstimateDto,
boolean forUpdate,
ModelTaskDto modelTaskDto) {
ErrorCodeEnum errorCode = ErrorCodeEnum.DATA_VALIDATED_FAILED;
String errorMessage = MyCommonUtil.getModelValidationError(modelEstimateDto, false);
if (errorMessage != null) {
return ResponseResult.error(errorCode, errorMessage);
}
errorMessage = MyCommonUtil.getModelValidationError(modelTaskDto);
if (errorMessage != null) {
return ResponseResult.error(errorCode, "参数 [modelTaskDto] " + errorMessage);
}
// 全部关联从表数据的验证和转换
JSONObject relationData = new JSONObject();
CallResult verifyResult;
// 下面是输入参数中,主表关联数据的验证。
ModelEstimate modelEstimate = MyModelUtil.copyTo(modelEstimateDto, ModelEstimate.class);
ModelEstimate originalData;
if (forUpdate && modelEstimate != null) {
originalData = modelEstimateService.getById(modelEstimate.getTaskId());
if (originalData == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
relationData.put("originalData", originalData);
}
// 处理主表的一对一关联 [ModelTask]
ModelTask modelTask = MyModelUtil.copyTo(modelTaskDto, ModelTask.class);
verifyResult = modelTaskService.verifyRelatedData(modelTask);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
relationData.put("modelTask", modelTask);
return ResponseResult.success(new Tuple2<>(modelEstimate, relationData));
}
private ResponseResult<Void> doDelete(Long taskId) {
String errorMessage;
// 验证关联Id的数据合法性
ModelEstimate originalModelEstimate = modelEstimateService.getById(taskId);
if (originalModelEstimate == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!modelEstimateService.remove(taskId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
}
...@@ -55,7 +55,7 @@ public class ModelManageController { ...@@ -55,7 +55,7 @@ public class ModelManageController {
} }
ModelManage modelManage = MyModelUtil.copyTo(modelManageDto, ModelManage.class); ModelManage modelManage = MyModelUtil.copyTo(modelManageDto, ModelManage.class);
ModelVersion modelVersion = MyModelUtil.copyTo(modelVersionDto, ModelVersion.class); ModelVersion modelVersion = MyModelUtil.copyTo(modelVersionDto, ModelVersion.class);
modelManage = modelManageService.saveAndCreateVersion(modelManage,modelVersion); modelManage = modelManageService.saveAndCreateVersion(modelManage, modelVersion);
return ResponseResult.success(modelManage.getModelId()); return ResponseResult.success(modelManage.getModelId());
} }
...@@ -86,6 +86,18 @@ public class ModelManageController { ...@@ -86,6 +86,18 @@ public class ModelManageController {
return ResponseResult.success(); return ResponseResult.success();
} }
/**
* 列出符合过滤条件的模型管理列表。
*
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/listForTree")
public ResponseResult<List<ModelManageVo>> listForTree() {
List<ModelManage> modelManageList =
modelManageService.getModelManageListWithRelation(new ModelManage(), new ModelVersion(), null, null, "");
return ResponseResult.success(ModelManage.INSTANCE.fromModelList(modelManageList));
}
/** /**
* 删除模型管理数据。 * 删除模型管理数据。
* *
...@@ -104,12 +116,12 @@ public class ModelManageController { ...@@ -104,12 +116,12 @@ public class ModelManageController {
/** /**
* 列出符合过滤条件的模型管理列表。 * 列出符合过滤条件的模型管理列表。
* *
* @param modelManageDtoFilter 过滤对象。 * @param modelManageDtoFilter 过滤对象。
* @param modelVersionDtoFilter 一对多从表过滤对象。 * @param modelVersionDtoFilter 一对多从表过滤对象。
* @param modelTaskDtoFilter 一对多从表过滤对象。 * @param modelTaskDtoFilter 一对多从表过滤对象。
* @param modelDeployDtoFilter 一对多从表过滤对象。 * @param modelDeployDtoFilter 一对多从表过滤对象。
* @param orderParam 排序参数。 * @param orderParam 排序参数。
* @param pageParam 分页参数。 * @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。 * @return 应答结果对象,包含查询结果集。
*/ */
@PostMapping("/list") @PostMapping("/list")
......
package com.yice.webadmin.app.controller; package com.yice.webadmin.app.controller;
import com.alibaba.fastjson.JSONObject;
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.github.pagehelper.page.PageMethod; import com.github.pagehelper.page.PageMethod;
...@@ -35,58 +36,60 @@ public class ModelTaskController { ...@@ -35,58 +36,60 @@ public class ModelTaskController {
private ModelTaskService modelTaskService; private ModelTaskService modelTaskService;
/** /**
* 新增模型任务数据。 * 新增模型任务数据,及其关联的从表数据
* *
* @param modelTaskDto 新增对象。 * @param modelTaskDto 新增主表对象。
* @param modelEstimateDto 一对一模型评估从表Dto。
* @param modelCompressDto 一对一模型压缩从表Dto。
* @return 应答结果对象,包含新增对象主键Id。 * @return 应答结果对象,包含新增对象主键Id。
*/ */
@ApiOperationSupport(ignoreParameters = {"modelTaskDto.taskId"}) @ApiOperationSupport(ignoreParameters = {"modelTaskDto.taskId"})
@OperationLog(type = SysOperationLogType.ADD) @OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add") @PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody ModelTaskDto modelTaskDto) { public ResponseResult<Long> add(
String errorMessage = MyCommonUtil.getModelValidationError(modelTaskDto, false); @MyRequestBody ModelTaskDto modelTaskDto,
if (errorMessage != null) { @MyRequestBody ModelEstimateDto modelEstimateDto,
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); @MyRequestBody ModelCompressDto modelCompressDto) {
} ResponseResult<Tuple2<ModelTask, JSONObject>> verifyResult = this.doBusinessDataVerifyAndConvert(
ModelTask modelTask = MyModelUtil.copyTo(modelTaskDto, ModelTask.class); modelTaskDto, false, modelEstimateDto, modelCompressDto);
// 验证关联Id的数据合法性 if (!verifyResult.isSuccess()) {
CallResult callResult = modelTaskService.verifyRelatedData(modelTask, null); return ResponseResult.errorFrom(verifyResult);
if (!callResult.isSuccess()) {
return ResponseResult.errorFrom(callResult);
} }
modelTask = modelTaskService.saveNew(modelTask); Tuple2<ModelTask, JSONObject> bizData = verifyResult.getData();
ModelTask modelTask = bizData.getFirst();
modelTask = modelTaskService.saveNewWithRelation(modelTask, bizData.getSecond());
return ResponseResult.success(modelTask.getTaskId()); return ResponseResult.success(modelTask.getTaskId());
} }
/** /**
* 更新模型任务数据。 * 修改模型任务数据,及其关联的从表数据。
* *
* @param modelTaskDto 更新对象。 * @param modelTaskDto 修改后的对象。
* @return 应答结果对象。 * @param modelEstimateDto 一对一模型评估从表Dto。
* @param modelCompressDto 一对一模型压缩从表Dto。
* @return 应答结果对象,包含新增对象主键Id。
*/ */
@ApiOperationSupport(ignoreParameters = {"modelTaskDto.taskId"})
@OperationLog(type = SysOperationLogType.UPDATE) @OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update") @PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody ModelTaskDto modelTaskDto) { public ResponseResult<Long> update(
String errorMessage = MyCommonUtil.getModelValidationError(modelTaskDto, true); @MyRequestBody ModelTaskDto modelTaskDto,
if (errorMessage != null) { @MyRequestBody ModelEstimateDto modelEstimateDto,
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage); @MyRequestBody ModelCompressDto modelCompressDto) {
String errorMessage;
ResponseResult<Tuple2<ModelTask, JSONObject>> verifyResult = this.doBusinessDataVerifyAndConvert(
modelTaskDto, true, modelEstimateDto, modelCompressDto);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
} }
ModelTask modelTask = MyModelUtil.copyTo(modelTaskDto, ModelTask.class); Tuple2<ModelTask, JSONObject> bizData = verifyResult.getData();
ModelTask originalModelTask = modelTaskService.getById(modelTask.getTaskId()); ModelTask originalModelTask = bizData.getSecond().getObject("originalData", ModelTask.class);
if (originalModelTask == null) { ModelTask modelTask = bizData.getFirst();
// NOTE: 修改下面方括号中的话述 if (!modelTaskService.updateWithRelation(modelTask, originalModelTask, bizData.getSecond())) {
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!"; errorMessage = "数据验证失败,[ModelTask] 数据不存在!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage); return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
} }
// 验证关联Id的数据合法性 return ResponseResult.success(modelTask.getTaskId());
CallResult callResult = modelTaskService.verifyRelatedData(modelTask, originalModelTask);
if (!callResult.isSuccess()) {
return ResponseResult.errorFrom(callResult);
}
if (!modelTaskService.update(modelTask, originalModelTask)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
} }
/** /**
...@@ -108,6 +111,8 @@ public class ModelTaskController { ...@@ -108,6 +111,8 @@ public class ModelTaskController {
* 列出符合过滤条件的模型任务列表。 * 列出符合过滤条件的模型任务列表。
* *
* @param modelTaskDtoFilter 过滤对象。 * @param modelTaskDtoFilter 过滤对象。
* @param modelEstimateDtoFilter 一对一从表过滤对象。
* @param modelCompressDtoFilter 一对一从表过滤对象。
* @param orderParam 排序参数。 * @param orderParam 排序参数。
* @param pageParam 分页参数。 * @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。 * @return 应答结果对象,包含查询结果集。
...@@ -115,14 +120,19 @@ public class ModelTaskController { ...@@ -115,14 +120,19 @@ public class ModelTaskController {
@PostMapping("/list") @PostMapping("/list")
public ResponseResult<MyPageData<ModelTaskVo>> list( public ResponseResult<MyPageData<ModelTaskVo>> list(
@MyRequestBody ModelTaskDto modelTaskDtoFilter, @MyRequestBody ModelTaskDto modelTaskDtoFilter,
@MyRequestBody ModelEstimateDto modelEstimateDtoFilter,
@MyRequestBody ModelCompressDto modelCompressDtoFilter,
@MyRequestBody MyOrderParam orderParam, @MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) { @MyRequestBody MyPageParam pageParam) {
if (pageParam != null) { if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
} }
ModelTask modelTaskFilter = MyModelUtil.copyTo(modelTaskDtoFilter, ModelTask.class); ModelTask modelTaskFilter = MyModelUtil.copyTo(modelTaskDtoFilter, ModelTask.class);
ModelEstimate modelEstimateFilter = MyModelUtil.copyTo(modelEstimateDtoFilter, ModelEstimate.class);
ModelCompress modelCompressFilter = MyModelUtil.copyTo(modelCompressDtoFilter, ModelCompress.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, ModelTask.class); String orderBy = MyOrderParam.buildOrderBy(orderParam, ModelTask.class);
List<ModelTask> modelTaskList = modelTaskService.getModelTaskListWithRelation(modelTaskFilter, orderBy); List<ModelTask> modelTaskList =
modelTaskService.getModelTaskListWithRelation(modelTaskFilter, modelEstimateFilter, modelCompressFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(modelTaskList, ModelTask.INSTANCE)); return ResponseResult.success(MyPageUtil.makeResponseData(modelTaskList, ModelTask.INSTANCE));
} }
...@@ -142,6 +152,50 @@ public class ModelTaskController { ...@@ -142,6 +152,50 @@ public class ModelTaskController {
return ResponseResult.success(modelTaskVo); return ResponseResult.success(modelTaskVo);
} }
private ResponseResult<Tuple2<ModelTask, JSONObject>> doBusinessDataVerifyAndConvert(
ModelTaskDto modelTaskDto,
boolean forUpdate,
ModelEstimateDto modelEstimateDto,
ModelCompressDto modelCompressDto) {
ErrorCodeEnum errorCode = ErrorCodeEnum.DATA_VALIDATED_FAILED;
String errorMessage = MyCommonUtil.getModelValidationError(modelTaskDto, false);
if (errorMessage != null) {
return ResponseResult.error(errorCode, errorMessage);
}
errorMessage = MyCommonUtil.getModelValidationError(modelEstimateDto);
if (errorMessage != null) {
return ResponseResult.error(errorCode, "参数 [modelEstimateDto] " + errorMessage);
}
errorMessage = MyCommonUtil.getModelValidationError(modelCompressDto);
if (errorMessage != null) {
return ResponseResult.error(errorCode, "参数 [modelCompressDto] " + errorMessage);
}
// 全部关联从表数据的验证和转换
JSONObject relationData = new JSONObject();
CallResult verifyResult;
// 下面是输入参数中,主表关联数据的验证。
ModelTask modelTask = MyModelUtil.copyTo(modelTaskDto, ModelTask.class);
ModelTask originalData = null;
if (forUpdate && modelTask != null) {
originalData = modelTaskService.getById(modelTask.getTaskId());
if (originalData == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
relationData.put("originalData", originalData);
}
verifyResult = modelTaskService.verifyRelatedData(modelTask, originalData);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
// 处理主表的一对一关联 [ModelEstimate]
ModelEstimate modelEstimate = MyModelUtil.copyTo(modelEstimateDto, ModelEstimate.class);
relationData.put("modelEstimate", modelEstimate);
// 处理主表的一对一关联 [ModelCompress]
ModelCompress modelCompress = MyModelUtil.copyTo(modelCompressDto, ModelCompress.class);
relationData.put("modelCompress", modelCompress);
return ResponseResult.success(new Tuple2<>(modelTask, relationData));
}
private ResponseResult<Void> doDelete(Long taskId) { private ResponseResult<Void> doDelete(Long taskId) {
String errorMessage; String errorMessage;
// 验证关联Id的数据合法性 // 验证关联Id的数据合法性
......
package com.yice.webadmin.app.controller;
import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.yice.webadmin.app.vo.*;
import com.yice.webadmin.app.dto.*;
import com.yice.webadmin.app.model.*;
import com.yice.webadmin.app.service.*;
import com.yice.common.core.object.*;
import com.yice.common.core.util.*;
import com.yice.common.core.constant.*;
import com.yice.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 精调任务运行操作控制器类。
*
* @author linking
* @date 2023-04-13
*/
@Api(tags = "精调任务运行管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/tuningRun")
public class TuningRunController {
@Autowired
private TuningRunService tuningRunService;
/**
* 新增精调任务运行数据。
*
* @param tuningRunDto 新增对象。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"tuningRunDto.runId"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody TuningRunDto tuningRunDto) {
String errorMessage = MyCommonUtil.getModelValidationError(tuningRunDto, false);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
TuningRun tuningRun = MyModelUtil.copyTo(tuningRunDto, TuningRun.class);
tuningRun = tuningRunService.saveNew(tuningRun);
return ResponseResult.success(tuningRun.getRunId());
}
/**
* 更新精调任务运行数据。
*
* @param tuningRunDto 更新对象。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody TuningRunDto tuningRunDto) {
String errorMessage = MyCommonUtil.getModelValidationError(tuningRunDto, true);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
TuningRun tuningRun = MyModelUtil.copyTo(tuningRunDto, TuningRun.class);
TuningRun originalTuningRun = tuningRunService.getById(tuningRun.getRunId());
if (originalTuningRun == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!tuningRunService.update(tuningRun, originalTuningRun)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除精调任务运行数据。
*
* @param runId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long runId) {
if (MyCommonUtil.existBlankArgument(runId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(runId);
}
/**
* 列出符合过滤条件的精调任务运行列表。
*
* @param tuningRunDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<TuningRunVo>> list(
@MyRequestBody TuningRunDto tuningRunDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
TuningRun tuningRunFilter = MyModelUtil.copyTo(tuningRunDtoFilter, TuningRun.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, TuningRun.class);
List<TuningRun> tuningRunList = tuningRunService.getTuningRunListWithRelation(tuningRunFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(tuningRunList, TuningRun.INSTANCE));
}
/**
* 查看指定精调任务运行对象详情。
*
* @param runId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<TuningRunVo> view(@RequestParam Long runId) {
TuningRun tuningRun = tuningRunService.getByIdWithRelation(runId, MyRelationParam.full());
if (tuningRun == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
TuningRunVo tuningRunVo = TuningRun.INSTANCE.fromModel(tuningRun);
return ResponseResult.success(tuningRunVo);
}
private ResponseResult<Void> doDelete(Long runId) {
String errorMessage;
// 验证关联Id的数据合法性
TuningRun originalTuningRun = tuningRunService.getById(runId);
if (originalTuningRun == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!tuningRunService.remove(runId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
}
package com.yice.webadmin.app.controller;
import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.yice.webadmin.app.vo.*;
import com.yice.webadmin.app.dto.*;
import com.yice.webadmin.app.model.*;
import com.yice.webadmin.app.service.*;
import com.yice.common.core.object.*;
import com.yice.common.core.util.*;
import com.yice.common.core.constant.*;
import com.yice.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 精调任务操作控制器类。
*
* @author linking
* @date 2023-04-13
*/
@Api(tags = "精调任务管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/tuningTask")
public class TuningTaskController {
@Autowired
private TuningTaskService tuningTaskService;
/**
* 新增精调任务数据。
*
* @param tuningTaskDto 新增对象。
* @return 应答结果对象,包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"tuningTaskDto.taskId", "tuningTaskDto.searchString"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody TuningTaskDto tuningTaskDto) {
String errorMessage = MyCommonUtil.getModelValidationError(tuningTaskDto, false);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
TuningTask tuningTask = MyModelUtil.copyTo(tuningTaskDto, TuningTask.class);
tuningTask = tuningTaskService.saveNew(tuningTask);
return ResponseResult.success(tuningTask.getTaskId());
}
/**
* 更新精调任务数据。
*
* @param tuningTaskDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {"tuningTaskDto.searchString"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody TuningTaskDto tuningTaskDto) {
String errorMessage = MyCommonUtil.getModelValidationError(tuningTaskDto, true);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
TuningTask tuningTask = MyModelUtil.copyTo(tuningTaskDto, TuningTask.class);
TuningTask originalTuningTask = tuningTaskService.getById(tuningTask.getTaskId());
if (originalTuningTask == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!tuningTaskService.update(tuningTask, originalTuningTask)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除精调任务数据。
*
* @param taskId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long taskId) {
if (MyCommonUtil.existBlankArgument(taskId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(taskId);
}
/**
* 列出符合过滤条件的精调任务列表。
*
* @param tuningTaskDtoFilter 过滤对象。
* @param tuningRunDtoFilter 一对多从表过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<TuningTaskVo>> list(
@MyRequestBody TuningTaskDto tuningTaskDtoFilter,
@MyRequestBody TuningRunDto tuningRunDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
TuningTask tuningTaskFilter = MyModelUtil.copyTo(tuningTaskDtoFilter, TuningTask.class);
TuningRun tuningRunFilter = MyModelUtil.copyTo(tuningRunDtoFilter, TuningRun.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, TuningTask.class);
List<TuningTask> tuningTaskList =
tuningTaskService.getTuningTaskListWithRelation(tuningTaskFilter, tuningRunFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(tuningTaskList, TuningTask.INSTANCE));
}
/**
* 查看指定精调任务对象详情。
*
* @param taskId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<TuningTaskVo> view(@RequestParam Long taskId) {
TuningTask tuningTask = tuningTaskService.getByIdWithRelation(taskId, MyRelationParam.full());
if (tuningTask == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
TuningTaskVo tuningTaskVo = TuningTask.INSTANCE.fromModel(tuningTask);
return ResponseResult.success(tuningTaskVo);
}
private ResponseResult<Void> doDelete(Long taskId) {
String errorMessage;
// 验证关联Id的数据合法性
TuningTask originalTuningTask = tuningTaskService.getById(taskId);
if (originalTuningTask == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (!tuningTaskService.remove(taskId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
}
package com.yice.webadmin.app.dao;
import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.ModelCompress;
import com.yice.webadmin.app.model.ModelTask;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* 模型压缩数据操作访问接口。
*
* @author linking
* @date 2023-04-13
*/
public interface ModelCompressMapper extends BaseDaoMapper<ModelCompress> {
/**
* 批量插入对象列表。
*
* @param modelCompressList 新增对象列表。
*/
void insertList(List<ModelCompress> modelCompressList);
/**
* 获取过滤后的对象列表。
*
* @param modelCompressFilter 主表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<ModelCompress> getModelCompressList(
@Param("modelCompressFilter") ModelCompress modelCompressFilter, @Param("orderBy") String orderBy);
/**
* 获取过滤后的对象列表。同时支持基于一对一从表字段的过滤条件。
*
* @param modelCompressFilter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<ModelCompress> getModelCompressListEx(
@Param("modelCompressFilter") ModelCompress modelCompressFilter,
@Param("modelTaskFilter") ModelTask modelTaskFilter,
@Param("orderBy") String orderBy);
}
package com.yice.webadmin.app.dao;
import com.yice.common.core.annotation.EnableDataPerm;
import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.ModelEstimate;
import com.yice.webadmin.app.model.ModelTask;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* 模型评估数据操作访问接口。
*
* @author linking
* @date 2023-04-13
*/
@EnableDataPerm
public interface ModelEstimateMapper extends BaseDaoMapper<ModelEstimate> {
/**
* 批量插入对象列表。
*
* @param modelEstimateList 新增对象列表。
*/
void insertList(List<ModelEstimate> modelEstimateList);
/**
* 获取过滤后的对象列表。
*
* @param modelEstimateFilter 主表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<ModelEstimate> getModelEstimateList(
@Param("modelEstimateFilter") ModelEstimate modelEstimateFilter, @Param("orderBy") String orderBy);
/**
* 获取过滤后的对象列表。同时支持基于一对一从表字段的过滤条件。
*
* @param modelEstimateFilter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<ModelEstimate> getModelEstimateListEx(
@Param("modelEstimateFilter") ModelEstimate modelEstimateFilter,
@Param("modelTaskFilter") ModelTask modelTaskFilter,
@Param("orderBy") String orderBy);
}
...@@ -2,6 +2,8 @@ package com.yice.webadmin.app.dao; ...@@ -2,6 +2,8 @@ package com.yice.webadmin.app.dao;
import com.yice.common.core.base.dao.BaseDaoMapper; import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.ModelTask; import com.yice.webadmin.app.model.ModelTask;
import com.yice.webadmin.app.model.ModelEstimate;
import com.yice.webadmin.app.model.ModelCompress;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.*; import java.util.*;
...@@ -30,4 +32,19 @@ public interface ModelTaskMapper extends BaseDaoMapper<ModelTask> { ...@@ -30,4 +32,19 @@ public interface ModelTaskMapper extends BaseDaoMapper<ModelTask> {
*/ */
List<ModelTask> getModelTaskList( List<ModelTask> getModelTaskList(
@Param("modelTaskFilter") ModelTask modelTaskFilter, @Param("orderBy") String orderBy); @Param("modelTaskFilter") ModelTask modelTaskFilter, @Param("orderBy") String orderBy);
/**
* 获取过滤后的对象列表。同时支持基于一对一从表字段的过滤条件。
*
* @param modelTaskFilter 主表过滤对象。
* @param modelEstimateFilter 一对一从表过滤对象。
* @param modelCompressFilter 一对一从表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<ModelTask> getModelTaskListEx(
@Param("modelTaskFilter") ModelTask modelTaskFilter,
@Param("modelEstimateFilter") ModelEstimate modelEstimateFilter,
@Param("modelCompressFilter") ModelCompress modelCompressFilter,
@Param("orderBy") String orderBy);
} }
package com.yice.webadmin.app.dao;
import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.TuningRun;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* 精调任务运行数据操作访问接口。
*
* @author linking
* @date 2023-04-13
*/
public interface TuningRunMapper extends BaseDaoMapper<TuningRun> {
/**
* 批量插入对象列表。
*
* @param tuningRunList 新增对象列表。
*/
void insertList(List<TuningRun> tuningRunList);
/**
* 获取过滤后的对象列表。
*
* @param tuningRunFilter 主表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<TuningRun> getTuningRunList(
@Param("tuningRunFilter") TuningRun tuningRunFilter, @Param("orderBy") String orderBy);
}
package com.yice.webadmin.app.dao;
import com.yice.common.core.base.dao.BaseDaoMapper;
import com.yice.webadmin.app.model.TuningTask;
import com.yice.webadmin.app.model.TuningRun;
import org.apache.ibatis.annotations.Param;
import java.util.*;
/**
* 精调任务数据操作访问接口。
*
* @author linking
* @date 2023-04-13
*/
public interface TuningTaskMapper extends BaseDaoMapper<TuningTask> {
/**
* 批量插入对象列表。
*
* @param tuningTaskList 新增对象列表。
*/
void insertList(List<TuningTask> tuningTaskList);
/**
* 获取过滤后的对象列表。
*
* @param tuningTaskFilter 主表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<TuningTask> getTuningTaskList(
@Param("tuningTaskFilter") TuningTask tuningTaskFilter, @Param("orderBy") String orderBy);
/**
* 获取过滤后的对象列表。同时支持基于一对一从表字段的过滤条件。
*
* @param tuningTaskFilter 主表过滤对象。
* @param tuningRunFilter 一对多从表过滤对象。
* @param orderBy 排序字符串,order by从句的参数。
* @return 对象列表。
*/
List<TuningTask> getTuningTaskListEx(
@Param("tuningTaskFilter") TuningTask tuningTaskFilter,
@Param("tuningRunFilter") TuningRun tuningRunFilter,
@Param("orderBy") String orderBy);
}
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/> <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="deleted_flag" jdbcType="TINYINT" property="deletedFlag"/>
<result column="data_type" jdbcType="TINYINT" property="dataType"/> <result column="data_type" jdbcType="TINYINT" property="dataType"/>
</resultMap> </resultMap>
...@@ -24,7 +23,6 @@ ...@@ -24,7 +23,6 @@
create_time, create_time,
update_user_id, update_user_id,
update_time, update_time,
deleted_flag,
data_type) data_type)
VALUES VALUES
<foreach collection="list" index="index" item="item" separator="," > <foreach collection="list" index="index" item="item" separator="," >
...@@ -36,7 +34,6 @@ ...@@ -36,7 +34,6 @@
#{item.createTime}, #{item.createTime},
#{item.updateUserId}, #{item.updateUserId},
#{item.updateTime}, #{item.updateTime},
#{item.deletedFlag},
#{item.dataType}) #{item.dataType})
</foreach> </foreach>
</insert> </insert>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/> <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="deleted_flag" jdbcType="TINYINT" property="deletedFlag"/>
<result column="dataset_id" jdbcType="BIGINT" property="datasetId"/> <result column="dataset_id" jdbcType="BIGINT" property="datasetId"/>
<result column="output_status" jdbcType="TINYINT" property="outputStatus"/> <result column="output_status" jdbcType="TINYINT" property="outputStatus"/>
<result column="clean_status" jdbcType="TINYINT" property="cleanStatus"/> <result column="clean_status" jdbcType="TINYINT" property="cleanStatus"/>
...@@ -33,7 +32,6 @@ ...@@ -33,7 +32,6 @@
create_time, create_time,
update_user_id, update_user_id,
update_time, update_time,
deleted_flag,
dataset_id, dataset_id,
output_status, output_status,
clean_status, clean_status,
...@@ -54,7 +52,6 @@ ...@@ -54,7 +52,6 @@
#{item.createTime}, #{item.createTime},
#{item.updateUserId}, #{item.updateUserId},
#{item.updateTime}, #{item.updateTime},
#{item.deletedFlag},
#{item.datasetId}, #{item.datasetId},
#{item.outputStatus}, #{item.outputStatus},
#{item.cleanStatus}, #{item.cleanStatus},
...@@ -74,7 +71,6 @@ ...@@ -74,7 +71,6 @@
<sql id="filterRef"> <sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 --> <!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.DatasetVersionMapper.inputFilterRef"/> <include refid="com.yice.webadmin.app.dao.DatasetVersionMapper.inputFilterRef"/>
AND lmp_dataset_version.deleted_flag = ${@com.yice.common.core.constant.GlobalDeletedFlag@NORMAL}
</sql> </sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 --> <!-- 这里仅包含调用接口输入的主表过滤条件 -->
......
<?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.ModelCompressMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelCompress">
<id column="task_id" jdbcType="BIGINT" property="taskId"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="task_name" jdbcType="VARCHAR" property="taskName"/>
<result column="task_describe" jdbcType="VARCHAR" property="taskDescribe"/>
<result column="source_model_id" jdbcType="BIGINT" property="sourceModelId"/>
<result column="create_method" jdbcType="TINYINT" property="createMethod"/>
<result column="target_model_id" jdbcType="BIGINT" property="targetModelId"/>
</resultMap>
<insert id="insertList">
INSERT INTO lmp_model_compress
(task_id,
create_user_id,
create_time,
update_user_id,
update_time,
task_name,
task_describe,
source_model_id,
create_method,
target_model_id)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.taskId},
#{item.createUserId},
#{item.createTime},
#{item.updateUserId},
#{item.updateTime},
#{item.taskName},
#{item.taskDescribe},
#{item.sourceModelId},
#{item.createMethod},
#{item.targetModelId})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.ModelCompressMapper.inputFilterRef"/>
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="modelCompressFilter != null">
<if test="modelCompressFilter.taskId != null">
AND lmp_model_compress.task_id = #{modelCompressFilter.taskId}
</if>
<if test="modelCompressFilter.searchString != null and modelCompressFilter.searchString != ''">
<bind name = "safeModelCompressSearchString" value = "'%' + modelCompressFilter.searchString + '%'" />
AND IFNULL(lmp_model_compress.task_name,'') LIKE #{safeModelCompressSearchString}
</if>
</if>
</sql>
<select id="getModelCompressList" resultMap="BaseResultMap" parameterType="com.yice.webadmin.app.model.ModelCompress">
SELECT * FROM lmp_model_compress
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<!-- 支持基于一对一或者一对多从表字段过滤的SQL_ID -->
<select id="getModelCompressListEx" resultMap="BaseResultMap" >
SELECT
lmp_model_compress.*
FROM
lmp_model_compress
LEFT JOIN
lmp_model_task ON lmp_model_compress.task_id = lmp_model_task.task_id
<where>
<include refid="filterRef"/>
<include refid="com.yice.webadmin.app.dao.ModelTaskMapper.inputFilterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper>
<?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.ModelEstimateMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.ModelEstimate">
<id column="task_id" jdbcType="BIGINT" property="taskId"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="task_name" jdbcType="VARCHAR" property="taskName"/>
<result column="task_describe" jdbcType="VARCHAR" property="taskDescribe"/>
<result column="model_version_id" jdbcType="BIGINT" property="modelVersionId"/>
<result column="dataset_version_id" jdbcType="BIGINT" property="datasetVersionId"/>
<result column="scoring_mode" jdbcType="TINYINT" property="scoringMode"/>
</resultMap>
<insert id="insertList">
INSERT INTO lmp_model_estimate
(task_id,
create_user_id,
create_time,
update_user_id,
update_time,
task_name,
task_describe,
model_version_id,
dataset_version_id,
scoring_mode)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.taskId},
#{item.createUserId},
#{item.createTime},
#{item.updateUserId},
#{item.updateTime},
#{item.taskName},
#{item.taskDescribe},
#{item.modelVersionId},
#{item.datasetVersionId},
#{item.scoringMode})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.ModelEstimateMapper.inputFilterRef"/>
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="modelEstimateFilter != null">
<if test="modelEstimateFilter.taskId != null">
AND lmp_model_estimate.task_id = #{modelEstimateFilter.taskId}
</if>
<if test="modelEstimateFilter.searchString != null and modelEstimateFilter.searchString != ''">
<bind name = "safeModelEstimateSearchString" value = "'%' + modelEstimateFilter.searchString + '%'" />
AND IFNULL(lmp_model_estimate.task_name,'') LIKE #{safeModelEstimateSearchString}
</if>
</if>
</sql>
<select id="getModelEstimateList" resultMap="BaseResultMap" parameterType="com.yice.webadmin.app.model.ModelEstimate">
SELECT * FROM lmp_model_estimate
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<!-- 支持基于一对一或者一对多从表字段过滤的SQL_ID -->
<select id="getModelEstimateListEx" resultMap="BaseResultMap" >
SELECT
lmp_model_estimate.*
FROM
lmp_model_estimate
LEFT JOIN
lmp_model_task ON lmp_model_estimate.task_id = lmp_model_task.task_id
<where>
<include refid="filterRef"/>
<include refid="com.yice.webadmin.app.dao.ModelTaskMapper.inputFilterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper>
...@@ -74,4 +74,24 @@ ...@@ -74,4 +74,24 @@
ORDER BY ${orderBy} ORDER BY ${orderBy}
</if> </if>
</select> </select>
<!-- 支持基于一对一或者一对多从表字段过滤的SQL_ID -->
<select id="getModelTaskListEx" resultMap="BaseResultMap" >
SELECT
lmp_model_task.*
FROM
lmp_model_task
LEFT JOIN
lmp_model_estimate ON lmp_model_task.task_id = lmp_model_estimate.task_id
LEFT JOIN
lmp_model_compress ON lmp_model_task.task_id = lmp_model_compress.task_id
<where>
<include refid="filterRef"/>
<include refid="com.yice.webadmin.app.dao.ModelEstimateMapper.inputFilterRef"/>
<include refid="com.yice.webadmin.app.dao.ModelCompressMapper.inputFilterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper> </mapper>
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
<result column="model_training_method" jdbcType="VARCHAR" property="modelTrainingMethod"/> <result column="model_training_method" jdbcType="VARCHAR" property="modelTrainingMethod"/>
<result column="run_name" jdbcType="VARCHAR" property="runName"/> <result column="run_name" jdbcType="VARCHAR" property="runName"/>
<result column="training_task" jdbcType="VARCHAR" property="trainingTask"/> <result column="training_task" jdbcType="VARCHAR" property="trainingTask"/>
<result column="model_url" jdbcType="VARCHAR" property="modelUrl"/>
<result column="is_compress" jdbcType="TINYINT" property="isCompress"/>
</resultMap> </resultMap>
<insert id="insertList"> <insert id="insertList">
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/> <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="deleted_flag" jdbcType="TINYINT" property="deletedFlag"/>
<result column="template_name" jdbcType="VARCHAR" property="templateName"/> <result column="template_name" jdbcType="VARCHAR" property="templateName"/>
<result column="template_label" jdbcType="VARCHAR" property="templateLabel"/> <result column="template_label" jdbcType="VARCHAR" property="templateLabel"/>
<result column="view_count" jdbcType="BIGINT" property="viewCount"/> <result column="view_count" jdbcType="BIGINT" property="viewCount"/>
...@@ -31,7 +30,6 @@ ...@@ -31,7 +30,6 @@
create_time, create_time,
update_user_id, update_user_id,
update_time, update_time,
deleted_flag,
template_name, template_name,
template_label, template_label,
view_count, view_count,
...@@ -51,7 +49,6 @@ ...@@ -51,7 +49,6 @@
#{item.createTime}, #{item.createTime},
#{item.updateUserId}, #{item.updateUserId},
#{item.updateTime}, #{item.updateTime},
#{item.deletedFlag},
#{item.templateName}, #{item.templateName},
#{item.templateLabel}, #{item.templateLabel},
#{item.viewCount}, #{item.viewCount},
...@@ -71,7 +68,6 @@ ...@@ -71,7 +68,6 @@
<sql id="filterRef"> <sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 --> <!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.PromptTemplateMapper.inputFilterRef"/> <include refid="com.yice.webadmin.app.dao.PromptTemplateMapper.inputFilterRef"/>
AND lmp_prompt_template.deleted_flag = ${@com.yice.common.core.constant.GlobalDeletedFlag@NORMAL}
</sql> </sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 --> <!-- 这里仅包含调用接口输入的主表过滤条件 -->
......
<?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.TuningRunMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.TuningRun">
<id column="run_id" jdbcType="BIGINT" property="runId"/>
<result column="task_id" jdbcType="BIGINT" property="taskId"/>
<result column="run_status" jdbcType="TINYINT" property="runStatus"/>
<result column="run_version" jdbcType="TINYINT" property="runVersion"/>
<result column="run_name" jdbcType="VARCHAR" property="runName"/>
<result column="model_id" jdbcType="BIGINT" property="modelId"/>
<result column="model_version_id" jdbcType="BIGINT" property="modelVersionId"/>
<result column="run_time" jdbcType="BIGINT" property="runTime"/>
<result column="dataset_version_id" jdbcType="BIGINT" property="datasetVersionId"/>
<result column="split_ratio" jdbcType="TINYINT" property="splitRatio"/>
<result column="train_mode" jdbcType="VARCHAR" property="trainMode"/>
<result column="train_method" jdbcType="VARCHAR" property="trainMethod"/>
<result column="configuration" jdbcType="LONGVARCHAR" property="configuration"/>
<result column="publish_status" jdbcType="TINYINT" property="publishStatus"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<insert id="insertList">
INSERT INTO lmp_tuning_run
(run_id,
task_id,
run_status,
run_version,
run_name,
model_id,
model_version_id,
run_time,
dataset_version_id,
split_ratio,
train_mode,
train_method,
configuration,
publish_status,
create_user_id,
create_time,
update_user_id,
update_time)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.runId},
#{item.taskId},
#{item.runStatus},
#{item.runVersion},
#{item.runName},
#{item.modelId},
#{item.modelVersionId},
#{item.runTime},
#{item.datasetVersionId},
#{item.splitRatio},
#{item.trainMode},
#{item.trainMethod},
#{item.configuration},
#{item.publishStatus},
#{item.createUserId},
#{item.createTime},
#{item.updateUserId},
#{item.updateTime})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.TuningRunMapper.inputFilterRef"/>
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="tuningRunFilter != null">
<if test="tuningRunFilter.runId != null">
AND lmp_tuning_run.run_id = #{tuningRunFilter.runId}
</if>
<if test="tuningRunFilter.taskId != null">
AND lmp_tuning_run.task_id = #{tuningRunFilter.taskId}
</if>
</if>
</sql>
<select id="getTuningRunList" resultMap="BaseResultMap" parameterType="com.yice.webadmin.app.model.TuningRun">
SELECT * FROM lmp_tuning_run
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper>
<?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.TuningTaskMapper">
<resultMap id="BaseResultMap" type="com.yice.webadmin.app.model.TuningTask">
<id column="task_id" jdbcType="BIGINT" property="taskId"/>
<result column="task_name" jdbcType="VARCHAR" property="taskName"/>
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<result column="task_describe" jdbcType="VARCHAR" property="taskDescribe"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<insert id="insertList">
INSERT INTO lmp_tuning_task
(task_id,
task_name,
task_type,
task_describe,
create_user_id,
create_time,
update_user_id,
update_time)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.taskId},
#{item.taskName},
#{item.taskType},
#{item.taskDescribe},
#{item.createUserId},
#{item.createTime},
#{item.updateUserId},
#{item.updateTime})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.yice.webadmin.app.dao.TuningTaskMapper.inputFilterRef"/>
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="tuningTaskFilter != null">
<if test="tuningTaskFilter.taskId != null">
AND lmp_tuning_task.task_id = #{tuningTaskFilter.taskId}
</if>
<if test="tuningTaskFilter.taskName != null and tuningTaskFilter.taskName != ''">
<bind name = "safeTuningTaskTaskName" value = "'%' + tuningTaskFilter.taskName + '%'" />
AND lmp_tuning_task.task_name LIKE #{safeTuningTaskTaskName}
</if>
<if test="tuningTaskFilter.searchString != null and tuningTaskFilter.searchString != ''">
<bind name = "safeTuningTaskSearchString" value = "'%' + tuningTaskFilter.searchString + '%'" />
AND IFNULL(lmp_tuning_task.task_name,'') LIKE #{safeTuningTaskSearchString}
</if>
</if>
</sql>
<select id="getTuningTaskList" resultMap="BaseResultMap" parameterType="com.yice.webadmin.app.model.TuningTask">
SELECT * FROM lmp_tuning_task
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
<!-- 支持基于一对一或者一对多从表字段过滤的SQL_ID -->
<select id="getTuningTaskListEx" resultMap="BaseResultMap" >
SELECT
lmp_tuning_task.*
FROM
lmp_tuning_task
<where>
<include refid="filterRef"/>
<if test="tuningRunFilter != null">
AND EXISTS (SELECT * FROM lmp_tuning_run
<where>
lmp_tuning_task.task_id = lmp_tuning_run.task_id
<include refid="com.yice.webadmin.app.dao.TuningRunMapper.filterRef"/>
</where>)
</if>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
</select>
</mapper>
...@@ -43,12 +43,6 @@ public class DatasetManageDto { ...@@ -43,12 +43,6 @@ public class DatasetManageDto {
@ApiModelProperty(value = "模板") @ApiModelProperty(value = "模板")
private Integer template; private Integer template;
/**
* 删除标识。
*/
@ApiModelProperty(value = "删除标识")
private Integer deletedFlag;
/** /**
* 数据类型。 * 数据类型。
*/ */
......
package com.yice.webadmin.app.dto;
import com.yice.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* ModelCompressDto对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("ModelCompressDto对象")
@Data
public class ModelCompressDto {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID", required = true)
@NotNull(message = "数据验证失败,任务ID不能为空!", groups = {UpdateGroup.class})
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 描述。
*/
@ApiModelProperty(value = "描述")
private String taskDescribe;
/**
* 源模型版本ID。
*/
@ApiModelProperty(value = "源模型版本ID")
private Long sourceVersionId;
/**
* 创建方式。
*/
@ApiModelProperty(value = "创建方式")
private Integer createMethod;
/**
* 目标模型。
*/
@ApiModelProperty(value = "目标模型")
private Long targetModelId;
/**
* 新模型名称。
*/
@ApiModelProperty(value = "新模型名称")
private String targetModelName;
/**
* task_name LIKE搜索字符串。
*/
@ApiModelProperty(value = "LIKE模糊搜索字符串")
private String searchString;
}
package com.yice.webadmin.app.dto;
import com.yice.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* ModelEstimateDto对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("ModelEstimateDto对象")
@Data
public class ModelEstimateDto {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID", required = true)
@NotNull(message = "数据验证失败,任务ID不能为空!", groups = {UpdateGroup.class})
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 描述。
*/
@ApiModelProperty(value = "描述")
private String taskDescribe;
/**
* 待评估模型版本ID。
*/
@ApiModelProperty(value = "待评估模型版本ID")
private Long modelVersionId;
/**
* 评估数据集版本ID。
*/
@ApiModelProperty(value = "评估数据集版本ID")
private Long datasetVersionId;
/**
* 打分模式。
*/
@ApiModelProperty(value = "打分模式")
private Integer scoringMode;
/**
* task_name LIKE搜索字符串。
*/
@ApiModelProperty(value = "LIKE模糊搜索字符串")
private String searchString;
}
...@@ -126,4 +126,11 @@ public class ModelVersionDto { ...@@ -126,4 +126,11 @@ public class ModelVersionDto {
*/ */
@ApiModelProperty(value = "模型地址") @ApiModelProperty(value = "模型地址")
private String modelUrl; private String modelUrl;
/**
* 是否被压缩。
*/
@ApiModelProperty(value = "是否被压缩")
private Integer isCompress;
} }
package com.yice.webadmin.app.dto;
import com.yice.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* TuningRunDto对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("TuningRunDto对象")
@Data
public class TuningRunDto {
/**
* 运行ID。
*/
@ApiModelProperty(value = "运行ID", required = true)
@NotNull(message = "数据验证失败,运行ID不能为空!", groups = {UpdateGroup.class})
private Long runId;
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID")
private Long taskId;
/**
* 运行状态。
*/
@ApiModelProperty(value = "运行状态")
private Integer runStatus;
/**
* 运行版本号。
*/
@ApiModelProperty(value = "运行版本号")
private Integer runVersion;
/**
* 运行名称。
*/
@ApiModelProperty(value = "运行名称")
private String runName;
/**
* 基础模型ID。
*/
@ApiModelProperty(value = "基础模型ID")
private Long modelId;
/**
* 基础模型版本ID。
*/
@ApiModelProperty(value = "基础模型版本ID")
private Long modelVersionId;
/**
* 运行时长。
*/
@ApiModelProperty(value = "运行时长")
private Long runTime;
/**
* 数据集版本ID。
*/
@ApiModelProperty(value = "数据集版本ID")
private Long datasetVersionId;
/**
* 拆分比例。
*/
@ApiModelProperty(value = "拆分比例")
private Integer splitRatio;
/**
* 训练模式。
*/
@ApiModelProperty(value = "训练模式")
private String trainMode;
/**
* 训练方法。
*/
@ApiModelProperty(value = "训练方法")
private String trainMethod;
/**
* 参数配置。
*/
@ApiModelProperty(value = "参数配置")
private String configuration;
/**
* 发布状态。
*/
@ApiModelProperty(value = "发布状态")
private Integer publishStatus;
}
package com.yice.webadmin.app.dto;
import com.yice.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* TuningTaskDto对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("TuningTaskDto对象")
@Data
public class TuningTaskDto {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID", required = true)
@NotNull(message = "数据验证失败,任务ID不能为空!", groups = {UpdateGroup.class})
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 任务类型。
*/
@ApiModelProperty(value = "任务类型")
private Integer taskType;
/**
* 任务描述。
*/
@ApiModelProperty(value = "任务描述")
private String taskDescribe;
/**
* task_name LIKE搜索字符串。
*/
@ApiModelProperty(value = "LIKE模糊搜索字符串")
private String searchString;
}
...@@ -44,10 +44,6 @@ public class DatasetManage extends BaseModel { ...@@ -44,10 +44,6 @@ public class DatasetManage extends BaseModel {
*/ */
private Integer template; private Integer template;
/**
* 删除标识。
*/
private Integer deletedFlag;
/** /**
* 数据类型。 * 数据类型。
......
...@@ -37,11 +37,6 @@ public class DatasetVersion extends BaseModel { ...@@ -37,11 +37,6 @@ public class DatasetVersion extends BaseModel {
*/ */
private Integer inputStatus; private Integer inputStatus;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
private Integer deletedFlag;
/** /**
* 数据集ID。 * 数据集ID。
......
package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.yice.common.core.util.MyCommonUtil;
import com.yice.common.core.annotation.*;
import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.webadmin.app.vo.ModelCompressVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
/**
* ModelCompress实体对象。
*
* @author linking
* @date 2023-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "lmp_model_compress")
public class ModelCompress extends BaseModel {
/**
* 任务ID。
*/
@TableId(value = "task_id")
private Long taskId;
/**
* 任务名称。
*/
private String taskName;
/**
* 描述。
*/
private String taskDescribe;
/**
* 源模型。
*/
private Long sourceVersionId;
/**
* 创建方式。
*/
private Integer createMethod;
/**
* 目标模型。
*/
private Long targetVersionId;
/**
* 目标模型。
*/
@TableField(exist = false)
private Long targetModelId;
/**
* 新模型名称。
*/
@TableField(exist = false)
private String targetModelName;
/**
* task_name LIKE搜索字符串。
*/
@TableField(exist = false)
private String searchString;
public void setSearchString(String searchString) {
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
}
@RelationOneToOne(
masterIdField = "taskId",
slaveModelClass = ModelTask.class,
slaveIdField = "taskId")
@TableField(exist = false)
private ModelTask modelTask;
@Mapper
public interface ModelCompressModelMapper extends BaseModelMapper<ModelCompressVo, ModelCompress> {
/**
* 转换Vo对象到实体对象。
*
* @param modelCompressVo 域对象。
* @return 实体对象。
*/
@Mapping(target = "modelTask", expression = "java(mapToBean(modelCompressVo.getModelTask(), com.yice.webadmin.app.model.ModelTask.class))")
@Override
ModelCompress toModel(ModelCompressVo modelCompressVo);
/**
* 转换实体对象到VO对象。
*
* @param modelCompress 实体对象。
* @return 域对象。
*/
@Mapping(target = "modelTask", expression = "java(beanToMap(modelCompress.getModelTask(), false))")
@Override
ModelCompressVo fromModel(ModelCompress modelCompress);
}
public static final ModelCompressModelMapper INSTANCE = Mappers.getMapper(ModelCompressModelMapper.class);
}
package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.yice.common.core.util.MyCommonUtil;
import com.yice.common.core.annotation.*;
import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.webadmin.app.vo.ModelEstimateVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
/**
* ModelEstimate实体对象。
*
* @author linking
* @date 2023-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "lmp_model_estimate")
public class ModelEstimate extends BaseModel {
/**
* 任务ID。
*/
@TableId(value = "task_id")
private Long taskId;
/**
* 任务名称。
*/
private String taskName;
/**
* 描述。
*/
private String taskDescribe;
/**
* 待评估模型版本ID。
*/
private Long modelVersionId;
/**
* 评估数据集版本ID。
*/
private Long datasetVersionId;
/**
* 打分模式。
*/
private Integer scoringMode;
/**
* task_name LIKE搜索字符串。
*/
@TableField(exist = false)
private String searchString;
public void setSearchString(String searchString) {
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
}
@RelationOneToOne(
masterIdField = "taskId",
slaveModelClass = ModelTask.class,
slaveIdField = "taskId")
@TableField(exist = false)
private ModelTask modelTask;
@Mapper
public interface ModelEstimateModelMapper extends BaseModelMapper<ModelEstimateVo, ModelEstimate> {
/**
* 转换Vo对象到实体对象。
*
* @param modelEstimateVo 域对象。
* @return 实体对象。
*/
@Mapping(target = "modelTask", expression = "java(mapToBean(modelEstimateVo.getModelTask(), com.yice.webadmin.app.model.ModelTask.class))")
@Override
ModelEstimate toModel(ModelEstimateVo modelEstimateVo);
/**
* 转换实体对象到VO对象。
*
* @param modelEstimate 实体对象。
* @return 域对象。
*/
@Mapping(target = "modelTask", expression = "java(beanToMap(modelEstimate.getModelTask(), false))")
@Override
ModelEstimateVo fromModel(ModelEstimate modelEstimate);
}
public static final ModelEstimateModelMapper INSTANCE = Mappers.getMapper(ModelEstimateModelMapper.class);
}
package com.yice.webadmin.app.model; package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.yice.common.core.annotation.*;
import com.yice.common.core.base.model.BaseModel; import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.base.mapper.BaseModelMapper; import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.webadmin.app.vo.ModelTaskVo; import com.yice.webadmin.app.vo.ModelTaskVo;
...@@ -63,8 +64,42 @@ public class ModelTask extends BaseModel { ...@@ -63,8 +64,42 @@ public class ModelTask extends BaseModel {
*/ */
private Integer modelVersion; private Integer modelVersion;
@RelationOneToOne(
masterIdField = "taskId",
slaveModelClass = ModelEstimate.class,
slaveIdField = "taskId")
@TableField(exist = false)
private ModelEstimate modelEstimate;
@RelationOneToOne(
masterIdField = "taskId",
slaveModelClass = ModelCompress.class,
slaveIdField = "taskId")
@TableField(exist = false)
private ModelCompress modelCompress;
@Mapper @Mapper
public interface ModelTaskModelMapper extends BaseModelMapper<ModelTaskVo, ModelTask> { public interface ModelTaskModelMapper extends BaseModelMapper<ModelTaskVo, ModelTask> {
/**
* 转换Vo对象到实体对象。
*
* @param modelTaskVo 域对象。
* @return 实体对象。
*/
@Mapping(target = "modelEstimate", expression = "java(mapToBean(modelTaskVo.getModelEstimate(), com.yice.webadmin.app.model.ModelEstimate.class))")
@Mapping(target = "modelCompress", expression = "java(mapToBean(modelTaskVo.getModelCompress(), com.yice.webadmin.app.model.ModelCompress.class))")
@Override
ModelTask toModel(ModelTaskVo modelTaskVo);
/**
* 转换实体对象到VO对象。
*
* @param modelTask 实体对象。
* @return 域对象。
*/
@Mapping(target = "modelEstimate", expression = "java(beanToMap(modelTask.getModelEstimate(), false))")
@Mapping(target = "modelCompress", expression = "java(beanToMap(modelTask.getModelCompress(), false))")
@Override
ModelTaskVo fromModel(ModelTask modelTask);
} }
public static final ModelTaskModelMapper INSTANCE = Mappers.getMapper(ModelTaskModelMapper.class); public static final ModelTaskModelMapper INSTANCE = Mappers.getMapper(ModelTaskModelMapper.class);
} }
...@@ -116,7 +116,7 @@ public class ModelVersion extends BaseModel { ...@@ -116,7 +116,7 @@ public class ModelVersion extends BaseModel {
/** /**
* 是否被压缩。 * 是否被压缩。
*/ */
private String isCompress; private Integer isCompress;
@RelationOneToOne( @RelationOneToOne(
masterIdField = "modelId", masterIdField = "modelId",
......
...@@ -30,11 +30,6 @@ public class PromptTemplate extends BaseModel { ...@@ -30,11 +30,6 @@ public class PromptTemplate extends BaseModel {
@TableId(value = "template_id") @TableId(value = "template_id")
private Long templateId; private Long templateId;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
private Integer deletedFlag;
/** /**
* 模板名称。 * 模板名称。
......
package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.webadmin.app.vo.TuningRunVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
/**
* TuningRun实体对象。
*
* @author linking
* @date 2023-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "lmp_tuning_run")
public class TuningRun extends BaseModel {
/**
* 运行ID。
*/
@TableId(value = "run_id")
private Long runId;
/**
* 任务ID。
*/
private Long taskId;
/**
* 运行状态。
*/
private Integer runStatus;
/**
* 运行版本号。
*/
private Integer runVersion;
/**
* 运行名称。
*/
private String runName;
/**
* 基础模型ID。
*/
private Long modelId;
/**
* 基础模型版本ID。
*/
private Long modelVersionId;
/**
* 运行时长。
*/
private Long runTime;
/**
* 数据集版本ID。
*/
private Long datasetVersionId;
/**
* 拆分比例。
*/
private Integer splitRatio;
/**
* 训练模式。
*/
private String trainMode;
/**
* 训练方法。
*/
private String trainMethod;
/**
* 参数配置。
*/
private String configuration;
/**
* 发布状态。
*/
private Integer publishStatus;
@Mapper
public interface TuningRunModelMapper extends BaseModelMapper<TuningRunVo, TuningRun> {
}
public static final TuningRunModelMapper INSTANCE = Mappers.getMapper(TuningRunModelMapper.class);
}
package com.yice.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.yice.common.core.util.MyCommonUtil;
import com.yice.common.core.annotation.*;
import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.webadmin.app.vo.TuningTaskVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* TuningTask实体对象。
*
* @author linking
* @date 2023-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "lmp_tuning_task")
public class TuningTask extends BaseModel {
/**
* 任务ID。
*/
@TableId(value = "task_id")
private Long taskId;
/**
* 任务名称。
*/
private String taskName;
/**
* 任务类型。
*/
private Integer taskType;
/**
* 任务描述。
*/
private String taskDescribe;
/**
* task_name LIKE搜索字符串。
*/
@TableField(exist = false)
private String searchString;
public void setSearchString(String searchString) {
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
}
/**
* TuningRun 的一对多关联表数据对象。
* 通常在一对多的关联中,我们基于从表数据过滤主表数据,此时需要先对从表数据进行嵌套子查询过滤,并将从表过滤数据列表集成到该字段。
*/
@RelationOneToMany(
masterIdField = "taskId",
slaveModelClass = TuningRun.class,
slaveIdField = "taskId")
@TableField(exist = false)
private List<TuningRun> tuningRunList;
@Mapper
public interface TuningTaskModelMapper extends BaseModelMapper<TuningTaskVo, TuningTask> {
/**
* 转换Vo对象到实体对象。
*
* @param tuningTaskVo 域对象。
* @return 实体对象。
*/
@Mapping(target = "tuningRunList", expression = "java(mapToBean(tuningTaskVo.getTuningRunList(), com.yice.webadmin.app.model.TuningRun.class))")
@Override
TuningTask toModel(TuningTaskVo tuningTaskVo);
/**
* 转换实体对象到VO对象。
*
* @param tuningTask 实体对象。
* @return 域对象。
*/
@Mapping(target = "tuningRunList", expression = "java(beanToMap(tuningTask.getTuningRunList(), false))")
@Override
TuningTaskVo fromModel(TuningTask tuningTask);
}
public static final TuningTaskModelMapper INSTANCE = Mappers.getMapper(TuningTaskModelMapper.class);
}
package com.yice.webadmin.app.service;
import com.alibaba.fastjson.JSONObject;
import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.service.IBaseService;
import java.util.*;
/**
* 模型压缩数据操作服务接口。
*
* @author linking
* @date 2023-04-13
*/
public interface ModelCompressService extends IBaseService<ModelCompress, Long> {
/**
* 保存新增对象。
*
* @param modelCompress 新增对象。
* @return 返回新增对象。
*/
ModelCompress saveNew(ModelCompress modelCompress);
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param modelCompressList 新增对象列表。
*/
void saveNewBatch(List<ModelCompress> modelCompressList);
/**
* 保存新增主表对象及关联对象。
*
* @param modelCompress 新增主表对象。
* @param relationData 全部关联从表数据。
* @return 返回新增主表对象。
*/
ModelCompress saveNewWithRelation(ModelCompress modelCompress, JSONObject relationData);
/**
* 更新数据对象。
*
* @param modelCompress 更新的对象。
* @param originalModelCompress 原有数据对象。
* @return 成功返回true,否则false。
*/
boolean update(ModelCompress modelCompress, ModelCompress originalModelCompress);
/**
* 更新主表对象及关联对象。
*
* @param modelCompress 主表对象新数据。
* @param originalModelCompress 主表对象源数据。
* @param relationData 全部关联从表数据。
* @return 修改成功返回true,否则false。
*/
boolean updateWithRelation(ModelCompress modelCompress, ModelCompress originalModelCompress, JSONObject relationData);
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
boolean remove(Long taskId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getModelCompressListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<ModelCompress> getModelCompressList(ModelCompress filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getModelCompressList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<ModelCompress> getModelCompressListWithRelation(ModelCompress filter, ModelTask modelTaskFilter, String orderBy);
}
package com.yice.webadmin.app.service;
import com.alibaba.fastjson.JSONObject;
import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.service.IBaseService;
import java.util.*;
/**
* 模型评估数据操作服务接口。
*
* @author linking
* @date 2023-04-13
*/
public interface ModelEstimateService extends IBaseService<ModelEstimate, Long> {
/**
* 保存新增对象。
*
* @param modelEstimate 新增对象。
* @return 返回新增对象。
*/
ModelEstimate saveNew(ModelEstimate modelEstimate);
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param modelEstimateList 新增对象列表。
*/
void saveNewBatch(List<ModelEstimate> modelEstimateList);
/**
* 保存新增主表对象及关联对象。
*
* @param modelEstimate 新增主表对象。
* @param relationData 全部关联从表数据。
* @return 返回新增主表对象。
*/
ModelEstimate saveNewWithRelation(ModelEstimate modelEstimate, JSONObject relationData);
/**
* 更新数据对象。
*
* @param modelEstimate 更新的对象。
* @param originalModelEstimate 原有数据对象。
* @return 成功返回true,否则false。
*/
boolean update(ModelEstimate modelEstimate, ModelEstimate originalModelEstimate);
/**
* 更新主表对象及关联对象。
*
* @param modelEstimate 主表对象新数据。
* @param originalModelEstimate 主表对象源数据。
* @param relationData 全部关联从表数据。
* @return 修改成功返回true,否则false。
*/
boolean updateWithRelation(ModelEstimate modelEstimate, ModelEstimate originalModelEstimate, JSONObject relationData);
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
boolean remove(Long taskId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getModelEstimateListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<ModelEstimate> getModelEstimateList(ModelEstimate filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getModelEstimateList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<ModelEstimate> getModelEstimateListWithRelation(ModelEstimate filter, ModelTask modelTaskFilter, String orderBy);
}
package com.yice.webadmin.app.service; package com.yice.webadmin.app.service;
import com.alibaba.fastjson.JSONObject;
import com.yice.webadmin.app.model.*; import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.service.IBaseService; import com.yice.common.core.base.service.IBaseService;
...@@ -28,6 +29,15 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> { ...@@ -28,6 +29,15 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> {
*/ */
void saveNewBatch(List<ModelTask> modelTaskList); void saveNewBatch(List<ModelTask> modelTaskList);
/**
* 保存新增主表对象及关联对象。
*
* @param modelTask 新增主表对象。
* @param relationData 全部关联从表数据。
* @return 返回新增主表对象。
*/
ModelTask saveNewWithRelation(ModelTask modelTask, JSONObject relationData);
/** /**
* 更新数据对象。 * 更新数据对象。
* *
...@@ -37,6 +47,16 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> { ...@@ -37,6 +47,16 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> {
*/ */
boolean update(ModelTask modelTask, ModelTask originalModelTask); boolean update(ModelTask modelTask, ModelTask originalModelTask);
/**
* 更新主表对象及关联对象。
*
* @param modelTask 主表对象新数据。
* @param originalModelTask 主表对象源数据。
* @param relationData 全部关联从表数据。
* @return 修改成功返回true,否则false。
*/
boolean updateWithRelation(ModelTask modelTask, ModelTask originalModelTask, JSONObject relationData);
/** /**
* 删除指定数据。 * 删除指定数据。
* *
...@@ -69,8 +89,10 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> { ...@@ -69,8 +89,10 @@ public interface ModelTaskService extends IBaseService<ModelTask, Long> {
* 如果仅仅需要获取主表数据,请移步(getModelTaskList),以便获取更好的查询性能。 * 如果仅仅需要获取主表数据,请移步(getModelTaskList),以便获取更好的查询性能。
* *
* @param filter 主表过滤对象。 * @param filter 主表过滤对象。
* @param modelEstimateFilter 一对一从表过滤对象。
* @param modelCompressFilter 一对一从表过滤对象。
* @param orderBy 排序参数。 * @param orderBy 排序参数。
* @return 查询结果集。 * @return 查询结果集。
*/ */
List<ModelTask> getModelTaskListWithRelation(ModelTask filter, String orderBy); List<ModelTask> getModelTaskListWithRelation(ModelTask filter, ModelEstimate modelEstimateFilter, ModelCompress modelCompressFilter, String orderBy);
} }
package com.yice.webadmin.app.service;
import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.service.IBaseService;
import java.util.*;
/**
* 精调任务运行数据操作服务接口。
*
* @author linking
* @date 2023-04-13
*/
public interface TuningRunService extends IBaseService<TuningRun, Long> {
/**
* 保存新增对象。
*
* @param tuningRun 新增对象。
* @return 返回新增对象。
*/
TuningRun saveNew(TuningRun tuningRun);
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param tuningRunList 新增对象列表。
*/
void saveNewBatch(List<TuningRun> tuningRunList);
/**
* 更新数据对象。
*
* @param tuningRun 更新的对象。
* @param originalTuningRun 原有数据对象。
* @return 成功返回true,否则false。
*/
boolean update(TuningRun tuningRun, TuningRun originalTuningRun);
/**
* 删除指定数据。
*
* @param runId 主键Id。
* @return 成功返回true,否则false。
*/
boolean remove(Long runId);
/**
* 当前服务的支持表为从表,根据主表的关联Id,删除一对多的从表数据。
*
* @param taskId 从表关联字段。
* @return 删除数量。
*/
int removeByTaskId(Long taskId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getTuningRunListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<TuningRun> getTuningRunList(TuningRun filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getTuningRunList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<TuningRun> getTuningRunListWithRelation(TuningRun filter, String orderBy);
}
package com.yice.webadmin.app.service;
import com.yice.webadmin.app.model.*;
import com.yice.common.core.base.service.IBaseService;
import java.util.*;
/**
* 精调任务数据操作服务接口。
*
* @author linking
* @date 2023-04-13
*/
public interface TuningTaskService extends IBaseService<TuningTask, Long> {
/**
* 保存新增对象。
*
* @param tuningTask 新增对象。
* @return 返回新增对象。
*/
TuningTask saveNew(TuningTask tuningTask);
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param tuningTaskList 新增对象列表。
*/
void saveNewBatch(List<TuningTask> tuningTaskList);
/**
* 更新数据对象。
*
* @param tuningTask 更新的对象。
* @param originalTuningTask 原有数据对象。
* @return 成功返回true,否则false。
*/
boolean update(TuningTask tuningTask, TuningTask originalTuningTask);
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
boolean remove(Long taskId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getTuningTaskListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<TuningTask> getTuningTaskList(TuningTask filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getTuningTaskList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param tuningRunFilter 一对多从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
List<TuningTask> getTuningTaskListWithRelation(TuningTask filter, TuningRun tuningRunFilter, String orderBy);
}
...@@ -131,7 +131,6 @@ public class DatasetManageServiceImpl extends BaseService<DatasetManage, Long> i ...@@ -131,7 +131,6 @@ public class DatasetManageServiceImpl extends BaseService<DatasetManage, Long> i
public List<DatasetManage> getDatasetManageListWithRelation(DatasetManage filter, DatasetVersion datasetVersionFilter, String orderBy) { public List<DatasetManage> getDatasetManageListWithRelation(DatasetManage filter, DatasetVersion datasetVersionFilter, String orderBy) {
List<DatasetManage> resultList = List<DatasetManage> resultList =
datasetManageMapper.getDatasetManageListEx(filter, datasetVersionFilter, orderBy); datasetManageMapper.getDatasetManageListEx(filter, datasetVersionFilter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000; int batchSize = resultList instanceof Page ? 0 : 1000;
...@@ -145,12 +144,7 @@ public class DatasetManageServiceImpl extends BaseService<DatasetManage, Long> i ...@@ -145,12 +144,7 @@ public class DatasetManageServiceImpl extends BaseService<DatasetManage, Long> i
DatasetManage reDatasetManage = this.saveNew(datasetManage); DatasetManage reDatasetManage = this.saveNew(datasetManage);
DatasetVersion datasetVersion = new DatasetVersion(); DatasetVersion datasetVersion = new DatasetVersion();
datasetVersion.setDatasetId(reDatasetManage.getDatasetId()); datasetVersion.setDatasetId(reDatasetManage.getDatasetId());
List<DatasetVersion> datasetVersions = this.datasetVersionService.getDatasetVersionList(datasetVersion, "dataset_version"); datasetVersion.setDatasetVersion(1);
Integer version = 1;
if (datasetVersions != null && datasetVersions.size() != 0) {
version = datasetVersions.get(datasetVersions.size() - 1).getDatasetVersion() + 1;
}
datasetVersion.setDatasetVersion(version);
datasetVersion.setCleanStatus(0); datasetVersion.setCleanStatus(0);
datasetVersion.setDataVolume(0L); datasetVersion.setDataVolume(0L);
datasetVersion.setEnhanceStatus(0); datasetVersion.setEnhanceStatus(0);
......
...@@ -7,7 +7,6 @@ import com.yice.webadmin.app.service.*; ...@@ -7,7 +7,6 @@ import com.yice.webadmin.app.service.*;
import com.yice.webadmin.app.dao.*; import com.yice.webadmin.app.dao.*;
import com.yice.webadmin.app.model.*; 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.constant.GlobalDeletedFlag;
import com.yice.common.core.object.MyRelationParam; import com.yice.common.core.object.MyRelationParam;
import com.yice.common.core.object.CallResult; import com.yice.common.core.object.CallResult;
import com.yice.common.core.base.service.BaseService; import com.yice.common.core.base.service.BaseService;
...@@ -180,7 +179,6 @@ public class DatasetVersionServiceImpl extends BaseService<DatasetVersion, Long> ...@@ -180,7 +179,6 @@ public class DatasetVersionServiceImpl extends BaseService<DatasetVersion, Long>
datasetVersion.setVersionId(idGenerator.nextLongId()); datasetVersion.setVersionId(idGenerator.nextLongId());
} }
MyModelUtil.fillCommonsForInsert(datasetVersion); MyModelUtil.fillCommonsForInsert(datasetVersion);
datasetVersion.setDeletedFlag(GlobalDeletedFlag.NORMAL);
return datasetVersion; return datasetVersion;
} }
} }
package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*;
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.object.MyRelationParam;
import com.yice.common.core.base.service.BaseService;
import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 模型压缩数据操作服务类。
*
* @author linking
* @date 2023-04-13
*/
@Slf4j
@Service("modelCompressService")
public class ModelCompressServiceImpl extends BaseService<ModelCompress, Long> implements ModelCompressService {
@Autowired
private ModelCompressMapper modelCompressMapper;
@Autowired
private ModelTaskService modelTaskService;
@Autowired
private IdGeneratorWrapper idGenerator;
@Autowired
private ModelVersionService modelVersionService;
@Autowired
private ModelManageService modelManageService;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<ModelCompress> mapper() {
return modelCompressMapper;
}
/**
* 保存新增对象。
*
* @param modelCompress 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public ModelCompress saveNew(ModelCompress modelCompress) {
modelCompressMapper.insert(this.buildDefaultValue(modelCompress));
return modelCompress;
}
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param modelCompressList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<ModelCompress> modelCompressList) {
if (CollUtil.isNotEmpty(modelCompressList)) {
modelCompressList.forEach(this::buildDefaultValue);
modelCompressMapper.insertList(modelCompressList);
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public ModelCompress saveNewWithRelation(ModelCompress modelCompress, JSONObject relationData) {
if (modelCompress.getCreateMethod() == 0) {
ModelVersion modelVersion = new ModelVersion();
modelVersion.setModelId(modelCompress.getTargetModelId());
List<ModelVersion> modelVersionList = this.modelVersionService.getModelVersionList(modelVersion, "model_version");
int lastModelVersion = modelVersionList.get(modelVersionList.size() - 1).getModelVersion();
modelVersion.setModelId(modelCompress.getTargetModelId());
modelVersion.setIsCompress(1);
modelVersion.setModelVersion(lastModelVersion + 1);
this.modelVersionService.saveNew(modelVersion);
} else {
ModelManage modelManage = new ModelManage();
ModelVersion modelVersion = new ModelVersion();
modelManage.setModelName(modelCompress.getTargetModelName());
modelManage.setModelType(0);
modelVersion.setIsCompress(1);
modelManage.setModelDescribe("模型压缩");
this.modelManageService.saveAndCreateVersion(modelManage,modelVersion);
}
this.saveNew(modelCompress);
this.saveOrUpdateOneToOneRelationData(modelCompress, relationData);
return modelCompress;
}
/**
* 更新数据对象。
*
* @param modelCompress 更新的对象。
* @param originalModelCompress 原有数据对象。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(ModelCompress modelCompress, ModelCompress originalModelCompress) {
MyModelUtil.fillCommonsForUpdate(modelCompress, originalModelCompress);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<ModelCompress> uw = this.createUpdateQueryForNullValue(modelCompress, modelCompress.getTaskId());
return modelCompressMapper.update(modelCompress, uw) == 1;
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateWithRelation(
ModelCompress modelCompress, ModelCompress originalModelCompress, JSONObject relationData) {
// modelCompress 为空的时候,无需修改主表数据。
if (modelCompress != null && !this.update(modelCompress, originalModelCompress)) {
return false;
}
this.saveOrUpdateOneToOneRelationData(originalModelCompress, relationData);
return true;
}
private void saveOrUpdateOneToOneRelationData(ModelCompress modelCompress, JSONObject relationData) {
// 对于一对一新增或更新,如果主键值为空就新增,否则就更新,同时更新updateTime和updateUserId。
ModelTask modelTask = relationData.getObject("modelTask", ModelTask.class);
if (modelTask != null) {
modelTask.setTaskId(modelCompress.getTaskId());
modelTaskService.saveNew(modelTask);
/*modelTaskService.saveNewOrUpdate(modelTask,
modelTaskService::saveNew, modelTaskService::update);*/
}
}
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long taskId) {
if (modelCompressMapper.deleteById(taskId) == 0) {
return false;
}
modelTaskService.remove(taskId);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getModelCompressListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<ModelCompress> getModelCompressList(ModelCompress filter, String orderBy) {
return modelCompressMapper.getModelCompressList(filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getModelCompressList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<ModelCompress> getModelCompressListWithRelation(ModelCompress filter, ModelTask modelTaskFilter, String orderBy) {
List<ModelCompress> resultList =
modelCompressMapper.getModelCompressListEx(filter, modelTaskFilter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
private ModelCompress buildDefaultValue(ModelCompress modelCompress) {
if (modelCompress.getTaskId() == null) {
modelCompress.setTaskId(idGenerator.nextLongId());
}
MyModelUtil.fillCommonsForInsert(modelCompress);
return modelCompress;
}
}
package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*;
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.object.MyRelationParam;
import com.yice.common.core.base.service.BaseService;
import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 模型评估数据操作服务类。
*
* @author linking
* @date 2023-04-13
*/
@Slf4j
@Service("modelEstimateService")
public class ModelEstimateServiceImpl extends BaseService<ModelEstimate, Long> implements ModelEstimateService {
@Autowired
private ModelEstimateMapper modelEstimateMapper;
@Autowired
private ModelTaskService modelTaskService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<ModelEstimate> mapper() {
return modelEstimateMapper;
}
/**
* 保存新增对象。
*
* @param modelEstimate 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public ModelEstimate saveNew(ModelEstimate modelEstimate) {
modelEstimateMapper.insert(this.buildDefaultValue(modelEstimate));
return modelEstimate;
}
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param modelEstimateList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<ModelEstimate> modelEstimateList) {
if (CollUtil.isNotEmpty(modelEstimateList)) {
modelEstimateList.forEach(this::buildDefaultValue);
modelEstimateMapper.insertList(modelEstimateList);
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public ModelEstimate saveNewWithRelation(ModelEstimate modelEstimate, JSONObject relationData) {
this.saveNew(modelEstimate);
this.saveOrUpdateOneToOneRelationData(modelEstimate, relationData);
return modelEstimate;
}
/**
* 更新数据对象。
*
* @param modelEstimate 更新的对象。
* @param originalModelEstimate 原有数据对象。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(ModelEstimate modelEstimate, ModelEstimate originalModelEstimate) {
MyModelUtil.fillCommonsForUpdate(modelEstimate, originalModelEstimate);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<ModelEstimate> uw = this.createUpdateQueryForNullValue(modelEstimate, modelEstimate.getTaskId());
return modelEstimateMapper.update(modelEstimate, uw) == 1;
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateWithRelation(
ModelEstimate modelEstimate, ModelEstimate originalModelEstimate, JSONObject relationData) {
// modelEstimate 为空的时候,无需修改主表数据。
if (modelEstimate != null && !this.update(modelEstimate, originalModelEstimate)) {
return false;
}
this.saveOrUpdateOneToOneRelationData(originalModelEstimate, relationData);
return true;
}
private void saveOrUpdateOneToOneRelationData(ModelEstimate modelEstimate, JSONObject relationData) {
// 对于一对一新增或更新,如果主键值为空就新增,否则就更新,同时更新updateTime和updateUserId。
ModelTask modelTask = relationData.getObject("modelTask", ModelTask.class);
if (modelTask != null) {
modelTask.setTaskId(modelEstimate.getTaskId());
modelTaskService.saveNew(modelTask);
// modelTaskService.saveNewOrUpdate(modelTask,
// modelTaskService::saveNew, modelTaskService::update);
}
}
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long taskId) {
if (modelEstimateMapper.deleteById(taskId) == 0) {
return false;
}
modelTaskService.remove(taskId);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getModelEstimateListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<ModelEstimate> getModelEstimateList(ModelEstimate filter, String orderBy) {
return modelEstimateMapper.getModelEstimateList(filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getModelEstimateList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param modelTaskFilter 一对一从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<ModelEstimate> getModelEstimateListWithRelation(ModelEstimate filter, ModelTask modelTaskFilter, String orderBy) {
List<ModelEstimate> resultList =
modelEstimateMapper.getModelEstimateListEx(filter, modelTaskFilter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
private ModelEstimate buildDefaultValue(ModelEstimate modelEstimate) {
if (modelEstimate.getTaskId() == null) {
modelEstimate.setTaskId(idGenerator.nextLongId());
}
MyModelUtil.fillCommonsForInsert(modelEstimate);
return modelEstimate;
}
}
...@@ -164,7 +164,10 @@ public class ModelManageServiceImpl extends BaseService<ModelManage, Long> imple ...@@ -164,7 +164,10 @@ public class ModelManageServiceImpl extends BaseService<ModelManage, Long> imple
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000; int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.full(), batchSize); Set<String> ignoreFields = new HashSet<>();
ignoreFields.add("modelTaskList");
ignoreFields.add("modelDeployList");
this.buildRelationForDataList(resultList, MyRelationParam.full(), batchSize, ignoreFields);
return resultList; return resultList;
} }
@Transactional @Transactional
...@@ -175,7 +178,8 @@ public class ModelManageServiceImpl extends BaseService<ModelManage, Long> imple ...@@ -175,7 +178,8 @@ public class ModelManageServiceImpl extends BaseService<ModelManage, Long> imple
if (modelVersion.getBusinessLabel() == null && modelManage.getBusinessLabel() != null) { if (modelVersion.getBusinessLabel() == null && modelManage.getBusinessLabel() != null) {
modelVersion.setBusinessLabel(modelManage.getBusinessLabel()); modelVersion.setBusinessLabel(modelManage.getBusinessLabel());
} }
modelVersion.setVersionId(1L); modelVersion.setModelVersion(1);
modelVersion.setIsCompress(0);
this.modelVersionService.saveNew(modelVersion); this.modelVersionService.saveNew(modelVersion);
return reModelManage; return reModelManage;
} }
......
package com.yice.webadmin.app.service.impl; package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.*; import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*; import com.yice.webadmin.app.service.*;
...@@ -33,6 +34,10 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement ...@@ -33,6 +34,10 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement
@Autowired @Autowired
private ModelTaskMapper modelTaskMapper; private ModelTaskMapper modelTaskMapper;
@Autowired @Autowired
private ModelEstimateService modelEstimateService;
@Autowired
private ModelCompressService modelCompressService;
@Autowired
private ModelManageService modelManageService; private ModelManageService modelManageService;
@Autowired @Autowired
private IdGeneratorWrapper idGenerator; private IdGeneratorWrapper idGenerator;
...@@ -74,6 +79,14 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement ...@@ -74,6 +79,14 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement
} }
} }
@Transactional(rollbackFor = Exception.class)
@Override
public ModelTask saveNewWithRelation(ModelTask modelTask, JSONObject relationData) {
this.saveNew(modelTask);
this.saveOrUpdateOneToOneRelationData(modelTask, relationData);
return modelTask;
}
/** /**
* 更新数据对象。 * 更新数据对象。
* *
...@@ -90,6 +103,34 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement ...@@ -90,6 +103,34 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement
return modelTaskMapper.update(modelTask, uw) == 1; return modelTaskMapper.update(modelTask, uw) == 1;
} }
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateWithRelation(
ModelTask modelTask, ModelTask originalModelTask, JSONObject relationData) {
// modelTask 为空的时候,无需修改主表数据。
if (modelTask != null && !this.update(modelTask, originalModelTask)) {
return false;
}
this.saveOrUpdateOneToOneRelationData(originalModelTask, relationData);
return true;
}
private void saveOrUpdateOneToOneRelationData(ModelTask modelTask, JSONObject relationData) {
// 对于一对一新增或更新,如果主键值为空就新增,否则就更新,同时更新updateTime和updateUserId。
ModelEstimate modelEstimate = relationData.getObject("modelEstimate", ModelEstimate.class);
if (modelEstimate != null) {
modelEstimate.setTaskId(modelTask.getTaskId());
modelEstimateService.saveNewOrUpdate(modelEstimate,
modelEstimateService::saveNew, modelEstimateService::update);
}
ModelCompress modelCompress = relationData.getObject("modelCompress", ModelCompress.class);
if (modelCompress != null) {
modelCompress.setTaskId(modelTask.getTaskId());
modelCompressService.saveNewOrUpdate(modelCompress,
modelCompressService::saveNew, modelCompressService::update);
}
}
/** /**
* 删除指定数据。 * 删除指定数据。
* *
...@@ -99,7 +140,12 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement ...@@ -99,7 +140,12 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean remove(Long taskId) { public boolean remove(Long taskId) {
return modelTaskMapper.deleteById(taskId) == 1; if (modelTaskMapper.deleteById(taskId) == 0) {
return false;
}
modelEstimateService.remove(taskId);
modelCompressService.remove(taskId);
return true;
} }
/** /**
...@@ -135,12 +181,15 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement ...@@ -135,12 +181,15 @@ public class ModelTaskServiceImpl extends BaseService<ModelTask, Long> implement
* 如果仅仅需要获取主表数据,请移步(getModelTaskList),以便获取更好的查询性能。 * 如果仅仅需要获取主表数据,请移步(getModelTaskList),以便获取更好的查询性能。
* *
* @param filter 主表过滤对象。 * @param filter 主表过滤对象。
* @param modelEstimateFilter 一对一从表过滤对象。
* @param modelCompressFilter 一对一从表过滤对象。
* @param orderBy 排序参数。 * @param orderBy 排序参数。
* @return 查询结果集。 * @return 查询结果集。
*/ */
@Override @Override
public List<ModelTask> getModelTaskListWithRelation(ModelTask filter, String orderBy) { public List<ModelTask> getModelTaskListWithRelation(ModelTask filter, ModelEstimate modelEstimateFilter, ModelCompress modelCompressFilter, String orderBy) {
List<ModelTask> resultList = modelTaskMapper.getModelTaskList(filter, orderBy); List<ModelTask> resultList =
modelTaskMapper.getModelTaskListEx(filter, modelEstimateFilter, modelCompressFilter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000; int batchSize = resultList instanceof Page ? 0 : 1000;
......
...@@ -35,6 +35,8 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp ...@@ -35,6 +35,8 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp
@Autowired @Autowired
private ModelManageService modelManageService; private ModelManageService modelManageService;
@Autowired @Autowired
private ModelTaskService modelTaskService;
@Autowired
private IdGeneratorWrapper idGenerator; private IdGeneratorWrapper idGenerator;
/** /**
...@@ -57,6 +59,13 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp ...@@ -57,6 +59,13 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp
@Override @Override
public ModelVersion saveNew(ModelVersion modelVersion) { public ModelVersion saveNew(ModelVersion modelVersion) {
modelVersionMapper.insert(this.buildDefaultValue(modelVersion)); modelVersionMapper.insert(this.buildDefaultValue(modelVersion));
/*ModelTask modelTask = new ModelTask();
modelTask.setModelVersion(modelVersion.getModelVersion());
modelTask.setModelId(modelVersion.getModelId());
modelTask.setTaskType(0);
modelTask.setVersionId(modelVersion.getVersionId());
modelTask.setVersionName(modelVersion.getVersionName());
this.modelTaskService.saveNew(modelTask);*/
return modelVersion; return modelVersion;
} }
...@@ -151,7 +160,7 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp ...@@ -151,7 +160,7 @@ public class ModelVersionServiceImpl extends BaseService<ModelVersion, Long> imp
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。 // 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。 // 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000; int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); this.buildRelationForDataList(resultList, MyRelationParam.full(), batchSize);
return resultList; return resultList;
} }
......
...@@ -6,7 +6,6 @@ import com.yice.webadmin.app.service.*; ...@@ -6,7 +6,6 @@ import com.yice.webadmin.app.service.*;
import com.yice.webadmin.app.dao.*; import com.yice.webadmin.app.dao.*;
import com.yice.webadmin.app.model.*; 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.constant.GlobalDeletedFlag;
import com.yice.common.core.object.MyRelationParam; import com.yice.common.core.object.MyRelationParam;
import com.yice.common.core.object.CallResult; import com.yice.common.core.object.CallResult;
import com.yice.common.core.base.service.BaseService; import com.yice.common.core.base.service.BaseService;
...@@ -183,7 +182,6 @@ public class PromptTemplateServiceImpl extends BaseService<PromptTemplate, Long> ...@@ -183,7 +182,6 @@ public class PromptTemplateServiceImpl extends BaseService<PromptTemplate, Long>
promptTemplate.setTemplateId(idGenerator.nextLongId()); promptTemplate.setTemplateId(idGenerator.nextLongId());
} }
MyModelUtil.fillCommonsForInsert(promptTemplate); MyModelUtil.fillCommonsForInsert(promptTemplate);
promptTemplate.setDeletedFlag(GlobalDeletedFlag.NORMAL);
return promptTemplate; return promptTemplate;
} }
} }
package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*;
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.object.MyRelationParam;
import com.yice.common.core.object.CallResult;
import com.yice.common.core.base.service.BaseService;
import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 精调任务运行数据操作服务类。
*
* @author linking
* @date 2023-04-13
*/
@Slf4j
@Service("tuningRunService")
public class TuningRunServiceImpl extends BaseService<TuningRun, Long> implements TuningRunService {
@Autowired
private TuningRunMapper tuningRunMapper;
@Autowired
private TuningTaskService tuningTaskService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<TuningRun> mapper() {
return tuningRunMapper;
}
/**
* 保存新增对象。
*
* @param tuningRun 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public TuningRun saveNew(TuningRun tuningRun) {
tuningRunMapper.insert(this.buildDefaultValue(tuningRun));
return tuningRun;
}
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param tuningRunList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<TuningRun> tuningRunList) {
if (CollUtil.isNotEmpty(tuningRunList)) {
tuningRunList.forEach(this::buildDefaultValue);
tuningRunMapper.insertList(tuningRunList);
}
}
/**
* 更新数据对象。
*
* @param tuningRun 更新的对象。
* @param originalTuningRun 原有数据对象。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(TuningRun tuningRun, TuningRun originalTuningRun) {
MyModelUtil.fillCommonsForUpdate(tuningRun, originalTuningRun);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<TuningRun> uw = this.createUpdateQueryForNullValue(tuningRun, tuningRun.getRunId());
return tuningRunMapper.update(tuningRun, uw) == 1;
}
/**
* 删除指定数据。
*
* @param runId 主键Id。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long runId) {
return tuningRunMapper.deleteById(runId) == 1;
}
/**
* 当前服务的支持表为从表,根据主表的关联Id,删除一对多的从表数据。
*
* @param taskId 从表关联字段。
* @return 删除数量。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int removeByTaskId(Long taskId) {
TuningRun deletedObject = new TuningRun();
deletedObject.setTaskId(taskId);
return tuningRunMapper.delete(new QueryWrapper<>(deletedObject));
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getTuningRunListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<TuningRun> getTuningRunList(TuningRun filter, String orderBy) {
return tuningRunMapper.getTuningRunList(filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getTuningRunList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<TuningRun> getTuningRunListWithRelation(TuningRun filter, String orderBy) {
List<TuningRun> resultList = tuningRunMapper.getTuningRunList(filter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
*
* @param tuningRun 最新数据对象。
* @param originalTuningRun 原有数据对象。
* @return 数据全部正确返回true,否则false。
*/
@Override
public CallResult verifyRelatedData(TuningRun tuningRun, TuningRun originalTuningRun) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
//这里是一对多的验证
if (this.needToVerify(tuningRun, originalTuningRun, TuningRun::getTaskId)
&& !tuningTaskService.existId(tuningRun.getTaskId())) {
return CallResult.error(String.format(errorMessageFormat, "任务ID"));
}
return CallResult.ok();
}
private TuningRun buildDefaultValue(TuningRun tuningRun) {
if (tuningRun.getRunId() == null) {
tuningRun.setRunId(idGenerator.nextLongId());
}
MyModelUtil.fillCommonsForInsert(tuningRun);
return tuningRun;
}
}
package com.yice.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yice.webadmin.app.service.*;
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.object.MyRelationParam;
import com.yice.common.core.base.service.BaseService;
import com.yice.common.core.util.MyModelUtil;
import com.yice.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 精调任务数据操作服务类。
*
* @author linking
* @date 2023-04-13
*/
@Slf4j
@Service("tuningTaskService")
public class TuningTaskServiceImpl extends BaseService<TuningTask, Long> implements TuningTaskService {
@Autowired
private TuningTaskMapper tuningTaskMapper;
@Autowired
private TuningRunService tuningRunService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<TuningTask> mapper() {
return tuningTaskMapper;
}
/**
* 保存新增对象。
*
* @param tuningTask 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public TuningTask saveNew(TuningTask tuningTask) {
tuningTaskMapper.insert(this.buildDefaultValue(tuningTask));
return tuningTask;
}
/**
* 利用数据库的insertList语法,批量插入对象列表。
*
* @param tuningTaskList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<TuningTask> tuningTaskList) {
if (CollUtil.isNotEmpty(tuningTaskList)) {
tuningTaskList.forEach(this::buildDefaultValue);
tuningTaskMapper.insertList(tuningTaskList);
}
}
/**
* 更新数据对象。
*
* @param tuningTask 更新的对象。
* @param originalTuningTask 原有数据对象。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(TuningTask tuningTask, TuningTask originalTuningTask) {
MyModelUtil.fillCommonsForUpdate(tuningTask, originalTuningTask);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<TuningTask> uw = this.createUpdateQueryForNullValue(tuningTask, tuningTask.getTaskId());
return tuningTaskMapper.update(tuningTask, uw) == 1;
}
/**
* 删除指定数据。
*
* @param taskId 主键Id。
* @return 成功返回true,否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long taskId) {
if (tuningTaskMapper.deleteById(taskId) == 0) {
return false;
}
tuningRunService.removeByTaskId(taskId);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getTuningTaskListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<TuningTask> getTuningTaskList(TuningTask filter, String orderBy) {
return tuningTaskMapper.getTuningTaskList(filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getTuningTaskList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param tuningRunFilter 一对多从表过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<TuningTask> getTuningTaskListWithRelation(TuningTask filter, TuningRun tuningRunFilter, String orderBy) {
List<TuningTask> resultList =
tuningTaskMapper.getTuningTaskListEx(filter, tuningRunFilter, orderBy);
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
private TuningTask buildDefaultValue(TuningTask tuningTask) {
if (tuningTask.getTaskId() == null) {
tuningTask.setTaskId(idGenerator.nextLongId());
}
MyModelUtil.fillCommonsForInsert(tuningTask);
return tuningTask;
}
}
...@@ -45,11 +45,6 @@ public class DatasetManageVo extends BaseVo { ...@@ -45,11 +45,6 @@ public class DatasetManageVo extends BaseVo {
@ApiModelProperty(value = "模板") @ApiModelProperty(value = "模板")
private Integer template; private Integer template;
/**
* 删除标识。
*/
@ApiModelProperty(value = "删除标识")
private Integer deletedFlag;
/** /**
* 数据类型。 * 数据类型。
......
...@@ -110,6 +110,7 @@ public class DatasetVersionVo extends BaseVo { ...@@ -110,6 +110,7 @@ public class DatasetVersionVo extends BaseVo {
@ApiModelProperty(value = "文件地址") @ApiModelProperty(value = "文件地址")
private String fileUrl; private String fileUrl;
/** /**
* versionId 的一对一关联数据对象,数据对应类型为DatasetDetailVo。 * versionId 的一对一关联数据对象,数据对应类型为DatasetDetailVo。
*/ */
......
package com.yice.webadmin.app.vo;
import com.yice.common.core.base.vo.BaseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
/**
* ModelCompressVO视图对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("ModelCompressVO视图对象")
@Data
@EqualsAndHashCode(callSuper = true)
public class ModelCompressVo extends BaseVo {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID")
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 描述。
*/
@ApiModelProperty(value = "描述")
private String taskDescribe;
/**
* 源模型。
*/
@ApiModelProperty(value = "源模型")
private Long sourceVersionId;
/**
* 创建方式。
*/
@ApiModelProperty(value = "创建方式")
private Integer createMethod;
/**
* 目标模型。
*/
@ApiModelProperty(value = "目标模型")
private Long targetVersionId;
/**
* taskId 的一对一关联数据对象,数据对应类型为ModelTaskVo。
*/
@ApiModelProperty(value = "taskId 的一对一关联数据对象,数据对应类型为ModelTaskVo")
private Map<String, Object> modelTask;
}
package com.yice.webadmin.app.vo;
import com.yice.common.core.base.vo.BaseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
/**
* ModelEstimateVO视图对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("ModelEstimateVO视图对象")
@Data
@EqualsAndHashCode(callSuper = true)
public class ModelEstimateVo extends BaseVo {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID")
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 描述。
*/
@ApiModelProperty(value = "描述")
private String taskDescribe;
/**
* 待评估模型版本ID。
*/
@ApiModelProperty(value = "待评估模型版本ID")
private Long modelVersionId;
/**
* 评估数据集版本ID。
*/
@ApiModelProperty(value = "评估数据集版本ID")
private Long datasetVersionId;
/**
* 打分模式。
*/
@ApiModelProperty(value = "打分模式")
private Integer scoringMode;
/**
* taskId 的一对一关联数据对象,数据对应类型为ModelTaskVo。
*/
@ApiModelProperty(value = "taskId 的一对一关联数据对象,数据对应类型为ModelTaskVo")
private Map<String, Object> modelTask;
}
...@@ -7,6 +7,7 @@ import lombok.Data; ...@@ -7,6 +7,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
import java.util.Map;
/** /**
* ModelTaskVO视图对象。 * ModelTaskVO视图对象。
...@@ -66,4 +67,16 @@ public class ModelTaskVo extends BaseVo { ...@@ -66,4 +67,16 @@ public class ModelTaskVo extends BaseVo {
*/ */
@ApiModelProperty(value = "模型版本号") @ApiModelProperty(value = "模型版本号")
private Integer modelVersion; private Integer modelVersion;
/**
* taskId 的一对一关联数据对象,数据对应类型为ModelEstimateVo。
*/
@ApiModelProperty(value = "taskId 的一对一关联数据对象,数据对应类型为ModelEstimateVo")
private Map<String, Object> modelEstimate;
/**
* taskId 的一对一关联数据对象,数据对应类型为ModelCompressVo。
*/
@ApiModelProperty(value = "taskId 的一对一关联数据对象,数据对应类型为ModelCompressVo")
private Map<String, Object> modelCompress;
} }
...@@ -128,6 +128,13 @@ public class ModelVersionVo extends BaseVo { ...@@ -128,6 +128,13 @@ public class ModelVersionVo extends BaseVo {
@ApiModelProperty(value = "模型地址") @ApiModelProperty(value = "模型地址")
private String modelUrl; private String modelUrl;
/**
* 是否被压缩。
*/
@ApiModelProperty(value = "是否被压缩")
private Integer isCompress;
/** /**
* modelId 的一对一关联数据对象,数据对应类型为ModelManageVo。 * modelId 的一对一关联数据对象,数据对应类型为ModelManageVo。
*/ */
......
package com.yice.webadmin.app.vo;
import com.yice.common.core.base.vo.BaseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* TuningRunVO视图对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("TuningRunVO视图对象")
@Data
@EqualsAndHashCode(callSuper = true)
public class TuningRunVo extends BaseVo {
/**
* 运行ID。
*/
@ApiModelProperty(value = "运行ID")
private Long runId;
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID")
private Long taskId;
/**
* 运行状态。
*/
@ApiModelProperty(value = "运行状态")
private Integer runStatus;
/**
* 运行版本号。
*/
@ApiModelProperty(value = "运行版本号")
private Integer runVersion;
/**
* 运行名称。
*/
@ApiModelProperty(value = "运行名称")
private String runName;
/**
* 基础模型ID。
*/
@ApiModelProperty(value = "基础模型ID")
private Long modelId;
/**
* 基础模型版本ID。
*/
@ApiModelProperty(value = "基础模型版本ID")
private Long modelVersionId;
/**
* 运行时长。
*/
@ApiModelProperty(value = "运行时长")
private Long runTime;
/**
* 数据集版本ID。
*/
@ApiModelProperty(value = "数据集版本ID")
private Long datasetVersionId;
/**
* 拆分比例。
*/
@ApiModelProperty(value = "拆分比例")
private Integer splitRatio;
/**
* 训练模式。
*/
@ApiModelProperty(value = "训练模式")
private String trainMode;
/**
* 训练方法。
*/
@ApiModelProperty(value = "训练方法")
private String trainMethod;
/**
* 参数配置。
*/
@ApiModelProperty(value = "参数配置")
private String configuration;
/**
* 发布状态。
*/
@ApiModelProperty(value = "发布状态")
private Integer publishStatus;
}
package com.yice.webadmin.app.vo;
import com.yice.common.core.base.vo.BaseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
import java.util.List;
/**
* TuningTaskVO视图对象。
*
* @author linking
* @date 2023-04-13
*/
@ApiModel("TuningTaskVO视图对象")
@Data
@EqualsAndHashCode(callSuper = true)
public class TuningTaskVo extends BaseVo {
/**
* 任务ID。
*/
@ApiModelProperty(value = "任务ID")
private Long taskId;
/**
* 任务名称。
*/
@ApiModelProperty(value = "任务名称")
private String taskName;
/**
* 任务类型。
*/
@ApiModelProperty(value = "任务类型")
private Integer taskType;
/**
* 任务描述。
*/
@ApiModelProperty(value = "任务描述")
private String taskDescribe;
/**
* TuningRun 的一对多关联表数据对象。数据对应类型为TuningRun。
*/
@ApiModelProperty(value = "TuningRun 的一对多关联表数据对象。数据对应类型为TuningRun")
private List<Map<String, Object>> tuningRunList;
}
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