查询站点已绑定/未绑定设备列表,气象设备实时数据接口返回格式调整等

This commit is contained in:
mi9688
2024-12-03 17:38:57 +08:00
parent 6c835034cd
commit 79cdd499f7
11 changed files with 125 additions and 43 deletions

View File

@ -52,17 +52,21 @@ public class DeviceHistoryDataController extends BaseController {
public TableDataInfo getMeteorologyHistoryData(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology){ public TableDataInfo getMeteorologyHistoryData(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology){
startPage(); startPage();
List<DeviceRealtimedataMeteorology> list = new LambdaQueryChainWrapper<>(deviceRealtimedataMeteorologyMapper) List<DeviceRealtimedataMeteorology> list = new LambdaQueryChainWrapper<>(deviceRealtimedataMeteorologyMapper)
.eq(DeviceRealtimedataMeteorology::getDeviceId,deviceRealtimedataMeteorology.getDeviceId()).list(); .eq(DeviceRealtimedataMeteorology::getDeviceId,deviceRealtimedataMeteorology.getDeviceId())
.orderByDesc(DeviceRealtimedataMeteorology::getRealTime)
.list();
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 获取墒情实时数据 * 获取墒情设备历史数据
*/ */
@GetMapping("/moisture") @GetMapping("/moisture")
public TableDataInfo getMoistureHistoryData(DeviceRealtimedataMoisture deviceRealtimedataMoisture){ public TableDataInfo getMoistureHistoryData(DeviceRealtimedataMoisture deviceRealtimedataMoisture){
startPage(); startPage();
List<DeviceRealtimedataMoisture> list = new LambdaQueryChainWrapper<>(deviceRealtimedataMoistureMapper) List<DeviceRealtimedataMoisture> list = new LambdaQueryChainWrapper<>(deviceRealtimedataMoistureMapper)
.eq(DeviceRealtimedataMoisture::getDeviceId,deviceRealtimedataMoisture.getDeviceId()).list(); .eq(DeviceRealtimedataMoisture::getDeviceId,deviceRealtimedataMoisture.getDeviceId())
.orderByDesc(DeviceRealtimedataMoisture::getRealTime)
.list();
return getDataTable(list); return getDataTable(list);
} }
/** /**

View File

@ -9,11 +9,16 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* 监控设备实时数据
*/
@RestController @RestController
@RequestMapping("/device/real/data") @RequestMapping("/device/real/data")
public class DeviceMonitorController extends BaseController { public class DeviceMonitorController extends BaseController {
@Autowired @Autowired
private YingshiyunService yingshiyunService; private YingshiyunService yingshiyunService;
@GetMapping("/monitor") @GetMapping("/monitor")
public AjaxResult getVideoUrl(@Param("deviceId") String deviceId){ public AjaxResult getVideoUrl(@Param("deviceId") String deviceId){
return success(yingshiyunService.getVideoPlayUrl(deviceId)); return success(yingshiyunService.getVideoPlayUrl(deviceId));

View File

@ -19,7 +19,6 @@ public class DeviceRealtimedataMeteorologyController {
/** /**
* 获取最新的一条气象数据 * 获取最新的一条气象数据
* @return
*/ */
@GetMapping(value = "/weather/realtimedata") @GetMapping(value = "/weather/realtimedata")
public AjaxResult getLatestWeatherRealtimedata() { public AjaxResult getLatestWeatherRealtimedata() {

View File

@ -0,0 +1,44 @@
package com.fastbee.data.controller.gis.water;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.ggroup.domain.GSiteDevice;
import com.fastbee.ggroup.domain.vo.GSiteDeviceVo;
import com.fastbee.ggroup.service.IGSiteDeviceService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/gis/site/device")
@Api(tags = "站点设备")
public class GSiteDeviceController extends BaseController {
@Autowired
private IGSiteDeviceService gSiteDeviceService;
/**
* 查询站点未关联的设备列表
* @param siteId 站点id
* @param groupId 设备组id
*/
@GetMapping("/unbind")
public AjaxResult getUnbindDeviceList(Long siteId,Long groupId) {
List<GSiteDeviceVo> gSiteDeviceList = gSiteDeviceService.selectUnbindDeviceList(siteId,groupId);
return AjaxResult.success(gSiteDeviceList);
}
/**
* 查询站点已关联的设备列表
* @param siteId 站点id
* @param groupId 设备组id
*/
@GetMapping("/bind")
public AjaxResult getBindDeviceList(Long siteId,Long groupId) {
List<GSiteDeviceVo> gSiteDeviceList = gSiteDeviceService.selectBindDeviceList(siteId,groupId);
return AjaxResult.success(gSiteDeviceList);
}
}

View File

@ -68,5 +68,5 @@ public interface IDeviceRealtimedataMeteorologyService extends IService<DeviceRe
* 获取最新的一条气象数据 * 获取最新的一条气象数据
* @return * @return
*/ */
public List<DeviceProperties> getLatestWeatherRealtimedata(); public Map<String,Object> getLatestWeatherRealtimedata();
} }

View File

@ -106,15 +106,17 @@ public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<Device
* @return * @return
*/ */
@Override @Override
public List<DeviceProperties> getLatestWeatherRealtimedata(){ public Map<String,Object> getLatestWeatherRealtimedata(){
Map<String,Object> rest= new HashMap<>();
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("real_time"); queryWrapper.orderByDesc("real_time");
queryWrapper.last("limit 1"); queryWrapper.last("limit 1");
DeviceRealtimedataMeteorology meteorology = deviceRealtimedataMeteorologyMapper.selectOne(queryWrapper); DeviceRealtimedataMeteorology meteorology = deviceRealtimedataMeteorologyMapper.selectOne(queryWrapper);
List<DeviceProperties> devicePropertiesList = new ArrayList<>(); List<DeviceProperties> devicePropertiesList = new ArrayList<>();
rest.put("props",devicePropertiesList);
if(Objects.isNull(meteorology)){ if(Objects.isNull(meteorology)){
return devicePropertiesList; return rest;
} }
devicePropertiesList.add(DeviceProperties.builder().name("空气温度").value(meteorology.getAirTemp().toString()).unit("°C").build()); devicePropertiesList.add(DeviceProperties.builder().name("空气温度").value(meteorology.getAirTemp().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("空气湿度").value(meteorology.getAirHumi().toString()).unit("°C").build()); devicePropertiesList.add(DeviceProperties.builder().name("空气湿度").value(meteorology.getAirHumi().toString()).unit("°C").build());
@ -129,6 +131,10 @@ public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<Device
devicePropertiesList.add(DeviceProperties.builder().name("蒸发量").value(meteorology.getZhengfa().toString()).unit("t/h").build()); devicePropertiesList.add(DeviceProperties.builder().name("蒸发量").value(meteorology.getZhengfa().toString()).unit("t/h").build());
devicePropertiesList.add(DeviceProperties.builder().name("土壤温度").value(meteorology.getSoilTemp().toString()).unit("°C").build()); devicePropertiesList.add(DeviceProperties.builder().name("土壤温度").value(meteorology.getSoilTemp().toString()).unit("°C").build());
devicePropertiesList.add(DeviceProperties.builder().name("土壤湿度").value(meteorology.getSoilHumi().toString()).unit("°C").build()); devicePropertiesList.add(DeviceProperties.builder().name("土壤湿度").value(meteorology.getSoilHumi().toString()).unit("°C").build());
return devicePropertiesList;
Map<String,Object> info=new HashMap<>();
info.put("deviceEncoding", meteorology.getDeviceId());
rest.put("info",info);
return rest;
} }
} }

View File

@ -0,0 +1,11 @@
package com.fastbee.ggroup.domain.vo;
import lombok.Data;
@Data
public class GSiteDeviceVo {
private Long deviceId;//设备id
private String deviceName ;//设备名称
private Long siteId ;//站点id
}

View File

@ -3,6 +3,7 @@ package com.fastbee.ggroup.service;
import java.util.List; import java.util.List;
import com.fastbee.ggroup.domain.GSiteDevice; import com.fastbee.ggroup.domain.GSiteDevice;
import com.fastbee.ggroup.domain.dto.GSiteDeviceDto; import com.fastbee.ggroup.domain.dto.GSiteDeviceDto;
import com.fastbee.ggroup.domain.vo.GSiteDeviceVo;
import com.fastbee.iot.domain.Device; import com.fastbee.iot.domain.Device;
/** /**
@ -18,7 +19,14 @@ public interface IGSiteDeviceService
/** /**
* 查询站点未关联的设备列表 * 查询站点未关联的设备列表
*/ */
public List<GSiteDevice> selectUnbindDeviceList(Long siteId); public List<GSiteDeviceVo> selectUnbindDeviceList(Long siteId,Long groupId);
/**
* 查询站点已关联设备列表
* @param siteId 站点设备关系主键
*/
public List<GSiteDeviceVo> selectBindDeviceList(Long siteId,Long groupId);
/** /**
* 查询站点设备关系 * 查询站点设备关系
@ -68,12 +76,6 @@ public interface IGSiteDeviceService
*/ */
public int deleteGSiteDeviceById(Long id); public int deleteGSiteDeviceById(Long id);
/**
* 查询站点设备已经关联关系信息
*
* @param id 站点设备关系主键
* @return 结果
*/
public List<GSiteDeviceDto> getGSiteDeviceByDevice(Long id);
} }

View File

@ -3,11 +3,15 @@ package com.fastbee.ggroup.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.ggroup.domain.GSites; import com.fastbee.ggroup.domain.GSites;
import com.fastbee.ggroup.domain.dto.GSiteDeviceDto; import com.fastbee.ggroup.domain.dto.GSiteDeviceDto;
import com.fastbee.ggroup.domain.vo.GSiteDeviceVo;
import com.fastbee.ggroup.mapper.GSitesMapper; import com.fastbee.ggroup.mapper.GSitesMapper;
import com.fastbee.iot.domain.Device; import com.fastbee.iot.domain.Device;
import com.fastbee.iot.domain.Group;
import com.fastbee.iot.mapper.DeviceMapper; import com.fastbee.iot.mapper.DeviceMapper;
import com.fastbee.iot.mapper.GroupMapper;
import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -34,26 +38,42 @@ public class GSiteDeviceServiceImpl implements IGSiteDeviceService
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@Autowired
private GroupMapper groupMapper;
/** /**
* 查询设备 * 查询站点未关联的设备列表
* @param siteId * @param siteId 站点id
* @return
*/ */
@Override @Override
public List<GSiteDevice> selectUnbindDeviceList(Long siteId) { public List<GSiteDeviceVo> selectUnbindDeviceList(Long siteId,Long groupId) {
MPJLambdaWrapper<Device> objectMPJLambdaWrapper = new MPJLambdaWrapper<Device>() MPJLambdaWrapper<GSiteDevice> objectMPJLambdaWrapper = new MPJLambdaWrapper<GSiteDevice>()
.select(Device::getDeviceId, Device::getDeviceName)
.select(GSiteDevice::getSiteId, GSiteDevice::getDeviceId) .select(GSiteDevice::getSiteId, GSiteDevice::getDeviceId)
.leftJoin(GSites.class, GSites::getId, GSiteDevice::getSiteId); .select(Device::getDeviceId, Device::getDeviceName)
List<GSiteDevice> gSiteDevices = deviceMapper.selectJoinList(GSiteDevice.class, objectMPJLambdaWrapper); .leftJoin(Device.class, Device::getDeviceId, GSiteDevice::getDeviceId)
.ne(GSiteDevice::getSiteId, siteId);
return gSiteDeviceMapper.selectJoinList(GSiteDeviceVo.class, objectMPJLambdaWrapper);
}
return gSiteDevices; /**
* 查询站点已关联设备列表
* @param siteId 站点设备关系主键
*/
@Override
public List<GSiteDeviceVo> selectBindDeviceList(Long siteId,Long groupId){
MPJLambdaWrapper<GSiteDevice> objectMPJLambdaWrapper = new MPJLambdaWrapper<GSiteDevice>()
.select(GSiteDevice::getSiteId, GSiteDevice::getDeviceId)
.select(Device::getDeviceId, Device::getDeviceName)
.leftJoin(Device.class, Device::getDeviceId, GSiteDevice::getDeviceId)
.eq(GSiteDevice::getSiteId, siteId);
List<GSiteDeviceVo> gSiteDeviceVos = gSiteDeviceMapper.selectJoinList(GSiteDeviceVo.class, objectMPJLambdaWrapper);
List<Group> groups = new LambdaQueryChainWrapper<>(groupMapper).select(Group::getGroupId,Group::getGroupName).list();
return gSiteDeviceVos;
} }
/** /**
* 查询站点设备关系 * 查询站点设备关系
*
* @param id 站点设备关系主键 * @param id 站点设备关系主键
* @return 站点设备关系 * @return 站点设备关系
*/ */
@ -123,15 +143,5 @@ public class GSiteDeviceServiceImpl implements IGSiteDeviceService
return gSiteDeviceMapper.deleteGSiteDeviceById(id); return gSiteDeviceMapper.deleteGSiteDeviceById(id);
} }
/**
* 查询站点设备已经关联关系信息
*
* @param id 站点设备关系主键
* @return 结果
*/
@Override
public List<GSiteDeviceDto> getGSiteDeviceByDevice(Long id){
return null;
}
} }

View File

@ -6,6 +6,7 @@ import java.util.Set;
import com.fastbee.iot.domain.Group; import com.fastbee.iot.domain.Group;
import com.fastbee.iot.model.DeviceGroupInput; import com.fastbee.iot.model.DeviceGroupInput;
import com.fastbee.iot.model.IdOutput; import com.fastbee.iot.model.IdOutput;
import com.github.yulichang.base.MPJBaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
@ -15,7 +16,7 @@ import org.springframework.stereotype.Repository;
* @date 2021-12-16 * @date 2021-12-16
*/ */
@Repository @Repository
public interface GroupMapper public interface GroupMapper extends MPJBaseMapper<Group>
{ {
/** /**
* 查询设备分组 * 查询设备分组