|
@@ -0,0 +1,361 @@
|
|
|
+package com.huimv.face.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huimv.face.entity.SelectCamera;
|
|
|
+import com.huimv.face.repo.CamerasRepository;
|
|
|
+import com.huimv.face.repo.SelectCameraRepository;
|
|
|
+import com.huimv.face.repo.StrangerModelsRepository;
|
|
|
+import com.huimv.face.util.DateUtils;
|
|
|
+import com.huimv.face.util.HttpClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/api")
|
|
|
+public class APIcontroller {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CamerasRepository camerasRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SelectCameraRepository selectCameraRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StrangerModelsRepository strangerModelsRepository;
|
|
|
+
|
|
|
+ @RequestMapping("/flow/record")
|
|
|
+ public Object list127(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "_t") String _t,
|
|
|
+ @RequestParam(name = "people_id", required = false) String peopleid,
|
|
|
+ @RequestParam(name = "task_id") int task_id,
|
|
|
+ @RequestParam(name = "date") String date) throws IOException {
|
|
|
+ String URL = "http://36.26.62.70:10081/api/flow/record?_t" + _t + "&task_id=" + task_id + "&date=" + date + "&people_id=" + peopleid;
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ System.out.println("flow/record--记录");
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ * @param request
|
|
|
+ * @param _t
|
|
|
+ * @param start_page
|
|
|
+ * @param page_count
|
|
|
+ * @param task_id
|
|
|
+ * @param date
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+//新增0
|
|
|
+ @RequestMapping("/flow/record/list")
|
|
|
+ public Object list121(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "_t") String _t,
|
|
|
+ @RequestParam(name = "start_page", required = false) String start_page, //重复
|
|
|
+ @RequestParam(name = "page_count", required = false) String page_count, //重复
|
|
|
+ @RequestParam(name = "task_id") int task_id,
|
|
|
+ @RequestParam(name = "date") String date) throws IOException {
|
|
|
+ // http://36.22.189.214:8010/api/flow/record/list?_t=1619751478000&start_page=1&page_count=100&task_id=1&date=1619712000000
|
|
|
+ String URL = "http://36.26.62.70:10081/api/flow/record/list?_t" + _t + "&task_id=" + task_id + "&date=" + date + "&start_page=" + start_page + "&page_count=" + page_count;
|
|
|
+
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ System.out.println("通行记录");
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //之前的
|
|
|
+ @RequestMapping("/flow/statistic")
|
|
|
+ public Object list12(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "_t") String _t,
|
|
|
+ @RequestParam(name = "task_id") int task_id,
|
|
|
+ @RequestParam(name = "date") String date) throws IOException {
|
|
|
+
|
|
|
+ String URL = "http://192.168.3.50:10080/api/flow/statistic?_t" + _t + "&" + "task_id=" + task_id + "&" + "date=" + date;
|
|
|
+
|
|
|
+ String URL01 = "http://192.168.3.50:10080/api/flow/statistic?_t=1615898302287&task_id=2&date=1615824000000";
|
|
|
+ String URL02 = "http://36.26.62.70:10081/api/pass_records?_t=1619687680619&start_page=1&page_count=30&camera_id=4";
|
|
|
+ //发送请求
|
|
|
+ String URL03 = "http://36.26.62.70:10081/api/flow/statistic?_t" + _t + "&" + "task_id=" + task_id + "&" + "date=" + date;
|
|
|
+ HttpClient httpClient = new HttpClient(URL03);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ System.out.println("/flow/statistic**请求成功");
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/alarm_records")
|
|
|
+ public Object list13(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "_t", required = false) String _t, //重复
|
|
|
+ @RequestParam(name = "start_page", required = false) String start_page, //重复
|
|
|
+ @RequestParam(name = "page_count", required = false) String page_count, //重复
|
|
|
+ @RequestParam(name = "begin_time", required = false) String begin_time,
|
|
|
+ @RequestParam(name = "end_time", required = false) String end_time,
|
|
|
+ @RequestParam(name = "group_id", required = false) String group_id,
|
|
|
+ @RequestParam(name = "camera_id", required = false) String camera_id,
|
|
|
+ @RequestParam(name = "keyword", required = false) String keyword //重复
|
|
|
+
|
|
|
+ ) throws IOException {
|
|
|
+
|
|
|
+ String URL = "http://192.168.3.50:10080/api/alarm_records?_t" + _t + "&" + "start_page=" + start_page + "&" + "page_count=" + page_count
|
|
|
+ + "&" + "begin_time=" + begin_time + "&" + "end_time=" + end_time
|
|
|
+ + "&" + "group_id=" + group_id + "&" + "camera_id=" + camera_id
|
|
|
+ + "&" + "keyword=" + keyword;
|
|
|
+
|
|
|
+ //换到海盐之后的路径
|
|
|
+ String URL01 = "http://36.26.62.70:10081/api/alarm_records?_t" + _t + "&" + "start_page=" + start_page + "&" + "page_count=" + page_count
|
|
|
+ + "&" + "begin_time=" + begin_time + "&" + "end_time=" + end_time
|
|
|
+ + "&" + "group_id=" + group_id + "&" + "camera_id=" + camera_id
|
|
|
+ + "&" + "keyword=" + keyword;
|
|
|
+ System.out.println(URL01);
|
|
|
+ //http://192.168.3.4:8075/api/alarm_records?_t=1615905127152&start_page=1&page_count=30
|
|
|
+ //&begin_time=1615824000000&end_time=1615870800000&camera_id=&group_id=&keyword='
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL01);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ System.out.println("获取警报记录");
|
|
|
+ // System.out.println(content);
|
|
|
+ return jsonObject;
|
|
|
+ //return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //单个摄像头通行记录 过去一天,过去一周,过去一个月,活动版本 ,想办法修改成SQL操作
|
|
|
+ @RequestMapping("/pass_records")
|
|
|
+ public List<Map> list121(HttpServletRequest request,
|
|
|
+ @RequestParam(name = "modo") int modo,//1.天 2.周 3.月
|
|
|
+ @RequestParam(name = "_t") String _t,
|
|
|
+ @RequestParam(name = "kind") int kind //1.在库 2.陌生人
|
|
|
+ ) throws Exception {
|
|
|
+ //选中的摄像头在 select_cameras 表中,直接查找第一条
|
|
|
+ SelectCamera selectCamera = selectCameraRepository.selectid1();
|
|
|
+ JSONArray jsonArray = JSONObject.parseArray(selectCamera.getCamera());
|
|
|
+ System.out.println("得到的数组为" + jsonArray);
|
|
|
+ List<Map> countlist01 = new ArrayList();
|
|
|
+ Iterator<Object> it = jsonArray.iterator();
|
|
|
+ if (kind == 1) {
|
|
|
+ while (it.hasNext()) {
|
|
|
+ int job = Integer.parseInt((String) it.next());
|
|
|
+ System.out.println("数值" + job);
|
|
|
+ //摄像机位置
|
|
|
+ String cameraAddress = camerasRepository.findByIdtest(job).getCameraAddress();
|
|
|
+ System.out.println("查询地址结束");
|
|
|
+ int pagecount = 50000;
|
|
|
+ int startpage = 1;
|
|
|
+ //想办法制作成从数据库查询
|
|
|
+ String URL = "http://36.26.62.70:10081/api/pass_records?_t=" + _t + "&start_page=" + startpage + "&page_count=" + pagecount + "&camera_id=" + job;
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ JSONObject dataJo = jsonObject.getJSONObject("data");
|
|
|
+ JSONArray listJa = dataJo.getJSONArray("list");//获取所有的数据
|
|
|
+ System.out.println("返回数量: " + listJa.size());
|
|
|
+ //统计所有的数据,进行循环处理。通过比较时间,获得链表长度
|
|
|
+ List<Integer> count_total_passrecord = new ArrayList();
|
|
|
+ for (Object object : listJa) {
|
|
|
+ Map<String, Object> maps = new HashMap<String, Object>();
|
|
|
+ maps.putAll((Map<? extends String, ?>) object);
|
|
|
+ //获取时间,拿到单条数据时间用于下面的比对
|
|
|
+ Long getDataTime = (Long) maps.get("time");
|
|
|
+ Date date = new Date();
|
|
|
+ Date passda = new Date();
|
|
|
+ if (modo == 1) {
|
|
|
+ passda = DateUtils.getPassedDay();
|
|
|
+ System.out.println("过去一天" + passda);
|
|
|
+ } else if (modo == 2) {
|
|
|
+ passda = DateUtils.getPassedWeek();
|
|
|
+ System.out.println("过去一周" + passda);
|
|
|
+ } else if (modo == 3) {
|
|
|
+ passda = DateUtils.getPassedMonth();
|
|
|
+ System.out.println("过去一月" + passda);
|
|
|
+ }
|
|
|
+ //获取当前的时间,直接对时间戳进行比较
|
|
|
+ Date datee = new Date(getDataTime);
|
|
|
+ if (datee.getTime() > passda.getTime()) {
|
|
|
+ count_total_passrecord.add(1);
|
|
|
+ }
|
|
|
+ System.out.println(date);
|
|
|
+ }
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put(cameraAddress, count_total_passrecord.size());
|
|
|
+ countlist01.add(map);
|
|
|
+ }
|
|
|
+ return countlist01;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //2.陌生人
|
|
|
+ while (it.hasNext()) {
|
|
|
+ int job = Integer.parseInt((String) it.next());
|
|
|
+ System.out.println("数值" + job);
|
|
|
+ //摄像机位置
|
|
|
+ String cameraAddress = camerasRepository.findByIdtest(job).getCameraAddress();
|
|
|
+ System.out.println("查询地址结束");
|
|
|
+
|
|
|
+ //统计所有的数据,进行循环处理。通过比较时间,获得链表长度
|
|
|
+ List<Integer> count_stranger_passrecord = new ArrayList();
|
|
|
+ //统计陌生人
|
|
|
+ List<List<Object>> findbycameras = strangerModelsRepository.findbycameras(job);
|
|
|
+ for (List<Object> list : findbycameras) {
|
|
|
+ System.out.println(list.get(0)); //1616579737356
|
|
|
+
|
|
|
+ Long time = Long.valueOf(list.get(0).toString());
|
|
|
+
|
|
|
+ Date passda = new Date();
|
|
|
+ if (modo == 1) {
|
|
|
+ passda = DateUtils.getPassedDay();
|
|
|
+ System.out.println("过去一天" + passda);
|
|
|
+ } else if (modo == 2) {
|
|
|
+ passda = DateUtils.getPassedWeek();
|
|
|
+ System.out.println("过去一周" + passda);
|
|
|
+ } else if (modo == 3) {
|
|
|
+ passda = DateUtils.getPassedMonth();
|
|
|
+ System.out.println("过去一月" + passda);
|
|
|
+ }
|
|
|
+ //陌生人的人数
|
|
|
+ //获取当前的时间,直接对时间戳进行比较
|
|
|
+ Date datee = new Date(time);
|
|
|
+ if (datee.getTime() > passda.getTime()) {
|
|
|
+ count_stranger_passrecord.add(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put(cameraAddress, count_stranger_passrecord.size());
|
|
|
+ countlist01.add(map);
|
|
|
+ }
|
|
|
+ return countlist01;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+ //单个摄像头通行记录 过去一天 过去一周 过去一个月 写死版本 淘汰
|
|
|
+ @RequestMapping("/pass_records1")
|
|
|
+ public List<Map> list12 (HttpServletRequest request,
|
|
|
+ @RequestParam(name = "modo") int modo,//1.天 2.周 3.月
|
|
|
+ @RequestParam(name = "_t") String _t,
|
|
|
+ @RequestParam(name = "start_page") int startpage,
|
|
|
+ @RequestParam(name = "page_count") int pagecount,
|
|
|
+ @RequestParam(name = "camera_id") int cameraid
|
|
|
+ // @RequestParam(name = "date") String date
|
|
|
+ ) throws Exception {
|
|
|
+
|
|
|
+ List<Map> countlist01 = new ArrayList();
|
|
|
+ List<Integer> countlist02 = new ArrayList();
|
|
|
+ countlist02.add(1);
|
|
|
+ countlist02.add(3);
|
|
|
+ countlist02.add(4);
|
|
|
+ countlist02.add(6);
|
|
|
+ countlist02.add(7);
|
|
|
+ for (Integer i : countlist02) {
|
|
|
+
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ pagecount = 5;
|
|
|
+ String URL = "http://36.26.62.70:10081/api/pass_records?_t=" + _t + "&start_page=" + startpage + "&page_count=" + pagecount + "&camera_id=" + i;
|
|
|
+
|
|
|
+ //发送请求
|
|
|
+ HttpClient httpClient = new HttpClient(URL);
|
|
|
+ httpClient.setHttps(false);
|
|
|
+ httpClient.get();
|
|
|
+ String content = httpClient.getContent();
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ JSONObject dataJo = jsonObject.getJSONObject("data");
|
|
|
+ JSONArray listJa = dataJo.getJSONArray("list");
|
|
|
+ System.out.println("返回数量: " + listJa.size());
|
|
|
+ //统计 所有的数据 进行循环处理
|
|
|
+ List<Integer> countlist = new ArrayList();
|
|
|
+ for (Object object : listJa) {
|
|
|
+ Map<String, Object> maps = new HashMap<String, Object>();
|
|
|
+ maps.putAll((Map<? extends String, ?>) object);
|
|
|
+ //获取时间
|
|
|
+ Long time = (Long) maps.get("time");
|
|
|
+ String longToStr = Long.toString(time);
|
|
|
+ Date date = new Date();
|
|
|
+ Date passda = new Date();
|
|
|
+ if (modo == 1) {
|
|
|
+ passda = DateUtils.getPassedDay();
|
|
|
+ System.out.println("过去一天" + passda);
|
|
|
+ } else if (modo == 2) {
|
|
|
+ passda = DateUtils.getPassedWeek();
|
|
|
+ System.out.println("过去一周" + passda);
|
|
|
+ } else if (modo == 3) {
|
|
|
+ passda = DateUtils.getPassedMonth();
|
|
|
+ System.out.println("过去一月" + passda);
|
|
|
+ }
|
|
|
+ //直接对时间戳进行比较
|
|
|
+ Date datee = new Date(time);//获取的时间
|
|
|
+ if (datee.getTime() > passda.getTime()) {
|
|
|
+ countlist.add(1);
|
|
|
+ }
|
|
|
+ System.out.println(date);
|
|
|
+ System.out.println(time);
|
|
|
+ }
|
|
|
+ // System.out.println(content);
|
|
|
+ switch (i) {
|
|
|
+ case 1:
|
|
|
+ map.put("产房过道西", countlist.size());//1
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ map.put("产房外入口", countlist.size());//3
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ map.put("产房淋浴出口", countlist.size());//4
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ map.put("产房区产房过道中", countlist.size());//6
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ map.put("怀配四单元中间过道", countlist.size());//7
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ countlist01.add(map);
|
|
|
+ }
|
|
|
+ return countlist01;
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|