Merge remote-tracking branch 'origin/main'

This commit is contained in:
顾君禹
2025-08-25 16:39:12 +08:00
11 changed files with 166 additions and 39 deletions

View File

@@ -8,7 +8,7 @@ import java.lang.annotation.Target;
/**
* 多租户 Job 注解
*/
@Target({ElementType.METHOD})
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface TenantJob {
}

View File

@@ -3,18 +3,14 @@ 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.ProductionPlanPageRespVO;
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;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.service.cropFarmingCenter.CropFarmingCenterService;
import cn.iocoder.yudao.module.farm.service.farmingrecord.FarmingRecordService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
@@ -54,8 +50,8 @@ public class CropFarmingCenterController {
// 生产计划
@GetMapping("/production-plan/page")
@Operation(summary = "生产计划-分页")
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);
public CommonResult<ProductionPlanPageRespVO> getProductionPlanPage(@Valid cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageReqVO pageReqVO) {
ProductionPlanPageRespVO pageResult = cropFarmingCenterService.getProductionPlanPage(pageReqVO);
return success(pageResult);
}

View File

@@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @description: 分页响应实体
* @author: binda
* @date: 2025/8/25 14:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProductionPlanPageRespVO {
@Schema(description = "分页数据")
private PageResult<ProductionPlanRespVO> list;
@Schema(description = "计划概括信息")
private PlanOverview planOverview;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class PlanOverview{
@Schema(description = "总面积")
private BigDecimal totalArea;
@Schema(description = "计划总数")
private Integer planCount;
@Schema(description = "已完成-计划个数")
private Integer planCompletedCount;
@Schema(description = "进行中-计划个数")
private Integer planInProgressCount;
@Schema(description = "逾期-计划个数")
private Integer planOverdueCount;
}
}

View File

@@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
@@ -12,6 +14,8 @@ import java.time.LocalDate;
* @date: 2025/8/21 14:17
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProductionPlanRespVO {
@Schema(description = "ID")
@@ -74,4 +78,5 @@ public class ProductionPlanRespVO {
@Schema(description = "模型", example = "芋艿")
private ModelManagementRespVO modelManagementRespVO;
}

View File

@@ -35,7 +35,7 @@ public class ProductionPlanUpdateReqVO {
@Schema(description = "采收开始日期")
private LocalDate harvestStartDate;
@Schema(description = "计划执行状态")
@Schema(description = "计划执行状态 (1:未开始;2:进行中;3:已完成;4:逾期)")
private Integer planStatus;

View File

@@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.farm.dal.mysql.productionplan;
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.cropFarmingCenter.vo.ProductionPlanPageRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 种植中心-生产计划-生产计划 Mapper
@@ -41,4 +43,5 @@ public interface ProductionPlanMapper extends BaseMapperX<ProductionPlanDO> {
);
}
ProductionPlanPageRespVO.PlanOverview getPlanOverview(@Param("baseId") String baseId);
}

View File

@@ -29,6 +29,7 @@ public class CommonConstants {
PLAN_MAP.put(2, "进行中");
PLAN_MAP.put(3, "已完成");
PLAN_MAP.put(4, "逾期");
PLAN_MAP.put(5, "已结束");
}
// 模型类型 (1:模型模板; 2:引用案例)

View File

@@ -0,0 +1,66 @@
package cn.iocoder.yudao.module.farm.scheduled;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.farm.service.farmingrecord.FarmingRecordService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @description: 生产计划
* 表关系
* 模型管理: farm_model_management
* 模型管理-管理周期: farm_model_cycle
* 模型管理-管理周期-环境指标: farm_model_environment_index
* 模型管理-管理周期-病虫草害: farm_model_pest_disease_weed
* 模型管理-管理周期-气象灾害: farm_model_weather_disaster
* 模型管理-管理周期-农事事操: farm_model_farming_operation
* 模型管理-管理周期-农事操作-投入品: farm_model_farming_operation_input
* @author: binda
* @date: 2025/8/22 17:12
*/
@Component
@TenantJob
@Slf4j
public class ProductionPlanJob implements JobHandler {
private final ProductionPlanService productionPlanService;
private final FarmingRecordService farmingRecordService;
public ProductionPlanJob(ProductionPlanService productionPlanService, FarmingRecordService farmingRecordService) {
this.productionPlanService = productionPlanService;
this.farmingRecordService = farmingRecordService;
}
/**
* 1. 更新任务状态
* 2. 更新地块面积
* 3. 创建农事记录
*
* @param param 参数
* @return
* @throws Exception
*/
@Override
public String execute(String param) throws Exception {
this.updatePlanStatusHandler();
this.updatePlanAreaHandler();
this.insertRecordHandler();
return "success";
}
private void updatePlanStatusHandler() {
}
private void updatePlanAreaHandler() {
}
private void insertRecordHandler() {
}
}

View File

@@ -1,10 +1,6 @@
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;
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.*;
/**
* @description: 种植中心
@@ -27,8 +23,7 @@ public interface CropFarmingCenterService {
void updateProductionPlan(ProductionPlanUpdateReqVO updateReqVO);
PageResult<ProductionPlanRespVO> getProductionPlanPage(ProductionPlanPageReqVO reqVO);
ProductionPlanPageRespVO getProductionPlanPage(ProductionPlanPageReqVO reqVO);
int getCropCount(Long tenantId);

View File

@@ -4,33 +4,27 @@ 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.cropFarmingCenter.vo.*;
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecordinput.vo.FarmingRecordInputSaveReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.modelcycle.vo.ModelCycleRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.modelfarmingoperation.vo.ModelFarmingOperationRespVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecord.FarmingRecordDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.farmingrecordinput.FarmingRecordInputDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.modelfarmingoperationinput.ModelFarmingOperationInputDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.dal.mysql.baseinfo.BaseInfoMapper;
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.farmingrecord.FarmingRecordService;
import cn.iocoder.yudao.module.farm.service.farmingrecordinput.FarmingRecordInputService;
import cn.iocoder.yudao.module.farm.service.modelmanagement.ModelManagementService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import cn.iocoder.yudao.module.farm.utils.StrHelperUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -47,15 +41,17 @@ import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PRODUCTION_P
@Slf4j
public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
private final BaseInfoMapper baseInfoMapper;
private final ProductionPlanMapper productionPlanMapper;
private final ModelManagementService modelManagementService;
private final FarmingRecordService farmingRecordService;
private final FarmingRecordInputService farmingRecordInputService;
public CropFarmingCenterServiceImpl(ProductionPlanMapper productionPlanMapper,
ModelManagementService modelManagementService,
FarmingRecordService farmingRecordService,
FarmingRecordInputService farmingRecordInputService) {
public CropFarmingCenterServiceImpl(BaseInfoMapper baseInfoMapper, ProductionPlanMapper productionPlanMapper,
ModelManagementService modelManagementService,
FarmingRecordService farmingRecordService,
FarmingRecordInputService farmingRecordInputService) {
this.baseInfoMapper = baseInfoMapper;
this.productionPlanMapper = productionPlanMapper;
this.modelManagementService = modelManagementService;
this.farmingRecordService = farmingRecordService;
@@ -189,12 +185,13 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
@Override
public ProductionPlanRespVO getProductionPlan(String id) {
LoginUser user = getLoginUser();
QueryWrapper<ProductionPlanDO> queryWrapper = new QueryWrapper();
queryWrapper.eq("id", id);
queryWrapper.eq("tenant_id", user.getTenantId());
ProductionPlanDO productionPlanDO = productionPlanMapper.selectOne(queryWrapper);
ProductionPlanDO productionPlanDO = productionPlanMapper.selectOne(
Wrappers.<ProductionPlanDO>lambdaQuery()
.eq(ProductionPlanDO::getId, id)
.eq(ProductionPlanDO::getTenantId, user.getTenantId())
);
if (productionPlanDO == null) {
return new ProductionPlanRespVO();
throw exception(PRODUCTION_PLAN_NOT_EXISTS);
}
ModelManagementRespVO modelManagementRespVO = modelManagementService.getModelManagement(productionPlanDO.getSpeciesModelId());
@@ -211,18 +208,23 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
}
@Override
public PageResult<ProductionPlanRespVO> getProductionPlanPage(ProductionPlanPageReqVO reqVO) {
public ProductionPlanPageRespVO getProductionPlanPage(ProductionPlanPageReqVO reqVO) {
PageResult<ProductionPlanDO> productionPlanDOPageResult = productionPlanMapper.selectPage2(reqVO);
PageResult<ProductionPlanRespVO> result = BeanUtils.toBean(productionPlanDOPageResult, ProductionPlanRespVO.class);
result.getList().forEach(e -> {
PageResult<ProductionPlanRespVO> resultData = BeanUtils.toBean(productionPlanDOPageResult, ProductionPlanRespVO.class);
resultData.getList().forEach(e -> {
ModelManagementRespVO modelManagementRespVO = modelManagementService.getModelManagement(e.getSpeciesModelId());
e.setModelManagementRespVO(modelManagementRespVO);
});
return result;
// 计划概述
BaseInfoDO baseObj = baseInfoMapper.selectOne("base_id", reqVO.getBaseId());
ProductionPlanPageRespVO.PlanOverview planOverview = productionPlanMapper.getPlanOverview(reqVO.getBaseId());
planOverview.setTotalArea(baseObj.getArea());
return new ProductionPlanPageRespVO(resultData,planOverview);
}
@Override

View File

@@ -15,10 +15,25 @@
where tenant_id = #{tenantId}
and deleted = 0
</select>
<select id="getTotalArea" parameterType="Long" resultType="java.lang.Double">
select sum(total_area)
from farm_production_plan
where tenant_id = #{tenantId}
and deleted = 0
</select>
<select id="getPlanOverview"
parameterType="string"
resultType="cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPageRespVO$PlanOverview">
SELECT
base_id,
COUNT(*) AS planCount,
SUM(CASE WHEN plan_status = 3 THEN 1 ELSE 0 END) AS planCompletedCount,
SUM(CASE WHEN plan_status = 2 THEN 1 ELSE 0 END) AS planInProgressCount,
SUM(CASE WHEN plan_status = 4 THEN 1 ELSE 0 END) AS planOverdueCount
FROM farm_production_plan
WHERE base_id IS NOT NULL AND deleted = 0 AND base_id = #{baseId}
GROUP BY base_id
</select>
</mapper>