123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #pragma once
- #include "scan_common.h"
- #include "basic_struct.h"
- #include "basic_struct_result.h"
- #include "..\Schema\schema_struct.h"
- #include "DataBaseManagerHolder.h"
- #include <vector>
- #include <boost/smart_ptr.hpp>
- #include "../Identifier/schema_struct_auto.h"
- #include "../Identifier/schema_struct.h"
- #include "../Identifier/OnLineCardSchemaStruct.h"
- #include "rapidjson/document.h"
- #include <thread>
- #include <atomic>
- #include <queue>
- #include <mutex>
- #include <condition_variable>
- #include <future>
- #include "ScoreCounter.h"
- using namespace std;
- class CImgUploader;
- class CResultUploader;
- class CIdentifyService;
- #include "UploadManager.h"
- #include "NetOperator.h"
- #ifdef _DEBUG
- #pragma comment(lib,"LibHJIPC_d.lib")
- #else
- #pragma comment(lib,"LibHJIPC.lib")
- #endif // DEBUG
- class CBatchService :public IService, public CDataBaseManagerHolder, public INetNotify
- {
- public:
- CBatchService(bool bOnlineCard, int nSubjectID, int nOnlineScanType);
- ~CBatchService(void);
- public:
- /************************************************************************/
- /* 注册窗口,识别模块遇到问题将向该窗口发送消息 */
- /************************************************************************/
- int SetHandlerWnd(HWND hwnd);
- /************************************************************************/
- /* 准备扫描 */
- /************************************************************************/
- int ReadyScan(FEEDER_TYPE feederType, const ScanParam & param);
- int PreErrorHandleRestoreSite(bool bcontinue, int scan_type, FEEDER_TYPE feederType, const ScanParam & param);
- int QueryExceptionPaper(const long exception_type, vector<STUDENT_INFO>& studentList);
- int QueryPaperDetail(const int paper_id, PAPER_DETAIL &paper_detail, vector<PAGE_DETAIL> &pageList, vector<GROUP_QUESTION> &questionList);
- int UpdatePaperStudent(const int paper_id, const std::string examinee_id, const std::string student_code, const std::string studentName, const long schoolId, const std::string stuCode = "", const std::string stuSchoolCode = "", const std::string className = "", const std::string gradeName = "", bool bReIdentify = false);
- int ReIdentify(const int paper_id, const std::string& stu_code, const std::vector<img_param>& params);
- int loadDuXueFirstMode();
- string GetBatchCode();
- //清除数据
- int ClearDbTemp();
- //忽略试卷
- int IgnorePaper(const int paper_id);
- //忽略异常
- int IgnoreException(const long exceptions);
- // 覆盖试卷
- int ReplacePaper(const int paper_id, int &paper_id_ret);
- void CoverdAllKaohaochongtu();
- // 全部覆盖试卷
- int ReplaceAllKaoHaoChongTu(vector<int> &paper_id_List);
- //开始上传
- int StartUploadPaper(HWND hWnd, int student_paper_id = -1,bool bErrorPaper=false);
- //放弃本次扫描结果
- int GiveUpCurrentBatch();
- virtual BOOL SupportPause(void);
- /*从文件夹扫描继续扫描时设置扫描路径*/
- int SetFolderScanDir(const std::string& img_dir);
- virtual BOOL Stop(void);
- //查询异常卷总数
- int QueryExptionPaperCount(int & exc_count, int & total_count);
- //查询异常类型信息
- int QueryExptionTypeInfo(vector<EXCEPTION_TYPE_INFO> & infos);
- int LoadSchema(long long examId, std::string examName, long examCourseId, std::string courseName, std::string schemaPath, std::string rule = "");
- vector<int> GetAllConfictPaper(int student_paper_id, string student_id);//获取冲突试卷
- const boost::shared_ptr<const identify::schema::ISCH_Schema>& GeSchema(){ return m_schema; }
- int SetCookie(CString path, CString name, CString value);
- void saveQuestionStd(long long examId, std::string examName, long examCourseId, std::string courseName, std::vector<schema::SCHEMA_QUESTION> &questions,std::string rule = "");
- void Online_saveQuestionStd(long long examId, std::string examName, long examCourseId, std::string courseName, std::string rule = "");
- int QueryNormalPaper(vector<STUDENT_INFO> & studentList);
- int QueryMubanImgPath(int page_index, std::string& imgPath);
- int QueryMubanImgCount(int& page_count);
- int SetLocalServerCookie(CString name, CString value);
- const boost::shared_ptr<const HANDLE_INFO>& GetHandleInfo();
- void getCurScanExam(std::string exam_code, std::vector<std::vector<coverStu>> &stuInfo);
- void getCoverStuInfoByExamCode(std::string examCode, std::vector<coverStu> &stuInfo);
- void RestoreErrorHandleSite(const std::string& task_id, const std::string&type, const std::string& strPath);
- int UpateErrorStudentData(const std::string&task_id);
- void SetErrorHandle(bool bErrorHandle);
- void InitUploadManager(bool bEanble, bool bCountiue, bool bErrorHanle, bool bOnlineCard, IUploudNotify*pNotify);
- void OnScanListFilter(bool bsuccess, int nUploadState);
- int UploadOnScanCmd(int nCmd, const char*param, void*ret);
- void QuickHandle(bool bGetPath, char*path_nor, int nor_len, char*path_exc, int exc_len);
- int BatchServiceCmd(int cmd, void*param, void*ret);
- boost::shared_ptr<CResultUploader> GetRstUploaderPtr(){ return m_result_uploader; }
- HANDLE GetEventZXHXCreateDB(){ return m_eventZXHXCreateDB; }
- void leaveCurrentBatch();
- int ExamineThisScan(PAPER_DETAIL &paper_detail);
- int SetAbsentExam(PAPER_DETAIL &paper_detail, int absent);
- int QueryKeGuanTiYiChang(const int paper_id, std::vector<KEGUANTI_DETAIL>& keguantiList);
- int UpdateKeGuanTiYiChang(const int paper_id, std::vector<KEGUANTI_DETAIL>& keguantiList);
- private:
- // 返回 paper_id
- int RestoreStudentPaper(const std::string task_id,const std::string&task_type, rapidjson::Value&doc);
- void RestoreFile(int paper_id, const std::string&path,const std::string&path_ori);
- std::map<int,int> RestorePages(int paper_id,const std::string&path, rapidjson::Value&value);
- void RestoreResult(int paper_id, rapidjson::Value&value, const std::map<int, int>&mapPageID);
- void RestoreException(int paper_id, rapidjson::Value&value, const std::map<int, int>&mapPageID);
- void RestoreStudent(rapidjson::Value&value);
- protected:
- virtual ServiceState OnStarting( void );
- virtual ServiceState OnRunning( void );
- virtual ServiceState OnStoping(void);
- virtual ServiceState OnPausing(void);
- virtual ServiceState OnResuming(void);
- private:
- HANDLE m_eventZXHXCreateDB;
- boost::shared_ptr<CResultUploader> m_result_uploader;//成绩上传服务
- FEEDER_TYPE m_feeder_type;//当前图像送入器类型
- RTL_CRITICAL_SECTION bantch_db_lock;
- CppSQLite3DB bantch_db;
- HWND m_hwnd;
- //批次号
- CString m_bantch_code;
- //当前批次的数据库的ID
- int m_database_id;
- CString m_bantch_dir;
- //本次扫描原始图像存放目录
- CString m_norimg_dir;
- CString m_excimg_dir;
- CString m_img_clips_dir;
- CString m_img_alynasis_dir;
- CString m_img_alynasis_result_dir;
- CString m_img_down_load_dir;
- std::string m_muban_img_dir;
- bool m_bErrorHandle;
- //标记是否非正常关闭
- BOOL m_abnormal_stop;
- CString m_paper_code;
- boost::shared_ptr<const identify::schema::ISCH_Schema> m_schema;
- boost::shared_ptr<const HANDLE_INFO> m_handleInfo;
- //主任务
- boost::shared_ptr<CIdentifyService> mainService;
- vector<boost::shared_ptr<CIdentifyService>> subService;
- schema::SCHEMA m_schema0;
- OnLineCard::PaperTemplate* m_onlineCardTemplate;
- bool ParseTemplateFromJson(const std::string&fileName);
- bool ParseTemplateFromJsonAll(const std::string&fileName);//全学科在线答题卡
- long m_examCourseId;
- long long m_examId;
- std::string m_examName;
- std::string m_courseName;
- int m_bantch_state;
- char m_db_file_name[520];
- bool m_bOnlineCard;
- int m_nSubjectID;
- int m_nOnlineScanType;
- UploadManager m_upload_manager;
- std::future<int> m_coverd_all_kaohaochongtu;
- CScoreCounterEx m_scoreCounter;
- std::map<std::string, std::string> m_mapKeguantiNickName; // 客观题题号重模板中获取
- public:
- void getStdAnswerAndScore();
- CString MarkHttpHeaderData();
- bool readPaperId(CString& strPaperId);
- void logForDbg(string strLog);
- void recordBarcodeFlag(int nFlag);
- virtual void OnNetNotify(const char*data) override;
- };
|