Browse Source

-024-08-03 增加日志的时间区间查询; 增加打印页面格式属性支持

master
zhousq 4 months ago
parent
commit
a901dbefff
  1. 12
      bin/appstart.bat
  2. 7
      win-admin/src/main/java/com/win/web/controller/print/WinPrintServerControler.java
  3. 2
      win-admin/src/main/resources/application.yml
  4. 3
      win-admin/src/main/resources/logback.xml
  5. 19
      win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java
  6. 5
      win-print/src/main/java/com/win/print/service/PrintTaskProcesser.java
  7. 25
      win-print/src/main/java/com/win/print/util/PdfPrintUtil.java
  8. 22
      win-print/src/main/java/com/win/print/util/PrinterUtil.java
  9. 4
      win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml
  10. 36
      win-print/src/main/resources/templates/print/logmanager/logmanager.html
  11. 3
      win-print/src/main/resources/templates/print/modelmanager/add.html
  12. 1
      win-print/src/main/resources/templates/print/modelmanager/edit.html
  13. 2
      win-print/src/main/resources/templates/print/modelmanager/modelmanager.html

12
bin/appstart.bat

@ -0,0 +1,12 @@
@echo off
echo.
echo 闻荫打印服务启动
echo.
cd %~dp0
echo 【chcp 65001】设置编码格式为UTF-8--
chcp 65001
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
D:\openjdk-21.0.1\bin\java %JAVA_OPTS% -Dfile.encoding=UTF-8 -jar win-admin.jar
echo 闻荫打印服务启动完成
cd bin
pause

7
win-admin/src/main/java/com/win/web/controller/print/WinPrintServerControler.java

@ -93,8 +93,9 @@ public class WinPrintServerControler extends BaseController {
Integer copyCounts = Optional.ofNullable(dataVo.getCopyCount()).orElse(1);
WinPrintModel winPrintModel = winPrintModelService.selectWinPrintModelByCode(modelCode);
if (ObjectUtil.isEmpty(winPrintModel)) {
return AjaxResult.error("打印失败!未找到指定模版!");
return AjaxResult.error("打印失败!未找到指定模版配置!");
}
//处理模版文件来源
String modelName = winPrintModel.getmFilename();
String modelType = winPrintModel.getmType();
@ -102,6 +103,10 @@ public class WinPrintServerControler extends BaseController {
String taskId=Optional.ofNullable(dataVo.getTaskId()).orElse(IdUtil.fastSimpleUUID());
String modelPage=winPrintModel.getmPageSize();
String isPageRolated=winPrintModel.getIsPageRotate();
String modeleDir = DataUnitl.getWorkingDir(templatePathDefault);
if (!FileUtil.exist(modeleDir+"/"+modelName) && !"STRING".equalsIgnoreCase(modelTypeSrc)) {
return AjaxResult.error("打印失败!未找到指定模版文件!");
}
int fontSize=Optional.ofNullable(winPrintModel.getFontSize()).orElse(14);
String fontName=Optional.ofNullable(winPrintModel.getFontName()).orElse("STSong-Light");
Date printeDate=null;

2
win-admin/src/main/resources/application.yml

@ -40,7 +40,7 @@ server:
# 日志配置
logging:
level:
com.win: debug
com.win: info
org.springframework: warn
# 用户配置

3
win-admin/src/main/resources/logback.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/ruoyi/logs" />
<property name="log.path" value="/logs" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
@ -9,6 +9,7 @@
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>

19
win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java

@ -83,6 +83,25 @@ public class WinPrintTasksLogs extends BaseEntity
private String isPageRolated;
private String taskId;
private Integer copyCounts;
private Date printTimeStart;
private Date printTimeEnd;
public Date getPrintTimeStart() {
return printTimeStart;
}
public void setPrintTimeStart(Date printTimeStart) {
this.printTimeStart = printTimeStart;
}
public Date getPrintTimeEnd() {
return printTimeEnd;
}
public void setPrintTimeEnd(Date printTimeEnd) {
this.printTimeEnd = printTimeEnd;
}
public void setTenantId(String tenantId)
{
this.tenantId = tenantId;

5
win-print/src/main/java/com/win/print/service/PrintTaskProcesser.java

@ -11,6 +11,7 @@ import com.win.print.util.PdfPrintUtil;
import com.win.print.util.PrinterUtil;
import com.win.print.util.WinPrintJobListener;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.printing.PDFPrintable;
import org.slf4j.Logger;
@ -63,7 +64,9 @@ public class PrintTaskProcesser {
PrintRequestAttributeSet printRequestAttribute = printerUtil.getPrintRequestAttribute(printAttribute,"winTask");
if("pdf".equalsIgnoreCase(type)){
PdfPrintUtil pdfPrintUtil=new PdfPrintUtil();
pdfPrintUtil.print(file,printService,printRequestAttribute);
//pdfPrintUtil.print(file,printService,printRequestAttribute);
pdfPrintUtil.print_page(file,printService,printRequestAttribute);
}else{
DocPrintJob pringJobByName = printService.createPrintJob();
Doc simpleDoc = new SimpleDoc(new FileInputStream(file), getDocFlavor(type), null);

25
win-print/src/main/java/com/win/print/util/PdfPrintUtil.java

@ -26,7 +26,7 @@ public class PdfPrintUtil {
}
job.setPrintable(pdfPrintable);
job.setJobName("标签打印");
job.setCopies(1);
//job.setCopies(1);
// 执行打印
job.print(attrs);
} catch (PrinterException printerException) {
@ -37,5 +37,28 @@ public class PdfPrintUtil {
}
}
public void print_page(File pdfFile, PrintService printService, PrintRequestAttributeSet attrs) throws IOException {
// 加载PDF文档
PDDocument document = PDDocument.load(pdfFile);
try {
// 创建一个打印任务
PrinterJob job = PrinterJob.getPrinterJob();
PDFPageable pdfPageable = new PDFPageable(document);
// 查找并设置打印机
if (printService != null) {
job.setPrintService(printService);
}
job.setPageable(pdfPageable);
job.setJobName("标签打印");
//job.setCopies(1);
// 执行打印
job.print(attrs);
} catch (PrinterException printerException) {
throw new RuntimeException(printerException);
} finally {
// 关闭PDF文档
document.close();
}
}
}

22
win-print/src/main/java/com/win/print/util/PrinterUtil.java

@ -65,18 +65,18 @@ public class PrinterUtil {
// 设置打印参数
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(atrrSet.getCopyCount())); //份数
// aset.add(atrrSet.getPaperType().getMediaSizeName());
aset.add(atrrSet.getPaperType().getMediaSizeName());
aset.add(new JobName(jobName,null));
// if (atrrSet.getIsDuplicates()) {
// aset.add(Sides.DUPLEX);//单双面
// } else {
// aset.add(Sides.ONE_SIDED);
// }
// if (atrrSet.getIsPortrait()) {
// aset.add(OrientationRequested.PORTRAIT);//横向
// } else {
// aset.add(OrientationRequested.LANDSCAPE);//纵向
// }
if (atrrSet.getIsDuplicates()) {
aset.add(Sides.DUPLEX);//单双面
} else {
aset.add(Sides.ONE_SIDED);
}
if (atrrSet.getIsPortrait()) {
aset.add(OrientationRequested.PORTRAIT);//横向
} else {
aset.add(OrientationRequested.LANDSCAPE);//纵向
}
return aset;
}

4
win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml

@ -43,8 +43,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="printType != null and printType != ''"> and print_type = #{printType}</if>
<if test="modelCode != null and modelCode != ''"> and model_code = #{modelCode}</if>
<if test="requestType != null and requestType != ''"> and request_type = #{requestType}</if>
<if test="settingCode != null and settingCode != ''"> and print_setting_code = #{settingCode}</if>
<if test="taskId != null and taskId != ''"> and task_id = #{taskId}</if>
<!-- <if test="settingCode != null and settingCode != ''"> and print_setting_code = #{settingCode}</if>-->
<if test="printerName != null and printerName != ''"> and printer_name like concat('%', #{printerName}, '%')</if>
<if test="printTimeStart != null and printTimeEnd != null"> and print_time between #{printTimeStart} and #{printTimeEnd}</if>
</where>
order by created_time desc
</select>

36
win-print/src/main/resources/templates/print/logmanager/logmanager.html

@ -12,8 +12,9 @@
<div class="select-list">
<ul>
<li>
<label>打印时间:</label>
<input type="text" class="time-input" placeholder="请选择打印时间" name="printTime"/>
<label>创建时间:</label>
<input type="text" class="time-input" placeholder="开始时间" name="printTimeStart" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
<input type="text" class="time-input" placeholder="结束时间" name="printTimeEnd" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
</li>
<li>
<label>任务ID:</label>
@ -96,19 +97,19 @@
title: 'id',
visible: false
},
{
field: 'clientCode',
title: '客户端编码'
},
{
field: 'taskId',
title: '任务ID'
},
{
field: 'modelCode',
title: '模版编码'
},
{
field: 'createdTime',
title: '创建时间'
},
{
field: 'printTime',
title: '打印时间'
@ -135,14 +136,14 @@
field: 'printerName',
title: '打印机名称'
},
// {
// field: 'settingCode',
// title: '打印配置'
// },
{
field: 'copyCounts',
title: '份数'
},
{
field: 'taskId',
title: '任务ID'
},
{
field: 'taskStatus',
title: '状态',
@ -159,17 +160,10 @@
}
},
// {
// field: 'requestType',
// title: '请求类型',
// formatter: function (value, row, index) {
// return $.table.selectDictLabel(requestTypeDatas, value);
// }
// field: 'ipAddr',
// title: '服务地址',
// visible: false
// },
{
field: 'ipAddr',
title: '服务地址',
visible: false
},
{
title: '操作',
align: 'center',

3
win-print/src/main/resources/templates/print/modelmanager/add.html

@ -101,7 +101,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">字体大小:</label>
<div class="col-sm-8">
<input name="fontSize" class="form-control" type="number" >
<input name="fontSize" class="form-control" type="number" value="18" >
</div>
</div>
</div>
@ -238,6 +238,7 @@
var row = {
index: $.table.serialNumber(count),
paramCode: "",
paramName: "",
paramDesc: "",
paramType: "",
}

1
win-print/src/main/resources/templates/print/modelmanager/edit.html

@ -215,6 +215,7 @@
var row = {
index: $.table.serialNumber(count),
paramCode: "",
paramName: "",
paramDesc: "",
paramType: "",
}

2
win-print/src/main/resources/templates/print/modelmanager/modelmanager.html

@ -113,7 +113,7 @@
},
{
field: 'mFilename',
title: '模版地址'
title: '模版文件名'
},
{
field: 'mPageSize',

Loading…
Cancel
Save