|
|
@@ -2,6 +2,7 @@ package com.sqx.modules.utils.fieYun;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.activity.service.ActivityService;
|
|
|
import com.sqx.modules.activity.vo.ActivityOrderVO;
|
|
|
import com.sqx.modules.activity.vo.ActivityVO;
|
|
|
@@ -15,7 +16,9 @@ import com.sqx.modules.goods.entity.GoodsShop;
|
|
|
import com.sqx.modules.goods.service.GoodsShopService;
|
|
|
import com.sqx.modules.order.entity.OrderGoods;
|
|
|
import com.sqx.modules.order.entity.TbOrder;
|
|
|
+import com.sqx.modules.order.service.AppOrderService;
|
|
|
import com.sqx.modules.printInfo.entity.*;
|
|
|
+import com.sqx.modules.printInfo.service.PrintInfoDetailService;
|
|
|
import com.sqx.modules.printInfo.service.PrintInfoService;
|
|
|
import com.sqx.modules.printInfo.service.PrintInfoShopService;
|
|
|
import com.sqx.modules.utils.fieYun.model.OrderForm;
|
|
|
@@ -60,6 +63,20 @@ public class FeiYunUtils {
|
|
|
|
|
|
private static PrintInfoService printInfoService;
|
|
|
|
|
|
+ private static AppOrderService appOrderService;
|
|
|
+
|
|
|
+ private static PrintInfoDetailService printInfoDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setPrintInfoDetailService(PrintInfoDetailService printInfoDetailService) {
|
|
|
+ FeiYunUtils.printInfoDetailService = printInfoDetailService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setAppOrderService(AppOrderService appOrderService) {
|
|
|
+ FeiYunUtils.appOrderService = appOrderService;
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
public void setActivityService(ActivityService activityService) {
|
|
|
FeiYunUtils.activityService = activityService;
|
|
|
@@ -948,7 +965,14 @@ public class FeiYunUtils {
|
|
|
}
|
|
|
//endregion
|
|
|
if (goods_name_start != null) {
|
|
|
- stringBuilder.append(goods_name_start).append("名称").append(goods_name_end).append(" ");
|
|
|
+ //长度十个字
|
|
|
+ stringBuilder.append(goods_name_start).append("名称").append(goods_name_end);
|
|
|
+ if (sum_money_start != null) {
|
|
|
+ stringBuilder.append(" ");
|
|
|
+ } else {
|
|
|
+ stringBuilder.append(" ");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (goods_price_start != null) {
|
|
|
@@ -980,7 +1004,19 @@ public class FeiYunUtils {
|
|
|
name = orderGoods.getGoodsName();
|
|
|
}
|
|
|
stringBuilder.append(goods_name_start).append(name).append(goods_name_end);
|
|
|
- stringBuilder.append(" ");
|
|
|
+
|
|
|
+ StringBuilder space = new StringBuilder();
|
|
|
+ if (sum_money_start != null) {
|
|
|
+ for (int len = (name.length() - 1); len < 7; len++) {
|
|
|
+ space.append(" ");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for (int len = (name.length() - 1); len < 10; len++) {
|
|
|
+ space.append(" ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stringBuilder.append(space.toString());
|
|
|
stringBuilder.append(goods_price_start).append(orderGoods.getGoodsPrice()).append(goods_price_end);
|
|
|
if (orderGoods.getGoodsPrice().doubleValue() < 10) {
|
|
|
stringBuilder.append(" ");
|
|
|
@@ -1493,7 +1529,7 @@ public class FeiYunUtils {
|
|
|
|
|
|
String content = stringBuilder.toString();
|
|
|
|
|
|
- doRequest(sn, content, tbOrder.getStatus(), isAppend);
|
|
|
+ doRequest(sn, content, tbOrder.getStatus(), isAppend, tbOrder.getOrderId());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -1506,7 +1542,7 @@ public class FeiYunUtils {
|
|
|
/**
|
|
|
* 小票机打印订单接口
|
|
|
*
|
|
|
- * @param sn 打印机编号
|
|
|
+ * @param sn 打印机编号
|
|
|
* @return 成功:{"msg":"ok","ret":0,"data":"xxxxxxx_xxxxxxxx_xxxxxxxx","serverExecutedTime":5}
|
|
|
* 失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5}
|
|
|
*/
|
|
|
@@ -1522,7 +1558,7 @@ public class FeiYunUtils {
|
|
|
sb.append("<BR>");
|
|
|
sb.append("<CUT>");
|
|
|
|
|
|
- doRequest(sn, sb.toString(),5,null);
|
|
|
+ doRequest(sn, sb.toString(), 5, null, tbOrder.getOrderId());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -1531,7 +1567,7 @@ public class FeiYunUtils {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private static void doRequest(String sn, String content, Integer status, Integer isAppend) {
|
|
|
+ private static void doRequest(String sn, String content, Integer status, Integer isAppend, Long orderId) {
|
|
|
RequestConfig requestConfig = RequestConfig.custom()
|
|
|
.setSocketTimeout(30000)//读取超时
|
|
|
.setConnectTimeout(30000)//连接超时
|
|
|
@@ -1565,6 +1601,22 @@ public class FeiYunUtils {
|
|
|
result = EntityUtils.toString(httpentity);
|
|
|
}
|
|
|
|
|
|
+ //region 添加订单打印状态
|
|
|
+ int updateData = appOrderService.updateOrderPrint(orderId);
|
|
|
+ if (updateData <= 0) {
|
|
|
+ log.error("更新订单打印状态失败,订单ID为:{}", orderId);
|
|
|
+ }
|
|
|
+
|
|
|
+ PrintInfoDetail pid = new PrintInfoDetail();
|
|
|
+ pid.setOrderStatus(eOrderStatus.stringOf(status));
|
|
|
+ pid.setOrderId(orderId);
|
|
|
+ pid.setIsAppend(isAppend == null ? "否" : (isAppend.intValue() == 1 ? "是" : "否"));
|
|
|
+ Result detailResult = printInfoDetailService.insertPrintInfoDetail(pid);
|
|
|
+ if ((int) detailResult.get("code") != 0) {
|
|
|
+ log.error("记录打印数据失败,订单ID为:" + orderId + ";是否补打:" + isAppend);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
log.info("打印请求成功,打印机sn:{},打印内容:{},响应结果:{}", sn, content, result);
|
|
|
} else {
|
|
|
log.error("打印请求失败,响应码为:{}", stateCode);
|
|
|
@@ -2067,36 +2119,36 @@ public class FeiYunUtils {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 飞鹅技术支持-2020-03-25
|
|
|
- * #########################################################################################################
|
|
|
- * 一,纯数字条件下:
|
|
|
- * 58mm打印机最大支持28位纯数字,80mm打印机最大支持46位纯数字,超出无效
|
|
|
- *
|
|
|
- * 26-28位数字条形码,在数字中不可以出现2个及以上连续的0存在
|
|
|
- * 23-25位数字条形码,在数字中不可以出现3个及以上连续的0存在
|
|
|
- * 21-22位数字条形码,在数字中不可以出现4个及以上连续的0存在
|
|
|
- * 19-20位数字条形码,在数字中不可以出现6个及以上连续的0存在
|
|
|
- * 17-18位数字条形码,在数字中不可以出现8个及以上连续的0存在
|
|
|
- * 15-16位数字条形码,在数字中不可以出现10个及以上连续的0存在
|
|
|
- * 少于或等于14位数字的条形码,0的数量没有影响
|
|
|
- * #########################################################################################################
|
|
|
- * 二,非纯数字混合条件下:
|
|
|
- * 58mm打印机最大支持14位字符,80mm打印机最大支持23位字符,超出无效
|
|
|
- *
|
|
|
- * 支持数字,大小写字母,特殊字符例如: !@#$%^&*()-=+_
|
|
|
- * #########################################################################################################
|
|
|
- * 把条形码函数返回值,调用飞鹅云打印接口发给打印机打印
|
|
|
+ * 飞鹅技术支持-2020-03-25
|
|
|
+ * #########################################################################################################
|
|
|
+ * 一,纯数字条件下:
|
|
|
+ * 58mm打印机最大支持28位纯数字,80mm打印机最大支持46位纯数字,超出无效
|
|
|
+ * <p>
|
|
|
+ * 26-28位数字条形码,在数字中不可以出现2个及以上连续的0存在
|
|
|
+ * 23-25位数字条形码,在数字中不可以出现3个及以上连续的0存在
|
|
|
+ * 21-22位数字条形码,在数字中不可以出现4个及以上连续的0存在
|
|
|
+ * 19-20位数字条形码,在数字中不可以出现6个及以上连续的0存在
|
|
|
+ * 17-18位数字条形码,在数字中不可以出现8个及以上连续的0存在
|
|
|
+ * 15-16位数字条形码,在数字中不可以出现10个及以上连续的0存在
|
|
|
+ * 少于或等于14位数字的条形码,0的数量没有影响
|
|
|
+ * #########################################################################################################
|
|
|
+ * 二,非纯数字混合条件下:
|
|
|
+ * 58mm打印机最大支持14位字符,80mm打印机最大支持23位字符,超出无效
|
|
|
+ * <p>
|
|
|
+ * 支持数字,大小写字母,特殊字符例如: !@#$%^&*()-=+_
|
|
|
+ * #########################################################################################################
|
|
|
+ * 把条形码函数返回值,调用飞鹅云打印接口发给打印机打印
|
|
|
*/
|
|
|
private static String getDigitBarCode(String input) {
|
|
|
String chr = "";
|
|
|
String laststr = "";
|
|
|
- byte[] codeB = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }; // 匹配字符集B
|
|
|
- byte[] codeC = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
|
|
+ byte[] codeB = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39}; // 匹配字符集B
|
|
|
+ byte[] codeC = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
|
|
|
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
|
|
|
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42,
|
|
|
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53,
|
|
|
- 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63 }; // 匹配字符集C
|
|
|
+ 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63}; // 匹配字符集C
|
|
|
int length = input.length();
|
|
|
byte[] b = new byte[100];
|
|
|
b[0] = 0x1b;
|
|
|
@@ -2117,7 +2169,7 @@ public class FeiYunUtils {
|
|
|
b[15] = (byte) (length + 2); // 得出条形码长度
|
|
|
b[16] = 0x7b;
|
|
|
b[17] = 0x42;
|
|
|
- boolean result=input.matches("[0-9]+");//判断是否为纯数字
|
|
|
+ boolean result = input.matches("[0-9]+");//判断是否为纯数字
|
|
|
if (length > 14 && result == true) {
|
|
|
b[17] = 0x43;
|
|
|
int j = 0;
|
|
|
@@ -2131,18 +2183,18 @@ public class FeiYunUtils {
|
|
|
j = j + 2;
|
|
|
if (iindex == 0) {
|
|
|
chr = "";
|
|
|
- if(b[key + i - 1] == '0' && b[key + i - 2] == '0') {
|
|
|
+ if (b[key + i - 1] == '0' && b[key + i - 2] == '0') {
|
|
|
b[key + i] = codeB[0];
|
|
|
- b[key + i+1] = codeB[0];
|
|
|
- key+=1;
|
|
|
- }else {
|
|
|
- if(b[key + i-1] == 'C' && b[key + i-2] == '{' ){//判断前面的为字符集C时转换字符集B
|
|
|
+ b[key + i + 1] = codeB[0];
|
|
|
+ key += 1;
|
|
|
+ } else {
|
|
|
+ if (b[key + i - 1] == 'C' && b[key + i - 2] == '{') {//判断前面的为字符集C时转换字符集B
|
|
|
b[key + i - 2] = 0x7b;
|
|
|
b[key + i - 1] = 0x42;
|
|
|
b[key + i] = codeB[0];
|
|
|
b[key + i + 1] = codeB[0];
|
|
|
key += 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
b[key + i] = 0x7b;
|
|
|
b[key + i + 1] = 0x42;
|
|
|
b[key + i + 2] = codeB[0];
|
|
|
@@ -2157,19 +2209,19 @@ public class FeiYunUtils {
|
|
|
b[key + i + 1] = 0x43;
|
|
|
b[key + i + 2] = codeC[iindex];
|
|
|
key += 2;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
chr = "";
|
|
|
b[key + i] = codeC[iindex];
|
|
|
- if(iindex == 48) chr = "chr";//判断chr(48)等于0的情况
|
|
|
+ if (iindex == 48) chr = "chr";//判断chr(48)等于0的情况
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
int lastKey = getLastIndex(b);
|
|
|
if (length % 2 > 0) {
|
|
|
int lastnum = Integer.valueOf(input.substring(input.length() - 1)); // 取得字符串的最后一个数字
|
|
|
- if(b[lastKey] == '0' && b[lastKey-1] == '0'){//判断前面的为字符集B,此时不需要转换字符集
|
|
|
+ if (b[lastKey] == '0' && b[lastKey - 1] == '0') {//判断前面的为字符集B,此时不需要转换字符集
|
|
|
b[lastKey + 1] = codeB[lastnum];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
b[lastKey + 1] = 0x7b;
|
|
|
b[lastKey + 2] = 0x42;
|
|
|
b[lastKey + 3] = codeB[lastnum];
|
|
|
@@ -2183,14 +2235,14 @@ public class FeiYunUtils {
|
|
|
str = new String(b);
|
|
|
laststr = str;
|
|
|
|
|
|
- String Last_two = input.substring(input.length()-2,input.length());
|
|
|
+ String Last_two = input.substring(input.length() - 2, input.length());
|
|
|
int Last_two_int = 0;
|
|
|
Last_two_int = Integer.valueOf(Last_two);
|
|
|
- if(Last_two_int > 32) {
|
|
|
+ if (Last_two_int > 32) {
|
|
|
laststr = laststr.trim().substring(1);
|
|
|
}
|
|
|
} else { // 1-14位数字的条形码进来这个区间
|
|
|
- b[15] = (byte) (length+2);
|
|
|
+ b[15] = (byte) (length + 2);
|
|
|
laststr = new String(b);
|
|
|
laststr = laststr.substring(0, 18);
|
|
|
laststr += input;
|