Quellcode durchsuchen

对接60*80mm的标签纸

张洋 vor 3 Jahren
Ursprung
Commit
17d0437e08

+ 1 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting_biaoqian_print.xml

@@ -13,6 +13,7 @@
 			<ListLabelElement text="35*25mm" />
 			<ListLabelElement text="30*25mm" />
 			<ListLabelElement text="30*20mm" />
+			<ListLabelElement text="60*80mm" />
 		</Combo>
 	</HorizontalLayout>
 	

+ 10 - 0
zhipuzi_pos_windows/page/CSettingPageUI.cpp

@@ -667,6 +667,12 @@ void CSettingPageUI::InitShow()
 		com->SelectItem(3, false, false);
 		com->SetText(L"30*20mm");
 	}
+	else if (setting_biaoqian_printer_guige == "60*80mm")
+	{
+		com->SetInternVisible(true);
+		com->SelectItem(4, false, false);
+		com->SetText(L"60*80mm");
+	}
 
 	com = static_cast<CComboUI*>(this->FindSubControl(_T("setting_biaoqian_printer_fangxiang")));
 	std::string setting_biaoqian_printer_fangxiang = CSetting::GetInstance()->GetParam("setting_biaoqian_printer_fangxiang");
@@ -1795,6 +1801,10 @@ void CSettingPageUI::HandleItemSelectMsg(TNotifyUI& msg)
 		{
 			CSetting::GetInstance()->SetParam("setting_biaoqian_printer_guige", "30*20mm");
 		}
+		else if (com->GetCurSel() == 4)
+		{
+			CSetting::GetInstance()->SetParam("setting_biaoqian_printer_guige", "60*80mm");
+		}
 	}
 	else if (name == _T("setting_biaoqian_printer_fangxiang"))
 	{

+ 153 - 40
zhipuzi_pos_windows/print/CPosPrinterData.cpp

@@ -500,6 +500,11 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
 		biaoqian_width = 30;
 		biaoqian_height = 20;
 	}
+	else  if (printer_guige == "60*80mm")
+	{
+		biaoqian_width = 60;
+		biaoqian_height = 80;
+	}
 	else
 	{
 		biaoqian_width = 40;
@@ -531,7 +536,7 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
 		{
 			if (it->is_taocan_item == false)
 			{
-				//如果当前商品的分类,在厨房打印机设置的分类里面,才加入
+				//如果当前商品的分类,在标签打印机设置的分类里面,才加入
 				cur_printer_use.push_back(*it);
 			}
 		}
@@ -550,7 +555,7 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
 		{
 			if (ids_map.find((*it).m_type_id) != ids_map.end() && it->is_taocan_item == false)
 			{
-				//如果当前商品的分类,在厨房打印机设置的分类里面,才加入
+				//如果当前商品的分类,在标签打印机设置的分类里面,才加入
 				cur_printer_use.push_back(*it);
 			}
 		}
@@ -589,11 +594,14 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
 
 			//纸张宽度40mm的,是 320个点位(每mm8个),刚好可以放13个汉字,每个汉字宽度差不多是24,商品换行显示的时候,
 			//每行最多12个汉字,也就是空24个,因此这里设置12,刚好左右各空一半
-            textData += BIAOQIAN_TEXTGet(order_num_info, 12, 6, 1, 1);
+            textData += BIAOQIAN_TEXTGet(order_num_info, 12, 12, 1, 1);
 
             //打印份数
             std::string numInfo = to_string(curFoodNum) + "/" + to_string(foodNum);
-            textData += BIAOQIAN_TEXTGet(numInfo, 180, 6, 1, 1);
+
+			//计算份数的位置
+			int nFenshuLeft = (biaoqian_width - 8) * 8;
+            textData += BIAOQIAN_TEXTGet(numInfo, nFenshuLeft, 12, 1, 1);
 
             //每行最多显示12个汉字,这里要计算一下换行(要先转成ANSI格式)
             std::string handle_food_name = CLewaimaiString::UTF8ToANSI(food_name);
@@ -629,27 +637,76 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
                 nRow++;
             }
 
-			int nPriceY;
-			if (biaoqian_height ==  30)
+			int nHeightNow;
+			if (biaoqian_height <= 30)
 			{
-				nPriceY = 180;
-			}
-			else if (biaoqian_height == 25)
-			{
-				nPriceY = 140;
+				nHeightNow = (biaoqian_height - 8) * 8;
 			}
-			else if (biaoqian_height == 20)
+			else
 			{
-				nPriceY = 100;
+				nHeightNow = (30 - 8) * 8;
 			}
 
             //打印价格
-            std::string priceInfo = CLewaimaiString::UTF8ToANSI(food_price) + "元";
-            textData += BIAOQIAN_TEXTGet(priceInfo, 12, nPriceY, 1, 1);
+            std::string priceInfo = "单价:" + CLewaimaiString::UTF8ToANSI(food_price) + "元";
+            textData += BIAOQIAN_TEXTGet(priceInfo, 12, nHeightNow, 1, 1);
 
             //打印订单号
             std::string order_num = "订单号:" + CLewaimaiString::UTF8ToANSI(order.m_order_num);
-            textData += BIAOQIAN_TEXTGet(order_num, 12, nPriceY + 30, 1, 1);
+            textData += BIAOQIAN_TEXTGet(order_num, 12, nHeightNow + 30, 1, 1);
+
+			if (biaoqian_width >= 60)
+			{
+				nHeightNow = nHeightNow + 30 + 30 + 30;
+
+				//这种是很宽的纸,接着打印姓名、电话、地址等信息
+
+				if (order.m_is_selftake == "1")
+				{
+					string date = "配送时间:【自取单】" + CLewaimaiString::UTF8ToANSI(order.m_delivery_date);
+					textData += BIAOQIAN_TEXTGet(date, 12, nHeightNow, 1, 1);
+				}
+				else
+				{
+					if (order.m_is_book == "1")
+					{
+						//预约单
+						string date = "配送时间:【预约单】" + CLewaimaiString::UTF8ToANSI(order.m_delivery_date) + "送达";
+						textData += BIAOQIAN_TEXTGet(date, 12, nHeightNow, 1, 1);
+					}
+					else
+					{
+						//非预约单
+						string date = "配送时间:【即时单】立即送达";
+						textData += BIAOQIAN_TEXTGet(date, 12, nHeightNow, 1, 1);
+					}
+				}
+
+				std::string pay_type = "支付方式:" + CLewaimaiString::UTF8ToANSI(order.m_pay_type);
+				textData += BIAOQIAN_TEXTGet(pay_type, 12, nHeightNow + 30, 1, 1);
+
+				std::string name = "姓名:" + CLewaimaiString::UTF8ToANSI(order.m_customer_name);
+				textData += BIAOQIAN_TEXTGet(name, 12, nHeightNow + 90, 2, 2);
+
+				std::string phone = "电话:" + CLewaimaiString::UTF8ToANSI(order.m_phone);
+				textData += BIAOQIAN_TEXTGet(phone, 12, nHeightNow + 150, 2, 2);
+
+				//地址有可能很长要换行,要处理一下
+				std::string address = "地址:" + CLewaimaiString::UTF8ToANSI(order.m_address);
+
+				//每行最多显示12个汉字,这里要计算一下换行(要先转成ANSI格式)
+				std::string handle_address_name = address;
+				std::vector<std::string> addressVector = HandleBiaoqianFoodname(handle_address_name, biaoqian_width, true);
+
+				int nRow = 0;
+
+				for (std::vector<std::string>::iterator it = addressVector.begin(); it != addressVector.end(); it++)
+				{
+					textData += BIAOQIAN_TEXTGet(*it, 12, nHeightNow + 210 + 60 * nRow, 2, 2);
+
+					nRow++;
+				}
+			}
 
 			WriteData(textData);
 
@@ -3021,7 +3078,7 @@ std::string CPosPrinterData::HandleFoodTotalPrice(std::string oldprice, int guig
     }
 }
 
-std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string oldname, int nBiaoqianWidth)
+std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string oldname, int nBiaoqianWidth, bool is_name_big)
 {
     std::vector<std::string> newnameArray;
     int nHanzi, nZimu;
@@ -3030,6 +3087,11 @@ std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string old
 	//文字内容的实际宽度,1个汉字算2个宽度,1个英文或者数字、标点算1个(40mm宽度最多打印12个汉字 )
     int nWidth = nHanzi * 2 + nZimu;
 
+	if (is_name_big == true)
+	{
+		nWidth = nWidth * 2;
+	}
+
     //40 *30mmm的标签,宽度最大24
     int maxWidth;
 	if (nBiaoqianWidth == 40)
@@ -3044,6 +3106,10 @@ std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string old
 	{
 		maxWidth = 18;
 	}
+	else if (nBiaoqianWidth == 60)
+	{
+		maxWidth = 36;
+	}
 	else
 	{
 		maxWidth = 24;
@@ -3052,7 +3118,17 @@ std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string old
     if(nWidth <= maxWidth)
     {
         //对于nWidth补空格
-        for(int i = 0; i < maxWidth - nWidth; i++)
+		int nSpaceNum = 0;
+		if (is_name_big == true)
+		{
+			nSpaceNum = (maxWidth - nWidth) / 2;
+		}
+		else
+		{
+			nSpaceNum = maxWidth - nWidth;
+		}
+
+        for(int i = 0; i < nSpaceNum; i++)
         {
             oldname += " ";
         }
@@ -3087,27 +3163,54 @@ std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string old
             nTotal++;
         }
 
-        if(nTmp == maxWidth)
-        {
-            //这里开始要换行了
-            string newnameItem;
-            newnameItem.assign(oldname, nTotal - nTmp, nTmp);
-            newnameArray.push_back(newnameItem);
-            nTmp = 0;
-        }
-        else if(nTmp == maxWidth - 1)
-        {
-            //如果是第14个了,判断下一个是不是中文,如果是的话也要换行
-            if(!(*(s + 1) >= 0 && *(s + 1) <= 127))
-            {
-                //下一个是中文,也要换行了,补齐一个空格
-                string newnameItem;
-                newnameItem.assign(oldname, nTotal - nTmp, nTmp);
-                newnameItem += " ";
-                newnameArray.push_back(newnameItem);
-                nTmp = 0;
-            }
-        }
+		if (is_name_big == true)
+		{
+			if (nTmp * 2 == maxWidth)
+			{
+				//这里开始要换行了
+				string newnameItem;
+				newnameItem.assign(oldname, nTotal - nTmp, nTmp);
+				newnameArray.push_back(newnameItem);
+				nTmp = 0;
+			}
+			else if (nTmp * 2 == maxWidth - 2)
+			{
+				//判断下一个是不是中文,如果是的话也要换行
+				if (!(*(s + 1) >= 0 && *(s + 1) <= 127))
+				{
+					//下一个是中文,也要换行了,补齐一个空格
+					string newnameItem;
+					newnameItem.assign(oldname, nTotal - nTmp, nTmp);
+					newnameItem += " ";
+					newnameArray.push_back(newnameItem);
+					nTmp = 0;
+				}
+			}
+		}
+		else
+		{
+			if (nTmp == maxWidth)
+			{
+				//这里开始要换行了
+				string newnameItem;
+				newnameItem.assign(oldname, nTotal - nTmp, nTmp);
+				newnameArray.push_back(newnameItem);
+				nTmp = 0;
+			}
+			else if (nTmp == maxWidth - 1)
+			{
+				//判断下一个是不是中文,如果是的话也要换行
+				if (!(*(s + 1) >= 0 && *(s + 1) <= 127))
+				{
+					//下一个是中文,也要换行了,补齐一个空格
+					string newnameItem;
+					newnameItem.assign(oldname, nTotal - nTmp, nTmp);
+					newnameItem += " ";
+					newnameArray.push_back(newnameItem);
+					nTmp = 0;
+				}
+			}
+		}
     }
 
     if(nTmp > 0)
@@ -3116,7 +3219,17 @@ std::vector<std::string> CPosPrinterData::HandleBiaoqianFoodname(std::string old
         string newnameItem;
         newnameItem.assign(oldname, nTotal - nTmp, nTmp);
 
-        for(int i = 0; i < maxWidth - nTmp; i++)
+		int nSpaceNum = 0;
+		if (is_name_big == true)
+		{
+			nSpaceNum = (maxWidth - nTmp) / 2;
+		}
+		else
+		{
+			nSpaceNum = maxWidth - nTmp;
+		}
+
+        for(int i = 0; i < nSpaceNum; i++)
         {
             newnameItem += " ";
         }

+ 1 - 1
zhipuzi_pos_windows/print/CPosPrinterData.h

@@ -78,7 +78,7 @@ private:
 	std::string HandleFoodTotalPrice(std::string oldprice, int guige = 1);
 
 	//对标签打印的名字进行换行处理
-	std::vector<std::string> HandleBiaoqianFoodname(std::string oldname, int nBiaoqianWdith);
+	std::vector<std::string> HandleBiaoqianFoodname(std::string oldname, int nBiaoqianWdith, bool is_name_big = false);
 
 private:
 	//把所有打印命令汇总到一起,然后一次性发送给打印机,这个变量用来存储一个订单的所有命令