墒情数据接口

This commit is contained in:
zhumeixiao 2024-11-21 10:11:21 +08:00
parent 393c942da2
commit db13870ffe
3 changed files with 16 additions and 5 deletions

View File

@ -1,9 +1,13 @@
package com.fastbee.data.controller.aaScreenAgricultural; package com.fastbee.data.controller.aaScreenAgricultural;
import com.fastbee.common.core.domain.AjaxResult; import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl; import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;
import com.fastbee.deviceInfo.service.impl.DeviceInformationMoistureServiceImpl;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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;
@ -12,13 +16,19 @@ import org.springframework.web.bind.annotation.RestController;
public class DeviceRealtimedataMoistureController { public class DeviceRealtimedataMoistureController {
@Autowired @Autowired
private DeviceRealtimedataMoistureServiceImpl deviceRealtimedataMoistureServiceImpl; private DeviceRealtimedataMoistureServiceImpl deviceRealtimedataMoistureServiceImpl;
@Autowired
private DeviceInformationMoistureServiceImpl deviceInformationMoistureServiceImpl;
/** /**
* 获取最新一条墒情数据 * 获取最新一条墒情数据
* @return * @return
*/ */
@GetMapping("/weather/realtimedata") @GetMapping("/weather/realtimedata")
public AjaxResult getLatestWeatherRealtimedata() { public AjaxResult getLatestWeatherRealtimedata( String deviceId) {
return AjaxResult.success(deviceRealtimedataMoistureServiceImpl.getLatestWeatherRealtimedata()); return AjaxResult.success(deviceRealtimedataMoistureServiceImpl.getLatestWeatherRealtimedata(deviceId));
}
@GetMapping("/weather/pullDown")
public AjaxResult getLatestWeatherPullDown() {
return AjaxResult.success(deviceInformationMoistureServiceImpl.selectDeviceInformationMoistureList(null));
} }
} }

View File

@ -64,5 +64,5 @@ public interface IDeviceRealtimedataMoistureService
* 获取最新一条墒情数据 * 获取最新一条墒情数据
* @return * @return
*/ */
public List<DeviceProperties> getLatestWeatherRealtimedata(); public List<DeviceProperties> getLatestWeatherRealtimedata(String deviceId);
} }

View File

@ -100,10 +100,11 @@ public class DeviceRealtimedataMoistureServiceImpl implements IDeviceRealtimedat
* 获取最新一条墒情数据 * 获取最新一条墒情数据
* @return * @return
*/ */
public List<DeviceProperties> getLatestWeatherRealtimedata(){ public List<DeviceProperties> getLatestWeatherRealtimedata(String deviceId){
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.orderByDesc("real_time"); queryWrapper.orderByDesc("real_time");
queryWrapper.last("limit 1"); queryWrapper.last("limit 1");
queryWrapper.eq("device_id",deviceId);
DeviceRealtimedataMoisture moisture = deviceRealtimedataMoistureMapper.selectOne(queryWrapper); DeviceRealtimedataMoisture moisture = deviceRealtimedataMoistureMapper.selectOne(queryWrapper);
List<Map<String, String>> mapList = new ArrayList<>(); List<Map<String, String>> mapList = new ArrayList<>();
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();