|
|
@@ -514,14 +514,6 @@ public class FeiYunUtils {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- //endregion
|
|
|
- //<B></B> :放大一倍
|
|
|
- //<BOLD></BOLD> :字体加粗
|
|
|
- //<C></C> :居中
|
|
|
- //<CB></CB> :居中放大
|
|
|
- // :右对齐
|
|
|
- //PrintModelResult result
|
|
|
- //字体样式只针对内容
|
|
|
|
|
|
List<OrderGoods> orderGoodsList = tbOrder.getOrderGoodsList();
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
@@ -1500,66 +1492,9 @@ public class FeiYunUtils {
|
|
|
}
|
|
|
|
|
|
String content = stringBuilder.toString();
|
|
|
- log.info("打印内容:" + content);
|
|
|
- //通过POST请求,发送打印信息到服务器
|
|
|
- RequestConfig requestConfig = RequestConfig.custom()
|
|
|
- .setSocketTimeout(30000)//读取超时
|
|
|
- .setConnectTimeout(30000)//连接超时
|
|
|
- .build();
|
|
|
|
|
|
- CloseableHttpClient httpClient = HttpClients.custom()
|
|
|
- .setDefaultRequestConfig(requestConfig)
|
|
|
- .build();
|
|
|
- String URL = commonInfoService.findOne(325).getValue();
|
|
|
- String USER = commonInfoService.findOne(326).getValue();
|
|
|
- String UKEY = commonInfoService.findOne(327).getValue();
|
|
|
- HttpPost post = new HttpPost(URL);
|
|
|
- List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
|
|
- nvps.add(new BasicNameValuePair("user", USER));
|
|
|
- String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
|
|
- nvps.add(new BasicNameValuePair("stime", STIME));
|
|
|
- nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME)));
|
|
|
- nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));//固定值,不需要修改
|
|
|
- nvps.add(new BasicNameValuePair("sn", sn));
|
|
|
- nvps.add(new BasicNameValuePair("content", content));
|
|
|
- nvps.add(new BasicNameValuePair("times", "1"));//打印联数
|
|
|
+ doRequest(sn, content);
|
|
|
|
|
|
- CloseableHttpResponse response = null;
|
|
|
- String result = null;
|
|
|
- try {
|
|
|
- post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
|
|
|
- response = httpClient.execute(post);
|
|
|
- int statecode = response.getStatusLine().getStatusCode();
|
|
|
- if (statecode == 200) {
|
|
|
- HttpEntity httpentity = response.getEntity();
|
|
|
- if (httpentity != null) {
|
|
|
- //服务器返回的JSON字符串,建议要当做日志记录起来
|
|
|
- result = EntityUtils.toString(httpentity);
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (response != null) {
|
|
|
- response.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- try {
|
|
|
- post.abort();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- try {
|
|
|
- httpClient.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- log.error("打印返回值:" + result);
|
|
|
- return result;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
log.error("打印异常:" + e.getMessage(), e);
|