1、数据训练列表查询接口 bugfix
2、新增 导出数据训练接口
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.sdm.common.entity.req.data;
|
||||
|
||||
import com.sdm.common.entity.ExportExcelFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelExportExcelFormat {
|
||||
|
||||
/**
|
||||
* 导出的基本属性值
|
||||
*/
|
||||
private List<ExportExcelFormat> excelHeaders;
|
||||
|
||||
/**
|
||||
* 导出数据训练的可选查询参数
|
||||
*/
|
||||
private ModelExportExcelParam params;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sdm.common.entity.req.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ModelExportExcelParam{
|
||||
|
||||
/**
|
||||
* 使用算法
|
||||
*/
|
||||
@Schema(description = "使用算法")
|
||||
private String algorithmUsed;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@Schema(description = "说明")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
@Schema(description = "模型名称")
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 训练人
|
||||
*/
|
||||
@Schema(description = "训练人")
|
||||
private String trainer;
|
||||
|
||||
/**
|
||||
* 训练状态
|
||||
*/
|
||||
@Schema(description = "训练状态")
|
||||
private String trainingStatus;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,11 +2,13 @@ package com.sdm.data.controller;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.data.BaseReq;
|
||||
import com.sdm.common.entity.req.data.ModelExportExcelFormat;
|
||||
import com.sdm.data.model.req.*;
|
||||
import com.sdm.data.service.IModelService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -43,7 +45,7 @@ public class ModelTraningController {
|
||||
*/
|
||||
@PostMapping("/getModelList")
|
||||
@Operation(summary = "获取模型列表", description = "获取模型列表")
|
||||
public SdmResponse getModelList(@RequestBody BaseReq baseReq) {
|
||||
public SdmResponse getModelList(@RequestBody QueryModelReq baseReq) {
|
||||
return modelService.getModelList(baseReq);
|
||||
}
|
||||
|
||||
@@ -158,4 +160,16 @@ public class ModelTraningController {
|
||||
return modelService.getModelPredictResult(modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param modelExportExcelFormat
|
||||
* @param httpservletResponse
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/exportModel")
|
||||
@Operation(summary = "导出数据训练", description = "导出数据训练")
|
||||
public SdmResponse exportModel(@RequestBody ModelExportExcelFormat modelExportExcelFormat , HttpServletResponse httpservletResponse) {
|
||||
return modelService.exportModel(modelExportExcelFormat, httpservletResponse);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
41
data/src/main/java/com/sdm/data/model/req/QueryModelReq.java
Normal file
41
data/src/main/java/com/sdm/data/model/req/QueryModelReq.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.sdm.data.model.req;
|
||||
|
||||
import com.sdm.common.entity.req.data.BaseReq;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryModelReq extends BaseReq {
|
||||
|
||||
/**
|
||||
* 使用算法
|
||||
*/
|
||||
@Schema(description = "使用算法")
|
||||
private String algorithmUsed;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@Schema(description = "说明")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
@Schema(description = "模型名称")
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 训练人
|
||||
*/
|
||||
@Schema(description = "训练人")
|
||||
private String trainer;
|
||||
|
||||
/**
|
||||
* 训练状态
|
||||
*/
|
||||
@Schema(description = "训练状态")
|
||||
private String trainingStatus;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.sdm.data.service;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.data.BaseReq;
|
||||
import com.sdm.common.entity.req.data.ModelExportExcelFormat;
|
||||
import com.sdm.data.model.req.*;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 模型训练服务接口
|
||||
@@ -21,7 +23,7 @@ public interface IModelService {
|
||||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
SdmResponse getModelList(BaseReq baseReq);
|
||||
SdmResponse getModelList(QueryModelReq baseReq);
|
||||
|
||||
/**
|
||||
* 获取模型详情
|
||||
@@ -91,4 +93,7 @@ public interface IModelService {
|
||||
* @return
|
||||
*/
|
||||
SdmResponse getModelPredictResult(Long modelId);
|
||||
|
||||
SdmResponse exportModel(ModelExportExcelFormat modelExportExcelFormat, HttpServletResponse httpservletResponse);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,14 +5,25 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.ExportExcelFormat;
|
||||
import com.sdm.common.entity.enums.ApprovalFileDataStatusEnum;
|
||||
import com.sdm.common.entity.req.data.BaseReq;
|
||||
import com.sdm.common.entity.req.data.KnowledgeExportExcelParam;
|
||||
import com.sdm.common.entity.req.data.ModelExportExcelFormat;
|
||||
import com.sdm.common.entity.req.data.ModelExportExcelParam;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.utils.PageUtils;
|
||||
import com.sdm.common.utils.excel.ExcelUtil;
|
||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||
import com.sdm.data.model.entity.TrainingModel;
|
||||
import com.sdm.data.model.entity.TrainingModelAlgorithmParam;
|
||||
import com.sdm.data.model.req.*;
|
||||
import com.sdm.data.service.*;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
@@ -164,9 +175,14 @@ public class ModelServiceImpl implements IModelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse getModelList(BaseReq baseReq) {
|
||||
public SdmResponse getModelList(QueryModelReq baseReq) {
|
||||
PageHelper.startPage(baseReq.getCurrent(), baseReq.getSize());
|
||||
List<TrainingModel> models = trainingModelService.lambdaQuery().orderByDesc(TrainingModel::getCreateTime).list();
|
||||
List<TrainingModel> models = trainingModelService.lambdaQuery().eq(StringUtils.isNotBlank(baseReq.getAlgorithmUsed()),TrainingModel::getAlgorithmUsed,baseReq.getAlgorithmUsed())
|
||||
.like(StringUtils.isNotBlank(baseReq.getDescription()),TrainingModel::getDescription,baseReq.getDescription())
|
||||
.like(StringUtils.isNotBlank(baseReq.getModelName()),TrainingModel::getModelName,baseReq.getModelName())
|
||||
.eq(StringUtils.isNotBlank(baseReq.getTrainer()),TrainingModel::getTrainer,baseReq.getTrainer())
|
||||
.eq(StringUtils.isNotBlank(baseReq.getTrainingStatus()),TrainingModel::getTrainingStatus,baseReq.getTrainingStatus())
|
||||
.orderByDesc(TrainingModel::getCreateTime).list();
|
||||
PageInfo<TrainingModel> page = new PageInfo<>(models);
|
||||
return PageUtils.getJsonObjectSdmResponse(models, page);
|
||||
}
|
||||
@@ -1379,4 +1395,34 @@ public class ModelServiceImpl implements IModelService {
|
||||
return SdmResponse.success(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse exportModel(ModelExportExcelFormat modelExportExcelFormat, HttpServletResponse httpServletResponse) {
|
||||
SdmResponse response = new SdmResponse();
|
||||
QueryModelReq req = new QueryModelReq();
|
||||
ModelExportExcelParam params = modelExportExcelFormat.getParams();
|
||||
if (ObjectUtils.isNotEmpty(params)) {
|
||||
BeanUtils.copyProperties(params,req);
|
||||
}
|
||||
List<ExportExcelFormat> exportExcelFormats = modelExportExcelFormat.getExcelHeaders();
|
||||
req.setCurrent(1);
|
||||
req.setSize(10000);
|
||||
SdmResponse taskRespond = getModelList(req);
|
||||
if(taskRespond.isSuccess()) {
|
||||
if (!(taskRespond.getData() instanceof PageDataResp)) {
|
||||
ExcelUtil.exportExcelNoMerge(new JSONArray(),exportExcelFormats,httpServletResponse);
|
||||
return response;
|
||||
}
|
||||
PageDataResp dataObj = (PageDataResp) taskRespond.getData();
|
||||
List<TrainingModel> dataList = (List<TrainingModel>) dataObj.getData();
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
ExcelUtil.exportExcelNoMerge(new JSONArray(),exportExcelFormats,httpServletResponse);
|
||||
return response;
|
||||
}
|
||||
ExcelUtil.exportExcelNoMerge(JSONArray.from(dataList),exportExcelFormats,httpServletResponse);
|
||||
} else {
|
||||
response = SdmResponse.failed(taskRespond.getMessage());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user