2 Commits 36330a339d ... d4f81110f2

Author SHA1 Message Date
  maoyehu d4f81110f2 Merge branch 'translation' of http://gitz.zhixinhuixue.net:18880/zxhx-client-tool/pdfproject into translation 2 years ago
  maoyehu d4713c88c6 1 2 years ago

+ 1 - 1
MFCApplication1/AssignWords.h

@@ -2,7 +2,7 @@
 #include <string.h>
 #include <vector>
 #include <tuple>
-
+using namespace std;
 /***********************************************************************/
 //函 数 名:AssignWordsFromTest
 //功	能:从文件读取并分配到对应栏的内存中

+ 19 - 9
MFCApplication1/CvxText.cpp

@@ -368,7 +368,7 @@ std::string JsonToString(const Json::Value & root)
 	return stream.str();
 }
 
-int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<string>& vecLines, CString dir, std::string& strPngPath) {
+int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath) {
 	/* 这里要做一些栏数 和 vecLines的对应值确认 */
 	if (2 == cols && 14 * 2 == vecLines.size())
 		; // ok 
@@ -418,8 +418,8 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 	//generatePageJson(vecPts, vecBoxPages);
 
 	// 画警示信息
-	string strMesInfo = "1、请在每题下方的横线上书写本题的内容!\
-						\n\n2、题号不需要书写,标点符号需要原样书写。☆\
+	string strMesInfo = "1、请在题目下面的横线上书写题目结果!\
+						\n\n2、请用黑色笔书写。☆\
 						\n\n3、如果本题书写有误,进行了涂抹修改等操作,请将题号前矩形框用任意笔进行填涂!☆☆\n";
 	putTextZH(img, fSize, strMesInfo.c_str(), cv::Point(leftPos + 20, topPos + 20), Scalar(0), 25, "宋体");
 	int lineTop1 = topPos + 20 + fSize.height + 20;
@@ -481,7 +481,8 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 			cv::Rect rcNum(ptNum.x, ptNum.y, fSize.width, fSize.height);
 
 			strStinfo.clear();
-			string strTgInfo = vecLines[vecIndex];
+			string strTgInfo = std::get<0>(vecLines[vecIndex]);
+			string strSolution = std::get<1>(vecLines[vecIndex]);
 			if (!engShow)
 				; /*  移除词性   */
 			//char szTemp[2048];
@@ -518,6 +519,7 @@ int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool
 			queInfo["width"] = rcQues.width;
 			queInfo["height"] = rcQues.height;
 			queInfo["info"] = strTgInfo.c_str();
+			queInfo["solution"] = strSolution.c_str();
 
 			Json::Value ansInfo;
 			ansInfo["x"] = rcAns.x;
@@ -681,6 +683,7 @@ int cutPaper(int pageNum, std::string strJsonPath, std::string strPaperPath, std
 		
 		std::string id = row["id"].asString();
 		std::string info = row["queInfo"]["info"].asString();
+		std::string solution = row["queInfo"]["solution"].asString();
 
 		Json::Value ttbox = row["ttbox"];
 		Json::Value ansInfo = row["ansInfo"];
@@ -696,15 +699,22 @@ int cutPaper(int pageNum, std::string strJsonPath, std::string strPaperPath, std
 		bool ret = analysis_ttbox_mark(gray_src, rc_ttbox);
 		
 		char szTxtPath[MAX_PATH] = { 0 };
+		char szStdPath[MAX_PATH] = { 0 };
 		char szJpgPath[MAX_PATH] = { 0 };
 		DWORD dwCount = GetTickCount();
-		sprintf(szTxtPath, "%s\\%s\\%d_%s_%ld.txt", strSavePath.c_str(), ret ? "abnormal" : "normal", pageNum, id.c_str(), dwCount);
+		sprintf(szTxtPath, "%s\\%s\\%d_%s_%ld_yy.txt", strSavePath.c_str(), ret ? "abnormal" : "normal", pageNum, id.c_str(), dwCount);
+		sprintf(szStdPath, "%s\\%s\\%d_%s_%ld_zz.txt", strSavePath.c_str(), ret ? "abnormal" : "normal", pageNum, id.c_str(), dwCount);
 		sprintf(szJpgPath, "%s\\%s\\%d_%s_%ld.jpg", strSavePath.c_str(), ret ? "abnormal" : "normal", pageNum, id.c_str(), dwCount);
 
-		CFile zip;
-		zip.Open(CA2T(szTxtPath), CFile::modeCreate | CFile::modeWrite);
-		zip.Write((void*)info.c_str(), info.length());
-		zip.Close();
+		CFile zip1;
+		zip1.Open(CA2T(szTxtPath), CFile::modeCreate | CFile::modeWrite);
+		zip1.Write((void*)info.c_str(), info.length());
+		zip1.Close();
+
+		CFile zip2;
+		zip2.Open(CA2T(szStdPath), CFile::modeCreate | CFile::modeWrite);
+		zip2.Write((void*)solution.c_str(), solution.length());
+		zip2.Close();
 
 		cv::Mat cut = src(rc_ansInfo);
 		cv::imwrite(szJpgPath, cut);

+ 1 - 1
MFCApplication1/CvxText.h

@@ -48,7 +48,7 @@ int getLineStrWidth(string str, int fontSize, int ttBoxW, int tiSl, int backPix)
     *  @return   : 
     *  @author   :  qqm  2022/08/31 19:42
 *********************************************************/
-int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<std::string> & vecLines, CString dir, std::string& strPngPath);
+int dataCollectionPaper(int cols, int index, int fontSize, int lineGrayPix, bool engShow, std::vector<tuple<string, string>>& vecLines, CString dir, std::string& strPngPath);
 
 /********************************************************
 	*  @function :  ´ðÌ⿨Çиî

+ 39 - 9
MFCApplication1/MFCApplication1Dlg.cpp

@@ -97,10 +97,41 @@ DWORD WINAPI ProcessThread(void *param)
 {
 	CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
 	
-	std::vector<std::string> twoList;
-	std::vector<std::string> threeList;
-	std::vector<std::string> fourList;
-	AssignWordsFromTest(UnicodeToGB2312(pWnd->m_strTextPath), twoList, threeList, fourList);
+	std::vector<tuple<string, string>> oneList;
+	std::vector<tuple<string, string>> twoList;
+	std::vector<tuple<string, string>> errorList;
+	std::vector<tuple<string, string>> fourList;
+	int ret = AssignWordsFromTest(UnicodeToGB2312(pWnd->m_strTextPath), oneList, twoList, errorList, fourList);
+	if (ret < 0)
+	{
+		static wstring erroArry[] = { L"关联文件不可用\r\n", L"两个文件行数不一致\r\n", 
+			L"原数据行空,内容行有数据\r\n", L"内容行空,原数据行有数据\r\n" };
+		wstring erro = L"未知错误";
+		switch (ret)
+		{
+		default:
+			break;
+		case -1:erro = erroArry[0]; break;
+		case -2:erro = erroArry[1]; break;
+		case -3:erro = erroArry[2]; break;
+		case -4:erro = erroArry[3]; break;
+		}
+		SendMessage(pWnd->m_hWnd, WM_SHOWINFO, (WPARAM)erro.c_str(), 1);
+		return 0L;
+	}
+	if (ret == 0)
+	{
+		for (auto& iter : errorList)
+		{
+			wstring erroInfo;
+			erroInfo.append(L"题目:");
+			erroInfo.append(CA2T(std::get<0>(iter).c_str()));
+			erroInfo.append(L"标准答案:");
+			erroInfo.append(CA2T(std::get<1>(iter).c_str()));
+			erroInfo.append(L"有问题\r\n");
+			SendMessage(pWnd->m_hWnd, WM_SHOWINFO, (WPARAM)erroInfo.c_str(), 0);
+		}
+	}
 
 	HMODULE module = GetModuleHandle(0);
 	TCHAR pFileName[MAX_PATH + 2] = { 0 };
@@ -114,11 +145,11 @@ DWORD WINAPI ProcessThread(void *param)
 	GetPrivateProfileString(L"USER", L"GrayPix", L"100", wgray, 10, strFilePath);
 	int nLineGrayPix = _wtoi(wgray);
 	
-	auto CovertPdfFunc = [&](std::vector<std::string>&  vctFiles, int col, int& pageNum){
+	auto CovertPdfFunc = [&](std::vector<tuple<string, string>>&  vctFiles, int col, int& pageNum){
 		std::string strPage1;
 		for (size_t i = 0; i < vctFiles.size(); i += max_line * col)
 		{
-			std::vector<std::string> vecSmall;
+			std::vector<tuple<string, string>> vecSmall;
 			auto last = std::min(vctFiles.size(), i + max_line * col);
 			vecSmall.insert(vecSmall.begin(), vctFiles.begin() + i, vctFiles.begin() + last);
 
@@ -156,10 +187,9 @@ DWORD WINAPI ProcessThread(void *param)
 	
 
 	int pageNum = _wtoi(pWnd->m_strPageNumber);
+	CovertPdfFunc(oneList, 1, pageNum);
 	CovertPdfFunc(twoList, 2, pageNum);
-	CovertPdfFunc(threeList, 3, pageNum);
-	CovertPdfFunc(fourList, 4, pageNum);
-
+	
 	//通知发送消息到窗口
 	CString strErrorMsg = L"";
 	strErrorMsg.Format(L"PDF生成完成!\r\n");