|
|
|
@ -5,114 +5,99 @@ import android.content.Context;
|
|
|
|
|
import cpcl.PrinterHelper;
|
|
|
|
|
|
|
|
|
|
public class PrintAsOrder {
|
|
|
|
|
public static int print(String code, String fbaCode, String country, String channel, String count) {
|
|
|
|
|
int reusult = 0;
|
|
|
|
|
System.out.println("print start");
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.printAreaSize("0", "200", "200", "400", "1");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 10;
|
|
|
|
|
}
|
|
|
|
|
// try {
|
|
|
|
|
// PrinterHelper.Align(PrinterHelper.CENTER);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// reusult = 1;
|
|
|
|
|
// }
|
|
|
|
|
private static void setBold() {
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Barcode(PrinterHelper.BARCODE, PrinterHelper.code128, "2", "1", "130", "45", "26", false, "", "", "", code);
|
|
|
|
|
PrinterHelper.SetBold("2");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 2;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.SetBold("3");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 4;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.AutCenter(PrinterHelper.TEXT, "45", "180", 500, 8, code);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void closeBold() {
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.SetBold("0");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int print(String code, String fbaCode, String country, String channel, String count) {
|
|
|
|
|
int re = 0;
|
|
|
|
|
if (fbaCode.isEmpty()) {
|
|
|
|
|
fbaCode = "非FBA订单";
|
|
|
|
|
re = printNoFba(code, count);
|
|
|
|
|
} else {
|
|
|
|
|
fbaCode = "FBA号:" + fbaCode;
|
|
|
|
|
re = printFba(code, fbaCode, country, channel, count);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.AutCenter(PrinterHelper.TEXT, "45", "222", 500, 8, fbaCode);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 5;
|
|
|
|
|
return re;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
// PrinterHelper.Prefeed("14");
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// reusult =3;
|
|
|
|
|
// }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
public static int printNoFba(String code, String count) {
|
|
|
|
|
int reusult = 0;
|
|
|
|
|
System.out.println("print start");
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Line("42", "269", "550", "269", "2");
|
|
|
|
|
PrinterHelper.printAreaSize("0", "200", "200", "400", "1");
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.CENTER);
|
|
|
|
|
PrinterHelper.Barcode(PrinterHelper.BARCODE, PrinterHelper.code128, "2", "1", "130", "0", "26", false, "", "", "", code);
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.LEFT);
|
|
|
|
|
PrinterHelper.SetBold("3");
|
|
|
|
|
PrinterHelper.AutCenter(PrinterHelper.TEXT, "45", "170", 500, 4, code);
|
|
|
|
|
closeBold();
|
|
|
|
|
|
|
|
|
|
PrinterHelper.Line("42", "228", "550", "228", "2");
|
|
|
|
|
setBold();
|
|
|
|
|
PrinterHelper.SetMag("2","2");
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "20", "0", "45", "254", "未建计划");
|
|
|
|
|
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.RIGHT);
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "20", "0", "42", "254", "件数");
|
|
|
|
|
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "20", "0", "42", "300", count);
|
|
|
|
|
PrinterHelper.SetMag("1","1");
|
|
|
|
|
closeBold();
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.LEFT);
|
|
|
|
|
PrinterHelper.Form();
|
|
|
|
|
PrinterHelper.Print();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 6;
|
|
|
|
|
reusult = -1;
|
|
|
|
|
}
|
|
|
|
|
channel = "渠道名称:" + channel;
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "45", "290", channel);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 7;
|
|
|
|
|
System.out.println("print finish");
|
|
|
|
|
return reusult;
|
|
|
|
|
}
|
|
|
|
|
// try {
|
|
|
|
|
// PrinterHelper.Align(PrinterHelper.LEFT);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// reusult = 1;
|
|
|
|
|
// }
|
|
|
|
|
country = "目的国:" + country;
|
|
|
|
|
|
|
|
|
|
public static int printFba(String code, String fbaCode, String country, String channel, String count) {
|
|
|
|
|
int reusult = 0;
|
|
|
|
|
System.out.println("print start");
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.printAreaSize("0", "200", "200", "400", "1");
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.CENTER);
|
|
|
|
|
PrinterHelper.Barcode(PrinterHelper.BARCODE, PrinterHelper.code128, "2", "1", "130", "0", "26", false, "", "", "", code);
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.LEFT);
|
|
|
|
|
PrinterHelper.SetBold("3");
|
|
|
|
|
PrinterHelper.AutCenter(PrinterHelper.TEXT, "45", "150", 500, 4, code);
|
|
|
|
|
closeBold();
|
|
|
|
|
fbaCode = "FBA号:" + fbaCode;
|
|
|
|
|
PrinterHelper.AutCenter(PrinterHelper.TEXT, "45", "222", 500, 8, fbaCode);
|
|
|
|
|
PrinterHelper.Line("42", "269", "550", "269", "2");
|
|
|
|
|
setBold();
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "45", "290", "渠道名称:");
|
|
|
|
|
closeBold();
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "180", "290", channel);
|
|
|
|
|
country = "目的国:" + country;
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "45", "337", country);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 7;
|
|
|
|
|
}
|
|
|
|
|
// try {
|
|
|
|
|
// PrinterHelper.Align(PrinterHelper.RIGHT);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// reusult = 1;
|
|
|
|
|
// }
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.RIGHT);
|
|
|
|
|
setBold();
|
|
|
|
|
count = "件数:" + count;
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "400", "337", count);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 7;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Text(PrinterHelper.TEXT, "8", "0", "40", "337", count);
|
|
|
|
|
closeBold();
|
|
|
|
|
PrinterHelper.Align(PrinterHelper.LEFT);
|
|
|
|
|
PrinterHelper.Form();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 8;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
PrinterHelper.Print();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
reusult = 9;
|
|
|
|
|
reusult = -1;
|
|
|
|
|
}
|
|
|
|
|
System.out.println("print finish");
|
|
|
|
|
return reusult;
|
|
|
|
|