派生自 development/c++

xuxiuxi
2019-03-15 4a1845ab43395de6838e535bdf7ca932316ee9ec
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <QString>
#include "../DB/LDBTool.h"
#include "sdkHdlManage.h"
#include <QDateTime>
#include <QVector>
 
sdkHdlManage::sdkHdlManage(LDBTool *dbTool) : TaskManage(dbTool) {
    init();
}
 
sdkHdlManage::~sdkHdlManage() {
 
}
 
void sdkHdlManage::init(void) {
    //search all sdk_hdl_info
    m_list = db_c->searchSdkHdlTableAll();
 
}
 
getsdkHdlManage sdkHdlManage::getTask(void) {
    getsdkHdlManage result;
    QDateTime endTime;
 
    if (m_list.size() > 0) {
        Record_Sdk_Hdl_info sdlHdlRec = *m_list.begin();
        m_list.pop_front();
        result.src_path = sdlHdlRec.str_src_path.toStdString();
        result.total = sdlHdlRec.n_total;
        result.pos = sdlHdlRec.n_pos;
 
        auto t_rec = db_c->searchChnSdkTableByChannelId(sdlHdlRec.str_storage_dev_id,
                                                        sdlHdlRec.n_chn);//.str_sdks.toStdString();
        result.en_sdk = t_rec.str_sdks.toStdString();
 
        result.str_addr = db_c->searchChannelTableByChannelId(sdlHdlRec.str_storage_dev_id,
                                                              sdlHdlRec.n_chn).str_addr.toStdString();
 
        result.str_cmp_thr = t_rec.str_cmp_thr.toStdString();
        result.str_det_thr = t_rec.str_det_thr.toStdString();
        result.strDevID = t_rec.str_storage_dev_id.toStdString();
        result.nChannelID = t_rec.n_chn;
 
    } else {
        //get task from cut_video_info
        Record_Cut_Video_info rec = db_c->searchOldestRecordfromCutTableByUpdateTime();
 
        if (rec.str_storage_dev_id.size() > 0) {
            result.src_path = rec.str_dst_path.toStdString();
            result.total = rec.n_total;
            result.pos = 0;
 
            auto t_rec = db_c->searchChnSdkTableByChannelId(rec.str_storage_dev_id,
                                                            rec.n_chn);//.str_sdks.toStdString();
 
            result.en_sdk = t_rec.str_sdks.toStdString();
 
            result.str_addr = db_c->searchChannelTableByChannelId(rec.str_storage_dev_id,
                                                                  rec.n_chn).str_addr.toStdString();
 
            result.str_cmp_thr = t_rec.str_cmp_thr.toStdString();
            result.str_det_thr = t_rec.str_det_thr.toStdString();
            result.strDevID = t_rec.str_storage_dev_id.toStdString();
            result.nChannelID = t_rec.n_chn;
 
            //insert rec to sdk_hdl_info && delete cut_video_info
 
            Record_Sdk_Hdl_info sdlHdlRec{0, rec.str_storage_dev_id, rec.n_chn, rec.str_dst_path, rec.n_total, 0, ""};
            bool ret = db_c->insertSdkHdlTableAndDeleteCutVideoTable(sdlHdlRec, rec.str_storage_dev_id, rec.n_chn,
                                                                     rec.str_src_path);
            if (!ret) {
                return getsdkHdlManage();
            }
        }
    }
    return result;
}
 
 
bool sdkHdlManage::updateSdkHdlPos(const pfinishSdkHdlManage finishInfo) {
    //根据devID&chn&src_path,更新sdk_hdl_info的pos,pos+1
    return db_c->updateSdkHdlTablePos(QString::fromStdString(finishInfo->src_path), finishInfo->pos);
}
 
 
bool sdkHdlManage::finishTask(const pfinishSdkHdlManage finishInfo) {
    //TODO
    //根据devID&chn&src_path 删除sdk_hdl_info这条记录
    return db_c->deleteSdkHdlTable(QString::fromStdString(finishInfo->src_path));
}