fix (farm): 设备中心
- 添加腔型摄像机设备
This commit is contained in:
@@ -49,6 +49,8 @@ public class DeviceInfoDetailV2RespVO {
|
||||
@Schema(description = "绑定状态:1: 绑定; 0: 未绑定")
|
||||
private Integer bindingState;
|
||||
private String bindingStateName;
|
||||
@Schema(description = "设备地址 (监控摄像)")
|
||||
private String deviceUrl;
|
||||
@Schema(description = "设备坐标")
|
||||
private String point;
|
||||
|
||||
|
||||
@@ -179,11 +179,8 @@ public class DigitalCockpitController {
|
||||
|
||||
@GetMapping("/device-info/monitor-data")
|
||||
@Operation(summary = "监测数据")
|
||||
@Parameter(name = "baseId", description = "基地ID", required = true)
|
||||
public CommonResult<DeviceMonitorDataRespVO> getMonitoringData(@RequestParam("baseId") String baseId) {
|
||||
|
||||
|
||||
DeviceMonitorDataRespVO res = new DeviceMonitorDataRespVO();
|
||||
public CommonResult<List<DeviceMonitorDataRespVO>> getMonitoringData() {
|
||||
List<DeviceMonitorDataRespVO> res = deviceInfoService.deviceList();
|
||||
return success(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,33 +16,8 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class DeviceMonitorDataRespVO {
|
||||
|
||||
private Soil soilInfo;
|
||||
private Wf wfInfo;
|
||||
private VideoMonitor videoMonitorInfo;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Soil {
|
||||
private String deviceTypeName;
|
||||
private List<Row> data;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Wf {
|
||||
private String deviceTypeName;
|
||||
private List<Row> data;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class VideoMonitor {
|
||||
private String deviceTypeName;
|
||||
private List<Row> data;
|
||||
}
|
||||
private List<Row> rows;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -50,6 +25,7 @@ public class DeviceMonitorDataRespVO {
|
||||
public static class Row {
|
||||
private String name;
|
||||
private String status;
|
||||
private String url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ public class DeviceInfoDO extends BaseDO {
|
||||
* 设备状态
|
||||
*/
|
||||
private Integer deviceState;
|
||||
/**
|
||||
* 设备地址 (监控摄像)
|
||||
*/
|
||||
private String deviceUrl;
|
||||
/**
|
||||
* 绑定状态:1: 绑定; 0: 未绑定
|
||||
*/
|
||||
|
||||
@@ -47,6 +47,7 @@ public class CommonConstants {
|
||||
public static Map<Integer,String> DEVICE_STATE_MAP = new HashMap<>();
|
||||
public static Map<Integer,String> BINDING_STATE_MAP = new HashMap<>();
|
||||
public static Map<String,String> NEWS_TYPE_MAP = new HashMap<>();
|
||||
public static Map<String,String> ONLINE_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
PLAN_MAP.put(PLAN_STATUS_1, "未开始");
|
||||
@@ -78,6 +79,9 @@ public class CommonConstants {
|
||||
NEWS_TYPE_MAP.put(NEWS_TYPE_3,"热搜");
|
||||
NEWS_TYPE_MAP.put(NEWS_TYPE_4,"重磅");
|
||||
NEWS_TYPE_MAP.put(NEWS_TYPE_99,"其他");
|
||||
|
||||
ONLINE_MAP.put("online", "在线");
|
||||
ONLINE_MAP.put("offline", "离线");
|
||||
}
|
||||
|
||||
// 模型类型 (1:模型模板; 2:引用案例)
|
||||
@@ -116,4 +120,5 @@ public class CommonConstants {
|
||||
|
||||
public final static String DEVICE_TYPE_SOIL = "soil";
|
||||
public final static String DEVICE_TYPE_WF = "water_fertilizer";
|
||||
public final static String DEVICE_TYPE_VIDEO_MONITOR = "video_monitor";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.farm.service.devicealarm;
|
||||
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.devicealarm.DeviceAlarmDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
@@ -101,4 +102,5 @@ public interface DeviceAlarmService {
|
||||
* @param alarmData 报警数据
|
||||
*/
|
||||
void checkAndCreateAlarm(String deviceId, Integer alarmType, String alarmData);
|
||||
|
||||
}
|
||||
|
||||
@@ -217,7 +217,8 @@ public class DeviceClassifyServiceImpl implements DeviceClassifyService {
|
||||
x.eq(DeviceClassifyDO::getTenantId, getLoginUser().getTenantId());
|
||||
List<DeviceClassifyDO> deviceClassifyDOS = deviceClassifyMapper.selectList(x);
|
||||
|
||||
Map<String, String> typeNameMap = deviceClassifyDOS.stream().filter(device -> device.getParentId() != null && device.getParentId() == 0).collect(Collectors.toMap(e -> e.getId().toString(), DeviceClassifyDO::getName));
|
||||
Map<String, String> typeNameMap = deviceClassifyDOS.stream().filter(device -> device.getParentId() != null && device.getParentId() == 0)
|
||||
.collect(Collectors.toMap(e -> e.getId().toString(), DeviceClassifyDO::getName));
|
||||
return typeNameMap;
|
||||
}
|
||||
|
||||
@@ -226,7 +227,8 @@ public class DeviceClassifyServiceImpl implements DeviceClassifyService {
|
||||
x.eq(DeviceClassifyDO::getTenantId, getLoginUser().getTenantId());
|
||||
List<DeviceClassifyDO> deviceClassifyDOS = deviceClassifyMapper.selectList(x);
|
||||
|
||||
Map<String, String> typeCodeMap = deviceClassifyDOS.stream().filter(device -> device.getParentId() != null && device.getParentId() == 0).collect(Collectors.toMap(e -> e.getId().toString(), DeviceClassifyDO::getTypeCode));
|
||||
Map<String, String> typeCodeMap = deviceClassifyDOS.stream().filter(device -> device.getParentId() != null && device.getParentId() == 0)
|
||||
.collect(Collectors.toMap(e -> e.getId().toString(), DeviceClassifyDO::getTypeCode));
|
||||
return typeCodeMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceInfo
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.RealTimeDataResponse;
|
||||
@@ -135,4 +136,6 @@ public interface DeviceInfoService {
|
||||
*/
|
||||
DeviceInfoRespVO getDeviceInfoByDp(String baseId);
|
||||
|
||||
List<DeviceMonitorDataRespVO> deviceList();
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceInfo
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceclassify.DeviceClassifyDO;
|
||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||
@@ -24,8 +25,11 @@ import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.RealTimeDataRe
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.UnifiedLoginResponse;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.soil.history.HistoryDataListPageReqVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.soil.realtime.RealTimeDataReqVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.soil.realtime.RealTimeDataRespVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.wf.realtime.RealTimeDeviceDataReqVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.wf.realtime.RealTimeDeviceDataRespVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.wf.updateparams.UpdateDeviceStatusReqVO;
|
||||
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.wf.updateparams.UpdateDeviceStatusRespVO;
|
||||
import cn.iocoder.yudao.module.farm.service.deviceclassify.DeviceClassifyService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,6 +44,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.module.farm.dal.mysql.deviceinfo.DeviceInfoMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -357,5 +362,81 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
||||
return new DeviceInfoRespVO(totalCount, deviceInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceMonitorDataRespVO> deviceList() {
|
||||
Long tenantId = getLoginUser().getTenantId();
|
||||
LambdaQueryWrapperX<DeviceInfoDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||
wrapperX.eq(DeviceInfoDO::getTenantId, tenantId);
|
||||
wrapperX.eq(DeviceInfoDO::getDeleted, CommonConstants.NO_CODE);
|
||||
|
||||
List<DeviceInfoDO> doList = deviceInfoMapper.selectList(wrapperX);
|
||||
Map<String, List<DeviceInfoDO>> groupedByDeviceType = doList.stream().collect(Collectors.groupingBy(DeviceInfoDO::getDeviceType));
|
||||
|
||||
Map<String, String> typeCodeMap = deviceClassifyService.getTypeCodeMap();
|
||||
Map<String, String> typeNameMap = deviceClassifyService.getTypeNameMap();
|
||||
|
||||
|
||||
List<DeviceMonitorDataRespVO> res = new ArrayList<>();
|
||||
for (Map.Entry<String, List<DeviceInfoDO>> d : groupedByDeviceType.entrySet()) {
|
||||
String deviceType = d.getKey();
|
||||
List<DeviceInfoDO> list = d.getValue();
|
||||
|
||||
String typeCode = typeCodeMap.getOrDefault(deviceType, "其他");
|
||||
List<DeviceMonitorDataRespVO.Row> rows = this.getRealTimeList(typeCode, list);
|
||||
res.add(new DeviceMonitorDataRespVO(typeNameMap.get(deviceType), rows));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<DeviceMonitorDataRespVO.Row> getRealTimeList(String typeCode, List<DeviceInfoDO> doList) {
|
||||
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
||||
|
||||
for (DeviceInfoDO d : doList) {
|
||||
// 获取设备商数据
|
||||
switch (typeCode) {
|
||||
case DEVICE_TYPE_SOIL:
|
||||
DeviceInfoDetailV2RespVO.SoilInfo soilInfo = getSoilInfo(d.getDeviceUniqueId(), d.getPlotId(), 12);
|
||||
List<DeviceMonitorDataRespVO.Row> rows1 = this.getSoilData(d.getDeviceName(), soilInfo);
|
||||
rows.addAll(rows1);
|
||||
break;
|
||||
case DEVICE_TYPE_WF:
|
||||
DeviceInfoDetailV2RespVO.WfInfo wfInfo = getWfInfo(d.getDeviceUniqueId(), d.getPlotId());
|
||||
List<DeviceMonitorDataRespVO.Row> rows2 = this.getWfData( wfInfo);
|
||||
rows.addAll(rows2);
|
||||
break;
|
||||
case DEVICE_TYPE_VIDEO_MONITOR:
|
||||
rows.add(new DeviceMonitorDataRespVO.Row(d.getDeviceName(),DEVICE_STATE_MAP.get(d.getDeviceState()),d.getDeviceUrl()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<DeviceMonitorDataRespVO.Row> getWfData(DeviceInfoDetailV2RespVO.WfInfo wfInfo) {
|
||||
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
||||
|
||||
RealTimeDeviceDataRespVO realTimeDeviceDataRespVO = (RealTimeDeviceDataRespVO) wfInfo.getRealTimeData().getData();
|
||||
List<RealTimeDeviceDataRespVO.DataRow> data = realTimeDeviceDataRespVO.getData();
|
||||
for (RealTimeDeviceDataRespVO.DataRow d : data) {
|
||||
rows.add(new DeviceMonitorDataRespVO.Row(d.getPropertyName(), d.getFormatValue(), ""));
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
private List<DeviceMonitorDataRespVO.Row> getSoilData(String name, DeviceInfoDetailV2RespVO.SoilInfo soilInfo) {
|
||||
List<DeviceMonitorDataRespVO.Row> rows = new ArrayList<>();
|
||||
|
||||
RealTimeDataRespVO realTimeDataRespVO = (RealTimeDataRespVO) soilInfo.getRealTimeData().getData();
|
||||
List<RealTimeDataRespVO.DeviceInfo> data = realTimeDataRespVO.getData();
|
||||
for (RealTimeDataRespVO.DeviceInfo d : data) {
|
||||
rows.add(new DeviceMonitorDataRespVO.Row(name, ONLINE_MAP.get(d.getStatus()), ""));
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user