|
@@ -0,0 +1,197 @@
|
|
|
+package com.gis.web.controller.dafengSmartCommunityController;
|
|
|
+
|
|
|
+import com.gis.common.config.ConfigConstant;
|
|
|
+import com.gis.common.deyuan.util.NewResultUtils;
|
|
|
+import com.gis.common.deyuan.util.ResultUtils;
|
|
|
+import com.gis.common.util.DoorUtils;
|
|
|
+import com.gis.common.util.IOTUtils;
|
|
|
+import com.gis.common.util.Result;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.sql.Date;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Log4j2
|
|
|
+@Api(tags = "云平台-社区监控")
|
|
|
+@RestController
|
|
|
+@RequestMapping("communityMonitor")
|
|
|
+public class CommunityMonitor {
|
|
|
+ @Autowired
|
|
|
+ NewResultUtils resultUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ConfigConstant configConstant;
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "code", value = "小区编码 如:510115001076510115001076012", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime", value = "开始时间 格式: yyyy-MM-dd HH:mm:ss 如:2021-12-15 16:20:20", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime", value = "结束时间 格式: yyyy-MM-dd HH:mm:ss", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("车辆进出监控")
|
|
|
+ @GetMapping("vehicleEntrance/{code}/{startTime}/{endTime}")
|
|
|
+ public Result vehicleEntrance(@PathVariable String code,@PathVariable String startTime,@PathVariable String endTime){
|
|
|
+ SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date(System.currentTimeMillis());
|
|
|
+ String day=formatter.format(date);
|
|
|
+ System.out.println(formatter.format(date));
|
|
|
+ String apiUrl = "/open/api/v1/device/vehicleEntrance";
|
|
|
+ HashMap<String, Object> param = new HashMap<>();
|
|
|
+ param.put("residentialCode", code);
|
|
|
+ param.put("startTime", startTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+ return resultUtils.doGetResult(apiUrl, param);
|
|
|
+ }
|
|
|
+// @ApiOperation("重点人员进出预警")
|
|
|
+// @GetMapping("peopleEntrance/{code}/{page}/{size}")
|
|
|
+// public Result peopleEntrance(@PathVariable String code,@PathVariable int page,@PathVariable int size){
|
|
|
+// String apiUrl = "/open/api/v1/device/peopleEntrance";
|
|
|
+// HashMap<String, Object> param = new HashMap<>();
|
|
|
+// param.put("townCode", code);
|
|
|
+// param.put("page", page);
|
|
|
+// param.put("size", size);
|
|
|
+// return resultUtils.doGetResult(apiUrl, param);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("根据社区code得到小区code")
|
|
|
+ @GetMapping("residential/{code}")
|
|
|
+ public Result residential(@PathVariable String code){
|
|
|
+ String apiUrl = "/open/api/v1/community/fuzzy/search/residential";
|
|
|
+ HashMap<String, Object> param = new HashMap<>();
|
|
|
+ param.put("areaCode", code);
|
|
|
+ param.put("pageIndex", 1);
|
|
|
+ param.put("pageSize", 100);
|
|
|
+ return resultUtils.doGetResult(apiUrl, param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "code", value = "小区编码 如:510115001076510115001076012", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime", value = "开始时间 格式: yyyy-MM-dd HH:mm:ss 如:2021-12-15 16:20:20", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime", value = "结束时间 格式: yyyy-MM-dd HH:mm:ss", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("出行时间异常人群")
|
|
|
+ @GetMapping("peopleEntrance/{code}/{startTime}/{endTime}")
|
|
|
+ public Result peopleEntrance(@PathVariable String code,@PathVariable String startTime,@PathVariable String endTime){
|
|
|
+ String apiUrl = "/open/api/v1/device/peopleEntrance";
|
|
|
+ return getTimeCount(apiUrl,code,startTime,endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// @ApiImplicitParams({
|
|
|
+// @ApiImplicitParam(name = "code", value = "小区编码", dataType = "String"),
|
|
|
+// })
|
|
|
+// @ApiOperation("出行时间异常人群")
|
|
|
+// @GetMapping("peopleEntrance/{code}")
|
|
|
+// public String peopleEntrance(@PathVariable String code){
|
|
|
+// SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+// Date date = new Date(System.currentTimeMillis());
|
|
|
+// String day=formatter.format(date);
|
|
|
+// System.out.println(formatter.format(date));
|
|
|
+// String time1=day+" 00:00:00";
|
|
|
+// String time2=day+" 01:00:00";
|
|
|
+// String time3=day+" 02:00:00";
|
|
|
+// String time4=day+" 03:00:00";
|
|
|
+// String time5=day+" 04:00:00";
|
|
|
+// String time6=day+" 05:00:00";
|
|
|
+// String time7=day+" 06:00:00";
|
|
|
+//
|
|
|
+// String apiUrl = "/open/api/v1/device/peopleEntrance";
|
|
|
+// int num1=getTimeCount(apiUrl,code,time1,time2);
|
|
|
+// int num2=getTimeCount(apiUrl,code,time2,time3);
|
|
|
+// int num3=getTimeCount(apiUrl,code,time3,time4);
|
|
|
+// int num4=getTimeCount(apiUrl,code,time4,time5);
|
|
|
+// int num5=getTimeCount(apiUrl,code,time5,time6);
|
|
|
+// int num6=getTimeCount(apiUrl,code,time6,time7);
|
|
|
+//
|
|
|
+// return num1+" "+num2+" "+num3+" "+num4+" "+num5+" "+num6;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ private Result getTimeCount(String url,String code,String time1,String time2){
|
|
|
+ HashMap<String, Object> param = new HashMap<>();
|
|
|
+ param.put("residentialCode", code);
|
|
|
+ param.put("startTime", time1);
|
|
|
+ param.put("endTime", time2);
|
|
|
+ Result residentialResult= resultUtils.doGetResult(url, param);
|
|
|
+
|
|
|
+ return residentialResult;
|
|
|
+ }
|
|
|
+// /*
|
|
|
+// * 根据社区编码获取社区所有小区编码
|
|
|
+// * @param code 社区编码
|
|
|
+// */
|
|
|
+// private List<String> getResidentialCode(String code){
|
|
|
+// String residentialResultUrl="/open/api/v1/community/fuzzy/search/residential";
|
|
|
+// HashMap<String, Object> param1 = new HashMap<>();
|
|
|
+// param1.put("areaCode", code);
|
|
|
+// param1.put("pageIndex", 1);
|
|
|
+// param1.put("pageSize", 100);
|
|
|
+// Result residentialResult= resultUtils.doGetResult(residentialResultUrl, param1);
|
|
|
+// JSONObject obj=(JSONObject) residentialResult.getData();
|
|
|
+// JSONArray arr=obj.getJSONArray("res");
|
|
|
+// List<String> codes=new ArrayList<String>();
|
|
|
+// Iterator<Object> it = arr.iterator();
|
|
|
+// while (it.hasNext()) {
|
|
|
+// JSONObject ob = (JSONObject) it.next();
|
|
|
+// codes.add(ob.getString("residentialCode"));
|
|
|
+// //打印出遍历出的jsonObject
|
|
|
+// System.out.println(ob.getString("residentialCode"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// return codes;
|
|
|
+// }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "code", value = "组织机构编码 如:510114001017240", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("视频列表数据")
|
|
|
+ @GetMapping("videoList/{code}")
|
|
|
+ public Result videoList(@PathVariable String code) throws Exception {
|
|
|
+ String apiUrl =configConstant.apiVideo+"/bi/findVideoInfo";
|
|
|
+ System.out.println("apiUrl: "+apiUrl);
|
|
|
+ TreeMap<String, Object> param = new TreeMap<>();
|
|
|
+ param.put("code", code);
|
|
|
+ param.put("pageSize", 200);
|
|
|
+ return DoorUtils.doPostDecrypt(apiUrl,param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "视频id ", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "code", value = "小区组织机构编码 如:510114001017240", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "protocol", value = "取流协议 “rtmp”:RTMP协议;“hls”:HLS协议", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("获取视频流-普通")
|
|
|
+ @GetMapping("getVideo/{code}/{id}/{protocol}")
|
|
|
+ public Result getVideo(@PathVariable String code,@PathVariable String id,@PathVariable String protocol) throws Exception {
|
|
|
+ String apiUrl =configConstant.apiVideo+"/bi/getVideoUrlById";
|
|
|
+ TreeMap<String, Object> param = new TreeMap<>();
|
|
|
+ param.put("code", code);
|
|
|
+ param.put("id", id);
|
|
|
+ param.put("protocol", protocol);
|
|
|
+ return DoorUtils.doPostDecrypt(apiUrl,param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "视频id ", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "code", value = "小区组织机构编码 如:510114001017240", dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "protocol", value = "取流协议 “rtmp”:RTMP协议;“hls”:HLS协议", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("获取视频流-物联平台")
|
|
|
+ @GetMapping("getVideoIOT/{code}/{id}/{protocol}")
|
|
|
+ public Result getVideoIOT(@PathVariable String code,@PathVariable String id,@PathVariable String protocol) throws Exception {
|
|
|
+ String apiUrl =configConstant.apiIOTVideo+"/api/getVideoUrlById";
|
|
|
+ TreeMap<String, Object> param = new TreeMap<>();
|
|
|
+ param.put("code", code);
|
|
|
+ param.put("id", id);
|
|
|
+ param.put("protocol", protocol);
|
|
|
+ return IOTUtils.doPostDecrypt(apiUrl,param);
|
|
|
+ }
|
|
|
+}
|