update migration agl

This commit is contained in:
Ralph Soika 2023-01-31 17:10:01 +01:00
parent d8e824f153
commit 5bc6225765
4 changed files with 243 additions and 78 deletions

View file

@ -340,20 +340,38 @@
</dependency> </dependency>
<!-- JUnit Tests -->
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId> <artifactId>javax.json-api</artifactId>
<version>1.1</version> <version>1.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish</groupId> <groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId> <artifactId>javax.json</artifactId>
<version>1.1</version> <version>1.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- JAX-RS 2.0 Test dependencies -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.30.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.3.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>imixs-melman</artifactId>
<version>1.0.22</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -237,13 +237,12 @@ public class OPListController implements Serializable {
public void updateChildList(ItemCollection workitem) { public void updateChildList(ItemCollection workitem) {
double paymentTotal = 0; double paymentTotal = 0;
List<Map> mapInvoiceItems = new ArrayList<Map>(); List<Map> mapInvoiceItems = new ArrayList<Map>();
// convert the child ItemCollection elements into a List of Map logger.fine("Convert child items into Map...");
logger.info("Convert child items into Map...");
// iterate over all order items.. // iterate over all order items..
List<String> selectionList = new ArrayList<String>(); List<String> selectionList = new ArrayList<String>();
for (ItemCollection invoice : invoiceList) { for (ItemCollection invoice : invoiceList) {
if (invoice.getItemValueBoolean("selected")) { if (invoice.getItemValueBoolean("selected")) {
logger.info("calculate - " + invoice.getUniqueID()); logger.fine("calculate - " + invoice.getUniqueID());
selectionList.add(invoice.getUniqueID()); selectionList.add(invoice.getUniqueID());
paymentTotal = paymentTotal + invoice.getItemValueDouble("payment.amount"); paymentTotal = paymentTotal + invoice.getItemValueDouble("payment.amount");
ItemCollection invoiceStub = new ItemCollection(); ItemCollection invoiceStub = new ItemCollection();

View file

@ -8,9 +8,15 @@ import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
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.imixs.workflow.exceptions.PluginException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -21,20 +27,41 @@ public class MigrationMahnerAusziffern {
List<Rechnung> rechnungen = new ArrayList<Rechnung>(); List<Rechnung> rechnungen = new ArrayList<Rechnung>();
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;
@Before @Before
public void setup() throws PluginException { public void setup() throws PluginException, RestAPIException {
List<Rechnung> rechnungen = new ArrayList<Rechnung>(); rechnungen = new ArrayList<Rechnung>();
// Init Workflow Client
workflowCLient = new WorkflowClient(restAPI);
FormAuthenticator formAuth = new FormAuthenticator(restAPI, user, ps);
workflowCLient.registerClientRequestFilter(formAuth);
ItemCollection ding = workflowCLient.getWorkitem("1ef4757f-69ae-4ec1-8ba1-01d380d046e7");
if (ding!=null) {
System.out.println("pip");
} else {
System.out.println("pap");
}
} }
/** /**
* Diese Test Method wandelt die Datei OPD_migration_230126.csv in eine EXTV * Diese Test Method wandelt die Datei OPD_migration_230126.csv in eine EXTV
* Datev Datei um, welche wir dann für einen einmaligen Import der * Datev Datei um, welche wir dann für einen einmaligen Import der
* Rechnugnsdaten verwenden können. * Rechnugnsdaten verwenden können.
* @throws PluginException
* @throws RestAPIException
* *
*/ */
@Test @Test
public void anlysiere() { public void anlysiere() throws RestAPIException, PluginException {
System.out.println("***********************"); System.out.println("***********************");
System.out.println("* OP Listen Auszifferliste *"); System.out.println("* OP Listen Auszifferliste *");
@ -57,10 +84,7 @@ public class MigrationMahnerAusziffern {
Assert.assertTrue(fieldnames.contains("Kontonummer")); Assert.assertTrue(fieldnames.contains("Kontonummer"));
String line; String line;
int count = 0;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
@ -73,17 +97,18 @@ public class MigrationMahnerAusziffern {
Assert.fail(); Assert.fail();
} }
analyzeLine(data,count); analyzeLine(data, count);
count++; count++;
// if (count>25) { // if (count>2800) {
// break; // break;
// } // }
} }
System.out.println("=================================================");
System.out.println("... fininshed - read " + count + " lines."); System.out.println("... fininshed - read " + count + " lines.");
System.out.println(" " + notFound + " Rechnungen nicht mehr aktiven Bestand");
System.out.println(" processed " + countProcessed + " Rechnungen in total");
} catch (IOException e) { } catch (IOException e) {
@ -101,29 +126,33 @@ public class MigrationMahnerAusziffern {
} }
} }
/** /**
* Prüft eine einzelen Datenzeile * Prüft eine einzelen Datenzeile
* *
* @param writer * @param writer
* @param data * @param data
* @throws IOException * @throws IOException
* @throws RestAPIException
* @throws PluginException
*/ */
private void analyzeLine(String[] data, int line) throws IOException { private void analyzeLine(String[] data, int line) throws IOException, RestAPIException, PluginException {
System.out.println("...line " + count);
String rechnungsNummer = data[2]; String rechnungsNummer = data[2];
String rechnungsDatum=data[3];
String faelligkeit=data[4];
String saldo=data[7];
String zahlung=data[6]; String rechnungsDatum = data[3];
String faelligkeit = data[4];
String saldo = data[7];
String zahlung = data[6];
// vertasuchen // vertasuchen
if (faelligkeit.length()==8) { if (faelligkeit.length() == 8) {
faelligkeit=faelligkeit.substring(4,8)+faelligkeit.substring(2,4)+faelligkeit.substring(0,2); faelligkeit = faelligkeit.substring(4, 8) + faelligkeit.substring(2, 4) + faelligkeit.substring(0, 2);
} else { } else {
faelligkeit="20230125"; faelligkeit = "20230125";
} }
String text=data[18]; String text = data[18];
String basisumsatz = "0,00"; String basisumsatz = "0,00";
String umsatz = data[5]; String umsatz = data[5];
if ("0,00".equals(umsatz)) { if ("0,00".equals(umsatz)) {
@ -150,53 +179,133 @@ public class MigrationMahnerAusziffern {
String gegenkonto = data[0]; String gegenkonto = data[0];
String konto = data[12]; String konto = data[12];
boolean skip=false; boolean skip = false;
// umdrehen von sh // umdrehen von sh
if ("\"H\"".equals(sh)) { if ("\"H\"".equals(sh)) {
sh="\"S\""; sh = "\"S\"";
} else { } else {
sh="\"H\""; sh = "\"H\"";
} }
// cache diese Information // cache diese Information
Rechnung rech=new Rechnung(gegenkonto,rechnungsNummer,umsatz,sh, wkz); Rechnung rech = new Rechnung(gegenkonto, rechnungsNummer, umsatz, sh, wkz);
Rechnung matchingRech=findMatch(rech); // nur wenn die Rechnung in Office ist
if (matchingRech!=null) { if (findRechnung(rech.rechnungsNummer)) {
System.out.println(" Bitte Ausziffern : "+rech.konto + " = " +rech.rechnungsNummer + " -> "+matchingRech.rechnungsNummer);
Rechnung matchingRech = findMatch(rech);
if (matchingRech != null) {
System.out.println("___________________________________________________");
System.out.println(" Bitte Ausziffern : " + rech.konto + " = " + rech.rechnungsNummer + " -> "
+ matchingRech.rechnungsNummer);
// Starte RestAPI call.....
processRechnungen(rech.rechnungsNummer, matchingRech.rechnungsNummer);
// matchingRech muss aus dem cach raus
boolean removeresult=rechnungen.remove(matchingRech);
if (removeresult==false) {
System.out.println(" ACHTUNG WIR haben ein Proboem ");
throw new PluginException("ERROR", "ERROR", "Nichzt im chache!!!!!!");
} }
//throw new PluginException("STOP", "STOP", "STOP!!!!!!");
} else {
// ab in den cache
rechnungen.add(rech); rechnungen.add(rech);
}
} else {
// die rechnung gibts nicht und es gibt nicths zu prüfen
}
} }
private boolean isEmpty(String data) { private boolean isEmpty(String data) {
return (data.isEmpty() || "\"\"".equals(data)); return (data.isEmpty() || "\"\"".equals(data));
} }
/**
* Diese Methode schließt die Rechnungen mit den übergebenen Rechnungsnummer ab
*
* Beispiel: Bitte Ausziffern : 17755 = "190818" -> "190313"
*
* @throws UnsupportedEncodingException
* @throws RestAPIException
* @throws PluginException
*/
private void processRechnungen(String rech1, String rech2) throws RestAPIException, UnsupportedEncodingException, PluginException {
// erstmal die Kanddaten suchen
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1
+ " OR invoice.number:" + rech2 + ")";
System.out.println(query);
List<ItemCollection> result = workflowCLient.searchDocuments(query);
if (result == null || result.size() != 2) {
System.out.println("Fehler - Rechnungen nicht gefunden!");
notFound=notFound+2;
return;
}
System.out.println("Ich beginne jetzt mit Gabys Workflow...");
ItemCollection rechItemCol=result.get(0);
rechItemCol.event(420);
workflowCLient.processWorkitem(rechItemCol);
rechItemCol=result.get(1);
rechItemCol.event(420);
workflowCLient.processWorkitem(rechItemCol);
countProcessed=countProcessed+2;
}
/** /**
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende Gegenrechnung gibt. * Teste ob es diese Rechnung im Office gibt.
*
* @param rech1
* @throws RestAPIException
* @throws UnsupportedEncodingException
* @throws PluginException
*/
private boolean findRechnung(String rech1) throws RestAPIException, UnsupportedEncodingException, PluginException {
// erstmal die Kanddaten suchen
String query = "type:workitem AND $modelversion:rechnungsausgang-de-1.0 AND (invoice.number:" + rech1+ ")";
//System.out.println(query);
List<ItemCollection> result = workflowCLient.searchDocuments(query);
if (result != null && result.size() == 1) {
//System.out.println(" OK - Rechnungen gefunden!");
return true;
}
return false;
}
/**
* Hilfsmethdoe die prüft ob es zu diesr Rechnung shcon eine passende
* Gegenrechnung gibt.
*
* @param rech * @param rech
* @return * @return
*/ */
private Rechnung findMatch(Rechnung rech) { private Rechnung findMatch(Rechnung rech) {
// gehen über all rechnungen und vergleiche alle eigenschaften // gehen über all rechnungen und vergleiche alle eigenschaften
for (Rechnung matchRech: rechnungen) { for (Rechnung matchRech : rechnungen) {
if (rech.rechnungsNummer.equals(matchRech.rechnungsNummer)) { if (rech.rechnungsNummer.equals(matchRech.rechnungsNummer)) {
System.out.println(" !! Rechnungsnummer Doppelt : " +rech.rechnungsNummer); System.out.println(" !! Rechnungsnummer Doppelt : " + rech.rechnungsNummer);
} }
if (rech.konto.equals(matchRech.konto ) if (rech.konto.equals(matchRech.konto) && rech.umsatz.equals(matchRech.umsatz)
&& rech.umsatz.equals(matchRech.umsatz) && rech.wkz.equals(matchRech.wkz) && !rech.sh.equals(matchRech.sh)) {
&& rech.wkz.equals(matchRech.wkz)
&& !rech.sh.equals(matchRech.sh)) {
// Hurrar wir habne eine treffer // Hurrar wir habne eine treffer
return matchRech; return matchRech;
} }
@ -213,6 +322,7 @@ public class MigrationMahnerAusziffern {
String umsatz; String umsatz;
String sh; String sh;
String wkz; String wkz;
public Rechnung(String konto, String rechnungsNummer, String umsatz, String sh, String wkz) { public Rechnung(String konto, String rechnungsNummer, String umsatz, String sh, String wkz) {
super(); super();
this.konto = konto; this.konto = konto;
@ -222,6 +332,37 @@ public class MigrationMahnerAusziffern {
this.wkz = wkz; this.wkz = wkz;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getEnclosingInstance().hashCode();
result = prime * result + Objects.hash(konto, rechnungsNummer, sh, umsatz, wkz);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Rechnung other = (Rechnung) obj;
if (!getEnclosingInstance().equals(other.getEnclosingInstance()))
return false;
return Objects.equals(konto, other.konto) && Objects.equals(rechnungsNummer, other.rechnungsNummer)
&& Objects.equals(sh, other.sh) && Objects.equals(umsatz, other.umsatz)
&& Objects.equals(wkz, other.wkz);
}
private MigrationMahnerAusziffern getEnclosingInstance() {
return MigrationMahnerAusziffern.this;
}
} }
} }

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 --> <!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.2.SNAPSHOT-v20200602-1600-B1" targetNamespace="http://www.imixs.org/bpmn2"> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext" xmlns:imixs="http://www.imixs.org/bpmn2" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1" targetNamespace="http://www.imixs.org/bpmn2">
<bpmn2:extensionElements> <bpmn2:extensionElements>
<imixs:item name="txtworkflowmodelversion" type="xs:string"> <imixs:item name="txtworkflowmodelversion" type="xs:string">
<imixs:value><![CDATA[rechnungsausgang-de-1.0]]></imixs:value> <imixs:value><![CDATA[rechnungsausgang-de-1.0]]></imixs:value>
@ -2278,6 +2278,7 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht</bpmn2:text>
<bpmn2:association id="Association_7" sourceRef="DataObject_2" targetRef="Task_5005"/> <bpmn2:association id="Association_7" sourceRef="DataObject_2" targetRef="Task_5005"/>
<bpmn2:association id="Association_8" sourceRef="DataObject_2" targetRef="Task_3"/> <bpmn2:association id="Association_8" sourceRef="DataObject_2" targetRef="Task_3"/>
<bpmn2:association id="Association_9" sourceRef="DataObject_2" targetRef="Task_4"/> <bpmn2:association id="Association_9" sourceRef="DataObject_2" targetRef="Task_4"/>
<bpmn2:association id="Association_10" sourceRef="DataObject_2" targetRef="Task_6"/>
</bpmn2:process> </bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="Collaboration_1"> <bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="Collaboration_1">
@ -2999,6 +3000,12 @@ Wiedervorlage wird um 7 bzw. 5 Tage erhöht</bpmn2:text>
<di:waypoint xsi:type="dc:Point" x="573.0" y="728.0"/> <di:waypoint xsi:type="dc:Point" x="573.0" y="728.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_93"/> <bpmndi:BPMNLabel id="BPMNLabel_93"/>
</bpmndi:BPMNEdge> </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_Association_10" bpmnElement="Association_10" sourceElement="BPMNShape_DataObject_1" targetElement="BPMNShape_Task_1">
<di:waypoint xsi:type="dc:Point" x="897.0" y="589.0"/>
<di:waypoint xsi:type="dc:Point" x="1410.0" y="589.0"/>
<di:waypoint xsi:type="dc:Point" x="1410.0" y="490.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_94"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane> </bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1"> <bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0"/> <dc:Font name="arial" size="9.0"/>