Przeglądaj źródła

地块管理的基础功能,设备监控管理除查看按钮的基础功能,传感器和气象设备的定时任务。

zmj 11 miesięcy temu
rodzic
commit
9d7217840b
60 zmienionych plików z 4687 dodań i 2 usunięć
  1. 10 0
      pom.xml
  2. 1 0
      ruoyi-api/pom.xml
  3. 42 0
      ruoyi-api/ruoyi-api-base/pom.xml
  4. 69 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/RemoteBaseService.java
  5. 26 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/SensorDataStatistics.java
  6. 65 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/SensorRealtimeData.java
  7. 81 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/WeatherDataStatistics.java
  8. 100 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/WeatherRealtimeData.java
  9. 54 0
      ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/factory/RemoteBaerFallbackFactory.java
  10. 2 0
      ruoyi-api/ruoyi-api-base/src/main/resources/META-INF/spring.factories
  11. 1 0
      ruoyi-auth/src/main/resources/bootstrap.yml
  12. 8 0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java
  13. 6 0
      ruoyi-common/ruoyi-common-sensitive/pom.xml
  14. 1 0
      ruoyi-gateway/src/main/resources/bootstrap.yml
  15. 1 0
      ruoyi-modules/pom.xml
  16. 114 0
      ruoyi-modules/ruoyi-base/pom.xml
  17. 32 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/RuoYiBaseApplication.java
  18. 108 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/DeviceController.java
  19. 201 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/FieldController.java
  20. 129 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/SensorRealtimeDataController.java
  21. 124 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/WeatherRealtimeDataController.java
  22. 107 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/Device.java
  23. 132 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/Field.java
  24. 126 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/FieldDevice.java
  25. 171 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/FieldPersonnel.java
  26. 25 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/SensorDataStatistics.java
  27. 57 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/SensorRealtimeData.java
  28. 81 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/WeatherDataStatistics.java
  29. 97 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/WeatherRealtimeData.java
  30. 96 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/DeviceMapper.java
  31. 64 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldDeviceMapper.java
  32. 67 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldMapper.java
  33. 63 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldPersonnelMapper.java
  34. 82 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/SensorRealtimeDataMapper.java
  35. 73 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/WeatherRealtimeDataMapper.java
  36. 64 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IDeviceService.java
  37. 63 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IFieldPersonnelService.java
  38. 135 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IFieldService.java
  39. 82 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/ISensorRealtimeDataService.java
  40. 73 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IWeatherRealtimeDataService.java
  41. 98 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/DeviceServiceImpl.java
  42. 97 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/FieldPersonnelServiceImpl.java
  43. 198 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/FieldServiceImpl.java
  44. 123 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/SensorRealtimeDataServiceImpl.java
  45. 104 0
      ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/WeatherRealtimeDataServiceImpl.java
  46. 2 0
      ruoyi-modules/ruoyi-base/src/main/resources/banner.txt
  47. 30 0
      ruoyi-modules/ruoyi-base/src/main/resources/bootstrap.yml
  48. 74 0
      ruoyi-modules/ruoyi-base/src/main/resources/logback.xml
  49. 207 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/DeviceMapper.xml
  50. 96 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldDeviceMapper.xml
  51. 172 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldMapper.xml
  52. 103 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldPersonnelMapper.xml
  53. 127 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/SensorRealtimeDataMapper.xml
  54. 178 0
      ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/WeatherRealtimeDataMapper.xml
  55. 7 1
      ruoyi-modules/ruoyi-job/pom.xml
  56. 229 0
      ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/DeviceStatisticsData.java
  57. 1 0
      ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
  58. 6 0
      ruoyi-modules/ruoyi-system/pom.xml
  59. 1 0
      ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
  60. 1 1
      ruoyi-modules/ruoyi-system/src/main/resources/logback.xml

+ 10 - 0
pom.xml

@@ -253,6 +253,16 @@
                 <version>${ruoyi.version}</version>
             </dependency>
 
+
+
+            <!-- 基础接口 -->
+            <dependency>
+                <groupId>com.ruoyi</groupId>
+                <artifactId>ruoyi-api-base</artifactId>
+                <version>${ruoyi.version}</version>
+            </dependency>
+
+
         </dependencies>
     </dependencyManagement>
 

+ 1 - 0
ruoyi-api/pom.xml

@@ -10,6 +10,7 @@
 
     <modules>
         <module>ruoyi-api-system</module>
+        <module>ruoyi-api-base</module>
     </modules>
 
     <artifactId>ruoyi-api</artifactId>

+ 42 - 0
ruoyi-api/ruoyi-api-base/pom.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ruoyi-api</artifactId>
+        <groupId>com.ruoyi</groupId>
+        <version>3.6.5</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>ruoyi-api-base</artifactId>
+
+
+    <description>
+        ruoyi-api-base系统接口模块
+    </description>
+
+
+    <dependencies>
+
+        <!-- RuoYi Common Core-->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-common-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-api-system</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+
+</project>

+ 69 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/RemoteBaseService.java

@@ -0,0 +1,69 @@
+package com.ruoyi.base.api;
+
+
+import com.ruoyi.base.api.domain.SensorDataStatistics;
+import com.ruoyi.base.api.domain.SensorRealtimeData;
+import com.ruoyi.base.api.domain.WeatherDataStatistics;
+import com.ruoyi.base.api.domain.WeatherRealtimeData;
+import com.ruoyi.base.api.factory.RemoteBaerFallbackFactory;
+import com.ruoyi.common.core.constant.SecurityConstants;
+import com.ruoyi.common.core.constant.ServiceNameConstants;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+
+/**
+ * 基础服务
+ *
+ * @author ruoyi
+ */
+@FeignClient(contextId = "remoteBaseService", value = ServiceNameConstants.BASE_SERVICE, fallbackFactory = RemoteBaerFallbackFactory.class)
+public interface RemoteBaseService {
+
+
+    /**
+     *  查询传感器实时数据
+     * @param sensorRealtimeData 传感器实时数据对象
+     * @param source 请求来源
+     * @return
+     */
+    @PostMapping("/sensor/listSensor")
+    public AjaxResult listSensor(@RequestBody SensorRealtimeData sensorRealtimeData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+
+    /**
+     *
+     * @param weatherRealtimeData 气象站实时数据对象
+     * @param source 请求来源
+     * @return
+     */
+    @PostMapping("/weather/listWeather")
+    public AjaxResult listWeather(@RequestBody WeatherRealtimeData weatherRealtimeData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+
+
+    /**
+     *  新增传感器统计信息
+     * @param sensorDataStatistics 传感器实时数据对象
+     * @param source 请求来源
+     * @return
+     */
+    @PostMapping("/sensor/addSensorStatistics")
+    public AjaxResult addSensorStatistics(@RequestBody SensorDataStatistics sensorDataStatistics, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+
+
+    /**
+     *  新增气象设备统计信息
+     * @param weatherRealtimeData 气象设备实时数据对象
+     * @param source 请求来源
+     * @return
+     */
+    @PostMapping("/weather/addWeatherStatistics")
+    public AjaxResult addWeatherStatistics(@RequestBody WeatherDataStatistics weatherRealtimeData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+
+}

+ 26 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/SensorDataStatistics.java

@@ -0,0 +1,26 @@
+package com.ruoyi.base.api.domain;
+
+
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SensorDataStatistics extends BaseEntity
+{
+    private String deviceId;
+    private LocalDate date;
+    private BigDecimal maxTemperature;
+    private BigDecimal minTemperature;
+    private double avgHumidity;
+    private double avgLightIntensity;
+    private double avgSoilMoisture;
+
+}

+ 65 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/SensorRealtimeData.java

@@ -0,0 +1,65 @@
+package com.ruoyi.base.api.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 传感器实时数据对象 sensor_realtime_data
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SensorRealtimeData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 设备id */
+    @Excel(name = "设备id")
+    private String deviceId;
+
+    /** 温度值(°C) */
+    @Excel(name = "温度值(°C)")
+    private BigDecimal temperature;
+
+    /** 湿度值(%) */
+    @Excel(name = "湿度值(%)")
+    private BigDecimal humidity;
+
+    /** 光照强度(lux) */
+    @Excel(name = "光照强度(lux)")
+    private BigDecimal lightIntensity;
+
+    /** 土壤湿度(%) */
+    @Excel(name = "土壤湿度(%)")
+    private BigDecimal soilMoisture;
+
+    /** 采集时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date collectTime;
+
+
+    private LocalDateTime beginCollectTime;
+
+    private LocalDateTime endCollectTime;
+
+
+
+
+
+
+}

+ 81 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/WeatherDataStatistics.java

@@ -0,0 +1,81 @@
+package com.ruoyi.base.api.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 气象设备数据统计对象 weather_data_statistics
+ *
+ * @author ruoyi
+ * @date 2025-06-19
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class WeatherDataStatistics extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /** ID 主键 */
+    private Long id;
+
+    /** 数据统计日期(前一天) */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "数据统计日期(前一天)", width = 30, dateFormat = "yyyy-MM-dd")
+    private LocalDate date;
+
+    /** 气象设备编号 */
+    @Excel(name = "气象设备编号")
+    private String deviceId;
+
+    /** 最高温度(单位:摄氏度) */
+    @Excel(name = "最高温度(单位:摄氏度)")
+    private BigDecimal maxTemperature;
+
+    /** 最低温度(单位:摄氏度) */
+    @Excel(name = "最低温度(单位:摄氏度)")
+    private BigDecimal minTemperature;
+
+    /** 平均湿度(单位:%) */
+    @Excel(name = "平均湿度(单位:%)")
+    private BigDecimal avgHumidity;
+
+    /** 平均降雨量(单位:毫米) */
+    @Excel(name = "平均降雨量(单位:毫米)")
+    private BigDecimal avgRainfall;
+
+    /** 平均风速(单位:米/秒) */
+    @Excel(name = "平均风速(单位:米/秒)")
+    private BigDecimal avgWindSpeed;
+
+    /** 平均土壤温度 */
+    @Excel(name = "平均土壤温度")
+    private BigDecimal avgSoilTemperature;
+
+    /** 平均土壤水分 */
+    @Excel(name = "平均土壤水分")
+    private BigDecimal avgSoilHumidity;
+
+    /** 平均土壤氮 */
+    @Excel(name = "平均土壤氮")
+    private BigDecimal avgSoilN;
+
+    /** 平均土壤磷 */
+    @Excel(name = "平均土壤磷")
+    private BigDecimal avgSoilP;
+
+    /** 平均土壤钾 */
+    @Excel(name = "平均土壤钾")
+    private BigDecimal avgSoilK;
+
+    /** 累积降雨量 */
+    @Excel(name = "累积降雨量")
+    private BigDecimal dateRainfallA;
+}

+ 100 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/domain/WeatherRealtimeData.java

@@ -0,0 +1,100 @@
+package com.ruoyi.base.api.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 气象站实时数据对象 weather_realtime_data
+ * 
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WeatherRealtimeData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /**  */
+    private Long id;
+
+    /** 设备编号 */
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    /** 气温(°C) */
+    @Excel(name = "气温(°C)")
+    private BigDecimal temperature;
+
+    /** 湿度(%) */
+    @Excel(name = "湿度(%)")
+    private BigDecimal humidity;
+
+    /** 降雨量(mm) */
+    @Excel(name = "降雨量(mm)")
+    private BigDecimal rainfall;
+
+    /** 风向 */
+    @Excel(name = "风向")
+    private String windDirection;
+
+    /** 风速(m/s) */
+    @Excel(name = "风速(m/s)")
+    private BigDecimal windSpeed;
+
+    /** 气压(hPa) */
+    @Excel(name = "气压(hPa)")
+    private BigDecimal airPressure;
+
+    /** 光照强度(lux) */
+    @Excel(name = "光照强度(lux)")
+    private BigDecimal lightIntensity;
+
+    /** 采集时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date collectTime;
+
+    /** 土壤温度 */
+    @Excel(name = "土壤温度")
+    private BigDecimal soilTemperature;
+
+    /** 土壤水分 */
+    @Excel(name = "土壤水分")
+    private BigDecimal soilHumidity;
+
+    /** 土壤氮 */
+    @Excel(name = "土壤氮")
+    private BigDecimal soilN;
+
+    /** 土壤磷 */
+    @Excel(name = "土壤磷")
+    private BigDecimal soilP;
+
+    /** 土壤钾 */
+    @Excel(name = "土壤钾")
+    private BigDecimal soilK;
+
+    /** 累积降雨量mm 初始化开始累积 不要使用 */
+    @Excel(name = "累积降雨量mm 初始化开始累积 不要使用")
+    private BigDecimal rainfallA;
+
+
+    private LocalDateTime beginWeatherTime;
+
+    private LocalDateTime endWeatherTime;
+
+
+
+}

+ 54 - 0
ruoyi-api/ruoyi-api-base/src/main/java/com/ruoyi/base/api/factory/RemoteBaerFallbackFactory.java

@@ -0,0 +1,54 @@
+package com.ruoyi.base.api.factory;
+
+
+
+import com.ruoyi.base.api.RemoteBaseService;
+import com.ruoyi.base.api.domain.SensorDataStatistics;
+import com.ruoyi.base.api.domain.SensorRealtimeData;
+import com.ruoyi.base.api.domain.WeatherDataStatistics;
+import com.ruoyi.base.api.domain.WeatherRealtimeData;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class RemoteBaerFallbackFactory implements FallbackFactory<RemoteBaseService>{
+
+
+    private static final Logger log = LoggerFactory.getLogger(RemoteBaerFallbackFactory.class);
+
+    @Override
+    public RemoteBaseService create(Throwable throwable) {
+        log.error("基础服务调用失败:{}", throwable.getMessage());
+        return new RemoteBaseService()
+        {
+
+            @Override
+            public AjaxResult listSensor(SensorRealtimeData sensorRealtimeData, String source) {
+                return AjaxResult.error("查询传感器实时数据失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public AjaxResult listWeather(WeatherRealtimeData weatherRealtimeData, String source) {
+                return AjaxResult.error("查询气象站实时数据失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public AjaxResult addSensorStatistics(SensorDataStatistics sensorDataStatistics, String source) {
+                return AjaxResult.error("新增传感器统计数据失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public AjaxResult addWeatherStatistics(WeatherDataStatistics weatherRealtimeData, String source) {
+                return AjaxResult.error("新增气象设备统计数据失败:" + throwable.getMessage());
+            }
+
+
+        };
+    }
+}

+ 2 - 0
ruoyi-api/ruoyi-api-base/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  com.ruoyi.base.api.factory.RemoteBaerFallbackFactory

+ 1 - 0
ruoyi-auth/src/main/resources/bootstrap.yml

@@ -17,6 +17,7 @@ spring:
         server-addr: 121.4.16.100:8848
         username: nacos
         password: nacos369
+        namespace: dev
       config:
         username: nacos
         password: nacos369

+ 8 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java

@@ -21,4 +21,12 @@ public class ServiceNameConstants
      * 文件服务的serviceid
      */
     public static final String FILE_SERVICE = "ruoyi-file";
+
+
+
+    /**
+     * 基础服务的serviceid
+     */
+    public static final String BASE_SERVICE = "ruoyi-base";
+
 }

+ 6 - 0
ruoyi-common/ruoyi-common-sensitive/pom.xml

@@ -23,5 +23,11 @@
             <artifactId>ruoyi-common-core</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-api-base</artifactId>
+        </dependency>
+
+
     </dependencies>
 </project>

+ 1 - 0
ruoyi-gateway/src/main/resources/bootstrap.yml

@@ -17,6 +17,7 @@ spring:
         server-addr: 121.4.16.100:8848
         username: nacos
         password: nacos369
+        namespace: dev
       config:
         username: nacos
         password: nacos369

+ 1 - 0
ruoyi-modules/pom.xml

@@ -15,6 +15,7 @@
         <module>ruoyi-file</module>
         <module>ruoyi-uniapp</module>
         <module>ruoyi-qxsb</module>
+        <module>ruoyi-base</module>
     </modules>
 
     <artifactId>ruoyi-modules</artifactId>

+ 114 - 0
ruoyi-modules/ruoyi-base/pom.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ruoyi-modules</artifactId>
+        <groupId>com.ruoyi</groupId>
+        <version>3.6.5</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>ruoyi-base</artifactId>
+
+    <description>
+        ruoyi-base模块
+    </description>
+
+    <dependencies>
+
+        <!-- SpringCloud Alibaba Nacos -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+
+        <!-- SpringCloud Alibaba Nacos Config -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+
+        <!-- SpringCloud Alibaba Sentinel -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
+        </dependency>
+
+        <!-- SpringBoot Actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+
+        <!-- Mysql Connector -->
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common DataSource -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-common-datasource</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common DataScope -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-common-datascope</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common Log -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-common-log</artifactId>
+        </dependency>
+
+        <!-- RuoYi Common Swagger -->
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-common-swagger</artifactId>
+        </dependency>
+        <!-- Hutool工具包 -->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>${hutool.version}</version>
+        </dependency>
+
+        <!--Lombok-->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <classifier>exec</classifier>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 32 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/RuoYiBaseApplication.java

@@ -0,0 +1,32 @@
+package com.ruoyi.base;
+
+import com.ruoyi.common.security.annotation.EnableCustomConfig;
+import com.ruoyi.common.security.annotation.EnableRyFeignClients;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 基础模块
+ * 
+ * @author
+ */
+@EnableCustomConfig
+@EnableRyFeignClients
+@SpringBootApplication
+public class RuoYiBaseApplication
+{
+    public static void main(String[] args)
+    {
+        SpringApplication.run(RuoYiBaseApplication.class, args);
+        System.out.println("(♥◠‿◠)ノ゙  基础模块启动成功   ლ(´ڡ`ლ)゙  \n" +
+                " .-------.       ____     __        \n" +
+                " |  _ _   \\      \\   \\   /  /    \n" +
+                " | ( ' )  |       \\  _. /  '       \n" +
+                " |(_ o _) /        _( )_ .'         \n" +
+                " | (_,_).' __  ___(_ o _)'          \n" +
+                " |  |\\ \\  |  ||   |(_,_)'         \n" +
+                " |  | \\ `'   /|   `-'  /           \n" +
+                " |  |  \\    /  \\      /           \n" +
+                " ''-'   `'-'    `-..-'              ");
+    }
+}

+ 108 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/DeviceController.java

@@ -0,0 +1,108 @@
+package com.ruoyi.base.controller;
+
+import com.ruoyi.base.domain.Device;
+import com.ruoyi.base.service.IDeviceService;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.redis.service.RedisService;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 设备Controller
+ * 
+ * @author zmj
+ * @date 2025-05-29
+ */
+@RestController
+@RequestMapping("/device")
+public class DeviceController extends BaseController
+{
+    @Autowired
+    private IDeviceService deviceService;
+
+
+    @Autowired
+    private RedisService redisService;
+
+    /**
+     * 查询设备列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(Device device)
+    {
+        startPage();
+        List<Device> list = deviceService.selectDeviceList(device);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出设备列表
+     */
+    @RequiresPermissions("system:device:export")
+    @Log(title = "设备", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Device device)
+    {
+        List<Device> list = deviceService.selectDeviceList(device);
+        ExcelUtil<Device> util = new ExcelUtil<Device>(Device.class);
+        util.exportExcel(response, list, "设备数据");
+    }
+
+    /**
+     * 获取设备详细信息
+     */
+    @RequiresPermissions("system:device:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(deviceService.selectDeviceById(id));
+    }
+
+
+
+
+
+    /**
+     * 新增设备
+     */
+    @RequiresPermissions("system:device:add")
+    @Log(title = "设备", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Device device)
+    {
+        return toAjax(deviceService.insertDevice(device));
+    }
+
+    /**
+     * 修改设备
+     */
+    @RequiresPermissions("system:device:edit")
+    @Log(title = "设备", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Device device)
+    {
+        return toAjax(deviceService.updateDevice(device));
+    }
+
+    /**
+     * 删除设备
+     */
+    @RequiresPermissions("system:device:remove")
+    @Log(title = "设备", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(deviceService.deleteDeviceByIds(ids));
+    }
+
+
+}

+ 201 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/FieldController.java

@@ -0,0 +1,201 @@
+package com.ruoyi.base.controller;
+
+import com.ruoyi.base.domain.Field;
+import com.ruoyi.base.service.IFieldService;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 地块信息Controller
+ * 
+ * @author ruoyi
+ * @date 2025-05-20
+ */
+@RestController
+@RequestMapping("/field")
+public class FieldController extends BaseController
+{
+    @Autowired
+    private IFieldService fieldService;
+
+    /**
+     * 查询地块信息列表
+     */
+    @RequiresPermissions("system:field:list")
+    @GetMapping("/list")
+    public TableDataInfo list(Field field)
+    {
+        startPage();
+        List<Field> list = fieldService.selectFieldList(field);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询车辆供应商名称列表
+     */
+    /*@RequiresPermissions(value = {"base:supplier:list","base:contract:list","base:mounted:list"},logical = Logical.OR)*/
+    @GetMapping("/listName")
+    public List<Field> listName(Field field)
+    {
+        List<Field> list = fieldService.selectFieldList(field);
+        return list;
+    }
+
+    /**
+     * 导出地块信息列表
+     */
+    @RequiresPermissions("system:field:export")
+    @Log(title = "地块信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Field field)
+    {
+        List<Field> list = fieldService.selectFieldList(field);
+        ExcelUtil<Field> util = new ExcelUtil<Field>(Field.class);
+        util.exportExcel(response, list, "地块信息数据");
+    }
+
+    /**
+     * 获取地块信息详细信息
+     */
+    @RequiresPermissions("system:field:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(fieldService.selectFieldById(id));
+    }
+
+
+    /**
+     * 获取地块设备详细信息绑定
+     */
+    //@RequiresPermissions("system:field:query")
+    @GetMapping(value = "/device/{id}")
+    public AjaxResult getDeviceInfo(@PathVariable("id") Long id)
+    {
+        return success(fieldService.selectDeviceById(id));
+    }
+
+
+    /**
+     * 获取地块设备详细信息未绑定
+     */
+    //@RequiresPermissions("system:field:query")
+    @GetMapping(value = "/unDevice/{id}")
+    public AjaxResult getUnDeviceInfo(@PathVariable("id") Long id)
+    {
+        return success(fieldService.selectDeviceUnById(id));
+    }
+
+    /**
+     * 获取地块人员详细信息未绑定
+     */
+    @GetMapping(value = "/unUser/{id}")
+    public AjaxResult getUnUserInfo(@PathVariable("id") Long id)
+    {
+        return success(fieldService.selectUserUnById(id));
+    }
+
+
+    /**
+     * 获取地块人员详细信息
+     */
+    //@RequiresPermissions("system:field:query")
+    @GetMapping(value = "/person/{id}")
+    public AjaxResult getpersonInfo(@PathVariable("id") Long id)
+    {
+        return success(fieldService.selectUserById(id));
+    }
+
+    /**
+     * 新增地块信息
+     */
+    @RequiresPermissions("system:field:add")
+    @Log(title = "地块信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Field field)
+    {
+        field.setCreatedBy(SecurityUtils.getUsername());
+        return toAjax(fieldService.insertField(field));
+    }
+
+    /**
+     * 修改地块信息
+     */
+    @RequiresPermissions("system:field:edit")
+    @Log(title = "地块信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Field field)
+    {
+        return toAjax(fieldService.updateField(field));
+    }
+
+    /**
+     * 删除地块信息
+     */
+    @RequiresPermissions("system:field:remove")
+    @Log(title = "地块信息", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(fieldService.deleteFieldByIds(ids));
+    }
+
+    /**
+     * 绑定地块设备信息
+     */
+   /* @RequiresPermissions("system:field:remove")
+    @Log(title = "地块信息", businessType = BusinessType.DELETE)*/
+    @PutMapping("/bindFieldDevice/{ids}")
+    public AjaxResult bindFieldDevice(@PathVariable Long[] ids)
+    {
+        return toAjax(fieldService.bindFieldDevice(ids));
+    }
+
+
+    /**
+     * 解绑地块设备信息
+     */
+    /*@RequiresPermissions("system:field:remove")
+    @Log(title = "地块信息", businessType = BusinessType.DELETE)*/
+    @PutMapping("/unbindFieldDevice/{ids}")
+    public AjaxResult unbindFieldDevice(@PathVariable Long[] ids)
+    {
+        return toAjax(fieldService.unbindFieldDevice(ids));
+    }
+
+
+
+    /**
+     * 绑定地块人员信息
+     */
+   /* @RequiresPermissions("system:field:remove")
+    @Log(title = "地块信息", businessType = BusinessType.DELETE)*/
+    @PutMapping("/bindFieldPerson/{ids}")
+    public AjaxResult bindFieldPerson(@PathVariable Long[] ids)
+    {
+        return toAjax(fieldService.bindFieldUser(ids));
+    }
+
+
+    /**
+     * 解绑地块人员信息
+     */
+    /*@RequiresPermissions("system:field:remove")
+    @Log(title = "地块信息", businessType = BusinessType.DELETE)*/
+    @PutMapping("/unbindFieldPerson/{ids}")
+    public AjaxResult unbindFieldPerson(@PathVariable Long[] ids)
+    {
+        return toAjax(fieldService.unbindFieldUser(ids));
+    }
+}

+ 129 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/SensorRealtimeDataController.java

@@ -0,0 +1,129 @@
+package com.ruoyi.base.controller;
+
+import com.ruoyi.base.domain.SensorDataStatistics;
+import com.ruoyi.base.domain.SensorRealtimeData;
+import com.ruoyi.base.service.ISensorRealtimeDataService;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 传感器实时数据Controller
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+@RestController
+@RequestMapping("/sensor")
+public class SensorRealtimeDataController extends BaseController
+{
+    @Autowired
+    private ISensorRealtimeDataService sensorRealtimeDataService;
+
+    /**
+     * 查询传感器实时数据列表
+     */
+    @RequiresPermissions("base:data:list")
+    @GetMapping("/list")
+    public TableDataInfo list(SensorRealtimeData sensorRealtimeData)
+    {
+        startPage();
+        List<SensorRealtimeData> list = sensorRealtimeDataService.selectSensorRealtimeDataList(sensorRealtimeData);
+        return getDataTable(list);
+    }
+
+
+    @PostMapping("/listSensor")
+    public AjaxResult listSensor(@RequestBody SensorRealtimeData sensorRealtimeData)
+    {
+        List<SensorRealtimeData> list = sensorRealtimeDataService.selectSensorRealtimeDataList(sensorRealtimeData);
+        return success(list);
+    }
+
+    /**
+     * 导出传感器实时数据列表
+     */
+    @RequiresPermissions("base:data:export")
+    @Log(title = "传感器实时数据", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SensorRealtimeData sensorRealtimeData)
+    {
+        List<SensorRealtimeData> list = sensorRealtimeDataService.selectSensorRealtimeDataList(sensorRealtimeData);
+        ExcelUtil<SensorRealtimeData> util = new ExcelUtil<SensorRealtimeData>(SensorRealtimeData.class);
+        util.exportExcel(response, list, "传感器实时数据数据");
+    }
+
+    /**
+     * 获取传感器实时数据详细信息
+     */
+    @RequiresPermissions("base:data:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(sensorRealtimeDataService.selectSensorRealtimeDataById(id));
+    }
+
+
+    /**
+     * 获取传感器实时数据详细信息
+     */
+    @GetMapping(value = "/LatestTime/{deviceId}")
+    public AjaxResult getInfoLatestTime(String deviceId)
+    {
+        return success(sensorRealtimeDataService.selectSensorRealtimeDataLatestTimeById(deviceId));
+    }
+
+    /**
+     * 新增传感器实时数据
+     */
+    @RequiresPermissions("base:data:add")
+    @Log(title = "传感器实时数据", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SensorRealtimeData sensorRealtimeData)
+    {
+        return toAjax(sensorRealtimeDataService.insertSensorRealtimeData(sensorRealtimeData));
+    }
+
+
+    /**
+     * 新增传感器统计数据
+     */
+   /* @RequiresPermissions("base:data:add")
+    @Log(title = "传感器实时数据", businessType = BusinessType.INSERT)*/
+    @PostMapping("/addSensorStatistics")
+    public AjaxResult addSensorStatistics(@RequestBody SensorDataStatistics sensorDataStatistics)
+    {
+        return toAjax(sensorRealtimeDataService.insertSensorStatistics(sensorDataStatistics));
+    }
+
+    /**
+     * 修改传感器实时数据
+     */
+    @RequiresPermissions("base:data:edit")
+    @Log(title = "传感器实时数据", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SensorRealtimeData sensorRealtimeData)
+    {
+        return toAjax(sensorRealtimeDataService.updateSensorRealtimeData(sensorRealtimeData));
+    }
+
+    /**
+     * 删除传感器实时数据
+     */
+    @RequiresPermissions("base:data:remove")
+    @Log(title = "传感器实时数据", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(sensorRealtimeDataService.deleteSensorRealtimeDataByIds(ids));
+    }
+}

+ 124 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/WeatherRealtimeDataController.java

@@ -0,0 +1,124 @@
+package com.ruoyi.base.controller;
+
+import com.ruoyi.base.domain.WeatherDataStatistics;
+import com.ruoyi.base.domain.WeatherRealtimeData;
+import com.ruoyi.base.service.IWeatherRealtimeDataService;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 气象站实时数据Controller
+ * 
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+@RestController
+@RequestMapping("/weather")
+public class WeatherRealtimeDataController extends BaseController
+{
+    @Autowired
+    private IWeatherRealtimeDataService weatherRealtimeDataService;
+
+    /**
+     * 查询气象站实时数据列表
+     */
+    @RequiresPermissions("base:weather:list")
+    @GetMapping("/list")
+    public TableDataInfo list(WeatherRealtimeData weatherRealtimeData)
+    {
+        startPage();
+        List<WeatherRealtimeData> list = weatherRealtimeDataService.selectWeatherRealtimeDataList(weatherRealtimeData);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 查询气象站实时数据列表
+     */
+    @PostMapping("/listWeather")
+    public AjaxResult listWeather(@RequestBody WeatherRealtimeData weatherRealtimeData)
+    {
+
+        List<WeatherRealtimeData> list = weatherRealtimeDataService.selectWeatherRealtimeDataList(weatherRealtimeData);
+        return success(list);
+    }
+
+
+
+    /**
+     * 导出气象站实时数据列表
+     */
+    @RequiresPermissions("base:weather:export")
+    @Log(title = "气象站实时数据", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, WeatherRealtimeData weatherRealtimeData)
+    {
+        List<WeatherRealtimeData> list = weatherRealtimeDataService.selectWeatherRealtimeDataList(weatherRealtimeData);
+        ExcelUtil<WeatherRealtimeData> util = new ExcelUtil<WeatherRealtimeData>(WeatherRealtimeData.class);
+        util.exportExcel(response, list, "气象站实时数据数据");
+    }
+
+    /**
+     * 获取气象站实时数据详细信息
+     */
+    @RequiresPermissions("base:weather:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(weatherRealtimeDataService.selectWeatherRealtimeDataById(id));
+    }
+
+    /**
+     * 新增气象站实时数据
+     */
+    @RequiresPermissions("base:weather:add")
+    @Log(title = "气象站实时数据", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody WeatherRealtimeData weatherRealtimeData)
+    {
+        return toAjax(weatherRealtimeDataService.insertWeatherRealtimeData(weatherRealtimeData));
+    }
+
+
+
+    /**
+     * 新增气象站统计数据
+     */
+    @PostMapping("/addWeatherStatistics")
+    public AjaxResult addWeatherStatistics(@RequestBody WeatherDataStatistics weatherRealtimeData)
+    {
+        return toAjax(weatherRealtimeDataService.insertWeatherStatistics(weatherRealtimeData));
+    }
+
+    /**
+     * 修改气象站实时数据
+     */
+    @RequiresPermissions("base:weather:edit")
+    @Log(title = "气象站实时数据", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody WeatherRealtimeData weatherRealtimeData)
+    {
+        return toAjax(weatherRealtimeDataService.updateWeatherRealtimeData(weatherRealtimeData));
+    }
+
+    /**
+     * 删除气象站实时数据
+     */
+    @RequiresPermissions("base:weather:remove")
+    @Log(title = "气象站实时数据", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(weatherRealtimeDataService.deleteWeatherRealtimeDataByIds(ids));
+    }
+}

+ 107 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/Device.java

@@ -0,0 +1,107 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.annotation.Excels;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import com.ruoyi.system.api.domain.SysDept;
+import com.ruoyi.system.api.domain.SysRole;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 设备对象 device
+ * 
+ * @author zmj
+ * @date 2025-05-22
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Device extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    private Long id;
+
+    /** 设备编号 */
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    /** 设备名称 */
+    @Excel(name = "设备名称")
+    private String deviceName;
+
+    /** 设备类型(1-传感器,2-摄像头,3-控制器,4-气象设备) */
+    @Excel(name = "设备类型", readConverterExp = "1=-传感器,2-摄像头,3-控制器,4-气象设备")
+    private String deviceTypeId;
+
+    /** 所属农场ID */
+    @Excel(name = "所属农场ID")
+    private String farmId;
+
+    /** 设备型号 */
+    @Excel(name = "设备型号")
+    private String model;
+
+    /** GPS经度 */
+    private BigDecimal longitude;
+
+    /** GPS纬度 */
+    private BigDecimal latitude;
+
+    /** 厂家 */
+    @Excel(name = "厂家")
+    private String manufacturer;
+
+    /** 安装日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "安装日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date installDate;
+
+    /** 状态: 0-离线, 1-在线, 2-故障, 3-维护中 */
+    @Excel(name = "状态: 0-离线, 1-在线, 2-故障, 3-维护中")
+    private Long status;
+
+    /** 最后活动时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "最后活动时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date lastActiveTime;
+
+
+    private Long bindStatus;
+
+    /** 绑定时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date bindTime;
+
+
+    /** 所属地块 */
+    private String fieldName;
+
+
+
+    /** 部门对象 */
+    @Excels({
+            @Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
+            @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
+    })
+    private SysDept dept;
+
+    /** 角色对象 */
+    private List<SysRole> roles;
+
+    /** 所属机构id集合-查询条件 */
+    private List<String> deptIdList;
+
+    /** 所属机构id集合-查询条件 */
+    private List<String> fieldIdList;
+
+
+}

+ 132 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/Field.java

@@ -0,0 +1,132 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.annotation.Excels;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import com.ruoyi.system.api.domain.SysDept;
+import com.ruoyi.system.api.domain.SysRole;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 地块信息对象 field
+ * 
+ * @author ruoyi
+ * @date 2025-05-20
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Field extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 地块编号 */
+    @Excel(name = "地块编号")
+    private String fieldCode;
+
+    /** 地块名称 */
+    @Excel(name = "地块名称")
+    private String fieldName;
+
+    /** 所属农场ID */
+    @Excel(name = "所属农场ID")
+    private Long farmId;
+
+    /** 地块类型 */
+    @Excel(name = "地块类型")
+    private String fieldType;
+
+    /** 种植作物(字典) */
+    @Excel(name = "种植作物(字典)")
+    private String growCrops;
+
+    /** 面积(亩) */
+    @Excel(name = "面积(亩)")
+    private BigDecimal size;
+
+    /** 土壤类型 */
+    @Excel(name = "土壤类型")
+    private String soilType;
+
+    /** 灌溉方式 */
+    @Excel(name = "灌溉方式")
+    private String irrigationType;
+
+    /** 使用状态 */
+    @Excel(name = "使用状态")
+    private String status;
+
+    /** 负责人ID */
+    @Excel(name = "负责人ID")
+    private Long managerId;
+
+
+    /** 负责人名字 */
+    @Excel(name = "负责人名字")
+    private String managerName;
+
+    /** 绑定设备 */
+    private Long bindDeviceCount;
+
+    /** 绑定人员 */
+    private Long bindUserCount;
+
+    /** 地块描述 */
+    @Excel(name = "地块描述")
+    private String description;
+
+    /** 地理位置数据(GeoJSON格式) */
+    @Excel(name = "地理位置数据(GeoJSON格式)")
+    private String locationData;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date createdTime;
+
+    /** 更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date updatedTime;
+
+    /** 创建人ID */
+    @Excel(name = "创建人")
+    private String createdBy;
+
+    /** 更新人ID */
+    @Excel(name = "更新人")
+    private String updatedBy;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Integer isDeleted;
+
+    /** 部门对象 */
+    @Excels({
+            @Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
+            @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
+    })
+    private SysDept dept;
+
+    /** 角色对象 */
+    private List<SysRole> roles;
+
+    /** 所属机构id集合-查询条件 */
+    private List<String> deptIdList;
+
+
+
+
+
+
+}

+ 126 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/FieldDevice.java

@@ -0,0 +1,126 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+/**
+ * 地块设备绑定对象 field_device
+ *
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class FieldDevice extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 地块ID */
+    @Excel(name = "地块ID")
+    private Long fieldId;
+
+    /** 设备ID */
+    @Excel(name = "设备ID")
+    private Long deviceId;
+
+    /** 绑定时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "绑定时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date bindingTime;
+
+    /** 绑定状态(0-生效中,1-已解绑) */
+    @Excel(name = "绑定状态(0-生效中,1-已解绑)")
+    private String status;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Integer isDeleted;
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    public Long getId()
+    {
+        return id;
+    }
+
+    public void setFieldId(Long fieldId)
+    {
+        this.fieldId = fieldId;
+    }
+
+    public Long getFieldId()
+    {
+        return fieldId;
+    }
+
+    public void setDeviceId(Long deviceId)
+    {
+        this.deviceId = deviceId;
+    }
+
+    public Long getDeviceId()
+    {
+        return deviceId;
+    }
+
+    public void setBindingTime(Date bindingTime)
+    {
+        this.bindingTime = bindingTime;
+    }
+
+    public Date getBindingTime()
+    {
+        return bindingTime;
+    }
+
+    public void setStatus(String status)
+    {
+        this.status = status;
+    }
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    public void setIsDeleted(Integer isDeleted)
+    {
+        this.isDeleted = isDeleted;
+    }
+
+    public Integer getIsDeleted()
+    {
+        return isDeleted;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("fieldId", getFieldId())
+                .append("deviceId", getDeviceId())
+                .append("bindingTime", getBindingTime())
+                .append("status", getStatus())
+                .append("createTime", getCreateTime())
+                .append("updateTime", getUpdateTime())
+                .append("createBy", getCreateBy())
+                .append("updateBy", getUpdateBy())
+                .append("isDeleted", getIsDeleted())
+                .toString();
+    }
+}

+ 171 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/FieldPersonnel.java

@@ -0,0 +1,171 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
+
+/**
+ * 地块人员绑定对象 field_personnel
+ * 
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+@Data
+public class FieldPersonnel extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 地块ID */
+    @Excel(name = "地块ID")
+    private Long fieldId;
+
+    /** 人员ID */
+    @Excel(name = "人员ID")
+    private Long userId;
+
+    /** 角色类型(0-负责人,1-工作人员) */
+    @Excel(name = "角色类型(0-负责人,1-工作人员)")
+    private String roleType;
+
+    /** 绑定时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "绑定时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date bindingTime;
+
+    /** 绑定状态(0-生效中,1-已解绑) */
+    @Excel(name = "绑定状态(0-生效中,1-已解绑)")
+    private String status;
+
+    /** 创建人 */
+    @Excel(name = "创建人")
+    private String createdBy;
+
+    /** 更新人 */
+    @Excel(name = "更新人")
+    private String updatedBy;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Integer isDeleted;
+
+
+    private String userName;
+    private String postName;
+    private String phonenumber;
+
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+
+    public void setFieldId(Long fieldId) 
+    {
+        this.fieldId = fieldId;
+    }
+
+    public Long getFieldId() 
+    {
+        return fieldId;
+    }
+
+    public void setUserId(Long userId) 
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId() 
+    {
+        return userId;
+    }
+
+    public void setRoleType(String roleType) 
+    {
+        this.roleType = roleType;
+    }
+
+    public String getRoleType() 
+    {
+        return roleType;
+    }
+
+    public void setBindingTime(Date bindingTime) 
+    {
+        this.bindingTime = bindingTime;
+    }
+
+    public Date getBindingTime() 
+    {
+        return bindingTime;
+    }
+
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+
+    public void setCreatedBy(String createdBy) 
+    {
+        this.createdBy = createdBy;
+    }
+
+    public String getCreatedBy() 
+    {
+        return createdBy;
+    }
+
+    public void setUpdatedBy(String updatedBy) 
+    {
+        this.updatedBy = updatedBy;
+    }
+
+    public String getUpdatedBy() 
+    {
+        return updatedBy;
+    }
+
+    public void setIsDeleted(Integer isDeleted) 
+    {
+        this.isDeleted = isDeleted;
+    }
+
+    public Integer getIsDeleted() 
+    {
+        return isDeleted;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("fieldId", getFieldId())
+            .append("userId", getUserId())
+            .append("roleType", getRoleType())
+            .append("bindingTime", getBindingTime())
+            .append("status", getStatus())
+            .append("createTime", getCreateTime())
+            .append("updateTime", getUpdateTime())
+            .append("createdBy", getCreatedBy())
+            .append("updatedBy", getUpdatedBy())
+            .append("isDeleted", getIsDeleted())
+            .toString();
+    }
+}

+ 25 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/SensorDataStatistics.java

@@ -0,0 +1,25 @@
+package com.ruoyi.base.domain;
+
+
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SensorDataStatistics extends BaseEntity
+{
+    private String deviceId;
+    private LocalDate date;
+    private BigDecimal maxTemperature;
+    private BigDecimal minTemperature;
+    private double avgHumidity;
+    private double avgLightIntensity;
+    private double avgSoilMoisture;
+
+}

+ 57 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/SensorRealtimeData.java

@@ -0,0 +1,57 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 传感器实时数据对象 sensor_realtime_data
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class SensorRealtimeData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long id;
+
+    /** 设备id */
+    @Excel(name = "设备id")
+    private String deviceId;
+
+    /** 温度值(°C) */
+    @Excel(name = "温度值(°C)")
+    private BigDecimal temperature;
+
+    /** 湿度值(%) */
+    @Excel(name = "湿度值(%)")
+    private BigDecimal humidity;
+
+    /** 光照强度(lux) */
+    @Excel(name = "光照强度(lux)")
+    private BigDecimal lightIntensity;
+
+    /** 土壤湿度(%) */
+    @Excel(name = "土壤湿度(%)")
+    private BigDecimal soilMoisture;
+
+    /** 采集时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date collectTime;
+    private Date beginCollectTime;
+    private Date endCollectTime;
+
+
+}

+ 81 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/WeatherDataStatistics.java

@@ -0,0 +1,81 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/**
+ * 气象设备数据统计对象 weather_data_statistics
+ *
+ * @author ruoyi
+ * @date 2025-06-19
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class WeatherDataStatistics extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /** ID 主键 */
+    private Long id;
+
+    /** 数据统计日期(前一天) */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "数据统计日期(前一天)", width = 30, dateFormat = "yyyy-MM-dd")
+    private LocalDate date;
+
+    /** 气象设备编号 */
+    @Excel(name = "气象设备编号")
+    private String deviceId;
+
+    /** 最高温度(单位:摄氏度) */
+    @Excel(name = "最高温度(单位:摄氏度)")
+    private BigDecimal maxTemperature;
+
+    /** 最低温度(单位:摄氏度) */
+    @Excel(name = "最低温度(单位:摄氏度)")
+    private BigDecimal minTemperature;
+
+    /** 平均湿度(单位:%) */
+    @Excel(name = "平均湿度(单位:%)")
+    private BigDecimal avgHumidity;
+
+    /** 平均降雨量(单位:毫米) */
+    @Excel(name = "平均降雨量(单位:毫米)")
+    private BigDecimal avgRainfall;
+
+    /** 平均风速(单位:米/秒) */
+    @Excel(name = "平均风速(单位:米/秒)")
+    private BigDecimal avgWindSpeed;
+
+    /** 平均土壤温度 */
+    @Excel(name = "平均土壤温度")
+    private BigDecimal avgSoilTemperature;
+
+    /** 平均土壤水分 */
+    @Excel(name = "平均土壤水分")
+    private BigDecimal avgSoilHumidity;
+
+    /** 平均土壤氮 */
+    @Excel(name = "平均土壤氮")
+    private BigDecimal avgSoilN;
+
+    /** 平均土壤磷 */
+    @Excel(name = "平均土壤磷")
+    private BigDecimal avgSoilP;
+
+    /** 平均土壤钾 */
+    @Excel(name = "平均土壤钾")
+    private BigDecimal avgSoilK;
+
+    /** 累积降雨量 */
+    @Excel(name = "累积降雨量")
+    private BigDecimal dateRainfallA;
+}

+ 97 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/WeatherRealtimeData.java

@@ -0,0 +1,97 @@
+package com.ruoyi.base.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 气象站实时数据对象 weather_realtime_data
+ * 
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WeatherRealtimeData extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /**  */
+    private Long id;
+
+    /** 设备编号 */
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    /** 气温(°C) */
+    @Excel(name = "气温(°C)")
+    private BigDecimal temperature;
+
+    /** 湿度(%) */
+    @Excel(name = "湿度(%)")
+    private BigDecimal humidity;
+
+    /** 降雨量(mm) */
+    @Excel(name = "降雨量(mm)")
+    private BigDecimal rainfall;
+
+    /** 风向 */
+    @Excel(name = "风向")
+    private String windDirection;
+
+    /** 风速(m/s) */
+    @Excel(name = "风速(m/s)")
+    private BigDecimal windSpeed;
+
+    /** 气压(hPa) */
+    @Excel(name = "气压(hPa)")
+    private BigDecimal airPressure;
+
+    /** 光照强度(lux) */
+    @Excel(name = "光照强度(lux)")
+    private BigDecimal lightIntensity;
+
+    /** 采集时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date collectTime;
+
+    /** 土壤温度 */
+    @Excel(name = "土壤温度")
+    private BigDecimal soilTemperature;
+
+    /** 土壤水分 */
+    @Excel(name = "土壤水分")
+    private BigDecimal soilHumidity;
+
+    /** 土壤氮 */
+    @Excel(name = "土壤氮")
+    private BigDecimal soilN;
+
+    /** 土壤磷 */
+    @Excel(name = "土壤磷")
+    private BigDecimal soilP;
+
+    /** 土壤钾 */
+    @Excel(name = "土壤钾")
+    private BigDecimal soilK;
+
+    /** 累积降雨量mm 初始化开始累积 不要使用 */
+    @Excel(name = "累积降雨量mm 初始化开始累积 不要使用")
+    private BigDecimal rainfallA;
+
+    private LocalDateTime beginWeatherTime;
+
+    private LocalDateTime endWeatherTime;
+
+}

+ 96 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/DeviceMapper.java

@@ -0,0 +1,96 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.Device;
+import com.ruoyi.base.domain.FieldPersonnel;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 设备Mapper接口
+ * 
+ * @author zmj
+ * @date 2025-05-22
+ */
+public interface DeviceMapper 
+{
+    /**
+     * 查询设备
+     * 
+     * @param id 设备主键
+     * @return 设备
+     */
+    public Device selectDeviceById(Long id);
+
+
+    /**
+     * 根据地块ID查询设备绑定
+     *
+     * @param id 地块信息主键
+     * @return 设备
+     */
+    public  List<Device> selectDeviceByField(Long id);
+
+    /**
+     * 根据地块ID查询设备解绑
+     *
+     * @param id 地块信息主键
+     * @return 设备
+     */
+    public  List<Device> selectDeviceByunField(Map<String, Object> paramMap);
+
+    /**
+     * 根据地块ID查询用户解绑
+     *
+     * @param id 地块信息主键
+     * @return 设备
+     */
+    public  List<FieldPersonnel> selectDeviceByunUser(Map<String, Object> paramMap);
+
+    /**
+     * 查询设备列表
+     * 
+     * @param device 设备
+     * @return 设备集合
+     */
+    public List<Device> selectDeviceList(Device device);
+
+    /**
+     * 新增设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    public int insertDevice(Device device);
+
+    /**
+     * 修改设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    public int updateDevice(Device device);
+
+    /**
+     * 删除设备
+     * 
+     * @param id 设备主键
+     * @return 结果
+     */
+    public int deleteDeviceById(Long id);
+
+    /**
+     * 批量删除设备
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteDeviceByIds(Long[] ids);
+
+
+    List<FieldPersonnel> selectUserById(Long id);
+
+
+
+}

+ 64 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldDeviceMapper.java

@@ -0,0 +1,64 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.FieldDevice;
+
+import java.util.List;
+
+/**
+ * 地块设备绑定Mapper接口
+ *
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+public interface FieldDeviceMapper
+{
+    /**
+     * 查询地块设备绑定
+     *
+     * @param id 地块设备绑定主键
+     * @return 地块设备绑定
+     */
+    public FieldDevice selectFieldDeviceById(Long id);
+
+    /**
+     * 查询地块设备绑定列表
+     *
+     * @param fieldDevice 地块设备绑定
+     * @return 地块设备绑定集合
+     */
+    public List<FieldDevice> selectFieldDeviceList(FieldDevice fieldDevice);
+
+    /**
+     * 新增地块设备绑定
+     *
+     * @param fieldDevice 地块设备绑定
+     * @return 结果
+     */
+    public int insertFieldDevice(FieldDevice fieldDevice);
+
+    /**
+     * 修改地块设备绑定
+     *
+     * @param fieldDevice 地块设备绑定
+     * @return 结果
+     */
+    public int updateFieldDevice(FieldDevice fieldDevice);
+
+    /**
+     * 删除地块设备绑定
+     *
+     * @param id 地块设备绑定主键
+     * @return 结果
+     */
+    public int deleteFieldDeviceById(Long id);
+
+    /**
+     * 批量删除地块设备绑定
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteFieldDeviceByIds(Long[] ids);
+
+
+}

+ 67 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldMapper.java

@@ -0,0 +1,67 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.Field;
+
+import java.util.List;
+
+
+/**
+ * 地块信息Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-20
+ */
+public interface FieldMapper 
+{
+    /**
+     * 查询地块信息
+     * 
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    public Field selectFieldById(Long id);
+
+
+
+    /**
+     * 查询地块信息列表
+     * 
+     * @param field 地块信息
+     * @return 地块信息集合
+     */
+    public List<Field> selectFieldList(Field field);
+
+    /**
+     * 新增地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    public int insertField(Field field);
+
+    /**
+     * 修改地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    public int updateField(Field field);
+
+    /**
+     * 删除地块信息
+     * 
+     * @param id 地块信息主键
+     * @return 结果
+     */
+    public int deleteFieldById(Long id);
+
+    /**
+     * 批量删除地块信息
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteFieldByIds(Long[] ids);
+
+
+}

+ 63 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/FieldPersonnelMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.FieldPersonnel;
+
+import java.util.List;
+
+
+/**
+ * 地块人员绑定Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+public interface FieldPersonnelMapper 
+{
+    /**
+     * 查询地块人员绑定
+     * 
+     * @param id 地块人员绑定主键
+     * @return 地块人员绑定
+     */
+    public FieldPersonnel selectFieldPersonnelById(Long id);
+
+    /**
+     * 查询地块人员绑定列表
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 地块人员绑定集合
+     */
+    public List<FieldPersonnel> selectFieldPersonnelList(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 新增地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    public int insertFieldPersonnel(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 修改地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    public int updateFieldPersonnel(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 删除地块人员绑定
+     * 
+     * @param id 地块人员绑定主键
+     * @return 结果
+     */
+    public int deleteFieldPersonnelById(Long id);
+
+    /**
+     * 批量删除地块人员绑定
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteFieldPersonnelByIds(Long[] ids);
+}

+ 82 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/SensorRealtimeDataMapper.java

@@ -0,0 +1,82 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.SensorDataStatistics;
+import com.ruoyi.base.domain.SensorRealtimeData;
+
+import java.util.List;
+
+/**
+ * 传感器实时数据Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+public interface SensorRealtimeDataMapper 
+{
+    /**
+     * 查询传感器实时数据
+     * 
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    public SensorRealtimeData selectSensorRealtimeDataById(Long id);
+
+    /**
+     * 查询最新传感器实时数据
+     *
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    SensorRealtimeData selectSensorRealtimeDataLatestTimeById(String deviceId);
+
+    /**
+     * 查询传感器实时数据列表
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 传感器实时数据集合
+     */
+    public List<SensorRealtimeData> selectSensorRealtimeDataList(SensorRealtimeData sensorRealtimeData);
+
+    /**
+     * 新增传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    public int insertSensorRealtimeData(SensorRealtimeData sensorRealtimeData);
+
+
+    /**
+     * 新增传感器统计数据
+     *
+     * @param sensorDataStatistics 传感器统计数据
+     * @return 结果
+     */
+    int insertSensorStatistics(SensorDataStatistics sensorDataStatistics);
+
+    /**
+     * 修改传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    public int updateSensorRealtimeData(SensorRealtimeData sensorRealtimeData);
+
+    /**
+     * 删除传感器实时数据
+     * 
+     * @param id 传感器实时数据主键
+     * @return 结果
+     */
+    public int deleteSensorRealtimeDataById(Long id);
+
+    /**
+     * 批量删除传感器实时数据
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSensorRealtimeDataByIds(Long[] ids);
+
+
+}

+ 73 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/WeatherRealtimeDataMapper.java

@@ -0,0 +1,73 @@
+package com.ruoyi.base.mapper;
+
+import com.ruoyi.base.domain.WeatherDataStatistics;
+import com.ruoyi.base.domain.WeatherRealtimeData;
+
+import java.util.List;
+
+/**
+ * 气象站实时数据Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+public interface WeatherRealtimeDataMapper 
+{
+    /**
+     * 查询气象站实时数据
+     * 
+     * @param id 气象站实时数据主键
+     * @return 气象站实时数据
+     */
+    public WeatherRealtimeData selectWeatherRealtimeDataById(Long id);
+
+    /**
+     * 查询气象站实时数据列表
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 气象站实时数据集合
+     */
+    public List<WeatherRealtimeData> selectWeatherRealtimeDataList(WeatherRealtimeData weatherRealtimeData);
+
+    /**
+     * 新增气象站实时数据
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    public int insertWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData);
+
+
+
+    /**
+     * 新增气象站统计数据
+     *
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    int insertWeatherStatistics(WeatherDataStatistics weatherRealtimeData);
+    /**
+     * 修改气象站实时数据
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    public int updateWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData);
+
+    /**
+     * 删除气象站实时数据
+     * 
+     * @param id 气象站实时数据主键
+     * @return 结果
+     */
+    public int deleteWeatherRealtimeDataById(Long id);
+
+    /**
+     * 批量删除气象站实时数据
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteWeatherRealtimeDataByIds(Long[] ids);
+
+}

+ 64 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IDeviceService.java

@@ -0,0 +1,64 @@
+package com.ruoyi.base.service;
+
+import com.ruoyi.base.domain.Device;
+
+import java.util.List;
+
+/**
+ * 设备Service接口
+ * 
+ * @author zmj
+ * @date 2025-05-29
+ */
+public interface IDeviceService 
+{
+    /**
+     * 查询设备
+     * 
+     * @param id 设备主键
+     * @return 设备
+     */
+    public Device selectDeviceById(Long id);
+
+
+
+    /**
+     * 查询设备列表
+     * 
+     * @param device 设备
+     * @return 设备集合
+     */
+    public List<Device> selectDeviceList(Device device);
+
+    /**
+     * 新增设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    public int insertDevice(Device device);
+
+    /**
+     * 修改设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    public int updateDevice(Device device);
+
+    /**
+     * 批量删除设备
+     * 
+     * @param ids 需要删除的设备主键集合
+     * @return 结果
+     */
+    public int deleteDeviceByIds(Long[] ids);
+
+    /**
+     * 删除设备信息
+     * 
+     * @param id 设备主键
+     * @return 结果
+     */
+    public int deleteDeviceById(Long id);
+}

+ 63 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IFieldPersonnelService.java

@@ -0,0 +1,63 @@
+package com.ruoyi.base.service;
+
+import com.ruoyi.base.domain.FieldPersonnel;
+
+import java.util.List;
+
+
+/**
+ * 地块人员绑定Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+public interface IFieldPersonnelService 
+{
+    /**
+     * 查询地块人员绑定
+     * 
+     * @param id 地块人员绑定主键
+     * @return 地块人员绑定
+     */
+    public FieldPersonnel selectFieldPersonnelById(Long id);
+
+    /**
+     * 查询地块人员绑定列表
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 地块人员绑定集合
+     */
+    public List<FieldPersonnel> selectFieldPersonnelList(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 新增地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    public int insertFieldPersonnel(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 修改地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    public int updateFieldPersonnel(FieldPersonnel fieldPersonnel);
+
+    /**
+     * 批量删除地块人员绑定
+     * 
+     * @param ids 需要删除的地块人员绑定主键集合
+     * @return 结果
+     */
+    public int deleteFieldPersonnelByIds(Long[] ids);
+
+    /**
+     * 删除地块人员绑定信息
+     * 
+     * @param id 地块人员绑定主键
+     * @return 结果
+     */
+    public int deleteFieldPersonnelById(Long id);
+}

+ 135 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IFieldService.java

@@ -0,0 +1,135 @@
+package com.ruoyi.base.service;
+
+import com.ruoyi.base.domain.Device;
+import com.ruoyi.base.domain.Field;
+import com.ruoyi.base.domain.FieldPersonnel;
+
+import java.util.List;
+
+
+/**
+ * 地块信息Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-20
+ */
+public interface IFieldService 
+{
+    /**
+     * 查询地块信息
+     * 
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    public Field selectFieldById(Long id);
+
+    /**
+     * 查询地块信息列表
+     * 
+     * @param field 地块信息
+     * @return 地块信息集合
+     */
+    public List<Field> selectFieldList(Field field);
+
+    /**
+     * 新增地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    public int insertField(Field field);
+
+    /**
+     * 修改地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    public int updateField(Field field);
+
+    /**
+     * 批量删除地块信息
+     * 
+     * @param ids 需要删除的地块信息主键集合
+     * @return 结果
+     */
+    public int deleteFieldByIds(Long[] ids);
+
+    /**
+     * 删除地块信息信息
+     * 
+     * @param id 地块信息主键
+     * @return 结果
+     */
+    public int deleteFieldById(Long id);
+
+
+
+    /**
+     * 绑定地块设备信息
+     *
+     * @param ids
+     * @return 结果
+     */
+    public int bindFieldDevice(Long[] ids);
+
+    /**
+     * 绑定地块人员信息
+     *
+     * @param ids
+     * @return 结果
+     */
+    public int bindFieldUser(Long[] ids);
+
+
+
+    /**
+     * 解绑地块设备信息
+     *
+     * @param ids
+     * @return 结果
+     */
+    public int unbindFieldDevice(Long[] ids);
+
+
+    /**
+     * 解绑地块人员信息
+     *
+     * @param ids
+     * @return 结果
+     */
+    public int unbindFieldUser(Long[] ids);
+
+
+
+
+
+    /**
+     * 查询设备信息已绑定
+     *
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    public  List<Device> selectDeviceById(Long id);
+
+
+
+    public  List<FieldPersonnel> selectUserById(Long id);
+
+    /**
+     * 查询设备信息未绑定
+     *
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    public  List<Device> selectDeviceUnById(Long id);
+
+
+    /**
+     * 查询用户信息未绑定
+     *
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    public  List<FieldPersonnel> selectUserUnById(Long id);
+}

+ 82 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/ISensorRealtimeDataService.java

@@ -0,0 +1,82 @@
+package com.ruoyi.base.service;
+
+import com.ruoyi.base.domain.SensorDataStatistics;
+import com.ruoyi.base.domain.SensorRealtimeData;
+
+import java.util.List;
+
+/**
+ * 传感器实时数据Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+public interface ISensorRealtimeDataService 
+{
+    /**
+     * 查询传感器实时数据
+     * 
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    public SensorRealtimeData selectSensorRealtimeDataById(Long id);
+
+
+    /**
+     * 查询最新传感器实时数据
+     *
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    public SensorRealtimeData selectSensorRealtimeDataLatestTimeById(String deviceId);
+
+    /**
+     * 查询传感器实时数据列表
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 传感器实时数据集合
+     */
+    public List<SensorRealtimeData> selectSensorRealtimeDataList(SensorRealtimeData sensorRealtimeData);
+
+    /**
+     * 新增传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    public int insertSensorRealtimeData(SensorRealtimeData sensorRealtimeData);
+
+
+
+    /**
+     * 新增传感器统计
+     *
+     * @param sensorDataStatistics 传感器实时数据
+     * @return 结果
+     */
+    public int insertSensorStatistics(SensorDataStatistics sensorDataStatistics);
+
+    /**
+     * 修改传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    public int updateSensorRealtimeData(SensorRealtimeData sensorRealtimeData);
+
+    /**
+     * 批量删除传感器实时数据
+     * 
+     * @param ids 需要删除的传感器实时数据主键集合
+     * @return 结果
+     */
+    public int deleteSensorRealtimeDataByIds(Long[] ids);
+
+    /**
+     * 删除传感器实时数据信息
+     * 
+     * @param id 传感器实时数据主键
+     * @return 结果
+     */
+    public int deleteSensorRealtimeDataById(Long id);
+}

+ 73 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/IWeatherRealtimeDataService.java

@@ -0,0 +1,73 @@
+package com.ruoyi.base.service;
+
+import com.ruoyi.base.domain.WeatherDataStatistics;
+import com.ruoyi.base.domain.WeatherRealtimeData;
+
+import java.util.List;
+
+/**
+ * 气象站实时数据Service接口
+ *
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+public interface IWeatherRealtimeDataService {
+    /**
+     * 查询气象站实时数据
+     *
+     * @param id 气象站实时数据主键
+     * @return 气象站实时数据
+     */
+    public WeatherRealtimeData selectWeatherRealtimeDataById(Long id);
+
+    /**
+     * 查询气象站实时数据列表
+     *
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 气象站实时数据集合
+     */
+    public List<WeatherRealtimeData> selectWeatherRealtimeDataList(WeatherRealtimeData weatherRealtimeData);
+
+    /**
+     * 新增气象站实时数据
+     *
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    public int insertWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData);
+
+
+    /**
+     * 新增气象站统计数据
+     *
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    int insertWeatherStatistics(WeatherDataStatistics weatherRealtimeData);
+
+    /**
+     * 修改气象站实时数据
+     *
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    public int updateWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData);
+
+    /**
+     * 批量删除气象站实时数据
+     *
+     * @param ids 需要删除的气象站实时数据主键集合
+     * @return 结果
+     */
+    public int deleteWeatherRealtimeDataByIds(Long[] ids);
+
+    /**
+     * 删除气象站实时数据信息
+     *
+     * @param id 气象站实时数据主键
+     * @return 结果
+     */
+    public int deleteWeatherRealtimeDataById(Long id);
+
+
+}

+ 98 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,98 @@
+package com.ruoyi.base.service.impl;
+
+import com.ruoyi.base.domain.Device;
+import com.ruoyi.base.mapper.DeviceMapper;
+import com.ruoyi.base.service.IDeviceService;
+import com.ruoyi.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * 设备Service业务层处理
+ * 
+ * @author zmj
+ * @date 2025-05-29
+ */
+@Service
+public class DeviceServiceImpl implements IDeviceService
+{
+    @Autowired
+    private DeviceMapper deviceMapper;
+
+    /**
+     * 查询设备
+     * 
+     * @param id 设备主键
+     * @return 设备
+     */
+    @Override
+    public Device selectDeviceById(Long id)
+    {
+        return deviceMapper.selectDeviceById(id);
+    }
+
+    /**
+     * 查询设备列表
+     * 
+     * @param device 设备
+     * @return 设备
+     */
+    @Override
+    public List<Device> selectDeviceList(Device device)
+    {
+        return deviceMapper.selectDeviceList(device);
+    }
+
+    /**
+     * 新增设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    @Override
+    public int insertDevice(Device device)
+    {
+        device.setCreateTime(DateUtils.getNowDate());
+        return deviceMapper.insertDevice(device);
+    }
+
+    /**
+     * 修改设备
+     * 
+     * @param device 设备
+     * @return 结果
+     */
+    @Override
+    public int updateDevice(Device device)
+    {
+        device.setUpdateTime(DateUtils.getNowDate());
+        return deviceMapper.updateDevice(device);
+    }
+
+    /**
+     * 批量删除设备
+     * 
+     * @param ids 需要删除的设备主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDeviceByIds(Long[] ids)
+    {
+        return deviceMapper.deleteDeviceByIds(ids);
+    }
+
+    /**
+     * 删除设备信息
+     * 
+     * @param id 设备主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDeviceById(Long id)
+    {
+        return deviceMapper.deleteDeviceById(id);
+    }
+}

+ 97 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/FieldPersonnelServiceImpl.java

@@ -0,0 +1,97 @@
+package com.ruoyi.base.service.impl;
+
+import com.ruoyi.base.domain.FieldPersonnel;
+import com.ruoyi.base.mapper.FieldPersonnelMapper;
+import com.ruoyi.base.service.IFieldPersonnelService;
+import com.ruoyi.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 地块人员绑定Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-05-23
+ */
+@Service
+public class FieldPersonnelServiceImpl implements IFieldPersonnelService
+{
+    @Autowired
+    private FieldPersonnelMapper fieldPersonnelMapper;
+
+    /**
+     * 查询地块人员绑定
+     * 
+     * @param id 地块人员绑定主键
+     * @return 地块人员绑定
+     */
+    @Override
+    public FieldPersonnel selectFieldPersonnelById(Long id)
+    {
+        return fieldPersonnelMapper.selectFieldPersonnelById(id);
+    }
+
+    /**
+     * 查询地块人员绑定列表
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 地块人员绑定
+     */
+    @Override
+    public List<FieldPersonnel> selectFieldPersonnelList(FieldPersonnel fieldPersonnel)
+    {
+        return fieldPersonnelMapper.selectFieldPersonnelList(fieldPersonnel);
+    }
+
+    /**
+     * 新增地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    @Override
+    public int insertFieldPersonnel(FieldPersonnel fieldPersonnel)
+    {
+        fieldPersonnel.setCreateTime(DateUtils.getNowDate());
+        return fieldPersonnelMapper.insertFieldPersonnel(fieldPersonnel);
+    }
+
+    /**
+     * 修改地块人员绑定
+     * 
+     * @param fieldPersonnel 地块人员绑定
+     * @return 结果
+     */
+    @Override
+    public int updateFieldPersonnel(FieldPersonnel fieldPersonnel)
+    {
+        fieldPersonnel.setUpdateTime(DateUtils.getNowDate());
+        return fieldPersonnelMapper.updateFieldPersonnel(fieldPersonnel);
+    }
+
+    /**
+     * 批量删除地块人员绑定
+     * 
+     * @param ids 需要删除的地块人员绑定主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFieldPersonnelByIds(Long[] ids)
+    {
+        return fieldPersonnelMapper.deleteFieldPersonnelByIds(ids);
+    }
+
+    /**
+     * 删除地块人员绑定信息
+     * 
+     * @param id 地块人员绑定主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFieldPersonnelById(Long id)
+    {
+        return fieldPersonnelMapper.deleteFieldPersonnelById(id);
+    }
+}

+ 198 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/FieldServiceImpl.java

@@ -0,0 +1,198 @@
+package com.ruoyi.base.service.impl;
+
+import com.ruoyi.base.domain.Device;
+import com.ruoyi.base.domain.Field;
+import com.ruoyi.base.domain.FieldDevice;
+import com.ruoyi.base.domain.FieldPersonnel;
+import com.ruoyi.base.mapper.DeviceMapper;
+import com.ruoyi.base.mapper.FieldDeviceMapper;
+import com.ruoyi.base.mapper.FieldMapper;
+import com.ruoyi.base.mapper.FieldPersonnelMapper;
+import com.ruoyi.base.service.IFieldService;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 地块信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-05-20
+ */
+@Service
+public class FieldServiceImpl implements IFieldService
+{
+    @Autowired
+    private FieldMapper fieldMapper;
+
+    @Autowired
+    private DeviceMapper deviceMapper;
+
+    @Autowired
+    private FieldDeviceMapper fieldDeviceMapper;
+
+
+    @Autowired
+    private FieldPersonnelMapper fieldPersonnelMapper;
+
+
+
+    /**
+     * 查询地块信息
+     * 
+     * @param id 地块信息主键
+     * @return 地块信息
+     */
+    @Override
+    public Field selectFieldById(Long id)
+    {
+        return fieldMapper.selectFieldById(id);
+    }
+
+    /**
+     * 查询地块信息列表
+     * 
+     * @param field 地块信息
+     * @return 地块信息
+     */
+    @Override
+    public List<Field> selectFieldList(Field field)
+    {
+        List<Field> fields = fieldMapper.selectFieldList(field);
+        return fields;
+    }
+
+    /**
+     * 新增地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    @Override
+    public int insertField(Field field)
+    {
+        return fieldMapper.insertField(field);
+    }
+
+    /**
+     * 修改地块信息
+     * 
+     * @param field 地块信息
+     * @return 结果
+     */
+    @Override
+    public int updateField(Field field)
+    {
+        return fieldMapper.updateField(field);
+    }
+
+    /**
+     * 批量删除地块信息
+     * 
+     * @param ids 需要删除的地块信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFieldByIds(Long[] ids)
+    {
+        return fieldMapper.deleteFieldByIds(ids);
+    }
+
+    /**
+     * 删除地块信息信息
+     * 
+     * @param id 地块信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteFieldById(Long id)
+    {
+        return fieldMapper.deleteFieldById(id);
+    }
+
+    @Override
+    public int bindFieldDevice(Long[] ids) {
+        FieldDevice fieldDevice = new FieldDevice();
+        fieldDevice.setFieldId(ids[0]);
+        fieldDevice.setDeviceId(ids[1]);
+        fieldDevice.setBindingTime(new Date());
+        fieldDevice.setStatus("0");
+        fieldDevice.setCreateTime(new Date());
+        fieldDevice.setCreateBy(SecurityUtils.getUsername());
+        return fieldDeviceMapper.insertFieldDevice(fieldDevice);
+    }
+
+    @Override
+    public int bindFieldUser(Long[] ids) {
+        FieldPersonnel fieldPersonnel = new FieldPersonnel();
+        fieldPersonnel.setFieldId(ids[0]);
+        fieldPersonnel.setUserId(ids[1]);
+        fieldPersonnel.setBindingTime(new Date());
+        fieldPersonnel.setStatus("0");
+        fieldPersonnel.setCreateTime(new Date());
+        fieldPersonnel.setCreatedBy(SecurityUtils.getUsername());
+        return fieldPersonnelMapper.insertFieldPersonnel(fieldPersonnel);
+    }
+
+    @Override
+    public int unbindFieldDevice(Long[] ids) {
+        FieldDevice fieldDevice = new FieldDevice();
+        fieldDevice.setFieldId(ids[0]);
+        fieldDevice.setDeviceId(ids[1]);
+        fieldDevice.setStatus("1");
+        fieldDevice.setUpdateTime(new Date());
+        fieldDevice.setUpdateBy(SecurityUtils.getUsername());
+        return fieldDeviceMapper.updateFieldDevice(fieldDevice);
+    }
+
+
+    @Override
+    public int unbindFieldUser(Long[] ids) {
+        FieldPersonnel fieldPersonnel = new FieldPersonnel();
+        fieldPersonnel.setFieldId(ids[0]);
+        fieldPersonnel.setUserId(ids[1]);
+        fieldPersonnel.setStatus("1");
+        fieldPersonnel.setUpdateTime(new Date());
+        fieldPersonnel.setUpdateBy(SecurityUtils.getUsername());
+        return fieldPersonnelMapper.updateFieldPersonnel(fieldPersonnel);
+    }
+
+
+    @Override
+    public  List<Device> selectDeviceById(Long id)
+    {
+        return deviceMapper.selectDeviceByField(id);
+    }
+
+    @Override
+    public  List<Device> selectDeviceUnById(Long id)
+    {
+        Field field = fieldMapper.selectFieldById(id);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("id",id);
+        paramMap.put("farmId",field.getFarmId());
+        return deviceMapper.selectDeviceByunField(paramMap);
+    }
+
+    @Override
+    public List<FieldPersonnel> selectUserUnById(Long id) {
+        Field field = fieldMapper.selectFieldById(id);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("id",id);
+        paramMap.put("deptId",field.getFarmId());
+        return deviceMapper.selectDeviceByunUser(paramMap);
+    }
+
+    @Override
+    public List<FieldPersonnel> selectUserById(Long id) {
+        return deviceMapper.selectUserById(id);
+    }
+
+
+
+}

+ 123 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/SensorRealtimeDataServiceImpl.java

@@ -0,0 +1,123 @@
+package com.ruoyi.base.service.impl;
+
+import com.ruoyi.base.domain.SensorDataStatistics;
+import com.ruoyi.base.domain.SensorRealtimeData;
+import com.ruoyi.base.mapper.SensorRealtimeDataMapper;
+import com.ruoyi.base.service.ISensorRealtimeDataService;
+import com.ruoyi.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 传感器实时数据Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-06-17
+ */
+@Service
+public class SensorRealtimeDataServiceImpl implements ISensorRealtimeDataService 
+{
+    @Autowired
+    private SensorRealtimeDataMapper sensorRealtimeDataMapper;
+
+    /**
+     * 查询传感器实时数据
+     * 
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    @Override
+    public SensorRealtimeData selectSensorRealtimeDataById(Long id)
+    {
+        return sensorRealtimeDataMapper.selectSensorRealtimeDataById(id);
+    }
+
+    /**
+     * 查询最新传感器实时数据
+     *
+     * @param id 传感器实时数据主键
+     * @return 传感器实时数据
+     */
+    @Override
+    public SensorRealtimeData selectSensorRealtimeDataLatestTimeById(String deviceId)
+    {
+        return sensorRealtimeDataMapper.selectSensorRealtimeDataLatestTimeById(deviceId);
+    }
+
+    /**
+     * 查询传感器实时数据列表
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 传感器实时数据
+     */
+    @Override
+    public List<SensorRealtimeData> selectSensorRealtimeDataList(SensorRealtimeData sensorRealtimeData)
+    {
+        return sensorRealtimeDataMapper.selectSensorRealtimeDataList(sensorRealtimeData);
+    }
+
+    /**
+     * 新增传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    @Override
+    public int insertSensorRealtimeData(SensorRealtimeData sensorRealtimeData)
+    {
+        sensorRealtimeData.setCreateTime(DateUtils.getNowDate());
+        return sensorRealtimeDataMapper.insertSensorRealtimeData(sensorRealtimeData);
+    }
+
+
+    /**
+     * 新增传感器统计数据
+     *
+     * @param sensorDataStatistics 传感器实时数据
+     * @return 结果
+     */
+    @Override
+    public int insertSensorStatistics(SensorDataStatistics sensorDataStatistics) {
+        return sensorRealtimeDataMapper.insertSensorStatistics(sensorDataStatistics);
+    }
+
+
+    /**
+     * 修改传感器实时数据
+     * 
+     * @param sensorRealtimeData 传感器实时数据
+     * @return 结果
+     */
+    @Override
+    public int updateSensorRealtimeData(SensorRealtimeData sensorRealtimeData)
+    {
+        sensorRealtimeData.setUpdateTime(DateUtils.getNowDate());
+        return sensorRealtimeDataMapper.updateSensorRealtimeData(sensorRealtimeData);
+    }
+
+    /**
+     * 批量删除传感器实时数据
+     * 
+     * @param ids 需要删除的传感器实时数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSensorRealtimeDataByIds(Long[] ids)
+    {
+        return sensorRealtimeDataMapper.deleteSensorRealtimeDataByIds(ids);
+    }
+
+    /**
+     * 删除传感器实时数据信息
+     * 
+     * @param id 传感器实时数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSensorRealtimeDataById(Long id)
+    {
+        return sensorRealtimeDataMapper.deleteSensorRealtimeDataById(id);
+    }
+}

+ 104 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/WeatherRealtimeDataServiceImpl.java

@@ -0,0 +1,104 @@
+package com.ruoyi.base.service.impl;
+
+import com.ruoyi.base.domain.WeatherDataStatistics;
+import com.ruoyi.base.domain.WeatherRealtimeData;
+import com.ruoyi.base.mapper.WeatherRealtimeDataMapper;
+import com.ruoyi.base.service.IWeatherRealtimeDataService;
+import com.ruoyi.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 气象站实时数据Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-06-18
+ */
+@Service
+public class WeatherRealtimeDataServiceImpl implements IWeatherRealtimeDataService 
+{
+    @Autowired
+    private WeatherRealtimeDataMapper weatherRealtimeDataMapper;
+
+    /**
+     * 查询气象站实时数据
+     * 
+     * @param id 气象站实时数据主键
+     * @return 气象站实时数据
+     */
+    @Override
+    public WeatherRealtimeData selectWeatherRealtimeDataById(Long id)
+    {
+        return weatherRealtimeDataMapper.selectWeatherRealtimeDataById(id);
+    }
+
+    /**
+     * 查询气象站实时数据列表
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 气象站实时数据
+     */
+    @Override
+    public List<WeatherRealtimeData> selectWeatherRealtimeDataList(WeatherRealtimeData weatherRealtimeData)
+    {
+        return weatherRealtimeDataMapper.selectWeatherRealtimeDataList(weatherRealtimeData);
+    }
+
+    /**
+     * 新增气象站实时数据
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    @Override
+    public int insertWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData)
+    {
+        weatherRealtimeData.setCreateTime(DateUtils.getNowDate());
+        return weatherRealtimeDataMapper.insertWeatherRealtimeData(weatherRealtimeData);
+    }
+
+    @Override
+    public int insertWeatherStatistics(WeatherDataStatistics weatherRealtimeData) {
+        weatherRealtimeData.setCreateTime(DateUtils.getNowDate());
+        return weatherRealtimeDataMapper.insertWeatherStatistics(weatherRealtimeData);
+    }
+
+    /**
+     * 修改气象站实时数据
+     * 
+     * @param weatherRealtimeData 气象站实时数据
+     * @return 结果
+     */
+    @Override
+    public int updateWeatherRealtimeData(WeatherRealtimeData weatherRealtimeData)
+    {
+        weatherRealtimeData.setUpdateTime(DateUtils.getNowDate());
+        return weatherRealtimeDataMapper.updateWeatherRealtimeData(weatherRealtimeData);
+    }
+
+    /**
+     * 批量删除气象站实时数据
+     * 
+     * @param ids 需要删除的气象站实时数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteWeatherRealtimeDataByIds(Long[] ids)
+    {
+        return weatherRealtimeDataMapper.deleteWeatherRealtimeDataByIds(ids);
+    }
+
+    /**
+     * 删除气象站实时数据信息
+     * 
+     * @param id 气象站实时数据主键
+     * @return 结果
+     */
+    @Override
+    public int deleteWeatherRealtimeDataById(Long id)
+    {
+        return weatherRealtimeDataMapper.deleteWeatherRealtimeDataById(id);
+    }
+}

+ 2 - 0
ruoyi-modules/ruoyi-base/src/main/resources/banner.txt

@@ -0,0 +1,2 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}

+ 30 - 0
ruoyi-modules/ruoyi-base/src/main/resources/bootstrap.yml

@@ -0,0 +1,30 @@
+# Tomcat
+server:
+  port: 9301
+
+# Spring
+spring: 
+  application:
+    # 应用名称
+    name: ruoyi-base
+  profiles:
+    # 环境配置
+    active: dev
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        server-addr: 121.4.16.100:8848
+        username: nacos
+        password: nacos369
+        namespace: dev
+      config:
+        username: nacos
+        password: nacos369
+        # 配置中心地址
+        server-addr: 121.4.16.100:8848
+        # 配置文件格式
+        file-extension: yml
+        # 共享配置
+        shared-configs:
+          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 74 - 0
ruoyi-modules/ruoyi-base/src/main/resources/logback.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 日志存放路径 -->
+	<property name="log.path" value="logs/ruoyi-base" />
+   <!-- 日志输出格式 -->
+	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
+
+    <!-- 控制台输出 -->
+	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+		<encoder>
+			<pattern>${log.pattern}</pattern>
+		</encoder>
+	</appender>
+
+    <!-- 系统日志输出 -->
+	<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
+	    <file>${log.path}/info.log</file>
+        <!-- 循环政策:基于时间创建日志文件 -->
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+			<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
+			<!-- 日志最大的历史 60天 -->
+			<maxHistory>60</maxHistory>
+		</rollingPolicy>
+		<encoder>
+			<pattern>${log.pattern}</pattern>
+		</encoder>
+		<filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 过滤的级别 -->
+            <level>INFO</level>
+            <!-- 匹配时的操作:接收(记录) -->
+            <onMatch>ACCEPT</onMatch>
+            <!-- 不匹配时的操作:拒绝(不记录) -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+	</appender>
+
+    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+	    <file>${log.path}/error.log</file>
+        <!-- 循环政策:基于时间创建日志文件 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
+			<!-- 日志最大的历史 60天 -->
+			<maxHistory>60</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 过滤的级别 -->
+            <level>ERROR</level>
+			<!-- 匹配时的操作:接收(记录) -->
+            <onMatch>ACCEPT</onMatch>
+			<!-- 不匹配时的操作:拒绝(不记录) -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 系统模块日志级别控制  -->
+	<logger name="com.ruoyi" level="debug" />
+	<!-- Spring日志级别控制  -->
+	<logger name="org.springframework" level="warn" />
+
+	<root level="info">
+		<appender-ref ref="console" />
+	</root>
+	
+	<!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="file_info" />
+        <appender-ref ref="file_error" />
+    </root>
+</configuration>

+ 207 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/DeviceMapper.xml

@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.DeviceMapper">
+    
+    <resultMap type="com.ruoyi.base.domain.Device" id="DeviceResult">
+        <result property="id"    column="id"    />
+        <result property="deviceId"    column="device_id"    />
+        <result property="deviceName"    column="device_name"    />
+        <result property="deviceTypeId"    column="device_type_id"    />
+        <result property="farmId"    column="farm_id"    />
+        <result property="model"    column="model"    />
+        <result property="manufacturer"    column="manufacturer"    />
+        <result property="installDate"    column="install_date"    />
+        <result property="status"    column="status"    />
+        <result property="lastActiveTime"    column="last_active_time"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="bindStatus"    column="bindStatus"    />
+        <result property="bindTime"    column="binding_time"    />
+        <result property="fieldName"    column="field_name"    />
+        <result property="longitude"    column="longitude"    />
+        <result property="latitude"    column="latitude"    />
+        <result property="remark"    column="remark"    />
+        <association property="dept"    javaType="com.ruoyi.system.api.domain.SysDept"         resultMap="deptResult" />
+        <collection  property="roles"   javaType="java.util.List"  resultMap="RoleResult" />
+    </resultMap>
+
+
+    <resultMap type="FieldPersonnel" id="FieldPersonnelResult">
+        <result property="id"    column="id"    />
+        <result property="fieldId"    column="field_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="roleType"    column="role_type"    />
+        <result property="bindingTime"    column="binding_time"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createdBy"    column="created_by"    />
+        <result property="updatedBy"    column="updated_by"    />
+        <result property="isDeleted"    column="is_deleted"    />
+        <result property="userName"    column="user_name"    />
+        <result property="postName"    column="post_name"    />
+        <result property="phonenumber"    column="phonenumber"    />
+    </resultMap>
+
+    <resultMap id="deptResult" type="com.ruoyi.system.api.domain.SysDept">
+        <id     property="deptId"    column="dept_id"     />
+        <result property="parentId"  column="parent_id"   />
+        <result property="deptName"  column="dept_name"   />
+        <result property="ancestors" column="ancestors"   />
+        <result property="orderNum"  column="order_num"   />
+        <result property="leader"    column="leader"      />
+        <result property="status"    column="dept_status" />
+    </resultMap>
+
+    <resultMap id="RoleResult" type="com.ruoyi.system.api.domain.SysDept">
+        <id     property="roleId"       column="role_id"        />
+        <result property="roleName"     column="role_name"      />
+        <result property="roleKey"      column="role_key"       />
+        <result property="roleSort"     column="role_sort"      />
+        <result property="dataScope"    column="data_scope"     />
+        <result property="status"       column="role_status"    />
+    </resultMap>
+
+
+    <sql id="selectDeviceVo">
+        select id, device_id, device_name, device_type_id, farm_id, model, manufacturer, install_date, status, last_active_time, create_time, update_time, remark from device
+    </sql>
+
+    <select id="selectDeviceList" parameterType="com.ruoyi.base.domain.Device" resultMap="DeviceResult">
+        select de.id, de.device_id, de.device_name, de.device_type_id, de.farm_id, de.model,
+        de.manufacturer, de.install_date, de.status, de.last_active_time, de.create_time, de.update_time, de.remark,d.dept_name, d.leader,f.field_name
+        from device de
+        left join sys_dept d on de.farm_id = d.dept_id
+        left join  field_device fd on de.id = fd.device_id
+        left join field f on fd.field_id = f.id
+        <where>
+            (fd.status = 0 or fd.status is null)
+            <if test="deviceId != null  and deviceId != ''"> and de.device_id = #{deviceId}</if>
+            <if test="deviceName != null  and deviceName != ''"> and de.device_name like concat('%', #{deviceName}, '%')</if>
+            <if test="deptIdList != null  and deptIdList.size() != 0"> and de.farm_id in (<foreach collection="deptIdList" item="deptId" separator=",">#{deptId}</foreach>)</if>
+            <if test="fieldIdList != null  and fieldIdList.size() != 0"> and f.id in (<foreach collection="fieldIdList" item="deptId" separator=",">#{deptId}</foreach>)</if>
+            <if test="deviceTypeId != null  and deviceTypeId != ''"> and de.device_type_id = #{deviceTypeId}</if>
+            <if test="farmId != null  and farmId != ''"> and de.farm_id = #{farmId}</if>
+            <if test="model != null  and model != ''"> and de.model = #{model}</if>
+            <if test="manufacturer != null  and manufacturer != ''"> and de.manufacturer = #{manufacturer}</if>
+            <if test="installDate != null "> and de.install_date = #{installDate}</if>
+            <if test="status != null "> and de.status = #{status}</if>
+            <if test="lastActiveTime != null "> and de.last_active_time = #{lastActiveTime}</if>
+        </where>
+    </select>
+    
+    <select id="selectDeviceById" parameterType="Long" resultMap="DeviceResult">
+        select de.id, de.device_id, de.device_name, de.device_type_id, de.farm_id, de.model,
+               de.manufacturer, de.install_date, de.status, de.last_active_time,d.dept_name,f.field_name,de.remark,longitude,latitude
+        from device de
+                 left join sys_dept d on de.farm_id = d.dept_id
+                 left join field_device fd on de.id = fd.device_id
+                 left join field f on fd.field_id = f.id
+
+        where de.id = #{id} and (fd.status = 0 or fd.status is null);
+    </select>
+    <select id="selectDeviceByField" resultMap="DeviceResult">
+        select d.*,fd.status as bindStatus,fd.binding_time as binding_time
+        from field f
+                 left join field_device fd on f.id = fd.field_id
+                 left join device d on fd.device_id = d.id where f.id = #{id} and fd.status = 0;
+
+    </select>
+    <select id="selectUserById" resultMap="FieldPersonnelResult">
+        select u.user_name,p.post_name,u.phonenumber,fp.binding_time,u.user_id
+        from field f
+                 join field_personnel fp on f.id = fp.field_id
+                 left join sys_user u on fp.user_id = u.user_id
+                 left join sys_user_post sup on u.user_id = sup.user_id
+                 left join sys_post p on sup.post_id = p.post_id
+        where f.id = #{id} and fp.status = 0
+
+
+    </select>
+    <select id="selectDeviceByunField" resultMap="DeviceResult">
+        select d.*
+        from device d
+                 left join field f on d.farm_id = f.farm_id
+        where d.id not in (select device_id from field_device f where f.field_id = #{id} and f.status = 0) and
+            d.farm_id = #{farmId}
+    </select>
+    <select id="selectDeviceByunUser" resultMap="FieldPersonnelResult">
+        select u.user_name,p.post_name,u.phonenumber,u.user_id,sd.dept_name
+        from sys_user u
+                 left join field f on u.dept_id = f.farm_id
+                 left join sys_user_post sup on u.user_id = sup.user_id
+                 left join sys_post p on sup.post_id = p.post_id
+                 left join sys_dept sd on u.dept_id = sd.dept_id
+        where u.user_id not in (select user_id from field_personnel where field_id = #{id} and status = 0)
+          and u.dept_id = #{deptId}
+    </select>
+
+
+    <insert id="insertDevice" parameterType="com.ruoyi.base.domain.Device" useGeneratedKeys="true" keyProperty="id">
+        insert into device
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id,</if>
+            <if test="deviceName != null and deviceName != ''">device_name,</if>
+            <if test="deviceTypeId != null and deviceTypeId != ''">device_type_id,</if>
+            <if test="farmId != null">farm_id,</if>
+            <if test="model != null">model,</if>
+            <if test="manufacturer != null">manufacturer,</if>
+            <if test="longitude != null">longitude,</if>
+            <if test="latitude != null">latitude,</if>
+            <if test="installDate != null">install_date,</if>
+            <if test="status != null">status,</if>
+            <if test="lastActiveTime != null">last_active_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
+            <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
+            <if test="deviceTypeId != null and deviceTypeId != ''">#{deviceTypeId},</if>
+            <if test="farmId != null">#{farmId},</if>
+            <if test="model != null">#{model},</if>
+            <if test="manufacturer != null">#{manufacturer},</if>
+            <if test="longitude != null">#{longitude},</if>
+            <if test="latitude != null">#{latitude},</if>
+            <if test="installDate != null">#{installDate},</if>
+            <if test="status != null">#{status},</if>
+            <if test="lastActiveTime != null">#{lastActiveTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateDevice" parameterType="com.ruoyi.base.domain.Device">
+        update device
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
+            <if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
+            <if test="deviceTypeId != null and deviceTypeId != ''">device_type_id = #{deviceTypeId},</if>
+            <if test="farmId != null">farm_id = #{farmId},</if>
+            <if test="model != null">model = #{model},</if>
+            <if test="manufacturer != null">manufacturer = #{manufacturer},</if>
+            <if test="installDate != null">install_date = #{installDate},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="lastActiveTime != null">last_active_time = #{lastActiveTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteDeviceById" parameterType="Long">
+        delete from device where id = #{id}
+    </delete>
+
+    <delete id="deleteDeviceByIds" parameterType="String">
+        delete from device where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 96 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldDeviceMapper.xml

@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.FieldDeviceMapper">
+
+    <resultMap type="FieldDevice" id="FieldDeviceResult">
+        <result property="id"    column="id"    />
+        <result property="fieldId"    column="field_id"    />
+        <result property="deviceId"    column="device_id"    />
+        <result property="bindingTime"    column="binding_time"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="isDeleted"    column="is_deleted"    />
+    </resultMap>
+
+    <sql id="selectFieldDeviceVo">
+        select id, field_id, device_id, binding_time, status, create_time, update_time, create_by, update_by, is_deleted from field_device
+    </sql>
+
+    <select id="selectFieldDeviceList" parameterType="FieldDevice" resultMap="FieldDeviceResult">
+        <include refid="selectFieldDeviceVo"/>
+        <where>
+            <if test="fieldId != null "> and field_id = #{fieldId}</if>
+            <if test="deviceId != null "> and device_id = #{deviceId}</if>
+            <if test="bindingTime != null "> and binding_time = #{bindingTime}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
+        </where>
+    </select>
+
+    <select id="selectFieldDeviceById" parameterType="Long" resultMap="FieldDeviceResult">
+        <include refid="selectFieldDeviceVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertFieldDevice" parameterType="FieldDevice" useGeneratedKeys="true" keyProperty="id">
+        insert into field_device
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fieldId != null">field_id,</if>
+            <if test="deviceId != null">device_id,</if>
+            <if test="bindingTime != null">binding_time,</if>
+            <if test="status != null and status != ''">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createBy != null and createBy != ''">create_by,</if>
+            <if test="updateBy != null and updateBy != ''">update_by,</if>
+            <if test="isDeleted != null">is_deleted,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fieldId != null">#{fieldId},</if>
+            <if test="deviceId != null">#{deviceId},</if>
+            <if test="bindingTime != null">#{bindingTime},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
+            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
+            <if test="isDeleted != null">#{isDeleted},</if>
+        </trim>
+    </insert>
+
+    <update id="updateFieldDevice" parameterType="FieldDevice">
+        update field_device
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fieldId != null">field_id = #{fieldId},</if>
+            <if test="deviceId != null">device_id = #{deviceId},</if>
+            <if test="bindingTime != null">binding_time = #{bindingTime},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
+            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
+        </trim>
+        <where>
+            <if test="id != null "> and id = #{id}</if>
+            <if test="fieldId != null "> and field_id = #{fieldId}</if>
+            <if test="deviceId != null "> and device_id = #{deviceId}</if>
+        </where>
+    </update>
+
+    <delete id="deleteFieldDeviceById" parameterType="Long">
+        delete from field_device where id = #{id}
+    </delete>
+
+    <delete id="deleteFieldDeviceByIds" parameterType="String">
+        delete from field_device where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 172 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldMapper.xml

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.FieldMapper">
+    
+    <resultMap type="Field" id="FieldResult">
+        <result property="id"    column="id"    />
+        <result property="fieldCode"    column="field_code"    />
+        <result property="fieldName"    column="field_name"    />
+        <result property="farmId"    column="farm_id"    />
+        <result property="fieldType"    column="field_type"    />
+        <result property="growCrops"    column="grow_crops"    />
+        <result property="size"    column="size"    />
+        <result property="soilType"    column="soil_type"    />
+        <result property="irrigationType"    column="irrigation_type"    />
+        <result property="status"    column="status"    />
+        <result property="managerId"    column="manager_id"    />
+        <result property="managerName"    column="manager_name"    />
+        <result property="description"    column="description"    />
+        <result property="locationData"    column="location_data"    />
+        <result property="createdTime"    column="created_time"    />
+        <result property="updatedTime"    column="updated_time"    />
+        <result property="createdBy"    column="created_by"    />
+        <result property="updatedBy"    column="updated_by"    />
+        <result property="isDeleted"    column="is_deleted"    />
+        <result property="bindDeviceCount"    column="bindDeviceCount"    />
+        <result property="bindUserCount"    column="bindUserCount"    />
+        <association property="dept"    javaType="com.ruoyi.system.api.domain.SysDept"         resultMap="deptResult" />
+        <collection  property="roles"   javaType="java.util.List"  resultMap="RoleResult" />
+    </resultMap>
+
+    <resultMap id="deptResult" type="com.ruoyi.system.api.domain.SysDept">
+        <id     property="deptId"    column="dept_id"     />
+        <result property="parentId"  column="parent_id"   />
+        <result property="deptName"  column="dept_name"   />
+        <result property="ancestors" column="ancestors"   />
+        <result property="orderNum"  column="order_num"   />
+        <result property="leader"    column="leader"      />
+        <result property="status"    column="dept_status" />
+    </resultMap>
+
+    <resultMap id="RoleResult" type="com.ruoyi.system.api.domain.SysDept">
+        <id     property="roleId"       column="role_id"        />
+        <result property="roleName"     column="role_name"      />
+        <result property="roleKey"      column="role_key"       />
+        <result property="roleSort"     column="role_sort"      />
+        <result property="dataScope"    column="data_scope"     />
+        <result property="status"       column="role_status"    />
+    </resultMap>
+
+    <sql id="selectFieldVo">
+        select id, field_code, field_name, farm_id, field_type, grow_crops, size, soil_type, irrigation_type, status, manager_id, description, location_data, created_time, updated_time, created_by, updated_by, is_deleted from field
+    </sql>
+
+    <select id="selectFieldList" parameterType="Field" resultMap="FieldResult">
+        select fd.id, field_code, field_name, farm_id, field_type, grow_crops, fd.size, soil_type, irrigation_type, fd.status,
+               manager_id, description, location_data, fd.created_time, fd.updated_time, fd.created_by, fd.updated_by,manager_name,
+               is_deleted ,d.dept_name, d.leader,(select count(*) from field_device where  status = 0 and field_id = fd.id) as bindDeviceCount,
+        (select count(*) from field_personnel where  status = 0 and field_id = fd.id) as bindUserCount
+        from field fd
+        left join sys_dept d on fd.farm_id = d.dept_id
+        <where>  
+            <if test="fieldCode != null  and fieldCode != ''"> and field_code = #{fieldCode}</if>
+            <if test="fieldName != null  and fieldName != ''"> and field_name like concat('%', #{fieldName}, '%')</if>
+            <if test="deptIdList != null  and deptIdList.size() != 0"> and fd.farm_id in (<foreach collection="deptIdList" item="deptId" separator=",">#{deptId}</foreach>)</if>
+            <if test="fieldType != null  and fieldType != ''"> and field_type = #{fieldType}</if>
+            <if test="growCrops != null  and growCrops != ''"> and grow_crops = #{growCrops}</if>
+            <if test="size != null "> and size = #{size}</if>
+            <if test="soilType != null  and soilType != ''"> and soil_type = #{soilType}</if>
+            <if test="irrigationType != null  and irrigationType != ''"> and irrigation_type = #{irrigationType}</if>
+            <if test="status != null  and status != ''"> and fd.status = #{status}</if>
+            <if test="managerId != null "> and manager_id = #{managerId}</if>
+            <if test="description != null  and description != ''"> and description = #{description}</if>
+            <if test="locationData != null  and locationData != ''"> and location_data = #{locationData}</if>
+            <if test="params.beginfieldDate != null and params.beginfieldDate != '' and params.endfieldDate != null and params.endfieldDate != ''">
+             and created_time between #{params.beginfieldDate} and #{params.endfieldDate}
+             </if>
+
+        </where>
+    </select>
+    
+    <select id="selectFieldById" parameterType="Long" resultMap="FieldResult">
+        select fd.id, field_code, field_name, farm_id, field_type, grow_crops, fd.size, soil_type, manager_name,
+               irrigation_type, fd.status, manager_id, description, location_data, fd.created_time, fd.updated_time, fd.created_by, fd.updated_by, is_deleted ,d.dept_name, d.leader
+        from field fd
+                 left join sys_dept d on fd.farm_id = d.dept_id
+        where id = #{id}
+    </select>
+
+
+    <insert id="insertField" parameterType="Field" useGeneratedKeys="true" keyProperty="id">
+        insert into field
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fieldCode != null and fieldCode != ''">field_code,</if>
+            <if test="fieldName != null and fieldName != ''">field_name,</if>
+            <if test="farmId != null">farm_id,</if>
+            <if test="fieldType != null and fieldType != ''">field_type,</if>
+            <if test="growCrops != null and growCrops != ''">grow_crops,</if>
+            <if test="size != null">size,</if>
+            <if test="soilType != null">soil_type,</if>
+            <if test="irrigationType != null">irrigation_type,</if>
+            <if test="status != null and status != ''">status,</if>
+            <if test="managerId != null">manager_id,</if>
+            <if test="managerName != null">manager_name,</if>
+            <if test="description != null">description,</if>
+            <if test="locationData != null">location_data,</if>
+            <if test="createdTime != null">created_time,</if>
+            <if test="updatedTime != null">updated_time,</if>
+            <if test="createdBy != null">created_by,</if>
+            <if test="updatedBy != null">updated_by,</if>
+            <if test="isDeleted != null">is_deleted,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fieldCode != null and fieldCode != ''">#{fieldCode},</if>
+            <if test="fieldName != null and fieldName != ''">#{fieldName},</if>
+            <if test="farmId != null">#{farmId},</if>
+            <if test="fieldType != null and fieldType != ''">#{fieldType},</if>
+            <if test="growCrops != null and growCrops != ''">#{growCrops},</if>
+            <if test="size != null">#{size},</if>
+            <if test="soilType != null">#{soilType},</if>
+            <if test="irrigationType != null">#{irrigationType},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="managerId != null">#{managerId},</if>
+            <if test="managerName != null">#{managerName},</if>
+            <if test="description != null">#{description},</if>
+            <if test="locationData != null">#{locationData},</if>
+            <if test="createdTime != null">#{createdTime},</if>
+            <if test="updatedTime != null">#{updatedTime},</if>
+            <if test="createdBy != null">#{createdBy},</if>
+            <if test="updatedBy != null">#{updatedBy},</if>
+            <if test="isDeleted != null">#{isDeleted},</if>
+         </trim>
+    </insert>
+
+    <update id="updateField" parameterType="Field">
+        update field
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fieldCode != null and fieldCode != ''">field_code = #{fieldCode},</if>
+            <if test="fieldName != null and fieldName != ''">field_name = #{fieldName},</if>
+            <if test="farmId != null">farm_id = #{farmId},</if>
+            <if test="fieldType != null and fieldType != ''">field_type = #{fieldType},</if>
+            <if test="growCrops != null and growCrops != ''">grow_crops = #{growCrops},</if>
+            <if test="size != null">size = #{size},</if>
+            <if test="soilType != null">soil_type = #{soilType},</if>
+            <if test="irrigationType != null">irrigation_type = #{irrigationType},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="managerId != null">manager_id = #{managerId},</if>
+            <if test="managerName != null">manager_name = #{managerName},</if>
+            <if test="description != null">description = #{description},</if>
+            <if test="locationData != null">location_data = #{locationData},</if>
+            <if test="createdTime != null">created_time = #{createdTime},</if>
+            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
+            <if test="createdBy != null">created_by = #{createdBy},</if>
+            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
+            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+
+    <delete id="deleteFieldById" parameterType="Long">
+        delete from field where id = #{id}
+    </delete>
+
+    <delete id="deleteFieldByIds" parameterType="String">
+        delete from field where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 103 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/FieldPersonnelMapper.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.FieldPersonnelMapper">
+    
+    <resultMap type="FieldPersonnel" id="FieldPersonnelResult">
+        <result property="id"    column="id"    />
+        <result property="fieldId"    column="field_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="roleType"    column="role_type"    />
+        <result property="bindingTime"    column="binding_time"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createdBy"    column="created_by"    />
+        <result property="updatedBy"    column="updated_by"    />
+        <result property="isDeleted"    column="is_deleted"    />
+    </resultMap>
+
+    <sql id="selectFieldPersonnelVo">
+        select id, field_id, user_id, role_type, binding_time, status, create_time, update_time, created_by, updated_by, is_deleted from field_personnel
+    </sql>
+
+    <select id="selectFieldPersonnelList" parameterType="FieldPersonnel" resultMap="FieldPersonnelResult">
+        <include refid="selectFieldPersonnelVo"/>
+        <where>  
+            <if test="fieldId != null "> and field_id = #{fieldId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="roleType != null  and roleType != ''"> and role_type = #{roleType}</if>
+            <if test="bindingTime != null "> and binding_time = #{bindingTime}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
+            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
+            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
+        </where>
+    </select>
+    
+    <select id="selectFieldPersonnelById" parameterType="Long" resultMap="FieldPersonnelResult">
+        <include refid="selectFieldPersonnelVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertFieldPersonnel" parameterType="FieldPersonnel" useGeneratedKeys="true" keyProperty="id">
+        insert into field_personnel
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fieldId != null">field_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="roleType != null and roleType != ''">role_type,</if>
+            <if test="bindingTime != null">binding_time,</if>
+            <if test="status != null and status != ''">status,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createdBy != null and createdBy != ''">created_by,</if>
+            <if test="updatedBy != null and updatedBy != ''">updated_by,</if>
+            <if test="isDeleted != null">is_deleted,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fieldId != null">#{fieldId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="roleType != null and roleType != ''">#{roleType},</if>
+            <if test="bindingTime != null">#{bindingTime},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createdBy != null and createdBy != ''">#{createdBy},</if>
+            <if test="updatedBy != null and updatedBy != ''">#{updatedBy},</if>
+            <if test="isDeleted != null">#{isDeleted},</if>
+         </trim>
+    </insert>
+
+    <update id="updateFieldPersonnel" parameterType="FieldPersonnel">
+        update field_personnel
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fieldId != null">field_id = #{fieldId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="roleType != null and roleType != ''">role_type = #{roleType},</if>
+            <if test="bindingTime != null">binding_time = #{bindingTime},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createdBy != null and createdBy != ''">created_by = #{createdBy},</if>
+            <if test="updatedBy != null and updatedBy != ''">updated_by = #{updatedBy},</if>
+            <if test="isDeleted != null">is_deleted = #{isDeleted},</if>
+        </trim>
+        <where>
+            <if test="id != null "> and id = #{id}</if>
+            <if test="fieldId != null "> and field_id = #{fieldId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+        </where>
+    </update>
+
+    <delete id="deleteFieldPersonnelById" parameterType="Long">
+        delete from field_personnel where id = #{id}
+    </delete>
+
+    <delete id="deleteFieldPersonnelByIds" parameterType="String">
+        delete from field_personnel where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 127 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/SensorRealtimeDataMapper.xml

@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.SensorRealtimeDataMapper">
+    
+    <resultMap type="SensorRealtimeData" id="SensorRealtimeDataResult">
+        <result property="id"    column="id"    />
+        <result property="deviceId"    column="device_id"    />
+        <result property="temperature"    column="temperature"    />
+        <result property="humidity"    column="humidity"    />
+        <result property="lightIntensity"    column="light_intensity"    />
+        <result property="soilMoisture"    column="soil_moisture"    />
+        <result property="collectTime"    column="collect_time"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
+    </resultMap>
+
+    <sql id="selectSensorRealtimeDataVo">
+        select id, device_id, temperature, humidity, light_intensity, soil_moisture, collect_time, create_time, update_time, create_by, update_by from sensor_realtime_data
+    </sql>
+
+    <select id="selectSensorRealtimeDataList" parameterType="SensorRealtimeData" resultMap="SensorRealtimeDataResult">
+        <include refid="selectSensorRealtimeDataVo"/>
+        <where>  
+            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
+            <if test="temperature != null "> and temperature = #{temperature}</if>
+            <if test="humidity != null "> and humidity = #{humidity}</if>
+            <if test="lightIntensity != null "> and light_intensity = #{lightIntensity}</if>
+            <if test="soilMoisture != null "> and soil_moisture = #{soilMoisture}</if>
+            <if test="beginCollectTime != null  and endCollectTime != null ">
+                and collect_time between #{beginCollectTime} and #{endCollectTime}
+            </if>
+        </where>
+    </select>
+    
+    <select id="selectSensorRealtimeDataById" parameterType="Long" resultMap="SensorRealtimeDataResult">
+        <include refid="selectSensorRealtimeDataVo"/>
+        where id = #{id}
+    </select>
+    <select id="selectSensorRealtimeDataLatestTimeById"  resultMap="SensorRealtimeDataResult">
+        SELECT id, device_id, temperature, humidity, light_intensity, soil_moisture, collect_time, create_time, update_time, create_by, update_by
+        FROM sensor_realtime_data
+        WHERE device_id = #{deviceId}
+        ORDER BY collect_time DESC
+            LIMIT 1;
+    </select>
+
+    <insert id="insertSensorRealtimeData" parameterType="SensorRealtimeData" useGeneratedKeys="true" keyProperty="id">
+        insert into sensor_realtime_data
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id,</if>
+            <if test="temperature != null">temperature,</if>
+            <if test="humidity != null">humidity,</if>
+            <if test="lightIntensity != null">light_intensity,</if>
+            <if test="soilMoisture != null">soil_moisture,</if>
+            <if test="collectTime != null">collect_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createBy != null and createBy != ''">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
+            <if test="temperature != null">#{temperature},</if>
+            <if test="humidity != null">#{humidity},</if>
+            <if test="lightIntensity != null">#{lightIntensity},</if>
+            <if test="soilMoisture != null">#{soilMoisture},</if>
+            <if test="collectTime != null">#{collectTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+         </trim>
+    </insert>
+    <insert id="insertSensorStatistics">
+        insert into sensor_data_statistics
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="date != null">date,</if>
+            <if test="deviceId != null and deviceId != ''">sensor_id,</if>
+            <if test="maxTemperature != null">max_temperature,</if>
+            <if test="minTemperature != null">min_temperature,</if>
+            <if test="avgHumidity != null">avg_humidity,</if>
+            <if test="avgLightIntensity != null">avg_illumination,</if>
+            <if test="avgSoilMoisture != null">avg_soil_moisture,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="date != null">#{date},</if>
+            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
+            <if test="maxTemperature != null">#{maxTemperature},</if>
+            <if test="minTemperature != null">#{minTemperature},</if>
+            <if test="avgHumidity != null">#{avgHumidity},</if>
+            <if test="avgLightIntensity != null">#{avgLightIntensity},</if>
+            <if test="avgSoilMoisture != null">#{avgSoilMoisture},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSensorRealtimeData" parameterType="SensorRealtimeData">
+        update sensor_realtime_data
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
+            <if test="temperature != null">temperature = #{temperature},</if>
+            <if test="humidity != null">humidity = #{humidity},</if>
+            <if test="lightIntensity != null">light_intensity = #{lightIntensity},</if>
+            <if test="soilMoisture != null">soil_moisture = #{soilMoisture},</if>
+            <if test="collectTime != null">collect_time = #{collectTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSensorRealtimeDataById" parameterType="Long">
+        delete from sensor_realtime_data where id = #{id}
+    </delete>
+
+    <delete id="deleteSensorRealtimeDataByIds" parameterType="String">
+        delete from sensor_realtime_data where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 178 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/WeatherRealtimeDataMapper.xml

@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.WeatherRealtimeDataMapper">
+    
+    <resultMap type="WeatherRealtimeData" id="WeatherRealtimeDataResult">
+        <result property="id"    column="id"    />
+        <result property="deviceId"    column="device_id"    />
+        <result property="temperature"    column="temperature"    />
+        <result property="humidity"    column="humidity"    />
+        <result property="rainfall"    column="rainfall"    />
+        <result property="windDirection"    column="wind_direction"    />
+        <result property="windSpeed"    column="wind_speed"    />
+        <result property="airPressure"    column="air_pressure"    />
+        <result property="lightIntensity"    column="light_intensity"    />
+        <result property="collectTime"    column="collect_time"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="soilTemperature"    column="soil_temperature"    />
+        <result property="soilHumidity"    column="soil_humidity"    />
+        <result property="soilN"    column="soil_n"    />
+        <result property="soilP"    column="soil_p"    />
+        <result property="soilK"    column="soil_k"    />
+        <result property="rainfallA"    column="rainfall_a"    />
+    </resultMap>
+
+    <sql id="selectWeatherRealtimeDataVo">
+        select id, device_id, temperature, humidity, rainfall, wind_direction, wind_speed, air_pressure, light_intensity, collect_time, create_time, update_time, create_by, update_by, soil_temperature, soil_humidity, soil_n, soil_p, soil_k, rainfall_a from weather_realtime_data
+    </sql>
+
+    <select id="selectWeatherRealtimeDataList" parameterType="WeatherRealtimeData" resultMap="WeatherRealtimeDataResult">
+        <include refid="selectWeatherRealtimeDataVo"/>
+        <where>  
+            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
+            <if test="temperature != null "> and temperature = #{temperature}</if>
+            <if test="humidity != null "> and humidity = #{humidity}</if>
+            <if test="rainfall != null "> and rainfall = #{rainfall}</if>
+            <if test="windDirection != null  and windDirection != ''"> and wind_direction = #{windDirection}</if>
+            <if test="windSpeed != null "> and wind_speed = #{windSpeed}</if>
+            <if test="airPressure != null "> and air_pressure = #{airPressure}</if>
+            <if test="lightIntensity != null "> and light_intensity = #{lightIntensity}</if>
+            <if test="collectTime != null "> and collect_time = #{collectTime}</if>
+            <if test="soilTemperature != null "> and soil_temperature = #{soilTemperature}</if>
+            <if test="soilHumidity != null "> and soil_humidity = #{soilHumidity}</if>
+            <if test="soilN != null "> and soil_n = #{soilN}</if>
+            <if test="soilP != null "> and soil_p = #{soilP}</if>
+            <if test="soilK != null "> and soil_k = #{soilK}</if>
+            <if test="rainfallA != null "> and rainfall_a = #{rainfallA}</if>
+            <if test="beginWeatherTime != null  and endWeatherTime != null ">
+                and collect_time between #{beginWeatherTime} and #{endWeatherTime}
+            </if>
+        </where>
+    </select>
+    
+    <select id="selectWeatherRealtimeDataById" parameterType="Long" resultMap="WeatherRealtimeDataResult">
+        <include refid="selectWeatherRealtimeDataVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertWeatherRealtimeData" parameterType="WeatherRealtimeData" useGeneratedKeys="true" keyProperty="id">
+        insert into weather_realtime_data
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id,</if>
+            <if test="temperature != null">temperature,</if>
+            <if test="humidity != null">humidity,</if>
+            <if test="rainfall != null">rainfall,</if>
+            <if test="windDirection != null">wind_direction,</if>
+            <if test="windSpeed != null">wind_speed,</if>
+            <if test="airPressure != null">air_pressure,</if>
+            <if test="lightIntensity != null">light_intensity,</if>
+            <if test="collectTime != null">collect_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createBy != null and createBy != ''">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="soilTemperature != null">soil_temperature,</if>
+            <if test="soilHumidity != null">soil_humidity,</if>
+            <if test="soilN != null">soil_n,</if>
+            <if test="soilP != null">soil_p,</if>
+            <if test="soilK != null">soil_k,</if>
+            <if test="rainfallA != null">rainfall_a,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
+            <if test="temperature != null">#{temperature},</if>
+            <if test="humidity != null">#{humidity},</if>
+            <if test="rainfall != null">#{rainfall},</if>
+            <if test="windDirection != null">#{windDirection},</if>
+            <if test="windSpeed != null">#{windSpeed},</if>
+            <if test="airPressure != null">#{airPressure},</if>
+            <if test="lightIntensity != null">#{lightIntensity},</if>
+            <if test="collectTime != null">#{collectTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createBy != null and createBy != ''">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="soilTemperature != null">#{soilTemperature},</if>
+            <if test="soilHumidity != null">#{soilHumidity},</if>
+            <if test="soilN != null">#{soilN},</if>
+            <if test="soilP != null">#{soilP},</if>
+            <if test="soilK != null">#{soilK},</if>
+            <if test="rainfallA != null">#{rainfallA},</if>
+         </trim>
+    </insert>
+    <insert id="insertWeatherStatistics" >
+        insert into weather_data_statistics
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="date != null">date,</if>
+            <if test="deviceId != null and deviceId != ''">device_id,</if>
+            <if test="maxTemperature != null">max_temperature,</if>
+            <if test="minTemperature != null">min_temperature,</if>
+            <if test="avgHumidity != null">avg_humidity,</if>
+            <if test="avgRainfall != null">avg_rainfall,</if>
+            <if test="avgWindSpeed != null">avg_wind_speed,</if>
+            <if test="avgSoilTemperature != null">avg_soil_temperature,</if>
+            <if test="avgSoilHumidity != null">avg_soil_humidity,</if>
+            <if test="avgSoilN != null">avg_soil_n,</if>
+            <if test="avgSoilP != null">avg_soil_p,</if>
+            <if test="avgSoilK != null">avg_soil_k,</if>
+            <if test="dateRainfallA != null">date_rainfall_a,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="date != null">#{date},</if>
+            <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
+            <if test="maxTemperature != null">#{maxTemperature},</if>
+            <if test="minTemperature != null">#{minTemperature},</if>
+            <if test="avgHumidity != null">#{avgHumidity},</if>
+            <if test="avgRainfall != null">#{avgRainfall},</if>
+            <if test="avgWindSpeed != null">#{avgWindSpeed},</if>
+            <if test="avgSoilTemperature != null">#{avgSoilTemperature},</if>
+            <if test="avgSoilHumidity != null">#{avgSoilHumidity},</if>
+            <if test="avgSoilN != null">#{avgSoilN},</if>
+            <if test="avgSoilP != null">#{avgSoilP},</if>
+            <if test="avgSoilK != null">#{avgSoilK},</if>
+            <if test="dateRainfallA != null">#{dateRainfallA},</if>
+        </trim>
+    </insert>
+
+    <update id="updateWeatherRealtimeData" parameterType="WeatherRealtimeData">
+        update weather_realtime_data
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
+            <if test="temperature != null">temperature = #{temperature},</if>
+            <if test="humidity != null">humidity = #{humidity},</if>
+            <if test="rainfall != null">rainfall = #{rainfall},</if>
+            <if test="windDirection != null">wind_direction = #{windDirection},</if>
+            <if test="windSpeed != null">wind_speed = #{windSpeed},</if>
+            <if test="airPressure != null">air_pressure = #{airPressure},</if>
+            <if test="lightIntensity != null">light_intensity = #{lightIntensity},</if>
+            <if test="collectTime != null">collect_time = #{collectTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="soilTemperature != null">soil_temperature = #{soilTemperature},</if>
+            <if test="soilHumidity != null">soil_humidity = #{soilHumidity},</if>
+            <if test="soilN != null">soil_n = #{soilN},</if>
+            <if test="soilP != null">soil_p = #{soilP},</if>
+            <if test="soilK != null">soil_k = #{soilK},</if>
+            <if test="rainfallA != null">rainfall_a = #{rainfallA},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteWeatherRealtimeDataById" parameterType="Long">
+        delete from weather_realtime_data where id = #{id}
+    </delete>
+
+    <delete id="deleteWeatherRealtimeDataByIds" parameterType="String">
+        delete from weather_realtime_data where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 7 - 1
ruoyi-modules/ruoyi-job/pom.xml

@@ -70,7 +70,13 @@
             <groupId>com.ruoyi</groupId>
             <artifactId>ruoyi-common-swagger</artifactId>
         </dependency>
-        
+
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-api-base</artifactId>
+        </dependency>
+
+
     </dependencies>
 
     <build>

+ 229 - 0
ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/DeviceStatisticsData.java

@@ -0,0 +1,229 @@
+package com.ruoyi.job.task;
+
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.base.api.RemoteBaseService;
+import com.ruoyi.base.api.domain.SensorDataStatistics;
+import com.ruoyi.base.api.domain.SensorRealtimeData;
+import com.ruoyi.base.api.domain.WeatherDataStatistics;
+import com.ruoyi.base.api.domain.WeatherRealtimeData;
+import com.ruoyi.common.core.constant.SecurityConstants;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * 定时设备统计数据
+ *
+ * @author ruoyi
+ */
+@Component("deviceStatisticsData")
+public class DeviceStatisticsData {
+
+    private static final Logger log = LoggerFactory.getLogger(DeviceStatisticsData.class);
+
+    @Autowired
+    private RemoteBaseService remoteBaseService;
+
+    public void execute() {
+        //1、获取当前日期的前一天日期的起始日期和结束日期
+        LocalDate currentDate = LocalDate.now();
+        // 获取前一天的日期
+        LocalDate previousDate = currentDate.minusDays(1);
+        // 获取前一天的起始时间
+        LocalDateTime startOfPreviousDay = LocalDateTime.of(previousDate, LocalTime.MIDNIGHT);
+        // 获取前一天的结束时间
+        LocalDateTime endOfPreviousDay = LocalDateTime.of(previousDate, LocalTime.MAX);
+        //2、查询传感器设备当前日期的前一天日期的统计数据
+        SensorRealtimeData sensorRealtimeData = new SensorRealtimeData();
+        sensorRealtimeData.setBeginCollectTime(startOfPreviousDay);
+        sensorRealtimeData.setEndCollectTime(endOfPreviousDay);
+        AjaxResult ajaxResult = remoteBaseService.listSensor(sensorRealtimeData, SecurityConstants.INNER);
+        if (ajaxResult.isSuccess()) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            List<SensorRealtimeData> sensorRealtime = ((List<Map<String, Object>>) ajaxResult.get("data"))
+                    .stream()
+                    .map(map -> objectMapper.convertValue(map, SensorRealtimeData.class))
+                    .collect(Collectors.toList());
+
+            if (!sensorRealtime.isEmpty()) {
+                // 按照 deviceId 分组统计数据
+                Map<String, List<SensorRealtimeData>> groupedByDevice = sensorRealtime.stream()
+                        .collect(Collectors.groupingBy(SensorRealtimeData::getDeviceId));
+
+                List<SensorDataStatistics> statisticsList = groupedByDevice.entrySet().stream()
+                        .map(entry -> {
+                            String deviceId = entry.getKey();
+                            List<SensorRealtimeData> dataList = entry.getValue();
+
+                            BigDecimal maxTemperature = dataList.stream()
+                                    .map(SensorRealtimeData::getTemperature)
+                                    .filter(temperature -> temperature != null)
+                                    .max(BigDecimal::compareTo)
+                                    .orElse(BigDecimal.ZERO);
+
+                            BigDecimal minTemperature = dataList.stream()
+                                    .map(SensorRealtimeData::getTemperature)
+                                    .filter(temperature -> temperature != null)
+                                    .min(BigDecimal::compareTo)
+                                    .orElse(BigDecimal.ZERO);
+
+                            double avgHumidity = dataList.stream()
+                                    .mapToDouble(data -> data.getHumidity() != null ? data.getHumidity().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            double avgLightIntensity = dataList.stream()
+                                    .mapToDouble(data -> data.getLightIntensity() != null ? data.getLightIntensity().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            double avgSoilMoisture = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilMoisture() != null ? data.getSoilMoisture().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            return new SensorDataStatistics(deviceId,previousDate ,maxTemperature, minTemperature,
+                                    avgHumidity, avgLightIntensity, avgSoilMoisture);
+                        })
+                        .collect(Collectors.toList());
+
+                // 保存到数据库
+                for (SensorDataStatistics stats : statisticsList) {
+                    remoteBaseService.addSensorStatistics(stats, SecurityConstants.INNER);
+                }
+            } else {
+                log.info("传感器数据为空");
+            }
+        }
+
+
+        WeatherRealtimeData weatherRealtimeData = new WeatherRealtimeData();
+        weatherRealtimeData.setBeginWeatherTime(startOfPreviousDay);
+        weatherRealtimeData.setEndWeatherTime(endOfPreviousDay);
+        AjaxResult ajaxResultWeather = remoteBaseService.listWeather(weatherRealtimeData, SecurityConstants.INNER);
+        if (ajaxResultWeather.isSuccess()) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            List<WeatherRealtimeData> weatherRealtime = ((List<Map<String, Object>>) ajaxResultWeather.get("data"))
+                    .stream()
+                    .map(map -> objectMapper.convertValue(map, WeatherRealtimeData.class))
+                    .collect(Collectors.toList());
+            if (!weatherRealtime.isEmpty()) {
+                // 按设备ID分组
+                Map<String, List<WeatherRealtimeData>> groupedByDevice = weatherRealtime.stream()
+                        .collect(Collectors.groupingBy(WeatherRealtimeData::getDeviceId));
+
+                List<WeatherDataStatistics> statisticsList = groupedByDevice.entrySet().stream()
+                        .map(entry -> {
+                            String deviceId = entry.getKey();
+                            List<WeatherRealtimeData> dataList = entry.getValue();
+
+                            // 最高气温
+                            BigDecimal maxTemperature = dataList.stream()
+                                    .map(WeatherRealtimeData::getTemperature)
+                                    .filter(Objects::nonNull)
+                                    .max(BigDecimal::compareTo)
+                                    .orElse(null);
+
+                            // 最低气温
+                            BigDecimal minTemperature = dataList.stream()
+                                    .map(WeatherRealtimeData::getTemperature)
+                                    .filter(Objects::nonNull)
+                                    .min(BigDecimal::compareTo)
+                                    .orElse(null);
+
+                            // 平均湿度
+                            double avgHumidity = dataList.stream()
+                                    .mapToDouble(data -> data.getHumidity() != null ? data.getHumidity().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均降雨量
+                            double avgRainfall = dataList.stream()
+                                    .mapToDouble(data -> data.getRainfall() != null ? data.getRainfall().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均风速
+                            double avgWindSpeed = dataList.stream()
+                                    .mapToDouble(data -> data.getWindSpeed() != null ? data.getWindSpeed().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均土壤温度
+                            double avgSoilTemperature = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilTemperature() != null ? data.getSoilTemperature().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均土壤水分
+                            double avgSoilHumidity = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilHumidity() != null ? data.getSoilHumidity().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均土壤氮
+                            double avgSoilN = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilN() != null ? data.getSoilN().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均土壤磷
+                            double avgSoilP = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilP() != null ? data.getSoilP().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 平均土壤钾
+                            double avgSoilK = dataList.stream()
+                                    .mapToDouble(data -> data.getSoilK() != null ? data.getSoilK().doubleValue() : 0)
+                                    .average()
+                                    .orElse(0.0);
+
+                            // 累积降雨量
+                            BigDecimal dateRainfallA = dataList.stream()
+                                    .map(WeatherRealtimeData::getRainfallA)
+                                    .filter(Objects::nonNull)
+                                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                            WeatherDataStatistics stats = new WeatherDataStatistics();
+                            stats.setDate(previousDate);
+                            stats.setDeviceId(deviceId);
+                            stats.setMaxTemperature(maxTemperature);
+                            stats.setMinTemperature(minTemperature);
+                            stats.setAvgHumidity(BigDecimal.valueOf(avgHumidity));
+                            stats.setAvgRainfall(BigDecimal.valueOf(avgRainfall));
+                            stats.setAvgWindSpeed(BigDecimal.valueOf(avgWindSpeed));
+                            stats.setAvgSoilTemperature(BigDecimal.valueOf(avgSoilTemperature));
+                            stats.setAvgSoilHumidity(BigDecimal.valueOf(avgSoilHumidity));
+                            stats.setAvgSoilN(BigDecimal.valueOf(avgSoilN));
+                            stats.setAvgSoilP(BigDecimal.valueOf(avgSoilP));
+                            stats.setAvgSoilK(BigDecimal.valueOf(avgSoilK));
+                            stats.setDateRainfallA(dateRainfallA);
+                            return stats;
+                        })
+                        .collect(Collectors.toList());
+
+                // 保存到数据库
+                for (WeatherDataStatistics stats : statisticsList) {
+                    remoteBaseService.addWeatherStatistics(stats, SecurityConstants.INNER);
+                }
+            } else {
+                log.info("气象站数据为空");
+            }
+        }
+    }
+
+}

+ 1 - 0
ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml

@@ -17,6 +17,7 @@ spring:
         server-addr: 121.4.16.100:8848
         username: nacos
         password: nacos369
+        namespace: dev
       config:
         username: nacos
         password: nacos369

+ 6 - 0
ruoyi-modules/ruoyi-system/pom.xml

@@ -83,6 +83,12 @@
             <scope>provided</scope>
         </dependency>
 
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 1 - 0
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml

@@ -17,6 +17,7 @@ spring:
         server-addr: 121.4.16.100:8848
         username: nacos
         password: nacos369
+        namespace: dev
       config:
         username: nacos
         password: nacos369

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/resources/logback.xml

@@ -58,7 +58,7 @@
     </appender>
 
     <!-- 系统模块日志级别控制  -->
-	<logger name="com.ruoyi" level="info" />
+	<logger name="com.ruoyi" level="debug" />
 	<!-- Spring日志级别控制  -->
 	<logger name="org.springframework" level="warn" />