123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- package com.bizmatics.controller.web;
- import com.bizmatics.common.core.bean.ApiResult;
- import com.bizmatics.common.core.bean.CommonPage;
- import com.bizmatics.common.core.util.DateUtils;
- import com.bizmatics.model.Device;
- import com.bizmatics.model.DeviceList;
- import com.bizmatics.model.HtAnalogData;
- import com.bizmatics.model.vo.CorrespondDeviceListVO;
- import com.bizmatics.model.vo.CorrespondDeviceVO;
- import com.bizmatics.model.vo.DeviceOneVo;
- import com.bizmatics.persistence.mapper.DeviceMapper;
- import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
- import com.bizmatics.service.DeviceService;
- import com.bizmatics.service.vo.CorrespondDeviceVOT;
- import com.bizmatics.service.vo.DeviceCountVO;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- /**
- * 设备
- *
- * @author ya
- * @since 2021-07-07
- */
- @Slf4j
- @RestController
- @RequestMapping("/device")
- public class DeviceController {
- @Autowired
- private DeviceService deviceService;
- @Autowired
- private DeviceMapper deviceMapper;
- @Autowired
- private HtAnalogDataMapper htAnalogDataMapper;
- /**
- * 查询设备总数
- *
- * @param startTime
- * @param endTime
- * @return
- */
- @GetMapping("/count")
- public ApiResult<DeviceCountVO> count(@RequestParam Date startTime, @RequestParam Date endTime) {
- return ApiResult.success(deviceService.selectDeviceCount(startTime, endTime));
- }
- /**
- * 查询不同类型的设备数量
- *
- * @param site 站点id
- * @return
- */
- @GetMapping("/deviceTypeCount")
- public ApiResult<DeviceCountVO> selectDeviceCountByType(@RequestParam Integer site) {
- return ApiResult.success(deviceService.selectDeviceCountByType(site));
- }
- @GetMapping("/test")
- public List<String> test() {
- List<Device> list = deviceMapper.list(1, null, null, null, null, null);
- List<String> list1 = new ArrayList<>();
- for (Device device : list) {
- long l = System.currentTimeMillis();
- List<HtAnalogData> list2 = htAnalogDataMapper.list(DateUtils.addYears(new Date(), -10), new Date(), device.getDeviceCode());
- long e = System.currentTimeMillis();
- log.info("一个站点的数据获取时间" + (e - l));
- }
- return list1;
- }
- @GetMapping("deviceList")
- public ApiResult<List<DeviceList>> deviceList(@RequestParam String siteId) {
- return ApiResult.success(deviceService.deviceList(siteId));
- }
- /**
- * 数据管理-同比分析报表-右侧设备查询
- *
- * @param siteId 站点ID
- * @param deviceType 设备类型 默认1、用电设备
- * @return
- */
- @GetMapping("dataManagementDeviceList")
- public ApiResult<List<DeviceOneVo>> dataManagementDeviceList(@RequestParam int siteId,
- @RequestParam(value = "deviceType", required = false, defaultValue = "1") int deviceType) {
- return ApiResult.success(deviceService.dataManagementDeviceList(siteId, deviceType));
- }
- /**
- * 设备管理-通信设备-新增
- *
- * @param device
- * @return
- */
- @PostMapping("correspondDeviceAdd")
- public ApiResult<Void> correspondDeviceAdd(@RequestBody Device device) {
- deviceService.correspondDeviceAdd(device);
- return ApiResult.success();
- }
- /**
- * 设备管理-通信设备-修改
- *
- * @param device
- * @return
- */
- @PostMapping("correspondDeviceUpdate")
- public ApiResult<Void> correspondDeviceUpdate(@RequestBody Device device) {
- deviceService.correspondDeviceUpdate(device);
- return ApiResult.success();
- }
- /**
- * 设备管理-通信设备-注销
- *
- * @param id
- * @return
- */
- @GetMapping("correspondDeviceDel")
- public ApiResult<Void> correspondDeviceDel(@RequestParam int id) {
- deviceService.correspondDeviceDel(id);
- return ApiResult.success();
- }
- /**
- * 设备管理-通信设备-查询
- *
- * @param deviceName 设备名称
- * @param size 条数
- * @param current 页数
- * @return
- */
- @GetMapping("correspondDeviceList")
- public ApiResult<CommonPage<CorrespondDeviceVO>> correspondDeviceList(@RequestParam(required = false) String deviceName,
- @RequestParam(value = "size", required = false, defaultValue = "15") int size,
- @RequestParam(value = "current", required = false, defaultValue = "1") int current) {
- return ApiResult.success(deviceService.correspondDeviceList(deviceName, size, current));
- }
- /**
- * 设备管理-通信设备-修改回显
- *
- * @param id 通信设备表主键ID
- * @return
- */
- @GetMapping("correspondDeviceListEcho")
- public ApiResult<List<CorrespondDeviceListVO>> correspondDeviceListEcho(@RequestParam int id) {
- return ApiResult.success(deviceService.correspondDeviceListEcho(id));
- }
- /**
- * 设备管理-视频监测-列表查询
- *
- * @param siteId 站点ID
- * @param deviceName 设备名称
- * @param size 页数
- * @param current 条数
- * @param deviceType 1:183用电设备,2:视频监控设备,3:171用电设备,4:173用电设备,5:158智能网关,6:其他 0:所有
- * @return
- */
- @GetMapping("videoMonitoringDeviceList")
- public ApiResult<CommonPage<Device>> videoMonitoringDeviceList(@RequestParam Integer siteId,
- @RequestParam(required = false) String deviceName,
- @RequestParam(value = "size", required = false, defaultValue = "1") Integer size,
- @RequestParam(value = "current", required = false, defaultValue = "10") Integer current,
- @RequestParam(value = "deviceType", required = false, defaultValue = "2") Integer deviceType
- ) {
- return ApiResult.success(deviceService.videoMonitoringDeviceList(deviceName, deviceType, siteId, size, current));
- }
- }
|