店铺小票打印记录需求
This commit is contained in:
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -12,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.PrinterUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -131,6 +133,42 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
||||
entity.setRespCode(respCode);
|
||||
entity.setRespMsg(respMsg);
|
||||
super.save(entity);
|
||||
|
||||
// 云想印
|
||||
if ("yxyPrinter".equals(config.getContentType())) {
|
||||
// 延迟3ms,复查打印状态 (用户可以根据设备信息查询到当前设备的在线情况(注:该接口只能提供参考,设备的离线状态是在设备离线3分钟后才会生效))
|
||||
ThreadUtil.safeSleep(1000*3);
|
||||
String jsonStr = PrinterUtils.checkPrintStatus(config.getAddress(), entity.getTaskId());
|
||||
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(jsonStr);
|
||||
int code = resp.getInt("code");
|
||||
if(code == 0){
|
||||
cn.hutool.json.JSONObject data = resp.getJSONObject("data");
|
||||
boolean status = data.containsKey("status");
|
||||
if(!status){
|
||||
return;
|
||||
}
|
||||
boolean success = data.getBool("status",false);
|
||||
if(entity.getFailFlag()==0 && success){
|
||||
entity.setFailFlag(0);
|
||||
entity.setRespMsg("打印成功");
|
||||
entity.setPrintTime(entity.getCreateTime());
|
||||
}else if(entity.getFailFlag()==1 && success) {
|
||||
entity.setFailFlag(0);
|
||||
entity.setPrintTime(new Date());
|
||||
entity.setRespMsg("打印成功");
|
||||
// 如果设备在线 and 休眠5秒后查询结果是未打印,即视为设备已离线,云端3分钟后才会同步到离线信息
|
||||
}else if(entity.getFailFlag()==0 && !success){
|
||||
entity.setFailFlag(1);
|
||||
entity.setPrintTime(null);
|
||||
entity.setRespMsg("0_离线(设备上线后自动补打)");
|
||||
}else {
|
||||
entity.setFailFlag(1);
|
||||
entity.setPrintTime(null);
|
||||
entity.setRespMsg(StrUtil.concat(true,"打印失败,", "_", entity.getRespMsg()));
|
||||
}
|
||||
super.updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ShopPrintLogDTO convertToDTO(TbPrintMachineLog entity) {
|
||||
|
||||
Reference in New Issue
Block a user