From 7cfa09050726578c2cc5114e5bc8a419e6e2e466 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 15 十月 2024 11:03:45 +0800
Subject: [PATCH] 人脸上传数据延迟修复
---
ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java | 107 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 61 insertions(+), 46 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
index 548f892..0438581 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
@@ -240,9 +240,6 @@
notAddList.add(workOrder);
continue;
}
- //鏁板瓧鍓嶉潰琛�0
- workOrderNum++;
- workOrder.setWorkOrderNo(IdUtils.workOrderNO(now, String.format("%05d", workOrderNum)));
if (Objects.nonNull(point.getUnitId())) {
workOrder.setUnitId(Math.toIntExact(point.getUnitId()));
}
@@ -265,7 +262,12 @@
if (CollectionUtils.isEmpty(waitAddList)) {
return Boolean.TRUE;
}
- //璁板綍宸ュ崟鏁�
+ //璁板綍宸ュ崟鏁�,琛ュ厖宸ュ崟鍙�
+ for (WorkOrder workOrder : waitAddList) {
+ //鏁板瓧鍓嶉潰琛�0
+ workOrderNum++;
+ workOrder.setWorkOrderNo(IdUtils.workOrderNO(now, String.format("%05d", workOrderNum)));
+ }
redisCache.setCacheObject(RedisConstant.WORKORDER_NUM, workOrderNum);
redisCache.releaseLock(RedisConstant.WORKORDER_NUM_LOCK, requestId);
// 淇濆瓨宸ュ崟鍜屾晠闅滅被鍨�
@@ -764,51 +766,64 @@
@Override
public synchronized String getFrameImgByDevice(String deviceId, String channelId, String workOrderNo) throws Exception {
- String url = String.format(this.rtspServer + "/api/play/start/%s/%s", deviceId, channelId);
+ String url = String.format(this.rtspServer + "/api/play/start/img/%s/%s", deviceId, channelId);
String result = HttpUtils.sendGet(url);
- log.error("鎷垮埌鍙栨祦鍝嶅簲缁撴灉锛�" + result);
+ log.info("鎷垮埌鍙栨祦鍥剧墖鍝嶅簲缁撴灉锛�" + result);
WVPResult wvpResult = JSON.parseObject(result, WVPResult.class);
- String imgUrl = null;
- if (0 == wvpResult.getCode()) {
- log.error("璇锋眰鎴愬姛");
- JSONObject data = (JSONObject) wvpResult.getData();
- String rtspUrl = data.getString("rtsp"); // 鍙栧湴鍧�
- log.error("鐩爣鍦板潃锛�" + rtspUrl);
- FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault(rtspUrl);
- if (StringUtils.hasText(rtspUrl)) {
- try {
- grabber.setOption("rtsp_transport", "tcp"); // 浣跨敤tcp鐨勬柟寮忥紝涓嶇劧浼氫涪鍖呭緢涓ラ噸
- grabber.setImageWidth(1920);
- grabber.setImageHeight(1080);
- grabber.setFrameRate(25);
- grabber.start();
-
- Frame frame = grabber.grabFrame();
- if (frame != null) {
- //杞崲鍥惧儚
- Java2DFrameConverter converter = new Java2DFrameConverter();
- BufferedImage srcImage = converter.getBufferedImage(frame);
- if (srcImage != null) {
- imgUrl = workOrderNo + "_" + IdUtils.fastSimpleUUID() + ".png";
- // 鐢熸垚鍥剧墖璺緞
- String imgPath = PlatformConfig.getProfile() + "/" + imgUrl;
- System.out.println("鍥剧墖淇濆瓨鍦板潃锛�" + imgPath);
- imgUrl = Constants.RESOURCE_PREFIX + "/" + imgUrl;
- //鍒涘缓鏂囦欢
- File file = new File(imgPath);
- //杈撳嚭鏂囦欢
- ImageIO.write(srcImage, "png", file);
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- grabber.stop(); // 鍋滄鎹曡幏
- grabber.close(); // 閲婃斁璧勬簮
- }
- }
+ if(wvpResult.getCode() == 0) {
+ Object imgUrl = (Object) wvpResult.getData();
+ imgUrl = Objects.isNull(imgUrl) ? "" : imgUrl;
+ log.info("鎷垮埌鍙栨祦鍥剧墖锛�" + imgUrl);
+ return (String) imgUrl;
}
- return imgUrl;
+ return null;
+// WVPResult wvpResult = JSON.parseObject(result, WVPResult.class);
+// String imgUrl = null;
+// if (wvpResult.getCode() == 0) {
+// JSONObject data = (JSONObject) wvpResult.getData();
+// String rtspUrl = data.getString("fmp4"); // 鍙杕p4鍦板潃
+// if (StringUtils.hasText(rtspUrl)) {
+// System.out.println("鐩爣鍦板潃锛�" + rtspUrl);
+// FFmpegFrameGrabber grabber = null;
+// try {
+// grabber = new FFmpegFrameGrabber(rtspUrl);
+//// grabber.setOption("rtsp_transport", "tcp"); // 浣跨敤tcp鐨勬柟寮忥紝涓嶇劧浼氫涪鍖呭緢涓ラ噸
+//// grabber.setVideoOption("probesize", "10000"); // 璁剧疆鎹曡幏鍒嗘瀽鐨勬渶澶у瓧鑺�
+// grabber.start();
+// Frame frame = grabber.grabImage(); // 鐩存帴鎹曡幏涓�甯�
+// if (frame != null) {
+// System.out.println("鎴愬姛鎹曡幏涓�甯�");
+// // 灏咶rame杞崲涓篗at
+// OpenCVFrameConverter.ToMat converter = new OpenCVFrameConverter.ToMat();
+// Mat mat = converter.convertToMat(frame);
+//
+// imgUrl = workOrderNo + "_" + IdUtils.fastSimpleUUID() + ".png";
+// // 鐢熸垚鍥剧墖璺緞
+// String imgPath = PlatformConfig.getProfile() + "/" + imgUrl;
+// System.out.println("鍥剧墖淇濆瓨鍦板潃锛�" + imgPath);
+// imgUrl = Constants.RESOURCE_PREFIX + "/" + imgUrl;
+// // 淇濆瓨鍥剧墖
+// opencv_imgcodecs.imwrite(imgPath, mat);
+// } else {
+// System.out.println("鏈崟鑾峰埌甯�");
+// }
+// } catch (FrameGrabber.Exception e) {
+// e.printStackTrace();
+// } finally {
+// if (grabber != null) {
+// try {
+// grabber.stop(); // 鍋滄鎹曡幏
+// } catch (FrameGrabber.Exception e) {
+// e.printStackTrace();
+// }
+// }
+// }
+// }
+// } else {
+// System.out.println("璇锋眰澶辫触锛岄敊璇爜锛�" + wvpResult.getCode() + "--" + wvpResult.getMsg());
+// }
+// System.out.println("鍥剧墖URL锛�" + imgUrl);
+// return imgUrl;
}
@Override
--
Gitblit v1.8.0