farm模块-模型复制及发布
This commit is contained in:
@@ -41,7 +41,7 @@ public class ModelManagementController {
|
|||||||
return success(modelManagementService.createModelManagement(createReqVO));
|
return success(modelManagementService.createModelManagement(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/copyModel")
|
@PostMapping("/copy-model")
|
||||||
@Operation(summary = "复制模型管理")
|
@Operation(summary = "复制模型管理")
|
||||||
public CommonResult<String> copyModelManagement(@Valid @RequestBody ModelManagementSaveReqVO createReqVO) {
|
public CommonResult<String> copyModelManagement(@Valid @RequestBody ModelManagementSaveReqVO createReqVO) {
|
||||||
return success(modelManagementService.copyModelManagement(createReqVO));
|
return success(modelManagementService.copyModelManagement(createReqVO));
|
||||||
@@ -54,6 +54,13 @@ public class ModelManagementController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/is-release")
|
||||||
|
@Operation(summary = "更新模型管理")
|
||||||
|
public CommonResult<Boolean> isRelease(@Valid @RequestBody ModelManagementSaveReqVO updateReqVO) {
|
||||||
|
modelManagementService.isRelease(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除模型管理")
|
@Operation(summary = "删除模型管理")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@@ -78,6 +85,13 @@ public class ModelManagementController {
|
|||||||
return success(modelManagement);
|
return success(modelManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page-release")
|
||||||
|
@Operation(summary = "获得发布模型分页")
|
||||||
|
public CommonResult<PageResult<ModelManagementRespVO>> getModelManagementPageRelease(@Valid ModelManagementPageReqVO pageReqVO) {
|
||||||
|
PageResult<ModelManagementDO> pageResult = modelManagementService.getModelManagementPageRelease(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, ModelManagementRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得模型管理分页")
|
@Operation(summary = "获得模型管理分页")
|
||||||
public CommonResult<PageResult<ModelManagementRespVO>> getModelManagementPage(@Valid ModelManagementPageReqVO pageReqVO) {
|
public CommonResult<PageResult<ModelManagementRespVO>> getModelManagementPage(@Valid ModelManagementPageReqVO pageReqVO) {
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ public class ModelManagementPageReqVO extends PageParam {
|
|||||||
|
|
||||||
@Schema(description = "租户id", example = "20468")
|
@Schema(description = "租户id", example = "20468")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
private int isRelease;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ public class ModelManagementRespVO {
|
|||||||
@Schema(description = "租户id", example = "20468")
|
@Schema(description = "租户id", example = "20468")
|
||||||
@ExcelProperty("租户id")
|
@ExcelProperty("租户id")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
private int isRelease;
|
||||||
private List<ModelCycleRespVO> modelCycles;
|
private List<ModelCycleRespVO> modelCycles;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,5 +47,5 @@ public class ModelManagementSaveReqVO {
|
|||||||
|
|
||||||
@Schema(description = "租户id", example = "20468")
|
@Schema(description = "租户id", example = "20468")
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
private int isRelease;
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement;
|
package cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelcycle.ModelCycleDO;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型管理 DO
|
* 模型管理 DO
|
||||||
*
|
*
|
||||||
@@ -81,5 +81,5 @@ public class ModelManagementDO extends BaseDO {
|
|||||||
* 任务ID
|
* 任务ID
|
||||||
*/
|
*/
|
||||||
private String taskId;
|
private String taskId;
|
||||||
|
private int isRelease;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.farm.dal.mysql.modelmanagement;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManagementDO;
|
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManagementDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模型管理 Mapper
|
* 模型管理 Mapper
|
||||||
@@ -48,4 +48,25 @@ public interface ModelManagementMapper extends BaseMapperX<ModelManagementDO> {
|
|||||||
return selectJoinPage(reqVO, ModelManagementDO.class, query);
|
return selectJoinPage(reqVO, ModelManagementDO.class, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<ModelManagementDO> selectPageRelease(ModelManagementPageReqVO reqVO) {
|
||||||
|
MPJLambdaWrapperX<ModelManagementDO> query = new MPJLambdaWrapperX<ModelManagementDO>()
|
||||||
|
.selectAll(ModelManagementDO.class)
|
||||||
|
.likeIfPresent(ModelManagementDO::getModelName, reqVO.getModelName())
|
||||||
|
.eqIfPresent(ModelManagementDO::getSpeciesId, reqVO.getSpeciesId())
|
||||||
|
.likeIfPresent(ModelManagementDO::getSpeciesName, reqVO.getSpeciesName())
|
||||||
|
.eqIfPresent(ModelManagementDO::getCycle, reqVO.getCycle())
|
||||||
|
.eqIfPresent(ModelManagementDO::getHarvest, reqVO.getHarvest())
|
||||||
|
.eqIfPresent(ModelManagementDO::getSuitablePlantingAreas, reqVO.getSuitablePlantingAreas())
|
||||||
|
.eqIfPresent(ModelManagementDO::getDescription, reqVO.getDescription())
|
||||||
|
.betweenIfPresent(ModelManagementDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(ModelManagementDO::getBaseId, reqVO.getBaseId())
|
||||||
|
.likeIfPresent(ModelManagementDO::getBaseName, reqVO.getBaseName())
|
||||||
|
.eqIfPresent(ModelManagementDO::getPlotId, reqVO.getPlotId())
|
||||||
|
.likeIfPresent(ModelManagementDO::getPlotName, reqVO.getPlotName())
|
||||||
|
.eqIfPresent(ModelManagementDO::getTenantId, reqVO.getTenantId())
|
||||||
|
.eqIfPresent(ModelManagementDO::getIsRelease, 1)
|
||||||
|
.orderByDesc(ModelManagementDO::getCreateTime);
|
||||||
|
|
||||||
|
return selectJoinPage(reqVO, ModelManagementDO.class, query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -63,4 +63,8 @@ public interface ModelManagementService {
|
|||||||
PageResult<ModelManagementDO> getModelManagementPage(ModelManagementPageReqVO pageReqVO);
|
PageResult<ModelManagementDO> getModelManagementPage(ModelManagementPageReqVO pageReqVO);
|
||||||
|
|
||||||
String copyModelManagement(@Valid ModelManagementSaveReqVO createReqVO);
|
String copyModelManagement(@Valid ModelManagementSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
void isRelease(@Valid ModelManagementSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
PageResult<ModelManagementDO> getModelManagementPageRelease(@Valid ModelManagementPageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
ModelManagementDO modelManagement = BeanUtils.toBean(createReqVO, ModelManagementDO.class);
|
ModelManagementDO modelManagement = BeanUtils.toBean(createReqVO, ModelManagementDO.class);
|
||||||
modelManagement.setId(IdUtil.fastUUID());
|
modelManagement.setId(IdUtil.fastUUID());
|
||||||
modelManagement.setTenantId(String.valueOf(user.getTenantId()));
|
modelManagement.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
|
modelManagement.setIsRelease(0);
|
||||||
modelManagementMapper.insert(modelManagement);
|
modelManagementMapper.insert(modelManagement);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
@@ -99,11 +100,10 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
List<ModelCycleDO> originalCycles = modelCycleMapper.selectListByModelId(id);
|
List<ModelCycleDO> originalCycles = modelCycleMapper.selectListByModelId(id);
|
||||||
for (ModelCycleDO originalCycle : originalCycles) {
|
for (ModelCycleDO originalCycle : originalCycles) {
|
||||||
// 复制周期
|
// 复制周期
|
||||||
ModelCycleDO newCycle = BeanUtils.toBean(originalCycle, ModelCycleDO.class);
|
|
||||||
String newCycleId = IdUtil.fastUUID();
|
String newCycleId = IdUtil.fastUUID();
|
||||||
newCycle.setId(newCycleId);
|
originalCycle.setId(newCycleId);
|
||||||
newCycle.setModelId(newModelId);
|
originalCycle.setModelId(newModelId);
|
||||||
modelCycleMapper.insert(newCycle);
|
modelCycleMapper.insert(originalCycle);
|
||||||
|
|
||||||
// 复制环境指标
|
// 复制环境指标
|
||||||
List<ModelEnvironmentIndexDO> environmentIndexes = modelEnvironmentIndexMapper.selectByCycleId(originalCycle.getId());
|
List<ModelEnvironmentIndexDO> environmentIndexes = modelEnvironmentIndexMapper.selectByCycleId(originalCycle.getId());
|
||||||
@@ -220,8 +220,95 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String copyModelManagement(ModelManagementSaveReqVO createReqVO) {
|
public String copyModelManagement(ModelManagementSaveReqVO createReqVO) {
|
||||||
// createModelManagementCase(createReqVO.getId());
|
// 1. 查询原模型(类型为模型模板)
|
||||||
return "";
|
ModelManagementDO modelManagementDO = modelManagementMapper.selectOne(
|
||||||
|
ModelManagementDO::getId, createReqVO.getId(),
|
||||||
|
ModelManagementDO::getType, CommonConstants.MODEL_TYPE_1
|
||||||
|
);
|
||||||
|
|
||||||
|
if (modelManagementDO == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 创建新的模型引用案例
|
||||||
|
ModelManagementDO newModelCase = BeanUtils.toBean(modelManagementDO, ModelManagementDO.class);
|
||||||
|
String newModelId = IdUtil.fastUUID();
|
||||||
|
newModelCase.setId(newModelId);
|
||||||
|
newModelCase.setType(CommonConstants.MODEL_TYPE_1);
|
||||||
|
newModelCase.setModelName(modelManagementDO.getModelName() + "-复制模型");
|
||||||
|
|
||||||
|
// 3. 保存新的模型引用案例
|
||||||
|
modelManagementMapper.insert(newModelCase);
|
||||||
|
|
||||||
|
// 4. 复制模型周期及其子集
|
||||||
|
List<ModelCycleDO> originalCycles = modelCycleMapper.selectListByModelId(createReqVO.getId());
|
||||||
|
for (ModelCycleDO originalCycle : originalCycles) {
|
||||||
|
// 复制周期
|
||||||
|
String newCycleId = IdUtil.fastUUID();
|
||||||
|
originalCycle.setId(newCycleId);
|
||||||
|
originalCycle.setModelId(newModelId);
|
||||||
|
modelCycleMapper.insert(originalCycle);
|
||||||
|
|
||||||
|
// 复制环境指标
|
||||||
|
List<ModelEnvironmentIndexDO> environmentIndexes = modelEnvironmentIndexMapper.selectByCycleId(originalCycle.getId());
|
||||||
|
for (ModelEnvironmentIndexDO envIndex : environmentIndexes) {
|
||||||
|
envIndex.setId(IdUtil.fastUUID());
|
||||||
|
envIndex.setCycleId(newCycleId);
|
||||||
|
modelEnvironmentIndexMapper.insert(envIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制气象灾害
|
||||||
|
List<ModelWeatherDisasterDO> weatherDisasters = modelWeatherDisasterMapper.selectByCycleId(originalCycle.getId());
|
||||||
|
for (ModelWeatherDisasterDO weatherDisaster : weatherDisasters) {
|
||||||
|
weatherDisaster.setId(IdUtil.fastUUID());
|
||||||
|
weatherDisaster.setCycleId(newCycleId);
|
||||||
|
modelWeatherDisasterMapper.insert(weatherDisaster);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制病虫草灾害
|
||||||
|
List<ModelPestDiseaseWeedDO> pestDiseaseWeeds = modelPestDiseaseWeedMapper.selectByCycleId(originalCycle.getId());
|
||||||
|
for (ModelPestDiseaseWeedDO pestDiseaseWeed : pestDiseaseWeeds) {
|
||||||
|
pestDiseaseWeed.setId(IdUtil.fastUUID());
|
||||||
|
pestDiseaseWeed.setCycleId(newCycleId);
|
||||||
|
modelPestDiseaseWeedMapper.insert(pestDiseaseWeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制农事操作
|
||||||
|
List<ModelFarmingOperationDO> farmingOperations = modelFarmingOperationMapper.selectByCycleId(originalCycle.getId());
|
||||||
|
for (ModelFarmingOperationDO farmingOperation : farmingOperations) {
|
||||||
|
String newFarmingId = IdUtil.fastUUID();
|
||||||
|
farmingOperation.setId(newFarmingId);
|
||||||
|
farmingOperation.setCycleId(newCycleId);
|
||||||
|
modelFarmingOperationMapper.insert(farmingOperation);
|
||||||
|
|
||||||
|
// 复制农事操作投入品
|
||||||
|
List<ModelFarmingOperationInputDO> farmingOperationInputs = modelFarmingOperationInputMapper.selectByFarmingId(farmingOperation.getId());
|
||||||
|
for (ModelFarmingOperationInputDO farmingOperationInput : farmingOperationInputs) {
|
||||||
|
farmingOperationInput.setId(IdUtil.fastUUID());
|
||||||
|
farmingOperationInput.setFarmingId(newFarmingId);
|
||||||
|
modelFarmingOperationInputMapper.insert(farmingOperationInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回新建的模型引用案例ID
|
||||||
|
return newModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void isRelease(ModelManagementSaveReqVO updateReqVO) {
|
||||||
|
|
||||||
|
ModelManagementDO modelManagementDO = modelManagementMapper.selectById(updateReqVO.getId());
|
||||||
|
if (modelManagementDO.getIsRelease() == 0) {
|
||||||
|
modelManagementDO.setIsRelease(1);
|
||||||
|
} else {
|
||||||
|
modelManagementDO.setIsRelease(0);
|
||||||
|
}
|
||||||
|
modelManagementMapper.updateById(modelManagementDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<ModelManagementDO> getModelManagementPageRelease(ModelManagementPageReqVO pageReqVO) {
|
||||||
|
return modelManagementMapper.selectPageRelease(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user