This commit is contained in:
linfso 2024-08-10 00:32:06 +08:00
parent 383a135d0e
commit fe88385e48
4 changed files with 36 additions and 13 deletions

View File

@ -1937,6 +1937,11 @@ public class EmisBaseService {
extData.put("operateEmployeeName",WaybillHelper.removeUnSeeChar(waybill.getOperateEmployeeName()));
order.put("extData",extData.toJSONString());
// 把exData 数据展开到 map
order.putAll(extData.getInnerMap());
order.put("qrCodeText",extData.toJSONString());
order.put("goodsInfo", WaybillHelper.removeUnSeeChar(waybill.getGoodsInfo()));
order.put("remark", WaybillHelper.removeUnSeeChar(waybill.getRemark()));

View File

@ -92,11 +92,11 @@ public class CPCL {
* @return CPCL
*/
public static byte[] text(int font, int fontSize, int x, int y, String data) {
return text(0, font, fontSize, x, y,false, data);
return text(0, font, fontSize, x, y,false,"LEFT", data);
}
public static byte[] text(int font, int fontSize, int x, int y,boolean isBold, String data) {
return text(0, font, fontSize, x, y,isBold, data);
public static byte[] text(int font, int fontSize, int x, int y,boolean isBold,String horzAlign, String data) {
return text(0, font, fontSize, x, y,isBold,horzAlign, data);
}
/**
@ -110,7 +110,7 @@ public class CPCL {
* @param data 打印内容
* @return CPCL
*/
public static byte[] text(int degree, int font, int fontSize, int x, int y,boolean isBold, String data) {
public static byte[] text(int degree, int font, int fontSize, int x, int y,boolean isBold,String horzAlign, String data) {
String command;
switch (degree) {
case 90:
@ -130,7 +130,7 @@ public class CPCL {
if(isBold){
sb.append("SETBOLD 1"+ " "+ LINE);
}
sb.append(horzAlign + LINE);
sb.append(command + " " + font + " " + fontSize + " " + x + " " + y + " " + data + LINE);
// SETBOLD 1
// TEXT 24 0 0 0 This text is in bold

View File

@ -135,8 +135,9 @@ public class CpclBuilder {
return append(CPCL.text(font, fontSize, x, y, data));
}
public CpclBuilder text(int font, int fontSize, int x, int y,boolean isBold, String data) {
return append(CPCL.text(font, fontSize, x, y,isBold, data));
public CpclBuilder text(int font, int fontSize, int x, int y,boolean isBold, String horzAlign,String data) {
return append(CPCL.text(font, fontSize, x, y,isBold, horzAlign,data));
}
/**
@ -151,7 +152,7 @@ public class CpclBuilder {
* @return CpclBuilder
*/
public CpclBuilder text(int degree, int font, int fontSize, int x, int y, String data) {
return append(CPCL.text(degree, font, fontSize, x, y,false, data));
return append(CPCL.text(degree, font, fontSize, x, y,false,"LEFT", data));
}

View File

@ -109,9 +109,6 @@ public class CvtTplToCpcl {
// Map<String, String> valueMap = new HashMap<>();
// valueMap.put("name", "Alice");
// valueMap.put("age", "30");
// System.out.println(resolvedString);
@ -127,6 +124,7 @@ public class CvtTplToCpcl {
// String fontSizeStr=fontStrArr[1];
int fontSize=(int)Float.parseFloat(fontSizeStr.trim());
String textStr=item.getStr("Text","");
String horzAlign=item.getStr("HorzAlign","LEFT").toUpperCase();
boolean isBold=false;
if(fontStrArr.length>=3) {
String styleStr = fontStrArr[2];
@ -139,7 +137,9 @@ public class CvtTplToCpcl {
int x=item.getInt("Left",0);
int y=item.getInt("Top",0);
builder.text(0, fontSize, x*scale, y*scale,isBold,getFormatStr(textStr,paramMap) );
int fontS=getFontSize(fontSize);
builder.text(0, fontS, x*scale, y*scale,isBold,horzAlign,getFormatStr(textStr,paramMap) );
}
@ -150,6 +150,23 @@ public class CvtTplToCpcl {
}
private static int getFontSize(int pt){
if(pt<9){
return 0;
}
else if(pt>=9 && pt<13){
return 1;
}
else if(pt>=13 && pt<20){
return 2;
}
else if(pt>=20){
return 3;
}
return 0;
}
private static String getFormatStr(String tplStr,Map paramMap){
tplStr=tplStr.replaceAll("\\[","{");
@ -174,7 +191,7 @@ public class CvtTplToCpcl {
public static void main(String[] args) {
String tplFile="/Users/alan/Downloads/探路速运-130-0524【主单】(16).frx";
String tplFile="/Users/alan/Downloads/探路速运-130-0806【子单-无logo】 - .frx";
String cmd=genCmdTpl(tplFile);