Testprogramm für Frau Kück geschrieben
This commit is contained in:
parent
194c50eec8
commit
3ed2906009
2 changed files with 141 additions and 10 deletions
|
|
@ -33,6 +33,8 @@ import java.io.InputStream;
|
|||
import java.io.Serializable;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
|
@ -90,7 +92,7 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
int errors = 0;
|
||||
int count = 0;
|
||||
public static String _QUERY = "($modelversion:rechnungsausgang-de-1.0)\n" +
|
||||
"AND $created:[20240604 TO 20240701]";
|
||||
"AND $modified:[20240725 TO 20241231]";
|
||||
// public static String _QUERY = "($modelversion:rechnungsausgang-dwc-1.0)\n" +
|
||||
// //
|
||||
// "AND $created:[20240604 TO 20240619]";
|
||||
|
|
@ -132,14 +134,16 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
}
|
||||
|
||||
for (ItemCollection workitem : result) {
|
||||
String type = workitem.getItemValueString("invoice.type");
|
||||
if ("G".equals(type) || "SR".equals(type)) {
|
||||
double total = workitem.getItemValueDouble("invoice.saldo");
|
||||
if (total >= 0) {
|
||||
logger.info("---Falsch: " + workitem.getUniqueID());
|
||||
|
||||
// wir intesserien uns nur für den Schritt 5200.20
|
||||
// 2024-07-24T10:00:37.451|rechnungseingang-de-1.2|5200.20|0|
|
||||
List<String> evntLog = workitem.getItemValue("$eventlog");
|
||||
|
||||
for (String log : evntLog) {
|
||||
if (checkEventLogEntry(log)) {
|
||||
log = log + workitem.getItemValueString("invoice.number") + "; "
|
||||
+ workitem.getItemValueString("cdtr.name") + ";\n";
|
||||
falsch++;
|
||||
workitem.setItemValue("invoice.saldo", -total);
|
||||
// documentService.save(workitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -147,11 +151,39 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
|
||||
log = log + "\n\n";
|
||||
log = log + "" + result.size() + " rechnungen geprüft";
|
||||
log = log + "" + falsch + " davon falsch";
|
||||
log = log + "" + falsch + " davon betroffen";
|
||||
log = log + "\n\n";
|
||||
return log;
|
||||
}
|
||||
|
||||
// Methode, die überprüft, ob ein Eintrag die Bedingungen erfüllt
|
||||
private boolean checkEventLogEntry(String logEntry) {
|
||||
// Die gesuchte Zeichenkette
|
||||
String searchString = "|rechnungseingang-de-1.2|5200.20|";
|
||||
|
||||
// Prüfe, ob die Zeichenkette enthalten ist
|
||||
if (logEntry.contains(searchString)) {
|
||||
// Hole den Zeitstempel aus dem Log-Eintrag
|
||||
String timestampStr = logEntry.split("\\|")[0];
|
||||
|
||||
// Definiere das Format des Zeitstempels
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
|
||||
// Parse den Zeitstempel in ein LocalDateTime-Objekt
|
||||
LocalDateTime timestamp = LocalDateTime.parse(timestampStr, formatter);
|
||||
|
||||
// Definiere das Datum und die Zeitgrenzen für den 25.07.2024
|
||||
LocalDateTime startTime = LocalDateTime.of(2024, 7, 25, 7, 0);
|
||||
LocalDateTime endTime = LocalDateTime.of(2024, 7, 25, 15, 0);
|
||||
|
||||
// Überprüfe, ob der Zeitstempel im gewünschten Bereich liegt
|
||||
if (!timestamp.isBefore(startTime) && !timestamp.isAfter(endTime)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method fixes the wrong amount of a imported xml invoice.
|
||||
*
|
||||
|
|
@ -192,7 +224,7 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
}
|
||||
|
||||
@GET
|
||||
@Path("/fix")
|
||||
@Path("/xxxxxxxxxxxxxxxxxxxxxxxxxxfix")
|
||||
@Produces({ MediaType.TEXT_PLAIN })
|
||||
public String fixMissingRate()
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package com.alexanderlogistics.migration;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import org.imixs.melman.FormAuthenticator;
|
||||
import org.imixs.melman.RestAPIException;
|
||||
import org.imixs.melman.WorkflowClient;
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.PluginException;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Prüft alle rechnungen
|
||||
*
|
||||
* Können Sie mir bitte eine Liste zu kommen lassen, von allen
|
||||
* Gutschriften/Rechnungen die gestern (25.07.2024) gebucht worden sind im
|
||||
* Zeitraum von 07:00 Uhr bis 15:00 Uhr.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CargosoftExportAnalyse25Juli {
|
||||
|
||||
WorkflowClient workflowCLient = null;
|
||||
String user = "archive";
|
||||
String ps = "archive4imixs";
|
||||
String restAPI = "https://alexander-logistics.office-workflow.de/api/";
|
||||
int countProcessed = 0;
|
||||
int notFound = 0;
|
||||
int count = 0;
|
||||
|
||||
@Test
|
||||
public void test() throws PluginException, RestAPIException {
|
||||
|
||||
String query = "$modified:[20240725070000 TO 20241231150000]";
|
||||
|
||||
// Init Workflow Client
|
||||
workflowCLient = new WorkflowClient(restAPI);
|
||||
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
|
||||
workflowCLient.registerClientRequestFilter(formAuth);
|
||||
workflowCLient.setPageSize(10000);
|
||||
workflowCLient.setItems("invoice.number,$eventlog,$uniqueid,cdtr.name,$workflowsummary");
|
||||
try {
|
||||
List<ItemCollection> rechnungen = workflowCLient.searchDocuments(query);
|
||||
System.out.println("Fond " + rechnungen.size() + " invoices");
|
||||
for (ItemCollection workitem : rechnungen) {
|
||||
// System.out.println(" " + workitem.getUniqueID());
|
||||
|
||||
// wir intesserien uns nur für den Schritt 5200.20
|
||||
// 2024-07-24T10:00:37.451|rechnungseingang-de-1.2|5200.20|0|
|
||||
List<String> evntLog = workitem.getItemValue("$eventlog");
|
||||
|
||||
for (String log : evntLog) {
|
||||
if (checkEventLogEntry(log)) {
|
||||
String out = workitem.getItemValueString("$workflowsummary") + ";";
|
||||
System.out.println(out);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (RestAPIException | UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Finished");
|
||||
}
|
||||
|
||||
// Methode, die überprüft, ob ein Eintrag die Bedingungen erfüllt
|
||||
private boolean checkEventLogEntry(String logEntry) {
|
||||
// Die gesuchte Zeichenkette
|
||||
String searchString = "|rechnungseingang-de-1.2|5200.20|";
|
||||
// System.out.println(logEntry);
|
||||
// Prüfe, ob die Zeichenkette enthalten ist
|
||||
if (logEntry.contains(searchString)) {
|
||||
// Hole den Zeitstempel aus dem Log-Eintrag
|
||||
String timestampStr = logEntry.split("\\|")[0];
|
||||
|
||||
// Definiere das Format des Zeitstempels
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
|
||||
// Parse den Zeitstempel in ein LocalDateTime-Objekt
|
||||
LocalDateTime timestamp = LocalDateTime.parse(timestampStr, formatter);
|
||||
|
||||
// Definiere das Datum und die Zeitgrenzen für den 25.07.2024
|
||||
LocalDateTime startTime = LocalDateTime.of(2024, 7, 25, 7, 0);
|
||||
LocalDateTime endTime = LocalDateTime.of(2024, 7, 25, 15, 0);
|
||||
|
||||
// Überprüfe, ob der Zeitstempel im gewünschten Bereich liegt
|
||||
if (!timestamp.isBefore(startTime) && !timestamp.isAfter(endTime)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue