AlarmJobTestController.java 5.5 KB
package com.skua.modules.controller;

import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.skua.core.api.vo.Result;
import com.skua.modules.quartz.DeviceStatusJob;
import com.skua.modules.quartz.EquipAlarmJob;
import com.skua.modules.quartz.EquipmentMaintainReminderJob;
import com.skua.modules.quartz.EquipmentRepairAlarmJob;
import com.skua.modules.quartz.RealTimeAlarmJob;
import com.skua.modules.quartz.RelevanceAlarmJob;
import com.skua.modules.quartz.SuddenIncreaseAlarmJob;
import com.skua.modules.quartz.XtDataSameJob;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description 报警分析控制层
 * @Date 2020-12-16 17:08
 * @Param
 * @return
 **/
@Slf4j
@RestController
@RequestMapping("/alarm/testJob")
@Api(tags = "报警定时测试服务")
public class AlarmJobTestController {

    @Autowired
    private RealTimeAlarmJob realTimeAlarmJob;
    @Autowired
    private DeviceStatusJob deviceStatusJob;
    @Autowired
    private EquipAlarmJob xtEquipAlarmJob;
    @Autowired
    private RelevanceAlarmJob relevanceAlarmJob;
    @Autowired
    private EquipmentRepairAlarmJob equipmentRepairAlarmJob;
    @Autowired
    private EquipmentMaintainReminderJob equipmentMaintainReminderJob;
    @Autowired
    private SuddenIncreaseAlarmJob suddenIncreaseAlarmJob;
    
    @Autowired
    private XtDataSameJob dataSameJob;
    
    @ApiOperation(value = "测试实时数据报警定时服务", notes = "测试实时数据报警定时服务")
    @GetMapping(value = "/testRealTimeAlarmJob")
    public Result<String> testRealTimeAlarmJob() {

        Result<String> result = new Result<>();
        try {
			realTimeAlarmJob.execute(null);
		} catch (JobExecutionException e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    @ApiOperation(value = "测试关联报警定时服务", notes = "测试关联报警定时服务")
    @GetMapping(value = "/testRelevanceAlarmJob")
    public Result<String> testRelevanceAlarmJob() {
        Result<String> result = new Result<>();
        try {
        	relevanceAlarmJob.execute(null);
		} catch (JobExecutionException e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    
    @ApiOperation(value = "测试设备频繁维修定时服务", notes = "测试设备频繁维修报警定时服务")
    @GetMapping(value = "/testEquipmentRepairAlarmJob")
    public Result<String> testEquipmentRepairAlarmJob() {
        Result<String> result = new Result<>();
        try {
        	equipmentRepairAlarmJob.execute("20220523133125362420190458314219");
		} catch (Exception e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    
    @ApiOperation(value = "测试设备到期提醒定时服务", notes = "测试设备到期提醒定时服务")
    @GetMapping(value = "/testEquipmentMaintainReminderJob")
    public Result<String> testEquipmentMaintainReminderJob() {
        Result<String> result = new Result<>();
        try {
        	equipmentMaintainReminderJob.execute(null);
		} catch (Exception e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    
    @ApiOperation(value = "测试指标突增报警定时服务", notes = "测试指标突增报警定时服务")
    @GetMapping(value = "/testSuddenIncreaseAlarmJob")
    public Result<String> testSuddenIncreaseAlarmJob() {
        Result<String> result = new Result<>();
        try {
        	suddenIncreaseAlarmJob.execute(null);
		} catch (Exception e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    
    @ApiOperation(value = "测试设备故障报警定时服务", notes = "测试设备故障报警定时服务")
    @GetMapping(value = "/testEquipAlarmJob")
    public Result<String> testEquipAlarmJob() {

        Result<String> result = new Result<>();
        try {
        	xtEquipAlarmJob.execute(null);
		} catch (JobExecutionException e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;
    }
    
    @ApiOperation(value = "数据长期不变报警定时服务", notes = "数据长期不变报警定时服务")
    @GetMapping(value = "/testDataSameJob")
    public Result<String> testDataSameJob() {

        Result<String> result = new Result<>();
        try {
        	dataSameJob.execute(null);
		} catch (JobExecutionException e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;

    }
    
    @ApiOperation(value = "测试设备在、离线报警定时服务", notes = "测试设备在、离线报警定时服务")
    @GetMapping(value = "/testDeviceStatusJob")
    public Result<String> testDeviceStatusJob() {

        Result<String> result = new Result<>();
        try {
        	dataSameJob.execute(null);
		} catch (JobExecutionException e) {
			e.printStackTrace();
		}
        result.setResult("成功");
        result.setSuccess(true);
        return result;

    }

}