|
@@ -1334,6 +1334,8 @@ public class FeiYunUtils {
|
|
|
//拼凑订单内容时可参考如下格式
|
|
//拼凑订单内容时可参考如下格式
|
|
|
//根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
|
|
//根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
|
|
|
|
|
|
|
|
|
|
+ log.info("utils方法打印开始");
|
|
|
|
|
+
|
|
|
//region 以前的代码
|
|
//region 以前的代码
|
|
|
String content = "<CB>测试打印</CB><BR>";
|
|
String content = "<CB>测试打印</CB><BR>";
|
|
|
content += "名称 单价 数量 金额<BR>";
|
|
content += "名称 单价 数量 金额<BR>";
|
|
@@ -1354,9 +1356,9 @@ public class FeiYunUtils {
|
|
|
content += "订餐时间:2016-08-08 08:08:08<BR>";
|
|
content += "订餐时间:2016-08-08 08:08:08<BR>";
|
|
|
content += "<QR>http://www.dzist.com</QR>";
|
|
content += "<QR>http://www.dzist.com</QR>";
|
|
|
//endregion
|
|
//endregion
|
|
|
-
|
|
|
|
|
|
|
+ log.info("utils方法打印开始1");
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
-
|
|
|
|
|
|
|
+ log.info("utils方法打印开始2");
|
|
|
//region 以前的代码
|
|
//region 以前的代码
|
|
|
/*stringBuilder.append("<BR>").append("<BR>").append("<BR>");
|
|
/*stringBuilder.append("<BR>").append("<BR>").append("<BR>");
|
|
|
stringBuilder.append("<CB>").append(tbOrder.getShopName()).append("</CB><BR>");
|
|
stringBuilder.append("<CB>").append(tbOrder.getShopName()).append("</CB><BR>");
|
|
@@ -1422,43 +1424,64 @@ public class FeiYunUtils {
|
|
|
stringBuilder.append("订餐时间:").append(tbOrder.getPayTime()).append("<BR>");*/
|
|
stringBuilder.append("订餐时间:").append(tbOrder.getPayTime()).append("<BR>");*/
|
|
|
//endregion
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
+ log.info("utils方法打印开始3");
|
|
|
//通过POST请求,发送打印信息到服务器
|
|
//通过POST请求,发送打印信息到服务器
|
|
|
RequestConfig requestConfig = RequestConfig.custom()
|
|
RequestConfig requestConfig = RequestConfig.custom()
|
|
|
.setSocketTimeout(30000)//读取超时
|
|
.setSocketTimeout(30000)//读取超时
|
|
|
.setConnectTimeout(30000)//连接超时
|
|
.setConnectTimeout(30000)//连接超时
|
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
|
|
+ log.info("utils方法打印开始4");
|
|
|
CloseableHttpClient httpClient = HttpClients.custom()
|
|
CloseableHttpClient httpClient = HttpClients.custom()
|
|
|
.setDefaultRequestConfig(requestConfig)
|
|
.setDefaultRequestConfig(requestConfig)
|
|
|
.build();
|
|
.build();
|
|
|
|
|
+ log.info("utils方法打印开始5");
|
|
|
String URL = commonInfoService.findOne(325).getValue();
|
|
String URL = commonInfoService.findOne(325).getValue();
|
|
|
|
|
+ log.info("utils方法打印开始6");
|
|
|
String USER = commonInfoService.findOne(326).getValue();
|
|
String USER = commonInfoService.findOne(326).getValue();
|
|
|
|
|
+ log.info("utils方法打印开始7");
|
|
|
String UKEY = commonInfoService.findOne(327).getValue();
|
|
String UKEY = commonInfoService.findOne(327).getValue();
|
|
|
|
|
+ log.info("utils方法打印开始8");
|
|
|
HttpPost post = new HttpPost(URL);
|
|
HttpPost post = new HttpPost(URL);
|
|
|
|
|
+ log.info("utils方法打印开始9");
|
|
|
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
|
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
|
|
|
|
+ log.info("utils方法打印开始10");
|
|
|
nvps.add(new BasicNameValuePair("user", USER));
|
|
nvps.add(new BasicNameValuePair("user", USER));
|
|
|
|
|
+ log.info("utils方法打印开始11");
|
|
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
|
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
|
|
|
|
+ log.info("utils方法打印开始12");
|
|
|
nvps.add(new BasicNameValuePair("stime", STIME));
|
|
nvps.add(new BasicNameValuePair("stime", STIME));
|
|
|
nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME)));
|
|
nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME)));
|
|
|
nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改
|
|
nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改
|
|
|
nvps.add(new BasicNameValuePair("sn", sn));
|
|
nvps.add(new BasicNameValuePair("sn", sn));
|
|
|
nvps.add(new BasicNameValuePair("content", content));
|
|
nvps.add(new BasicNameValuePair("content", content));
|
|
|
nvps.add(new BasicNameValuePair("times", "1"));//打印联数
|
|
nvps.add(new BasicNameValuePair("times", "1"));//打印联数
|
|
|
-
|
|
|
|
|
|
|
+ log.info("utils方法打印开始13");
|
|
|
CloseableHttpResponse response = null;
|
|
CloseableHttpResponse response = null;
|
|
|
String result = null;
|
|
String result = null;
|
|
|
|
|
+ log.info("utils方法打印开始14");
|
|
|
try {
|
|
try {
|
|
|
|
|
+ log.info("utils方法打印开始15");
|
|
|
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
|
|
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
|
|
|
|
|
+ log.info("utils方法打印开始16");
|
|
|
response = httpClient.execute(post);
|
|
response = httpClient.execute(post);
|
|
|
|
|
+ log.info("utils方法打印开始17");
|
|
|
int statecode = response.getStatusLine().getStatusCode();
|
|
int statecode = response.getStatusLine().getStatusCode();
|
|
|
|
|
+ log.info("utils方法打印开始18");
|
|
|
if (statecode == 200) {
|
|
if (statecode == 200) {
|
|
|
|
|
+ log.info("utils方法打印开始19");
|
|
|
HttpEntity httpentity = response.getEntity();
|
|
HttpEntity httpentity = response.getEntity();
|
|
|
|
|
+ log.info("utils方法打印开始20");
|
|
|
if (httpentity != null) {
|
|
if (httpentity != null) {
|
|
|
|
|
+ log.info("utils方法打印开始21");
|
|
|
//服务器返回的JSON字符串,建议要当做日志记录起来
|
|
//服务器返回的JSON字符串,建议要当做日志记录起来
|
|
|
result = EntityUtils.toString(httpentity);
|
|
result = EntityUtils.toString(httpentity);
|
|
|
|
|
+ log.info("utils方法打印开始22");
|
|
|
}
|
|
}
|
|
|
|
|
+ log.info("utils方法打印开始23");
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ log.info("utils方法打印开始24"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
} finally {
|
|
|
try {
|
|
try {
|
|
@@ -1466,16 +1489,19 @@ public class FeiYunUtils {
|
|
|
response.close();
|
|
response.close();
|
|
|
}
|
|
}
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
|
|
+ log.info("utils方法打印开始25"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
post.abort();
|
|
post.abort();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ log.info("utils方法打印开始26"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
httpClient.close();
|
|
httpClient.close();
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
|
|
+ log.info("utils方法打印开始27"+e.getMessage());
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|