店铺小票打印记录需求
This commit is contained in:
@@ -2,24 +2,22 @@ package com.chaozhanggui.system.cashierservice;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
//@EntityScan(basePackageClasses = {Shell.class})
|
||||
//@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
@Slf4j
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
* @author tankaikai
|
||||
* @since 2024-10-09 17:14
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("shop/print/log")
|
||||
public class ShopPrintLogController {
|
||||
|
||||
@Resource
|
||||
private ShopPrintLogService shopPrintLogService;
|
||||
|
||||
@GetMapping("page")
|
||||
public Result page(@RequestParam Map<String, Object> params) {
|
||||
PageInfo<TbPrintMachineLog> page = shopPrintLogService.page(params);
|
||||
return Result.success(CodeEnum.SUCCESS, page);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 16:56
|
||||
*/
|
||||
@@ -27,21 +28,21 @@ public class ShopPrinterController {
|
||||
private ShopPrinterService shopPrinterService;
|
||||
|
||||
@GetMapping("page")
|
||||
public Result page(@RequestParam Map<String, Object> params) {
|
||||
public Result page(@RequestHeader String token, @RequestParam Map<String, Object> params) {
|
||||
PageInfo<ShopPrinterDTO> page = shopPrinterService.page(params);
|
||||
return Result.success(CodeEnum.SUCCESS,page);
|
||||
return Result.success(CodeEnum.SUCCESS, page);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public Result list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopPrinterDTO> list = shopPrinterService.list(params);
|
||||
return Result.success(CodeEnum.SUCCESS,list);
|
||||
return Result.success(CodeEnum.SUCCESS, list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Result get(@PathVariable("id") Integer id) {
|
||||
ShopPrinterDTO dto = shopPrinterService.get(id);
|
||||
return Result.success(CodeEnum.SUCCESS,dto);
|
||||
return Result.success(CodeEnum.SUCCESS, dto);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@@ -57,14 +58,14 @@ public class ShopPrinterController {
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
public Result delete(@PathVariable("id") Integer id){
|
||||
public Result delete(@PathVariable("id") Integer id) {
|
||||
shopPrinterService.delete(id);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("update-status")
|
||||
public Result updateStatus(@RequestBody ShopPrinterDTO dto){
|
||||
shopPrinterService.updateStatus(dto.getId(),dto.getStatus());
|
||||
public Result updateStatus(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.updateStatus(dto.getId(), dto.getStatus());
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 16:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbPrintMachineLogMapper extends BaseMapper<TbPrintMachineLog> {
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -39,6 +41,23 @@ public class TbPrintMachine implements Serializable {
|
||||
private String productId;
|
||||
private String config;
|
||||
|
||||
private String receiptSize;
|
||||
private String classifyPrint;
|
||||
private String tablePrint;
|
||||
private String printQty;
|
||||
private String printMethod;
|
||||
private String printType;
|
||||
private String printReceipt;
|
||||
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private Long currentUserId;
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private String currentUserName;
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private String currentUserNickName;
|
||||
public String getConfig() {
|
||||
return config;
|
||||
}
|
||||
@@ -176,4 +195,84 @@ public class TbPrintMachine implements Serializable {
|
||||
public void setProductId(String productId) {
|
||||
this.productId = productId == null ? null : productId.trim();
|
||||
}
|
||||
|
||||
public String getReceiptSize() {
|
||||
return receiptSize;
|
||||
}
|
||||
|
||||
public void setReceiptSize(String receiptSize) {
|
||||
this.receiptSize = receiptSize;
|
||||
}
|
||||
|
||||
public String getClassifyPrint() {
|
||||
return classifyPrint;
|
||||
}
|
||||
|
||||
public void setClassifyPrint(String classifyPrint) {
|
||||
this.classifyPrint = classifyPrint;
|
||||
}
|
||||
|
||||
public String getTablePrint() {
|
||||
return tablePrint;
|
||||
}
|
||||
|
||||
public void setTablePrint(String tablePrint) {
|
||||
this.tablePrint = tablePrint;
|
||||
}
|
||||
|
||||
public String getPrintQty() {
|
||||
return printQty;
|
||||
}
|
||||
|
||||
public void setPrintQty(String printQty) {
|
||||
this.printQty = printQty;
|
||||
}
|
||||
|
||||
public String getPrintMethod() {
|
||||
return printMethod;
|
||||
}
|
||||
|
||||
public void setPrintMethod(String printMethod) {
|
||||
this.printMethod = printMethod;
|
||||
}
|
||||
|
||||
public String getPrintType() {
|
||||
return printType;
|
||||
}
|
||||
|
||||
public void setPrintType(String printType) {
|
||||
this.printType = printType;
|
||||
}
|
||||
|
||||
public String getPrintReceipt() {
|
||||
return printReceipt;
|
||||
}
|
||||
|
||||
public void setPrintReceipt(String printReceipt) {
|
||||
this.printReceipt = printReceipt;
|
||||
}
|
||||
|
||||
public Long getCurrentUserId() {
|
||||
return currentUserId;
|
||||
}
|
||||
|
||||
public void setCurrentUserId(Long currentUserId) {
|
||||
this.currentUserId = currentUserId;
|
||||
}
|
||||
|
||||
public String getCurrentUserName() {
|
||||
return currentUserName;
|
||||
}
|
||||
|
||||
public void setCurrentUserName(String currentUserName) {
|
||||
this.currentUserName = currentUserName;
|
||||
}
|
||||
|
||||
public String getCurrentUserNickName() {
|
||||
return currentUserNickName;
|
||||
}
|
||||
|
||||
public void setCurrentUserNickName(String currentUserNickName) {
|
||||
this.currentUserNickName = currentUserNickName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 16:19:50
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_print_machine_log")
|
||||
public class TbPrintMachineLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 打印机类型 本地打印机-local USB打印机-USB 云打印机-network
|
||||
*/
|
||||
private String connectionType;
|
||||
/**
|
||||
* 打印机品牌 云想印 = yxyPrinter飞鹅 = fePrinter 本地 = local USB = printer
|
||||
*/
|
||||
private String contentType;
|
||||
/**
|
||||
* 打印小票 标签-label 出品-kitchen 小票-cash
|
||||
*/
|
||||
private String subType;
|
||||
/**
|
||||
* 打印机名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* IP地址/打印机编号
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 端口/打印机秘钥
|
||||
*/
|
||||
private String port;
|
||||
/**
|
||||
* 小票尺寸 58mm 80mm
|
||||
*/
|
||||
private String receiptSize;
|
||||
/**
|
||||
* 分类打印 0-所以 1-部分分类 2-部分商品
|
||||
*/
|
||||
private String classifyPrint;
|
||||
/**
|
||||
* 桌台打印 0-所有 1-部分
|
||||
*/
|
||||
private String tablePrint;
|
||||
/**
|
||||
* 打印数量 c1m1^2=顾客+商家[2张] m1^1=商家[1张] c1^1顾客[1张] c2m1^3=顾客2+商家1[3张]
|
||||
*/
|
||||
private String printQty;
|
||||
/**
|
||||
* 打印方式 1-普通 2-单个菜
|
||||
*/
|
||||
private String printMethod;
|
||||
/**
|
||||
* 打印类型 JSON数组字符串数据 1-确认退款单 2-交班单 3-排队取号,如:[1,2,3]
|
||||
*/
|
||||
private String printType;
|
||||
/**
|
||||
* 打印票据 0-全部打印 1-仅厨房 2-仅前台
|
||||
*/
|
||||
private String printReceipt;
|
||||
/**
|
||||
* 打印内容
|
||||
*/
|
||||
private String printContent;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private String shopId;
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String bizType;
|
||||
/**
|
||||
* 打印人id
|
||||
*/
|
||||
private Long createUserId;
|
||||
/**
|
||||
* 打印人名称
|
||||
*/
|
||||
private String createUserName;
|
||||
/**
|
||||
* 打印任务创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 打印任务id,用于复查打印状态,云想印=orderId
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 实际打印时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date printTime;
|
||||
/**
|
||||
* 失败标识 1-是 0-否
|
||||
*/
|
||||
private Integer failFlag;
|
||||
/**
|
||||
* 响应代码
|
||||
*/
|
||||
private String respCode;
|
||||
/**
|
||||
* 响应消息
|
||||
*/
|
||||
private String respMsg;
|
||||
|
||||
}
|
||||
@@ -2,10 +2,12 @@ package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class CallNumPrintDTO {
|
||||
private Integer callQueueId;
|
||||
private Integer shopId;
|
||||
|
||||
private Long currentUserId;
|
||||
private String currentUserName;
|
||||
private String currentUserNickName;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 16:44
|
||||
*/
|
||||
@Data
|
||||
public class ShopPrintLogDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 打印机类型 本地打印机-local USB打印机-USB 云打印机-network
|
||||
*/
|
||||
private String connectionType;
|
||||
/**
|
||||
* 打印机品牌 云想印 = yxyPrinter飞鹅 = fePrinter 本地 = local USB = printer
|
||||
*/
|
||||
private String contentType;
|
||||
/**
|
||||
* 打印小票 标签-label 出品-kitchen 小票-cash
|
||||
*/
|
||||
private String subType;
|
||||
/**
|
||||
* 打印机名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* IP地址/打印机编号
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 端口/打印机秘钥
|
||||
*/
|
||||
private String port;
|
||||
/**
|
||||
* 小票尺寸 58mm 80mm
|
||||
*/
|
||||
private String receiptSize;
|
||||
/**
|
||||
* 分类打印 0-所以 1-部分分类 2-部分商品
|
||||
*/
|
||||
private String classifyPrint;
|
||||
/**
|
||||
* 桌台打印 0-所有 1-部分
|
||||
*/
|
||||
private String tablePrint;
|
||||
/**
|
||||
* 打印数量 c1m1^2=顾客+商家[2张] m1^1=商家[1张] c1^1顾客[1张] c2m1^3=顾客2+商家1[3张]
|
||||
*/
|
||||
private String printQty;
|
||||
/**
|
||||
* 打印方式 1-普通 2-单个菜
|
||||
*/
|
||||
private String printMethod;
|
||||
/**
|
||||
* 打印类型 JSON数组字符串数据 1-确认退款单 2-交班单 3-排队取号,如:[1,2,3]
|
||||
*/
|
||||
private String printType;
|
||||
/**
|
||||
* 打印票据 0-全部打印 1-仅厨房 2-仅前台
|
||||
*/
|
||||
private String printReceipt;
|
||||
/**
|
||||
* 打印内容
|
||||
*/
|
||||
private String printContent;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private String shopId;
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
private String bizType;
|
||||
/**
|
||||
* 打印人id
|
||||
*/
|
||||
private Long createUserId;
|
||||
/**
|
||||
* 打印人名称
|
||||
*/
|
||||
private String createUserName;
|
||||
/**
|
||||
* 打印任务创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 打印任务id,用于复查打印状态,云想印=orderId
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 实际打印时间
|
||||
*/
|
||||
private Date printTime;
|
||||
/**
|
||||
* 失败标识 1-是 0-否
|
||||
*/
|
||||
private Integer failFlag;
|
||||
/**
|
||||
* 响应代码
|
||||
*/
|
||||
private String respCode;
|
||||
/**
|
||||
* 响应消息
|
||||
*/
|
||||
private String respMsg;
|
||||
|
||||
}
|
||||
@@ -5,17 +5,23 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
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.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import com.chaozhanggui.system.cashierservice.util.Utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -45,6 +51,9 @@ public class PrintConsumer {
|
||||
Integer orderId = jsonObject.getInteger("orderId");
|
||||
JSONArray orderDetailIds = jsonObject.getJSONArray("orderDetailIds");
|
||||
Boolean isReturn = jsonObject.getBoolean("isReturn");
|
||||
Long currentUserId = jsonObject.getLong("currentUserId");
|
||||
String currentUserName = jsonObject.getString("currentUserName");
|
||||
String currentUserNickName = jsonObject.getString("currentUserNickName");
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
|
||||
@@ -59,6 +68,9 @@ public class PrintConsumer {
|
||||
}
|
||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one").forEach(machine -> {
|
||||
log.info("打印机信息: {}", machine);
|
||||
machine.setCurrentUserId(currentUserId);
|
||||
machine.setCurrentUserName(currentUserName);
|
||||
machine.setCurrentUserNickName(currentUserNickName);
|
||||
printerHandler.handleRequest(machine, isReturn, orderInfo, orderDetails, null);
|
||||
});
|
||||
|
||||
@@ -99,6 +111,9 @@ public class PrintConsumer {
|
||||
CallNumPrintDTO printDTO = JSONObject.parseObject(msg, CallNumPrintDTO.class);
|
||||
|
||||
getPrintMachine(printDTO.getShopId(), "cash", "callTicket").forEach(machine -> {
|
||||
machine.setCurrentUserId(printDTO.getCurrentUserId());
|
||||
machine.setCurrentUserName(printDTO.getCurrentUserName());
|
||||
machine.setCurrentUserNickName(printDTO.getCurrentUserNickName());
|
||||
printerHandler.handleRequest(machine, false, null, null, printDTO);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,18 +15,20 @@ import com.chaozhanggui.system.cashierservice.entity.po.CallNumPrintPO;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.TbCallTableMapper;
|
||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class YxyPrinter extends PrinterHandler{
|
||||
public class YxyPrinter extends PrinterHandler {
|
||||
private final TbCallQueueMapper tbCallQueueMapper;
|
||||
private final TbCallTableMapper tbCallTableMapper;
|
||||
@Value("${wx.mini.page.call}")
|
||||
@@ -34,6 +36,9 @@ public class YxyPrinter extends PrinterHandler{
|
||||
|
||||
private final TbShopInfoMapper shopInfoMapper;
|
||||
|
||||
@Resource
|
||||
private ShopPrintLogService shopPrintLogService;
|
||||
|
||||
public YxyPrinter(TbShopInfoMapper shopInfoMapper, TbProductMapper productMapper, TbProductSkuMapper productSkuMapper, TbShopUserMapper shopUserMapper, TbCallQueueMapper tbCallQueueMapper, TbCallTableMapper tbCallTableMapper) {
|
||||
super("yxyPrinter", productMapper, productSkuMapper, shopUserMapper);
|
||||
this.shopInfoMapper = shopInfoMapper;
|
||||
@@ -46,10 +51,10 @@ public class YxyPrinter extends PrinterHandler{
|
||||
if ("miniapp".equals(orderInfo.getOrderType())) {
|
||||
if (OrderUseTypeEnum.TAKEOUT.getValue().equals(orderInfo.getUseType())) {
|
||||
pickupNum = orderInfo.getOutNumber();
|
||||
}else {
|
||||
} else {
|
||||
pickupNum = orderInfo.getTableName();
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
pickupNum = orderInfo.getMasterId();
|
||||
}
|
||||
return pickupNum;
|
||||
@@ -63,7 +68,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
Math.abs(orderDetail.getNum()), orderDetail.getRemark(), orderDetail.getNote());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, "退款单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +79,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
orderDetail.getNum(), orderDetail.getRemark(), orderDetail.getNote());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, "新订单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +96,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, printType, data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +116,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, printType, data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +146,10 @@ public class YxyPrinter extends PrinterHandler{
|
||||
po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum()));
|
||||
String data = PrinterUtils.getCallNumPrintData(po);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
||||
TbPrintMachine machine = new TbPrintMachine();
|
||||
machine.setAddress("ZF544PG03W00005");
|
||||
shopPrintLogService.save(machine, "叫号单", data, resp);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineLog;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ShopPrintLogService {
|
||||
|
||||
PageInfo<TbPrintMachineLog> page(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 保存打印记录
|
||||
* @param config 打印机配置
|
||||
* @param bizType 业务类型
|
||||
* @param printContent 打印内容
|
||||
* @param respJson 打印机响应结果
|
||||
*/
|
||||
void save(TbPrintMachine config, String bizType, String printContent, String respJson);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
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.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPrintMachineLogMapper;
|
||||
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.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录ServiceImpl
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 17:10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper, TbPrintMachineLog> implements ShopPrintLogService {
|
||||
|
||||
private QueryWrapper<TbPrintMachineLog> getWrapper(Map<String, Object> params) {
|
||||
TbPrintMachineLog entity = BeanUtil.toBean(params, TbPrintMachineLog.class);
|
||||
|
||||
QueryWrapper<TbPrintMachineLog> wrapper = new QueryWrapper<>();
|
||||
|
||||
wrapper.lambda().eq(entity.getId() != null, TbPrintMachineLog::getId, entity.getId());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getShopId()), TbPrintMachineLog::getShopId, entity.getShopId());
|
||||
wrapper.lambda().likeRight(StrUtil.isNotEmpty(entity.getName()), TbPrintMachineLog::getName, entity.getName());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getConnectionType()), TbPrintMachineLog::getConnectionType, entity.getConnectionType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getContentType()), TbPrintMachineLog::getContentType, entity.getContentType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getSubType()), TbPrintMachineLog::getSubType, entity.getSubType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getAddress()), TbPrintMachineLog::getAddress, entity.getAddress());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPort()), TbPrintMachineLog::getPort, entity.getPort());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getReceiptSize()), TbPrintMachineLog::getReceiptSize, entity.getReceiptSize());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getClassifyPrint()), TbPrintMachineLog::getClassifyPrint, entity.getClassifyPrint());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getTablePrint()), TbPrintMachineLog::getTablePrint, entity.getTablePrint());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintQty()), TbPrintMachineLog::getPrintQty, entity.getPrintQty());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintMethod()), TbPrintMachineLog::getPrintMethod, entity.getPrintMethod());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintType()), TbPrintMachineLog::getPrintType, entity.getPrintType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintReceipt()), TbPrintMachineLog::getPrintReceipt, entity.getPrintReceipt());
|
||||
wrapper.lambda().eq(entity.getFailFlag() != null, TbPrintMachineLog::getFailFlag, entity.getFailFlag());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getRespCode()), TbPrintMachineLog::getRespCode, entity.getRespCode());
|
||||
wrapper.lambda().like(StrUtil.isNotEmpty(entity.getRespMsg()), TbPrintMachineLog::getRespMsg, entity.getRespMsg());
|
||||
wrapper.lambda().eq(entity.getCreateUserId() != null, TbPrintMachineLog::getCreateUserId, entity.getCreateUserId());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getCreateUserName()), TbPrintMachineLog::getCreateUserName, entity.getCreateUserName());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getTaskId()), TbPrintMachineLog::getTaskId, entity.getTaskId());
|
||||
wrapper.lambda().orderByDesc(TbPrintMachineLog::getId);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<TbPrintMachineLog> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
Integer pageNum = mapProxy.getInt("pageNum",1);
|
||||
Integer pageSize = mapProxy.getInt("pageSize",10);
|
||||
PageInfo<TbPrintMachineLog> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(getWrapper(params)));
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存打印记录
|
||||
*
|
||||
* @param config 打印机配置
|
||||
* @param bizType 业务类型
|
||||
* @param printContent 打印内容
|
||||
* @param respJson 打印机响应结果
|
||||
*/
|
||||
@Override
|
||||
@Async
|
||||
public void save(TbPrintMachine config, String bizType, String printContent, String respJson) {
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
TbPrintMachineLog entity = new TbPrintMachineLog();
|
||||
BeanUtil.copyProperties(config, entity);
|
||||
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())) {
|
||||
cn.hutool.json.JSONObject resp = JSONUtil.parseObj(respJson);
|
||||
int code = resp.getInt("code");
|
||||
cn.hutool.json.JSONObject data = resp.getJSONObject("data").getJSONObject("data");
|
||||
//设备状态,0: 离线, 1: 在线, 2: 获取失败, 3:未激活, 4:设备已禁用
|
||||
int status = data.getInt("status");
|
||||
if (code != 0) {
|
||||
failFlag = 1;
|
||||
respCode = code + "";
|
||||
respMsg = resp.getStr("msg");
|
||||
} else if (status != 1) {
|
||||
failFlag = 1;
|
||||
respCode = code + "";
|
||||
|
||||
respMsg = status+"_"+yxxStatusMap.get(status);
|
||||
}
|
||||
String taskId = resp.getJSONObject("data").getStr("orderId");
|
||||
entity.setTaskId(taskId);
|
||||
} else {
|
||||
// 飞鹅云打印机暂时没有适配,先return不做打印记录
|
||||
return;
|
||||
}
|
||||
entity.setBizType(bizType);
|
||||
entity.setCreateUserId(config.getCurrentUserId());
|
||||
entity.setCreateUserName(config.getCurrentUserName());
|
||||
if (StrUtil.isNotBlank(config.getCurrentUserNickName())) {
|
||||
entity.setCreateUserName(StrUtil.concat(true, config.getCurrentUserNickName(), " | ", config.getCurrentUserName()));
|
||||
}
|
||||
entity.setPrintContent(printContent);
|
||||
entity.setCreateTime(new Date());
|
||||
if(failFlag == 0){
|
||||
entity.setPrintTime(entity.getCreateTime());
|
||||
}
|
||||
entity.setFailFlag(failFlag);
|
||||
entity.setRespCode(respCode);
|
||||
entity.setRespMsg(respMsg);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
private ShopPrintLogDTO convertToDTO(TbPrintMachineLog entity) {
|
||||
ShopPrintLogDTO dto = new ShopPrintLogDTO();
|
||||
BeanUtil.copyProperties(entity, ShopPrintLogDTO.class);
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.CallNumPrintPO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO;
|
||||
@@ -25,7 +25,7 @@ import java.util.*;
|
||||
*/
|
||||
public class PrinterUtils {
|
||||
|
||||
private static final Logger log= LoggerFactory.getLogger(PrinterUtils.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(PrinterUtils.class);
|
||||
//请求地址
|
||||
private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json";
|
||||
//APPID
|
||||
@@ -68,13 +68,14 @@ public class PrinterUtils {
|
||||
|
||||
/**
|
||||
* 菜品票打印
|
||||
* @param type 是否退菜单
|
||||
* @param pickupNumber 取餐号
|
||||
* @param date 时间
|
||||
* @param productName 商品名
|
||||
* @param number 数量
|
||||
* @param remark sku规格名
|
||||
* @param note 备注
|
||||
*
|
||||
* @param type 是否退菜单
|
||||
* @param pickupNumber 取餐号
|
||||
* @param date 时间
|
||||
* @param productName 商品名
|
||||
* @param number 数量
|
||||
* @param remark sku规格名
|
||||
* @param note 备注
|
||||
*/
|
||||
public static String getPrintData(String type, String pickupNumber, String date, String productName, Integer number, String remark, String note) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -107,7 +108,7 @@ public class PrinterUtils {
|
||||
|
||||
public static String getCashPrintData(OrderDetailPO detailPO, String type, String orderType) {
|
||||
|
||||
log.info("getCashPrintData detailPO:{},type:{},orderType:{}",JSONUtil.toJSONString(detailPO),type,orderType);
|
||||
log.info("getCashPrintData detailPO:{},type:{},orderType:{}", JSONUtil.toJSONString(detailPO), type, orderType);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("<C><B>").append(detailPO.getMerchantName()).append("</B></C><BR><BR>");
|
||||
@@ -124,42 +125,41 @@ public class PrinterUtils {
|
||||
sb.append("<S>").append(String.format("%-15s", "品名").replace(' ', paddingCharacter)).append(String.format("%-4s", "数量").replace(' ', paddingCharacter)).append(String.format("%4s", "小计").replace(' ', paddingCharacter)).append("</S><BR>");
|
||||
for (OrderDetailPO.Detail detail : detailPO.getDetailList()) {
|
||||
|
||||
if(detail.getProductName().length()>4&&detail.getProductName().length()<=10){
|
||||
if (detail.getProductName().length() > 4 && detail.getProductName().length() <= 10) {
|
||||
|
||||
int count=getProducrName(detail.getProductName());
|
||||
if(count<=0){
|
||||
int length=15-(detail.getProductName().length()-4);
|
||||
int count = getProducrName(detail.getProductName());
|
||||
if (count <= 0) {
|
||||
int length = 15 - (detail.getProductName().length() - 4);
|
||||
sb.append("<S>").append(String.format("%-" + length + "s", detail.getProductName()).replace(' ', paddingCharacter)).append(String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter)).append(String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter)).append("</S><BR>");
|
||||
}else {
|
||||
int length=15+count-(detail.getProductName().length()-4);
|
||||
} else {
|
||||
int length = 15 + count - (detail.getProductName().length() - 4);
|
||||
sb.append("<S>").append(String.format("%-" + length + "s", detail.getProductName()).replace(' ', paddingCharacter)).append(String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter)).append(String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter)).append("</S><BR>");
|
||||
}
|
||||
|
||||
}else if(detail.getProductName().length()>10){
|
||||
} else if (detail.getProductName().length() > 10) {
|
||||
|
||||
sb.append("<S>").append(detail.getProductName()).append("</S><BR>");
|
||||
sb.append("<S>").append(String.format("%20s", detail.getNumber()).replace(' ', paddingCharacter)).append(String.format("%11s", detail.getAmount()).replace(' ', paddingCharacter)).append("</S><BR>");
|
||||
|
||||
}else {
|
||||
} else {
|
||||
sb.append("<S>").append(String.format("%-15s", detail.getProductName()).replace(' ', paddingCharacter)).append(String.format("%-4s", detail.getNumber()).replace(' ', paddingCharacter)).append(String.format("%8s", detail.getAmount()).replace(' ', paddingCharacter)).append("</S><BR>");
|
||||
}
|
||||
|
||||
if(detail.getSpec()!=null&& ObjectUtil.isNotEmpty(detail.getSpec())){
|
||||
if (detail.getSpec() != null && ObjectUtil.isNotEmpty(detail.getSpec())) {
|
||||
sb.append("<S>规格:").append(detail.getSpec()).append("</S><BR>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(ObjectUtil.isNotNull(detailPO.getDiscountAmount())&&ObjectUtil.isNotNull(detailPO.getDiscountAdio())){
|
||||
if (ObjectUtil.isNotNull(detailPO.getDiscountAmount()) && ObjectUtil.isNotNull(detailPO.getDiscountAdio())) {
|
||||
sb.append("------------------------<BR>");
|
||||
sb.append("<S>原价:".concat(String.format("%15s", detailPO.getReceiptsAmount()).replace(' ', paddingCharacter)).concat("</S><BR>"));
|
||||
sb.append("<S>折扣: ".concat(String.format("%15s", "-".concat(new BigDecimal(detailPO.getDiscountAmount()).toPlainString())).replace(' ', paddingCharacter)).concat("</S><BR>"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
sb.append("------------------------<BR>");
|
||||
String t = "¥" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount())||ObjectUtil.isNull(detailPO.getDiscountAmount())?detailPO.getReceiptsAmount():new BigDecimal(detailPO.getReceiptsAmount()).subtract(new BigDecimal(detailPO.getDiscountAmount())).toPlainString());
|
||||
String t = "¥" + (ObjectUtil.isEmpty(detailPO.getDiscountAmount()) || ObjectUtil.isNull(detailPO.getDiscountAmount()) ? detailPO.getReceiptsAmount() : new BigDecimal(detailPO.getReceiptsAmount()).subtract(new BigDecimal(detailPO.getDiscountAmount())).toPlainString());
|
||||
t = String.format("%11s", t).replace(' ', paddingCharacter);
|
||||
if (orderType.equals("return")) {
|
||||
sb.append("<F>应退" + t + "</F><BR>");
|
||||
@@ -353,7 +353,7 @@ public class PrinterUtils {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void printTickets(String voiceJson, Integer actWay, Integer cn, String devName, String data) {
|
||||
public static String printTickets(String voiceJson, Integer actWay, Integer cn, String devName, String data) {
|
||||
log.info("开始请求云享印,请求数据:{}, {}", voiceJson, data);
|
||||
//设备名称
|
||||
//行为方式 1:只打印数据 2:只播放信息 3:打印数据并播放信息
|
||||
@@ -383,10 +383,21 @@ public class PrinterUtils {
|
||||
header.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
|
||||
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multiValueMap, header);
|
||||
String httpResponse = restTemplate.postForObject(URL_STR,
|
||||
httpEntity, String.class);
|
||||
|
||||
System.out.println("map" + httpResponse);
|
||||
String httpResponse;
|
||||
try {
|
||||
httpResponse = restTemplate.postForObject(URL_STR,
|
||||
httpEntity, String.class);
|
||||
System.out.println("map" + httpResponse);
|
||||
return httpResponse;
|
||||
} catch (Exception e) {
|
||||
if (StrUtil.containsAny(e.getMessage(), "timed out")) {
|
||||
log.error("请求云享印超时,请稍后再试");
|
||||
httpResponse = "{\"code\":-1, \"msg\":\"请求云享印超时,请稍后再试\"}";
|
||||
} else {
|
||||
httpResponse = "{\"code\":-2, \"msg\":\"请求云享印出错,请稍后再试\"}";
|
||||
}
|
||||
}
|
||||
return httpResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,6 +414,56 @@ public class PrinterUtils {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查打印状态
|
||||
*
|
||||
* @param devName 设备名称,(唯一) 对应配置表中的address字段即(IP地址/打印机编号)
|
||||
* @param taskId 打印任务id,用于复查打印状态,云想印=orderId
|
||||
* @return
|
||||
*/
|
||||
public static String checkPrintStatus(String devName, String taskId) {
|
||||
String time = String.valueOf(System.currentTimeMillis());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
Map<String, String> param = getToken(time, uuid);
|
||||
String token = param.get("TOKEN");
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
paramMap.put("devName", devName);
|
||||
paramMap.put("orderId", taskId);
|
||||
paramMap.put("token", token);
|
||||
paramMap.put("appId", APP_ID);
|
||||
paramMap.put("timestamp", time);
|
||||
paramMap.put("requestId", uuid);
|
||||
paramMap.put("userCode", USER_CODE);
|
||||
|
||||
return HttpUtil.get("https://ioe.car900.com/v1/openApi/dev/findOrder.json", paramMap, 1000 * 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查打印机运行状态
|
||||
*
|
||||
* @param devName 设备名称,(唯一) 对应配置表中的address字段即(IP地址/打印机编号)
|
||||
* @return
|
||||
*/
|
||||
public static String findDeviceStatus(String devName) {
|
||||
String time = String.valueOf(System.currentTimeMillis());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
Map<String, String> param = getToken(time, uuid);
|
||||
String token = param.get("TOKEN");
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
|
||||
paramMap.put("devName", devName);
|
||||
paramMap.put("token", token);
|
||||
paramMap.put("appId", APP_ID);
|
||||
paramMap.put("timestamp", time);
|
||||
paramMap.put("requestId", uuid);
|
||||
paramMap.put("userCode", USER_CODE);
|
||||
|
||||
return HttpUtil.get("https://ioe.car900.com/v1/openApi/dev/findDevice.json", paramMap, 1000 * 5);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
|
||||
|
||||
7
src/main/resources/mapper/TbPrintMachineLogMapper.xml
Normal file
7
src/main/resources/mapper/TbPrintMachineLogMapper.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbPrintMachineLogMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -18,6 +18,14 @@
|
||||
<result column="sort" jdbcType="INTEGER" property="sort" />
|
||||
<result column="vendor_id" jdbcType="VARCHAR" property="vendorId" />
|
||||
<result column="product_id" jdbcType="VARCHAR" property="productId" />
|
||||
|
||||
<result column="receipt_size" jdbcType="VARCHAR" property="receiptSize" />
|
||||
<result column="classify_print" jdbcType="VARCHAR" property="classifyPrint" />
|
||||
<result column="table_print" jdbcType="VARCHAR" property="tablePrint" />
|
||||
<result column="print_qty" jdbcType="VARCHAR" property="printQty" />
|
||||
<result column="print_method" jdbcType="VARCHAR" property="printMethod" />
|
||||
<result column="print_type" jdbcType="VARCHAR" property="printType" />
|
||||
<result column="print_receipt" jdbcType="VARCHAR" property="printReceipt" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs">
|
||||
<result column="config" jdbcType="LONGVARCHAR" property="config" />
|
||||
@@ -25,7 +33,7 @@
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids,
|
||||
content_type, created_at, updated_at, sort, vendor_id, product_id
|
||||
content_type, created_at, updated_at, sort, vendor_id, product_id, receipt_size, classify_print, table_print, print_qty, print_method, print_type, print_receipt
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
config, category_list
|
||||
|
||||
Reference in New Issue
Block a user