feat (farm): 微信端API
- 农业资讯(模拟数据) - 进行中农事计划 (模拟数据) - 异常信息 (模拟数据) - 获取设备信息 (模拟数据)
This commit is contained in:
@@ -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<PageResult<FarmInformationRespVO>> getFarmInformation(@Valid FarmInformationReqVO req) {
|
||||
PageResult<FarmInformationRespVO> result = farmInformationService.getFarmInformationPage(req);
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
@GetMapping("/farming-record/executing-state")
|
||||
@Operation(summary = "进行中农事计划")
|
||||
public CommonResult<RecordExecutingStateRespVO> getFarmingRecordExecutingState(RecordExecutingStateReqVO req) {
|
||||
|
||||
return CommonResult.success(new RecordExecutingStateRespVO(20));
|
||||
}
|
||||
|
||||
@GetMapping("/message-center/abnormal-state")
|
||||
@Operation(summary = "异常信息")
|
||||
public CommonResult<List<AbnormalMessageRespVO>> getAbnormalMessage() {
|
||||
List<AbnormalMessageRespVO> 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<DeviceInfoRespVO> 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<FarmInformationDO> {
|
||||
|
||||
}
|
||||
@@ -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<FarmInformationRespVO> getFarmInformationPage(FarmInformationReqVO req);
|
||||
}
|
||||
@@ -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<FarmInformationRespVO> getFarmInformationPage(FarmInformationReqVO req) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.farm.dal.mysql.farminformation.FarmInformationMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user