|
|
@@ -4,17 +4,27 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.template.api.HikvisionAPI;
|
|
|
+import com.template.api.SmartNotificationControllerAPI;
|
|
|
import com.template.common.utils.GetCameraPreviewURL;
|
|
|
+import com.template.common.utils.Message2;
|
|
|
import com.template.model.pojo.SmartFaceDiscern;
|
|
|
+import com.template.model.pojo.SmartNotification;
|
|
|
+import com.template.model.pojo.SmartUser;
|
|
|
import com.template.model.pojo.SmartWarning;
|
|
|
import com.template.services.SmartFaceDiscernService;
|
|
|
+import com.template.services.SmartNotificationService;
|
|
|
+import com.template.services.SmartUserService;
|
|
|
import com.template.services.SmartWarningService;
|
|
|
+import org.aspectj.weaver.ast.Var;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.InputStreamReader;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
public class HikvisionController implements HikvisionAPI {
|
|
|
@@ -25,9 +35,16 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
@Autowired
|
|
|
SmartFaceDiscernService smartFaceDiscernService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SmartUserService smartUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SmartNotificationService smartNotificationService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 事件订阅
|
|
|
+ *
|
|
|
* @param request
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -60,9 +77,10 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
// 地点
|
|
|
String srcName = jsonObject1.getString("srcName");
|
|
|
smartWarning.setLocation(srcName);
|
|
|
-
|
|
|
+// 推送的事件
|
|
|
+ String pushType = "";
|
|
|
if ("131588".equals(eventType)) {
|
|
|
-
|
|
|
+ pushType = "区域入侵";
|
|
|
smartWarning.setType("区域入侵");
|
|
|
|
|
|
JSONArray fielddetection = data.getJSONArray("fielddetection");
|
|
|
@@ -72,7 +90,9 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
String imageUrl = jsonObject2.getString("imageUrl");
|
|
|
smartWarning.setImage(imageUrl);
|
|
|
|
|
|
- }else if ("131586".equals(eventType)){
|
|
|
+ } else if ("131586".equals(eventType)) {
|
|
|
+ pushType = "进入危险区域";
|
|
|
+
|
|
|
smartWarning.setType("进入区域");
|
|
|
|
|
|
JSONArray regionEntrance = data.getJSONArray("regionEntrance");
|
|
|
@@ -82,7 +102,9 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
String imageUrl = jsonObject2.getString("imageUrl");
|
|
|
smartWarning.setImage(imageUrl);
|
|
|
|
|
|
- }else if ("131587".equals(eventType)){
|
|
|
+ } else if ("131587".equals(eventType)) {
|
|
|
+ pushType = "离开安全区域";
|
|
|
+
|
|
|
smartWarning.setType("离开区域");
|
|
|
|
|
|
JSONArray regionExiting = data.getJSONArray("regionExiting");
|
|
|
@@ -92,7 +114,9 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
String imageUrl = jsonObject2.getString("imageUrl");
|
|
|
smartWarning.setImage(imageUrl);
|
|
|
|
|
|
- }else if ("131605".equals(eventType)){
|
|
|
+ } else if ("131605".equals(eventType)) {
|
|
|
+ pushType = "人员倒地";
|
|
|
+
|
|
|
smartWarning.setType("倒地");
|
|
|
|
|
|
JSONArray fallDown = data.getJSONArray("fallDown");
|
|
|
@@ -106,8 +130,38 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
|
|
|
smartWarningService.save(smartWarning);
|
|
|
|
|
|
+// 获取推送人
|
|
|
+ List<SmartUser> smartUserList = smartUserService.getListPush();
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(smartUserList) && smartUserList.size() > 0) {
|
|
|
+ for (SmartUser smartUser : smartUserList) {
|
|
|
+ SmartNotification smartNotification = new SmartNotification();
|
|
|
+ smartNotification.setUserId(smartUser.getId());
|
|
|
+ smartNotification.setTypeName(pushType);
|
|
|
+ smartNotification.setLocation(smartWarning.getLocation());
|
|
|
+ smartNotification.setImage(smartWarning.getImage());
|
|
|
+ smartNotification.setDateTime(smartWarning.getDateTime());
|
|
|
+ smartNotification.setType(1);
|
|
|
+
|
|
|
+ String gzhOpenId = smartUser.getGzhOpenId();
|
|
|
+ if (ObjectUtils.isNotEmpty(gzhOpenId)) {
|
|
|
+
|
|
|
+ // 时间格式是 yyyy-MM-dd HH:mm:ss,当前时间格式有问题
|
|
|
+ DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ String format = now.format(dateTimeFormatter1);
|
|
|
+
|
|
|
+// 公众号信息推送
|
|
|
+ Message2.send(gzhOpenId, pushType, smartWarning.getLocation(), format);
|
|
|
+
|
|
|
+ smartNotificationService.save(smartNotification);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -116,6 +170,7 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
|
|
|
/**
|
|
|
* 人脸比对
|
|
|
+ *
|
|
|
* @param request
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -167,7 +222,7 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
JSONObject jsonObject3 = faces.getJSONObject(0);
|
|
|
// 对比成功的图片
|
|
|
JSONArray identify = jsonObject3.getJSONArray("identify");
|
|
|
- if (ObjectUtils.isNotEmpty(identify)&&identify.size()>0) {
|
|
|
+ if (ObjectUtils.isNotEmpty(identify) && identify.size() > 0) {
|
|
|
// 取对比成功的第一张
|
|
|
JSONObject jsonObject4 = identify.getJSONObject(0);
|
|
|
JSONArray candidate = jsonObject4.getJSONArray("candidate");
|
|
|
@@ -196,6 +251,7 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
|
|
|
/**
|
|
|
* 重点人员
|
|
|
+ *
|
|
|
* @param request
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -209,7 +265,7 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
|
|
|
|
|
|
- System.out.println("jsonObject = " + jsonObject);
|
|
|
+// System.out.println("jsonObject = " + jsonObject);
|
|
|
|
|
|
JSONObject params = jsonObject.getJSONObject("params");
|
|
|
|
|
|
@@ -255,6 +311,38 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
|
|
|
|
|
|
smartWarningService.save(smartWarning);
|
|
|
+
|
|
|
+
|
|
|
+ // 获取推送人
|
|
|
+ List<SmartUser> smartUserList = smartUserService.getListPush();
|
|
|
+
|
|
|
+ String pushType = "危险人员";
|
|
|
+
|
|
|
+ for (SmartUser smartUser : smartUserList) {
|
|
|
+ String gzhOpenId = smartUser.getGzhOpenId();
|
|
|
+ if (ObjectUtils.isNotEmpty(gzhOpenId)) {
|
|
|
+ SmartNotification smartNotification = new SmartNotification();
|
|
|
+ smartNotification.setUserId(smartUser.getId());
|
|
|
+ smartNotification.setUserName(faceInfoName);
|
|
|
+ smartNotification.setTypeName(pushType);
|
|
|
+ smartNotification.setLocation(smartWarning.getLocation());
|
|
|
+ smartNotification.setImage(smartWarning.getImage());
|
|
|
+ smartNotification.setDateTime(smartWarning.getDateTime());
|
|
|
+ smartNotification.setType(1);
|
|
|
+
|
|
|
+ // 时间格式是 yyyy-MM-dd HH:mm:ss,当前时间格式有问题
|
|
|
+ DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ String format = now.format(dateTimeFormatter1);
|
|
|
+
|
|
|
+// 公众号信息推送
|
|
|
+ Message2.send(gzhOpenId, pushType, smartWarning.getLocation(), format);
|
|
|
+
|
|
|
+ smartNotificationService.save(smartNotification);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -265,13 +353,13 @@ public class HikvisionController implements HikvisionAPI {
|
|
|
|
|
|
@Override
|
|
|
public JSONObject playback() {
|
|
|
- String url="/api/video/v2/cameras/playbackURLs";
|
|
|
+ String url = "/api/video/v2/cameras/playbackURLs";
|
|
|
JSONObject jsonBoxdy = new JSONObject();
|
|
|
- jsonBoxdy.put("cameraIndexCode","ff2a2978a71c4ba0ac43a1a6be97a1a1");
|
|
|
- jsonBoxdy.put("streamType",0);
|
|
|
- jsonBoxdy.put("protocol","rtsp");
|
|
|
- jsonBoxdy.put("transmode",1);
|
|
|
- String s =GetCameraPreviewURL.CameraPreviewURL(url, jsonBoxdy);
|
|
|
+ jsonBoxdy.put("cameraIndexCode", "ff2a2978a71c4ba0ac43a1a6be97a1a1");
|
|
|
+ jsonBoxdy.put("streamType", 0);
|
|
|
+ jsonBoxdy.put("protocol", "rtsp");
|
|
|
+ jsonBoxdy.put("transmode", 1);
|
|
|
+ String s = GetCameraPreviewURL.CameraPreviewURL(url, jsonBoxdy);
|
|
|
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(s);
|
|
|
return jsonObject1;
|