| | |
| | | package com.ruoyi.statistical.controller; |
| | | |
| | | import com.ruoyi.statistical.param.ESParam; |
| | | import com.ruoyi.statistical.service.StatisticalService; |
| | | import com.ruoyi.statistical.vo.NumVo; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.util.Calendar; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | return statisticalService.factorySelect(); |
| | | } |
| | | |
| | | /** |
| | | * 报警数量分析年 |
| | | */ |
| | | @ApiOperation("报警数量分析年") |
| | | @GetMapping("alarm/year") |
| | | public Results alarmYear(String type){ |
| | | LocalDate today = LocalDate.now(); |
| | | int year = today.getYear(); |
| | | ESParam esParam = new ESParam(); |
| | | esParam.setStart(year+"-01-01"); |
| | | esParam.setEnd(year+"-12-31"); |
| | | if("1001".equals(type)){ |
| | | //盗电报警 |
| | | return Results.succeed(statisticalService.stealelecYear(esParam)); |
| | | }else if("1002".equals(type)){ |
| | | //通用光电 |
| | | return Results.succeed(statisticalService.cameraYear(esParam)); |
| | | }else if("1003".equals(type)){ |
| | | //雷达报警 |
| | | return Results.succeed(statisticalService.moveYear(esParam)); |
| | | }else if("1004".equals(type)){ |
| | | //防火报警 |
| | | return Results.succeed(statisticalService.fireYear(esParam)); |
| | | }else if("1005".equals(type)){ |
| | | //外联报警 |
| | | return Results.succeed(statisticalService.externalYear(esParam)); |
| | | }else if("1006".equals(type)){ |
| | | //门禁报警 |
| | | return Results.succeed(statisticalService.accessYear(esParam)); |
| | | }else if("1007".equals(type)){ |
| | | //移动终端 |
| | | return Results.succeed(statisticalService.apponekeyYear(esParam)); |
| | | }else if("1008".equals(type)){ |
| | | //移动终端 |
| | | return Results.succeed(statisticalService.pumpYear(esParam)); |
| | | }else if("1010".equals(type)){ |
| | | //电子围栏 |
| | | return Results.succeed(statisticalService.wallYear(esParam)); |
| | | }else if("1012".equals(type)){ |
| | | //预警告警 |
| | | return Results.succeed(statisticalService.digitizationYear(esParam)); |
| | | }else if("1014".equals(type)){ |
| | | //管线泄漏 |
| | | return Results.succeed(statisticalService.tubeYear(esParam)); |
| | | } |
| | | return Results.succeed(); |
| | | } |
| | | |
| | | /** |
| | | * 报警数量分析月 |
| | | */ |
| | | @ApiOperation("报警数量分析月") |
| | | @GetMapping("alarm/month") |
| | | public Results alarmMonth(String month,String type){ |
| | | LocalDate today = LocalDate.now(); |
| | | int year = today.getYear(); |
| | | int day = getDaysInMonth(Integer.valueOf(month),year); |
| | | ESParam esParam = new ESParam(); |
| | | esParam.setStart(year+"-"+month+"-01"); |
| | | esParam.setEnd(year+"-"+month+"-"+day); |
| | | if("1001".equals(type)){ |
| | | //盗电报警 |
| | | return Results.succeed(statisticalService.stealelecMonth(esParam)); |
| | | }else if("1002".equals(type)){ |
| | | //通用光电 |
| | | return Results.succeed(statisticalService.cameraMonth(esParam)); |
| | | }else if("1003".equals(type)){ |
| | | //雷达报警 |
| | | return Results.succeed(statisticalService.moveMonth(esParam)); |
| | | }else if("1004".equals(type)){ |
| | | //防火报警 |
| | | return Results.succeed(statisticalService.fireMonth(esParam)); |
| | | }else if("1005".equals(type)){ |
| | | //外联报警 |
| | | return Results.succeed(statisticalService.externalMonth(esParam)); |
| | | }else if("1006".equals(type)){ |
| | | //门禁报警 |
| | | return Results.succeed(statisticalService.accessMonth(esParam)); |
| | | }else if("1007".equals(type)){ |
| | | //移动终端 |
| | | return Results.succeed(statisticalService.apponekeyMonth(esParam)); |
| | | }else if("1008".equals(type)){ |
| | | //雷达停机 |
| | | return Results.succeed(statisticalService.pumpMonth(esParam)); |
| | | }else if("1010".equals(type)){ |
| | | //电子围栏 |
| | | return Results.succeed(statisticalService.wallMonth(esParam)); |
| | | }else if("1012".equals(type)){ |
| | | //预警告警 |
| | | return Results.succeed(statisticalService.digitizationMonth(esParam)); |
| | | }else if("1014".equals(type)){ |
| | | //管线泄漏 |
| | | return Results.succeed(statisticalService.tubeMonth(esParam)); |
| | | } |
| | | return Results.succeed(); |
| | | } |
| | | |
| | | //返回每月天数 |
| | | public int getDaysInMonth(int month, int year) { |
| | | switch (month) { |
| | | case Calendar.JANUARY: |
| | | case Calendar.MARCH: |
| | | case Calendar.MAY: |
| | | case Calendar.JULY: |
| | | case Calendar.AUGUST: |
| | | case Calendar.OCTOBER: |
| | | case Calendar.DECEMBER: |
| | | return 31; |
| | | case Calendar.APRIL: |
| | | case Calendar.JUNE: |
| | | case Calendar.SEPTEMBER: |
| | | case Calendar.NOVEMBER: |
| | | return 30; |
| | | case Calendar.FEBRUARY: |
| | | return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; |
| | | default: |
| | | throw new IllegalArgumentException("Invalid Month"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 在线设备数 |
| | | */ |
| | | @ApiOperation("在线设备数") |
| | | @GetMapping("unit") |
| | | public Results unit(){ |
| | | return Results.succeed(statisticalService.unit()); |
| | | } |
| | | |
| | | /** |
| | | * 报警数量 |
| | | */ |
| | | @ApiOperation("报警数量") |
| | | @GetMapping("alarm/num") |
| | | public Results num(){ |
| | | NumVo numVo = new NumVo(); |
| | | numVo.setStealelec(statisticalService.stealelecNum()); |
| | | numVo.setCamera(statisticalService.cameraNum()); |
| | | numVo.setMove(statisticalService.moveNum()); |
| | | numVo.setFire(statisticalService.fireNum()); |
| | | numVo.setExternal(statisticalService.externalNum()); |
| | | numVo.setAccess(statisticalService.accessNum()); |
| | | numVo.setApponekey(statisticalService.apponekeyNum()); |
| | | numVo.setPump(statisticalService.pumpNum()); |
| | | numVo.setWall(statisticalService.wallNum()); |
| | | numVo.setDigitization(statisticalService.digitizationNum()); |
| | | numVo.setTube(statisticalService.tubeNum()); |
| | | return Results.succeed(numVo); |
| | | } |
| | | |
| | | } |