店铺小票打印记录查询
This commit is contained in:
parent
fac61ff581
commit
f25141a495
|
|
@ -0,0 +1,37 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.service.shop.ShopPrintLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 17:51:38
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "店铺小票打印记录")
|
||||
@RequestMapping("/api/shop/print/log")
|
||||
public class ShopPrintLogController {
|
||||
|
||||
private final ShopPrintLogService shopPrintLogService;
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("分页")
|
||||
public ResponseEntity page(@RequestParam Map<String, Object> params) {
|
||||
Map<String, Object> page = shopPrintLogService.page(params);
|
||||
return ResponseEntity.ok().body(page);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "打印机类型 本地打印机-local USB打印机-USB 云打印机-network")
|
||||
private String connectionType;
|
||||
@ApiModelProperty(value = "打印机品牌 云想印 = yxyPrinter飞鹅 = fePrinter 本地 = local USB = printer")
|
||||
private String contentType;
|
||||
@ApiModelProperty(value = "打印小票 标签-label 出品-kitchen 小票-cash")
|
||||
private String subType;
|
||||
@ApiModelProperty(value = "打印机名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "IP地址/打印机编号")
|
||||
private String address;
|
||||
@ApiModelProperty(value = "端口/打印机秘钥")
|
||||
private String port;
|
||||
@ApiModelProperty(value = "小票尺寸 58mm 80mm")
|
||||
private String receiptSize;
|
||||
@ApiModelProperty(value = "分类打印 0-所以 1-部分分类 2-部分商品")
|
||||
private String classifyPrint;
|
||||
@ApiModelProperty(value = "桌台打印 0-所有 1-部分")
|
||||
private String tablePrint;
|
||||
@ApiModelProperty(value = "打印数量 c1m1^2=顾客+商家[2张] m1^1=商家[1张] c1^1顾客[1张] c2m1^3=顾客2+商家1[3张]")
|
||||
private String printQty;
|
||||
@ApiModelProperty(value = "打印方式 1-普通 2-单个菜")
|
||||
private String printMethod;
|
||||
@ApiModelProperty(value = "打印类型 JSON数组字符串数据 1-确认退款单 2-交班单 3-排队取号,如:[1,2,3]")
|
||||
private String printType;
|
||||
@ApiModelProperty(value = "打印票据 0-全部打印 1-仅厨房 2-仅前台")
|
||||
private String printReceipt;
|
||||
@ApiModelProperty(value = "打印内容")
|
||||
private String printContent;
|
||||
@ApiModelProperty(value = "店铺id")
|
||||
private String shopId;
|
||||
@ApiModelProperty(value = "业务类型")
|
||||
private String bizType;
|
||||
@ApiModelProperty(value = "打印人id")
|
||||
private Long createUserId;
|
||||
@ApiModelProperty(value = "打印人名称")
|
||||
private String createUserName;
|
||||
@ApiModelProperty(value = "打印任务创建时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "打印任务id,用于复查打印状态,云想印=orderId")
|
||||
private String taskId;
|
||||
@ApiModelProperty(value = "实际打印时间")
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date printTime;
|
||||
@ApiModelProperty(value = "失败标识 1-是 0-否")
|
||||
private Integer failFlag;
|
||||
@ApiModelProperty(value = "响应代码")
|
||||
private String respCode;
|
||||
@ApiModelProperty(value = "响应消息")
|
||||
private String respMsg;
|
||||
@ApiModelProperty(value = "打印结果")
|
||||
private String printResult;
|
||||
@ApiModelProperty(value = "失败原因")
|
||||
private String failReason;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineLogEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 16:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface TbPrintMachineLogMapper extends BaseMapper<TbPrintMachineLogEntity> {
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package cn.ysk.cashier.pojo.shop;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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 TbPrintMachineLogEntity 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;
|
||||
/**
|
||||
* 打印时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 打印任务id,用于复查打印状态,云想印=orderId
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 实际打印时间
|
||||
*/
|
||||
private Date printTime;
|
||||
/**
|
||||
* 失败标识 1-是 0-否
|
||||
*/
|
||||
private Integer failFlag;
|
||||
/**
|
||||
* 响应代码
|
||||
*/
|
||||
private String respCode;
|
||||
/**
|
||||
* 响应消息
|
||||
*/
|
||||
private String respMsg;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.ShopPrintLogDTO;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbPrintMachineLogMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbPrintMachineMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineEntity;
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineLogEntity;
|
||||
import cn.ysk.cashier.service.shop.ShopPrintLogService;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录ServiceImpl
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 17:10
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper, TbPrintMachineLogEntity> implements ShopPrintLogService {
|
||||
|
||||
private final TbPrintMachineMapper tbPrintMachineMapper;
|
||||
|
||||
private QueryWrapper<TbPrintMachineLogEntity> getWrapper(Map<String, Object> params) {
|
||||
TbPrintMachineLogEntity entity = BeanUtil.toBean(params, TbPrintMachineLogEntity.class);
|
||||
|
||||
QueryWrapper<TbPrintMachineLogEntity> wrapper = new QueryWrapper<>();
|
||||
|
||||
wrapper.lambda().eq(entity.getId() != null, TbPrintMachineLogEntity::getId, entity.getId());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getShopId()), TbPrintMachineLogEntity::getShopId, entity.getShopId());
|
||||
wrapper.lambda().likeRight(StrUtil.isNotEmpty(entity.getName()), TbPrintMachineLogEntity::getName, entity.getName());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getConnectionType()), TbPrintMachineLogEntity::getConnectionType, entity.getConnectionType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getContentType()), TbPrintMachineLogEntity::getContentType, entity.getContentType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getSubType()), TbPrintMachineLogEntity::getSubType, entity.getSubType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getAddress()), TbPrintMachineLogEntity::getAddress, entity.getAddress());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPort()), TbPrintMachineLogEntity::getPort, entity.getPort());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getReceiptSize()), TbPrintMachineLogEntity::getReceiptSize, entity.getReceiptSize());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getClassifyPrint()), TbPrintMachineLogEntity::getClassifyPrint, entity.getClassifyPrint());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getTablePrint()), TbPrintMachineLogEntity::getTablePrint, entity.getTablePrint());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintQty()), TbPrintMachineLogEntity::getPrintQty, entity.getPrintQty());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintMethod()), TbPrintMachineLogEntity::getPrintMethod, entity.getPrintMethod());
|
||||
wrapper.lambda().like(StrUtil.isNotEmpty(entity.getPrintType()), TbPrintMachineLogEntity::getPrintType, entity.getPrintType());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getPrintReceipt()), TbPrintMachineLogEntity::getPrintReceipt, entity.getPrintReceipt());
|
||||
wrapper.lambda().eq(entity.getFailFlag() != null, TbPrintMachineLogEntity::getFailFlag, entity.getFailFlag());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getRespCode()), TbPrintMachineLogEntity::getRespCode, entity.getRespCode());
|
||||
wrapper.lambda().like(StrUtil.isNotEmpty(entity.getRespMsg()), TbPrintMachineLogEntity::getRespMsg, entity.getRespMsg());
|
||||
wrapper.lambda().eq(entity.getCreateUserId() != null, TbPrintMachineLogEntity::getCreateUserId, entity.getCreateUserId());
|
||||
wrapper.lambda().like(StrUtil.isNotEmpty(entity.getCreateUserName()), TbPrintMachineLogEntity::getCreateUserName, entity.getCreateUserName());
|
||||
wrapper.lambda().eq(StrUtil.isNotEmpty(entity.getBizType()), TbPrintMachineLogEntity::getBizType, entity.getBizType());
|
||||
wrapper.lambda().orderByDesc(TbPrintMachineLogEntity::getId);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
int pageNum = mapProxy.getInt("page", 1);
|
||||
int pageSize = mapProxy.getInt("size", 10);
|
||||
Page<TbPrintMachineLogEntity> page = baseMapper.selectPage(new Page<>(pageNum, pageSize), getWrapper(params));
|
||||
List<ShopPrintLogDTO> list = new ArrayList<>();
|
||||
Optional.ofNullable(page).map(Page::getRecords)
|
||||
.ifPresent(itemList -> {
|
||||
for (TbPrintMachineLogEntity item : itemList) {
|
||||
list.add(convertToDTO(item));
|
||||
}
|
||||
});
|
||||
return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void saveByConfigId(Integer configId, String printContent, boolean success, Date printTime, Long userId, String userName) {
|
||||
Optional.ofNullable(configId).filter(Objects::nonNull).orElseThrow(() -> new BadRequestException("店铺打印机配置ID不能为空"));
|
||||
TbPrintMachineEntity configEntity = tbPrintMachineMapper.selectById(configId);
|
||||
Optional.ofNullable(configEntity).filter(Objects::nonNull).orElseThrow(() -> new BadRequestException("未找到对应的打印机配置数据"));
|
||||
TbPrintMachineLogEntity entity = BeanUtil.copyProperties(configEntity, TbPrintMachineLogEntity.class);
|
||||
entity.setPrintContent(printContent);
|
||||
entity.setCreateTime(printTime);
|
||||
entity.setFailFlag(success ? 0 : 1);
|
||||
entity.setCreateUserId(userId);
|
||||
entity.setCreateUserName(userName);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void save(ShopPrintLogDTO dto) {
|
||||
TbPrintMachineLogEntity entity = BeanUtil.copyProperties(dto, TbPrintMachineLogEntity.class);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
private ShopPrintLogDTO convertToDTO(TbPrintMachineLogEntity entity) {
|
||||
ShopPrintLogDTO dto = BeanUtil.copyProperties(entity, ShopPrintLogDTO.class);
|
||||
/**
|
||||
Dict connectionType = Dict.of("local", "本地打印机", "USB", "USB打印机", "network", "网络打印机");
|
||||
Dict contentType = Dict.of("local", "本地", "printer", "USB", "yxyPrinter", "云想印", "fePrinter", "飞鹅");
|
||||
Dict subType = Dict.of("label", "标签", "kitchen", "出品", "cash", "小票");
|
||||
Dict classifyPrint = Dict.of("0", "打印所有", "1", "部分分类", "2", "部分商品");
|
||||
Dict tablePrint = Dict.of("0", "打印所有", "1", "打印部分桌台");
|
||||
Dict printQty = Dict.of("c1m1^2", "顾客+商家[2张]", "m1^1", "商家[1张]", "c1^1", "顾客[1张]", "c2m1^3", "顾客2+商家1[3张]");
|
||||
Dict printMethod = Dict.of("1", "普通", "2", "单个菜");
|
||||
Dict printType = Dict.of("1", "确认退款单", "2", "交班单", "3", "排队取号");
|
||||
Dict printReceipt = Dict.of("0", "全部打印", "1", "仅厨房", "2", "仅前台");
|
||||
*/
|
||||
Dict failFlag = Dict.of("0", "成功", "1", "失败");
|
||||
//dto.setConnectionType(connectionType.getStr(dto.getConnectionType()));
|
||||
//dto.setContentType(contentType.getStr(dto.getContentType()));
|
||||
//dto.setSubType(subType.getStr(dto.getSubType()));
|
||||
//dto.setClassifyPrint(classifyPrint.getStr(dto.getClassifyPrint()));
|
||||
//dto.setTablePrint(tablePrint.getStr(dto.getTablePrint()));
|
||||
//dto.setPrintQty(printQty.getStr(dto.getPrintQty()));
|
||||
//dto.setPrintMethod(printMethod.getStr(dto.getPrintMethod()));
|
||||
//dto.setPrintType(printType.getStr(dto.getPrintType()));
|
||||
//dto.setPrintReceipt(printReceipt.getStr(dto.getPrintReceipt()));
|
||||
dto.setPrintResult(failFlag.getStr(dto.getFailFlag() + ""));
|
||||
dto.setFailReason(dto.getRespMsg());
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package cn.ysk.cashier.service.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.ShopPrintLogDTO;
|
||||
import cn.ysk.cashier.pojo.shop.TbPrintMachineLogEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺小票打印记录
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-10-8 16:40
|
||||
*/
|
||||
public interface ShopPrintLogService extends IService<TbPrintMachineLogEntity> {
|
||||
|
||||
Map<String, Object> page(Map<String, Object> params);
|
||||
|
||||
void saveByConfigId(Integer configId, String printContent, boolean success, Date printTime, Long userId, String userName);
|
||||
|
||||
void save(ShopPrintLogDTO dto);
|
||||
|
||||
}
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue