fix (farm): 农场首页
- 获取今日任务数接口
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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<PlotInfoDO> 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;
|
||||
}
|
||||
|
||||
@@ -146,4 +146,6 @@ public interface ProductionPlanService {
|
||||
|
||||
String getPlantSpeciesCodeForName(String plantSpeciesCode);
|
||||
|
||||
Integer getTodayTaskCount(String baseId);
|
||||
|
||||
}
|
||||
@@ -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<ProductionPlanDO> 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<ProductionPlanDO> planDOList = productionPlanMapper.selectList();
|
||||
int count = 0;
|
||||
for (ProductionPlanDO e : planDOList) {
|
||||
if (DateUtils.isTodayInRange(e.getProductionStartDate(),e.getProductionEndDate())) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user