package com.gyee.alarm.controller;


import com.gyee.alarm.model.vo.AlarmCustomTag;
import com.gyee.alarm.model.vo.AlarmSuperTalbeType;
import com.gyee.alarm.model.vo.AlarmTag;
import com.gyee.alarm.service.AlarmBtService;
import com.gyee.alarm.service.AlarmCtService;
import com.gyee.alarm.service.AlarmInService;
import com.gyee.alarm.service.AlarmWtService;
import com.gyee.alarm.util.StringUtils;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.EncodeException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 动态功率数据 前端控制器
 * </p>
 *
 * @author shilin
 * @since 2022-10-27
 */
@RestController
@RequestMapping("/api/alarm")
public class AlarmController {


    @Resource
    private AlarmWtService alarmWtService;

    @Resource
    private AlarmBtService alarmBtService;

    @Resource
    private AlarmCtService alarmCtService;

    @Resource
    private AlarmInService alarmInService;

    @PostMapping("/wtTags")
    public List<AlarmTag> findTagsByWt(String wpIds)
    {

        List<AlarmTag> ls = alarmWtService.findTags(AlarmSuperTalbeType.WT.getCode(),wpIds);
        return ls;
    }

    @GetMapping("/btTags")
    public List<AlarmTag> findTagsByBt()

    {
        List<AlarmTag> ls = alarmBtService.findTags(AlarmSuperTalbeType.BT.getCode());
        return ls;
    }

    @GetMapping("/inTags")
    public List<AlarmTag> findTagsByIn()

    {
        List<AlarmTag> ls = alarmInService.findTags();
        return ls;
    }

    @GetMapping("/ctTags")
    public List<AlarmCustomTag> findTagsByCt()

    {
        List<AlarmCustomTag> ls = alarmCtService.findTags(AlarmSuperTalbeType.CT.getCode());
        return ls;
    }

    @PostMapping("/saveWtTags")
    public void saveWtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
         alarmWtService.saveAlarms(alarms);
    }

    @PostMapping("/saveBtTags")
    public void saveBtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmBtService.saveAlarms(alarms);
    }

    @PostMapping("/saveCtTags")
    public void saveCtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmCtService.saveAlarms(alarms);
    }

    @PostMapping("/saveInTags")
    public void saveInTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmInService.saveAlarms(alarms);
    }

    @PostMapping("/updateInTags")
    public void updateInTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmInService.updateAlarms(alarms);
    }

    @PostMapping("/updateWtTags")
    public void updateWtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmWtService.updateAlarms(alarms);
    }

    @PostMapping("/updateBtTags")
    public void updateBtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmBtService.updateAlarms(alarms);
    }

    @PostMapping("/updateCtTags")
    public void updateCtTags(@RequestBody List<AlarmTag> alarms ) throws EncodeException, IOException, InterruptedException {
        alarmCtService.updateAlarms(alarms);
    }

}
