店铺小票打印记录需求

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

@@ -13,6 +13,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrintLogDTO;
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
import com.chaozhanggui.system.cashierservice.util.FeieyunPrintUtil;
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -94,6 +95,7 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
int failFlag = 0;
String respCode = "0";
String respMsg = "打印中";
Map<Integer, String> yxxStatusMap = MapUtil.builder(0, "离线(设备上线后自动补打)").put(1, "在线").put(2, "获取失败").put(3, "未激活").put(4, "设备已禁用").build();
// 云想印
if ("yxyPrinter".equals(config.getContentType())) {
@@ -110,12 +112,26 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
failFlag = 1;
respCode = code + "";
respMsg = status+"_"+yxxStatusMap.get(status);
respMsg = status + "_" + yxxStatusMap.get(status);
}
if(code == 0){
String taskId = resp.getJSONObject("data").getStr("orderId");
entity.setTaskId(taskId);
}
String taskId = resp.getJSONObject("data").getStr("orderId");
entity.setTaskId(taskId);
} else {
// 飞鹅云打印机暂时没有适配先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;
}
entity.setBizType(bizType);
@@ -168,6 +184,24 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
}
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);
}
}