From fb66d5ed24e716e536543364f746a9db5aeb20a9 Mon Sep 17 00:00:00 2001
From: shikeying <shikeying@163.com>
Date: 星期二, 27 九月 2022 18:47:56 +0800
Subject: [PATCH] 视频相似度分析4
---
recommend-video/src/main/java/com/iplatform/recvideo/VideoLoader.java | 99 +++++++++++
recommend-video/doc/table.SQL | 191 +++++++++++++++++++++
recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java | 17 +
recommend-video/src/main/java/com/iplatform/recvideo/VideoLoadInfo.java | 61 ++++++
recommend-video/src/main/java/com/iplatform/recvideo/service/VideoLoaderServiceImpl.java | 45 +++++
recommend-video/src/main/java/com/iplatform/recvideo/support/DefaultVideoLoader.java | 76 ++++++++
6 files changed, 488 insertions(+), 1 deletions(-)
diff --git a/recommend-video/doc/table.SQL b/recommend-video/doc/table.SQL
index 4506ab4..8c5d46e 100644
--- a/recommend-video/doc/table.SQL
+++ b/recommend-video/doc/table.SQL
@@ -1,3 +1,6 @@
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-- 浠ヤ笅涓虹储寮曡缃�
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER TABLE rc_video_t1
ADD INDEX inx_src_img (src_img) USING BTREE ;
@@ -17,4 +20,190 @@
ADD INDEX inx_vb_bid (batch_id) USING BTREE ;
ALTER TABLE rc_video_user
- ADD INDEX inx_vu_uid (user_id) USING BTREE ;
\ No newline at end of file
+ ADD INDEX inx_vu_uid (user_id) USING BTREE ;
+
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-- 浠ヤ笅涓鸿〃缁撴瀯
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+create table milvus_video_batch (
+ batch_id bigint(20) not null comment '鎵规id锛屽嵆锛氭棩鏈熸椂闂�',
+ video_id varchar(255) not null,
+ video_path varchar(255) default null,
+ vector_size int(11) not null default '0',
+ create_time bigint(20) not null,
+ status int(11) not null default '1' comment '鐘舵�侊細0 鏈畬鎴愶紝1瀹屾垚'
+) engine=innodb default charset=utf8;
+
+create table milvus_video_search (
+ milvus_id text,
+ image_path text,
+ video_id text
+) engine=innodb default charset=utf8;
+
+create table milvus_video_status (
+ id varchar(255) not null comment '瑙嗛璺緞',
+ create_time bigint(20) not null,
+ status int(11) not null default '0' comment '瀹屾垚鐘舵��: 0 鏈畬鎴�, 1 瀹屾垚',
+ records bigint(20) not null default '0',
+ primary key (id)
+) engine=innodb default charset=utf8;
+
+create table rc_task_status (
+ id bigint(20) not null comment '涓婚敭',
+ create_time bigint(20) not null comment '鍒涘缓鏃堕棿锛屽: 20220922180501',
+ name varchar(180) not null comment '浠诲姟鍚嶇О',
+ last_value bigint(20) not null comment '鑾峰彇鏁版嵁鐨勬渶澶у��',
+ status varchar(32) not null comment '褰撳墠鐘舵�侊紝瑙佹灇涓�: taskstatus',
+ start_time bigint(20) default null,
+ end_time bigint(20) default null,
+ msg varchar(180) default null comment '鎵ц鎻忚堪',
+ task_type varchar(32) not null comment '浠诲姟绫诲瀷锛岃鏋氫妇: tasktype',
+ primary key (id)
+) engine=innodb default charset=utf8;
+
+create table rc_video_batch (
+ id bigint(20) not null,
+ batch_id varchar(32) not null comment '鎵规id',
+ user_id bigint(20) not null,
+ src_video_id varchar(32) not null,
+ src_video_path varchar(255) default null,
+ primary key (id),
+ key inx_vb_bid (batch_id) using btree
+) engine=innodb default charset=utf8;
+
+create table rc_video_t1 (
+ src_img varchar(36) not null comment '鍥惧儚id',
+ src_video_id varchar(32) not null,
+ sim_video_id varchar(32) not null,
+ distance double not null default '0',
+ id varchar(32) not null,
+ primary key (id),
+ key inx_src_img (src_img) using btree,
+ key inx_src_vid (src_video_id) using btree
+) engine=innodb default charset=utf8;
+
+create table rc_video_t2 (
+ src_video_id varchar(32) not null,
+ sim_video_id varchar(32) not null,
+ score double not null default '0' comment '鐩镐技瑙嗛缁煎悎寰楀垎',
+ id varchar(32) not null,
+ batch_id varchar(32) not null default '0',
+ primary key (id),
+ key inx_t2_src_vid (src_video_id) using btree,
+ key inx_t2_src_bid (batch_id) using btree
+) engine=innodb default charset=utf8;
+
+create table rc_video_user (
+ user_id bigint(20) not null,
+ video_id varchar(32) not null,
+ score double not null default '0',
+ create_time bigint(20) not null default '0',
+ id bigint(20) not null,
+ primary key (id),
+ key inx_vu_uid (user_id) using btree
+) engine=innodb default charset=utf8;
+
+create table s_host (
+ id bigint(20) not null auto_increment,
+ create_time bigint(20) not null,
+ create_user varchar(36) not null,
+ url varchar(200) not null comment '搴撳湴鍧�',
+ port int(11) not null default '1306' comment '绔彛',
+ service_name varchar(100) default null comment '鏈嶅姟鍚嶇О',
+ authentication varchar(30) default null comment '璁よ瘉鐢ㄦ埛',
+ certification varchar(30) default null comment '鎺堟潈瀵嗙爜',
+ max_active int(11) not null default '5' comment '鏈�澶ц繛鎺ユ暟',
+ primary key (id)
+) engine=innodb auto_increment=105 default charset=utf8 comment='瀛樺偍璧勬簮鍙敤涓绘満';
+
+create table s_scheduler (
+ id int(11) not null comment '璋冨害鍣╥d',
+ create_time bigint(20) not null,
+ name varchar(180) not null,
+ status int(11) not null default '0' comment '鐘舵�侊細0_鍒濆鍖栵紝1_杩愯锛�2_鏆傚仠锛�9_缁撴潫锛�-1_浜哄伐缁堟',
+ start_time bigint(20) not null default '0' comment '璋冨害寮�濮嬭繍琛屾椂闂�',
+ end_time bigint(20) not null default '0' comment '璋冨害缁撴潫杩愯鏃堕棿',
+ interval_time int(11) not null default '5000' comment '鍐呴儴绾跨▼鎵ц闂撮殧鏃堕棿锛岄粯璁わ細5绉�',
+ sleep_time int(11) not null default '600000' comment '绾跨▼鎵ц涓紝鐫$湢鏃堕棿锛岄粯璁わ細10鍒嗛挓',
+ sleep_option int(11) not null default '1' comment '閲囬泦绾跨▼鍦ㄦ病鏈夎幏鍙栨暟鎹椂锛屾槸鍚﹁繘鍏ヤ紤鐪狅細0_鍚︼紝1_鏄�',
+ period_type varchar(36) not null comment '鍛ㄦ湡绫诲瀷锛歯one,day,week,month,year',
+ time_type varchar(36) not null comment '瀹氭椂绫诲瀷锛氱簿纭椂闂確exactly锛屾椂闂存_range',
+ year int(11) not null default '0',
+ month int(11) not null default '0',
+ day int(11) not null default '0',
+ hour int(11) not null default '0',
+ ranges varchar(50) default null comment '鏃堕棿鑼冨洿锛屽涓锛�5,6锛�12,15;...',
+ dept int(11) not null default '0',
+ class_name varchar(200) not null,
+ pause_time bigint(20) not null default '0',
+ summary varchar(255) default null,
+ primary key (id)
+) engine=innodb default charset=utf8 comment='骞冲彴璋冨害鍣ㄨ褰曡〃';
+
+create table sdc_gather (
+ id bigint(20) not null,
+ create_time bigint(20) not null,
+ create_user varchar(36) not null,
+ name varchar(120) not null comment '閲囬泦鍚嶇О',
+ description varchar(255) default null,
+ src_type tinyint(4) not null default '0' comment '閲囬泦婧愶細0_http,1_db',
+ src_url varchar(120) not null,
+ src_port int(11) default '80',
+ src_service varchar(120) default null,
+ src_user varchar(120) default null,
+ src_pass varchar(120) default null,
+ store_id varchar(36) not null comment '澶栭敭锛氬瓨鍌╥d',
+ status tinyint(4) not null default '0' comment '鐘舵�侊細0_鍒濆鍖栵紝1_杩愯锛�2_鏆傚仠锛�9_缁撴潫',
+ schedule_id int(11) not null comment '璋冨害鍣╥d',
+ primary key (id)
+) engine=innodb default charset=utf8 comment='閲囬泦浠诲姟璁板綍';
+
+create table sdc_meta_db (
+ id bigint(20) not null,
+ create_time bigint(20) not null,
+ store_id varchar(36) not null comment '澶栭敭锛氬瓨鍌╥d',
+ database_name varchar(60) default null,
+ used tinyint(4) not null default '0' comment '鏄惁琚娇鐢ㄨ繃锛�0_鍚︼紝1_鏄�',
+ is_using tinyint(4) not null default '0' comment '姝e湪琚娇鐢細0_鍚︼紝1_鏄�',
+ host_info varchar(100) not null comment '瀛樺偍浣跨敤搴撶殑淇℃伅锛歩p:port',
+ table_count int(11) not null default '0' comment '瀛樺湪鐨勮〃鏁伴噺',
+ summary varchar(255) default null,
+ password varchar(255) default null,
+ username varchar(255) default null,
+ primary key (id),
+ key store_id (store_id),
+ constraint sdc_meta_db_ibfk_1 foreign key (store_id) references sdc_store (id) on delete cascade
+) engine=innodb default charset=utf8 comment='鍏冩暟鎹暟鎹簱淇℃伅';
+
+create table sdc_meta_table (
+ id bigint(20) not null auto_increment,
+ create_time bigint(20) not null,
+ store_id varchar(36) not null comment '澶栭敭锛氬瓨鍌╥d',
+ db_id bigint(20) not null comment '澶栭敭锛歞bid',
+ table_name varchar(60) not null comment '琛ㄥ悕',
+ row_count bigint(20) not null default '0' comment '璁板綍鏁伴噺',
+ summary varchar(255) default null,
+ primary key (id),
+ key db_id (db_id),
+ key store_id (store_id),
+ constraint sdc_meta_table_ibfk_1 foreign key (db_id) references sdc_meta_db (id) on delete cascade,
+ constraint sdc_meta_table_ibfk_2 foreign key (store_id) references sdc_store (id) on delete cascade
+) engine=innodb default charset=utf8 comment='鍏冩暟鎹紝琛ㄤ俊鎭�';
+
+create table sdc_store (
+ id varchar(36) not null comment '瀛樺偍id锛屼富閿�',
+ create_time bigint(20) default null comment '鍒涘缓鏃堕棿姣鍊�',
+ create_user varchar(36) not null,
+ description varchar(255) not null comment '鎻忚堪',
+ inner_use tinyint(4) not null default '0' comment '鍐呴儴浣跨敤锛�0_琛ㄧず绯荤粺鎺у埗鐨勫唴閮ㄦ暟鎹紝鍏朵粬琛ㄧず澶栭儴瀛樺偍锛屽锛氳嚜宸辨墜鍔ㄥ姞涓婄殑鍙綔涓鸿褰�',
+ type varchar(30) not null comment '瀛樺偍绫诲瀷锛氭暟鎹簱銆佸垎甯冨紡鏂囦欢绯荤粺绛�',
+ database_type tinyint(4) not null default '0' comment '鏁版嵁搴撶被鍨嬶細0_derby,1_oracle,2_mysql,3_sqlserver',
+ strategy varchar(90) not null comment '瀛樺偍绛栫暐鐨勭被鍚�',
+ deleted tinyint(4) not null default '0' comment '鏄惁搴熷純锛�1_鏄紝0_鍚�',
+ update_time bigint(20) default null comment '鏇存柊鏃堕棿',
+ update_user varchar(36) default null comment '鏇存柊鐢ㄦ埛',
+ define_name varchar(60) not null comment '瀛樺偍搴撳畾涔夊悕瀛楋紝濡傦細鏁版嵁搴撳悕',
+ select_hosts varchar(100) not null comment '閫夋嫨涓绘満淇℃伅锛屽涓敤鑻辨枃鍒嗗彿闅斿紑',
+ primary key (id)
+) engine=innodb default charset=utf8;
diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoadInfo.java b/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoadInfo.java
new file mode 100644
index 0000000..2af125a
--- /dev/null
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoadInfo.java
@@ -0,0 +1,61 @@
+package com.iplatform.recvideo;
+
+/**
+ * 瑕佽幏鍙栫殑瑙嗛璁板綍銆�
+ * @author 鏃跺厠鑻�
+ * @date 2022-09-26
+ */
+public class VideoLoadInfo {
+
+ private String srcVideoId; // 瑙嗛鍘熷ID
+
+ private String videoSrcPath; // 鍦ㄥ師鏈嶅姟鍣ㄨ矾寰�
+
+ private String videoDestPath; // 瑕佹嫹璐濆埌鐩殑鏈嶅姟鍣ㄨ矾寰�
+
+ private String batchId; // 鎵规ID锛屼竴鑸槸鏃堕棿
+
+ private long userId; // 鐢ㄦ埛ID
+
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+
+ public String getSrcVideoId() {
+ return srcVideoId;
+ }
+
+ public void setSrcVideoId(String srcVideoId) {
+ this.srcVideoId = srcVideoId;
+ }
+
+ public String getVideoSrcPath() {
+ return videoSrcPath;
+ }
+
+ public void setVideoSrcPath(String videoSrcPath) {
+ this.videoSrcPath = videoSrcPath;
+ }
+
+ public String getVideoDestPath() {
+ return videoDestPath;
+ }
+
+ public void setVideoDestPath(String videoDestPath) {
+ this.videoDestPath = videoDestPath;
+ }
+
+ public String getBatchId() {
+ return batchId;
+ }
+
+ public void setBatchId(String batchId) {
+ this.batchId = batchId;
+ }
+
+}
diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoader.java b/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoader.java
new file mode 100644
index 0000000..62289d1
--- /dev/null
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/VideoLoader.java
@@ -0,0 +1,99 @@
+package com.iplatform.recvideo;
+
+import com.walker.infrastructure.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public abstract class VideoLoader {
+
+ protected final transient Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public void startup(String videoDataFolder, String batchId, boolean testMode){
+
+ }
+
+ public void destroy(){
+
+ }
+
+ public int execute() throws Exception{
+
+ long nextBatchId = this.acquireNextBatchId();
+
+ if(nextBatchId == 0){
+ logger.debug("鏈壘鍒颁笅涓�涓�(宸叉湁)鏈�澶ф壒娆★紝璇存槑杩樻病鏈夋搷浣滆繃锛岄粯璁よ缃竴涓悎鐞嗗�煎仛鍒濆鏌ヨ");
+ nextBatchId = this.acquireInitBatchId();
+ }
+
+ List<VideoLoadInfo> readyLoadList = null;
+
+ try{
+ readyLoadList = this.acquireLoadVideoFromDatabase(nextBatchId);
+
+ } catch (Exception ex){
+ logger.error("acquireLoadVideoFromDatabase(): " + ex.getMessage(), ex);
+ return -1;
+ }
+
+ if(StringUtils.isEmptyList(readyLoadList)){
+ logger.debug("鏈煡鎵惧埌浠讳綍瑕佽繙绋嬭幏鍙栫殑瑙嗛锛宺eadyLoadList = null");
+ return -1;
+ }
+
+ long savedBatchId = this.copyRemoteVideoFiles(readyLoadList, nextBatchId);
+ logger.info("鎷疯礉涓�鎵硅棰戞枃浠讹紝鍏�:" + readyLoadList.size() + "涓�, 杩斿洖鏈�鏂� savedBatchId = " + savedBatchId);
+ if(savedBatchId <= 0){
+ throw new IllegalArgumentException("鐢熸垚鐨� savedBatchId 鏃犳晥锛屾棤娉曠户缁悗缁噰闆�: " + savedBatchId);
+ }
+
+ try{
+ this.saveDataAndStatus(readyLoadList, savedBatchId);
+ return 1;
+ } catch (Exception ex){
+ logger.error("saveDataAndStatus(),淇濆瓨閲囬泦瑙嗛鏁版嵁鍜岀姸鎬佸け璐�:" + ex.getMessage(), ex);
+ return -1;
+ }
+ }
+
+ /**
+ * 鑾峰彇鏈�澶ф壒娆¢噰闆嗗�硷紝閫氬父涓烘椂闂存埑锛岀郴缁熶細浣跨敤璇ュ�煎幓鏌ユ壘涓氬姟涓秴杩囪鍊肩殑瑙嗛淇℃伅銆�
+ * @return
+ */
+ protected abstract long acquireNextBatchId();
+
+ /**
+ * 濡傛灉绯荤粺涓嶅瓨鍦ㄥ凡閲囬泦璁板綍锛屽垯浼氳嚜鍔ㄥ垵濮嬪寲涓�涓壒娆℃潵閲囬泦锛岃鍊奸�氬父浼氳緝鏃�
+ * @return
+ */
+ protected abstract long acquireInitBatchId();
+
+ /**
+ * 浠庝笟鍔″簱涓紝妫�绱㈡瘮鎵规鍊兼洿澶�(姣旇鏃堕棿鏇存櫄)鐨勮棰戣褰曘��
+ * @param nextBatchId
+ * @return
+ */
+ protected abstract List<VideoLoadInfo> acquireLoadVideoFromDatabase(long nextBatchId);
+
+ /**
+ * 浠庤繙绋嬫湇鍔″櫒鎷疯礉瑙嗛鏂囦欢鍒版湰鏈鸿矾寰勪腑銆�
+ * <pre>
+ * 1) 瑙嗛瑕佹嫹璐濆埌鎸囧畾鏂囦欢鏍圭洰褰曪紝绯荤粺鏈夐厤缃�: data-folder
+ * 2) 鎷疯礉鍚庤棰戞枃浠跺繀椤荤敤鏁版嵁搴揑D閲嶅懡鍚嶄负鏂囦欢鍚嶏紝濡�: 202209123.mp4
+ * </pre>
+ * @param readyLoadList
+ * @param nextBatchId
+ * @return 杩斿洖涓�涓渶鏂版壒娆″彿锛屼篃灏辨槸褰撳墠杩欐壒鏁版嵁鐨勬渶澶ф椂闂存埑銆�
+ */
+ protected abstract long copyRemoteVideoFiles(List<VideoLoadInfo> readyLoadList, long nextBatchId) throws Exception;
+
+ /**
+ * 淇濆瓨瑙嗛鎵规鏁版嵁锛屽苟鍒涘缓鏂扮姸鎬佽褰曪紝璁� <code>VideoSearchScheduler</code> 鑳界户缁畬鎴愯绠楃浉浼煎害鍐欏叆銆�<p></p>
+ * 鍙傝��: {@linkplain com.iplatform.recvideo.scheduler.VideoSearchScheduler}
+ * @param readyLoadList
+ * @param savedBatchId
+ * @return
+ */
+ protected abstract int saveDataAndStatus(List<VideoLoadInfo> readyLoadList, long savedBatchId);
+}
diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java b/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java
new file mode 100644
index 0000000..15886e7
--- /dev/null
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/scheduler/VideoLoadScheduler.java
@@ -0,0 +1,17 @@
+package com.iplatform.recvideo.scheduler;
+
+import com.iplatform.recvideo.VideoScheduler;
+import com.walker.store.AbstractStore;
+import com.walker.store.task.GatherTask;
+
+public class VideoLoadScheduler extends VideoScheduler {
+
+ public VideoLoadScheduler(int id, String name){
+ super(id, name);
+ }
+
+ @Override
+ protected GatherTask providerTask(AbstractStore store) {
+ return null;
+ }
+}
diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/service/VideoLoaderServiceImpl.java b/recommend-video/src/main/java/com/iplatform/recvideo/service/VideoLoaderServiceImpl.java
new file mode 100644
index 0000000..88023d5
--- /dev/null
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/service/VideoLoaderServiceImpl.java
@@ -0,0 +1,45 @@
+package com.iplatform.recvideo.service;
+
+import com.iplatform.model.po.Rc_task_status;
+import com.iplatform.model.po.Rc_video_batch;
+import com.iplatform.reccommon.TaskType;
+import com.walker.jdbc.service.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class VideoLoaderServiceImpl extends BaseServiceImpl {
+
+ private static final String SQL_NEXT_BATCH = "select max(last_value) next_batch_id from rc_task_status where task_type=? and (status='0' or status='1')";
+
+ /**
+ * 鏌ユ壘褰撳墠璁板綍涓凡鏈夌殑鏈�澶ф壒娆″�笺��
+ * @return
+ * @date 2022-09-26
+ */
+ public long queryNextBatchValue(){
+ Map<String, Object> nextBatchMap = this.get(SQL_NEXT_BATCH, new Object[]{TaskType.INDEX_VIDEO_LOAD});
+ if(nextBatchMap == null){
+ return 0;
+ }
+ if(nextBatchMap.get("next_batch_id") == null){
+ return 0;
+ }
+ return Long.parseLong(nextBatchMap.get("next_batch_id").toString());
+ }
+
+ /**
+ * 淇濆瓨鎵规瑙嗛璁板綍锛屽苟娣诲姞鏂扮殑(鐩镐技搴︽绱�)鐘舵�併��
+ * @param videoBatchList
+ * @param status
+ * @return
+ * @date 2022-09-26
+ */
+ public int execSaveBatchAndStatus(List<Rc_video_batch> videoBatchList, Rc_task_status status){
+ this.save(videoBatchList);
+ this.save(status);
+ return videoBatchList.size();
+ }
+}
diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/support/DefaultVideoLoader.java b/recommend-video/src/main/java/com/iplatform/recvideo/support/DefaultVideoLoader.java
new file mode 100644
index 0000000..ad69420
--- /dev/null
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/support/DefaultVideoLoader.java
@@ -0,0 +1,76 @@
+package com.iplatform.recvideo.support;
+
+import com.iplatform.model.po.Rc_task_status;
+import com.iplatform.model.po.Rc_video_batch;
+import com.iplatform.reccommon.TaskType;
+import com.iplatform.recvideo.VideoLoadInfo;
+import com.iplatform.recvideo.VideoLoader;
+import com.iplatform.recvideo.service.VideoLoaderServiceImpl;
+import com.walker.infrastructure.utils.DateUtils;
+import com.walker.infrastructure.utils.NumberGenerator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultVideoLoader extends VideoLoader {
+
+ private VideoLoaderServiceImpl videoLoaderService;
+
+ public void setVideoLoaderService(VideoLoaderServiceImpl videoLoaderService) {
+ this.videoLoaderService = videoLoaderService;
+ }
+
+ @Override
+ protected long acquireNextBatchId() {
+ return this.videoLoaderService.queryNextBatchValue();
+ }
+
+ @Override
+ protected long acquireInitBatchId() {
+ return 0;
+ }
+
+ @Override
+ protected List<VideoLoadInfo> acquireLoadVideoFromDatabase(long nextBatchId) {
+ return null;
+ }
+
+ @Override
+ protected long copyRemoteVideoFiles(List<VideoLoadInfo> readyLoadList, long nextBatchId) throws Exception {
+ return 0;
+ }
+
+ @Override
+ protected int saveDataAndStatus(List<VideoLoadInfo> readyLoadList, long savedBatchId) {
+ List<Rc_video_batch> videoBatchList = this.toVideoBatchList(readyLoadList, savedBatchId);
+ Rc_task_status taskStatus = this.createNewTaskStatus(savedBatchId);
+ return this.videoLoaderService.execSaveBatchAndStatus(videoBatchList, taskStatus);
+ }
+
+ private Rc_task_status createNewTaskStatus(long savedBatchId){
+ Rc_task_status status = new Rc_task_status();
+ status.setCreate_time(Long.parseLong(DateUtils.getDateTimeSecondForShow()));
+ status.setStatus("0");
+ status.setId(NumberGenerator.getLongSequenceNumber());
+ status.setTask_type(TaskType.INDEX_VIDEO_LOAD);
+ status.setLast_value(savedBatchId);
+ status.setName("鏁寸悊鑾峰彇鐭棰戜换鍔�");
+ return status;
+ }
+
+ private List<Rc_video_batch> toVideoBatchList(List<VideoLoadInfo> readyLoadList, long savedBatchId){
+ List<Rc_video_batch> resultList = new ArrayList<>(readyLoadList.size());
+ Rc_video_batch e = null;
+ String batchId = String.valueOf(savedBatchId);
+ for(VideoLoadInfo v : readyLoadList){
+ e = new Rc_video_batch();
+ e.setBatch_id(batchId);
+ e.setSrc_video_id(v.getSrcVideoId());
+ e.setUser_id(v.getUserId());
+ e.setSrc_video_path(v.getVideoDestPath());
+ e.setId(NumberGenerator.getLongSequenceNumber());
+ resultList.add(e);
+ }
+ return resultList;
+ }
+}
--
Gitblit v1.9.1