fix (farm): 农场首页
- 修改请求入参方式 - 删除弃用的接口
This commit is contained in:
@@ -31,30 +31,18 @@ public class HomeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private HomeService homeService;
|
private HomeService homeService;
|
||||||
|
|
||||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
|
||||||
@Operation(summary = "农场首页")
|
@Operation(summary = "农场首页")
|
||||||
@GetMapping("/{baseId}")
|
@GetMapping("")
|
||||||
public CommonResult<HomeInfo> getBaseInfo(@PathVariable("baseId") String baseId) {
|
@Parameter(name = "baseId", description = "基地ID")
|
||||||
|
public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
|
||||||
return success(homeService.getHomeInfo(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 = "农场首页-基地名称列表")
|
@Operation(summary = "农场首页-基地名称列表")
|
||||||
@GetMapping("/baseNames")
|
@GetMapping("/baseNames")
|
||||||
public CommonResult<List<BaseNameVO>> getBaseNameList() {
|
public CommonResult<List<BaseNameVO>> getBaseNameList() {
|
||||||
return success(homeService.getBaseNameList());
|
return success(homeService.getBaseNameList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "农场首页-公司基地及种植")
|
|
||||||
@GetMapping("/companyBaseFarming")
|
|
||||||
public CommonResult<Object> getCompanyBaseFarming() {
|
|
||||||
return success(homeService.getCompanyBaseFarming());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ 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 = "基地弹框信息")
|
||||||
@@ -29,8 +31,22 @@ public class HomeInfo {
|
|||||||
@Schema(description = "统计信息")
|
@Schema(description = "统计信息")
|
||||||
private StatisticalInfo statisticalInfo;
|
private StatisticalInfo statisticalInfo;
|
||||||
|
|
||||||
public HomeInfo(BaseOverviewInfo baseOverviewInfo) {
|
public HomeInfo(TenantInfo tenantInfo) {
|
||||||
this.baseOverviewInfo = baseOverviewInfo;
|
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
|
@Data
|
||||||
|
|||||||
@@ -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.plotinfo.PlotInfoService;
|
||||||
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -57,21 +56,22 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
@Override
|
@Override
|
||||||
public HomeInfo getHomeInfo(String baseId) {
|
public HomeInfo getHomeInfo(String baseId) {
|
||||||
|
|
||||||
if (StringUtils.isEmpty(baseId)) {
|
if (baseId.trim().isEmpty()) {
|
||||||
BaseOverviewInfo baseOverviewInfo = new BaseOverviewInfo();
|
return new HomeInfo(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(baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
|
return new HomeInfo(tenantInfo, baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StatisticalInfo getStatisticalInfo(String baseId) {
|
private StatisticalInfo getStatisticalInfo(String baseId) {
|
||||||
@@ -215,4 +215,13 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
map.put("personnelCount", personnelCount);
|
map.put("personnelCount", personnelCount);
|
||||||
return map;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user