package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.EquipmentAttribute;
import com.jiayue.ipfcst.service.ProtocolGatherDataPointService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 接入数据点位restful接口
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/7 10:12
 */
@RestController
@Slf4j
public class ProtocolGatherDataPointController {

  private final ProtocolGatherDataPointService protocolGatherDataPointService;

  @Autowired
  public ProtocolGatherDataPointController(ProtocolGatherDataPointService protocolGatherDataPointService){
    this.protocolGatherDataPointService=protocolGatherDataPointService;
  }


  /**
   * 查询设备接入点位属性
   * @param id 设备ID
   * @return 点位属性集合
   */
  @GetMapping(value = "/protocolGatherDataPoint/{id}/{equipmentType}")
  public ResponseVO findByTimeBetweenForPaging(@PathVariable("id") Integer id,
                                               @PathVariable("equipmentType") String equipmentType){
    List<EquipmentAttribute> equipmentAttribute = new ArrayList<>();
    try{
      equipmentAttribute = protocolGatherDataPointService.getEquipmentAttribute(id, equipmentType);
      return ResponseVO.success(equipmentAttribute);
    }catch(Exception e){
      e.printStackTrace();
      log.error("设备接入属性查询错误");
      return ResponseVO.fail(e.toString());
    }
  }



}
