123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #pragma once
- #include "PBQLock.h"
- #include "BatchService.h"
- #include "scan_common.h"
- #include "..\EvaluationUtil\HttpClient.h"
- #include "..\Schema\schema_struct.h"
- #include "SchemaLoader.h"
- #include "basic_struct_result.h"
- #include "..\Identifier\schema_struct.h"
- #include "ServerConfig.h"
- #include "TemplateManager.h"
- #include "resource.h"
- #include "IdentifyService.h"
- #include "ResultUploader.h"
- #include <direct.h>
- #include <time.h>
- #include "OnlineCardIdentifyService.h"
- #include <fstream>
- #include "../Identifier/OnLineCardSchemaStruct.h"
- #include "..\ZLibWrapMemLib\UnZipFile.h"
- #include "..\ZLibWrapMemLib\MemZipFile.h"
- #include "..\ZLibWrapLib\ZLibWrapLib.h"
- #include "OnlineCardStudentMatcher.h"
- #include "ResultUploader.h"
- #include <future>
- #include "../Identifier/PageIdentify.h"
- #include "ScanDll.h"
- using namespace schema;
- using namespace OnLineCard;
- extern string g_Indexdb;
- struct Paper_Page
- {
- int id;
- string path[2];
- string path_jiaozheng[2];//较正之后
- string result_dir;
- string result_json;
- string student_code;
- string student_name;
- string yun_header;
- string err_msg;
- string qr_code;
- int absent;
- int exc_code;
- int scan_cnt;//扫描次数
- int64 scan_time;
- OMR_RESULT* result[2];
- map<string, int> qid_cut_map;//题号 切割块数
- void Init_result()
- {
- result[0] = new OMR_RESULT;
- result[1] = new OMR_RESULT;
- }
- void Release_result()
- {
- if (result[0])
- {
- delete result[0];
- result[0] = NULL;
- }
- if (result[1])
- {
- delete result[1];
- result[1] = NULL;
- }
- }
- Paper_Page()
- {
- id = 0;
- absent = 0;
- scan_cnt = 0;
- path[0] = "";
- path[1] = "";
- path_jiaozheng[0] = "";
- path_jiaozheng[1] = "";
- result_dir = "";
- result_json = "";
- student_code = "";
- qr_code = "";
- student_name = "";
- result[0] = NULL;
- result[1] = NULL;
- yun_header = "";
- exc_code = 0;
- err_msg = "";
- scan_time = 0;
- Init_result();
- }
- ~Paper_Page()
- {
- Release_result();
- }
- };
- struct saveImgesPara{
- vector<CUT_AREA_RESULT*> *area_rst;
- CString dir;
- int subjectID;
- bool flag;
- bool bSaved;
- string path1;
- saveImgesPara(vector<CUT_AREA_RESULT*> *area_rst1, CString name1, int subjectid, bool flag1) : dir(name1), subjectID(subjectid), flag(flag1)
- {
- area_rst = area_rst1;
- bSaved = false;
- }
- };
- struct uploadImgPara
- {
- string img_path;
- string key;
- bool is_success;
- };
- class CBatch_Server
- {
- public:
- CBatch_Server();
- ~CBatch_Server();
- void Reset(int batch_id);
- void GetUnScanPapersFromDB();
- Paper_Page* GetPaperFromDB(int paper_id);
- Paper_Page* ReadNextPaper();
- bool GetCardTemplate(string exam_id, string task_id);
- void StartScan(int batch_id);
- void ReBatchScan(int batch_id, string exam_id);
- void ReScan(int batch_id, int paper_id, char* page0, char* page1, string exma_id = "");
- void ReScan(int batch_id, vector<int> paper_ids, char* exam_id);
- int m_thread_cnt;
- string MakeResultJsonAndUpload(Paper_Page* paper);
- int UploadResult(Paper_Page* paper);
- bool OpenBatchDb();
- void UpdatePaper(Paper_Page* paper);
- string ReadQRcode(Paper_Page* paper);
- void UpdateIndexDb(string batch_id, long long state, int success_cnt = -1);
- void StatisticsBatchInfo(string batch_id);
- void DrawSchema(IplImage*dst_img, SchemaPage* pageSchema, OMR_RESULT *result);
- void ReUploadAllFailed();
- void ReadExamInfo();
- bool ParseTemplateFromJsonAll(const std::string&fileName, OnLineCard::PaperTemplate* pOnlineCardTemplate);
- public:
- vector<Paper_Page*> m_PageVec;
- HANDLE m_thread_handle[16];
- PBQLock m_lockPageVec; //页面列表锁
- OnLineCard::PaperTemplate* m_onlineCardTemplate;
- string m_exam_id;
- string m_task_id;
- HANDLE m_hMutexIndex; //index.db3锁
- string m_batch_id;
- int m_total_cnt;
- string m_work_dir;
- string m_batch_code;
- bool m_bOffline_score;
- CppSQLite3DB m_batch_db;
- string m_indexDbPath;
- string m_batchDbPath;
- string m_regionQQ;
- string m_bucket_nameQQ;
- string m_hostHuawei;
- string m_bucketHuawei;
- bool m_bUseInputExam;
- map<string, string> qid_name;//题号 切割块数
- bool m_bDrawSchema;//
- bool m_bDrawResult;
- int m_yunType;//0 qq 1华为
- };
|