chenshijun
2019-04-22 291dbcd9331cd0df41addef74defa4654ee034fb
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#ifndef HTTP_CONFIGSERVER_H
#define HTTP_CONFIGSERVER_H
 
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
 
#include "opencv2/opencv.hpp"
#include <string>
#include "HttpSrvRetRecieve.hpp"
#include "LDBTool.h"
#include <ErlangDbTool.h>
#include <basic/util/BASE64/Base64.h>
#include <basic/util/opencv/CvUtil.h>
#include <sys/sem.h>
 
#include <LocalDBTool/SqliteFaceEncap.h>
#include <CurlDownloadImg.hpp>
#include <basic/util/fastdfs/FastFds.hpp>
#include <atomic>
#include "../FaceSearchServer/CasiaFaceWrapper/CasiaFaceWrapperN.h"
#include "AppPipeController.h"
 
#include <NsqMsgTool.hpp>
 
typedef std::shared_ptr<HttpServer::Response> PResponse;
 
 
struct srsPipeController_s {
    AppPipeController *appPC;
    std::atomic<int> userCounter;
};
 
class devHttpServer_c {
public:
    devHttpServer_c();
 
    devHttpServer_c(std::string test);
 
    devHttpServer_c(std::string ip, int port, int pthNum);
 
    ~devHttpServer_c();
 
//private:
    std::string dev_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string dev_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string devchn_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string devchn_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string dev_search_chns(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string chk_chn_connet(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string cam_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string cam_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string chk_cam_connet(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string chk_cam_disconnet(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string dev_del(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string cam_del(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string server_info_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string server_info_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string cut_dura_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string cut_dura_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string netconfig_edit(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string netconfig_show(std::string ip, unsigned int port, std::string content, PResponse &response);
 
 
    /***
     * 创建集群节点
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string addNode(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /***
     * 查询在线节点
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string searchNode(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string modifyCluName(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /***
     * 退出集群
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string removeNode(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     *创建数据底库
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string createDatabase(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 删除数据 底库
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string deleteDatabase(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /***
     * 更新数据 底库
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string updateDatabase(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 查询所有同步库
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string findAllDatabase(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 查询所有本地库
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string findLocalDatabase(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /***
     * 上传人员
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string addPerson(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    //#todo 批量添加人员借口
 
    /***
     * 向同步库批量添加人员及更新人员
     * feature_addPersonTracking 分支中更新功能分离为新借口
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string addPersons(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /***
     * 判断同步库中人员是否存在
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string personIsExists(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 更新同步库中的人员
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string updatePersonByOldId(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 删除人员
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string delPerson(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    /**
     * 加载特征
     * @param ip
     * @param port
     * @param content
     * @param response
     * @return
     */
    std::string loadFaceFeaData(std::string ip, unsigned int port, std::string content, PResponse &response);
 
 
    std::string getAlarmImageFromVideoFile(std::string ip, unsigned int port, std::string content, PResponse &response);
 
 
    std::string getRecordVideoPath(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string findDevId(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string editDevName(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string editDevId(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string findSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string editSdkRule(std::string ip, unsigned int port, std::string content, PResponse &response);
 
    std::string getSnapshot(std::string ip, unsigned int port, std::string content, PResponse &response);
 
private:
    void init(void);
 
private:
 
    HttpSrvRetRecieve _HttpSrvRetRecieve;
    LDBTool db_c;
    std::string m_cluster_id;
    std::string m_cluster_name;
    std::map<std::string, srsPipeController_s> m_rtmp;
 
 
    ErlangTool::ErlangDbTool *erlangDbTool;
    SqliteFaceEncap m_SqliteFaceEncap;
 
//    ErlangDbTool *erlangDbTool;
    std::map<std::thread::id, CasiaFaceWrapperN *> m_handleMap;
    CvUtil cvutil;
    Base64 base64;
    std::string m_batch;
    std::string m_SerialNumber;
 
    CurlDownloadImg m_curlDownloadImg;
 
    FastFdsWithLock fdfsClient;
 
    //nsq
    BasicMsg::Nsq::NsqMsgProducer *nsqMsgProducer;
 
 
    bool getDevSerialNumber(const char *ip, const int port, const char *username, \
                            const char *passwd, const char *brand, unsigned char *serialNumber) const;
 
    bool getDevChnList(const char *ip, const int port, const char *username, const char *passwd, \
                                        const char *brand, std::vector<int> &lvecUsefulChans) const;
 
    bool loadCurrentVideo(const char *ip, const int port, const char *username, const char *passwd, \
                                        const char *brand, const int chn, std::string &videopath) const;
 
    bool cam_connect_video_start(std::string ip, int port, std::string username, std::string passwd, \
                                        std::string brand) const;
 
    bool cam_connect_video_stop(std::string ip) const;
 
    void runAllApp() const;
 
    void killFaceSearchServerApp() const;
 
    void killVideoAnalysFromHCApp() const;
 
    bool getUVDevSerialNumber(const char *ip, const char *username, const char *passwd,
                              unsigned char *serialNumber = NULL) const;
 
    bool getHKDevSerialNumber(const char *ip, const int port, const char *username, const char *passwd,
                              unsigned char *serialNumber = NULL) const;
 
    bool createDevId(const int &dev_batch, const int &dev_sequence);
 
 
    std::vector<std::string> forEachFile(const std::string &dir_name);
 
    qint64 getVideoTime(/*const std::string& videoPath*/std::string &str_tmpTime);
 
 
    //根据PicDate获取报警图
    std::string getAlarmImageByPicDateAndDevId(const std::string &picDate, const std::string &devId,
                                               PResponse &response);
 
    //根据ImgKey获取报警图
    std::string getAlarmImageByImageKeyAndDevId(const std::string &imgKey, const std::string &devId,
                                                PResponse &response);
 
    //根据PicData获取视频路径
    std::string getVideoPathByPicDate(const std::string &picDate, const std::string &camId, qint64 &sub);
 
    //根据ImgKey获取视频的路径
    std::string getVideoPathByImgKey(const std::string &imgKey, const std::string &camId);
 
    //获取dir_name下的所有文件,带扩展名
    std::vector<std::string> forEachFileByImgKey(const std::string &dir_name);
 
    //根据ImgKey获取视频名
    std::string GetVideoNameByImgKey(const std::string &imgKey, const std::string &strPath);
 
};
 
#endif