Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -18,8 +18,6 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class HomeInfo {
|
public class HomeInfo {
|
||||||
|
|
||||||
@Schema(description = "租户信息概述")
|
|
||||||
private TenantInfo tenantInfo;
|
|
||||||
@Schema(description = "基地统计信息概述")
|
@Schema(description = "基地统计信息概述")
|
||||||
private BaseOverviewInfo baseOverviewInfo;
|
private BaseOverviewInfo baseOverviewInfo;
|
||||||
@Schema(description = "基地弹框信息")
|
@Schema(description = "基地弹框信息")
|
||||||
@@ -31,22 +29,8 @@ public class HomeInfo {
|
|||||||
@Schema(description = "统计信息")
|
@Schema(description = "统计信息")
|
||||||
private StatisticalInfo statisticalInfo;
|
private StatisticalInfo statisticalInfo;
|
||||||
|
|
||||||
public HomeInfo(TenantInfo tenantInfo) {
|
public HomeInfo(BaseOverviewInfo baseOverviewInfo) {
|
||||||
this.tenantInfo = tenantInfo;
|
this.baseOverviewInfo = baseOverviewInfo;
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -78,9 +62,26 @@ public class HomeInfo {
|
|||||||
@Schema(description = "基地坐标")
|
@Schema(description = "基地坐标")
|
||||||
private String point;
|
private String point;
|
||||||
@Schema(description = "在种地块")
|
@Schema(description = "在种地块")
|
||||||
private Integer beingPlot;
|
private String beingPlot;
|
||||||
@Schema(description = "在种作物数量")
|
@Schema(description = "在种作物数量")
|
||||||
private Integer beingCrop;
|
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
|
@Data
|
||||||
@@ -113,6 +114,8 @@ public class HomeInfo {
|
|||||||
private String manager;
|
private String manager;
|
||||||
@Schema(description = "基地坐标")
|
@Schema(description = "基地坐标")
|
||||||
private String point;
|
private String point;
|
||||||
|
@Schema(description = "基地颜色")
|
||||||
|
private String plotColor;
|
||||||
@Schema(description = "地块或作物集合")
|
@Schema(description = "地块或作物集合")
|
||||||
private PlotOrCropInfo plotOrCropInfo;
|
private PlotOrCropInfo plotOrCropInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,25 +57,24 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
public HomeInfo getHomeInfo(String baseId) {
|
public HomeInfo getHomeInfo(String baseId) {
|
||||||
|
|
||||||
if (baseId.trim().isEmpty()) {
|
if (baseId.trim().isEmpty()) {
|
||||||
return new HomeInfo(this.getCompanyInfo());
|
BaseOverviewInfo baseOverviewInfo = this.getCompanyInfo();
|
||||||
|
return new HomeInfo(baseOverviewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 员工集合 <id,name>
|
// 员工集合 <id,name>
|
||||||
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
|
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
|
||||||
|
|
||||||
|
|
||||||
TenantInfo tenantInfo = this.getCompanyInfo();
|
|
||||||
BaseOverviewInfo baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
|
BaseOverviewInfo baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
|
||||||
List<PlotPopupFrame> plotPopupFrames = this.getPlotPopupFrame(baseObj, employeeNameMap);
|
List<PlotPopupFrame> plotPopupFrames = this.getPlotPopupFrame(baseObj, employeeNameMap);
|
||||||
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId, employeeNameMap);
|
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId, employeeNameMap);
|
||||||
List<PlanInfo> planInfos = this.getPlanInfoList(baseId, "", null);
|
List<PlanInfo> planInfos = this.getPlanInfoList(baseId, "", null);
|
||||||
StatisticalInfo statisticalInfo = this.getStatisticalInfo(baseId);
|
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) {
|
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 warningCount = 0; // TODO: 2025/9/1 告警数量
|
||||||
Integer iotCount = 0; // TODO: 2025/9/1 物联设备数量
|
Integer iotCount = 0; // TODO: 2025/9/1 物联设备数量
|
||||||
return new StatisticalInfo(taskCount,warningCount,iotCount);
|
return new StatisticalInfo(taskCount,warningCount,iotCount);
|
||||||
@@ -85,6 +84,11 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
String employeeName= personnelManagementService.getEmployeeNameMap(employeeNameMap,baseObj.getManager());
|
String employeeName= personnelManagementService.getEmployeeNameMap(employeeNameMap,baseObj.getManager());
|
||||||
int growingPlotCount = productionPlanService.getGrowingPlotCount(baseObj.getId());
|
int growingPlotCount = productionPlanService.getGrowingPlotCount(baseObj.getId());
|
||||||
int growingCropCount = productionPlanService.getGrowingCropCount(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();
|
BaseOverviewInfo res = new BaseOverviewInfo();
|
||||||
res.setBaseId(baseObj.getId());
|
res.setBaseId(baseObj.getId());
|
||||||
@@ -93,7 +97,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
res.setManager(employeeName);
|
res.setManager(employeeName);
|
||||||
res.setPoint(baseObj.getPoint());
|
res.setPoint(baseObj.getPoint());
|
||||||
res.setPointName(""); // TODO: 2025/8/31 需要前端传入,才能获取
|
res.setPointName(""); // TODO: 2025/8/31 需要前端传入,才能获取
|
||||||
res.setBeingPlot(growingPlotCount);
|
res.setBeingPlot(plotRatio);
|
||||||
res.setBeingCrop(growingCropCount);
|
res.setBeingCrop(growingCropCount);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -126,6 +130,7 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
t.setPlotArea(e.getPlotArea());
|
t.setPlotArea(e.getPlotArea());
|
||||||
t.setManager(employeeName);
|
t.setManager(employeeName);
|
||||||
t.setPoint(e.getPoint());
|
t.setPoint(e.getPoint());
|
||||||
|
t.setPlotColor(e.getPlotColor());
|
||||||
t.setPlotOrCropInfo(plotOrCropInfo);
|
t.setPlotOrCropInfo(plotOrCropInfo);
|
||||||
targetList.add(t);
|
targetList.add(t);
|
||||||
}
|
}
|
||||||
@@ -216,12 +221,12 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TenantInfo getCompanyInfo() {
|
private BaseOverviewInfo getCompanyInfo() {
|
||||||
LoginUser user = getLoginUser();
|
LoginUser user = getLoginUser();
|
||||||
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
|
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
|
||||||
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数量
|
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数量
|
||||||
Double totalArea = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
|
Double totalArea = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
|
||||||
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
|
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
|
||||||
return new TenantInfo(baseCount,cropCount,totalArea,personnelCount);
|
return new BaseOverviewInfo("",baseCount,cropCount,totalArea,personnelCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,4 +146,6 @@ public interface ProductionPlanService {
|
|||||||
|
|
||||||
String getPlantSpeciesCodeForName(String plantSpeciesCode);
|
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.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
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.dal.mysql.specieslibrary.SpeciesLibraryMapper;
|
||||||
|
import cn.iocoder.yudao.module.farm.utils.DateUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -212,6 +213,8 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGrowingPlotCount(String baseId) {
|
public int getGrowingPlotCount(String baseId) {
|
||||||
|
|
||||||
|
|
||||||
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
||||||
long count = planList.stream().filter(e -> Objects.equals(e.getPlanStatus(), PLAN_STATUS_2)).count();
|
long count = planList.stream().filter(e -> Objects.equals(e.getPlanStatus(), PLAN_STATUS_2)).count();
|
||||||
return (int) count;
|
return (int) count;
|
||||||
@@ -307,5 +310,15 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
return cultivarNameMap.getOrDefault(plantSpeciesCode,"");
|
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