fix (farm):

- 种植中心
- 药物分类字典
This commit is contained in:
达富斌
2025-08-21 20:53:49 +08:00
parent 87d50efe06
commit a152f6f935
10 changed files with 150 additions and 55 deletions

View File

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanUpdateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
@@ -40,14 +41,11 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
public class CropFarmingCenterController {
private final CropFarmingCenterService cropFarmingCenterService;
private final ProductionPlanService productionPlanService;
private final FarmingRecordService farmingRecordService;
public CropFarmingCenterController(CropFarmingCenterService cropFarmingCenterService,
ProductionPlanService productionPlanService,
FarmingRecordService farmingRecordService) {
this.cropFarmingCenterService = cropFarmingCenterService;
this.productionPlanService = productionPlanService;
this.farmingRecordService = farmingRecordService;
}
@@ -56,9 +54,9 @@ public class CropFarmingCenterController {
// 生产计划
@GetMapping("/production-plan/page")
@Operation(summary = "生产计划-分页")
public CommonResult<PageResult<ProductionPlanRespVO>> getProductionPlanPage(@Valid ProductionPlanPageReqVO pageReqVO) {
PageResult<ProductionPlanDO> pageResult = productionPlanService.getProductionPlanPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductionPlanRespVO.class));
public CommonResult<PageResult<cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanRespVO>> getProductionPlanPage(@Valid cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageReqVO pageReqVO) {
PageResult<cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanRespVO> pageResult = cropFarmingCenterService.getProductionPlanPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/production-plan/get/{id}")
@@ -77,15 +75,12 @@ public class CropFarmingCenterController {
@PutMapping("/production-plan/update")
@Operation(summary = "生产计划-编辑")
public CommonResult<Boolean> updateProductionPlan(@Valid @RequestBody ProductionPlanSaveReqVO updateReqVO) {
productionPlanService.updateProductionPlan(updateReqVO);
public CommonResult<Boolean> updateProductionPlan(@Valid @RequestBody ProductionPlanUpdateReqVO updateReqVO) {
cropFarmingCenterService.updateProductionPlan(updateReqVO);
return success(true);
}
// 农事记录
@GetMapping("/farming-record/page")
@Operation(summary = "农事记录-分页")

View File

@@ -1,6 +1,13 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @description: 分页请求实体
@@ -8,11 +15,19 @@ import lombok.Data;
* @date: 2025/8/20 17:58
*/
@Data
public class ProductionPlanPageReqVO {
public class ProductionPlanPageReqVO extends PageParam {
@Schema(description = "基地id", example = "29734")
private String baseId;
@Schema(description = "地块ID", example = "19246")
private String plotId;
@Schema(description = "排产开始日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDate[] productionStartDate;
@Schema(description = "计划执行状态")
private Integer planStatus;
}

View File

@@ -37,6 +37,8 @@ public class ProductionPlanRespVO {
@Schema(description = "计划执行状态")
private Integer planStatus;
@Schema(description = "计划执行状态-名称")
private String planStatusName;
@Schema(description = "租户ID")

View File

@@ -28,6 +28,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.inputlibrary.InputLibraryDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.speciesclassifylibrary.SpeciesClassifyLibraryDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
import cn.iocoder.yudao.module.farm.dal.mysql.sysDict.SysDictDO;
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
import cn.iocoder.yudao.module.farm.service.disasterdata.DisasterDataService;
import cn.iocoder.yudao.module.farm.service.farmingnamemaintenance.FarmingNameMaintenanceService;
import cn.iocoder.yudao.module.farm.service.farmingtypemaintenance.FarmingTypeMaintenanceService;
@@ -36,13 +37,15 @@ import cn.iocoder.yudao.module.farm.service.speciesclassifylibrary.SpeciesClassi
import cn.iocoder.yudao.module.farm.service.specieslibrary.SpeciesLibraryService;
import cn.iocoder.yudao.module.farm.service.sysDict.SysDictService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.redisson.misc.Hash;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -190,9 +193,6 @@ public class DictController {
return success(true);
}
// 物种类别维护 todo 后续
// 投入品维护
@Operation(summary = "字典数据维护-投入品-分页")
@GetMapping("/invest-goods/page")
@@ -275,9 +275,34 @@ public class DictController {
@Operation(summary = "字典数据维护-下拉框列表-物种类别")
@GetMapping("/list/species-classify-library")
public CommonResult<List<SpeciesClassifyLibraryRespVO>> getSpeciesClassifyLibraryList() {
List<SpeciesClassifyLibraryDO> res = speciesClassifyLibraryService.getSpeciesClassifyLibraryList();
return success(BeanUtils.toBean(res, SpeciesClassifyLibraryRespVO.class));
List<SysDictDO> list = sysDictService.getByTypeCode(CommonConstants.DICT_TYPE_CODE_3);
Map<String, String> parentMap = list.stream()
.collect(Collectors.toMap(
SysDictDO::getField1Code, // key: field1Code
SysDictDO::getField1Name, // value: field1Name
(existing, replacement) -> existing // 处理重复key,保留现有值
));
List<SpeciesClassifyLibraryRespVO> parentList = new ArrayList<>();
for (Map.Entry<String, String> entry : parentMap.entrySet()) {
String key = entry.getKey();
SpeciesClassifyLibraryRespVO pVO = new SpeciesClassifyLibraryRespVO(key, entry.getValue());
List<SpeciesClassifyLibraryRespVO> childList = new ArrayList<>();
for (SysDictDO e : list) {
if (e.getField1Code().equals(key)) {
childList.add(new SpeciesClassifyLibraryRespVO(e.getField2Code(),e.getField2Name()));
}
}
pVO.setChildren(childList);
parentList.add(pVO);
}
return success(parentList);
}
@Operation(summary = "字典数据维护-下拉框列表-通用字典分类查询")
@GetMapping("/list/{dictTypeCode}")

View File

@@ -1,7 +1,11 @@
package cn.iocoder.yudao.module.farm.controller.admin.dict.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @description: 物种分类
@@ -9,17 +13,22 @@ import lombok.Data;
* @date: 2025/8/17 16:43
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SpeciesClassifyLibraryRespVO {
@Schema(description = "ID")
private String id;
@Schema(description = "一级分类-编码")
private String primaryClassCode;
private String SpeciesClassCode;
@Schema(description = "一级分类-名称")
private String primaryClassName;
@Schema(description = "二级分类-编码")
private String secondaryClassCode;
@Schema(description = "二级分类-名称")
private String secondaryClassName;
private String SpeciesClassName;
@Schema(description = "使用状态")
private String useStatus;
private List<SpeciesClassifyLibraryRespVO> children;
public SpeciesClassifyLibraryRespVO(String speciesClassCode, String speciesClassName) {
SpeciesClassCode = speciesClassCode;
SpeciesClassName = speciesClassName;
}
}

View File

@@ -18,20 +18,27 @@ public interface ProductionPlanMapper extends BaseMapperX<ProductionPlanDO> {
Double getTotalArea(Long tenantId);
// default PageResult<ProductionPlanDO> selectPage(ProductionPlanPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>()
// .eqIfPresent(ProductionPlanDO::getPlantSpecies, reqVO.getPlantSpecies())
// .eqIfPresent(ProductionPlanDO::getSpeciesModel, reqVO.getSpeciesModel())
// .betweenIfPresent(ProductionPlanDO::getProductionStartDate, reqVO.getProductionStartDate())
// .betweenIfPresent(ProductionPlanDO::getProductionEndDate, reqVO.getProductionEndDate())
// .betweenIfPresent(ProductionPlanDO::getHarvestStartDate, reqVO.getHarvestStartDate())
// .eqIfPresent(ProductionPlanDO::getCultivationAreaId, reqVO.getCultivationAreaId())
// .eqIfPresent(ProductionPlanDO::getBaseId, reqVO.getBaseId())
// .likeIfPresent(ProductionPlanDO::getBaseName, reqVO.getBaseName())
// .eqIfPresent(ProductionPlanDO::getPlotId, reqVO.getPlotId())
// .likeIfPresent(ProductionPlanDO::getPlotName, reqVO.getPlotName())
// .betweenIfPresent(ProductionPlanDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(ProductionPlanDO::getCreateTime));
// }
default PageResult<ProductionPlanDO> selectPage(ProductionPlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>()
.betweenIfPresent(ProductionPlanDO::getProductionStartDate, reqVO.getProductionStartDate())
.betweenIfPresent(ProductionPlanDO::getProductionEndDate, reqVO.getProductionEndDate())
.betweenIfPresent(ProductionPlanDO::getHarvestStartDate, reqVO.getHarvestStartDate())
.eqIfPresent(ProductionPlanDO::getBaseId, reqVO.getBaseId())
.likeIfPresent(ProductionPlanDO::getBaseName, reqVO.getBaseName())
.eqIfPresent(ProductionPlanDO::getPlotId, reqVO.getPlotId())
.likeIfPresent(ProductionPlanDO::getPlotName, reqVO.getPlotName())
.betweenIfPresent(ProductionPlanDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductionPlanDO::getCreateTime)
);
}
default PageResult<ProductionPlanDO> selectPage2(cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>()
.betweenIfPresent(ProductionPlanDO::getProductionStartDate, reqVO.getProductionStartDate())
.eqIfPresent(ProductionPlanDO::getBaseId, reqVO.getBaseId())
.eqIfPresent(ProductionPlanDO::getPlotId, reqVO.getPlotId())
.orderByDesc(ProductionPlanDO::getCreateTime)
);
}
}

View File

@@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.farm.enums;
import java.util.HashMap;
import java.util.Map;
/**
* @description: 通用常量
* @author: binda
@@ -20,12 +23,24 @@ public class CommonConstants {
public final static Integer PLAN_STATUS_3 = 3;
public final static Integer PLAN_STATUS_4 = 4;
public static Map<Integer, String> PLAN_MAP = new HashMap<>();
static{
PLAN_MAP.put(1, "未开始");
PLAN_MAP.put(2, "进行中");
PLAN_MAP.put(3, "已完成");
PLAN_MAP.put(4, "逾期");
}
// 模型类型 (1:模型模板; 2:引用案例)
public final static Integer MODEL_TYPE_1 = 1;
public final static Integer MODEL_TYPE_2 = 1;
public final static String DICT_TYPE_CODE_1 = "common_disaster";
/**
* 字典类型名称
*/
public final static String DICT_TYPE_CODE_1 = "common_disaster"; // 一般灾害
public final static String DICT_TYPE_CODE_2 = "weather_disaster"; // 气象灾害
public final static String DICT_TYPE_CODE_3 = "species_classify_library"; // 物种类别
}

View File

@@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.farm.service.cropFarmingCenter;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanUpdateReqVO;
/**
* @description: 种植中心
@@ -14,6 +17,7 @@ public interface CropFarmingCenterService {
* 生产计划-新增
* 1份生产计划 -> n种植区域 (区域: 一个基地的某个地块,划分为多亩地,交叉种植)
* -> 1模型案例(可以修改,不影响原有模版)
*
* @param
* @return
*/
@@ -21,7 +25,10 @@ public interface CropFarmingCenterService {
ProductionPlanRespVO getProductionPlan(String id);
void updateProductionPlan(ProductionPlanSaveReqVO updateReqVO);
void updateProductionPlan(ProductionPlanUpdateReqVO updateReqVO);
PageResult<ProductionPlanRespVO> getProductionPlanPage(ProductionPlanPageReqVO reqVO);
int getCropCount(Long tenantId);

View File

@@ -1,16 +1,17 @@
package cn.iocoder.yudao.module.farm.service.cropFarmingCenter;
import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanSaveReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanUpdateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementRespVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.dal.mysql.productionplan.ProductionPlanMapper;
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;
@@ -19,7 +20,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PRODUCTION_PLAN_NOT_EXISTS;
/**
* @description: 种植中心
@@ -30,14 +33,10 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
@Slf4j
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, ModelManagementService modelManagementService) {
this.cultivationAreaService = cultivationAreaService;
this.productionPlanService = productionPlanService;
public CropFarmingCenterServiceImpl(ProductionPlanMapper productionPlanMapper, ModelManagementService modelManagementService) {
this.productionPlanMapper = productionPlanMapper;
this.modelManagementService = modelManagementService;
}
@@ -80,7 +79,6 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
obj.setPlotName(e.getPlotName());
obj.setTenantId(e.getTenantId());
// 随机字符串 + 地块名称
obj.setPlanNumber(StrHelperUtil.generate() +"-"+ e.getPlotName());
obj.setId(taskId);
@@ -110,8 +108,24 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
}
@Override
public void updateProductionPlan(ProductionPlanSaveReqVO updateReqVO) {
public void updateProductionPlan(ProductionPlanUpdateReqVO updateReqVO) {
validateProductionPlanExists(updateReqVO.getId());
productionPlanMapper.updateById(BeanUtils.toBean(updateReqVO, ProductionPlanDO.class));
}
@Override
public PageResult<ProductionPlanRespVO> getProductionPlanPage(ProductionPlanPageReqVO reqVO) {
PageResult<ProductionPlanDO> productionPlanDOPageResult = productionPlanMapper.selectPage2(reqVO);
PageResult<ProductionPlanRespVO> result = BeanUtils.toBean(productionPlanDOPageResult, ProductionPlanRespVO.class);
result.getList().forEach(e -> {
ModelManagementRespVO modelManagementRespVO = modelManagementService.getModelManagement(e.getSpeciesModelId());
e.setModelManagementRespVO(modelManagementRespVO);
});
return result;
}
@Override
@@ -123,4 +137,10 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
public Double getTotalArea(Long tenantId) {
return productionPlanMapper.getTotalArea(tenantId);
}
private void validateProductionPlanExists(String id) {
if (productionPlanMapper.selectById(id) == null) {
throw exception(PRODUCTION_PLAN_NOT_EXISTS);
}
}
}

View File

@@ -89,7 +89,7 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
@Override
public PageResult<ProductionPlanDO> getProductionPlanPage(ProductionPlanPageReqVO pageReqVO) {
// productionPlanMapper.selectPage(pageReqVO);
productionPlanMapper.selectPage(pageReqVO);
return null;
}