maoyehu 2 лет назад
Родитель
Сommit
6db15c9f7b
1 измененных файлов с 26 добавлено и 6 удалено
  1. 26 6
      MFCApplication1/MFCApplication1Dlg.cpp

+ 26 - 6
MFCApplication1/MFCApplication1Dlg.cpp

@@ -159,8 +159,12 @@ DWORD WINAPI ProcessThread(void *param)
 int IdentifyCallback(result::spinfo& pinfo, void* param)
 {
 	CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
-	pWnd->FormatScanMsg("启动扫描线程......");
-
+	if (pinfo.choiceRes.size() < 3 || pinfo.vecUrlAPath.size() == 0)
+	{
+		pWnd->PostMessage(WM_PROCESS, NULL, NULL);
+		pWnd->FormatScanMsg("矫正图像失败原图为:%s", pinfo.vecUrlPath.size() > 0 ? pinfo.vecUrlPath[0].c_str() : "图像为空");
+	}
+	
 	std::string strChoiceRes;
 	for (auto& row : pinfo.choiceRes)
 	{
@@ -174,8 +178,7 @@ int IdentifyCallback(result::spinfo& pinfo, void* param)
 	int number = 0;
 	for (int i = 0; i < length; ++i)
 	{
-		//其中注意if的判断两个条件相等的符号
-		if (strChoiceRes[i] == '1')
+		if (strChoiceRes[i] == '1') // 其中注意if的判断两个条件相等的符号
 			number += pow(2, length - 1 - i);
 	}
 
@@ -185,7 +188,9 @@ int IdentifyCallback(result::spinfo& pinfo, void* param)
 	strJsonDir.append(".json");
 	std::string strSaveDir = CT2A(CConfig::Instance()->m_strCut);
 	cutPaper(number, strJsonDir, pinfo.vecUrlAPath[0], strSaveDir);
-
+	g_scanCount++;
+	pWnd->PostMessage(WM_PROCESS, NULL, NULL);
+	pWnd->FormatScanMsg("生成切割图像:%s", pinfo.vecUrlAPath[0].c_str());
 
 	return 0;
 }
@@ -231,7 +236,7 @@ string GetBatchId()
 	SYSTEMTIME st;
 	GetLocalTime(&st);
 	char chBuf[24] = { 0 };
-	sprintf(chBuf, "%02d%02d%02d%02d%02d%02d ",
+	sprintf(chBuf, "%02d%02d%02d%02d%02d%02d",
 		st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
 	return chBuf;
 }
@@ -546,6 +551,7 @@ void CMFCApplication1Dlg::SelectFile(CString& lpszFile)
 	if (IDOK == FileOpen.DoModal())
 	{
 		lpszFile = FileOpen.GetPathName();
+		lpszFile.Replace('\\', '/');
 	}
 }
 
@@ -663,6 +669,20 @@ void CMFCApplication1Dlg::OnBnClickedBtnScan()
 	GetDlgItem(ID_BTN_SCAN)->EnableWindow(FALSE);
 	m_strScanMsg = "";
 
+	CString strNormal(m_strCutPath);
+	strNormal.Append(L"/normal");
+	if (!PathIsDirectory(strNormal))
+	{
+		::CreateDirectory(strNormal, 0);
+	}
+
+	CString strAbnormal(m_strCutPath);
+	strAbnormal.Append(L"/abnormal");
+	if (!PathIsDirectory(strAbnormal))
+	{
+		::CreateDirectory(strAbnormal, 0);
+	}
+
 	SAFETY_EXIT_THREAD(_threadScan, 100);
 	_threadScan = CreateThread(NULL, 0, ScanThread, NULL, 0, NULL);
 }