Merge remote-tracking branch 'origin/main'

This commit is contained in:
顾君禹
2025-09-01 21:19:21 +08:00
5 changed files with 68 additions and 28 deletions

View File

@@ -18,8 +18,6 @@ import java.util.List;
@NoArgsConstructor
public class HomeInfo {
@Schema(description = "租户信息概述")
private TenantInfo tenantInfo;
@Schema(description = "基地统计信息概述")
private BaseOverviewInfo baseOverviewInfo;
@Schema(description = "基地弹框信息")
@@ -31,22 +29,8 @@ public class HomeInfo {
@Schema(description = "统计信息")
private StatisticalInfo statisticalInfo;
public HomeInfo(TenantInfo tenantInfo) {
this.tenantInfo = tenantInfo;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TenantInfo {
@Schema(description = "基地数量")
private Integer baseCount;
@Schema(description = "总面积")
private Integer cropCount;
@Schema(description = "在种作物数量")
private Double totalArea;
@Schema(description = "在职员工人数")
private Integer personnelCount;
public HomeInfo(BaseOverviewInfo baseOverviewInfo) {
this.baseOverviewInfo = baseOverviewInfo;
}
@Data
@@ -78,9 +62,26 @@ public class HomeInfo {
@Schema(description = "基地坐标")
private String point;
@Schema(description = "在种地块")
private Integer beingPlot;
private String beingPlot;
@Schema(description = "在种作物数量")
private Integer beingCrop;
@Schema(description = "基地数量")
private Integer baseCount;
@Schema(description = "总面积")
private Integer cropCount;
@Schema(description = "在种作物数量")
private Double totalArea;
@Schema(description = "在职员工人数")
private Integer personnelCount;
public BaseOverviewInfo(String baseId, Integer baseCount, Integer cropCount, Double totalArea, Integer personnelCount) {
this.baseId = baseId;
this.baseCount = baseCount;
this.cropCount = cropCount;
this.totalArea = totalArea;
this.personnelCount = personnelCount;
}
}
@Data
@@ -113,6 +114,8 @@ public class HomeInfo {
private String manager;
@Schema(description = "基地坐标")
private String point;
@Schema(description = "基地颜色")
private String plotColor;
@Schema(description = "地块或作物集合")
private PlotOrCropInfo plotOrCropInfo;
}

View File

@@ -57,25 +57,24 @@ public class HomeServiceImpl implements HomeService {
public HomeInfo getHomeInfo(String baseId) {
if (baseId.trim().isEmpty()) {
return new HomeInfo(this.getCompanyInfo());
BaseOverviewInfo baseOverviewInfo = this.getCompanyInfo();
return new HomeInfo(baseOverviewInfo);
}
// 员工集合 <id,name>
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
TenantInfo tenantInfo = this.getCompanyInfo();
BaseOverviewInfo baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
List<PlotPopupFrame> plotPopupFrames = this.getPlotPopupFrame(baseObj, employeeNameMap);
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId, employeeNameMap);
List<PlanInfo> planInfos = this.getPlanInfoList(baseId, "", null);
StatisticalInfo statisticalInfo = this.getStatisticalInfo(baseId);
return new HomeInfo(tenantInfo, baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
return new HomeInfo(baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
}
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);
@@ -85,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());
@@ -93,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;
}
@@ -126,6 +130,7 @@ public class HomeServiceImpl implements HomeService {
t.setPlotArea(e.getPlotArea());
t.setManager(employeeName);
t.setPoint(e.getPoint());
t.setPlotColor(e.getPlotColor());
t.setPlotOrCropInfo(plotOrCropInfo);
targetList.add(t);
}
@@ -216,12 +221,12 @@ public class HomeServiceImpl implements HomeService {
return map;
}
private TenantInfo getCompanyInfo() {
private BaseOverviewInfo getCompanyInfo() {
LoginUser user = getLoginUser();
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数量
Double totalArea = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
return new TenantInfo(baseCount,cropCount,totalArea,personnelCount);
return new BaseOverviewInfo("",baseCount,cropCount,totalArea,personnelCount);
}
}

View File

@@ -146,4 +146,6 @@ public interface ProductionPlanService {
String getPlantSpeciesCodeForName(String plantSpeciesCode);
Integer getTodayTaskCount(String baseId);
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}