liuxiaolong
2019-05-06 0bc4f4c791437b39b8c30624f5c21f8c855dc61d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.cloud.retrieve.controller;
 
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cloud.model.common.Result;
import com.cloud.retrieve.service.AggDataByEsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.Map;
 
@Api(value = "EsDataBaseController",description = "底库信息和分析列表查询")
@RestController
@RequestMapping("/data/api-r/dataBase")
public class EsDataBaseController {
 
    @Autowired
    private AggDataByEsService aggDataByEsService;
    @RequestMapping(value = "getAllDataBaseListByEs")
    @ApiOperation(value = "getAllDataBaseListByEs",notes = "查询全部底库数据",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
    })
    public Result getAllDataBaseListByEs(){
        JSONArray dataBaseList = aggDataByEsService.getAllDataBaseFromEs();
        return Result.ok("查询底库信息成功。",dataBaseList);
    }
 
    @RequestMapping("getAnalyListByEs")
    @ApiOperation(value = "getAnalyListByEs",notes = "查询全部分析条件数据",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiImplicitParams({
    })
    public Result getAnalysListByEs(){
        JSONArray analyList = aggDataByEsService.getAnalyListByEs();
        return Result.ok("查询分析条件信息成功。",analyList);
    }
 
    /**
     * 从 es 汇总设备数量
     * @return
     */
    @ApiOperation(value = "cameraCount",notes = "查询设备报警数量",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping("cameraCount")
    public Result cameraCount(){
        JSONObject respupdate = aggDataByEsService.aggEsDevSum();
            return  Result.ok("查询设备报警数量成功。",respupdate);
    }
 
    /**
     * 加条件设备数量
     * @return
     */
    @ApiOperation(value = "queryCameraCount",notes = "给定条件查询设备报警数量 " +
            "{\"dataBaseList\":[],\"sdkType\":[\"人脸\",\"拥挤\"],\"reqNumList\":[]," +
            "\"startDate\":\"2019-01-03\",\"endDate\":\"2019-01-12\"}",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping("queryCameraCount")
    public Result queryCameraCount(@RequestBody Map reqParam){
        List<String> baseName = (List<String>) reqParam.get("dataBaseList");
        List<String> analyType = (List<String>) reqParam.get("sdkType");
        List<String> videoReqNum = (List<String>) reqParam.get("reqNumList");
        String startDate = (String) reqParam.get("startDate");
        String endDate = (String) reqParam.get("endDate");
        JSONObject respupdate = aggDataByEsService.aggDevSumByEsParams(baseName,analyType,videoReqNum,startDate,endDate);
        return  Result.ok("查询设备报警数量成功。",respupdate);
    }
 
    /**
     * 从 es 汇总 人员报警数量
     * @return
     */
    @ApiOperation(value = "personHubCount",notes = "查询人员报警数量",httpMethod = "POST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @RequestMapping("personHubCount")
    public Result personHubCount(){
        JSONObject respupdate = aggDataByEsService.aggEsPersonSum();
        return  Result.ok("查询人员报警数量成功。",respupdate);
    }
 
 
}