店铺小票打印记录需求

This commit is contained in:
谭凯凯
2024-10-10 18:28:48 +08:00
committed by Tankaikai
parent ba710c854e
commit ed2f5763ce
4 changed files with 282 additions and 145 deletions

View File

@@ -10,11 +10,13 @@ import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper; import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderInfoMapper; import com.chaozhanggui.system.cashierservice.mybatis.MPOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopInfoMapper; import com.chaozhanggui.system.cashierservice.mybatis.MpShopInfoMapper;
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil; import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -27,6 +29,9 @@ public class FeiPrinter extends PrinterHandler{
private final MPOrderDetailMapper mPOrderDetailMapper; private final MPOrderDetailMapper mPOrderDetailMapper;
private final TbProductSkuMapper tbProductSkuMapper; private final TbProductSkuMapper tbProductSkuMapper;
@Resource
private ShopPrintLogService shopPrintLogService;
public FeiPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper, MPOrderInfoMapper mPOrderInfoMapper, MpShopInfoMapper mpShopInfoMapper, MpShopInfoMapper mpShopInfoMapper1, MPOrderDetailMapper mPOrderDetailMapper) { public FeiPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper, MPOrderInfoMapper mPOrderInfoMapper, MpShopInfoMapper mpShopInfoMapper, MpShopInfoMapper mpShopInfoMapper1, MPOrderDetailMapper mPOrderDetailMapper) {
super("fePrinter", productMapper, tbProductSkuMapper, tbShopUserMapper); super("fePrinter", productMapper, tbProductSkuMapper, tbShopUserMapper);
this.mPOrderInfoMapper = mPOrderInfoMapper; this.mPOrderInfoMapper = mPOrderInfoMapper;
@@ -49,9 +54,9 @@ public class FeiPrinter extends PrinterHandler{
return; return;
} }
String remark = sku.getSpecSnap(); String remark = sku.getSpecSnap();
FeieyunPrintUtil.getPrintData(machine.getAddress(), orderInfo.getMasterId(), String[] resp = FeieyunPrintUtil.getPrintData(machine.getAddress(), orderInfo.getMasterId(),
DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), remark); DateUtils.getTime(new Date(orderInfo.getCreatedAt())), orderDetail.getProductName(), orderDetail.getNum(), remark);
shopPrintLogService.save(machine, "新订单", resp[0], resp[1]);
} }
@Override @Override
@@ -64,7 +69,8 @@ public class FeiPrinter extends PrinterHandler{
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), null, null); "0", detailList, orderInfo.getRemark(), null, null);
String printType = "退款单"; String printType = "退款单";
FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType); String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
shopPrintLogService.save(machine, "退款单", resp[0], resp[1]);
} }
@Override @Override
@@ -77,7 +83,8 @@ public class FeiPrinter extends PrinterHandler{
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()), (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
"0", detailList, orderInfo.getRemark(), null, null); "0", detailList, orderInfo.getRemark(), null, null);
String printType = "结算单"; String printType = "结算单";
FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType); String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
shopPrintLogService.save(machine, "结算单", resp[0], resp[1]);
} }
@Override @Override

View File

@@ -1,20 +1,22 @@
package com.chaozhanggui.system.cashierservice.rabbit.print; package com.chaozhanggui.system.cashierservice.rabbit.print;
import cn.hutool.core.util.ObjectUtil;
import com.chaozhanggui.system.cashierservice.dao.TbProductMapper; import com.chaozhanggui.system.cashierservice.dao.TbProductMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper; import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper; import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO; import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper; import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderInfoMapper; import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopInfoMapper;
import com.chaozhanggui.system.cashierservice.util.DateUtils; import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil; import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -24,6 +26,8 @@ public class LocalLabelPrinter extends PrinterHandler{
private final MPOrderDetailMapper mPOrderDetailMapper; private final MPOrderDetailMapper mPOrderDetailMapper;
private final TbProductSkuMapper tbProductSkuMapper; private final TbProductSkuMapper tbProductSkuMapper;
@Resource
private ShopPrintLogService shopPrintLogService;
public LocalLabelPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper, MPOrderDetailMapper mPOrderDetailMapper) { public LocalLabelPrinter(TbProductMapper productMapper, TbProductSkuMapper tbProductSkuMapper, TbShopUserMapper tbShopUserMapper, MPOrderDetailMapper mPOrderDetailMapper) {
super("local", productMapper, tbProductSkuMapper, tbShopUserMapper); super("local", productMapper, tbProductSkuMapper, tbShopUserMapper);
@@ -44,8 +48,9 @@ public class LocalLabelPrinter extends PrinterHandler{
return; return;
} }
for (int i = 0; i < orderDetail.getNum(); i++) { for (int i = 0; i < orderDetail.getNum(); i++) {
FeieyunPrintUtil.printLabelMsg(machine.getAddress(), orderInfo.getTableName(), orderDetail.getProductName(), String[] resp = FeieyunPrintUtil.printLabelMsg(machine.getAddress(), orderInfo.getTableName(), orderDetail.getProductName(),
1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), sku.getSalePrice().toPlainString(), sku.getSpecSnap()); 1, DateUtils.getTimes(new Date(orderInfo.getCreatedAt())), sku.getSalePrice().toPlainString(), sku.getSpecSnap());
shopPrintLogService.save(machine, "新订单", resp[0], resp[1]);
} }
} }

View File

@@ -13,6 +13,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog; import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrintLogDTO; import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrintLogDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService; import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils; import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@@ -94,6 +95,7 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
int failFlag = 0; int failFlag = 0;
String respCode = "0"; String respCode = "0";
String respMsg = "打印中"; String respMsg = "打印中";
Map<Integer, String> yxxStatusMap = MapUtil.builder(0, "离线(设备上线后自动补打)").put(1, "在线").put(2, "获取失败").put(3, "未激活").put(4, "设备已禁用").build(); Map<Integer, String> yxxStatusMap = MapUtil.builder(0, "离线(设备上线后自动补打)").put(1, "在线").put(2, "获取失败").put(3, "未激活").put(4, "设备已禁用").build();
// 云想印 // 云想印
if ("yxyPrinter".equals(config.getContentType())) { if ("yxyPrinter".equals(config.getContentType())) {
@@ -112,10 +114,24 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
respMsg = status + "_" + yxxStatusMap.get(status); respMsg = status + "_" + yxxStatusMap.get(status);
} }
if(code == 0){
String taskId = resp.getJSONObject("data").getStr("orderId"); String taskId = resp.getJSONObject("data").getStr("orderId");
entity.setTaskId(taskId); entity.setTaskId(taskId);
} else { }
// 飞鹅云打印机暂时没有适配先return不做打印记录 // 飞鹅云打印机暂时没有适配先return不做打印记录
}else if ("fePrinter".equals(config.getContentType())) {
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
int ret = resp.getInt("ret");
if (ret != 0) {
failFlag = 1;
respCode = ret + "";
respMsg = resp.getStr("msg");
}else{
String printOrderId = resp.getStr("data");
entity.setTaskId(printOrderId);
}
} else {
// 其他打印机暂时没有适配先return不做打印记录
return; return;
} }
entity.setBizType(bizType); entity.setBizType(bizType);
@@ -168,6 +184,24 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
} }
super.updateById(entity); super.updateById(entity);
} }
// 飞鹅云打印机
}else if("fePrinter".equals(config.getContentType())){
ThreadUtil.safeSleep(1000*3);
Boolean success = FeieyunPrintUtil.checkPrintStatus(entity.getTaskId());
if(success == null){
entity.setFailFlag(1);
entity.setRespMsg("打印失败,未知错误");
}else if(success) {
entity.setFailFlag(0);
entity.setPrintTime(new Date());
entity.setRespMsg("打印成功");
}else {
String msg = FeieyunPrintUtil.checkOnline(entity.getAddress());
entity.setFailFlag(1);
entity.setPrintTime(null);
entity.setRespMsg(StrUtil.concat(true,"打印失败,", "_", msg));
}
super.updateById(entity);
} }
} }

View File

@@ -1,7 +1,11 @@
package com.chaozhanggui.system.cashierservice.util; package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO; import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
@@ -16,9 +20,7 @@ import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
public class FeieyunPrintUtil { public class FeieyunPrintUtil {
@@ -29,8 +31,7 @@ public class FeieyunPrintUtil {
public static final String SN = "960238952";//*必填*打印机编号必须要在管理后台里添加打印机或调用API接口添加之后才能调用API public static final String SN = "960238952";//*必填*打印机编号必须要在管理后台里添加打印机或调用API接口添加之后才能调用API
public static String[] printLabelMsg(String sn, String masterId, String productName, Integer number, String date, String money, String remark) {
public static String printLabelMsg(String sn,String masterId,String productName,Integer number,String date,String money,String remark){
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("<DIRECTION>1</DIRECTION>"); sb.append("<DIRECTION>1</DIRECTION>");
@@ -75,8 +76,7 @@ public class FeieyunPrintUtil {
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String result = null; String result = null;
try try {
{
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8")); post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
response = httpClient.execute(post); response = httpClient.execute(post);
int statecode = response.getStatusLine().getStatusCode(); int statecode = response.getStatusLine().getStatusCode();
@@ -87,12 +87,9 @@ public class FeieyunPrintUtil {
result = EntityUtils.toString(httpentity); result = EntityUtils.toString(httpentity);
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} } finally {
finally{
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
@@ -111,13 +108,11 @@ public class FeieyunPrintUtil {
e.printStackTrace(); e.printStackTrace();
} }
} }
return result; return new String[]{content, result};
} }
public static String buildPrintContent(String pickupNumber, String date, String productName, Integer number, String remark) {
public static String getPrintData(String sn,String pickupNumber,String date,String productName,Integer number,String remark) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("<CB>" + pickupNumber + "</CB><BR><BR>"); builder.append("<CB>" + pickupNumber + "</CB><BR><BR>");
@@ -134,8 +129,11 @@ public class FeieyunPrintUtil {
builder.append("<BR><BR><BR><BR><BR><BR>"); builder.append("<BR><BR><BR><BR><BR><BR>");
builder.append("<CUT>"); builder.append("<CUT>");
return builder.toString();
}
String content=builder.toString(); public static String[] getPrintData(String sn, String pickupNumber, String date, String productName, Integer number, String remark) {
String content = buildPrintContent(pickupNumber, date, productName, number, remark);
System.out.println("content:".concat(content)); System.out.println("content:".concat(content));
@@ -162,8 +160,7 @@ public class FeieyunPrintUtil {
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String result = null; String result = null;
try try {
{
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8")); post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
response = httpClient.execute(post); response = httpClient.execute(post);
int statecode = response.getStatusLine().getStatusCode(); int statecode = response.getStatusLine().getStatusCode();
@@ -175,12 +172,9 @@ public class FeieyunPrintUtil {
System.out.println("result:".concat(result)); System.out.println("result:".concat(result));
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} } finally {
finally{
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
@@ -199,18 +193,12 @@ public class FeieyunPrintUtil {
e.printStackTrace(); e.printStackTrace();
} }
} }
return result; return new String[]{content, result};
} }
public static String[] getCashPrintData(OrderDetailPO detailPO, String sn, String type, String orderType) {
public static String getCashPrintData(OrderDetailPO detailPO,String sn, String type, String orderType){
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<CB>" + detailPO.getMerchantName() + "</CB><BR><BR>"); sb.append("<CB>" + detailPO.getMerchantName() + "</CB><BR><BR>");
sb.append("<C><BOLD>" + type + "" + detailPO.getMasterId() + "】</BOLD></C><BR><BR>"); sb.append("<C><BOLD>" + type + "" + detailPO.getMasterId() + "】</BOLD></C><BR><BR>");
@@ -265,7 +253,6 @@ public class FeieyunPrintUtil {
} }
sb.append("打印时间:" + DateUtils.getTime(new Date()) + "<BR>"); sb.append("打印时间:" + DateUtils.getTime(new Date()) + "<BR>");
sb.append("<CUT>"); sb.append("<CUT>");
@@ -295,8 +282,7 @@ public class FeieyunPrintUtil {
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String result = null; String result = null;
try try {
{
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8")); post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
response = httpClient.execute(post); response = httpClient.execute(post);
int statecode = response.getStatusLine().getStatusCode(); int statecode = response.getStatusLine().getStatusCode();
@@ -307,12 +293,9 @@ public class FeieyunPrintUtil {
result = EntityUtils.toString(httpentity); result = EntityUtils.toString(httpentity);
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} } finally {
finally{
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
@@ -331,13 +314,11 @@ public class FeieyunPrintUtil {
e.printStackTrace(); e.printStackTrace();
} }
} }
return result; return new String[]{content, result};
} }
public static int getProducrName(String str) { public static int getProducrName(String str) {
int count = 0; int count = 0;
int digitCount = 0; int digitCount = 0;
@@ -358,12 +339,122 @@ public class FeieyunPrintUtil {
return s; return s;
} }
/**
* 检查飞鹅打印机是否在线
* @param sn 设备编号
* @return 在线,工作状态正常。/离线。/未知错误
*/
public static String checkOnline(String sn){
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("user", USER);
paramMap.put("stime", STIME);
paramMap.put("sig", signature(USER, UKEY, STIME));
paramMap.put("apiname", "Open_queryPrinterStatus");
paramMap.put("sn", sn);
String msg;
try {
String resp = HttpUtil.post(URL, paramMap, 1000 * 5);
//成功 开机 {"msg":"ok","ret":0,"data":"在线,工作状态正常。","serverExecutedTime":4}
//成功 离线 {"msg":"ok","ret":0,"data":"离线。","serverExecutedTime":7}
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
msg = json.getStr("data");
}catch (Exception e){
msg = "未知错误";
}
return msg;
}
/**
* 检查飞鹅打印机打印任务是否已打印
* @param printOrderId 打印订单编号
* @return null-未知错误true-已打印false-未打印
*/
public static Boolean checkPrintStatus(String printOrderId){
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("user", USER);
paramMap.put("stime", STIME);
paramMap.put("sig", signature(USER, UKEY, STIME));
paramMap.put("apiname", "Open_queryOrderState");
paramMap.put("orderid", printOrderId);
Boolean ret;
try {
String resp = HttpUtil.post(URL, paramMap, 1000 * 5);
//成功 {"msg":"ok","ret":0,"data":true,"serverExecutedTime":4}
//失败 {"msg":"ok","ret":0,"data":false,"serverExecutedTime":4}
JSONObject json = JSONUtil.parseObj(UnicodeUtil.toString(resp));
ret = json.getBool("data");
}catch (Exception e){
ret = null;
}
return ret;
}
public static void main(String[] args) { public static void main(String[] args) {
//testPrint();
// OrderDetailPO detailPO=new OrderDetailPO("牛叉闪闪",null,null,"DD20240312142156962",null,null,null,null,null,null,null,null); //testPrint2();
// getCashPrintData(detailPO,"922690786","结算单",null); testPrint3();
} }
public static void testPrint(){
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
Map<String, Object> paramMap = new HashMap<>();
// 参考文档https://help.feieyun.com/home/doc/zh;nav=0-2
paramMap.put("user", USER);
paramMap.put("stime", STIME);
paramMap.put("sig", signature("chaozhanggui2022@163.com", "UfWkhXxSkeSSscsU", STIME));
paramMap.put("apiname", "Open_printMsg");
paramMap.put("sn", "922690786");
paramMap.put("content", content);
paramMap.put("times", 1);
//paramMap.put("debug", "1");
String resp = HttpUtil.post(URL, paramMap, 1000 * 5);
//成功 开机和关机都会响应成功,只是打印任务已正确下发,不代表打印成功
//{"msg":"ok","ret":0,"data":"922690786_20241010174146_2050070451","serverExecutedTime":4} data是打印订单id
//失败1 {"msg":"参数错误 : 该帐号未注册.","ret":-2,"data":null,"serverExecutedTime":37}
System.out.println(UnicodeUtil.toString(resp));
}
/**
* 查询打印机状态
*/
public static void testPrint2(){
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
Map<String, Object> paramMap = new HashMap<>();
// 参考文档https://help.feieyun.com/home/doc/zh;nav=0-2
paramMap.put("user", USER);
paramMap.put("stime", STIME);
paramMap.put("sig", signature("chaozhanggui2022@163.com", "UfWkhXxSkeSSscsU", STIME));
paramMap.put("apiname", "Open_queryPrinterStatus");
paramMap.put("sn", "922690786");
//paramMap.put("debug", "1");
String resp = HttpUtil.post(URL, paramMap, 1000 * 5);
//成功 开机 {"msg":"ok","ret":0,"data":"在线,工作状态正常。","serverExecutedTime":4}
//成功 离线 {"msg":"ok","ret":0,"data":"离线。","serverExecutedTime":7}
System.out.println(UnicodeUtil.toString(resp));
}
/**
* 查询打印任务是否打印成功
*/
public static void testPrint3(){
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
String content = buildPrintContent("123456789", "2024-10-10 18:11:11", "澳洲大龙虾", 1, "一只吃爽爽");
Map<String, Object> paramMap = new HashMap<>();
// 参考文档https://help.feieyun.com/home/doc/zh;nav=0-2
paramMap.put("user", USER);
paramMap.put("stime", STIME);
paramMap.put("sig", signature("chaozhanggui2022@163.com", "UfWkhXxSkeSSscsU", STIME));
paramMap.put("apiname", "Open_queryOrderState");
paramMap.put("orderid", "922690786_20241010175946_1576957351x");
//paramMap.put("debug", "1");
String resp = HttpUtil.post(URL, paramMap, 1000 * 5);
//成功 {"msg":"ok","ret":0,"data":true,"serverExecutedTime":4}
//失败 {"msg":"ok","ret":0,"data":false,"serverExecutedTime":4}
System.out.println(UnicodeUtil.toString(resp));
}
} }