diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/home/vo/HomeInfo.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/home/vo/HomeInfo.java index 6d0baecc..5b3dc75e 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/home/vo/HomeInfo.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/home/vo/HomeInfo.java @@ -62,7 +62,7 @@ public class HomeInfo { @Schema(description = "基地坐标") private String point; @Schema(description = "在种地块") - private Integer beingPlot; + private String beingPlot; @Schema(description = "在种作物数量") private Integer beingCrop; diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/home/HomeServiceImpl.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/home/HomeServiceImpl.java index e91023f2..cc96da80 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/home/HomeServiceImpl.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/home/HomeServiceImpl.java @@ -74,7 +74,7 @@ public class HomeServiceImpl implements HomeService { } private StatisticalInfo getStatisticalInfo(String baseId) { - Integer taskCount = 0; // TODO: 2025/9/1 今日任务数量 + Integer taskCount = productionPlanService.getTodayTaskCount(baseId); Integer warningCount = 0; // TODO: 2025/9/1 告警数量 Integer iotCount = 0; // TODO: 2025/9/1 物联设备数量 return new StatisticalInfo(taskCount,warningCount,iotCount); @@ -84,6 +84,11 @@ public class HomeServiceImpl implements HomeService { String employeeName= personnelManagementService.getEmployeeNameMap(employeeNameMap,baseObj.getManager()); int growingPlotCount = productionPlanService.getGrowingPlotCount(baseObj.getId()); int growingCropCount = productionPlanService.getGrowingCropCount(baseObj.getId()); + List plotInfos = plotInfoService.getPlotInfos(baseObj.getId()); + String plotRatio = "0/0"; + if (!ObjectUtils.isEmpty(plotInfos)) { + plotRatio = growingPlotCount + "/" + plotInfos.size(); + } BaseOverviewInfo res = new BaseOverviewInfo(); res.setBaseId(baseObj.getId()); @@ -92,7 +97,7 @@ public class HomeServiceImpl implements HomeService { res.setManager(employeeName); res.setPoint(baseObj.getPoint()); res.setPointName(""); // TODO: 2025/8/31 需要前端传入,才能获取 - res.setBeingPlot(growingPlotCount); + res.setBeingPlot(plotRatio); res.setBeingCrop(growingCropCount); return res; } diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanService.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanService.java index 54f551c8..f778f963 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanService.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanService.java @@ -146,4 +146,6 @@ public interface ProductionPlanService { String getPlantSpeciesCodeForName(String plantSpeciesCode); + Integer getTodayTaskCount(String baseId); + } \ No newline at end of file diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanServiceImpl.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanServiceImpl.java index 5f67e93c..25e17a17 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanServiceImpl.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/productionplan/ProductionPlanServiceImpl.java @@ -8,6 +8,7 @@ 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.dal.dataobject.specieslibrary.SpeciesLibraryDO; import cn.iocoder.yudao.module.farm.dal.mysql.specieslibrary.SpeciesLibraryMapper; +import cn.iocoder.yudao.module.farm.utils.DateUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; @@ -212,6 +213,8 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { @Override public int getGrowingPlotCount(String baseId) { + + List planList = productionPlanMapper.selectList("base_id", baseId); long count = planList.stream().filter(e -> Objects.equals(e.getPlanStatus(), PLAN_STATUS_2)).count(); return (int) count; @@ -307,5 +310,15 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { return cultivarNameMap.getOrDefault(plantSpeciesCode,""); } - + @Override + public Integer getTodayTaskCount(String baseId) { + List planDOList = productionPlanMapper.selectList(); + int count = 0; + for (ProductionPlanDO e : planDOList) { + if (DateUtils.isTodayInRange(e.getProductionStartDate(),e.getProductionEndDate())) { + count++; + } + } + return count; + } } \ No newline at end of file diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/utils/DateUtils.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/utils/DateUtils.java new file mode 100644 index 00000000..59d0d87f --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/utils/DateUtils.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.farm.utils; + +import java.time.LocalDate; + +/** + * @description: + * @author: binda + * @date: 2025/9/1 20:29 + */ +public class DateUtils { + + public static boolean isTodayInRange(LocalDate startDate, LocalDate endDate) { + LocalDate today = LocalDate.now(); + return !today.isBefore(startDate) && !today.isAfter(endDate); + } + +}