大屏气象设备实时数据接口
This commit is contained in:
parent
3afe56706b
commit
c11265ed86
@ -0,0 +1,20 @@
|
|||||||
|
package com.fastbee.data.controller.deviceData;
|
||||||
|
|
||||||
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
|
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController()
|
||||||
|
@RequestMapping("/meteorology")
|
||||||
|
public class DeviceRealtimedataMeteorologyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceRealtimedataMeteorologyServiceImpl deviceRealtimedataMeteorologyService;
|
||||||
|
@GetMapping(value = "/weather/realtimedata")
|
||||||
|
public AjaxResult getLatestWeatherRealtimedata() {
|
||||||
|
return AjaxResult.success(deviceRealtimedataMeteorologyService.getLatestWeatherRealtimedata());
|
||||||
|
}
|
||||||
|
}
|
@ -22,4 +22,5 @@ public class RenKeUserDeviceOverviewController {
|
|||||||
public AjaxResult getsysAllUserDevice(){
|
public AjaxResult getsysAllUserDevice(){
|
||||||
return AjaxResult.success(renkeUserDeviceOverview.getsysAllUserDevice());
|
return AjaxResult.success(renkeUserDeviceOverview.getsysAllUserDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RenKeUserDeviceOverview {
|
public class RenKeUserDeviceOverview {
|
||||||
@ -28,6 +29,14 @@ public class RenKeUserDeviceOverview {
|
|||||||
JSONObject respBody = JSONUtil.parseObj(resultObjectStr);
|
JSONObject respBody = JSONUtil.parseObj(resultObjectStr);
|
||||||
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
||||||
Map<String,Integer> map = new HashMap<>();
|
Map<String,Integer> map = new HashMap<>();
|
||||||
|
|
||||||
|
/* Map<String, Integer> deviceTypeCountMap = realtimeDataList.stream()
|
||||||
|
.map(jsonObject -> (JSONObject) jsonObject)
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
e -> (String) e.get("deviceType"),
|
||||||
|
Collectors.summingInt(e -> 1)
|
||||||
|
));
|
||||||
|
Integer WORM = deviceTypeCountMap.getOrDefault(RenKeDeviceTypeConstant.WORM, 0);*/
|
||||||
//map = realtimeDataList.stream().collect(Collectors.groupingBy(obj -> ((JSONObject) obj).getStr("deviceType")));
|
//map = realtimeDataList.stream().collect(Collectors.groupingBy(obj -> ((JSONObject) obj).getStr("deviceType")));
|
||||||
Integer MET = 0;
|
Integer MET = 0;
|
||||||
Integer WORM = 0;
|
Integer WORM = 0;
|
||||||
@ -54,13 +63,15 @@ public class RenKeUserDeviceOverview {
|
|||||||
Spore=Spore+1;
|
Spore=Spore+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.put("MET",MET);
|
// map.put("MET",MET);
|
||||||
map.put("Worm",Worm);
|
// map.put("Worm",Worm);
|
||||||
map.put("Irrigation",Irrigation);
|
// map.put("Irrigation",Irrigation);
|
||||||
map.put("Camera",Camera);
|
// map.put("Camera",Camera);
|
||||||
map.put("wormFlagship",WORM);
|
map.put("wormFlagship",WORM);
|
||||||
map.put("Soil",Soil);
|
// map.put("Soil",Soil);
|
||||||
map.put("Spore",Spore);
|
// map.put("Spore",Spore);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,8 @@ import org.apache.poi.hpsf.Decimal;
|
|||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("iot_device_realtimedata_meteorology")
|
@TableName("iot_device_realtimedata_meteorology")
|
||||||
public class DeviceRealtimedataMeteorology extends BaseEntity
|
public class DeviceRealtimedataMeteorology
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -58,4 +58,10 @@ public interface IDeviceRealtimedataMeteorologyService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteDeviceRealtimedataMeteorologyById(Long id);
|
public int deleteDeviceRealtimedataMeteorologyById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新的一条气象数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DeviceRealtimedataMeteorology getLatestWeatherRealtimedata();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.fastbee.deviceData.service.impl;
|
package com.fastbee.deviceData.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.fastbee.common.utils.DateUtils;
|
import com.fastbee.common.utils.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -53,7 +56,7 @@ public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtime
|
|||||||
@Override
|
@Override
|
||||||
public int insertDeviceRealtimedataMeteorology(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology)
|
public int insertDeviceRealtimedataMeteorology(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology)
|
||||||
{
|
{
|
||||||
deviceRealtimedataMeteorology.setCreateTime(DateUtils.getNowDate());
|
deviceRealtimedataMeteorology.setSaveTime(DateUtils.getNowDate());
|
||||||
return deviceRealtimedataMeteorologyMapper.insertDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology);
|
return deviceRealtimedataMeteorologyMapper.insertDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtime
|
|||||||
@Override
|
@Override
|
||||||
public int updateDeviceRealtimedataMeteorology(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology)
|
public int updateDeviceRealtimedataMeteorology(DeviceRealtimedataMeteorology deviceRealtimedataMeteorology)
|
||||||
{
|
{
|
||||||
deviceRealtimedataMeteorology.setUpdateTime(DateUtils.getNowDate());
|
deviceRealtimedataMeteorology.setSaveTime(DateUtils.getNowDate());
|
||||||
return deviceRealtimedataMeteorologyMapper.updateDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology);
|
return deviceRealtimedataMeteorologyMapper.updateDeviceRealtimedataMeteorology(deviceRealtimedataMeteorology);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,4 +96,16 @@ public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtime
|
|||||||
{
|
{
|
||||||
return deviceRealtimedataMeteorologyMapper.deleteDeviceRealtimedataMeteorologyById(id);
|
return deviceRealtimedataMeteorologyMapper.deleteDeviceRealtimedataMeteorologyById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新的一条气象数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DeviceRealtimedataMeteorology getLatestWeatherRealtimedata(){
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
|
queryWrapper.orderByDesc("real_time");
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
return deviceRealtimedataMeteorologyMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user