From a901dbefffe177fed332c31266f60a0be83fee72 Mon Sep 17 00:00:00 2001 From: zhousq Date: Sat, 3 Aug 2024 11:04:10 +0800 Subject: [PATCH] =?UTF-8?q?-024-08-03=20=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=9B=20=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=A0=BC=E5=BC=8F=E5=B1=9E=E6=80=A7=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/appstart.bat | 12 +++++++ .../print/WinPrintServerControler.java | 7 +++- win-admin/src/main/resources/application.yml | 2 +- win-admin/src/main/resources/logback.xml | 3 +- .../win/print/domain/WinPrintTasksLogs.java | 21 ++++++++++- .../win/print/service/PrintTaskProcesser.java | 5 ++- .../java/com/win/print/util/PdfPrintUtil.java | 25 ++++++++++++- .../java/com/win/print/util/PrinterUtil.java | 22 ++++++------ .../mapper/print/WinPrintTasksLogsMapper.xml | 4 ++- .../print/logmanager/logmanager.html | 36 ++++++++----------- .../templates/print/modelmanager/add.html | 3 +- .../templates/print/modelmanager/edit.html | 1 + .../print/modelmanager/modelmanager.html | 2 +- 13 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 bin/appstart.bat diff --git a/bin/appstart.bat b/bin/appstart.bat new file mode 100644 index 0000000..76e529d --- /dev/null +++ b/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 \ No newline at end of file diff --git a/win-admin/src/main/java/com/win/web/controller/print/WinPrintServerControler.java b/win-admin/src/main/java/com/win/web/controller/print/WinPrintServerControler.java index 1047939..cb8d505 100644 --- a/win-admin/src/main/java/com/win/web/controller/print/WinPrintServerControler.java +++ b/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; diff --git a/win-admin/src/main/resources/application.yml b/win-admin/src/main/resources/application.yml index 4133e80..f553d2f 100644 --- a/win-admin/src/main/resources/application.yml +++ b/win-admin/src/main/resources/application.yml @@ -40,7 +40,7 @@ server: # 鏃ュ織閰嶇疆 logging: level: - com.win: debug + com.win: info org.springframework: warn # 鐢ㄦ埛閰嶇疆 diff --git a/win-admin/src/main/resources/logback.xml b/win-admin/src/main/resources/logback.xml index aeb4ff7..35fa8f1 100644 --- a/win-admin/src/main/resources/logback.xml +++ b/win-admin/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + @@ -9,6 +9,7 @@ ${log.pattern} + UTF-8 diff --git a/win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java b/win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java index b40fbe5..3a9dcff 100644 --- a/win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java +++ b/win-print/src/main/java/com/win/print/domain/WinPrintTasksLogs.java @@ -83,7 +83,26 @@ public class WinPrintTasksLogs extends BaseEntity private String isPageRolated; private String taskId; private Integer copyCounts; - public void setTenantId(String tenantId) + 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; } diff --git a/win-print/src/main/java/com/win/print/service/PrintTaskProcesser.java b/win-print/src/main/java/com/win/print/service/PrintTaskProcesser.java index f88c5fd..c11093d 100644 --- a/win-print/src/main/java/com/win/print/service/PrintTaskProcesser.java +++ b/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); diff --git a/win-print/src/main/java/com/win/print/util/PdfPrintUtil.java b/win-print/src/main/java/com/win/print/util/PdfPrintUtil.java index e3f6ef0..4706507 100644 --- a/win-print/src/main/java/com/win/print/util/PdfPrintUtil.java +++ b/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(); + } + } } diff --git a/win-print/src/main/java/com/win/print/util/PrinterUtil.java b/win-print/src/main/java/com/win/print/util/PrinterUtil.java index 9dd78bf..163a276 100644 --- a/win-print/src/main/java/com/win/print/util/PrinterUtil.java +++ b/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; } diff --git a/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml b/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml index dac2f8c..227f552 100644 --- a/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml +++ b/win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml @@ -43,8 +43,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and print_type = #{printType} and model_code = #{modelCode} and request_type = #{requestType} - and print_setting_code = #{settingCode} + and task_id = #{taskId} + and printer_name like concat('%', #{printerName}, '%') + and print_time between #{printTimeStart} and #{printTimeEnd} order by created_time desc diff --git a/win-print/src/main/resources/templates/print/logmanager/logmanager.html b/win-print/src/main/resources/templates/print/logmanager/logmanager.html index 93cdf76..ab40347 100644 --- a/win-print/src/main/resources/templates/print/logmanager/logmanager.html +++ b/win-print/src/main/resources/templates/print/logmanager/logmanager.html @@ -12,8 +12,9 @@
  • - - + + +
  • @@ -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', diff --git a/win-print/src/main/resources/templates/print/modelmanager/add.html b/win-print/src/main/resources/templates/print/modelmanager/add.html index e780c14..3fcb194 100644 --- a/win-print/src/main/resources/templates/print/modelmanager/add.html +++ b/win-print/src/main/resources/templates/print/modelmanager/add.html @@ -101,7 +101,7 @@
    - +
@@ -238,6 +238,7 @@ var row = { index: $.table.serialNumber(count), paramCode: "", + paramName: "", paramDesc: "", paramType: "", } diff --git a/win-print/src/main/resources/templates/print/modelmanager/edit.html b/win-print/src/main/resources/templates/print/modelmanager/edit.html index d1cf1d6..e124c6f 100644 --- a/win-print/src/main/resources/templates/print/modelmanager/edit.html +++ b/win-print/src/main/resources/templates/print/modelmanager/edit.html @@ -215,6 +215,7 @@ var row = { index: $.table.serialNumber(count), paramCode: "", + paramName: "", paramDesc: "", paramType: "", } diff --git a/win-print/src/main/resources/templates/print/modelmanager/modelmanager.html b/win-print/src/main/resources/templates/print/modelmanager/modelmanager.html index 6c0fe24..203888d 100644 --- a/win-print/src/main/resources/templates/print/modelmanager/modelmanager.html +++ b/win-print/src/main/resources/templates/print/modelmanager/modelmanager.html @@ -113,7 +113,7 @@ }, { field: 'mFilename', - title: '妯$増鍦板潃' + title: '妯$増鏂囦欢鍚' }, { field: 'mPageSize',