package org.springblade.third.iotdevice.open;

import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.third.iotdevice.dto.PepAlarmNoticeDto;
import org.springblade.third.iotdevice.dto.PepDeviceStatusNoticeDto;
import org.springblade.third.iotdevice.dto.PepHeartbeatNoticeDto;
import org.springblade.third.iotdevice.service.IPerceptionSubscribeService;
import org.springblade.third.iotdevice.vo.PepNoticeReturnVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author lidexi
 * @date 2021/5/27 13:38
 */

@RestController
@AllArgsConstructor
@RequestMapping("/open/perception")
public class PerceptionSubScribeController {

	private  final IPerceptionSubscribeService perceptionSubscribeService;

	/**
	 * 告警上报
	 * @param alarmNoticeDtoList
	 * @return
	 */
	@PostMapping("/alarm/notice")
	public PepNoticeReturnVO alarmReport(@RequestBody List<PepAlarmNoticeDto> alarmNoticeDtoList)  {
		return (PepNoticeReturnVO)this.perceptionSubscribeService.alarmReport(alarmNoticeDtoList);
	}

	/**
	 * 心跳上报
	 * @param pepHeartbeatNoticeDtos
	 * @return
	 */
	@PostMapping("/heartbeat/notice")
	public PepNoticeReturnVO heartbeatReport(@RequestBody List<PepHeartbeatNoticeDto> pepHeartbeatNoticeDtos){
		return (PepNoticeReturnVO)this.perceptionSubscribeService.heartBeatReport(pepHeartbeatNoticeDtos);
	}
	/**
	 * 设备状态更新上报接口
	 * @param map
	 * @return
	 */
	@PostMapping(value = "/deviceStatus/notice")
	public PepNoticeReturnVO deviceStatusReport(@RequestBody Map<String,Object> map){
		return (PepNoticeReturnVO)this.perceptionSubscribeService.deviceStatusChange(map);
	}


}
