Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
张艾宸
/
webScreen
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
张艾宸
2019-12-27 21:26:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a842ffc17130659fc16d415074b81b7aff339543
a842ffc1
1 parent
3ad40110
完善录制流程
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
108 行增加
和
55 行删除
.gitignore
config/config.js
config/method.js
routes/index.js
webScreen
webScreen.rar
.gitignore
查看文件 @
a842ffc
node_modules
.idea
\ No newline at end of file
...
...
config/config.js
查看文件 @
a842ffc
const
GETCLASSURL
=
"http://139.196.126.156:8081/getLogs/recordClassList"
const
GETCLASSURLPARAMETER
=
{
siteId
:[
"talk915"
,
"kuaikuenglish"
],
key
:
"xdymp4record20191225"
siteId
:[
"BuzzKID"
,
"kuaikuenglish"
],
key
:
"xdymp4record20191225"
,
page
:
1
}
const
PROJECTWINCATALOG
=
"E:/project/web_capture_release/win-x64"
...
...
@@ -18,9 +19,10 @@ const BACKMEDIACONFIG = {
portalPort
:
80
,
channels
:
2
,
playRecord
:
1
,
d
:
3
000
,
d
:
0.5
*
60
*
60
*
1
000
,
s
:
0
,
fa
:
15
fa
:
15
,
k
:
1
}
module
.
exports
=
{
GETCLASSURL
,
...
...
config/method.js
查看文件 @
a842ffc
...
...
@@ -11,11 +11,12 @@ const methods = {
let
endTime
=
new
Date
(
year
+
"-"
+
month
+
"-"
+
date
+
" 23:59:00"
).
getTime
()
return
{
startTime
,
endTime
endTime
,
ymd
:
year
+
"-"
+
month
+
"-"
+
date
}
},
async
getRequestClassIds
(
url
,
siteId
,
key
,
startTime
,
endTime
)
{
let
axiosUrl
=
`
$
{
url
}?
siteId
=
$
{
siteId
}
&
key
=
$
{
key
}
&
from
=
$
{
startTime
}
&
to
=
$
{
endTime
}
`
async
getRequestClassIds
(
url
,
siteId
,
key
,
startTime
,
endTime
,
page
)
{
let
axiosUrl
=
`
$
{
url
}?
siteId
=
$
{
siteId
}
&
key
=
$
{
key
}
&
from
=
$
{
startTime
}
&
to
=
$
{
endTime
}
&
page
=
$
{
page
}
`
let
result
=
await
axios
.
get
(
axiosUrl
)
return
result
},
...
...
routes/index.js
查看文件 @
a842ffc
...
...
@@ -9,73 +9,121 @@ const config = require("../config/config")
const
{
GETCLASSURL
,
GETCLASSURLPARAMETER
,
PROJECTCATALOG
,
PROJECTWINCATALOG
,
BACKMEDIACONFIG
}
=
config
const
{
YesterdayTime
,
getRequestClassIds
}
=
method
const
{
startTime
,
endTime
}
=
YesterdayTime
()
const
{
startTime
,
endTime
,
ymd
}
=
YesterdayTime
()
let
siteIds
=
GETCLASSURLPARAMETER
.
siteId
let
classid
=
[]
let
parentData
=
[]
var
classobj
=
{};
let
className
=
""
let
maxMedia
=
2
/**
*
* @param {*} id 课堂id
*/
function
mediaCreat
(
id
)
{
let
mediaDir
=
PROJECTCATALOG
+
"/media/"
let
dir
=
PROJECTCATALOG
+
"/media/"
+
className
if
(
!
fs
.
existsSync
(
mediaDir
)){
fs
.
mkdirSync
(
mediaDir
);
}
if
(
!
fs
.
existsSync
(
dir
)){
fs
.
mkdirSync
(
dir
);
class
MediaCreat
{
constructor
()
{
}
// 取出所有数据
async
allData
()
{
let
page
=
1
className
=
siteIds
.
shift
()
let
result
=
await
getRequestClassIds
(
GETCLASSURL
,
className
,
GETCLASSURLPARAMETER
.
key
,
startTime
,
endTime
,
page
)
for
(
let
j
=
0
;
j
<
result
.
data
.
data
.
list
.
length
;
j
++
)
{
classid
.
push
(
result
.
data
.
data
.
list
[
j
])
}
const
{
siteId
,
list
,
totalPage
}
=
result
.
data
.
data
for
(
let
i
=
page
+=
1
;
i
<=
totalPage
;
i
++
)
{
let
result
=
await
getRequestClassIds
(
GETCLASSURL
,
className
,
GETCLASSURLPARAMETER
.
key
,
startTime
,
endTime
,
i
)
for
(
let
j
=
0
;
j
<
result
.
data
.
data
.
list
.
length
;
j
++
)
{
classid
.
push
(
result
.
data
.
data
.
list
[
j
])
}
}
classid
=
classid
.
reduce
(
function
(
item
,
next
)
{
classobj
[
next
.
classId
]
?
''
:
classobj
[
next
.
classId
]
=
true
&&
item
.
push
(
next
);
return
item
;
},
[]);
parentData
=
JSON
.
parse
(
JSON
.
stringify
(
classid
))
return
true
}
let
url
=
`
web_capture_c
-
o
=
..
/
media
/
$
{
className
}
/${id}.mp4 -u="${BACKMEDIACONFIG.url}
?
classId=${id}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa}
`
var
workerProcess
=
spawn
(
url
,
{
cwd
:
PROJECTWINCATALOG
,
shell
:
true
})
workerProcess
.
stdout
.
on
(
'data'
,
async
function
(
data
)
{
if
(
classid
.
length
){
let
id
=
classid
.
shift
()
mediaCreat
(
id
[
'classId'
])
}
else
{
if
(
siteIds
.
length
)
{
// 如果有多家需要录制,继续录制下一家
className
=
siteIds
.
shift
()
let
result
=
await
getRequestClassIds
(
GETCLASSURL
,
className
,
GETCLASSURLPARAMETER
.
key
,
startTime
,
endTime
)
if
(
result
.
data
&&
result
.
data
.
code
==
0
)
{
// 返回成功
classid
=
result
.
data
.
data
.
list
if
(
classid
.
length
){
let
id
=
classid
.
shift
()
mediaCreat
(
id
[
'classId'
])
}
// 取出不同的值
async
notResult
(
data1
,
data2
)
{
new
Promise
((
resolve
,
reject
)
=>
{
let
data
=
[]
for
(
let
i
=
0
;
i
<
data2
.
length
;
i
++
)
{
// for(let j=0;j<data1.length;j++){
if
(
data1
.
indexOf
(
data2
[
i
].
classId
+
".mp4"
)
==
-
1
)
{
console
.
log
(
"不存在:"
+
data2
[
i
])
data
.
push
(
data2
[
i
])
}
}
console
.
log
(
"data"
,
data
)
return
resolve
(
data
)
})
}
async
mediaCreat
(
id
,
siteId
)
{
let
mediaDir
=
PROJECTCATALOG
+
"/media/"
let
classDir
=
PROJECTCATALOG
+
"/media/"
+
siteId
let
ymdDir
=
PROJECTCATALOG
+
"/media/"
+
siteId
+
"/"
+
ymd
if
(
!
fs
.
existsSync
(
mediaDir
))
{
fs
.
mkdirSync
(
mediaDir
);
}
if
(
!
fs
.
existsSync
(
classDir
))
{
fs
.
mkdirSync
(
classDir
);
}
});
// workerProcess.stderr.on('data', function (data) {
// console.log('stderr: ' + data);
// });
if
(
!
fs
.
existsSync
(
ymdDir
))
{
fs
.
mkdirSync
(
ymdDir
);
}
let
url
=
`
web_capture_c
-
o
=
..
/
media
/
$
{
siteId
}
/${ymd}/
$
{
id
}.
mp4
-
u
=
"${BACKMEDIACONFIG.url}?classId=${id}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}"
-
d
=
$
{
BACKMEDIACONFIG
.
d
}
-
s
=
$
{
BACKMEDIACONFIG
.
s
}
-
fa
=
$
{
BACKMEDIACONFIG
.
fa
}
-
k
=
$
{
BACKMEDIACONFIG
}
`
var
workerProcess
=
spawn
(
url
,
{
cwd
:
PROJECTWINCATALOG
,
shell
:
true
})
// workerProcess.stdout.on('data', async function (data) {
// });
// workerProcess.on('close', function (code) {
// console.log('子进程已退出,退出码 '+code);
// });
workerProcess
.
on
(
'close'
,
async
function
(
code
)
{
if
(
code
==
0
)
{
if
(
classid
.
length
)
{
let
shiftData
=
classid
.
shift
()
new
MediaCreat
().
mediaCreat
(
shiftData
[
'classId'
],
shiftData
[
'siteId'
])
}
else
{
// 判断是否有缺录
// let files = fs.readdirSync(ymdDir);
// if (files.length != parentData.length) {
// let notResult = await new MediaCreat().notResult(files,parentData)
// }
if
(
siteIds
.
length
)
{
// 如果有多家需要录制,继续录制下一家
let
isAppend
=
await
new
MediaCreat
().
allData
()
if
(
isAppend
)
{
let
shiftData
=
classid
.
shift
()
new
MediaCreat
().
mediaCreat
(
shiftData
[
'classId'
],
shiftData
[
'siteId'
])
}
}
}
}
else
{
new
MediaCreat
().
mediaCreat
(
id
,
siteId
)
}
});
}
}
router
.
get
(
'/'
,
async
function
(
req
,
res
,
next
)
{
className
=
siteIds
.
shift
()
let
result
=
await
getRequestClassIds
(
GETCLASSURL
,
className
,
GETCLASSURLPARAMETER
.
key
,
startTime
,
endTime
)
if
(
result
.
data
&&
result
.
data
.
code
==
0
)
{
// 成功
classid
=
result
.
data
.
data
.
list
if
(
classid
.
length
)
{
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
id
=
classid
.
shift
()
if
(
id
)
{
mediaCreat
(
id
[
'classId'
])
}
else
{
return
false
}
let
isAppend
=
await
new
MediaCreat
().
allData
()
if
(
isAppend
)
{
if
(
classid
.
length
)
{
for
(
let
i
=
0
;
i
<
maxMedia
;
i
++
)
{
let
shiftData
=
classid
.
shift
()
if
(
shiftData
)
{
new
MediaCreat
().
mediaCreat
(
shiftData
[
'classId'
],
shiftData
[
'siteId'
])
}
else
{
return
false
}
}
}
}
res
.
render
(
'index'
,
{
title
:
'Express'
});
});
...
...
webScreen
@
3ad40110
Subproject commit 3ad4011072147004f3e1cc8db37eada85d7fcc17
...
...
webScreen.rar
0 → 100644
查看文件 @
a842ffc
不能预览此文件类型
请
注册
或
登录
后发表评论