|
|
package com.topsail.influxdb.controller;
|
|
|
|
|
|
import com.topsail.influxdb.entity.DeviceHistoryData;
|
|
|
import com.topsail.influxdb.result.Result;
|
|
|
import com.topsail.influxdb.service.DeviceDataService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.validation.BindException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
@ResponseBody
|
|
|
@CrossOrigin
|
|
|
@RequestMapping(value = "/deviceData")
|
|
|
public class DeviceDataController {
|
|
|
private Logger logger = LoggerFactory.getLogger(DeviceDataController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private DeviceDataService deviceDataService;
|
|
|
|
|
|
/**
|
|
|
* 查询单个设备历史数据(根据设备号查询设备历史数据)
|
|
|
* devices/history/{deviceid}
|
|
|
*/
|
|
|
@GetMapping(value = "/history/{deviceid}")
|
|
|
public Result<List<DeviceHistoryData>> getHistoryData(String uid, Integer pageNo, Integer pageSize, String startTime, String endTime, @PathVariable("deviceid") String Imei) throws ParseException, BindException {
|
|
|
logger.info("history " + uid);
|
|
|
List<DeviceHistoryData> list = new ArrayList<>();
|
|
|
list = deviceDataService.getDeviceHistoryData(uid, pageNo, pageSize, startTime, endTime, Imei);
|
|
|
logger.info("finished request " + uid);
|
|
|
return Result.success(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询单个设备历史数据(根据设备号查询设备历史数据)
|
|
|
* devices/history/{deviceid}
|
|
|
*/
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
|
|
public Result<List<DeviceHistoryData>> deleteDeviceData() throws ParseException, BindException {
|
|
|
List<DeviceHistoryData> list = new ArrayList<>();
|
|
|
deviceDataService.deleteDeviceData();
|
|
|
return Result.success(list);
|
|
|
}
|
|
|
}
|