From ddb3068a51a8af8aa9a8f8c2cb9b6e9228b0c8d9 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 28 八月 2024 11:53:27 +0800
Subject: [PATCH] 同步国标设备、点播定时任务优化
---
/dev/null | 18 -
ycl-server/src/main/resources/mapper/zgyw/WorkOrderMapper.xml | 7
ycl-server/src/main/java/com/ycl/task/DeviceSynTask.java | 66 ++++++
ycl-server/src/main/java/com/ycl/task/WorkOrderImgTask.java | 18 +
ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java | 2
ycl-pojo/src/main/java/com/ycl/platform/wvp/Device.java | 463 ++++++++++++++++++++++++++++++++++++++++++++++
ycl-pojo/src/main/java/com/ycl/platform/domain/entity/DeviceInfo.java | 6
7 files changed, 553 insertions(+), 27 deletions(-)
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/DeviceInfo.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/DeviceInfo.java
index f8a17e0..e3b294a 100644
--- a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/DeviceInfo.java
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/DeviceInfo.java
@@ -22,9 +22,9 @@
/** 璁惧缂栧彿/鍥芥爣鐮� */
private String deviceId;
- @TableField("channel_id")
- /** 璁惧閫氶亾ID */
- private String channelId;
+ @TableField("device_name")
+ /** deviceName */
+ private String deviceName;
}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/wvp/Device.java b/ycl-pojo/src/main/java/com/ycl/platform/wvp/Device.java
new file mode 100644
index 0000000..5b66357
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/wvp/Device.java
@@ -0,0 +1,463 @@
+package com.ycl.platform.wvp;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+
+/**
+ * 鍥芥爣璁惧/骞冲彴
+ * @author lin
+ */
+@Schema(description = "鍥芥爣璁惧/骞冲彴")
+public class Device {
+
+ /**
+ * 璁惧鍥芥爣缂栧彿
+ */
+ @Schema(description = "璁惧鍥芥爣缂栧彿")
+ private String deviceId;
+
+ /**
+ * 璁惧鍚�
+ */
+ @Schema(description = "鍚嶇О")
+ private String name;
+
+ /**
+ * 鐢熶骇鍘傚晢
+ */
+ @Schema(description = "鐢熶骇鍘傚晢")
+ private String manufacturer;
+
+ /**
+ * 鍨嬪彿
+ */
+ @Schema(description = "鍨嬪彿")
+ private String model;
+
+ /**
+ * 鍥轰欢鐗堟湰
+ */
+ @Schema(description = "鍥轰欢鐗堟湰")
+ private String firmware;
+
+ /**
+ * 浼犺緭鍗忚
+ * UDP/TCP
+ */
+ @Schema(description = "浼犺緭鍗忚锛圲DP/TCP锛�")
+ private String transport;
+
+ /**
+ * 鏁版嵁娴佷紶杈撴ā寮�
+ * UDP:udp浼犺緭
+ * TCP-ACTIVE锛歵cp涓诲姩妯″紡
+ * TCP-PASSIVE锛歵cp琚姩妯″紡
+ */
+ @Schema(description = "鏁版嵁娴佷紶杈撴ā寮�")
+ private String streamMode;
+
+ /**
+ * wan鍦板潃_ip
+ */
+ @Schema(description = "IP")
+ private String ip;
+
+ /**
+ * wan鍦板潃_port
+ */
+ @Schema(description = "绔彛")
+ private int port;
+
+ /**
+ * wan鍦板潃
+ */
+ @Schema(description = "wan鍦板潃")
+ private String hostAddress;
+
+ /**
+ * 鍦ㄧ嚎
+ */
+ @Schema(description = "鏄惁鍦ㄧ嚎锛宼rue涓哄湪绾匡紝false涓虹绾�")
+ private boolean onLine;
+
+
+ /**
+ * 娉ㄥ唽鏃堕棿
+ */
+ @Schema(description = "娉ㄥ唽鏃堕棿")
+ private String registerTime;
+
+
+ /**
+ * 蹇冭烦鏃堕棿
+ */
+ @Schema(description = "蹇冭烦鏃堕棿")
+ private String keepaliveTime;
+
+
+ /**
+ * 蹇冭烦闂撮殧
+ */
+ @Schema(description = "蹇冭烦闂撮殧")
+ private int keepaliveIntervalTime;
+
+ /**
+ * 閫氶亾涓暟
+ */
+ @Schema(description = "閫氶亾涓暟")
+ private int channelCount;
+
+ /**
+ * 娉ㄥ唽鏈夋晥鏈�
+ */
+ @Schema(description = "娉ㄥ唽鏈夋晥鏈�")
+ private int expires;
+
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ @Schema(description = "鍒涘缓鏃堕棿")
+ private String createTime;
+
+ /**
+ * 鏇存柊鏃堕棿
+ */
+ @Schema(description = "鏇存柊鏃堕棿")
+ private String updateTime;
+
+ /**
+ * 璁惧浣跨敤鐨勫獟浣搃d, 榛樿涓簄ull
+ */
+ @Schema(description = "璁惧浣跨敤鐨勫獟浣搃d, 榛樿涓簄ull")
+ private String mediaServerId;
+
+ /**
+ * 瀛楃闆�, 鏀寔 UTF-8 涓� GB2312
+ */
+ @Schema(description = "绗﹂泦, 鏀寔 UTF-8 涓� GB2312")
+ private String charset ;
+
+ /**
+ * 鐩綍璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄
+ */
+ @Schema(description = "鐩綍璁㈤槄鍛ㄦ湡锛宱涓轰笉璁㈤槄")
+ private int subscribeCycleForCatalog;
+
+ /**
+ * 绉诲姩璁惧浣嶇疆璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄
+ */
+ @Schema(description = "绉诲姩璁惧浣嶇疆璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄")
+ private int subscribeCycleForMobilePosition;
+
+ /**
+ * 绉诲姩璁惧浣嶇疆淇℃伅涓婃姤鏃堕棿闂撮殧,鍗曚綅:绉�,榛樿鍊�5
+ */
+ @Schema(description = "绉诲姩璁惧浣嶇疆淇℃伅涓婃姤鏃堕棿闂撮殧,鍗曚綅:绉�,榛樿鍊�5")
+ private int mobilePositionSubmissionInterval = 5;
+
+ /**
+ * 鎶ヨ璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄
+ */
+ @Schema(description = "鎶ヨ蹇冭烦鏃堕棿璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄")
+ private int subscribeCycleForAlarm;
+
+ /**
+ * 鏄惁寮�鍚痵src鏍¢獙锛岄粯璁ゅ叧闂紝寮�鍚彲浠ラ槻姝覆娴�
+ */
+ @Schema(description = "鏄惁寮�鍚痵src鏍¢獙锛岄粯璁ゅ叧闂紝寮�鍚彲浠ラ槻姝覆娴�")
+ private boolean ssrcCheck = false;
+
+ /**
+ * 鍦扮悊鍧愭爣绯伙紝 鐩墠鏀寔 WGS84,GCJ02
+ */
+ @Schema(description = "鍦扮悊鍧愭爣绯伙紝 鐩墠鏀寔 WGS84,GCJ02")
+ private String geoCoordSys;
+
+ @Schema(description = "瀵嗙爜")
+ private String password;
+
+ @Schema(description = "鏀舵祦IP")
+ private String sdpIp;
+
+ @Schema(description = "SIP浜や簰IP锛堣澶囪闂钩鍙扮殑IP锛�")
+ private String localIp;
+
+ @Schema(description = "鏄惁浣滀负娑堟伅閫氶亾")
+ private boolean asMessageChannel;
+
+ @Schema(description = "璁惧娉ㄥ唽鐨勪簨鍔′俊鎭�")
+ private Object sipTransactionInfo;
+
+ @Schema(description = "鎺у埗璇煶瀵硅娴佺▼锛岄噴鏀炬敹鍒癆CK鍚庡彂娴�")
+ private boolean broadcastPushAfterAck;
+
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(String deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getManufacturer() {
+ return manufacturer;
+ }
+
+ public void setManufacturer(String manufacturer) {
+ this.manufacturer = manufacturer;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getFirmware() {
+ return firmware;
+ }
+
+ public void setFirmware(String firmware) {
+ this.firmware = firmware;
+ }
+
+ public String getTransport() {
+ return transport;
+ }
+
+ public void setTransport(String transport) {
+ this.transport = transport;
+ }
+
+ public String getStreamMode() {
+ return streamMode;
+ }
+
+ public Integer getStreamModeForParam() {
+ if (streamMode == null) {
+ return 0;
+ }
+ if (streamMode.equalsIgnoreCase("UDP")) {
+ return 0;
+ }else if (streamMode.equalsIgnoreCase("TCP-PASSIVE")) {
+ return 1;
+ }else if (streamMode.equalsIgnoreCase("TCP-ACTIVE")) {
+ return 2;
+ }
+ return 0;
+ }
+
+ public void setStreamMode(String streamMode) {
+ this.streamMode = streamMode;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String hostAddress) {
+ this.hostAddress = hostAddress;
+ }
+
+ public boolean isOnLine() {
+ return onLine;
+ }
+
+ public void setOnLine(boolean onLine) {
+ this.onLine = onLine;
+ }
+
+ public int getChannelCount() {
+ return channelCount;
+ }
+
+ public void setChannelCount(int channelCount) {
+ this.channelCount = channelCount;
+ }
+
+ public String getRegisterTime() {
+ return registerTime;
+ }
+
+ public void setRegisterTime(String registerTime) {
+ this.registerTime = registerTime;
+ }
+
+ public String getKeepaliveTime() {
+ return keepaliveTime;
+ }
+
+ public void setKeepaliveTime(String keepaliveTime) {
+ this.keepaliveTime = keepaliveTime;
+ }
+
+ public int getExpires() {
+ return expires;
+ }
+
+ public void setExpires(int expires) {
+ this.expires = expires;
+ }
+
+ public String getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(String createTime) {
+ this.createTime = createTime;
+ }
+
+ public String getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(String updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public String getMediaServerId() {
+ return mediaServerId;
+ }
+
+ public void setMediaServerId(String mediaServerId) {
+ this.mediaServerId = mediaServerId;
+ }
+
+ public String getCharset() {
+ return charset;
+ }
+
+ public void setCharset(String charset) {
+ this.charset = charset;
+ }
+
+ public int getSubscribeCycleForCatalog() {
+ return subscribeCycleForCatalog;
+ }
+
+ public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) {
+ this.subscribeCycleForCatalog = subscribeCycleForCatalog;
+ }
+
+ public int getSubscribeCycleForMobilePosition() {
+ return subscribeCycleForMobilePosition;
+ }
+
+ public void setSubscribeCycleForMobilePosition(int subscribeCycleForMobilePosition) {
+ this.subscribeCycleForMobilePosition = subscribeCycleForMobilePosition;
+ }
+
+ public int getMobilePositionSubmissionInterval() {
+ return mobilePositionSubmissionInterval;
+ }
+
+ public void setMobilePositionSubmissionInterval(int mobilePositionSubmissionInterval) {
+ this.mobilePositionSubmissionInterval = mobilePositionSubmissionInterval;
+ }
+
+ public int getSubscribeCycleForAlarm() {
+ return subscribeCycleForAlarm;
+ }
+
+ public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) {
+ this.subscribeCycleForAlarm = subscribeCycleForAlarm;
+ }
+
+ public boolean isSsrcCheck() {
+ return ssrcCheck;
+ }
+
+ public void setSsrcCheck(boolean ssrcCheck) {
+ this.ssrcCheck = ssrcCheck;
+ }
+
+ public String getGeoCoordSys() {
+ return geoCoordSys;
+ }
+
+ public void setGeoCoordSys(String geoCoordSys) {
+ this.geoCoordSys = geoCoordSys;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getSdpIp() {
+ return sdpIp;
+ }
+
+ public void setSdpIp(String sdpIp) {
+ this.sdpIp = sdpIp;
+ }
+
+ public String getLocalIp() {
+ return localIp;
+ }
+
+ public void setLocalIp(String localIp) {
+ this.localIp = localIp;
+ }
+
+ public int getKeepaliveIntervalTime() {
+ return keepaliveIntervalTime;
+ }
+
+ public void setKeepaliveIntervalTime(int keepaliveIntervalTime) {
+ this.keepaliveIntervalTime = keepaliveIntervalTime;
+ }
+
+ public boolean isAsMessageChannel() {
+ return asMessageChannel;
+ }
+
+ public void setAsMessageChannel(boolean asMessageChannel) {
+ this.asMessageChannel = asMessageChannel;
+ }
+
+ public Object getSipTransactionInfo() {
+ return sipTransactionInfo;
+ }
+
+ public void setSipTransactionInfo(Object sipTransactionInfo) {
+ this.sipTransactionInfo = sipTransactionInfo;
+ }
+
+ public boolean isBroadcastPushAfterAck() {
+ return broadcastPushAfterAck;
+ }
+
+ public void setBroadcastPushAfterAck(boolean broadcastPushAfterAck) {
+ this.broadcastPushAfterAck = broadcastPushAfterAck;
+ }
+}
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 9d519a6..5cd3093 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
@@ -662,7 +662,7 @@
@Override
public String getFrameImgByDevice(String deviceId, String channelId) {
- String url = String.format(this.rtspServer + "/start/%s/%s", deviceId, channelId);
+ String url = String.format(this.rtspServer + "/api/play/start/%s/%s", deviceId, channelId);
String result = HttpUtils.sendGet(url);
log.error("鎷垮埌鍙栨祦鍝嶅簲缁撴灉锛�" + result);
WVPResult wvpResult = JSON.parseObject(result, WVPResult.class);
diff --git a/ycl-server/src/main/java/com/ycl/task/DeviceChannelTask.java b/ycl-server/src/main/java/com/ycl/task/DeviceChannelTask.java
deleted file mode 100644
index ae1b355..0000000
--- a/ycl-server/src/main/java/com/ycl/task/DeviceChannelTask.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.ycl.task;
-
-import org.springframework.stereotype.Component;
-
-/**
- * 閫氶亾鍚屾
- *
- * @author锛歺p
- * @date锛�2024/8/21 15:18
- */
-@Component("deviceChannelTask")
-public class DeviceChannelTask {
-
- public void run() {
- // TODO 寰呭疄鐜�
- }
-
-}
diff --git a/ycl-server/src/main/java/com/ycl/task/DeviceSynTask.java b/ycl-server/src/main/java/com/ycl/task/DeviceSynTask.java
new file mode 100644
index 0000000..acc1753
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/task/DeviceSynTask.java
@@ -0,0 +1,66 @@
+package com.ycl.task;
+
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.github.pagehelper.PageInfo;
+import com.ycl.platform.domain.entity.DeviceInfo;
+import com.ycl.platform.mapper.DeviceInfoMapper;
+import com.ycl.platform.wvp.Device;
+import com.ycl.platform.wvp.WVPResult;
+import com.ycl.utils.http.HttpUtils;
+import lombok.RequiredArgsConstructor;
+import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * "鍥芥爣璁惧"鍚屾
+ *
+ * @author锛歺p
+ * @date锛�2024/8/21 15:18
+ */
+@RequiredArgsConstructor
+@Component("deviceSynTask")
+public class DeviceSynTask {
+
+ private final DeviceInfoMapper deviceInfoMapper;
+
+ @Value("${rtsp.server:http://127.0.0.1:7788}")
+ private String rtspServer;
+
+ public void run() {
+ String result = HttpUtils.sendGet(rtspServer + "/api/device/query/devices?page=1&count=15");
+ WVPResult wvpResult = JSON.parseObject(result, WVPResult.class);
+ if (0 == wvpResult.getCode()) {
+ PageInfo<Device> page = (PageInfo) wvpResult.getData();
+ List<Device> list = page.getList();
+ if (! CollectionUtils.isEmpty(list)) {
+ list.stream().forEach(item -> {
+ DeviceInfo device = new LambdaQueryChainWrapper<>(deviceInfoMapper)
+ .eq(DeviceInfo::getDeviceId, item.getDeviceId())
+ .one();
+ if (Objects.isNull(device)) {
+ DeviceInfo deviceInfo = new DeviceInfo();
+ deviceInfo.setDeviceId(item.getDeviceId());
+ deviceInfo.setDeviceName(item.getName());
+ Date now = new Date();
+ deviceInfo.setCreateTime(now);
+ deviceInfo.setUpdateTime(now);
+ deviceInfo.setDeleted(0);
+ deviceInfoMapper.insert(deviceInfo);
+ } else {
+ device.setDeviceName(item.getName());
+ deviceInfoMapper.updateById(device);
+ }
+ });
+ }
+ }
+ }
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/task/WorkOrderImgTask.java b/ycl-server/src/main/java/com/ycl/task/WorkOrderImgTask.java
index 4749539..2464693 100644
--- a/ycl-server/src/main/java/com/ycl/task/WorkOrderImgTask.java
+++ b/ycl-server/src/main/java/com/ycl/task/WorkOrderImgTask.java
@@ -1,10 +1,14 @@
package com.ycl.task;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.ycl.platform.domain.entity.DeviceInfo;
import com.ycl.platform.domain.vo.DeviceInfoVO;
+import com.ycl.platform.mapper.DeviceInfoMapper;
import com.ycl.platform.service.WorkOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
@@ -25,6 +29,7 @@
public class WorkOrderImgTask {
private final WorkOrderService workOrderService;
+ private final DeviceInfoMapper deviceInfoMapper;
private static final ExecutorService executorService = new ThreadPoolExecutor(8,
24,
@@ -37,9 +42,20 @@
public void run() {
// 鏌ュ嚭鏁呴殰鐨勮澶�
List<DeviceInfoVO> deviceList = workOrderService.hasErrorWorkOrderList();
+ if (CollectionUtils.isEmpty(deviceList)) {
+ return;
+ }
+ List<DeviceInfo> gbDevices = new LambdaQueryChainWrapper<>(deviceInfoMapper)
+ .orderByDesc(DeviceInfo::getUpdateTime)
+ .last("limit 1")
+ .list();
+ if (CollectionUtils.isEmpty(gbDevices)) {
+ return;
+ }
for (DeviceInfoVO deviceInfo : deviceList) {
executorService.submit(() -> {
- String frameImg = workOrderService.getFrameImgByDevice(deviceInfo.getDeviceId(), deviceInfo.getChannelId());
+ // 鍥芥爣璁惧鐨勭紪鐮佸氨鏄彇瑙嗛娴佺殑璁惧缂栫爜锛屽浗鏍囪澶囧氨涓�涓�傚浗鏍囪澶囩殑姣忎竴涓�氶亾浠h〃涓�涓憚鍍忓ご锛屼篃灏辨槸璁惧id鏄彇娴佺殑閫氶亾id
+ String frameImg = workOrderService.getFrameImgByDevice(gbDevices.get(0).getDeviceId(), deviceInfo.getDeviceId());
if (StringUtils.hasText(frameImg)) {
workOrderService.updateImgById(deviceInfo.getWorkOrderId(), frameImg);
}
diff --git a/ycl-server/src/main/resources/mapper/zgyw/WorkOrderMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/WorkOrderMapper.xml
index 18827a0..87fad71 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/WorkOrderMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/WorkOrderMapper.xml
@@ -215,12 +215,11 @@
<select id="hasErrorWorkOrderList" resultType="com.ycl.platform.domain.vo.DeviceInfoVO">
SELECT
wo.id as workOrderId,
- we.device_id,
- wec.channel_id
+ wo.serial_number as deviceId
FROM
t_work_order wo
- INNER JOIN wvp2.wvp_device we ON we.device_id = wo.serial_number
- INNER JOIN wvp2.wvp_device_channel wec ON we.device_id = wec.device_id
+ WHERE
+ deleted = 0
</select>
<insert id="addMany">
--
Gitblit v1.8.0