Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-03-27 12:45:45 +01:00
6 changed files with 22 additions and 19 deletions

View File

@@ -222,7 +222,7 @@ public class EmsController {
} else {
byte[] stream = Base64Utility.decodeBase64Zipped(encodedFile);
if (stream != null) {
printerService.print(printerName, new ByteArrayInputStream(stream), mimeType);
printerService.print(printerName, new ByteArrayInputStream(stream), mimeType, 1);
response = new ServiceRestResponse(EsitoType.OK);
} else {

View File

@@ -50,42 +50,42 @@ public class PrinterService {
public void print(String printerName, InputStream is, HashPrintRequestAttributeSet attrib, String mimeType) throws Exception {
PrintService myService = configPrinter(printerName);
printFileType(myService, is, attrib, mimeType);
printFileType(myService, is, attrib, mimeType, 1);
}
public void print(String printerName, String fileName, HashPrintRequestAttributeSet attrib, String mimeType) throws Exception {
PrintService myService = configPrinter(printerName);
FileInputStream fis = new FileInputStream(fileName);
printFileType(myService, fis, attrib, mimeType);
printFileType(myService, fis, attrib, mimeType, 1);
}
public void print(String printerName, InputStream is, String mimeType) throws Exception {
public void print(String printerName, InputStream is, String mimeType, int copies) throws Exception {
PrintService myService = configPrinter(printerName);
printFileType(myService, is, new HashPrintRequestAttributeSet(), mimeType);
printFileType(myService, is, new HashPrintRequestAttributeSet(), mimeType, copies);
}
public void print(String printerName, InputStream is, String mimeType, Orientation orientation) throws Exception {
PrintService myService = configPrinter(printerName);
printFileType(myService, is, new HashPrintRequestAttributeSet(), mimeType, orientation);
printFileType(myService, is, new HashPrintRequestAttributeSet(), mimeType, orientation, 1);
}
public void print(String printerName, InputStream is, HashPrintRequestAttributeSet attr, String mimeType, Orientation orientation) throws Exception {
PrintService myService = configPrinter(printerName);
printFileType(myService, is, attr, mimeType, orientation);
printFileType(myService, is, attr, mimeType, orientation, 1);
}
public void print(String printerName, String fileName, String mimeType) throws Exception {
PrintService myService = configPrinter(printerName);
FileInputStream fis = new FileInputStream(fileName);
printFileType(myService, fis, new HashPrintRequestAttributeSet(), mimeType);
printFileType(myService, fis, new HashPrintRequestAttributeSet(), mimeType, 1);
}
private void printFileType(PrintService myService, InputStream fis, HashPrintRequestAttributeSet attrib, String mimeType)
private void printFileType(PrintService myService, InputStream fis, HashPrintRequestAttributeSet attrib, String mimeType, int copies)
throws Exception {
printFileType(myService, fis, new HashPrintRequestAttributeSet(), mimeType, Orientation.AUTO);
printFileType(myService, fis, new HashPrintRequestAttributeSet(), mimeType, Orientation.AUTO, copies);
}
private void printFileType(PrintService myService, InputStream fis, HashPrintRequestAttributeSet attrib, String mimeType, Orientation orientation)
private void printFileType(PrintService myService, InputStream fis, HashPrintRequestAttributeSet attrib, String mimeType, Orientation orientation, int copies)
throws Exception {
if (mimeType != null && mimeType.endsWith("application/pdf")) {
try {
@@ -93,6 +93,7 @@ public class PrinterService {
PDDocument document = PDDocument.load(fis);
PrinterJob job = PrinterJob.getPrinterJob();
// job.setPageable(new PDFPageable(document,orientation));
job.setCopies(copies);
job.setPrintService(myService);
if (document.getNumberOfPages() > 0) {

View File

@@ -94,7 +94,7 @@ public class EmsEngineService {
numberOfCopies = numberOfCopies == null ? 1 : numberOfCopies;
for (int i = 0; i < numberOfCopies; i++) {
printerService.print(printerName, new ByteArrayInputStream(bytes), "application/pdf");
printerService.print(printerName, new ByteArrayInputStream(bytes), "application/pdf", 1);
}
return printerName;

View File

@@ -253,7 +253,7 @@ public class EuritmoImportService {
for (int a = 0; a < rifColloImported.size(); a++) {
HashMap<String, String> params = new HashMap<String, String>();
params.put("rif_ord", rifColloImported.get(a));
logisticService.printReport(reportName, params, 1, printerName);
logisticService.printReport(reportName, params, 1, printerName, 1);
}
}

View File

@@ -207,6 +207,7 @@ public class LogisticController {
public @ResponseBody
ServiceRestResponse printReport(@RequestParam String printerName,
@RequestParam int printQuantity,
@RequestParam(required = false, defaultValue = "1") int printCopies,
@RequestParam String reportName,
@RequestBody MultiValueMap<String, String> params) throws Exception {
@@ -219,9 +220,10 @@ public class LogisticController {
map.remove("profileDb");
map.remove("printerName");
map.remove("printQuantity");
map.remove("printCopies");
map.remove("reportName");
logisticService.printReport(reportName, map, printQuantity, printerName);
logisticService.printReport(reportName, map, printQuantity, printerName, printCopies);
return ServiceRestResponse.createPositiveResponse();
}
@@ -262,7 +264,7 @@ public class LogisticController {
ServiceRestResponse restResponse = ServiceRestResponse.createPositiveResponse();
try {
logisticService.printReport(reportName, params, printQuantity, printerName);
logisticService.printReport(reportName, params, printQuantity, printerName, 1);
} catch (EmptyReportException ex) {
restResponse.setErrorMessage(ex.getMessage());
}

View File

@@ -1088,7 +1088,7 @@ public class LogisticService {
zplSource = zplSource.replace("%%BARCODE%%", "000" + "01" + sdf2.format(dataCollo) + serie + UtilityString.leftPad(numCollo.toString(), 5, '0'));
printerService.print(printerName, new ByteArrayInputStream(zplSource.getBytes()), "text/plain");
printerService.print(printerName, new ByteArrayInputStream(zplSource.getBytes()), "text/plain", 1);
}
}
@@ -1328,7 +1328,7 @@ public class LogisticService {
public void printEtichettaBancale(String printerName, String encodedPdf) throws Exception {
byte[] stream = Base64Utility.decodeBase64Zipped(encodedPdf);
printerService.print(printerName, new ByteArrayInputStream(stream), null);
printerService.print(printerName, new ByteArrayInputStream(stream), null, 1);
}
public List<EntityBase> distribuzioneRigheCollo(String xmlCollo) throws Exception {
@@ -2089,7 +2089,7 @@ public class LogisticService {
return mtbColt;
}
public void printReport(String reportName, Map<String, String> params, int printQuantity, String printerName) throws Exception {
public void printReport(String reportName, Map<String, String> params, int printQuantity, String printerName, int printCopies) throws Exception {
List<PairsDTO> pairList = new ArrayList<PairsDTO>();
for (String key : params.keySet()) {
@@ -2107,7 +2107,7 @@ public class LogisticService {
throw new EmptyReportException();
}
for (int i = 0; i < printQuantity; i++) {
printerService.print(printerName, new ByteArrayInputStream(bytes), "application/pdf");
printerService.print(printerName, new ByteArrayInputStream(bytes), "application/pdf", printCopies);
}
}