forked from integrated_whb/integrated_whb
197 lines
7.0 KiB
Java
197 lines
7.0 KiB
Java
package com.zcloud.controller.mapApi;
|
||
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.zcloud.controller.base.BaseController;
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.service.system.UsersService;
|
||
import com.zcloud.service.video.VideoManagerService;
|
||
import com.zcloud.util.DateUtil;
|
||
import com.zcloud.util.Jurisdiction;
|
||
import com.zcloud.util.PLSUtil;
|
||
import com.zcloud.util.ReturnMap;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
||
import java.text.DateFormat;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* 说明:TODO
|
||
* 作者:wangxuan
|
||
* 官网:www.zcloudchina.com
|
||
*/
|
||
@Controller
|
||
@RequestMapping("/map")
|
||
public class MapController extends BaseController {
|
||
@Autowired
|
||
private UsersService usersService;
|
||
@Autowired
|
||
private VideoManagerService videomanagerService;
|
||
|
||
// ----------人员定位相关-------------//
|
||
|
||
/**
|
||
* @Description: 人员类型统计 告警类型统计
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/26/026 16:42
|
||
* @Param: [] []
|
||
* @Return: java.lang.String
|
||
*/
|
||
@RequestMapping(value = "/getPersonnelTypeCount")
|
||
@ResponseBody
|
||
public ReturnMap getPersonnelTypeCount() throws Exception {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
int userCount = usersService.getUserCount(pageData);
|
||
return ReturnMap.ok().put("userCount", userCount);
|
||
}
|
||
|
||
/**
|
||
* @Description: 告警类型统计 来自人员定位系统
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/26/026 16:43
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getAlarmTypeCount")
|
||
@ResponseBody
|
||
public ReturnMap getAlarmTypeCount() throws Exception {
|
||
return ReturnMap.ok().put("data", PLSUtil.getAlarmTypeCount(Jurisdiction.getCORPINFO_ID()));
|
||
}
|
||
|
||
/**
|
||
* @Description: 人员定位情况 来自人员定位系统
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/26/026 16:43
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getPersonnelPositioningCount")
|
||
@ResponseBody
|
||
public ReturnMap getPersonnelPositioningCount(Page page) throws Exception {
|
||
JSONObject personnelPositioningCount = PLSUtil.getPersonnelPositioningCount(Jurisdiction.getCORPINFO_ID(), page.getCurrentPage(), page.getShowCount());
|
||
return ReturnMap.ok().put("data", personnelPositioningCount);
|
||
}
|
||
// ----------摄像头相关-------------//
|
||
|
||
// 摄像头告警数 disposed
|
||
@RequestMapping(value = "/getCameraTopToShow")
|
||
@ResponseBody
|
||
public ReturnMap getCameraTopToShow() {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
PageData cameraCount = videomanagerService.getCameraTopToShow(pageData);
|
||
return ReturnMap.ok().put("pd", cameraCount);
|
||
}
|
||
/**
|
||
* @Description: 摄像头告警数
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/29/029 15:35
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getCameraAlarmCount")
|
||
@ResponseBody
|
||
public ReturnMap getCameraAlarmCount() {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
List<PageData> cameraCount = videomanagerService.getCameraAlarmCount(pageData);
|
||
return ReturnMap.ok().put("CameraAlarmCount", cameraCount);
|
||
}
|
||
/**
|
||
* @Description: 摄像头报警类型
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/29/029 10:52
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getCameraAlarmTypeCount")
|
||
@ResponseBody
|
||
public ReturnMap getCameraAlarmTypeCount() {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
List<PageData> cameraCount = videomanagerService.getCameraAlarmTypeCount(pageData);
|
||
return ReturnMap.ok().put("varList", cameraCount);
|
||
}
|
||
|
||
/**
|
||
* @Description: 摄像头告警时间趋势
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/29/029 10:51
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getCameraAlarmTimeCount")
|
||
@ResponseBody
|
||
public ReturnMap getCameraAlarmTimeCount() throws Exception {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
List<Map<String, String>> generateTimeArraySevenMonth = DateUtil.generateTimeArraySevenMonth(6);
|
||
pageData.put("generateTimeArray", generateTimeArraySevenMonth);
|
||
return ReturnMap.ok().put("varList", videomanagerService.getCameraAlarmTimeCount(pageData));
|
||
}
|
||
|
||
/**
|
||
* @Description: 摄像头告警来源
|
||
* @Author: dearLin
|
||
* @Date: 2024/1/29/029 10:51
|
||
* @Param: [] []
|
||
* @Return: com.zcloud.util.ReturnMap
|
||
*/
|
||
@RequestMapping(value = "/getCameraAlarmSourceCount")
|
||
@ResponseBody
|
||
public ReturnMap getCameraAlarmSourceCount() throws Exception {
|
||
PageData pageData = getPageData();
|
||
pageData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
int cameraCount = usersService.getUserCount(pageData);
|
||
return ReturnMap.ok().put("cameraCount", cameraCount);
|
||
}
|
||
// -----------------------//
|
||
|
||
public static List<Map<String, String>> generateTimeArray() {
|
||
List<Map<String, String>> timeArray = new ArrayList<>();
|
||
Calendar calendar = Calendar.getInstance();
|
||
|
||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
|
||
for (int i = 6; i >= 0; i--) {
|
||
Map<String, String> monthInfo = new HashMap<>();
|
||
|
||
int year = calendar.get(Calendar.YEAR);
|
||
int month = calendar.get(Calendar.MONTH) + 1;
|
||
|
||
String monthString = String.format(year+"-%02d", month);
|
||
String firstDayOfMonth = String.format("%04d-%02d-01 00:00:00", year, month);
|
||
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||
calendar.set(Calendar.MINUTE, 59);
|
||
calendar.set(Calendar.SECOND, 59);
|
||
String lastDayOfMonth = dateFormat.format(calendar.getTime());
|
||
|
||
monthInfo.put("month", monthString);
|
||
monthInfo.put("dateBegin", firstDayOfMonth);
|
||
monthInfo.put("dateEnd", lastDayOfMonth);
|
||
|
||
timeArray.add(monthInfo);
|
||
|
||
calendar.add(Calendar.MONTH, -1); // Go to the previous month
|
||
}
|
||
|
||
// Reverse the timeArray to have the order from past to present
|
||
Collections.reverse(timeArray);
|
||
|
||
return timeArray;
|
||
}
|
||
|
||
public static void main(String[] args) {
|
||
List<Map<String, String>> timeArray = generateTimeArray();
|
||
for (Map<String, String> monthInfo : timeArray) {
|
||
System.out.println(monthInfo);
|
||
}
|
||
}
|
||
}
|