From 91c375f039e39d98bbcf8e38c9dbb9992e1b7670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=BE=E5=AF=8C=E6=96=8C?= Date: Sat, 27 Sep 2025 15:34:33 +0800 Subject: [PATCH] =?UTF-8?q?feat=20(farm):=20=E5=88=A0=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81=20(=E8=A1=A5=E5=85=85=E6=8F=90?= =?UTF-8?q?=E4=BA=A4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 数字驾驶舱-告警/预警统计 --- .../controller/admin/api/ApiController.java | 12 +++---- .../DigitalCockpitController.java | 32 +++++++++++++++++-- .../digitalcockpit/vo/PlanSpeciesRespVO.java | 27 ++++++++++++++++ .../service/TokenCacheService.java | 2 ++ .../ModelManagementService.java | 2 ++ .../ModelManagementServiceImpl.java | 17 ++++++++++ 6 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/vo/PlanSpeciesRespVO.java diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/api/ApiController.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/api/ApiController.java index 7c7484c5..c791b2b7 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/api/ApiController.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/api/ApiController.java @@ -123,12 +123,6 @@ public class ApiController { return productionPlanService.getPlantingPlanCompletionChart(req); } - @PostMapping("/digital-cockpit/chart/disaster-statistics") - @Operation(summary = "数字驾驶舱-灾害统计-灾害分析") - public CommonResult> getDisasterStatisticsChart(@Valid @RequestBody DisasterAnalysisReqVO req) { - return screenDisasterDataService.getDisasterStatisticsChart(req); // TODO: 2025/9/4 未实现 - } - @PostMapping("/digital-cockpit/chart/farming-distribution") @Operation(summary = "数字驾驶舱-灾害统计-农事分布") public CommonResult getFarmingDistributionChart(@Valid @RequestBody FarmingDistributionReqVO req) { @@ -147,6 +141,12 @@ public class ApiController { return deviceInfoService.getDeviceMonitoring(req);// TODO: 2025/9/25 } + @PostMapping("/digital-cockpit/chart/disaster-statistics") + @Operation(summary = "数字驾驶舱-灾害统计-灾害分析") + public CommonResult> getDisasterStatisticsChart(@Valid @RequestBody DisasterAnalysisReqVO req) { + return screenDisasterDataService.getDisasterStatisticsChart(req); // TODO: 2025/9/4 未实现 + } + @PostMapping("/digital-cockpit/chart/warning-message") @Operation(summary = "数字驾驶舱-告警/预警统计") public CommonResult getMessageWarning(@Valid WarningMessageReqVO req) { diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/DigitalCockpitController.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/DigitalCockpitController.java index e72a6d27..f9c3fc70 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/DigitalCockpitController.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/DigitalCockpitController.java @@ -5,16 +5,20 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.*; import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO; import cn.iocoder.yudao.module.farm.dal.dataobject.companyinfo.CompanyInfoDO; +import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManagementDO; import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO; import cn.iocoder.yudao.module.farm.service.baseinfo.BaseInfoService; import cn.iocoder.yudao.module.farm.service.companyinfo.CompanyInfoService; import cn.iocoder.yudao.module.farm.service.deviceinfo.DeviceInfoService; import cn.iocoder.yudao.module.farm.service.farmingrecord.FarmingRecordService; +import cn.iocoder.yudao.module.farm.service.modelcycle.ModelCycleService; +import cn.iocoder.yudao.module.farm.service.modelmanagement.ModelManagementService; import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService; import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -22,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; @@ -42,14 +47,16 @@ public class DigitalCockpitController { private final DeviceInfoService deviceInfoService; private final ProductionPlanService productionPlanService; private final FarmingRecordService farmingRecordService; + private final ModelManagementService modelManagementService; - public DigitalCockpitController(BaseInfoService baseInfoService, PlotInfoService plotInfoService, CompanyInfoService companyInfoService, DeviceInfoService deviceInfoService, ProductionPlanService productionPlanService, FarmingRecordService farmingRecordService) { + public DigitalCockpitController(BaseInfoService baseInfoService, PlotInfoService plotInfoService, CompanyInfoService companyInfoService, DeviceInfoService deviceInfoService, ProductionPlanService productionPlanService, FarmingRecordService farmingRecordService, ModelManagementService modelManagementService) { this.baseInfoService = baseInfoService; this.plotInfoService = plotInfoService; this.companyInfoService = companyInfoService; this.deviceInfoService = deviceInfoService; this.productionPlanService = productionPlanService; this.farmingRecordService = farmingRecordService; + this.modelManagementService = modelManagementService; } @GetMapping("/company-info") @@ -119,6 +126,7 @@ public class DigitalCockpitController { @Parameter(name = "year", description = "查询条件: 年份", required = true) public CommonResult> getCropStatisticsInfo(@RequestParam("baseId") String baseId, @RequestParam("year") String year) { + // TODO: 2025/9/24 待实现 List res = new ArrayList<>(); res.add(new CropStatisticsRespVO("香菜",1000,1200)); return success(res); @@ -130,7 +138,7 @@ public class DigitalCockpitController { @Parameter(name = "year", description = "查询条件: 年份", required = true) public CommonResult> getYieldStatisticsInfo(@RequestParam("baseId") String baseId, @RequestParam("year") String year) { - + // TODO: 2025/9/24 待实现 List res = new ArrayList<>(); res.add(new YieldStatisticsRespVO("香菜",10000,16000)); return success(res); @@ -143,6 +151,7 @@ public class DigitalCockpitController { public CommonResult> getActualYieldStatisticsInfo(@RequestParam("baseId") String baseId, @RequestParam("year") String year) { + // TODO: 2025/9/24 待实现 List res = new ArrayList<>(); res.add(new ActualYieldStatisticsRespVO("香菜",10000,10001)); return success(res); @@ -152,6 +161,7 @@ public class DigitalCockpitController { @Operation(summary = "农事分布") @Parameter(name = "baseId", description = "基地ID", required = true) public CommonResult getFarmRecords(@RequestParam("baseId") String baseId) { + // TODO: 2025/9/24 待实现 FarmRecordsRespVO res = new FarmRecordsRespVO(); res.setTotalCount(0); res.setOverdueStatusCount(0); @@ -172,6 +182,7 @@ public class DigitalCockpitController { @Operation(summary = "设备统计") @Parameter(name = "baseId", description = "基地ID", required = true) public CommonResult getDeviceInfo(@RequestParam("baseId") String baseId) { + // TODO: 2025/9/24 待实现 DeviceInfoRespVO res = new DeviceInfoRespVO(); res.setTotal(17); res.setDeviceInfos( @@ -190,4 +201,21 @@ public class DigitalCockpitController { return success("暂时不做"); } + @GetMapping("/species/get") + @Operation(summary = "引用次数最多的模型物种信息") + @Parameter(name = "baseId", description = "基地ID", required = true) + public CommonResult getPlanSpeciesInfo(@RequestParam("baseId") String baseId) { + + ModelManagementDO mObj = modelManagementService.getTopQuoteCount(); + if (ObjectUtils.isEmpty(mObj)) { + return error(500,"还未创建模型"); + } + PlanSpeciesRespVO res = new PlanSpeciesRespVO(); + res.setImage(mObj.getSpeciesImage()); + res.setName(mObj.getSpeciesName()); + res.setCycleName(mObj.getCycleName()); + res.setDesc(mObj.getDescription()); + return success(res); + } + } diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/vo/PlanSpeciesRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/vo/PlanSpeciesRespVO.java new file mode 100644 index 00000000..5e22ca57 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/digitalcockpit/vo/PlanSpeciesRespVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 计划引用最多的物种 + * @author: binda + * @date: 2025/9/27 15:02 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PlanSpeciesRespVO { + + @Schema(description = "物种图片") + private String image; + @Schema(description = "物种分类名称") + private String name; + @Schema(description = "物种描述") + private String desc; + @Schema(description = "物种生命周期") + private String cycleName; + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/manager/equipmentproducer/service/TokenCacheService.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/manager/equipmentproducer/service/TokenCacheService.java index e33bed6a..528bb306 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/manager/equipmentproducer/service/TokenCacheService.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/manager/equipmentproducer/service/TokenCacheService.java @@ -19,6 +19,8 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j public abstract class TokenCacheService { + // 水肥机: token两个小时 + // 土壤: 一分钟最多采集6次数据,其他没限制 public final Map tokenCacheMap = new ConcurrentHashMap<>(); private final Map> deviceCacheMap = new ConcurrentHashMap<>(); diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementService.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementService.java index 13169b09..7c657a66 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementService.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementService.java @@ -104,4 +104,6 @@ public interface ModelManagementService { * @return */ int getFarmRecordCount(String speciesModelId); + + ModelManagementDO getTopQuoteCount(); } \ No newline at end of file diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementServiceImpl.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementServiceImpl.java index ce1f9dd5..009b1d63 100644 --- a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementServiceImpl.java +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/modelmanagement/ModelManagementServiceImpl.java @@ -600,6 +600,23 @@ public class ModelManagementServiceImpl implements ModelManagementService { return (int) count; } + @Override + public ModelManagementDO getTopQuoteCount() { + LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX<>(); + wrapperX.eq(ModelManagementDO::getTenantId, getLoginUser().getTenantId()); + List mList = modelManagementMapper.selectList(wrapperX); + + if (mList == null || mList.isEmpty()) { + return null; + } + + // 使用Stream找到quoteCount最大的记录 + Optional mostQuoted = mList.stream() + .max(Comparator.comparingInt(ModelManagementDO::getQuoteCount)); + + return mostQuoted.orElse(null); + } + private List getModelCycleListByModelId(String modelId) { LambdaQueryWrapperX wrapperXx = new LambdaQueryWrapperX<>(); wrapperXx.eq(ModelCycleDO::getModelId, modelId);