Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / StatisticsController.java
@liuyuanye liuyuanye 23 days ago 5 KB 告警分析,累计天数bug
package com.newfiber.termite.controller;

import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.ProjectInfo;
import com.newfiber.termite.domain.request.SnWarinTotalDaysRequestInfo;
import com.newfiber.termite.domain.request.WarnMonitoringRequest;
import com.newfiber.termite.domain.request.WarnMonthAlarmsRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.statistic.ProjectStatisticRequest;
import com.newfiber.termite.domain.request.statistic.SiteWarnDailySeqStatisticRequest;
import com.newfiber.termite.domain.request.statistic.SiteWarnTotalCountStatisticRequest;
import com.newfiber.termite.domain.response.*;
import com.newfiber.termite.domain.response.statistic.ProjectStatistic;
import com.newfiber.termite.domain.response.statistic.ProjectStatisticDetail;
import com.newfiber.termite.domain.response.statistic.SiteDailyWarnCount;
import com.newfiber.termite.domain.response.statistic.SiteTotalWarnCount;
import com.newfiber.termite.service.IDeviceInfoService;
import com.newfiber.termite.service.IProjectInfoService;
import com.newfiber.termite.service.IStatisticsService;
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.time.LocalDate;
import java.util.*;
import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * @author X.K
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/statistics")
@Api(value = "统计", tags = "统计")
public class StatisticsController extends BaseController {

    @Resource
    private IStatisticsService statisticsService;



    /**
     *
     */
    @GetMapping("/warn_date_seq_statistic")
    @ApiOperation(value = "告警日期时间序列统计", position = 50)
    public Result<Map<String, List<SiteDailyWarnCount>>> warnDailySeqStatistic(SiteWarnDailySeqStatisticRequest request) {
        Map<String, List<SiteDailyWarnCount>> response = statisticsService.warnDailySeqStatistic(request);
        return success(response);
    }

    /**
     *
     */
    @GetMapping("/site_warn_total_count_statistic")
    @ApiOperation(value = "累计告警次数统计", position = 50)
    public Result<List<SiteTotalWarnCount>> siteWarnTotalCountStatistic(SiteWarnTotalCountStatisticRequest request) {
        List<SiteTotalWarnCount> response = statisticsService.siteWarnTotalCountStatistic(request);
        return success(response);
    }

    /**
     *
     */
    @GetMapping("/project_statistic")
    @ApiOperation(value = "项目信息统计", position = 50)
    public Result<ProjectStatistic> projectWarnTotalCountStatistic(ProjectStatisticRequest request) {
        ProjectStatistic response = statisticsService.projectWarnTotalCountStatistic(request);
        return success(response);
    }

    @GetMapping("/warn_month_alarms")
    @ApiOperation(value = "告警分析", position = 50)
    //此接口暂留不再使用,使用下面的WarnMonthAlarmsStatistics接口
    public Result<WarnMonthAlarmsResponse> warnMonthAlarms(WarnMonthAlarmsRequest request){
        WarnMonthAlarmsResponse  response = statisticsService.warnMonthAlarms(request);
        return success(response);
    }

    @GetMapping("/WarnMonthAlarmsStatistics")
    @ApiOperation(value = "告警分析统计", position = 50)
    public Result<WarnMonthAlarmsResponse> WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request){
        WarnMonthAlarmsResponse  response = statisticsService.WarnMonthAlarmsStatistics(request);
        return success(response);
    }


    @GetMapping("/warn_monitoring")
    @ApiOperation(value = "监测预警", position = 50)
    public Result<WarnMonitoringResponse> warnMonitoring(WarnMonitoringRequest request){
        WarnMonitoringResponse response = statisticsService.warnMonitoring(request);
        return success(response);
    }

    /**
     * 查询累计告警天数
     */
    @GetMapping("/listWarinTotalDays")
    @ApiOperation(value = "列表查询累计告警天数", position = 60)
    public Result<List<WarnMonitoringResponseInfo>> listWarinTotalDays(WarnMonitoringRequest request){
        List<WarnMonitoringResponseInfo> warnMonitoringResponseInfoList = statisticsService.listWarinTotalDays(request);
        return success(warnMonitoringResponseInfoList);
    }


    /**
     * SN查询连续告警天数
     */
    @GetMapping("/SnWarinTotalDays")
    @ApiOperation(value = "查询设备累计告警天数", position = 60)
    public Result<List<SnWarinTotalDaysResponseInfo>> snWarinTotalDays(SnWarinTotalDaysRequestInfo request,@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDate date){
        List<SnWarinTotalDaysResponseInfo> warinTotalDaysResponseInfoList = statisticsService.snWarinTotalDays(request,date);
        return success(warinTotalDaysResponseInfoList);
    }

}