feat (farm): 业务功能

- 种植中心 - 生产计划
This commit is contained in:
达富斌
2025-08-21 09:22:20 +08:00
parent 6eebfe82f4
commit ea4761845d
12 changed files with 157 additions and 66 deletions

View File

@@ -70,9 +70,9 @@ public class CropFarmingCenterController {
@PostMapping("/production-plan/create") @PostMapping("/production-plan/create")
@Operation(summary = "生产计划-创建") @Operation(summary = "生产计划-创建")
public CommonResult<String> createProductionPlan(@Valid @RequestBody cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO createReqVO) { public CommonResult<Boolean> createProductionPlan(@Valid @RequestBody cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO createReqVO) {
String res = cropFarmingCenterService.createProductionPlan(createReqVO); cropFarmingCenterService.createProductionPlan(createReqVO);
return success(res); return success(true);
} }
@PutMapping("/production-plan/update") @PutMapping("/production-plan/update")

View File

@@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
import lombok.Data;
/**
* @description: 分页请求实体
* @author: binda
* @date: 2025/8/20 17:58
*/
@Data
public class ProductionPlanPageReqVO {
}

View File

@@ -14,11 +14,6 @@ import java.util.List;
@Data @Data
public class ProductionPlanSaveReqVO { public class ProductionPlanSaveReqVO {
@Schema(description = "UUID")
private String id;
@Schema(description = "计划编号")
private String planNumber;
@Schema(description = "种植物种-编码") @Schema(description = "种植物种-编码")
private String plantSpeciesCode; private String plantSpeciesCode;
@@ -61,19 +56,23 @@ public class ProductionPlanSaveReqVO {
/** /**
* 种植区域信息 * 种植区域信息
*/ */
@Schema(description = "种植日期") @Schema(description = "种植日期")
private LocalDate plantingDate; private LocalDate plantingDate;
@Schema(description = "种植株数") @Schema(description = "种植株数")
private LocalDate plantingQuantity; private Integer plantingQuantity;
@Schema(description = "预计产量") @Schema(description = "预计产量")
private Long predictedYields; private Integer predictedYields;
@Schema(description = "总面积")
private Double totalArea;
@Schema(description = "计划面积") @Schema(description = "计划面积")
private Long predictedArea; private Double predictedArea;
@Schema(description = "剩余面积") @Schema(description = "剩余面积")
private Long remainingArea; private Double remainingArea;
@Schema(description = "占地面积") @Schema(description = "占地面积")
private Integer usagePercentage; private Integer usagePercentage;
@Schema(description = "备注")
private String remark;
} }

View File

@@ -5,8 +5,6 @@ import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.Productio
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO; import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.Valid;
import jakarta.validation.Valid;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.productionplan; package cn.iocoder.yudao.module.farm.dal.dataobject.productionplan;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.time.LocalDate; import java.time.LocalDate;
@@ -23,18 +24,22 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
public class ProductionPlanDO extends BaseDO { public class ProductionPlanDO extends BaseDO {
/** /**
* 基础id * ID
*/ */
@TableId(type = IdType.INPUT) @TableId(type = IdType.INPUT)
private String id; private String id;
/**
* 计划编号
*/
private String planNumber;
/** /**
* 种植物种 * 种植物种
*/ */
private String plantSpecies; private String plantSpeciesCode;
/** /**
* 物种模型 * 物种模型
*/ */
private String speciesModel; private String speciesModelId;
/** /**
* 排产开始日期 * 排产开始日期
*/ */
@@ -47,14 +52,44 @@ public class ProductionPlanDO extends BaseDO {
* 采收开始日期 * 采收开始日期
*/ */
private LocalDate harvestStartDate; private LocalDate harvestStartDate;
/**
* 执行状态
*/
private Integer planStatus;
/**
* 种植日期
*/
private LocalDate plantingDate;
/**
* 种植株数
*/
private Integer plantingQuantity;
/** /**
* 预计产量 * 预计产量
*/ */
private Integer estimatedOutput; private Integer predictedYields;
/** /**
* 种植区域ID * 总面积
*/ */
private String cultivationAreaId; private Double totalArea;
/**
* 计划面积
*/
private Double predictedArea;
/**
* 剩余面积
*/
private Double remainingArea;
/**
* 占地面积
*/
private Integer usagePercentage;
/**
* 备注
*/
private String remark;
/** /**
* 基地id * 基地id
*/ */
@@ -71,6 +106,8 @@ public class ProductionPlanDO extends BaseDO {
* 地块 * 地块
*/ */
private String plotName; private String plotName;
/**
* 租户ID
*/
private String tenantId; private String tenantId;
} }

View File

@@ -1,8 +1,5 @@
package cn.iocoder.yudao.module.farm.dal.mysql.disasterdata; package cn.iocoder.yudao.module.farm.dal.mysql.disasterdata;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.farm.controller.admin.disasterdata.vo.DisasterDataPageReqVO; import cn.iocoder.yudao.module.farm.controller.admin.disasterdata.vo.DisasterDataPageReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO; import cn.iocoder.yudao.module.farm.dal.dataobject.disasterdata.DisasterDataDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;

View File

@@ -15,20 +15,20 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface ProductionPlanMapper extends BaseMapperX<ProductionPlanDO> { public interface ProductionPlanMapper extends BaseMapperX<ProductionPlanDO> {
default PageResult<ProductionPlanDO> selectPage(ProductionPlanPageReqVO reqVO) { // default PageResult<ProductionPlanDO> selectPage(ProductionPlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>() // return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>()
.eqIfPresent(ProductionPlanDO::getPlantSpecies, reqVO.getPlantSpecies()) // .eqIfPresent(ProductionPlanDO::getPlantSpecies, reqVO.getPlantSpecies())
.eqIfPresent(ProductionPlanDO::getSpeciesModel, reqVO.getSpeciesModel()) // .eqIfPresent(ProductionPlanDO::getSpeciesModel, reqVO.getSpeciesModel())
.betweenIfPresent(ProductionPlanDO::getProductionStartDate, reqVO.getProductionStartDate()) // .betweenIfPresent(ProductionPlanDO::getProductionStartDate, reqVO.getProductionStartDate())
.betweenIfPresent(ProductionPlanDO::getProductionEndDate, reqVO.getProductionEndDate()) // .betweenIfPresent(ProductionPlanDO::getProductionEndDate, reqVO.getProductionEndDate())
.betweenIfPresent(ProductionPlanDO::getHarvestStartDate, reqVO.getHarvestStartDate()) // .betweenIfPresent(ProductionPlanDO::getHarvestStartDate, reqVO.getHarvestStartDate())
.eqIfPresent(ProductionPlanDO::getCultivationAreaId, reqVO.getCultivationAreaId()) // .eqIfPresent(ProductionPlanDO::getCultivationAreaId, reqVO.getCultivationAreaId())
.eqIfPresent(ProductionPlanDO::getBaseId, reqVO.getBaseId()) // .eqIfPresent(ProductionPlanDO::getBaseId, reqVO.getBaseId())
.likeIfPresent(ProductionPlanDO::getBaseName, reqVO.getBaseName()) // .likeIfPresent(ProductionPlanDO::getBaseName, reqVO.getBaseName())
.eqIfPresent(ProductionPlanDO::getPlotId, reqVO.getPlotId()) // .eqIfPresent(ProductionPlanDO::getPlotId, reqVO.getPlotId())
.likeIfPresent(ProductionPlanDO::getPlotName, reqVO.getPlotName()) // .likeIfPresent(ProductionPlanDO::getPlotName, reqVO.getPlotName())
.betweenIfPresent(ProductionPlanDO::getCreateTime, reqVO.getCreateTime()) // .betweenIfPresent(ProductionPlanDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductionPlanDO::getCreateTime)); // .orderByDesc(ProductionPlanDO::getCreateTime));
} // }
} }

View File

@@ -12,4 +12,13 @@ public class CommonConstants {
public final static Integer NO_CODE = 0; public final static Integer NO_CODE = 0;
public final static String NO_NAME = "否"; public final static String NO_NAME = "否";
// 1:未开始;2:进行中;3:已完成;4:逾期
public final static Integer PLAN_STATUS_1 = 1;
public final static Integer PLAN_STATUS_2 = 2;
public final static Integer PLAN_STATUS_3 = 3;
public final static Integer PLAN_STATUS_4 = 4;
} }

View File

@@ -11,8 +11,10 @@ public interface CropFarmingCenterService {
/** /**
* 生产计划-新增 * 生产计划-新增
* 1份生产计划 -> n种植区域 (区域: 一个基地的某个地块,划分为多亩地,交叉种植)
* -> 1模型案例(可以修改,不影响原有模版)
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
String createProductionPlan(ProductionPlanSaveReqVO createReqVO); void createProductionPlan(ProductionPlanSaveReqVO createReqVO);
} }

View File

@@ -1,13 +1,19 @@
package cn.iocoder.yudao.module.farm.service.cropFarmingCenter; package cn.iocoder.yudao.module.farm.service.cropFarmingCenter;
import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO; import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO;
import cn.iocoder.yudao.module.farm.service.cultivationarea.CultivationAreaService; import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService; import cn.iocoder.yudao.module.farm.dal.mysql.productionplan.ProductionPlanMapper;
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
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;
import java.util.ArrayList;
import java.util.List;
/** /**
* @description: * @description: 种植中心
* @author: binda * @author: binda
* @date: 2025/8/19 11:34 * @date: 2025/8/19 11:34
*/ */
@@ -15,26 +21,50 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class CropFarmingCenterServiceImpl implements CropFarmingCenterService { public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
private final CultivationAreaService cultivationAreaService; private final ProductionPlanMapper productionPlanMapper;
private final ProductionPlanService productionPlanService;
public CropFarmingCenterServiceImpl(CultivationAreaService cultivationAreaService, ProductionPlanService productionPlanService) { public CropFarmingCenterServiceImpl(ProductionPlanMapper productionPlanMapper) {
this.cultivationAreaService = cultivationAreaService; this.productionPlanMapper = productionPlanMapper;
this.productionPlanService = productionPlanService;
} }
// 创建
// 1份生产计划 -> n种植区域; 1个种植区域 -> 1基地的n个地块(种植区域)
@Override @Override
public String createProductionPlan(ProductionPlanSaveReqVO createReqVO) { public void createProductionPlan(ProductionPlanSaveReqVO reqVO) {
List<ProductionPlanSaveReqVO.CultivationArea> cultivationAreaList = reqVO.getCultivationAreaList();
List<ProductionPlanDO> list = new ArrayList<>();
cultivationAreaList.forEach(e -> {
ProductionPlanDO obj = new ProductionPlanDO();
obj.setPlantSpeciesCode(reqVO.getPlantSpeciesCode());
obj.setSpeciesModelId(reqVO.getSpeciesModelId());
obj.setProductionStartDate(reqVO.getProductionStartDate());
obj.setProductionEndDate(reqVO.getProductionEndDate());
obj.setHarvestStartDate(reqVO.getHarvestStartDate());
obj.setPlanStatus(CommonConstants.PLAN_STATUS_1);
obj.setPlantingDate(e.getPlantingDate());
obj.setPlantingQuantity(e.getPlantingQuantity());
obj.setPredictedYields(e.getPredictedYields());
obj.setTotalArea(e.getTotalArea());
obj.setPredictedArea(e.getPredictedArea());
obj.setRemainingArea(e.getRemainingArea());
obj.setUsagePercentage(e.getUsagePercentage());
obj.setRemark(e.getRemark());
obj.setBaseId(e.getBaseId());
obj.setBaseName(e.getBaseName());
obj.setPlotId(e.getPlotId());
obj.setPlotName(e.getPlotName());
obj.setTenantId(e.getTenantId());
// 随机字符串 + 地块名称
obj.setId(IdUtil.fastUUID());
obj.setPlanNumber(StrHelperUtil.generate() + e.getPlotName());
list.add(obj);
});
productionPlanMapper.insertBatch(list);
return null;
} }
} }

View File

@@ -85,12 +85,12 @@ public class HomeServiceImpl implements HomeService {
productionPlanInfos.forEach(ee -> { productionPlanInfos.forEach(ee -> {
HomeInfoVO.ProductionPlanVO planVO = new HomeInfoVO.ProductionPlanVO(); HomeInfoVO.ProductionPlanVO planVO = new HomeInfoVO.ProductionPlanVO();
planVO.setId(ee.getId()); planVO.setId(ee.getId());
planVO.setPlantSpecies(ee.getPlantSpecies()); // planVO.setPlantSpecies(ee.getPlantSpecies());
planVO.setCultivationAreaId(ee.getCultivationAreaId()); // planVO.setCultivationAreaId(ee.getCultivationAreaId());
planVO.setManagementCycleName(""); // todo 当前管理周期名称 planVO.setManagementCycleName(""); // todo 当前管理周期名称
planVO.setManagementCyclePlan(""); // todo 当前管理周期计划进度 planVO.setManagementCyclePlan(""); // todo 当前管理周期计划进度
planVO.setCultivatedArea(0); // todo 种植面积 planVO.setCultivatedArea(0); // todo 种植面积
planVO.setEstimatedOutput(ee.getEstimatedOutput()); // todo 预产数量 // planVO.setEstimatedOutput(ee.getEstimatedOutput()); // todo 预产数量
planVO.setTaskCount(0); // todo 任务数量 planVO.setTaskCount(0); // todo 任务数量
planVO.setManager(""); // planVO.setManager(""); //
plans.add(planVO); // todo 任务负责人 plans.add(planVO); // todo 任务负责人

View File

@@ -1,17 +1,17 @@
package cn.iocoder.yudao.module.farm.service.productionplan; package cn.iocoder.yudao.module.farm.service.productionplan;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO; import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO; import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO; import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.LoginUser;
@@ -66,12 +66,12 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
} }
@Override @Override
public void deleteProductionPlanListByIds(List<String> ids) { public void deleteProductionPlanListByIds(List<String> ids) {
// 删除 // 删除
productionPlanMapper.deleteByIds(ids); productionPlanMapper.deleteByIds(ids);
} }
private void validateProductionPlanExists(String id) { private void validateProductionPlanExists(String id) {
if (productionPlanMapper.selectById(id) == null) { if (productionPlanMapper.selectById(id) == null) {
throw exception(PRODUCTION_PLAN_NOT_EXISTS); throw exception(PRODUCTION_PLAN_NOT_EXISTS);
} }
@@ -89,7 +89,8 @@ private void validateProductionPlanExists(String id) {
@Override @Override
public PageResult<ProductionPlanDO> getProductionPlanPage(ProductionPlanPageReqVO pageReqVO) { public PageResult<ProductionPlanDO> getProductionPlanPage(ProductionPlanPageReqVO pageReqVO) {
return productionPlanMapper.selectPage(pageReqVO); // productionPlanMapper.selectPage(pageReqVO);
return null;
} }
} }