|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.dpkj.modules.print.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.dpkj.common.config.PrinterConfig;
|
|
|
|
|
import com.dpkj.common.dto.LexMarkDTO;
|
|
|
|
|
import com.dpkj.common.dto.LexMarkResultDTO;
|
|
|
|
|
import com.dpkj.common.exception.RRException;
|
|
|
|
@ -15,7 +16,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 利盟MS439打印机服务
|
|
|
|
@ -31,6 +31,9 @@ public class MS439PrintServiceImpl implements MS439PrintService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ThirdService thirdService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private PrinterConfig printerConfig;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public LexMarkResultDTO<?> printImage(MS439Request request) {
|
|
|
|
|
// 校验是本地地址还是http开头的
|
|
|
|
@ -72,9 +75,20 @@ public class MS439PrintServiceImpl implements MS439PrintService {
|
|
|
|
|
// param.put("prtData", String.format("PrintType=%d;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()));
|
|
|
|
|
// 计算A4/A5归属
|
|
|
|
|
int printType = 1; // 默认使用第一层
|
|
|
|
|
if (printerConfig.getLevelOne().equals("A5")) {
|
|
|
|
|
if (request.getPagesource().equals("A4")) {
|
|
|
|
|
printType = 2;
|
|
|
|
|
}
|
|
|
|
|
} else if (printerConfig.getLevelOne().equals("A4")) {
|
|
|
|
|
if (request.getPagesource().equals("A5")) {
|
|
|
|
|
printType = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
param.put("prtData", String.format("PaperNum=%d;PrintType=%d;Stamp=%d;File[0]=%s;WaitNum=%d;copies=%d;stamp=%d;duplex=%d;color=%d;direction=%d",
|
|
|
|
|
request.getCopies(), // 盖章事件分数,和打印份数一致
|
|
|
|
|
Objects.equals(request.getPagesource(), "A4") ? 1 : 2, // 打印类型1-A4或者2-A5
|
|
|
|
|
printType, // 打印类型1-A4或者2-A5
|
|
|
|
|
request.getStamp(), // 是否盖章
|
|
|
|
|
request.getFileDir(), // 要打印的文件的路径
|
|
|
|
|
request.getCopies(), // 盖章事件分数,和打印份数一致
|
|
|
|
@ -87,6 +101,10 @@ public class MS439PrintServiceImpl implements MS439PrintService {
|
|
|
|
|
lexMarkDTO.setParam(param.toString());
|
|
|
|
|
LexMarkResultDTO<LexMarkResultDTO.Param> paramLexMarkResultDTO = thirdService.callDevice(lexMarkDTO, LexMarkResultDTO.Param.class);
|
|
|
|
|
|
|
|
|
|
if ( paramLexMarkResultDTO.getData().getResult() != 0){
|
|
|
|
|
throw new RRException(500, paramLexMarkResultDTO.getData().getResult() + "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
File file = new File(request.getFileDir());
|
|
|
|
|
// 检查文件是否存在
|
|
|
|
|
if (file.exists()) {
|
|
|
|
@ -127,11 +145,11 @@ public class MS439PrintServiceImpl implements MS439PrintService {
|
|
|
|
|
String paperStatus = "";
|
|
|
|
|
// 如果是A4,当前是取第一层纸盒作为A4
|
|
|
|
|
if (papersource.equals("A4")) {
|
|
|
|
|
paperStatus = papers[0];
|
|
|
|
|
paperStatus = printerConfig.getLevelOne().equals("A4") ? papers[0] : papers[1];
|
|
|
|
|
}
|
|
|
|
|
// 如果是A5,当前是取第二层纸盒只作为A5
|
|
|
|
|
if (papersource.equals("A5")) {
|
|
|
|
|
paperStatus = papers[1];
|
|
|
|
|
paperStatus = printerConfig.getLevelOne().equals("A5") ? papers[0] : papers[1];
|
|
|
|
|
}
|
|
|
|
|
if ( !(paperStatus.equals(MS439PaperStatusEnum.PAPERFULL.getPrintCode()) || paperStatus.equals(MS439PaperStatusEnum.PAPERLOW.getPrintCode()))){
|
|
|
|
|
throw new RRException(500, paperStatus);
|
|
|
|
|