fix (farm): 设备中心
- 水肥机设备
This commit is contained in:
@@ -28,68 +28,68 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
*/
|
||||
@Tag(name = "管理后台 - 大屏")
|
||||
@RestController
|
||||
@RequestMapping("/farm/big-screen")
|
||||
//@RequestMapping("/farm/big-screen")
|
||||
@Validated
|
||||
public class BigScreenController {
|
||||
|
||||
@Resource
|
||||
private BigScreenService bigScreenService;
|
||||
|
||||
// 基地板块 —— 基础信息
|
||||
@Operation(summary = "基地板块-基础信息")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/base/basic-info")
|
||||
public CommonResult<BaseBasicInfoRespVO> getBaseBasicInfo(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getBaseBasicInfo(baseId));
|
||||
}
|
||||
|
||||
// 基地板块 —— 基地面积统计
|
||||
@Operation(summary = "基地板块-基地面积统计")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/base/area-stats")
|
||||
public CommonResult<BaseAreaStatRespVO> getBaseAreaStats(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getBaseAreaStats(baseId));
|
||||
}
|
||||
|
||||
// 基地板块 —— 基地数量统计(地块、设施等数量)
|
||||
@Operation(summary = "基地板块-基地数量统计")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/base/count-stats")
|
||||
public CommonResult<BaseCountStatRespVO> getBaseCountStats(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getBaseCountStats(baseId));
|
||||
}
|
||||
|
||||
// 基地板块 —— 地块统计
|
||||
@Operation(summary = "基地板块-地块统计")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/base/plot-stats")
|
||||
public CommonResult<List<BasePlotStatRespVO>> getBasePlotStats(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getBasePlotStats(baseId));
|
||||
}
|
||||
|
||||
// 种植统计 —— 种植分布(饼图)
|
||||
@Operation(summary = "种植统计-种植分布饼图")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/planting/distribution-pie")
|
||||
public CommonResult<List<PlantingDistributionPieItemVO>> getPlantingDistributionPie(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getPlantingDistributionPie(baseId));
|
||||
}
|
||||
|
||||
// 种植统计 —— 产量分布(饼图)
|
||||
@Operation(summary = "种植统计-产量分布饼图")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/planting/yield-distribution-pie")
|
||||
public CommonResult<List<YieldDistributionPieItemVO>> getYieldDistributionPie(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getYieldDistributionPie(baseId));
|
||||
}
|
||||
|
||||
// 种植统计 —— 实际/预计产量对比(柱状图)
|
||||
@Operation(summary = "种植统计-实际预计产量对比柱状图")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
@GetMapping("/planting/yield-compare-bar")
|
||||
public CommonResult<List<YieldCompareBarItemVO>> getYieldCompareBar(@RequestParam("baseId") String baseId) {
|
||||
return success(bigScreenService.getYieldCompareBar(baseId));
|
||||
}
|
||||
// @Resource
|
||||
// private BigScreenService bigScreenService;
|
||||
//
|
||||
// // 基地板块 —— 基础信息
|
||||
// @Operation(summary = "基地板块-基础信息")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/base/basic-info")
|
||||
// public CommonResult<BaseBasicInfoRespVO> getBaseBasicInfo(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getBaseBasicInfo(baseId));
|
||||
// }
|
||||
//
|
||||
// // 基地板块 —— 基地面积统计
|
||||
// @Operation(summary = "基地板块-基地面积统计")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/base/area-stats")
|
||||
// public CommonResult<BaseAreaStatRespVO> getBaseAreaStats(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getBaseAreaStats(baseId));
|
||||
// }
|
||||
//
|
||||
// // 基地板块 —— 基地数量统计(地块、设施等数量)
|
||||
// @Operation(summary = "基地板块-基地数量统计")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/base/count-stats")
|
||||
// public CommonResult<BaseCountStatRespVO> getBaseCountStats(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getBaseCountStats(baseId));
|
||||
// }
|
||||
//
|
||||
// // 基地板块 —— 地块统计
|
||||
// @Operation(summary = "基地板块-地块统计")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/base/plot-stats")
|
||||
// public CommonResult<List<BasePlotStatRespVO>> getBasePlotStats(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getBasePlotStats(baseId));
|
||||
// }
|
||||
//
|
||||
// // 种植统计 —— 种植分布(饼图)
|
||||
// @Operation(summary = "种植统计-种植分布饼图")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/planting/distribution-pie")
|
||||
// public CommonResult<List<PlantingDistributionPieItemVO>> getPlantingDistributionPie(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getPlantingDistributionPie(baseId));
|
||||
// }
|
||||
//
|
||||
// // 种植统计 —— 产量分布(饼图)
|
||||
// @Operation(summary = "种植统计-产量分布饼图")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/planting/yield-distribution-pie")
|
||||
// public CommonResult<List<YieldDistributionPieItemVO>> getYieldDistributionPie(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getYieldDistributionPie(baseId));
|
||||
// }
|
||||
//
|
||||
// // 种植统计 —— 实际/预计产量对比(柱状图)
|
||||
// @Operation(summary = "种植统计-实际预计产量对比柱状图")
|
||||
// @Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
// @GetMapping("/planting/yield-compare-bar")
|
||||
// public CommonResult<List<YieldCompareBarItemVO>> getYieldCompareBar(@RequestParam("baseId") String baseId) {
|
||||
// return success(bigScreenService.getYieldCompareBar(baseId));
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @description: 设备商接口
|
||||
* @author: binda
|
||||
* @date: 2025/9/25 20:44
|
||||
*/
|
||||
|
||||
@@ -52,6 +52,8 @@ public class DeviceConf {
|
||||
private String hosts;
|
||||
private String username;
|
||||
private String password;
|
||||
private String clientId;
|
||||
private String grantType;
|
||||
private String url1; // 登录获取token POST
|
||||
private String url2; // 获取设备列表 GET
|
||||
private String url3; // 获取实时数据 GET
|
||||
|
||||
@@ -15,4 +15,6 @@ import lombok.NoArgsConstructor;
|
||||
public class LoginReqVO {
|
||||
private String username;
|
||||
private String password;
|
||||
private String clientId;
|
||||
private String grantType;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,21 @@ import lombok.NoArgsConstructor;
|
||||
public class LoginRespVO {
|
||||
private String code;
|
||||
private String msg;
|
||||
private String token;
|
||||
private Data data;
|
||||
|
||||
@lombok.Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Data {
|
||||
|
||||
private String scope;
|
||||
private String openid;
|
||||
private String access_token;
|
||||
private String refresh_token;
|
||||
private Long expire_in;
|
||||
private Long refresh_expire_in;
|
||||
private String client_id;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 设备实时数据
|
||||
* @author: binda
|
||||
@@ -15,21 +16,70 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RealTimeDeviceDataRespVO {
|
||||
private String deviceId;
|
||||
private String name;
|
||||
private String stateText; // 是否在线 中文
|
||||
private String stateValue; // 是否在线 编码
|
||||
private List<ControlProperty> controlProperties;
|
||||
|
||||
private String code;
|
||||
private String msg;
|
||||
private List<DataRow> data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ControlProperty {
|
||||
private String id; // 开关标识
|
||||
private String name;
|
||||
private String operateType; // 设备类型
|
||||
private String operateValue;
|
||||
private String value;
|
||||
public static class DataRow {
|
||||
private String id;
|
||||
private String deviceId;
|
||||
private String property; // 重要参数
|
||||
private String propertyName;
|
||||
private String type;
|
||||
private Boolean value; // 重要参数
|
||||
private Boolean originValue;
|
||||
private String formatValue;
|
||||
private String createTime;
|
||||
private String timestamp;
|
||||
private Expands expands;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Expands {
|
||||
private String id;
|
||||
private String name;
|
||||
private ValueType valueType;
|
||||
private ExpandsInner expands;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ValueType {
|
||||
private String type;
|
||||
private String falseValue;
|
||||
private String falseText;
|
||||
private String trueValue;
|
||||
private String trueText;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ExpandsInner {
|
||||
private String source;
|
||||
private String groupId;
|
||||
private String groupName;
|
||||
private Boolean otherEdit;
|
||||
private List<Metrics> metrics;
|
||||
private List<String> type;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Metrics{
|
||||
private String id;
|
||||
private String name;
|
||||
private String value;
|
||||
private Boolean range;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,12 @@ public class WaterFertilizerService extends AbstractDeviceService {
|
||||
protected UnifiedLoginResponse doLogin() {
|
||||
try {
|
||||
// 转换请求参数
|
||||
LoginReqVO wfRequest = new LoginReqVO(deviceConf.getWaterAndFertilizer().getUsername(), deviceConf.getWaterAndFertilizer().getPassword());
|
||||
LoginReqVO wfRequest = new LoginReqVO(
|
||||
deviceConf.getWaterAndFertilizer().getUsername(),
|
||||
deviceConf.getWaterAndFertilizer().getPassword(),
|
||||
deviceConf.getWaterAndFertilizer().getClientId(),
|
||||
deviceConf.getWaterAndFertilizer().getGrantType()
|
||||
);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json = objectMapper.writeValueAsString(wfRequest);
|
||||
// 调用水肥机设备厂商API POST 请求方式
|
||||
@@ -127,13 +132,15 @@ public class WaterFertilizerService extends AbstractDeviceService {
|
||||
return UnifiedLoginResponse.error(vendorResponse.getMsg());
|
||||
}
|
||||
|
||||
String access_token = vendorResponse.getData().getAccess_token();
|
||||
|
||||
// 水肥机响应缺少一些字段,设置默认值
|
||||
long currentTime = System.currentTimeMillis();
|
||||
UnifiedLoginResponse.LoginData loginData = new UnifiedLoginResponse.LoginData(
|
||||
"wf-login-sign-" + currentTime, // 生成登录标识
|
||||
currentTime, // token生成时间
|
||||
currentTime + 3600000 * 2, // 2小时后过期
|
||||
vendorResponse.getToken() // 实际token
|
||||
access_token // 实际token
|
||||
);
|
||||
|
||||
return UnifiedLoginResponse.success(loginData);
|
||||
@@ -141,9 +148,11 @@ public class WaterFertilizerService extends AbstractDeviceService {
|
||||
|
||||
private DevicePageRespVO callWFDeviceListApi(String token, DevicePageReqVO request) {
|
||||
String url = deviceConf.getWaterAndFertilizer().getHosts() + deviceConf.getWaterAndFertilizer().getUrl2();
|
||||
String clientId = deviceConf.getWaterAndFertilizer().getClientId();
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", "Bearer " + token);
|
||||
headers.put("clientId", clientId);
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
if (request.getUserCode() != null) {
|
||||
@@ -183,18 +192,22 @@ public class WaterFertilizerService extends AbstractDeviceService {
|
||||
private RealTimeDeviceDataRespVO callWFRealTimeDataApi(String token, RealTimeDeviceDataReqVO request) {
|
||||
String url = deviceConf.getWaterAndFertilizer().getHosts() + deviceConf.getWaterAndFertilizer().getUrl3();
|
||||
url = MessageFormat.format(url,request.getDeviceId());
|
||||
String clientId = deviceConf.getWaterAndFertilizer().getClientId();
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", "Bearer " + token);
|
||||
headers.put("clientId", clientId);
|
||||
|
||||
return httpClientUtils.doGet(url, headers, null, RealTimeDeviceDataRespVO.class);
|
||||
}
|
||||
|
||||
private UpdateDeviceStatusRespVO callWFUpdateDeviceApi(String token, UpdateDeviceStatusReqVO request) {
|
||||
String url = deviceConf.getWaterAndFertilizer().getHosts() + deviceConf.getWaterAndFertilizer().getUrl4();
|
||||
String clientId = deviceConf.getWaterAndFertilizer().getClientId();
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", "Bearer " + token);
|
||||
headers.put("clientId", clientId);
|
||||
|
||||
// 构建请求体,包含设备ID和参数
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
|
||||
@@ -209,14 +209,13 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
String token = login.getData().getToken();
|
||||
|
||||
// 获取设备列表
|
||||
DeviceListResponse response = equipmentProducerManager.getDeviceList(DEVICE_TYPE_WF, tenantId, token, null);
|
||||
System.out.println("获取设备列表:"+response);
|
||||
// DeviceListResponse response = equipmentProducerManager.getDeviceList(DEVICE_TYPE_WF, tenantId, token, null);
|
||||
// System.out.println("获取设备列表:"+response);
|
||||
|
||||
// 实时数据
|
||||
RealTimeDeviceDataReqVO wfRequest = new RealTimeDeviceDataReqVO(deviceUniqueId);
|
||||
RealTimeDataResponse realTimeData = equipmentProducerManager.getRealTimeData(DEVICE_TYPE_WF, tenantId, token, wfRequest);
|
||||
|
||||
|
||||
return new DeviceInfoDetailV2RespVO.WfInfo(deviceUniqueId,realTimeData);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ public class HttpClientUtil {
|
||||
}
|
||||
|
||||
private String getBaseUrl(String wmsHosts) {
|
||||
if (wmsHosts.startsWith("https://")) {
|
||||
return wmsHosts;
|
||||
}
|
||||
return "http://" + wmsHosts ;
|
||||
}
|
||||
|
||||
|
||||
@@ -344,10 +344,10 @@ spring:
|
||||
keep-alive: 60s # 空闲线程存活时间
|
||||
# 万懋wms系统
|
||||
wms:
|
||||
hosts: ${wms.hosts}
|
||||
url_1: ${wms.url_1}
|
||||
hosts: ${wanmao.wms.hosts}
|
||||
url_1: ${wanmao.wms.url_1}
|
||||
|
||||
# 万懋设备管理
|
||||
# 吉水设备管理
|
||||
device-manager:
|
||||
# 四情 (文档来源: 物连网农业四情采集api协议.pdf 版本:v2.0.3 日期:2022.08.16)
|
||||
four-situations:
|
||||
@@ -375,7 +375,11 @@ device-manager:
|
||||
hosts: https://ryy.mythiot.com
|
||||
username: jishui
|
||||
password: jishui@888
|
||||
url-1: /prod-api/login # 获取公钥 POST
|
||||
clientId: 8db4e3f233bba68d069d2f628ee8a621 # 固定值
|
||||
grantType: password # 固定值
|
||||
url-1: /prod-api/auth/getToken # 获取公钥 POST
|
||||
url-2: /prod-api/agriculture/deviceMain/list # 获取设备列表 GET
|
||||
url-3: /prod-api/agriculture/deviceMain/getDeviceAllPropertyAndDataSimple/{0} # 获取设备实时状态 GET {0}: deviceId
|
||||
url-3: /prod-api/agriculture/deviceMain/getDeviceAllPropertyAndData/{0} # 获取设备实时状态 GET {0}: deviceId
|
||||
url-4: /prod-api/agriculture/deviceMain/updateDeviceStatus # 更改设备属性 POST
|
||||
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ redis.database=5
|
||||
redis.password=luxifa970219
|
||||
|
||||
wm.wx.mp.app-id=wx508d9a9ab84f67d0
|
||||
wm.wx.mp.secret=88b5a8deca40c8f86d064717d82d8485
|
||||
wm.wx.mp.secret=92c571b9973f9078c11da47a16c4094c
|
||||
wm.wx.miniapp.app-id=wx508d9a9ab84f67d0
|
||||
wm.wx.miniapp.secret=88b5a8deca40c8f86d064717d82d8485
|
||||
wm.wx.miniapp.secret=92c571b9973f9078c11da47a16c4094c
|
||||
|
||||
# ????
|
||||
wms.hosts=https://wms.simple.gltec.cn/prod-ai
|
||||
wanmao.wms.hosts=https://wms.simple.gltec.cn/prod-api
|
||||
# ????
|
||||
#wms.hosts=47.111.15.9:8074/prod-api
|
||||
wms.url_1=getTenantByMobile
|
||||
#wanmao.wms.hosts=47.111.15.9:8074/prod-api
|
||||
wanmao.wms.url_1=getTenantByMobile
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user