Pārlūkot izejas kodu

解决插了2个usb打印机,不打印的问题

zhangyang 6 gadi atpakaļ
vecāks
revīzija
77d3546ac6

BIN
bin/Win32/Debug/lewaimai_pos_windows/db/pos.db


BIN
bin/Win32/Debug/lewaimai_pos_windows/lewaimai_pos_windows.exe


BIN
bin/Win32/Debug/lewaimai_pos_windows_server/lewaimai_pos_windows_server.exe


BIN
bin/Win32/Release/lewaimai_pos_windows/lewaimai_pos_windows.exe


BIN
bin/Win32/Release/setup/lewaimai_pos_windows_setup_1.0.0.2.exe


+ 1 - 1
bin/Win32/Release/setup/乐外卖接单软件安装脚本.nsi

@@ -2,7 +2,7 @@
 
 ; HM NIS Edit Wizard helper defines
 !define PRODUCT_NAME "乐外卖接单软件"
-!define PRODUCT_VERSION "1.0.0.2"
+!define PRODUCT_VERSION "1.0.0.3"
 !define PRODUCT_PUBLISHER "深圳市迅享科技有限公司"
 !define PRODUCT_WEB_SITE "https://www.lewaimai.com"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_NAME}.exe"

+ 2 - 3
lewaimai_pos_windows/network/CLewaimaiHttpClient.cpp

@@ -91,7 +91,6 @@ bool CLewaimaiHttpClient::Request(std::string url, std::map<string, string> para
 	std::string nonce = "123456";
 
 	//先添加默认参数,用于计算签名
-	params["machinecode"] = m_client.m_machinecode;
 	params["username"] = m_client.m_username;
 	params["nonce"] = nonce;
 	params["timestamp"] = timestamp;
@@ -141,12 +140,12 @@ bool CLewaimaiHttpClient::Request(std::string url, std::map<string, string> para
 		}
 	}
 
-	//LOG_INFO("postString:" << postString.c_str());
+	LOG_INFO("postString:" << postString.c_str());
 
 	CHttpClient m_httpClient;
 	int ret = m_httpClient.Posts(m_client.m_url + url, postString, response, NULL);
 
-	//LOG_INFO("response:" << response.c_str());
+	LOG_INFO("response:" << response.c_str());
 
 	if (ret == 0)
 	{

+ 0 - 1
lewaimai_pos_windows/network/CLewaimaiHttpClient.h

@@ -21,7 +21,6 @@ public:
 private:
 	std::string m_username;
 	std::string m_password;
-	std::string m_machinecode = "e6bc5694877b2aec";
 
 	std::string m_url = "https://api.lewaimai.com/seller";
 };

BIN
lewaimai_pos_windows/resource/lewaimai_pos_windows.aps


BIN
lewaimai_pos_windows/resource/lewaimai_pos_windows.rc


+ 25 - 11
lewaimai_pos_windows/tool/CPosPrinter.cpp

@@ -44,17 +44,20 @@ bool CPosPrinter::InitShouyin()
     {
         Port = szDevicePath[i++];
         //LOG_INFO("device.Port = " << Port);
-    }
 
-    m_hPort = CreateFile(Port, GENERIC_READ | GENERIC_WRITE,
-                         0, NULL,
-                         OPEN_EXISTING,
-                         FILE_ATTRIBUTE_NORMAL, NULL);
+		HANDLE hPort = CreateFile(Port, GENERIC_READ | GENERIC_WRITE,
+			0, NULL,
+			OPEN_EXISTING,
+			FILE_ATTRIBUTE_NORMAL, NULL);
 
-    if(m_hPort == INVALID_HANDLE_VALUE)
-    {
-        // 打开端口失败
-        return false;
+		if (hPort == INVALID_HANDLE_VALUE)
+		{
+			// 打开端口失败
+			continue;
+		}
+
+		//把当前发现的保存下来
+		m_hPorts.push_back(hPort);
     }
 
     return true;
@@ -779,7 +782,13 @@ int CPosPrinter::WriteData(string msg)
     if(m_type == 1)
     {
         DWORD dwWrite;
-        return WriteFile(m_hPort, msg.c_str(), (DWORD)msg.length(), &dwWrite, NULL);
+
+		for (std::vector<HANDLE>::iterator it = m_hPorts.begin(); it != m_hPorts.end(); it++)
+		{
+			WriteFile(*it, msg.c_str(), (DWORD)msg.length(), &dwWrite, NULL);
+		}
+
+		return 1;
     }
 
     else
@@ -803,7 +812,12 @@ int CPosPrinter::WriteBuf(char* buf, int len)
     if(m_type == 1)
     {
         DWORD dwWrite;
-        return WriteFile(m_hPort, buf, len, &dwWrite, NULL);
+
+		for (std::vector<HANDLE>::iterator it = m_hPorts.begin(); it != m_hPorts.end(); it++)
+		{
+			WriteFile(*it, buf, len, &dwWrite, NULL);
+		}
+		return 1;
     }
 
     else

+ 1 - 1
lewaimai_pos_windows/tool/CPosPrinter.h

@@ -55,7 +55,7 @@ private:
 	std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
 
 private:
-	HANDLE m_hPort = NULL;
+	std::vector<HANDLE> m_hPorts;
 
 	boost::asio::io_service m_io;
 	boost::asio::ip::tcp::socket m_socket;

+ 2 - 0
lewaimai_pos_windows_server/obj/x86/Release/lewaimai.e085afd9.tlog/lewaimai_pos_windows_server_linux.lastbuildstate

@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=:PlatformToolSet=Remote_GCC_1_0:EnableManagedIncrementalBuild=:VCToolArchitecture=:WindowsTargetPlatformVersion=
+Release|x86|E:\work\code\lewaimai_pos_windows\|

+ 0 - 0
lewaimai_pos_windows_server/obj/x86/Release/lewaimai.e085afd9.tlog/unsuccessfulbuild


+ 4 - 0
lewaimai_pos_windows_server/obj/x86/Release/lewaimai_pos_windows_server_linux.log

@@ -0,0 +1,4 @@
+D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(391,5): warning MSB8028: 中间目录(E:\work\code\lewaimai_pos_windows\lewaimai_pos_windows_server\obj\x86\Release\)包含从另一个项目(zhipuzi_pos_windows_server_linux.vcxproj)共享的文件。   这会导致错误的清除和重新生成行为。
+  Validating sources
+  Copying sources remotely to '172.16.1.71'
+D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Application Type\Linux\1.0\Linux.targets(162,5): error : Could not connect to the remote system. Please verify your connection settings, and that your machine is on the network and reachable.