799967501@qq.com

修改日期转换问题

{
"GETCLASSURL": "http://139.196.126.156:8081/getLogs/recordClassList",
"GETCLASSURLPARAMETER": {
"siteId": [],
"siteId": ["quanpinzy"],
"key": "xdymp4record20191225",
"page": 1,
"maxMedia": 1
... ...
... ... @@ -5,39 +5,51 @@ const methods = {
let YesterdayTime = (new Date).getTime() - 24 * 60 * 60 * 1000
let YesterdayTimeDate = new Date(YesterdayTime)
let year = YesterdayTimeDate.getFullYear()
year = year.toString()
let month = YesterdayTimeDate.getMonth() + 1
let date = YesterdayTimeDate.getDate()
let startTime = new Date(year + "-" + month + "-" + date + " 5:30:00").getTime()
let endTime = new Date(year + "-" + month + "-" + date + " 23:59:00").getTime()
if(month < 10){
if (month < 10) {
month = '0' + month
}else{
month = month.toString()
}
if(date < 10){
if (date < 10) {
date = '0' + date
}else{
date = date.toString()
}
return {
startTime,
endTime,
ymd:year+month+date
ymd: year + month + date
}
},
dayTimeYMD() {
let dayTimeDate = new Date()
let year = dayTimeDate.getFullYear()
year = year.toString()
let month = dayTimeDate.getMonth() + 1
let date = dayTimeDate.getDate()
if(month < 10){
if (month < 10) {
month = '0' + month
}else{
month = month.toString()
}
if(date < 10){
if (date < 10) {
date = '0' + date
}else{
date = date.toString()
}
return {
ymd:year+ month + date
ymd: year + month + date
}
},
async getRequestClassIds(url, siteId, key, startTime, endTime,page) {
async getRequestClassIds(url, siteId, key, startTime, endTime, page) {
let axiosUrl = `${url}?siteId=${siteId}&key=${key}&from=${startTime}&to=${endTime}&page=${page}`
console.log('axiosUrl', axiosUrl)
let result = await axios.get(axiosUrl)
return result
},
... ...
... ... @@ -13,6 +13,7 @@ const { YesterdayTime, getRequestClassIds, dayTimeYMD } = method
let siteIds = []
let classid = []
let classidPost = []
let parentData = {}
var classobj = {};
let className = ""
... ... @@ -94,8 +95,22 @@ class MediaCreat {
}
let files = fs.readdirSync(ymdDir);
// let interValGetFile = setInterval(()=>{
this.wrieLog("files:" + files)
if (files.indexOf(id + ".mp4") != -1) {
this.wrieLog("已存在:" + id + "课堂号,停止继续录制")
if (type == 'post') {
if (classidPost.length) {
let shiftData = classidPost.shift()
this.wrieLog(" 录制下一节课 课堂号:" + shiftData['classId'])
this.recordingCreat(shiftData['classId'], shiftData['siteId'], type)
}
} else {
if (classid.length) {
let shiftData = classid.shift()
this.wrieLog(" 录制下一节课 课堂号:" + shiftData['classId'])
this.recordingCreat(shiftData['classId'], shiftData['siteId'], type)
}
}
return
}
// 目前url是linux的写法 win系统不支持
... ... @@ -115,18 +130,34 @@ class MediaCreat {
if (files.indexOf(id + ".mp4") == -1) {
this.wrieLog(" 课堂录制未发现该" + id + "课堂号")
} else {
if (classid.length) {
let shiftData = classid.shift()
this.wrieLog(" 录制下一节课 课堂号:" + shiftData['classId'])
this.recordingCreat(shiftData['classId'], shiftData['siteId'], type)
if (type == 'get') {
if (classid.length) {
let shiftData = classid.shift()
this.wrieLog(" 录制下一节课 课堂号:" + shiftData['classId'])
this.recordingCreat(shiftData['classId'], shiftData['siteId'], type)
} else {
this.wrieLog("录制结束:------>")
fs.writeFile(ymdDir + "/download.json", `{ "code": "0", "success": "ok"}`, function (err) {
if (err) {
console.log(err);
}
});
}
} else {
this.wrieLog("录制结束:------>")
fs.writeFile(ymdDir + "/download.json", `{ "code": "0", "success": "ok"}`, function (err) {
if (err) {
console.log(err);
}
});
if (classidPost.length) {
let shiftData = classidPost.shift()
this.wrieLog(" 录制下一节课 课堂号:" + shiftData['classId'])
this.recordingCreat(shiftData['classId'], shiftData['siteId'], type)
} else {
this.wrieLog("录制结束:------>")
fs.writeFile(ymdDir + "/download.json", `{ "code": "0", "success": "ok"}`, function (err) {
if (err) {
console.log(err);
}
});
}
}
}
})
}
... ... @@ -193,19 +224,18 @@ router.post('/recording', async function (req, res, next) {
let fileConfig = new MediaCreat().getConfigFileJson()
if (!fileConfig) return false
let { classId, maxMedia } = req.body
if (classid.length > 0) {
if (classidPost.length > 0) {
// 有正在录制中的课堂,禁止重复
res.send({ code: "1", message: "有正在录制中的课堂", data: classid });
res.send({ code: "1", message: "有正在录制中的课堂", data: classidPost });
return
}
if (classId && classId.length) {
classid = classId
classidPost = classId
if (!maxMedia || maxMedia == undefined) {
maxMedia = 1
}
console.log("maxMedia", maxMedia)
for (let i = 0; i < maxMedia; i++) {
let shiftData = classid.shift()
let shiftData = classidPost.shift()
if (shiftData) {
new MediaCreat().recordingCreat(shiftData['classId'], shiftData['siteId'], 'post')
} else {
... ...