OP Liste bei KW - neues konzept

This commit is contained in:
Ralph Soika 2024-11-23 17:32:49 +01:00
parent 1bb65234fa
commit 8790248d88
6 changed files with 274 additions and 77 deletions

View file

@ -341,7 +341,6 @@ public class OPListExportAdapter extends POIFindReplaceAdapter {
}
// }
/**
* This method loads a text-block for a specified ref and appends the named
* fileData object of this document.

View file

@ -38,6 +38,8 @@ import org.imixs.workflow.exceptions.PluginException;
import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.office.config.ConfigService;
import org.imixs.workflow.poi.POIFindReplaceAdapter;
import org.imixs.workflow.poi.POIUtil;
import org.imixs.workflow.util.XMLParser;
import jakarta.inject.Inject;
@ -104,51 +106,144 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
public ItemCollection execute(ItemCollection document, ItemCollection event)
throws AdapterException, PluginException {
// read the opliste options
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "opliste", document, false);
if (evalItemCollection == null) {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), InvoiceService.ERROR_CONFIG,
"missing op-list configuration in model event - please check model configuration");
}
// ermittle die Hauptwährungen
ItemCollection configItemCollection = configService.loadConfiguration("AGL_CONFIGURATION");
List<String> currencyList = configItemCollection.getItemValue("currency.out");
if (currencyList == null || currencyList.size() < 2) {
if (currencyList == null || currencyList.size() < 1) {
throw new PluginException(OPListExportAdapter.class.getSimpleName(), InvoiceService.ERROR_CONFIG,
"missing Currency configuration - please check parameters");
}
String currency1 = currencyList.get(0);
String currency2 = currencyList.get(1);
String textblock = evalItemCollection.getItemValueString("textblock");
String template = evalItemCollection.getItemValueString("template");
String targetName = evalItemCollection.getItemValueString("target-name");
// read the template options
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "opliste",
document,
false);
if (evalItemCollection == null || !evalItemCollection.hasItem("excel-export")) {
throw new PluginException(OPListExportAdapter.class.getSimpleName(), CONFIG_ERROR,
"missing opliste configuration in model event - please check model configuration");
}
List<String> excelDefList = evalItemCollection.getItemValue("excel-export");
ItemCollection excelDefCollection = XMLParser.parseItemStructure(excelDefList.get(0));
String textblock = excelDefCollection.getItemValueString("textblock");
String template = excelDefCollection.getItemValueString("template");
String targetName = excelDefCollection.getItemValueString("target-name");
boolean filter = evalItemCollection.getItemValueBoolean("filter");
// adapt text....
targetName = workflowService.adaptText(targetName, document);
appendExcelTemplate(document, textblock, template, targetName);
logger.info("... loading poi configuration..");
// Process POI instructions
// read the config
ItemCollection poiConfig = workflowService.evalWorkflowResult(event, "poi-update", document, false);
if (poiConfig == null || !poiConfig.hasItem("findreplace")) {
throw new PluginException(POIFindReplaceAdapter.class.getSimpleName(), CONFIG_ERROR,
"missing poi configuration");
}
List<String> replaceDevList = poiConfig.getItemValue("findreplace");
String eval = poiConfig.getItemValueString("eval");
try {
logger.info("... update template with normal poi information..");
this.updateFileData(document.getFileData(targetName), document, replaceDevList, eval);
FileData fileData = appendExcelTemplate(document, textblock, template, targetName);
insertInvoiceRows(document, targetName, currency1, currency2);
} catch (PluginException | IOException | QueryException e) {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), InvoiceService.ERROR_CONFIG,
// get workbook
XSSFWorkbook doc = null;
try (InputStream imputStream = new ByteArrayInputStream(fileData.getContent())) {
doc = new XSSFWorkbook(imputStream);
// NOTE: we only take the first sheet !
XSSFSheet sheet = doc.getSheetAt(0);
// first add the columns for the currency list
addCurrencyColumns(doc, sheet, currencyList);
// insertInvoiceRows(sheet, document, targetName, filter, currencyList);
// write back the updated excel file
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
doc.write(byteArrayOutputStream);
byte[] newContent = byteArrayOutputStream.toByteArray();
FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(),
null);
document.addFileData(fileDataNew);
logger.finest("......new document added");
} catch (IOException e) {
throw new PluginException(OPListExportAdapter.class.getSimpleName(),
InvoiceService.ERROR_CONFIG,
"failed to update opliste: " + e.getMessage());
} finally {
if (doc != null) {
try {
doc.close();
} catch (IOException e) {
logger.severe("Failed to close workbook: " + e.getMessage());
e.printStackTrace();
}
}
}
// Finally process POI instructions
processPOIUpdate(document, event, targetName);
} catch (
PluginException e) {
throw new PluginException(OPListExportAdapter.class.getSimpleName(),
InvoiceService.ERROR_CONFIG,
"failed to update op-liste: " + e.getMessage());
}
logger.info("... completed!");
logger.fine("... completed!");
return document;
// logger.info("... loading poi configuration..");
// // Process POI instructions
// // read the config
// ItemCollection poiConfig = workflowService.evalWorkflowResult(event,
// "poi-update", document, false);
// if (poiConfig == null || !poiConfig.hasItem("findreplace")) {
// throw new PluginException(POIFindReplaceAdapter.class.getSimpleName(),
// CONFIG_ERROR,
// "missing poi configuration");
// }
// List<String> replaceDevList = poiConfig.getItemValue("findreplace");
// String eval = poiConfig.getItemValueString("eval");
// try {
// logger.info("... update template with normal poi information..");
// this.updateFileData(document.getFileData(targetName), document,
// replaceDevList, eval);
// insertInvoiceRows(document, targetName, currencyList.get(0),
// currencyList.get(1));
// } catch (PluginException | IOException | QueryException e) {
// throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(),
// InvoiceService.ERROR_CONFIG,
// "failed to update op-liste: " + e.getMessage());
// }
// logger.info("... completed!");
// return document;
}
/**
* EIne OP Liste kann für eine oder mehrere Währungen erstellt werden. Diese
* Hilfsmethode fügt die Spalten anhand der Währungen ein.
*
*
* @param sheet
* @param currencyList
*/
private void addCurrencyColumns(XSSFWorkbook doc, XSSFSheet sheet, List<String> currencyList) {
if (currencyList == null || currencyList.size() <= 1) {
// no extra currencies defined!
return;
}
// zusaetzliche Zellen einfuegen...
int newColumns = (currencyList.size() - 1) * 1;
for (int i = 0; i < newColumns; i++) {
logger.fine(".. add currency column...");
POIUtil.insertColumn(sheet, 1, 2 + i);
}
// Beschriftungen eintragen
int col = 1;
XSSFCell cell = null;
XSSFRow labelRow = sheet.getRow(10);
for (String currency : currencyList) {
cell = labelRow.getCell(col);
cell.setCellValue(currency);
col++;
}
}
/**
@ -529,12 +624,14 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
* @param document
* @throws PluginException
*/
private void appendExcelTemplate(ItemCollection document, String textblockRef, String template, String targetName)
private FileData appendExcelTemplate(ItemCollection document, String textblockRef, String template,
String targetName)
throws PluginException {
if ((template == null || template.isEmpty()) || (textblockRef == null || textblockRef.isEmpty())) {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), InvoiceService.ERROR_CONFIG,
"invalid op-list configuration in model event - textblock/template reference not defined!");
throw new PluginException(OPListExportAdapter.class.getSimpleName(),
InvoiceService.ERROR_CONFIG,
"invalid POI configuration in model event - textblock/template reference not defined!");
}
// load the text block
@ -542,15 +639,16 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
// do we found the document?
if (fileData == null) {
throw new PluginException(OPListExportAdapterByWeek.class.getSimpleName(), InvoiceService.ERROR_CONFIG,
"invalid op-list configuration in model event - template=" + template + " not found!");
throw new PluginException(OPListExportAdapter.class.getSimpleName(),
InvoiceService.ERROR_CONFIG,
"invalid POI configuration in model event - template=" + template
+ " not found!");
}
fileData.setName(targetName);
// append document
logger.info("...append new op-list Template: " + targetName);
logger.fine("...append new POI Template: " + targetName);
document.addFileData(fileData);
return fileData;
}
/**

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -100,6 +100,7 @@ th { font-weight: bold;}
<bpmn2:flowNodeRef>gateway_L9r5iA</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>gateway_37SSsw</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>textAnnotation_iPsg3g</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>event_opebWA</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:startEvent id="StartEvent_1" name="Start">
@ -219,36 +220,6 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<imixs:item name="txtnextprocesstree" type="xs:string">
<imixs:value/>
</imixs:item>
<imixs:item name="txtactivityresult" type="xs:string">
<imixs:value><![CDATA[<item name="action">home</item>
<item name="process">Mahnwesen</item>
<opliste name="textblock">OP-Liste Template</opliste>
<opliste name="template">op-liste_template.xlsx</opliste>
<opliste name="target-name">op-liste_<itemvalue>space.name</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</opliste>
<opliste name="filter">true</opliste>
<poi-update name="findreplace">
<find>C6</find>
<replace><itemvalue>sequencenumber</itemvalue></replace>
<type>text</type>
</poi-update>
<poi-update name="findreplace">
<find>D6</find>
<replace>Überfällig / 2. Mahnstufe</replace>
<type>text</type>
</poi-update>
<poi-update name="findreplace">
<find>C8</find>
<replace><itemvalue>space.name</itemvalue></replace>
<type>text</type>
</poi-update>
<poi-update name="findreplace">
<find>I6</find>
<replace><itemvalue format="dd.MM.yyyy">$lasteventdate</itemvalue></replace>
<type>date</type>
</poi-update>
]]></imixs:value>
</imixs:item>
<imixs:item name="txtname" type="xs:string">
<imixs:value><![CDATA[Speichern]]></imixs:value>
</imixs:item>
@ -265,6 +236,30 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<imixs:item name="keymailreceiverfields" type="xs:string">
<imixs:value><![CDATA[process.manager]]></imixs:value>
</imixs:item>
<imixs:item name="txtactivityresult" type="xs:string">
<imixs:value><![CDATA[<opliste name="excel-export">
<textblock>OP-Liste Template</textblock>
<template>op-liste_template.xlsx</template>
<target-name>op-liste_<itemvalue>dbtr.number</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</target-name>
</opliste>
<poi-update name="findreplace">
<find>C6</find>
<replace><itemvalue>sequencenumber</itemvalue></replace>
<type>text</type>
</poi-update>
<poi-update name="findreplace">
<find>B7</find>
<replace><itemvalue>space.name</itemvalue></replace>
<type>text</type>
</poi-update>
<poi-update name="findreplace">
<find>F6</find>
<replace><itemvalue format="dd.MM.yyyy">$lasteventdate</itemvalue></replace>
<type>date</type>
</poi-update>]]></imixs:value>
</imixs:item>
</bpmn2:extensionElements>
<bpmn2:documentation id="Documentation_1"><![CDATA[OP-Liste an Fachbereich versenden]]></bpmn2:documentation>
<bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>
@ -302,6 +297,7 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<bpmn2:outgoing>SequenceFlow_19</bpmn2:outgoing>
<bpmn2:incoming>Association_1</bpmn2:incoming>
<bpmn2:incoming>sequenceFlow_N0jfWA</bpmn2:incoming>
<bpmn2:incoming>sequenceFlow_QUQCFw</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_19" sourceRef="Task_4" targetRef="EndEvent_3">
<bpmn2:documentation id="documentation_AvvoyQ"/>
@ -432,18 +428,17 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
</imixs:item>
<imixs:item name="txtactivityresult" type="xs:string">
<imixs:value><![CDATA[<item name="process">Mahnwesen</item>
<opliste name="textblock">OP-Liste KW Template</opliste>
<opliste name="template">op-liste_kw_template.xlsx</opliste>
<opliste name="target-name">op-liste_<itemvalue>space.name</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</opliste>
<opliste name="excel-export">
<textblock>OP-Liste KW Template</textblock>
<template>op-liste_kw_template.xlsx</template>
<target-name>op-liste_<itemvalue>space.name</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</target-name>
</opliste>
<poi-update name="findreplace">
<find>I6</find>
<find>A8</find>
<replace><itemvalue format="dd.MM.yyyy">$lasteventdate</itemvalue></replace>
<type>date</type>
</poi-update>
<poi-update name="eval">I7</poi-update>
]]></imixs:value>
</imixs:item>
</bpmn2:extensionElements>
@ -491,6 +486,101 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<bpmn2:sequenceFlow id="sequenceFlow_N0jfWA" sourceRef="gateway_37SSsw" targetRef="Task_4">
<bpmn2:documentation id="documentation_N6ydlg"/>
</bpmn2:sequenceFlow>
<bpmn2:intermediateCatchEvent id="event_opebWA" imixs:activityid="110" name="[template]">
<bpmn2:extensionElements>
<imixs:item name="keylogtimeformat" type="xs:string">
<imixs:value><![CDATA[2]]></imixs:value>
</imixs:item>
<imixs:item name="keyarchive" type="xs:string">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="txtmailsubject" type="xs:string">
<imixs:value><![CDATA[Neue OP Liste: <itemvalue>sequencenumber</itemvalue> <itemvalue>space.name</itemvalue> - <itemvalue format="dd.MM.yyyy">$created</itemvalue>]]></imixs:value>
</imixs:item>
<imixs:item name="keyaccessmode" type="xs:string">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="keyscheduledactivity" type="xs:string">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="rtfmailbody" type="xs:string">
<imixs:value><![CDATA[<bpmn2:message>Html-Header</bpmn2:message>
<p>Hallo,</p>
<p>
Bitte prüfen Sie die angefügte OP-Liste. Diese enthält sämtlich noch offenen Rechnungen zum Zeitpunkt des Exports für diesen Fachbereich.
</p>
<p>
Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt" ab.
</p>
<a href="<propertyvalue>application.url</propertyvalue>pages/workitems/workitem.jsf?id=<itemvalue>$uniqueid</itemvalue>"><propertyvalue>application.url</propertyvalue>pages/workitems/workitem.jsf?id=<itemvalue>$uniqueid</itemvalue></a>
<attachments></attachments>
<bpmn2:message>Html-Footer</bpmn2:message>]]></imixs:value>
</imixs:item>
<imixs:item name="keyversion" type="xs:string">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="keyaddwritefields" type="xs:string"/>
<imixs:item name="numnextactivityid" type="xs:int">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="keyfollowup" type="xs:string">
<imixs:value><![CDATA[2]]></imixs:value>
</imixs:item>
<imixs:item name="keypublicresult" type="xs:string">
<imixs:value><![CDATA[1]]></imixs:value>
</imixs:item>
<imixs:item name="keylogdateformat" type="xs:string">
<imixs:value><![CDATA[2]]></imixs:value>
</imixs:item>
<imixs:item name="keyownershipfields" type="xs:string"/>
<imixs:item name="numnextid" type="xs:int">
<imixs:value><![CDATA[5000]]></imixs:value>
</imixs:item>
<imixs:item name="txtnextprocesstree" type="xs:string">
<imixs:value/>
</imixs:item>
<imixs:item name="txtname" type="xs:string">
<imixs:value><![CDATA[Speichern]]></imixs:value>
</imixs:item>
<imixs:item name="keyownershipmode" type="xs:string">
<imixs:value><![CDATA[0]]></imixs:value>
</imixs:item>
<imixs:item name="rtfresultlog" type="xs:string">
<imixs:value><![CDATA[OP Liste versendet]]></imixs:value>
</imixs:item>
<imixs:item name="keyupdateacl" type="xs:boolean">
<imixs:value>false</imixs:value>
</imixs:item>
<imixs:item name="nammailreceiver" type="xs:string"/>
<imixs:item name="keymailreceiverfields" type="xs:string">
<imixs:value><![CDATA[process.manager]]></imixs:value>
</imixs:item>
<imixs:item name="txtactivityresult" type="xs:string">
<imixs:value><![CDATA[<item name="process">Mahnwesen</item>
<opliste name="excel-export">
<textblock>OP-Liste KW Template</textblock>
<template>op-liste_kw_template.xlsx</template>
<target-name>op-liste_<itemvalue>space.name</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</target-name>
</opliste>
<poi-update name="findreplace">
<find>A8</find>
<replace><itemvalue format="dd.MM.yyyy">$lasteventdate</itemvalue></replace>
<type>date</type>
</poi-update>
]]></imixs:value>
</imixs:item>
</bpmn2:extensionElements>
<bpmn2:documentation id="documentation_R7BQyA"><![CDATA[OP-Liste an Fachbereich versenden]]></bpmn2:documentation>
<bpmn2:outputSet id="outputSet_Jvo8Aw" name="Output Set 2">
<bpmn2:dataOutputRefs>DataOutput_2</bpmn2:dataOutputRefs>
</bpmn2:outputSet>
<bpmn2:signalEventDefinition id="signalEventDefinition_mSqzzg" signalRef="signal_2"/>
<bpmn2:outgoing>sequenceFlow_QUQCFw</bpmn2:outgoing>
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="sequenceFlow_QUQCFw" sourceRef="event_opebWA" targetRef="Task_4">
<bpmn2:documentation id="documentation_SzbLsw"/>
</bpmn2:sequenceFlow>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
<bpmndi:BPMNPlane bpmnElement="Collaboration_1" id="BPMNPlane_1">
@ -671,6 +761,16 @@ Nach Prüfung schließen Sie bitte den Vorgang über die Schaltfläche "Erledigt
<di:waypoint x="900.0" y="435.0"/>
<di:waypoint x="960.0" y="435.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape bpmnElement="event_opebWA" id="BPMNShape_UXvSTA">
<dc:Bounds height="36.0" width="36.0" x="997.0" y="527.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_fGrzOg">
<dc:Bounds height="20.0" width="100.0" x="965.0" y="566.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_QUQCFw" id="BPMNEdge_3ROT5Q" sourceElement="BPMNShape_UXvSTA" targetElement="BPMNShape_Task_4">
<di:waypoint x="1015.0" y="527.0"/>
<di:waypoint x="1015.0" y="460.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0"/>