feat (farm): 农事记录,生产计划
- 基地统计信息 - 增加 实际产量字段
This commit is contained in:
@@ -3,10 +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.ProductionPlanRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanPage2ReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.ProductionPlanResp2VO;
|
||||
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.FarmingRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.farmingrecord.vo.FarmingRecordSaveReqVO;
|
||||
@@ -135,6 +132,13 @@ public class CropFarmingCenterController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "生产计划-统计信息")
|
||||
@GetMapping("/production-plan/statistics")
|
||||
@Parameter(name = "baseId", description = "基地编号")
|
||||
public CommonResult<BasePlanOverviewRespVO> getBaseOverview(@RequestParam("baseId") String baseId) {
|
||||
BasePlanOverviewRespVO res = cropFarmingCenterService.getBaseOverview(baseId);
|
||||
return success(res);
|
||||
}
|
||||
|
||||
// 农事记录
|
||||
@GetMapping("/farming-record/page")
|
||||
@@ -171,4 +175,12 @@ public class CropFarmingCenterController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "农事记录-统计信息")
|
||||
@GetMapping("/farming-record/statistics")
|
||||
@Parameter(name = "baseId", description = "基地编号")
|
||||
public CommonResult<FarmRecordOverviewRespVO> getFarmRecordOverview(@RequestParam("baseId") String baseId) {
|
||||
FarmRecordOverviewRespVO res = cropFarmingCenterService.getFarmRecordOverview(baseId);
|
||||
return success(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
|
||||
|
||||
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/9/3 13:40
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BasePlanOverviewRespVO {
|
||||
@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;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo;
|
||||
|
||||
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/9/3 14:45
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FarmRecordOverviewRespVO {
|
||||
@Schema(description = "总面积")
|
||||
private BigDecimal totalArea;
|
||||
@Schema(description = "农事总数")
|
||||
private Integer farmRecordCount;
|
||||
}
|
||||
@@ -78,6 +78,10 @@ public class ProductionPlanDO extends BaseDO {
|
||||
* 预计产量
|
||||
*/
|
||||
private Integer predictedYields;
|
||||
/**
|
||||
* 实际产量
|
||||
*/
|
||||
private Integer practicalYields;
|
||||
/**
|
||||
* 总面积
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.farm.controller.admin.baseinfo.vo.BaseInfoPageReq
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 基地 Mapper
|
||||
*
|
||||
@@ -27,4 +29,6 @@ public interface BaseInfoMapper extends BaseMapperX<BaseInfoDO> {
|
||||
}
|
||||
|
||||
int getBaseCount(Long tenantId);
|
||||
|
||||
BigDecimal getTotalBaseArea(String id, Long tenantId);
|
||||
}
|
||||
@@ -143,8 +143,9 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
||||
List<BaseNameRespVO.PlotInfoVO> childList = new ArrayList<>();
|
||||
for (PlotInfoDO aDo : plotInfoDOS) {
|
||||
if (aDo.getBaseId().equals(key)) {
|
||||
double remainingArea = productionPlanService.getPredictedArea(aDo.getBaseId());
|
||||
childList.add(new BaseNameRespVO.PlotInfoVO(aDo.getPlotId(), aDo.getPlotName(), aDo.getPlotArea(), remainingArea));
|
||||
BigDecimal plotArea = aDo.getPlotArea();
|
||||
double remainingArea = productionPlanService.getPredictedArea(aDo.getPlotId(),plotArea);
|
||||
childList.add(new BaseNameRespVO.PlotInfoVO(aDo.getPlotId(), aDo.getPlotName(), plotArea, remainingArea));
|
||||
}
|
||||
}
|
||||
obj.setChildren(childList);
|
||||
|
||||
@@ -25,6 +25,7 @@ public interface CropFarmingCenterService {
|
||||
void updateProductionPlan(ProductionPlanUpdateReqVO updateReqVO);
|
||||
|
||||
PageResult<ProductionPlanRespVO> getProductionPlanPage(ProductionPlanPage2ReqVO reqVO);
|
||||
|
||||
PageResult<ProductionPlanResp2VO> getProductionPlanPage2(ProductionPlanPage2ReqVO reqVO);
|
||||
|
||||
int getCropCount(Long tenantId);
|
||||
@@ -36,4 +37,8 @@ public interface CropFarmingCenterService {
|
||||
void reviseProductionPlan(ProductionPlanUpdateReqVO updateReqVO);
|
||||
|
||||
void restartProductionPlan(ProductionPlanUpdateReqVO updateReqVO);
|
||||
|
||||
BasePlanOverviewRespVO getBaseOverview(String baseId);
|
||||
|
||||
FarmRecordOverviewRespVO getFarmRecordOverview(String baseId);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
@@ -297,7 +298,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
id += nodes.size();
|
||||
}
|
||||
|
||||
return new PageResult<ProductionPlanResp2VO>(roots, (long) roots.size());
|
||||
return new PageResult<>(roots, (long) roots.size());
|
||||
}
|
||||
|
||||
private List<ProductionPlanResp2VO> loopPlanList(ProductionPlanResp2VO currentParentNode,
|
||||
@@ -328,7 +329,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
subNode.setPredictedYields(subPlan.getPredictedYields());
|
||||
subNode.setOverdueDays(this.countOverdueDays(subPlan));
|
||||
subNode.setIntervalDays(this.countIntervalDays(subPlan));
|
||||
subNode.setPlanOverview(this.getPlanOverview(subPlan));
|
||||
// subNode.setPlanOverview(this.getPlanOverview(subPlan));
|
||||
subNode.setModelInfo(this.getModelManagement(subPlan, employeeNameMap));
|
||||
nodes.add(subNode);
|
||||
|
||||
@@ -370,7 +371,7 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
modelInfo.setCycleName(modelManagementDo.getCycleName());
|
||||
modelInfo.setPredictedArea(planObj.getPredictedArea());
|
||||
modelInfo.setPredictedYields(planObj.getPredictedYields());
|
||||
modelInfo.setProgressBar("1/10"); // TODO: 2025/8/30
|
||||
modelInfo.setProgressBar("1/10"); // TODO: 2025/8/30 农事记录
|
||||
modelInfo.setProgressRatio("10"); // TODO: 2025/8/31
|
||||
modelInfo.setProgressNumerator(1);
|
||||
modelInfo.setProgressDenominator(10);
|
||||
@@ -497,4 +498,30 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
|
||||
public void restartProductionPlan(ProductionPlanUpdateReqVO updateReqVO) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasePlanOverviewRespVO getBaseOverview(String baseId) {
|
||||
LoginUser user = getLoginUser();
|
||||
Long tenantId = user.getTenantId();
|
||||
BigDecimal totalArea = baseInfoMapper.getTotalBaseArea(baseId,tenantId);
|
||||
|
||||
if (totalArea != null) {
|
||||
ProductionPlanRespVO.PlanOverview source = productionPlanMapper.getPlanOverview(baseId);
|
||||
source.setTotalArea(totalArea);
|
||||
return BeanUtils.toBean(source, BasePlanOverviewRespVO.class);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FarmRecordOverviewRespVO getFarmRecordOverview(String baseId) {
|
||||
LoginUser user = getLoginUser();
|
||||
Long tenantId = user.getTenantId();
|
||||
|
||||
BigDecimal totalArea = baseInfoMapper.getTotalBaseArea(baseId,tenantId);
|
||||
int farmRecordCount = farmingRecordService.getFarmRecordOverview(baseId);
|
||||
|
||||
return new FarmRecordOverviewRespVO(totalArea,farmRecordCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface FarmingRecordService {
|
||||
List<FarmingRecordDO> getFarmingRecordList();
|
||||
|
||||
void createFarmingRecordList(List<FarmingRecordSaveReqVO> farmingRecordSaveReqVOList);
|
||||
|
||||
int getFarmRecordOverview(String baseId);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.farmingtypemaintenance.Farmin
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecord.FarmingRecordMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingrecordinput.FarmingRecordInputMapper;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.farmingtypemaintenance.FarmingTypeMaintenanceMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -227,4 +228,17 @@ public class FarmingRecordServiceImpl implements FarmingRecordService {
|
||||
public void createFarmingRecordList(List<FarmingRecordSaveReqVO> farmingRecordSaveReqVOList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFarmRecordOverview(String baseId) {
|
||||
LoginUser user = getLoginUser();
|
||||
Long tenantId = user.getTenantId();
|
||||
|
||||
LambdaQueryWrapperX<FarmingRecordDO> x = new LambdaQueryWrapperX<>();
|
||||
x.eqIfPresent(FarmingRecordDO::getBaseId, baseId);
|
||||
x.eq(FarmingRecordDO::getTenantId, tenantId);
|
||||
Long count = farmingRecordMapper.selectCount(x);
|
||||
return count.intValue();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public interface ProductionPlanService {
|
||||
* @param baseId
|
||||
* @return
|
||||
*/
|
||||
double getPredictedArea(String baseId);
|
||||
double getPredictedArea(String plotId,BigDecimal plotArea);
|
||||
|
||||
/**
|
||||
* 获取在种地块面积
|
||||
|
||||
@@ -253,13 +253,14 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPredictedArea(String baseId) {
|
||||
public double getPredictedArea(String plotId,BigDecimal plotArea) {
|
||||
|
||||
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
||||
return planList.stream()
|
||||
List<ProductionPlanDO> planList = productionPlanMapper.selectList("plot_id", plotId);
|
||||
double sum = planList.stream()
|
||||
.filter(e -> Objects.equals(e.getPlanStatus(), PLAN_STATUS_2))
|
||||
.mapToDouble(ProductionPlanDO::getPredictedArea)
|
||||
.sum();
|
||||
return plotArea.subtract(BigDecimal.valueOf(sum)).doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,4 +15,17 @@
|
||||
where tenant_id = #{tenantId}
|
||||
and deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="getTotalBaseArea" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
SUM(area) AS total_area
|
||||
FROM
|
||||
farm_base_info
|
||||
<where>
|
||||
deleted = b'0'
|
||||
<if test="id != null and id != ''">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -33,7 +33,12 @@
|
||||
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}
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="baseId != null and baseId != ''">
|
||||
AND base_id = #{baseId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY base_id
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user