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