Sfoglia il codice sorgente

厨房打印机的打印也弄好了

zhangyang 6 anni fa
parent
commit
9c0f008416

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


BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


BIN
bin/Win32/Debug/zhipuzi_pos_windows_server/zhipuzi_pos_windows_server.exe


+ 217 - 21
lewaimai_dispatch/network/CMessagePush.cpp

@@ -13,8 +13,28 @@ CMessagePush::~CMessagePush()
 
 
 void CMessagePush::Start()
 void CMessagePush::Start()
 {
 {
-	std::thread t(&CMessagePush::Run, this);
-	t.detach();
+	//开始处理接收消息
+	std::thread t_1(&CMessagePush::Run, this);
+	t_1.detach();
+
+	//处理声音提醒
+	std::thread t_2(&CMessagePush::HandleVoice, this);
+	t_2.detach();
+
+	//处理订单确认
+	std::thread t_3(&CMessagePush::HandleConfirm, this);
+	t_3.detach();
+
+	//处理收银打印
+	std::thread t_4(&CMessagePush::HandleShouyinPrinter, this);
+	t_4.detach();
+
+	//处理厨房打印
+	std::thread t_5(&CMessagePush::HandleChufangPrinter, this);
+	t_5.detach();
+
+	std::thread t_6(&CMessagePush::HandlePrinter, this);
+	t_6.detach();
 }
 }
 
 
 void CMessagePush::Run()
 void CMessagePush::Run()
@@ -102,17 +122,13 @@ void CMessagePush::HandleMessage(std::string msg)
 			//新订单来了,首先判断是否要语音提醒
 			//新订单来了,首先判断是否要语音提醒
 			if (CSetting::GetParam("setting_is_new_waimai_voice") == "1")
 			if (CSetting::GetParam("setting_is_new_waimai_voice") == "1")
 			{
 			{
-				wstring path = CSystem::GetProgramDir() + L"\\music\\new_wamai_order.wav";
-				PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+				AddVoice(order_id);
 			}
 			}
 
 
-			//这里注意,下面要交给另外一个线程去处理,否则如果没有厨房打印机试图连接可能会卡住线程
-
 			//判断是否要自动确认
 			//判断是否要自动确认
 			if (CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
 			if (CSetting::GetParam("setting_is_new_waimai_autoconfirm") == "1")
 			{
 			{
-				CWaimaiOrder newOrder;
-				newOrder.ConfirmeOrder(order_id);
+				AddConfirm(order_id);
 			}
 			}
 
 
 			//判断是否右下角弹框提醒
 			//判断是否右下角弹框提醒
@@ -121,19 +137,7 @@ void CMessagePush::HandleMessage(std::string msg)
 				
 				
 			}
 			}
 
 
-			//判断是否自动打印收银小票
-			if (CSetting::GetParam("setting_is_new_waimai_printer") == "1")
-			{
-				CPosPrinter printer;
-				printer.PrintWaimaiOrder(order_id, order_no);
-			}
-
-			//判断是否进行自动的厨房打印
-			if (CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
-			{
-				CPosPrinter printer(2);
-				printer.PrintWaimaiOrder(order_id, order_no);
-			}
+			AddPinter(order_id, order_no);
 		}
 		}
 	}
 	}
 	catch (std::exception& e)
 	catch (std::exception& e)
@@ -172,4 +176,196 @@ void CMessagePush::handle_write(const boost::system::error_code& error)
 	{
 	{
 		//这里有时会出现,看看是什么错误,可能是断开了跟服务器的连接
 		//这里有时会出现,看看是什么错误,可能是断开了跟服务器的连接
 	}
 	}
+}
+
+void CMessagePush::AddVoice(std::string order_id)
+{
+	m_voice_mutex.lock();
+
+	m_voice_queue.push(order_id);
+
+	m_voice_mutex.unlock();
+}
+
+void CMessagePush::AddConfirm(std::string order_id)
+{
+	m_confirm_mutex.lock();
+
+	m_confirm_queue.push(order_id);
+
+	m_confirm_mutex.unlock();
+}
+
+void CMessagePush::AddPinter(std::string order_id, std::string order_no)
+{
+	m_printer_mutex.lock();
+
+	WaimaiPinterInfo newPrinter;
+	newPrinter.order_id = order_id;
+	newPrinter.order_no = order_no;
+
+	m_printer_queue.push(newPrinter);
+
+	m_printer_mutex.unlock();
+}
+
+void CMessagePush::AddShouyinPrinter(CWaimaiOrder order)
+{
+	m_shouyin_printer_mutex.lock();
+
+	m_shouyin_printer_queue.push(order);
+
+	m_shouyin_printer_mutex.unlock();
+}
+
+void CMessagePush::AddChufangPrinter(CWaimaiOrder order)
+{
+	m_chufang_printer_mutex.lock();
+
+	m_chufang_printer_queue.push(order);
+
+	m_chufang_printer_mutex.unlock();
+}
+
+void CMessagePush::HandleVoice()
+{
+	while (true)
+	{
+		m_voice_mutex.lock();
+
+		if (m_voice_queue.empty())
+		{
+			m_voice_mutex.unlock();
+
+			CSystem::my_sleep(1);
+			continue;
+		}
+
+		std::string order_id = m_voice_queue.back();
+		m_voice_queue.pop();
+
+		m_voice_mutex.unlock();
+
+		wstring path = CSystem::GetProgramDir() + L"\\music\\new_wamai_order.wav";
+		PlaySound(path.c_str(), NULL, SND_FILENAME | SND_ASYNC);
+
+		//8秒内最多播放一次
+		CSystem::my_sleep(8);
+	}
+}
+
+void CMessagePush::HandleConfirm()
+{
+	while (true)
+	{
+		m_confirm_mutex.lock();
+
+		if (m_confirm_queue.empty())
+		{
+			m_confirm_mutex.unlock();
+
+			CSystem::my_sleep(1);
+			continue;
+		}
+
+		std::string order_id = m_confirm_queue.back();
+		m_confirm_queue.pop();
+
+		m_confirm_mutex.unlock();
+
+		CWaimaiOrder newOrder;
+		newOrder.ConfirmeOrder(order_id);
+	}
+}
+
+void CMessagePush::HandlePrinter()
+{
+	while (true)
+	{
+		m_printer_mutex.lock();
+
+		if (m_printer_queue.empty())
+		{
+			m_printer_mutex.unlock();
+
+			CSystem::my_sleep(1);
+			continue;
+		}
+
+		WaimaiPinterInfo printerInfo = m_printer_queue.back();
+		std::string order_id = printerInfo.order_id;
+		std::string order_no = printerInfo.order_no;
+
+		m_printer_queue.pop();
+
+		m_printer_mutex.unlock();
+
+		CWaimaiOrder order;
+		if (CSetting::GetParam("setting_is_new_waimai_printer") == "1" || CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+		{
+			order.InitData(order_id, order_no);
+		}
+
+		//判断是否自动打印收银小票
+		if (CSetting::GetParam("setting_is_new_waimai_printer") == "1")
+		{
+			AddShouyinPrinter(order);
+		}
+
+		//判断是否进行自动的厨房打印
+		if (CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+		{
+			AddChufangPrinter(order);
+		}
+	}
+}
+
+void CMessagePush::HandleShouyinPrinter()
+{
+	while (true)
+	{
+		m_shouyin_printer_mutex.lock();
+
+		if (m_shouyin_printer_queue.empty())
+		{
+			m_shouyin_printer_mutex.unlock();
+
+			CSystem::my_sleep(1);
+			continue;
+		}
+
+		CWaimaiOrder order = m_shouyin_printer_queue.back();
+
+		m_shouyin_printer_queue.pop();
+
+		m_shouyin_printer_mutex.unlock();
+
+		CPosPrinter printer;
+		printer.PrintWaimaiOrderShouyin(order);
+	}
+}
+
+void CMessagePush::HandleChufangPrinter()
+{
+	while (true)
+	{
+		m_chufang_printer_mutex.lock();
+
+		if (m_chufang_printer_queue.empty())
+		{
+			m_chufang_printer_mutex.unlock();
+
+			CSystem::my_sleep(1);
+			continue;
+		}
+
+		CWaimaiOrder order = m_chufang_printer_queue.back();
+
+		m_chufang_printer_queue.pop();
+
+		m_chufang_printer_mutex.unlock();
+
+		CPosPrinter printer;
+		printer.PrintWaimaiOrderChufang(order);
+	}
 }
 }

+ 41 - 3
lewaimai_dispatch/network/CMessagePush.h

@@ -1,6 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "../pch/pch.h"
 #include "../pch/pch.h"
+#include "../order/CWaimaiOrder.h"
 
 
 using boost::asio::ip::tcp;
 using boost::asio::ip::tcp;
 
 
@@ -14,11 +15,18 @@ public:
 	std::string m_order_no;
 	std::string m_order_no;
 };
 };
 
 
+class WaimaiPinterInfo
+{
+public:
+	std::string order_id;
+	std::string order_no;
+};
+
 class CMessagePush
 class CMessagePush
 {
 {
 public:
 public:
-	CMessagePush(boost::asio::io_context& io_context)
-		: socket_(io_context), m_io_context(io_context)
+	CMessagePush()
+		: socket_(m_io_context)
 	{
 	{
 
 
 	}
 	}
@@ -39,18 +47,48 @@ public:
 	//专门处理推送消息
 	//专门处理推送消息
 	void HandleMessage(std::string msg);
 	void HandleMessage(std::string msg);
 
 
+	//队列处理
+	void HandleVoice();
+	void HandleConfirm();
+	void HandlePrinter();
+	void HandleShouyinPrinter();
+	void HandleChufangPrinter();
+
+	void AddPinter(std::string order_id, std::string order_no);
+
+	void AddShouyinPrinter(CWaimaiOrder order);
+
+	void AddChufangPrinter(CWaimaiOrder order);
+
 private:
 private:
 	void handle_read(const boost::system::error_code& error,
 	void handle_read(const boost::system::error_code& error,
 		size_t bytes_transferred);
 		size_t bytes_transferred);
 
 
 	void handle_write(const boost::system::error_code& error);
 	void handle_write(const boost::system::error_code& error);
 
 
+	void AddVoice(std::string order_id);
+
+	void AddConfirm(std::string order_id);	
+
 private:
 private:
 	bool m_is_work = true;
 	bool m_is_work = true;
 
 
-	boost::asio::io_context& m_io_context;
+	boost::asio::io_context m_io_context;
 	tcp::socket socket_;
 	tcp::socket socket_;
+
 	enum { max_length = 1024 };
 	enum { max_length = 1024 };
 	char data_[max_length];
 	char data_[max_length];
+
+	std::queue<std::string> m_voice_queue;
+	std::queue<std::string> m_confirm_queue;
+	std::queue<WaimaiPinterInfo> m_printer_queue;
+	std::queue<CWaimaiOrder> m_shouyin_printer_queue;
+	std::queue<CWaimaiOrder> m_chufang_printer_queue;
+
+	std::mutex m_voice_mutex;
+	std::mutex m_confirm_mutex;
+	std::mutex m_printer_mutex;
+	std::mutex m_shouyin_printer_mutex;
+	std::mutex m_chufang_printer_mutex;
 };
 };
 
 

+ 299 - 40
lewaimai_dispatch/tool/CPosPrinter.cpp

@@ -6,35 +6,22 @@
 
 
 using boost::asio::ip::tcp;
 using boost::asio::ip::tcp;
 
 
-CPosPrinter::CPosPrinter(int print_type): m_socket(m_io)
+CPosPrinter::CPosPrinter(): m_socket(m_io)
 {
 {
-	m_type = print_type;
 
 
-    if(print_type == 1)
-    {
-        Init();
-    }
-
-    else
-    {
-        InitChufang();
-    }
 }
 }
 
 
 
 
 CPosPrinter::~CPosPrinter()
 CPosPrinter::~CPosPrinter()
 {
 {
-	if (m_type == 2)
-	{
-		m_socket.close();
-	}
+
 }
 }
 
 
-bool CPosPrinter::Init()
+bool CPosPrinter::InitShouyin()
 {
 {
     //遍历USB设备,找到POS打印机路径
     //遍历USB设备,找到POS打印机路径
     //设备路径
     //设备路径
-    TCHAR * szDevicePath[MAX_DEVICE];
+    TCHAR* szDevicePath[MAX_DEVICE];
     //设置中文字符
     //设置中文字符
     setlocale(LC_CTYPE, "chs");
     setlocale(LC_CTYPE, "chs");
     TCHAR* Port = NULL;
     TCHAR* Port = NULL;
@@ -69,37 +56,26 @@ bool CPosPrinter::Init()
     return true;
     return true;
 }
 }
 
 
-bool CPosPrinter::InitChufang()
+void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
 {
 {
-    try
-    {
-        boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string("192.168.10.47"), 9100);
-        m_socket.connect(ep);
-    }
+	//设置模式,后面输出数据不会错
+	m_type = 1;
 
 
-    catch(std::exception& e)
+    //初始化收银打印机的链接
+    bool ret = InitShouyin();
+    if(ret == false)
     {
     {
-        std::cout << e.what() << std::endl;
+        LOG_INFO("打开收银打印机端口失败!");
+        return;
     }
     }
 
 
-    return true;
-}
-
-void CPosPrinter::PrintWaimaiOrder(string order_id, std::string order_no)
-{
-    CWaimaiOrder order;
-    order.InitData(order_id, order_no);
-
-    PrintWaimaiOrder(order);
-}
-
-void CPosPrinter::PrintWaimaiOrder(CWaimaiOrder& order)
-{
+    //读取当前收银打印机的设置
     std::string guige = CSetting::GetParam("setting_printer_guige");
     std::string guige = CSetting::GetParam("setting_printer_guige");
-    std::string lianshu = CSetting::GetParam("setting_printer_lianshu");
 
 
+    std::string lianshu = CSetting::GetParam("setting_printer_lianshu");
     int n_lianshu = atoi(lianshu.c_str());
     int n_lianshu = atoi(lianshu.c_str());
 
 
+    //正式开始打印
     for(int i = 0; i < n_lianshu; i++)
     for(int i = 0; i < n_lianshu; i++)
     {
     {
         POS_Reset();
         POS_Reset();
@@ -392,6 +368,289 @@ void CPosPrinter::PrintWaimaiOrder(CWaimaiOrder& order)
     }
     }
 }
 }
 
 
+void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
+{
+	//设置模式,后面输出数据不会错
+	m_type = 2;
+
+    //读取厨房打印机信息
+    std::vector<ChufangPrinter> total_printers = CSetting::getChufangPrints();
+
+    for(std::vector<ChufangPrinter>::iterator it = total_printers.begin(); it != total_printers.end(); it++)
+    {
+        ChufangPrinter printer = *it;
+
+        std::string ip = printer.ip;
+
+        //初始化连接
+        try
+        {
+            boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string(ip.c_str()), 9100);
+            m_socket.connect(ep);
+        }
+
+        catch(std::exception& e)
+        {
+            std::string err = e.what();
+            LOG_INFO("连接厨房打印机失败,IP地址:" << ip.c_str() << ",错误信息:" << err.c_str());
+
+            //连接失败了,处理下一个厨房打印机
+            continue;
+        }
+
+        std::string guige = printer.guige;
+        std::string fendan = printer.fendan;
+        std::string fenlei = printer.fenlei;
+        std::string fenlei_ids = printer.fenlei_ids;
+
+        std::vector<CWaimaiOrderItem> cur_printer_use;
+        if(fenlei == "0")
+        {
+            cur_printer_use = order.m_order_items;
+        }
+        else
+        {
+            //如果开启了分类打印,就要比对了
+            std::map<string, bool> ids_map;
+            std::vector<string> ids = CLewaimaiString::Split(fenlei_ids, ",");
+            for(std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
+            {
+                ids_map[(*it)] = true;
+            }
+
+            for(std::vector<CWaimaiOrderItem>::iterator it = order.m_order_items.begin(); it != order.m_order_items.end(); it++)
+            {
+                if(ids_map.find((*it).m_type_id) != ids_map.end())
+                {
+                    //如果当前商品的分类,在厨房打印机设置的分类里面,才加入
+                    cur_printer_use.push_back(*it);
+                }
+            }
+        }
+
+        if(fendan == "0")
+        {
+            POS_Reset();
+
+            POS_TextOut("派工单", true, 1);
+
+            POS_FeedLine();
+            POS_FeedLine();
+
+            //预设选项
+            if(order.m_order_field.size() > 1)
+            {
+                for(std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
+                {
+                    string order_field = CLewaimaiString::UTF8ToANSI((*it).name) + ":" + CLewaimaiString::UTF8ToANSI((*it).value);
+                    POS_TextOut(order_field, false, 0);
+                    POS_FeedLine();
+                }
+            }
+
+            //准备开始打印商品详情
+            string lines;
+
+            if(guige == "58")
+            {
+                lines = "--------------------------------";
+            }
+
+            else
+            {
+                lines = "------------------------------------------------";
+            }
+
+            POS_TextOut(lines);
+            POS_FeedLine();
+
+            //商品标题
+            if(guige == "58")
+            {
+                POS_TextOut("商品              单价 数量 金额");
+            }
+
+            else
+            {
+                POS_TextOut("商品                            单价  数量  金额");
+            }
+
+            POS_FeedLine();
+
+            //商品内容
+            for(std::vector<CWaimaiOrderItem>::iterator it = cur_printer_use.begin(); it != cur_printer_use.end(); it++)
+            {
+                std::string food_name = (*it).m_food_name;
+                std::string food_price = (*it).m_item_price;
+                std::string quantity = (*it).m_quantity;
+
+                //计算总价
+                double item_price = atof(food_price.c_str()) * atof(quantity.c_str());
+                std::string food_total_price = CLewaimaiString::DoubleToString(item_price, 2);
+
+                food_name = CLewaimaiString::UTF8ToANSI(food_name);
+
+                //先输出商品名字
+                std::vector<string> m_names;
+
+                if(guige == "58")
+                {
+                    m_names = HandleFoodname(food_name, 1);
+                }
+
+                else
+                {
+                    m_names = HandleFoodname(food_name, 2);
+                }
+
+                std::string firstLine = m_names[0];
+                std::string priceShow = HandleFoodItemPrice(food_price, 2);
+                std::string quantityShow = HandleFoodQuantity(quantity, 2);
+                std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, 2);
+
+                std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
+
+                POS_TextOut(firstLineShow, false, 0);
+                POS_FeedLine();
+
+                for(std::vector<string>::iterator it = m_names.begin() + 1; it != m_names.end(); it++)
+                {
+                    POS_TextOut((*it), false, 0);
+                    POS_FeedLine();
+                }
+            }
+
+            //判断是否有备注
+            if(order.m_memo.length() > 0)
+            {
+                POS_FeedLine();
+                string address = "顾客备注:" + CLewaimaiString::UTF8ToANSI(order.m_memo);
+                POS_TextOut(address, false, 0);
+                POS_FeedLine();
+            }
+
+            //结束商品详情打印
+            POS_TextOut(lines);
+            POS_FeedLine();
+
+            POS_FeedLine();
+
+            POS_CutPaper();
+        }
+        else
+        {
+            POS_Reset();
+
+            //分单模式下,每个商品打印一张单
+            for(std::vector<CWaimaiOrderItem>::iterator it = cur_printer_use.begin(); it != cur_printer_use.end(); it++)
+            {
+                POS_TextOut("派工单", true, 1);
+
+                POS_FeedLine();
+                POS_FeedLine();
+
+                //预设选项
+                if(order.m_order_field.size() > 1)
+                {
+                    for(std::vector<CWaimaiOrderField>::iterator it = order.m_order_field.begin(); it != order.m_order_field.end() - 1; it++)
+                    {
+                        string order_field = CLewaimaiString::UTF8ToANSI((*it).name) + ":" + CLewaimaiString::UTF8ToANSI((*it).value);
+                        POS_TextOut(order_field, false, 0);
+                        POS_FeedLine();
+                    }
+                }
+
+                //准备开始打印商品详情
+                string lines;
+
+                if(guige == "58")
+                {
+                    lines = "--------------------------------";
+                }
+
+                else
+                {
+                    lines = "------------------------------------------------";
+                }
+
+                POS_TextOut(lines);
+                POS_FeedLine();
+
+                //商品标题
+                if(guige == "58")
+                {
+                    POS_TextOut("商品              单价 数量 金额");
+                }
+
+                else
+                {
+                    POS_TextOut("商品                            单价  数量  金额");
+                }
+
+                POS_FeedLine();
+
+                std::string food_name = (*it).m_food_name;
+                std::string food_price = (*it).m_item_price;
+                std::string quantity = (*it).m_quantity;
+
+                //计算总价
+                double item_price = atof(food_price.c_str()) * atof(quantity.c_str());
+                std::string food_total_price = CLewaimaiString::DoubleToString(item_price, 2);
+
+                food_name = CLewaimaiString::UTF8ToANSI(food_name);
+
+                //先输出商品名字
+                std::vector<string> m_names;
+
+                if(guige == "58")
+                {
+                    m_names = HandleFoodname(food_name, 1);
+                }
+
+                else
+                {
+                    m_names = HandleFoodname(food_name, 2);
+                }
+
+                std::string firstLine = m_names[0];
+                std::string priceShow = HandleFoodItemPrice(food_price, 2);
+                std::string quantityShow = HandleFoodQuantity(quantity, 2);
+                std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, 2);
+
+                std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
+
+                POS_TextOut(firstLineShow, false, 0);
+                POS_FeedLine();
+
+                for(std::vector<string>::iterator it = m_names.begin() + 1; it != m_names.end(); it++)
+                {
+                    POS_TextOut((*it), false, 0);
+                    POS_FeedLine();
+                }
+
+                //判断是否有备注
+                if(order.m_memo.length() > 0)
+                {
+                    POS_FeedLine();
+                    string address = "顾客备注:" + CLewaimaiString::UTF8ToANSI(order.m_memo);
+                    POS_TextOut(address, false, 0);
+                    POS_FeedLine();
+                }
+
+                //结束商品详情打印
+                POS_TextOut(lines);
+                POS_FeedLine();
+
+                POS_FeedLine();
+
+                POS_CutPaper();
+            }
+        }
+
+		m_socket.close();
+    }
+}
+
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 //获取CreateFile的USB端口号
 //获取CreateFile的USB端口号
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -532,7 +791,7 @@ int CPosPrinter::WriteData(string msg)
     }
     }
 }
 }
 
 
-int CPosPrinter::WriteBuf(char *buf, int len)
+int CPosPrinter::WriteBuf(char* buf, int len)
 {
 {
     if(m_type == 1)
     if(m_type == 1)
     {
     {

+ 8 - 11
lewaimai_dispatch/tool/CPosPrinter.h

@@ -15,19 +15,15 @@ const GUID USB_GUID = {0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0, 0x4f
 class CPosPrinter
 class CPosPrinter
 {
 {
 public:
 public:
-	//print_type为1表示收银打印,为2表示厨房打印
-    CPosPrinter(int print_type = 1);
+    CPosPrinter();
     ~CPosPrinter();
     ~CPosPrinter();
 
 
-	bool Init();
-
-	bool InitChufang();
-
-	//type为1表示58mmm,为2表示80mmm
-	void PrintWaimaiOrder(std::string order_id, std::string order_no);
-    void PrintWaimaiOrder(CWaimaiOrder& order);
+    void PrintWaimaiOrderShouyin(CWaimaiOrder& order);
+	void PrintWaimaiOrderChufang(CWaimaiOrder& order);
 
 
 private:
 private:
+	bool InitShouyin();
+
 	int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
 	int GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath);
 
 
 	int WriteData(string meg);
 	int WriteData(string meg);
@@ -59,10 +55,11 @@ private:
 	std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
 	std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
 
 
 private:
 private:
-	int m_type;
-
 	HANDLE m_hPort = NULL;
 	HANDLE m_hPort = NULL;
 
 
 	boost::asio::io_service m_io;
 	boost::asio::io_service m_io;
 	boost::asio::ip::tcp::socket m_socket;
 	boost::asio::ip::tcp::socket m_socket;
+
+	//这个是当前的输出模式,是收银模式还是厨房打印模式
+	int m_type;
 };
 };

+ 4 - 2
lewaimai_dispatch/wnd/CMainWnd.cpp

@@ -133,7 +133,8 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         order.InitData(waimai_order_id, waimai_order_no);
         order.InitData(waimai_order_id, waimai_order_no);
 
 
         CPosPrinter printer;
         CPosPrinter printer;
-        printer.PrintWaimaiOrder(order);
+        printer.PrintWaimaiOrderShouyin(order);
+		//printer.PrintWaimaiOrderChufang(order);
     }
     }
 
 
     else if(name == _T("waimai_order_list_confirme"))
     else if(name == _T("waimai_order_list_confirme"))
@@ -285,7 +286,8 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         CWaimaiOrderInfoUI* order_info_page = static_cast<CWaimaiOrderInfoUI*>(m_pm.FindControl(_T("waimaiorder_info_page")));
         CWaimaiOrderInfoUI* order_info_page = static_cast<CWaimaiOrderInfoUI*>(m_pm.FindControl(_T("waimaiorder_info_page")));
 
 
         CPosPrinter printer;
         CPosPrinter printer;
-        printer.PrintWaimaiOrder(order_info_page->m_order);
+        printer.PrintWaimaiOrderShouyin(order_info_page->m_order);
+		//printer.PrintWaimaiOrderChufang(order_info_page->m_order);
     }
     }
 
 
     else if(name == _T("waimai_order_info_page_confirme"))
     else if(name == _T("waimai_order_info_page_confirme"))

+ 2 - 3
lewaimai_dispatch/zhipuzi_pos_windows.cpp

@@ -17,9 +17,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
 	sqllite.InitConfig();
 	sqllite.InitConfig();
 	sqllite.Close();
 	sqllite.Close();
 
 
-    //由这个对象来处理消息推送
-    boost::asio::io_context io_context;
-    CMessagePush push(io_context);
+    //由这个对象来处理消息推送的接收,以及消息的处理
+    CMessagePush push;
     push.Start();
     push.Start();
 
 
     //开始展示窗口
     //开始展示窗口