package com.cloud.retrieve.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.cloud.model.common.Result;
|
import com.cloud.retrieve.model.EsDataQueryParam;
|
import com.cloud.retrieve.service.EsDataService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Map;
|
|
@Slf4j
|
@RestController
|
@Api(value = "EsDataBaseController",description = "es数据查询")
|
@RequestMapping("/data/api-r/es")
|
public class EsDataController {
|
|
@Autowired
|
private EsDataService esDataService;
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
|
|
@ApiOperation(value = "findEsData",notes = "查询es检索数据",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("findEsData")
|
public Result findEsData(@RequestBody EsDataQueryParam esSearch){
|
// log.info(sdf.format(new Date())+"查询es检索数据前");
|
JSONObject allDataByMoreParams = esDataService.getAllDataByMoreParams(esSearch);
|
// log.info(sdf.format(new Date())+"查询es检索数据返回");
|
return Result.ok("查询es检索数据成功。",allDataByMoreParams);
|
}
|
|
@ApiOperation(value = "updateEsToAlarm",notes = "修改为已确认报警 {\"id\":\"dc6e4b7b-08ad-4ba2-b1f0-4bbc5ace7c43\",\"ack_alarm\":\"1\"}",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("updateEsToAlarm")
|
public Result updateEsToAlarm(@RequestBody Map reqMap){
|
String dataId = (String) reqMap.get("id");
|
String ack_alarm = (String) reqMap.get("ack_alarm");
|
if (dataId == null || dataId.isEmpty() || ack_alarm == null || ack_alarm .isEmpty()){
|
throw new RuntimeException("dataId或ack_alarm 参数为空"+dataId+ack_alarm);
|
}
|
log.info(sdf.format(new Date())+"修改为已确认前");
|
JSONObject respupdate = esDataService.updateEsDataByEsId(dataId,ack_alarm);
|
log.info(sdf.format(new Date())+"修改为已确认后");
|
if (respupdate.getBoolean("success")){
|
return Result.ok("修改为已确认报警成功。",respupdate);
|
}else {
|
return Result.error(new RuntimeException("操作过于频繁,报警确认失败,请稍后再试。"));
|
}
|
}
|
|
@ApiOperation(value = "cameraRecord",notes = "地图某摄像机报警记录或抓拍分页数据 " +
|
"{\"videoReqNum\":\"d820807a-5b83-4321-9b43-e0129102a9ff\",\"page\":1,\"size\":6,\"personIsHub\":\"\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("cameraRecord")
|
public Result findEsAlarmDataByEquPage(@RequestBody Map reqMap){
|
Integer page = (Integer) reqMap.get("page");
|
Integer size = (Integer) reqMap.get("size");
|
String equId = (String) reqMap.get("videoReqNum");
|
String personIsHub = (String) reqMap.get("personIsHub"); //
|
if (page == null || size == null ){
|
page = 1;size = 8;
|
}
|
// log.info("某摄像机报警记录查询参数page:"+page+"size:"+size+"equId:"+equId);
|
JSONObject respupdate = esDataService.findEsPersonAlarmDataByEquPage(page,size,equId,personIsHub);
|
return Result.ok("设备记录查询成功。",respupdate);
|
}
|
|
@ApiOperation(value = "alarmRecord",notes = "地图全部报警记录分页数据 {\"page\":1,\"size\":8}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("alarmRecord")
|
public Result findEsAllAlarmDataByPage(@RequestBody Map reqMap) throws ParseException {
|
Integer page = (Integer) reqMap.get("page");
|
Integer size = (Integer) reqMap.get("size");
|
Date startDate = reqMap.get("startDate")== null?null:sdf.parse(reqMap.get("startDate").toString());
|
Date endDate = reqMap.get("endDate")== null?null:sdf.parse(reqMap.get("endDate").toString());
|
if (page == null || size == null ){
|
page = 1;size = 6;
|
}
|
log.info("某摄像机报警记录查询参数page:"+page+"size:"+size);
|
JSONObject respView = esDataService.findEsAllAlarmDataByPage(page,size,startDate,endDate);
|
return Result.ok("全部报警记录查询成功。",respView);
|
}
|
|
|
@ApiOperation(value = "personDetail",notes =
|
"单人报警记录详情{\"id\":\"d820807a-5b83-4321-9b43-e0129102a9ff\",\"personId\":\"psv\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("personDetail")
|
public Result findEsDataByPerson(@RequestBody Map reqMap){
|
String id = (String) reqMap.get("id");
|
String personId = (String) reqMap.get("personId");
|
if (id == null ||id.isEmpty()|| personId == null|| personId.isEmpty()){
|
throw new RuntimeException("数据id,人员personId:"+id+personId+"为空。");
|
}
|
log.info("单人报警记录详情查询参数id:"+id+"personId:"+personId);
|
JSONObject respView = esDataService.getPersonDetail(id,personId);
|
return Result.ok("全部报警记录查询成功。",respView);
|
}
|
|
@ApiOperation(value = "accompanyPerson",notes =
|
"随行人员查询 {\"videoReqNum\":\"reqNum\",\"picDate\":\"2019-01-03 12:12:12\",\"personId\":\"perId\",\"Id\":\"Id\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("accompanyPerson")
|
public Result accompanyPerson(@RequestBody Map reqMap) throws ParseException {
|
String videoReqNum = (String) reqMap.get("videoReqNum");
|
String picDate = (String) reqMap.get("picDate");
|
String personId = (String) reqMap.get("personId");
|
String id = (String) reqMap.get("Id");
|
if (videoReqNum == null ||videoReqNum.isEmpty()|| picDate == null|| picDate.isEmpty()||
|
((personId == null || personId.isEmpty())&&(id == null || id.isEmpty()))){
|
throw new RuntimeException("随行人员查询 videoReqNum,picDate:"+videoReqNum+picDate+"personId:"+personId+"为空。");
|
}
|
log.info("随行人员查询参数videoReqNum:"+videoReqNum+"picDate:"+picDate);
|
JSONObject respView = esDataService.getAccompanyPerson(videoReqNum,personId,picDate,id);
|
return Result.ok("随行人员记录查询成功。",respView);
|
}
|
|
@ApiOperation(value = "getPersonnLocus",notes =
|
"人员轨迹查询 {\"personId\":\"PSVAD010120181215175357774\"," +
|
"\"startDate\":\"2018-12-01\",\"endDate\":\"2018-12-31\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("getPersonnLocus")
|
public Result getPersonnLocus(@RequestBody Map reqMap) throws ParseException {
|
String personId = (String) reqMap.get("personId");
|
String startDate = (String) reqMap.get("startDate");
|
String endDate = (String) reqMap.get("endDate");
|
if (personId == null ||personId.isEmpty()|| startDate == null|| startDate.isEmpty()|| endDate == null|| endDate.isEmpty()){
|
throw new RuntimeException("人员轨迹查询参数 personId,startDate:"+personId+startDate+"endDate"+endDate+"为空。");
|
}
|
log.info("人员轨迹查询参数personId:"+personId+"startDate:"+startDate+startDate+"endDate:"+endDate);
|
JSONObject respView = esDataService.getPersonnLocus(personId,startDate,endDate);
|
return Result.ok("人员轨迹查询成功。",respView);
|
}
|
|
@ApiOperation(value = "getPersonnLocusByJni",notes =
|
"人员轨迹查询 {\"picId\":\"PSVAD010120181215175357.jpg\"}",
|
httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping("getPersonnLocusByJni")
|
public Result getPersonnLocusByJni(@RequestBody Map reqMap) throws ParseException {
|
String picId = (String) reqMap.get("picId");
|
if (picId == null ||picId.isEmpty()){
|
throw new RuntimeException("人员轨迹查询参数 picId:"+picId+"为空。");
|
}
|
log.info("人员轨迹查询参数picId:"+picId);
|
JSONObject respView = esDataService.getPersonnLocusByRedis(picId);
|
return Result.ok("人员轨迹查询成功。",respView);
|
}
|
|
}
|