feat (farm): 业务功能
- 种植中心 - 生产计划 - 模型管理 - 引用模型案例
This commit is contained in:
@@ -27,6 +27,10 @@ public class ModelManagementDO extends BaseDO {
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String id;
|
||||
/**
|
||||
* 模型类型 (1:模型; 2:引用案例)
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 模型名称
|
||||
*/
|
||||
@@ -73,5 +77,9 @@ public class ModelManagementDO extends BaseDO {
|
||||
private String plotName;
|
||||
|
||||
private String tenantId;
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
}
|
||||
|
||||
@@ -20,5 +20,8 @@ public class CommonConstants {
|
||||
public final static Integer PLAN_STATUS_3 = 3;
|
||||
public final static Integer PLAN_STATUS_4 = 4;
|
||||
|
||||
// 模型类型 (1:模型模板; 2:引用案例)
|
||||
public final static Integer MODEL_TYPE_1 = 1;
|
||||
public final static Integer MODEL_TYPE_2 = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.productionplan.ProductionPlanMappe
|
||||
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
||||
import cn.iocoder.yudao.module.farm.service.cultivationarea.CultivationAreaService;
|
||||
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
||||
import cn.iocoder.yudao.module.farm.service.modelmanagement.ModelManagementService;
|
||||
import cn.iocoder.yudao.module.farm.utils.StrHelperUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,28 +27,32 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
private final CultivationAreaService cultivationAreaService;
|
||||
private final ProductionPlanService productionPlanService;
|
||||
private final ProductionPlanMapper productionPlanMapper;
|
||||
private final ModelManagementService modelManagementService;
|
||||
|
||||
public CropFarmingCenterServiceImpl(CultivationAreaService cultivationAreaService, ProductionPlanService productionPlanService, ProductionPlanMapper productionPlanMapper) {
|
||||
public CropFarmingCenterServiceImpl(CultivationAreaService cultivationAreaService, ProductionPlanService productionPlanService, ProductionPlanMapper productionPlanMapper, ModelManagementService modelManagementService) {
|
||||
this.cultivationAreaService = cultivationAreaService;
|
||||
this.productionPlanService = productionPlanService;
|
||||
this.productionPlanMapper = productionPlanMapper;
|
||||
this.modelManagementService = modelManagementService;
|
||||
}
|
||||
|
||||
|
||||
// 创建
|
||||
// 1份生产计划 -> n种植区域; 1个种植区域 -> 1基地的n个地块(种植区域)
|
||||
|
||||
|
||||
@Override
|
||||
public void createProductionPlan(ProductionPlanSaveReqVO reqVO) {
|
||||
String taskId = IdUtil.fastUUID();
|
||||
String speciesModelId = reqVO.getSpeciesModelId();
|
||||
// 创建模型案例
|
||||
speciesModelId = modelManagementService.createModelManagementCase(speciesModelId,taskId);
|
||||
if (speciesModelId.equals("")) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ProductionPlanSaveReqVO.CultivationArea> cultivationAreaList = reqVO.getCultivationAreaList();
|
||||
|
||||
List<ProductionPlanDO> list = new ArrayList<>();
|
||||
cultivationAreaList.forEach(e -> {
|
||||
for (ProductionPlanSaveReqVO.CultivationArea e : cultivationAreaList) {
|
||||
ProductionPlanDO obj = new ProductionPlanDO();
|
||||
obj.setPlantSpeciesCode(reqVO.getPlantSpeciesCode());
|
||||
obj.setSpeciesModelId(reqVO.getSpeciesModelId());
|
||||
obj.setSpeciesModelId(speciesModelId);
|
||||
obj.setProductionStartDate(reqVO.getProductionStartDate());
|
||||
obj.setProductionEndDate(reqVO.getProductionEndDate());
|
||||
obj.setHarvestStartDate(reqVO.getHarvestStartDate());
|
||||
@@ -68,11 +73,12 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
obj.setPlotName(e.getPlotName());
|
||||
obj.setTenantId(e.getTenantId());
|
||||
|
||||
|
||||
// 随机字符串 + 地块名称
|
||||
obj.setId(IdUtil.fastUUID());
|
||||
obj.setPlanNumber(StrHelperUtil.generate() + e.getPlotName());
|
||||
obj.setId(taskId);
|
||||
list.add(obj);
|
||||
});
|
||||
}
|
||||
productionPlanMapper.insertBatch(list);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface ModelManagementService {
|
||||
* @return 编号
|
||||
*/
|
||||
String createModelManagement(@Valid ModelManagementSaveReqVO createReqVO);
|
||||
String createModelManagementCase(String id,String taskId);
|
||||
|
||||
/**
|
||||
* 更新模型管理
|
||||
|
||||
@@ -23,6 +23,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.modelfarmingoperationinput.ModelFa
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.modelmanagement.ModelManagementMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.modelpestdiseaseweed.ModelPestDiseaseWeedMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.modelweatherdisaster.ModelWeatherDisasterMapper;
|
||||
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -71,6 +72,23 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
||||
return modelManagement.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createModelManagementCase(String id,String taskId) {
|
||||
|
||||
ModelManagementDO modelManagementDO = modelManagementMapper.selectOne(
|
||||
ModelManagementDO::getId, id,
|
||||
ModelManagementDO::getType, CommonConstants.MODEL_TYPE_1
|
||||
);
|
||||
|
||||
if (modelManagementDO == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
this.getModelManagement(modelManagementDO.getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateModelManagement(ModelManagementSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
|
||||
Reference in New Issue
Block a user