Bläddra i källkod

update: 调整打印格式: 去除工艺; 经销商两行占位

huwanxiao 1 år sedan
förälder
incheckning
20604cc4d9
1 ändrade filer med 44 tillägg och 24 borttagningar
  1. 44 24
      app/src/main/java/com/naz/sdkdemo/MainActivity.java

+ 44 - 24
app/src/main/java/com/naz/sdkdemo/MainActivity.java

@@ -1057,10 +1057,9 @@ public class MainActivity extends BaseActivity {
                 currentHeight = currentHeight-mTextSpace*mPot;
                 printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[1]);
                 currentHeight = currentHeight-mFontHeight;
-            }
-            if (!TextUtils.isEmpty(productName[2])){
+            }else{
                 currentHeight = currentHeight-mTextSpace*mPot;
-                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[2]);
+                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, " ");
                 currentHeight = currentHeight-mFontHeight;
             }
             currentHeight = currentHeight-mSpace*mPot;
@@ -1071,18 +1070,29 @@ public class MainActivity extends BaseActivity {
             if (module.decor_two_code_show !=null){
                 printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.decor_code_show)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.decor_two_code_show);
             }
+//            // 工艺部分
+//            currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+//            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "工  艺:")       // 工艺 -> module.craft_type_code_show
+//                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.craft_type_code_show);
+//            // 测试用
+//            module.box_order_product.process_title_two = "第二工艺  第二工艺";
+//            if (module.craft_type_two_code_show!=null){
+//                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.craft_type_code_show)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.craft_type_two_code_show);
+//            }
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "工  艺:")       // 工艺 -> module.craft_type_code_show
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.craft_type_code_show);
-            // 测试用
-            //module.box_order_product.process_title_two = "第二工艺  第二工艺";
-            if (module.craft_type_two_code_show!=null){
-                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.craft_type_code_show)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.craft_type_two_code_show);
+            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:");  // 经销商: ->  module.exe_sale_order_b.customer_name
+            String[] customerName = getStrs(module.exe_sale_order_b.customer_name , mPaperHeight*mPot-5*mFontWidth);
+            if (!TextUtils.isEmpty(customerName[0])){
+               printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, customerName[0]);
+            }
+            if (!TextUtils.isEmpty(customerName[1])){
+               currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+               printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, customerName[1]);
+            }else{
+               currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+               printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, "");
             }
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:")  // 经销商: ->  module.exe_sale_order_b.customer_name
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.exe_sale_order_b.customer_name);
-            currentHeight = currentHeight-mFontHeight-mSpace*mPot;
             currentHeight = currentHeight-mFontHeight-mSpace*mPot/8;
             printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "包装数量:")    // 包装数量 -> module.box_num
                     .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_num)
@@ -1164,10 +1174,9 @@ public class MainActivity extends BaseActivity {
                 currentHeight = currentHeight-mTextSpace*mPot;
                 printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[1]);
                 currentHeight = currentHeight-mFontHeight;
-            }
-            if (!TextUtils.isEmpty(productName[2])){
+            }else{
                 currentHeight = currentHeight-mTextSpace*mPot;
-                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[2]);
+                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, " ");
                 currentHeight = currentHeight-mFontHeight;
             }
             currentHeight = currentHeight-mSpace*mPot;
@@ -1178,17 +1187,28 @@ public class MainActivity extends BaseActivity {
             if (module.box_order_product.color_two !=null){
                 printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.box_order_product.color)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.color_two);
             }
-            currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "工  艺:")       // 工艺 -> module.craft_type_code_show
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.process_title);
-            // 测试用
+//            // 工艺部分
+//            currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+//            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "工  艺:")       // 工艺 -> module.craft_type_code_show
+//                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.process_title);
+//            // 测试用
 //            module.box_order_product.process_title_two = "第二工艺  第二工艺";
-            if (module.box_order_product.process_title_two!=null){
-                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.box_order_product.process_title)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.process_title_two);
-            }
+//            if (module.box_order_product.process_title_two!=null){
+//                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth)+getStrLength2(module.box_order_product.process_title)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.process_title_two);
+//            }
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:")  // 经销商: ->  module.exe_sale_order_b.customer_name
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.customer_name);
+            printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:");  // 经销商: ->  module.exe_sale_order_b.customer_name
+            String[] customerName = getStrs(module.box_order_product.customer_name, mPaperHeight*mPot - 12 * mFontWidth);
+            if (!TextUtils.isEmpty(customerName[0])){
+                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, customerName[0]);
+            }
+            if (!TextUtils.isEmpty(customerName[1])){
+                currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, customerName[1]);
+            } else {
+                currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+                printer.text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, " ");
+            }
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
             currentHeight = currentHeight - mFontHeight-mSpace*mPot/8;
             printer.text(currentHeight - mFontHeightDistanceHalf, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "包装数量:")    // 包装数量 -> module.box_num