增加 未建计划模版

master
张萌 3 years ago
parent c2d7dfcd10
commit 5ed5250622

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

@ -75,10 +75,17 @@ class _HomeState extends State<Home> {
TextButton( TextButton(
onPressed: () async { onPressed: () async {
await HyPrinter.printAsOrder( await HyPrinter.printAsOrder(
'ASSZ202112120001', '', "欧洲特快", '法国', "2/10"); 'ASSZ202112120001', '', "", '', "2/10");
setState(() {}); setState(() {});
}, },
child: const Text('打印')), child: const Text('打印非FBA面单')),
TextButton(
onPressed: () async {
await HyPrinter.printAsOrder('ASSZ202112120001',
'FBA15RY33MN8U00001', "欧洲特快", '法国', "2/10");
setState(() {});
},
child: const Text('打印FBA面单')),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
await HyPrinter.printBarCode(0, 0, "2", "1", "130", "45", "26", await HyPrinter.printBarCode(0, 0, "2", "1", "130", "45", "26",

Loading…
Cancel
Save