master
章文轩 2 years ago
parent a916f14567
commit 5736243738

@ -5,19 +5,11 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="2f8e3712-04e2-429a-bcea-c8db1a54008e" name="默认变更列表" comment=""> <list default="true" id="2f8e3712-04e2-429a-bcea-c8db1a54008e" name="默认变更列表" comment="">
<change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dj_printer.iml" beforeDir="false" afterPath="$PROJECT_DIR$/dj_printer.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/example/android/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/dj_printer.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dj_printer.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/lib/dj_printer.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dj_printer.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -50,6 +50,124 @@ public class AsPrint {
} }
} }
public void printAsCodeNew(String code,String barCode, String channel, String country, String num,String sum,
int offset, boolean hasPlan) throws IOException {
if (hasPlan) {
PrintPlanNew(code,barCode, channel, country, num, sum, offset);
} else {
PrintNoPlanNew(code,barCode,num,sum,offset);
}
}
private void PrintPlanNew(String code,String barCode, String channel, String country, String num,String sum,
int offset) throws IOException {
int cx = 0;
int cy = 0;
int cSize = 0;
if(country.length()>5){
cSize = 55;
cx = 55;
cy = 220;
country = country.substring(0,4)+"\n"+country.substring(4);
}else if(country.length()==5){
cSize = 50;
cx = 40;
cy = 250;
}else {
cSize = 60;
cy = 245;
cx = 85-country.length()*15;
}
cpclPrinter.setForm(0, 203, 203, 800, 575, 0, 1);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
cpclPrinter.printBox(0, 10, 570, 800, 3);
cpclPrinter.printLine(0, 160, 570, 160, 3);
cpclPrinter.printLine(0, 400, 570, 400, 3);
cpclPrinter.printLine(0, 560, 570, 560, 3);
cpclPrinter.printAndroidFont(50, 50, Typeface.DEFAULT_BOLD, true, code, 575, 65);
cpclPrinter.printAndroidFont(cx, cy, Typeface.DEFAULT_BOLD, true, country,
575, cSize);
cpclPrinter.printAndroidFont(90, 440, Typeface.DEFAULT, false, channel, 575, 40);
cpclPrinter.printAndroidFont(160, 745, Typeface.DEFAULT, false, barCode, 575, 28);
cpclPrinter.printLine(333, 110, 333, 350, 3);
cpclPrinter.setCPCLBarcode(0, 0, 0);
cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION,
CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO,
150, 0, 580, barCode, 0);
// cpclPrinter.printAndroidFont(700, 440, Typeface.DEFAULT, false, barCode, 575, 20);
// cpclPrinter.setCPCLBarcode(0, 0, 0);
// cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION, CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO, 130, 0, 26, code, 0);
// cpclPrinter.printCPCLText(0, 0, 3, 0, 170, code, 0);
// cpclPrinter.printLine(0, 220, 535, 220, 3);
// cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
// cpclPrinter.printAndroidFont(40, 240, Typeface.DEFAULT_BOLD, true, "渠道名称:", 575, 30);
// cpclPrinter.printAndroidFont(170, 240, Typeface.DEFAULT, channel, 575, 30);
// cpclPrinter.printAndroidFont(40, 300, Typeface.DEFAULT, "目的地:" + country, 575, 30);
// cpclPrinter.printAndroidFont(400 - offset, 300, Typeface.DEFAULT_BOLD, true, "件数:", 575, 30);
// cpclPrinter.printAndroidFont(480 - offset, 300, Typeface.DEFAULT, countStr, 575, 30);
cpclPrinter.printForm();
}
private void PrintNoPlanNew(String code,String barCode, String num,String sum,
int offset) throws IOException {
cpclPrinter.setForm(0, 203, 203, 500, 575, 0, 1);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
// cpclPrinter.setCPCLBarcode(0, 0, 0);
// cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION, CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO, 130, 0, 26, code, 0);
// cpclPrinter.printCPCLText(0, 0, 3, 0, 170, code, 0);
// cpclPrinter.printLine(0, 220, 535, 220, 3);
// cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
// cpclPrinter.printAndroidFont(40, 240, Typeface.DEFAULT_BOLD, true, "未建计划", 575, 50);
// cpclPrinter.printAndroidFont(400, 240, Typeface.DEFAULT_BOLD, true, "件数:", 575, 50);
// cpclPrinter.printAndroidFont(400 - offset, 300, Typeface.DEFAULT, countStr, 575, 30);
cpclPrinter.printForm();
}
private void printNewPlan(String code, String channel, String country, String countStr, int offset, private void printNewPlan(String code, String channel, String country, String countStr, int offset,
Bitmap imgCode, Bitmap imgChannel, Bitmap imgCountry, Bitmap imgCode, Bitmap imgChannel, Bitmap imgCountry,
Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException { Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException {

@ -97,15 +97,31 @@ public class DjPrinterPlugin implements FlutterPlugin, MethodCallHandler {
byte[] bytesCountry = call.argument("bytesCountry"); byte[] bytesCountry = call.argument("bytesCountry");
byte[] bytesBarCode =call.argument("bytesBarCode"); byte[] bytesBarCode = call.argument("bytesBarCode");
byte[] bytesSum = call.argument("bytesSum"); byte[] bytesSum = call.argument("bytesSum");
byte[] bytesNum =call.argument("bytesNum"); byte[] bytesNum = call.argument("bytesNum");
asPrint.printAsCode(code, channel, country, countStr, offset, hasPlan, byteCode, bytesChannel, bytesCountry, bytesBarCode, bytesNum, bytesSum);
asPrint.printAsCode(code, channel, country, countStr, offset, hasPlan,byteCode,bytesChannel,bytesCountry,bytesBarCode,bytesNum,bytesSum); } catch (UnsupportedEncodingException e) {
//asPrint.printAsCode(); e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
result.success(true);
} else if (call.method.equals("newPrint")) {
try {
String code = call.argument("code");
String barCode = call.argument("barCode");
String channel = call.argument("channel");
String country = call.argument("country");
String num = call.argument("num");
String sum = call.argument("sum");
int offset = call.argument("offset");
boolean hasPlan = call.argument("hasPlan");
asPrint.printAsCodeNew(code, barCode, channel, country, num, sum, offset, hasPlan);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();

@ -94,13 +94,15 @@ class _MyAppState extends State<MyApp> {
), ),
TextButton( TextButton(
onPressed: () { onPressed: () {
DjPrinter().printAScodeByImg( DjPrinter().printNewAScode(
code: 'ASSZ2022012500010002', code: 'ASSZ87658907',
channel: '加拿大温哥华海派快线-卡派/UPS派送', barCode: 'ASSZ2010000001111',
country: '加拿大', channel: '加拿大温哥华海派快线-\n卡派/UPS派送',
countStr: '10/20', country: '伊苏尔',
num: '2',
sum:'20',
offset: 0, offset: 0,
hasPlan: false, sum: '20', num: '5'); hasPlan: true, );
}, },
child: const Text('打印')), child: const Text('打印')),

@ -124,6 +124,31 @@ class DjPrinter {
} }
} }
Future<bool?> printNewAScode({required String code,
required String barCode,
required String channel,
required String country,
required String num,
required String sum,
required int offset,
required bool hasPlan}) async {
final res = await _channel.invokeMethod('newPrint', {
'code': code,
'barCode':barCode,
'channel': channel,
'country': country,
'num': num,
'sum': sum,
'offset': offset,
'hasPlan': hasPlan,
});
return res;
}
Future<bool?> printAScode({required String code, Future<bool?> printAScode({required String code,
required String channel, required String channel,
required String country, required String country,

Loading…
Cancel
Save