|
@@ -1,6 +1,9 @@
|
|
|
package com.sy.coinage.util.printer;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.sy.coinage.core.util.SpringUtils;
|
|
|
+import com.sy.coinage.sys.model.Dict;
|
|
|
+import com.sy.coinage.sys.service.IDictService;
|
|
|
import com.sy.coinage.util.Common;
|
|
|
import com.sy.coinage.util.RfidEpcTool;
|
|
|
import com.zebra.sdk.comm.Connection;
|
|
@@ -10,6 +13,7 @@ import com.zebra.sdk.printer.PrinterStatus;
|
|
|
import com.zebra.sdk.printer.ZebraPrinter;
|
|
|
import com.zebra.sdk.printer.ZebraPrinterFactory;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
@@ -24,6 +28,7 @@ public class ZplImgConvertPrinter {
|
|
|
private static Integer DEFAULT_PORT = 9100; // 默认9100端口
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param rfidInfoDTO
|
|
@@ -161,7 +166,11 @@ public class ZplImgConvertPrinter {
|
|
|
// zplSb.append("^PQ1,0,1,Y"); //打印一张
|
|
|
//打印两张 >> 打印三张
|
|
|
// zplSb.append("^PQ3,0,1,Y");
|
|
|
- zplSb.append("^PQ2,0,1,Y");
|
|
|
+ // zplSb.append("^PQ2,0,1,Y");
|
|
|
+ //根据配置来获取打印数量
|
|
|
+ int amount = getPrintAmoutByDictId(80); // rfid打印标签的dictId
|
|
|
+ zplSb.append("^PQ").append(amount).append(",0,1,Y");
|
|
|
+//
|
|
|
return zplSb.toString();
|
|
|
}
|
|
|
|
|
@@ -244,8 +253,12 @@ public class ZplImgConvertPrinter {
|
|
|
//写入指令
|
|
|
zplSb.append("^RFW,H,,12,E^FD").append(rfidHex).append("^FS");
|
|
|
//打印指令 打印数量1;当每个rfid标签打印2个,每个拷贝是1个
|
|
|
- zplSb.append("^PQ1,0,1,Y");
|
|
|
|
|
|
+// zplSb.append("^PQ1,0,1,Y");
|
|
|
+
|
|
|
+ //根据配置来获取打印数量
|
|
|
+ int amount = getPrintAmoutByDictId(79); // 空白标签的dictId
|
|
|
+ zplSb.append("^PQ").append(amount).append(",0,1,Y");
|
|
|
return zplSb.toString();
|
|
|
}
|
|
|
|
|
@@ -282,5 +295,30 @@ public class ZplImgConvertPrinter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取打印数量 : 根据ID写死配置
|
|
|
+ * ID: 79 ->空白标签
|
|
|
+ * ID: 80 -> rfid实际打印数量
|
|
|
+ * * @param dictId : 字典表里的ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static int getPrintAmoutByDictId(int dictId){
|
|
|
+
|
|
|
+ int result = 1;
|
|
|
+ IDictService dictService = SpringUtils.getBean(IDictService.class);
|
|
|
+
|
|
|
+ Dict dict = dictService.getById(dictId);
|
|
|
+
|
|
|
+ if(dictId == 93){//空白标签
|
|
|
+ if(dict != null) {
|
|
|
+ result = dict.getVal() != null ? Integer.valueOf(dict.getVal()) : 1; //默认值是1
|
|
|
+ }
|
|
|
+ }else if(dictId == 94) {//rfid实体标签
|
|
|
+ if(dict != null) {
|
|
|
+ result = dict.getVal() != null ? Integer.valueOf(dict.getVal()) : 2; //默认值是2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
}
|