diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/WxController.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/WxController.java new file mode 100644 index 00000000..d33896f2 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/WxController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.*; +import cn.iocoder.yudao.module.farm.service.deviceinfo.DeviceInfoService; +import cn.iocoder.yudao.module.farm.service.farminformation.FarmInformationService; +import cn.iocoder.yudao.module.farm.service.farmingrecord.FarmingRecordService; +import cn.iocoder.yudao.module.farm.service.messagecenter.MessageCenterService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @description: 微信端 + * @author: binda + * @date: 2025/9/25 17:05 + */ +@Tag(name = "微信端") +@RestController +@RequestMapping("/farm/wx") +@Validated +public class WxController { + + private final FarmInformationService farmInformationService; + private final DeviceInfoService deviceInfoService; + private final FarmingRecordService farmingRecordService; + private final MessageCenterService messageCenterService; + + public WxController(FarmInformationService farmInformationService, DeviceInfoService deviceInfoService, FarmingRecordService farmingRecordService, MessageCenterService messageCenterService) { + this.farmInformationService = farmInformationService; + this.deviceInfoService = deviceInfoService; + this.farmingRecordService = farmingRecordService; + this.messageCenterService = messageCenterService; + } + + + @Operation(summary = "农业资讯") + @GetMapping("/farm-information/page") + public CommonResult> getFarmInformation(@Valid FarmInformationReqVO req) { + PageResult result = farmInformationService.getFarmInformationPage(req); + return CommonResult.success(result); + } + + @GetMapping("/farming-record/executing-state") + @Operation(summary = "进行中农事计划") + public CommonResult getFarmingRecordExecutingState(RecordExecutingStateReqVO req) { + + return CommonResult.success(new RecordExecutingStateRespVO(20)); + } + + @GetMapping("/message-center/abnormal-state") + @Operation(summary = "异常信息") + public CommonResult> getAbnormalMessage() { + List res = new ArrayList<>(); + res.add(new AbnormalMessageRespVO("土壤湿度过低", "低于3%")); + res.add(new AbnormalMessageRespVO("土壤湿度过低", "低于3%")); + res.add(new AbnormalMessageRespVO("土壤湿度过低", "低于3%")); + + return CommonResult.success(res); + } + + @GetMapping("/device-info/get") + @Operation(summary = "获取设备信息") + @Parameter(name = "baseId", description = "基地编号") + public CommonResult getDeviceInfoList(@RequestParam("baseId") String baseId) { + DeviceInfoRespVO.DeviceRealData realData = new DeviceInfoRespVO.DeviceRealData("剩余电量", 100, "大气湿度", 0, "大气温度", 0); + + DeviceInfoRespVO.DeviceDetail deviceDetail = new DeviceInfoRespVO.DeviceDetail(); + deviceDetail.setId("DEV001"); + deviceDetail.setDeviceUniqueId("SN202405270001"); + deviceDetail.setDeviceType("DT001"); + deviceDetail.setDeviceTypeName("农业环境气象监测-新"); + deviceDetail.setImage("http://223.83.152.93:9000/farm/20250909/trsqjc_1757398720478.png"); + deviceDetail.setImageList(Arrays.asList("http://223.83.152.93:9000/farm/20250909/trsqjc_1757398720478.png")); + deviceDetail.setDeviceState(1); + deviceDetail.setDeviceStateName("在线"); + deviceDetail.setBindingState(1); + deviceDetail.setBindingStateName("已绑定"); + deviceDetail.setPlotName("门村村小香薯种植基地"); + deviceDetail.setRealData(realData); + + DeviceInfoRespVO d = new DeviceInfoRespVO(); + d.setTotal(1); + d.setOnlineTotal(1); + d.setOfflineTotal(0); + d.setDeviceDetail(deviceDetail); + + return CommonResult.success(d); + } + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageReqVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageReqVO.java new file mode 100644 index 00000000..ed64029b --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageReqVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author: binda + * @date: 2025/9/25 19:09 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AbnormalMessageReqVO { + private String xx; +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageRespVO.java new file mode 100644 index 00000000..5d8a63dd --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/AbnormalMessageRespVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 19:06 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AbnormalMessageRespVO { + private String name; + private String value; +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceInfoRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceInfoRespVO.java new file mode 100644 index 00000000..c055d354 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/DeviceInfoRespVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 19:13 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DeviceInfoRespVO { + + private Integer total; + private Integer onlineTotal; + private Integer offlineTotal; + private DeviceDetail deviceDetail; + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class DeviceDetail{ + private String id; + @Schema(description = "设备全局唯一标识(设备厂商提供)", requiredMode = Schema.RequiredMode.REQUIRED) + private String deviceUniqueId; + @Schema(description = "设备类型 (设备类型ID)") + private String deviceType; + @Schema(description = "设备类型 (设备类型-名称)") + private String deviceTypeName; + @Schema(description = "设备图片") + private String image; + private List imageList; + @Schema(description = "设备状态:0-未激活,1-在线,2-离线,3-维护中,4-故障") + private Integer deviceState; + @Schema(description = "设备状态名称") + private String deviceStateName; + @Schema(description = "绑定状态:1: 绑定; 0: 未绑定") + private Integer bindingState; + private String bindingStateName; + @Schema(description = "地块名称") + private String plotName; + @Schema(description = "设备实时数据") + private DeviceRealData realData; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class DeviceRealData{ + private String k1; + private Integer v1; + private String k2; + private Integer v2; + private String k3; + private Integer v3; + } + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationReqVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationReqVO.java new file mode 100644 index 00000000..3c560a96 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 17:33 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FarmInformationReqVO extends PageParam { + private String id; +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationRespVO.java new file mode 100644 index 00000000..01d81a49 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/FarmInformationRespVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author: binda + * @date: 2025/9/25 17:09 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FarmInformationRespVO { + + @Schema(description = "资讯类型 (1: 要闻; 99:其他)") + private String infoType; + private String infoTypeName; + @Schema(description = "资讯标题") + private String infoTitle; + @Schema(description = "资讯正文") + private String infoText; + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateReqVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateReqVO.java new file mode 100644 index 00000000..37888f0f --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateReqVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * @description: TODO + * @author: binda + * @date: 2025/9/25 19:01 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class RecordExecutingStateReqVO { + + @Schema(description = "农事计划开始日期") + private LocalDate startDate; + @Schema(description = "农事计划结束日期") + private LocalDate endDate; + + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateRespVO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateRespVO.java new file mode 100644 index 00000000..e1909f75 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/wx/vo/RecordExecutingStateRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.farm.controller.admin.wx.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * @description: TODO + * @author: binda + * @date: 2025/9/25 19:01 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class RecordExecutingStateRespVO { + + private Integer total; + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/farminformation/FarmInformationDO.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/farminformation/FarmInformationDO.java new file mode 100644 index 00000000..a99133a2 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/farminformation/FarmInformationDO.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.farm.dal.dataobject.farminformation; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 17:22 + */ +@TableName("farm_information") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FarmInformationDO extends BaseDO { + + @TableId + private String id; + private String infoType; + private String infoTitle; + private String infoText; + private String tenantId; + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/farminformation/FarmInformationMapper.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/farminformation/FarmInformationMapper.java new file mode 100644 index 00000000..27cf3ed2 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/farminformation/FarmInformationMapper.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.farm.dal.mysql.farminformation; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.farm.dal.dataobject.farminformation.FarmInformationDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * @description: 农业资讯 + * @author: binda + * @data: 2025/9/25 17:20 + */ +@Mapper +public interface FarmInformationMapper extends BaseMapperX { + +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationService.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationService.java new file mode 100644 index 00000000..fec37b14 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationService.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.farm.service.farminformation; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.FarmInformationReqVO; +import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.FarmInformationRespVO; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 17:27 + */ +public interface FarmInformationService { + PageResult getFarmInformationPage(FarmInformationReqVO req); +} diff --git a/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationServiceImpl.java b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationServiceImpl.java new file mode 100644 index 00000000..a89460d4 --- /dev/null +++ b/yudao-module-farm/src/main/java/cn/iocoder/yudao/module/farm/service/farminformation/FarmInformationServiceImpl.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.farm.service.farminformation; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.FarmInformationReqVO; +import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.FarmInformationRespVO; +import org.springframework.stereotype.Service; + +/** + * @description: + * @author: binda + * @date: 2025/9/25 17:27 + */ +@Service +public class FarmInformationServiceImpl implements FarmInformationService{ + + @Override + public PageResult getFarmInformationPage(FarmInformationReqVO req) { + + return null; + } + +} diff --git a/yudao-module-farm/src/main/resources/mapper/farmInformation/FarmInformationMapper.xml b/yudao-module-farm/src/main/resources/mapper/farmInformation/FarmInformationMapper.xml new file mode 100644 index 00000000..4ad6f9cf --- /dev/null +++ b/yudao-module-farm/src/main/resources/mapper/farmInformation/FarmInformationMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file