package com.lutao.cloud.oil.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.lutao.cloud.common.core.util.MessageInfo;
import com.lutao.cloud.common.security.annotation.Inner;
import com.lutao.cloud.oil.pojo.param.*;
import com.lutao.cloud.oil.pojo.vo.*;
import com.lutao.cloud.oil.service.IBusinessPerceptionMonitorAlarmService;
import com.lutao.cloud.oil.service.PerceptionDynamicService;
import com.lutao.cloud.oil.service.WorkStausService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 javax.annotation.Resource;
import java.util.List;

@Api(value = "关键工艺参数监测报警",tags = "关键工艺参数监测报警")
@RequestMapping("/equipment-tag")
@RestController
public class EquipmentTagController {

    @Resource
    private WorkStausService workStausService;

    @Resource
    private IBusinessPerceptionMonitorAlarmService iBusinessPerceptionMonitorAlarmService;

    @Resource
    private PerceptionDynamicService perceptionDynamicService;

    @ApiOperation(value = "关键工艺监测预警",notes = "关键工艺监测预警")
    @ApiOperationSupport(order = 1)
    @PostMapping("/equipment-alarm-list")
    @Inner(value = false)
    public MessageInfo<IPage<EquipmentTagAlarmVO>> equipmentTagAlarmList(Page page, @RequestBody EquipmentTagParam param){
        return iBusinessPerceptionMonitorAlarmService.queryEquipmentTagAlarm(page,param);
    }

    @ApiOperation(value = "关键工艺监测预警图表",notes = "关键工艺监测预警图表")
    @PostMapping("/equipment-alarm-chart")
    @Inner(value = false)
    public MessageInfo<TagProcessAlarmVO> equipmentTagAlarmChart(@RequestBody EquipmentTagParam param){
        return iBusinessPerceptionMonitorAlarmService.queryEquipmentTagAlarmChart(param);
    }

    @ApiOperation(value = "关键设备工况状态监测报警",notes = "关键设备工况状态监测报警")
    @ApiOperationSupport(order = 2)
    @PostMapping("/equipment-work-status-alarm")
    @Inner(value = false)
    public MessageInfo<IPage<EquipmentWorkStatusAlarmVO>> equipmentWorkStatusAlarm(Page page, @RequestBody EquipmentWorkStatusAlarmParam param){
        return workStausService.queryEquipmentWorkStatusAlarm(page,param);
    }

    @ApiOperation(value = "预警监测-近七日报警趋势",notes = "预警监测-近七日报警趋势")
    @ApiOperationSupport(order = 3)
    @PostMapping("/recent-month-equipment-tag-alarm-trend")
    @Inner(value = false)
    public MessageInfo<List<TagAlarmTrendVO>> recentMonthEquipmentTagAlarmTrend(@RequestBody EquipmentTagParam param){

        return iBusinessPerceptionMonitorAlarmService.getAlarmTrend(param);
    }

//    @ApiOperation(value = "关键工艺参数检测报警-动态数据",notes = "关键工艺参数检测报警-动态数据")
//    @ApiOperationSupport(order = 4)
//    @PostMapping("/process-param-Tag-page")
//    @Inner(value = false)
//    public MessageInfo<IPage<ProcessTagVO>> processParamTagPage(Page page,@RequestBody EquipmentTagParam param){
//
//        return iBusinessPerceptionMonitorAlarmService.getProcessParamTagPage(page,param);
//    }

//    @ApiOperation(value = "关键工艺参数检测报警-动态数据-FROM TSDB",notes = "关键工艺参数检测报警-动态数据-FROM TSDB")
//    @ApiOperationSupport(order = 5)
//    @PostMapping ("/process-param-alarm")
//    @Inner(value = false)
//    public MessageInfo<List<ProcessTagVO>> processTagAlarmList(@RequestBody EquipmentTagParam param,int current,int size){
//        return iBusinessPerceptionMonitorAlarmService.getProcessParamTagList(param,current,size);
//    }

    @ApiOperation(value = "关键工艺监测-工艺参数信息",notes = "关键工艺监测-工艺参数信息")
    @ApiOperationSupport(order = 6)
    @PostMapping ("/process-param-info")
    @Inner(value = false)
    public MessageInfo<IPage<ProcessParametersTagVO>> processTagInfoList(Page page,@RequestBody ProcessParametersTagVOParam param){
        return iBusinessPerceptionMonitorAlarmService.getProcessParamInfoPage(page,param);
    }

    @ApiOperation(value = "关键工艺参数检测-根据tag_code获取参数历史信息",notes = "关键工艺参数检测-根据tag_code获取参数历史信息")
    @ApiOperationSupport(order = 7)
    @PostMapping ("/process-param-history")
    @Inner(value = false)
    public MessageInfo<IPage<ProcessParametersTagVO>> processTagHistory(Page page,@RequestBody EquipmentTagParam param){
        return iBusinessPerceptionMonitorAlarmService.getPerceptionMonitorInfoByTagCode(page,param);
    }

    @ApiOperation(value = "预警监测-监测点位统计")
    @ApiOperationSupport(order = 8)
    @PostMapping("/early-warning-monitoring-point-statistic")
    @Inner(value = false)
    public MessageInfo<List<MonitorPointVO>> earlyWarningMonitoringPointStatistic(@RequestBody BaseParam param){
        return iBusinessPerceptionMonitorAlarmService.earlyWarningMonitoringPointStatistic(param);
    }


    //@ApiOperation(value = "预警监测-近七日报警趋势")

    @ApiOperation(value = "关键工艺预警-报警环比and报警因素分析")
    @ApiOperationSupport(order = 9)
    @PostMapping("/tag-alarm-qoq")
    @Inner(value = false)
    public MessageInfo<TagAlarmQoqVO> tagAlarmQoq(@RequestBody TagAlarmQoqVOParam param){
        return iBusinessPerceptionMonitorAlarmService.getTagAlarmQoq(param);
    }

    @ApiOperation(value = "关键工艺监测-报警环比列表")
    @ApiOperationSupport(order = 10)
    @PostMapping("/tag-alarm-qoq-list")
    @Inner(value = false)
    public MessageInfo<List<TagAlarmQoqListVO>> tagAlarmQoqList(@RequestBody TagAlarmQoqVOParam param){
        return iBusinessPerceptionMonitorAlarmService.getTagAlarmQoqList(param);
    }

    @ApiOperation(value = "报警统计")
    @ApiOperationSupport(order = 11)
    @PostMapping("/alarm-statistics")
    @Inner(value = false)
    public MessageInfo<AlarmStatisticsVO> alarmStatistics(@RequestBody AlarmStatisticsParam param){
        return iBusinessPerceptionMonitorAlarmService.alarmStatistics(param);
    }


}
