派生自 development/c++

zhangjixing
2019-01-18 9f08028f23d9e5cbfa159bec1e07d63b141a6809
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <QString>
#include "../DB/LDBTool.h"
#include "cutManage.h"
#include <QDateTime>
#include <QVector>
#include <basic/debug/Debug.h>
 
//cutManage::cutManage()
//{
//    init();
//}
 
 
cutManage::cutManage(LDBTool *dbTool) : TaskManage(dbTool) {
    init();
}
 
cutManage::~cutManage() {
 
}
 
void cutManage::init(void) {
    //search all cut_video_info where finish_flag = 0
    m_list = db_c->searchCutVideoTableAll();
}
 
getCutFileManage cutManage::getTask(void) {
    getCutFileManage result;
 
    if (m_list.size() > 0) {
        //get task from cut_video_info
        Record_Cut_Video_info rec = *m_list.begin();
        m_list.pop_front();
        result.src_path = rec.str_src_path.toStdString();
    } else {
        //get task from load_file_info
        //search oldest update time record
        Record_Load_File_info rec = db_c->searchOldestRecordfromLoadTableByUpdateTime();
        if (rec.n_id == 0 || rec.str_storage_dev_id.size() <= 0) {
            DBG("searchOldestRecordfromChnTableByUpdateTime NULL");
            return result;
        }
 
        result.src_path = rec.str_load_file_path.toStdString();
 
        //修改更新时间
        rec.tim_update_time = QDateTime::currentDateTime();
 
        //insert rec to cut_video_info && delete load_file_info
        Record_Cut_Video_info cutVideoRec = {0, rec.str_storage_dev_id, rec.n_chn, rec.str_load_file_path, "", 0, false,
                                             QDateTime::currentDateTime(), ""};
 
        bool ret = db_c->insertCutVideoTableAndDeleteLoadFileTable(cutVideoRec, rec.str_storage_dev_id, rec.n_chn,
                                                                   rec.tim_do_time);
        if (!ret) {
            return getCutFileManage();
        }
    }
    return result;
}
 
 
bool cutManage::finishTask(const pfinishCutFileManage finishInfo) {
    //根据devID&chn&src_path更改cut_video_info完成标志和目标路径,total
    return db_c->updateCutVideoTable(finishInfo->src_path, finishInfo->dst_path, finishInfo->total);
}