fix (farm): 农场首页

- 修改请求入参方式
- 删除弃用的接口
This commit is contained in:
达富斌
2025-09-01 16:35:19 +08:00
parent e1b50dcfac
commit 8b589b8e76
3 changed files with 39 additions and 26 deletions

View File

@@ -31,30 +31,18 @@ public class HomeController {
@Resource
private HomeService homeService;
@Parameter(name = "baseId", description = "基地ID", required = true)
@Operation(summary = "农场首页")
@GetMapping("/{baseId}")
public CommonResult<HomeInfo> getBaseInfo(@PathVariable("baseId") String baseId) {
@GetMapping("")
@Parameter(name = "baseId", description = "基地ID")
public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
return success(homeService.getHomeInfo(baseId));
}
@Parameter(name = "baseId", description = "基地ID", required = true)
@Operation(summary = "农场首页-概要信息")
@GetMapping("/outlined/{baseId}")
public CommonResult<OutlinedInfoVO> getWeatherInfo(@PathVariable("baseId") String baseId) {
return success(homeService.getOutlinedInfo(baseId));
}
@Operation(summary = "农场首页-基地名称列表")
@GetMapping("/baseNames")
public CommonResult<List<BaseNameVO>> getBaseNameList() {
return success(homeService.getBaseNameList());
}
@Operation(summary = "农场首页-公司基地及种植")
@GetMapping("/companyBaseFarming")
public CommonResult<Object> getCompanyBaseFarming() {
return success(homeService.getCompanyBaseFarming());
}
}

View File

@@ -18,6 +18,8 @@ import java.util.List;
@NoArgsConstructor
public class HomeInfo {
@Schema(description = "租户信息概述")
private TenantInfo tenantInfo;
@Schema(description = "基地统计信息概述")
private BaseOverviewInfo baseOverviewInfo;
@Schema(description = "基地弹框信息")
@@ -29,8 +31,22 @@ public class HomeInfo {
@Schema(description = "统计信息")
private StatisticalInfo statisticalInfo;
public HomeInfo(BaseOverviewInfo baseOverviewInfo) {
this.baseOverviewInfo = baseOverviewInfo;
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;
}
@Data

View File

@@ -16,7 +16,6 @@ import cn.iocoder.yudao.module.farm.service.personnelmanagement.PersonnelManagem
import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -57,21 +56,22 @@ public class HomeServiceImpl implements HomeService {
@Override
public HomeInfo getHomeInfo(String baseId) {
if (StringUtils.isEmpty(baseId)) {
BaseOverviewInfo baseOverviewInfo = new BaseOverviewInfo();
return new HomeInfo(baseOverviewInfo);
if (baseId.trim().isEmpty()) {
return new HomeInfo(this.getCompanyInfo());
}
// 员工集合 <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);
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId, employeeNameMap);
List<PlanInfo> planInfos = this.getPlanInfoList(baseId, "", null);
StatisticalInfo statisticalInfo = this.getStatisticalInfo(baseId);
return new HomeInfo(baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
return new HomeInfo(tenantInfo, baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
}
private StatisticalInfo getStatisticalInfo(String baseId) {
@@ -132,7 +132,7 @@ public class HomeServiceImpl implements HomeService {
return targetList;
}
private PlotOrCropInfo getPlotOrCropInfoList(PlotInfoDO e ,String label,String employeeName) {
private PlotOrCropInfo getPlotOrCropInfoList(PlotInfoDO e, String label, String employeeName) {
Double predictedArea = productionPlanService.getBeingPlotArea(e.getPlotId());
if (ObjectUtils.isEmpty(predictedArea)) {
predictedArea = 0.00;
@@ -152,7 +152,7 @@ public class HomeServiceImpl implements HomeService {
t.setLotCount(0); // TODO: 2025/8/31 物联设备数量
t.setManager(employeeName);
t.setQrCodeUrl(""); // TODO: 2025/8/31 暂无
t.setPlanInfos(this.getPlanInfoList(e.getBaseId(),e.getPlotId(),employeeName));
t.setPlanInfos(this.getPlanInfoList(e.getBaseId(), e.getPlotId(), employeeName));
return t;
}
@@ -215,4 +215,13 @@ public class HomeServiceImpl implements HomeService {
map.put("personnelCount", personnelCount);
return map;
}
private TenantInfo 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);
}
}