feat (farm): 基地规划

- 计算地块占比
This commit is contained in:
达富斌
2025-08-27 18:16:33 +08:00
parent 87c2b48bd3
commit 62309578d6
2 changed files with 14 additions and 7 deletions

View File

@@ -62,8 +62,10 @@ public class BaseInfoRespVO {
private Integer cropCount; private Integer cropCount;
@Schema(description = "在种地块数量") @Schema(description = "在种地块数量")
private Integer plotCount; private Integer plotCount;
@Schema(description = "地块总数")
private Integer plotTotalCount;
@Schema(description = "在种地块占比") @Schema(description = "在种地块占比")
private Integer plotRatio; private Double plotRatio;
} }
@Data @Data

View File

@@ -181,19 +181,24 @@ public class BaseInfoServiceImpl implements BaseInfoService {
String baseId = obj.getId(); String baseId = obj.getId();
String baseName = obj.getName(); String baseName = obj.getName();
BigDecimal baseArea = obj.getArea(); BigDecimal baseArea = obj.getArea();
List<PlotInfoDO> plotList = plotInfoMapper.selectList("base_id", baseId);
// 在种作物数量 // 在种作物数量
Integer cropCount = speciesLibraryMapper.getSpeciesCount(tenantId,baseId);; Integer cropCount = speciesLibraryMapper.getSpeciesCount(tenantId,baseId);
// 在种地块数量
Integer plotCount = 0; // todo
// 在种地块占比 // 在种地块占比
Integer plotRatio = 0; // todo double plotRatio = 0.00;
// 在种地块数量
int plotCount = 1;
// 地块总数
int plotTotalCount = plotList.size();
if (plotTotalCount > 0) {
plotRatio = Math.round((plotCount * 10000.0) / plotTotalCount) / 100.0;
}
obj.setBaseOverview(new BaseInfoRespVO.BaseInfo(baseId,baseName,baseArea,cropCount,plotCount,plotRatio)); obj.setBaseOverview(new BaseInfoRespVO.BaseInfo(baseId,baseName,baseArea,cropCount,plotCount,plotTotalCount,plotRatio));
// 地块集合 // 地块集合
List<BaseInfoRespVO.PlotInfo> targetList = new ArrayList<>(); List<BaseInfoRespVO.PlotInfo> targetList = new ArrayList<>();
List<PlotInfoDO> plotList = plotInfoMapper.selectList("base_id", baseId);
for (PlotInfoDO aDo : plotList) { for (PlotInfoDO aDo : plotList) {
String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统"); String plotManager = employeeMap.getOrDefault(aDo.getEmployeeId(), "系统");
BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(aDo.getPlotId(), aDo.getPlotName(), aDo.getPlotArea(), plotManager); BaseInfoRespVO.PlotInfo target = new BaseInfoRespVO.PlotInfo(aDo.getPlotId(), aDo.getPlotName(), aDo.getPlotArea(), plotManager);