feat:ms439打印机相关接口,增加小票打印机获取接口
This commit is contained in:
parent
f4edd0189b
commit
2ee5b3015a
7
pom.xml
7
pom.xml
|
@ -120,6 +120,13 @@
|
||||||
<version>5.8.15</version>
|
<version>5.8.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 数据校验-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.dpkj.modules.print.controller;
|
||||||
|
|
||||||
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.common.vo.Result;
|
||||||
|
import com.dpkj.modules.print.request.MS439Request;
|
||||||
|
import com.dpkj.modules.print.service.MS439PrintService;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MS439控制层,利盟打印机
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-03 10:47:06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ms439")
|
||||||
|
public class MS439Controller {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MS439PrintService ms439PrintService;
|
||||||
|
|
||||||
|
@PostMapping("/print")
|
||||||
|
public Result<LexMarkResultDTO<?>> print(@Validated @RequestBody MS439Request request){
|
||||||
|
return Result.ok(ms439PrintService.printImage(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getStatus")
|
||||||
|
public Result<String> print(){
|
||||||
|
this.ms439PrintService.getStatus();
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.dpkj.common.dto.LexMarkResultDTO;
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
import com.dpkj.common.vo.Result;
|
import com.dpkj.common.vo.Result;
|
||||||
import com.dpkj.modules.print.service.PrintService;
|
import com.dpkj.modules.print.service.PrintService;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -14,7 +15,7 @@ import javax.annotation.Resource;
|
||||||
* @since 2025-02-08 11:49:46
|
* @since 2025-02-08 11:49:46
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/print")
|
@RequestMapping("/receipt")
|
||||||
public class RegisterController {
|
public class RegisterController {
|
||||||
|
|
||||||
@Resource(name = "registerService")
|
@Resource(name = "registerService")
|
||||||
|
@ -40,5 +41,13 @@ public class RegisterController {
|
||||||
return Result.ok((LexMarkResultDTO)printService.printImage(null, null, 0, 0, filePath));
|
return Result.ok((LexMarkResultDTO)printService.printImage(null, null, 0, 0, filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取小票打印机状态
|
||||||
|
*/
|
||||||
|
@PostMapping("/getStatus")
|
||||||
|
public Result<String> getStatus(){
|
||||||
|
this.printService.getStatus();
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ms439打印机设备状态枚举
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 11:31:25
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439DeviceStatusEnum {
|
||||||
|
/**
|
||||||
|
* 打印机正常
|
||||||
|
*/
|
||||||
|
HEALTHY(439200, "正常", "HEALTHY"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机忙碌,请稍后
|
||||||
|
*/
|
||||||
|
BUSY(439201, "打印机忙碌,请稍后", "BUSY"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机发生故障
|
||||||
|
*/
|
||||||
|
FATAL(439500, "打印机发生故障", "FATAL"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未发现打印机
|
||||||
|
*/
|
||||||
|
NODEVICE(439501, "未发现打印机", "NODEVICE"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439DeviceStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439DeviceStatusEnum value : MS439DeviceStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "打印机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439DeviceStatusEnum value : MS439DeviceStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MS439打印机墨盒状态
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 11:39:35
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439InkStatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 墨盒满
|
||||||
|
*/
|
||||||
|
INKFULL(439200, "墨盒满", "INKFULL"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 墨盒少
|
||||||
|
*/
|
||||||
|
INKLOW(439203, "墨盒少", "INKLOW"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缺墨盒
|
||||||
|
*/
|
||||||
|
INKOUT(439511, "缺墨盒", "INKOUT"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持墨盒检测
|
||||||
|
*/
|
||||||
|
INKNOTSUPP(439512, "不支持墨盒检测", "INKNOTSUPP"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 墨盒状态未知
|
||||||
|
*/
|
||||||
|
INKUNKNOWN(439513, "墨盒未知", "INKUNKNOWN");
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439InkStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439InkStatusEnum value : MS439InkStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "打印机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439InkStatusEnum value : MS439InkStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ms439打印机介质枚举
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 11:38:08
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439MediaStatusEnum {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 介质在通道
|
||||||
|
*/
|
||||||
|
PRESENT(439200, "介质在通道", "PRESENT"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无介质
|
||||||
|
*/
|
||||||
|
NOTPRESENT(439502, "无介质", "NOTPRESENT"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡介质
|
||||||
|
*/
|
||||||
|
JAMMED(439503, "卡介质", "JAMMED"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持
|
||||||
|
*/
|
||||||
|
NOTSUPP(439504, "不支持", "NOTSUPP"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未知
|
||||||
|
*/
|
||||||
|
UNKNOWN(439505, "未知", "UNKNOWN"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 介质在出口
|
||||||
|
*/
|
||||||
|
EXITING(439506, "介质在出口", "EXITING"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 介质被回收(复位时)
|
||||||
|
*/
|
||||||
|
RETRACTED(439507, "介质被回收(复位时)", "RETRACTED"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439MediaStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439MediaStatusEnum value : MS439MediaStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "打印机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439MediaStatusEnum value : MS439MediaStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MS439打印机纸盒状态枚举
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 11:53:21
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439PaperStatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纸满
|
||||||
|
*/
|
||||||
|
PAPERFULL(439200, "纸满", "PAPERFULL"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 少纸
|
||||||
|
*/
|
||||||
|
PAPERLOW(439204, "少纸", "PAPERLOW"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缺纸
|
||||||
|
*/
|
||||||
|
PAPEROUT(439514, "缺纸", "PAPEROUT"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持纸箱检测
|
||||||
|
*/
|
||||||
|
PAPERNOTSUPP(439515, "不支持纸箱检测", "PAPERNOTSUPP"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡纸
|
||||||
|
*/
|
||||||
|
PAPERJAMMED(439516, "卡纸", "PAPERJAMMED"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纸箱未知
|
||||||
|
*/
|
||||||
|
PAPERUNKNOWN(439517, "纸箱未知", "PAPERUNKNOWN");
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439PaperStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439PaperStatusEnum value : MS439PaperStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "打印机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439PaperStatusEnum value : MS439PaperStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盖章机状态枚举
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 15:13:58
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439StampStatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盖章机正常
|
||||||
|
*/
|
||||||
|
HEALTHY(439200, "正常", "HEALTHY"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盖章机忙碌,请稍后
|
||||||
|
*/
|
||||||
|
BUSY(439201, "盖章机忙碌,请稍后", "BUSY"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盖章机发生故障
|
||||||
|
*/
|
||||||
|
FATAL(439500, "盖章机发生故障", "FATAL"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未发现盖章机
|
||||||
|
*/
|
||||||
|
NODEVICE(439501, "未发现盖章机", "NODEVICE"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439StampStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439StampStatusEnum value : MS439StampStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "盖章机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439StampStatusEnum value : MS439StampStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.dpkj.modules.print.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MS439打印机 磁带状态
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-06 11:38:48
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum MS439TonerStatusEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 磁带满
|
||||||
|
*/
|
||||||
|
TONERFULL(439200, "碳带满", "TONERFULL"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 碳带少
|
||||||
|
*/
|
||||||
|
TONERLOW(439202, "碳带少", "TONERLOW"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缺碳带
|
||||||
|
*/
|
||||||
|
TONEROUT(439508, "缺碳带", "TONEROUT"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不支持碳带检测
|
||||||
|
*/
|
||||||
|
TONERNOTSUPP(439509, "不支持碳带检测", "TONERNOTSUPP"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 碳带状态未知
|
||||||
|
*/
|
||||||
|
TONERUNKNOWN(439510, "碳带未知", "TONERUNKNOWN")
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String msg;
|
||||||
|
|
||||||
|
private final String printCode;
|
||||||
|
|
||||||
|
|
||||||
|
MS439TonerStatusEnum(Integer code, String msg, String printCode) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.printCode = printCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String printCode){
|
||||||
|
for (MS439TonerStatusEnum value : MS439TonerStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "打印机未知的错误";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPCode(String printCode){
|
||||||
|
for (MS439TonerStatusEnum value : MS439TonerStatusEnum.values()) {
|
||||||
|
if ( value.getPrintCode().equals(printCode)){
|
||||||
|
return value.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.dpkj.modules.print.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @since 2025-02-28 16:29:27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class MS439Request implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 什么类型的纸张,默认A4
|
||||||
|
*/
|
||||||
|
private String pagesource = "A4";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 份数,默认1
|
||||||
|
*/
|
||||||
|
private Integer copies = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件的路径
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "文件路径不能为空")
|
||||||
|
private String fileDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否盖章,默认不盖章 1盖章,0不盖章
|
||||||
|
*/
|
||||||
|
private Integer stamp = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单面打印,或者双面 duplex 1/2,默认1
|
||||||
|
*/
|
||||||
|
private Integer duplex = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 颜色 0黑白,1彩色,默认是黑白的
|
||||||
|
*/
|
||||||
|
private Integer color = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印方向 direction 0纵向/1横向
|
||||||
|
*/
|
||||||
|
private Integer direction = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.dpkj.modules.print.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小票打印请求,壁挂和打印机接口 进行统一
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-03-10 9:25:34
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class ReceiptPrintRequest implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径地址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "文件路径不能为空")
|
||||||
|
private String fileDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板名称,也可以是自己写的html的字符串文件
|
||||||
|
*/
|
||||||
|
private String templateName = "hospital";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 填充模板的数据,必填,但是需要通过自己设置的模板名称进行设计,部分设计规则
|
||||||
|
* 特殊字段图片类型:qrCodeBase64_2base64Type_120_120,字段解析,qrCodeBase64为字段名称,
|
||||||
|
* _2base64Type为将这个数据转换为图片类型的base64编码,第一个_120图片的宽度,第二个_120的为图片高度
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "模板填充数据不能为空")
|
||||||
|
private String templateFillData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成的模板的宽度,默认为:600
|
||||||
|
*/
|
||||||
|
private Integer width = 600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成的模板的高度,默认为:950
|
||||||
|
*/
|
||||||
|
private Integer height = 950;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.dpkj.modules.print.service;
|
||||||
|
|
||||||
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.modules.print.request.MS439Request;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
|
import javassist.compiler.Lex;
|
||||||
|
|
||||||
|
public interface MS439PrintService {
|
||||||
|
|
||||||
|
LexMarkResultDTO<?> printImage(MS439Request request);
|
||||||
|
|
||||||
|
LexMarkResultDTO<PrinterStatus> getStatus();
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.dpkj.modules.print.service;
|
package com.dpkj.modules.print.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印服务接口
|
* 打印服务接口
|
||||||
|
@ -31,4 +33,7 @@ public interface PrintService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LexMarkResultDTO<PrinterStatus> getStatus();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
package com.dpkj.modules.print.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.common.constant.ErrorCodeConstants;
|
||||||
|
import com.dpkj.common.dto.LexMarkDTO;
|
||||||
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.common.exception.RRException;
|
||||||
|
import com.dpkj.common.utils.ThirdService;
|
||||||
|
import com.dpkj.modules.print.enums.*;
|
||||||
|
import com.dpkj.modules.print.request.MS439Request;
|
||||||
|
import com.dpkj.modules.print.service.MS439PrintService;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 利盟MS439打印机服务
|
||||||
|
*
|
||||||
|
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2025-02-10 11:49:26
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MS439PrintServiceImpl implements MS439PrintService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ThirdService thirdService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LexMarkResultDTO<?> printImage(MS439Request request) {
|
||||||
|
LexMarkResultDTO<PrinterStatus> status = this.getStatus();
|
||||||
|
|
||||||
|
PrinterStatus ms439 = status.getData();
|
||||||
|
String stPaperEx = ms439.getStPaperEx();
|
||||||
|
if (stPaperEx == null || stPaperEx.equals("")) {
|
||||||
|
throw new RRException("获取打印机纸张状态出问题");
|
||||||
|
}
|
||||||
|
String[] papers = stPaperEx.split("\\|");
|
||||||
|
if ( papers.length < 2) {
|
||||||
|
throw new RRException("打印机纸盒数量不对");
|
||||||
|
}
|
||||||
|
String paperStatus = "";
|
||||||
|
// 如果是A4,当前是取第一层纸盒作为A4
|
||||||
|
if (request.getPagesource().equals("A4")) {
|
||||||
|
paperStatus = papers[0];
|
||||||
|
}
|
||||||
|
// 如果是A5,当前是取第二层纸盒只作为A5
|
||||||
|
if (request.getPagesource().equals("A5")) {
|
||||||
|
paperStatus = papers[1];
|
||||||
|
}
|
||||||
|
if ( !(paperStatus.equals(MS439PaperStatusEnum.PAPERFULL.getPrintCode()) || !paperStatus.equals(MS439PaperStatusEnum.PAPERLOW.getPrintCode()))){
|
||||||
|
throw new RRException(MS439PaperStatusEnum.getPCode(paperStatus), MS439PaperStatusEnum.getMessage(paperStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是要盖章,校验盖章机器是否正常
|
||||||
|
if ( request.getStamp() == 1) {
|
||||||
|
String deviceExStatus = ms439.getStDeviceExStatus();
|
||||||
|
if (deviceExStatus == null || deviceExStatus.equals("")) {
|
||||||
|
throw new RRException("获取打印机设备状态出问题");
|
||||||
|
}
|
||||||
|
String[] devices = stPaperEx.split("\\|");
|
||||||
|
if (devices.length < 2) {
|
||||||
|
throw new RRException("打印机默认设备数量不对");
|
||||||
|
}
|
||||||
|
String device = devices[1];
|
||||||
|
// 校验盖章机是否正常,除了HEALTHY都抛异常
|
||||||
|
if (!device.equals(MS439StampStatusEnum.HEALTHY.getPrintCode()) ) {
|
||||||
|
throw new RRException(MS439StampStatusEnum.getPCode(device),
|
||||||
|
MS439StampStatusEnum.getMessage(device));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LexMarkDTO lexMarkDTO = new LexMarkDTO();
|
||||||
|
lexMarkDTO.setActionName("PrintText");
|
||||||
|
lexMarkDTO.setCallID(19283);
|
||||||
|
lexMarkDTO.setDevName("HtmPrinter");
|
||||||
|
lexMarkDTO.setPluginMethod("exec");
|
||||||
|
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("prtData", String.format("pagesource=%s;copies=%d;file[0]=%s;stamp=%d;duplex=%d;color=%d;direction=%d",
|
||||||
|
request.getPagesource(), request.getCopies(), request.getFileDir(), request.getStamp(),
|
||||||
|
request.getDuplex(), request.getColor(), request.getDirection()));
|
||||||
|
lexMarkDTO.setParam(param.toString());
|
||||||
|
return thirdService.callDevice(lexMarkDTO, LexMarkResultDTO.Param.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LexMarkResultDTO<PrinterStatus> getStatus() {
|
||||||
|
LexMarkDTO lexMarkDTO = new LexMarkDTO();
|
||||||
|
lexMarkDTO.setActionName("GetStatus");
|
||||||
|
lexMarkDTO.setCallID(19283);
|
||||||
|
lexMarkDTO.setDevName("HtmPrinter");
|
||||||
|
lexMarkDTO.setPluginMethod("exec");
|
||||||
|
|
||||||
|
LexMarkResultDTO<PrinterStatus> status = thirdService.callDevice(lexMarkDTO, PrinterStatus.class);
|
||||||
|
if ( status.getResult() != 0){
|
||||||
|
throw new RRException(ErrorCodeConstants.MS439_PRINT_ERROR_CODE.get(status.getResult()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PrinterStatus ms439 = status.getData();
|
||||||
|
// 校验打印机是否正常,除了HEALTHY都抛异常
|
||||||
|
if (!ms439.getStDeviceStatus().equals(MS439DeviceStatusEnum.HEALTHY.getPrintCode()) ) {
|
||||||
|
throw new RRException(500, ms439.getStDeviceStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验介质 介质在通道才放行
|
||||||
|
if (!ms439.getStMedia().equals(MS439MediaStatusEnum.PRESENT.getPrintCode())) {
|
||||||
|
throw new RRException(500, ms439.getStMedia());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验磁带 满或者少才放行
|
||||||
|
if ( !(ms439.getStToner().equals(MS439TonerStatusEnum.TONERFULL.getPrintCode()) || ms439.getStToner().equals(MS439TonerStatusEnum.TONERLOW.getPrintCode()))){
|
||||||
|
throw new RRException(500, ms439.getStToner());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验墨盒 满或者少才放行,当前获取为未知
|
||||||
|
if ( !(ms439.getStInk().equals(MS439InkStatusEnum.INKFULL.getPrintCode()) || ms439.getStInk().equals(MS439InkStatusEnum.INKLOW.getPrintCode())
|
||||||
|
|| ms439.getStInk().equals(MS439InkStatusEnum.INKUNKNOWN.getPrintCode()))){
|
||||||
|
throw new RRException(500, ms439.getStInk());
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,18 @@ package com.dpkj.modules.print.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.dpkj.common.constant.ErrorCodeConstants;
|
||||||
import com.dpkj.common.dto.LexMarkDTO;
|
import com.dpkj.common.dto.LexMarkDTO;
|
||||||
import com.dpkj.common.dto.LexMarkResultDTO;
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
||||||
|
import com.dpkj.common.exception.RRException;
|
||||||
import com.dpkj.common.utils.TemplateUtils;
|
import com.dpkj.common.utils.TemplateUtils;
|
||||||
import com.dpkj.common.utils.ThirdService;
|
import com.dpkj.common.utils.ThirdService;
|
||||||
|
import com.dpkj.modules.print.enums.MS439DeviceStatusEnum;
|
||||||
|
import com.dpkj.modules.print.enums.MS439InkStatusEnum;
|
||||||
|
import com.dpkj.modules.print.enums.MS439MediaStatusEnum;
|
||||||
|
import com.dpkj.modules.print.enums.MS439TonerStatusEnum;
|
||||||
import com.dpkj.modules.print.service.PrintService;
|
import com.dpkj.modules.print.service.PrintService;
|
||||||
|
import com.dpkj.modules.print.vo.PrinterStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thymeleaf.util.StringUtils;
|
import org.thymeleaf.util.StringUtils;
|
||||||
|
|
||||||
|
@ -51,5 +58,43 @@ public class RegisterServiceImpl implements PrintService {
|
||||||
return thirdService.callDevice(lexMarkDTO, LexMarkResultDTO.Param.class);
|
return thirdService.callDevice(lexMarkDTO, LexMarkResultDTO.Param.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LexMarkResultDTO<PrinterStatus> getStatus() {
|
||||||
|
LexMarkDTO lexMarkDTO = new LexMarkDTO();
|
||||||
|
lexMarkDTO.setActionName("GetStatus");
|
||||||
|
lexMarkDTO.setCallID(11225);
|
||||||
|
lexMarkDTO.setDevName("ReceiptPrinter");
|
||||||
|
lexMarkDTO.setPluginMethod("getInfo");
|
||||||
|
// lexMarkDTO.setMethodType(0);
|
||||||
|
LexMarkResultDTO<PrinterStatus> status = thirdService.callDevice(lexMarkDTO, PrinterStatus.class);
|
||||||
|
if ( status.getResult() != 0){
|
||||||
|
throw new RRException(ErrorCodeConstants.MS439_PRINT_ERROR_CODE.get(status.getResult()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PrinterStatus ms439 = status.getData();
|
||||||
|
// 校验打印机是否正常,除了HEALTHY都抛异常
|
||||||
|
if (!ms439.getStDeviceStatus().equals(MS439DeviceStatusEnum.HEALTHY.getPrintCode()) ) {
|
||||||
|
throw new RRException(500, ms439.getStDeviceStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验介质 介质在通道才放行
|
||||||
|
if (!ms439.getStMedia().equals(MS439MediaStatusEnum.PRESENT.getPrintCode())) {
|
||||||
|
throw new RRException(500, ms439.getStMedia());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验磁带 满或者少才放行
|
||||||
|
if ( !(ms439.getStToner().equals(MS439TonerStatusEnum.TONERFULL.getPrintCode()) || ms439.getStToner().equals(MS439TonerStatusEnum.TONERLOW.getPrintCode()))){
|
||||||
|
throw new RRException(500, ms439.getStToner());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验墨盒 满或者少才放行,当前获取为未知
|
||||||
|
if ( !(ms439.getStInk().equals(MS439InkStatusEnum.INKFULL.getPrintCode()) || ms439.getStInk().equals(MS439InkStatusEnum.INKLOW.getPrintCode())
|
||||||
|
|| ms439.getStInk().equals(MS439InkStatusEnum.INKUNKNOWN.getPrintCode()))){
|
||||||
|
throw new RRException(500, ms439.getStInk());
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.dpkj.modules.print.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PrinterStatus {
|
||||||
|
/**
|
||||||
|
* sp服务版本号
|
||||||
|
*/
|
||||||
|
private String SPVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印机状态
|
||||||
|
* HEALTHY: 正常
|
||||||
|
* FATAL: 故障
|
||||||
|
* BUSY: 忙
|
||||||
|
* NODEVICE: 无设备
|
||||||
|
*/
|
||||||
|
private String StDeviceStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 介质状态
|
||||||
|
* PRESENT: 介质在通道
|
||||||
|
* NOTPRESENT: 无介质
|
||||||
|
* JAMMED: 卡介质
|
||||||
|
* NOTSUPP: 不支持
|
||||||
|
* UNKNOWN: 未知
|
||||||
|
* EXITING: 介质在出口
|
||||||
|
* RETRACTED 介质被回收(复位时)
|
||||||
|
*/
|
||||||
|
private String StMedia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 磁带状态
|
||||||
|
* TONERFULL: 碳带满
|
||||||
|
* TONERLOW: 碳带少
|
||||||
|
* TONEROUT: 缺碳带
|
||||||
|
* TONERNOTSUPP: 不支持碳带检测
|
||||||
|
* TONERUNKNOWN: 碳带未知
|
||||||
|
*/
|
||||||
|
private String StToner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 墨盒状态
|
||||||
|
* INKFULL: 墨盒满
|
||||||
|
* INKLOW: 墨盒少
|
||||||
|
* INKOUT: 缺墨盒
|
||||||
|
* INKNOTSUPP: 不支持墨盒检测
|
||||||
|
* INKUNKNOWN: 墨盒未知
|
||||||
|
*/
|
||||||
|
private String StInk;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 纸盒扩展,取前面两个
|
||||||
|
*/
|
||||||
|
private String StPaperEx;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备扩展,第一个是打印机状态,第二个是盖章机状态
|
||||||
|
*/
|
||||||
|
private String StDeviceExStatus;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue