BatchInfo.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #pragma once
  2. #include "PBQLock.h"
  3. #include "BatchService.h"
  4. #include "scan_common.h"
  5. #include "..\EvaluationUtil\HttpClient.h"
  6. #include "..\Schema\schema_struct.h"
  7. #include "SchemaLoader.h"
  8. #include "basic_struct_result.h"
  9. #include "..\Identifier\schema_struct.h"
  10. #include "ServerConfig.h"
  11. #include "TemplateManager.h"
  12. #include "resource.h"
  13. #include "IdentifyService.h"
  14. #include "ResultUploader.h"
  15. #include <direct.h>
  16. #include <time.h>
  17. #include "OnlineCardIdentifyService.h"
  18. #include <fstream>
  19. #include "../Identifier/OnLineCardSchemaStruct.h"
  20. #include "..\ZLibWrapMemLib\UnZipFile.h"
  21. #include "..\ZLibWrapMemLib\MemZipFile.h"
  22. #include "..\ZLibWrapLib\ZLibWrapLib.h"
  23. #include "OnlineCardStudentMatcher.h"
  24. #include "ResultUploader.h"
  25. #include <future>
  26. #include "../Identifier/PageIdentify.h"
  27. #include "ScanDll.h"
  28. using namespace schema;
  29. using namespace OnLineCard;
  30. extern string g_Indexdb;
  31. struct Paper_Page
  32. {
  33. int id;
  34. string path[2];
  35. string path_jiaozheng[2];//较正之后
  36. string result_dir;
  37. string result_json;
  38. string student_code;
  39. string student_name;
  40. string yun_header;
  41. string err_msg;
  42. string qr_code;
  43. int absent;
  44. int exc_code;
  45. int scan_cnt;//扫描次数
  46. int64 scan_time;
  47. OMR_RESULT* result[2];
  48. map<string, int> qid_cut_map;//题号 切割块数
  49. void Init_result()
  50. {
  51. result[0] = new OMR_RESULT;
  52. result[1] = new OMR_RESULT;
  53. }
  54. void Release_result()
  55. {
  56. if (result[0])
  57. {
  58. delete result[0];
  59. result[0] = NULL;
  60. }
  61. if (result[1])
  62. {
  63. delete result[1];
  64. result[1] = NULL;
  65. }
  66. }
  67. Paper_Page()
  68. {
  69. id = 0;
  70. absent = 0;
  71. scan_cnt = 0;
  72. path[0] = "";
  73. path[1] = "";
  74. path_jiaozheng[0] = "";
  75. path_jiaozheng[1] = "";
  76. result_dir = "";
  77. result_json = "";
  78. student_code = "";
  79. qr_code = "";
  80. student_name = "";
  81. result[0] = NULL;
  82. result[1] = NULL;
  83. yun_header = "";
  84. exc_code = 0;
  85. err_msg = "";
  86. scan_time = 0;
  87. Init_result();
  88. }
  89. ~Paper_Page()
  90. {
  91. Release_result();
  92. }
  93. };
  94. struct saveImgesPara{
  95. vector<CUT_AREA_RESULT*> *area_rst;
  96. CString dir;
  97. int subjectID;
  98. bool flag;
  99. bool bSaved;
  100. string path1;
  101. saveImgesPara(vector<CUT_AREA_RESULT*> *area_rst1, CString name1, int subjectid, bool flag1) : dir(name1), subjectID(subjectid), flag(flag1)
  102. {
  103. area_rst = area_rst1;
  104. bSaved = false;
  105. }
  106. };
  107. struct uploadImgPara
  108. {
  109. string img_path;
  110. string key;
  111. bool is_success;
  112. };
  113. class CBatch_Server
  114. {
  115. public:
  116. CBatch_Server();
  117. ~CBatch_Server();
  118. void Reset(int batch_id);
  119. void GetUnScanPapersFromDB();
  120. Paper_Page* GetPaperFromDB(int paper_id);
  121. Paper_Page* ReadNextPaper();
  122. bool GetCardTemplate(string exam_id, string task_id);
  123. void StartScan(int batch_id);
  124. void ReBatchScan(int batch_id, string exam_id);
  125. void ReScan(int batch_id, int paper_id, char* page0, char* page1, string exma_id = "");
  126. void ReScan(int batch_id, vector<int> paper_ids, char* exam_id);
  127. int m_thread_cnt;
  128. string MakeResultJsonAndUpload(Paper_Page* paper);
  129. int UploadResult(Paper_Page* paper);
  130. bool OpenBatchDb();
  131. void UpdatePaper(Paper_Page* paper);
  132. string ReadQRcode(Paper_Page* paper);
  133. void UpdateIndexDb(string batch_id, long long state, int success_cnt = -1);
  134. void StatisticsBatchInfo(string batch_id);
  135. void DrawSchema(IplImage*dst_img, SchemaPage* pageSchema, OMR_RESULT *result);
  136. void ReUploadAllFailed();
  137. void ReadExamInfo();
  138. bool ParseTemplateFromJsonAll(const std::string&fileName, OnLineCard::PaperTemplate* pOnlineCardTemplate);
  139. public:
  140. vector<Paper_Page*> m_PageVec;
  141. HANDLE m_thread_handle[16];
  142. PBQLock m_lockPageVec; //页面列表锁
  143. OnLineCard::PaperTemplate* m_onlineCardTemplate;
  144. string m_exam_id;
  145. string m_task_id;
  146. HANDLE m_hMutexIndex; //index.db3锁
  147. string m_batch_id;
  148. int m_total_cnt;
  149. string m_work_dir;
  150. string m_batch_code;
  151. bool m_bOffline_score;
  152. CppSQLite3DB m_batch_db;
  153. string m_indexDbPath;
  154. string m_batchDbPath;
  155. string m_regionQQ;
  156. string m_bucket_nameQQ;
  157. string m_hostHuawei;
  158. string m_bucketHuawei;
  159. bool m_bUseInputExam;
  160. map<string, string> qid_name;//题号 切割块数
  161. bool m_bDrawSchema;//
  162. bool m_bDrawResult;
  163. int m_yunType;//0 qq 1华为
  164. };