update - draft
This commit is contained in:
parent
1762c5c878
commit
b7011a5cf8
4 changed files with 388 additions and 261 deletions
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<artifactId>office-alexander-logistics</artifactId>
|
||||
<groupId>com.alexander-logistics</groupId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
</parent>
|
||||
<artifactId>office-alexander-logistics-app</artifactId>
|
||||
<packaging>war</packaging>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ 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;
|
||||
|
|
@ -61,255 +62,318 @@ import jakarta.inject.Inject;
|
|||
*/
|
||||
public class AGLAnalyticExcelAdapterDebitor extends POIFindReplaceAdapter {
|
||||
|
||||
private static Logger logger = Logger.getLogger(AGLAnalyticExcelAdapter.class.getName());
|
||||
private static Logger logger = Logger.getLogger(AGLAnalyticExcelAdapter.class.getName());
|
||||
|
||||
@Inject
|
||||
WorkflowService workflowService;
|
||||
@Inject
|
||||
WorkflowService workflowService;
|
||||
|
||||
@Inject
|
||||
OPListExportService opListExportService;
|
||||
@Inject
|
||||
OPListExportService opListExportService;
|
||||
|
||||
@Inject
|
||||
DocumentService documentService;
|
||||
@Inject
|
||||
DocumentService documentService;
|
||||
|
||||
@Inject
|
||||
ConfigService configService;
|
||||
@Inject
|
||||
ConfigService configService;
|
||||
|
||||
/**
|
||||
* This method
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ItemCollection execute(ItemCollection document, ItemCollection event)
|
||||
throws AdapterException, PluginException {
|
||||
/**
|
||||
* This method
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ItemCollection execute(ItemCollection document, ItemCollection event)
|
||||
throws AdapterException, PluginException {
|
||||
|
||||
// ermittle die Hauptwährungen
|
||||
ItemCollection configItemCollection = configService.loadConfiguration("AGL_CONFIGURATION");
|
||||
List<String> currencyList = configItemCollection.getItemValue("currency.out");
|
||||
if (currencyList == null || currencyList.size() < 2) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"missing Currency configuration - please check parameters");
|
||||
}
|
||||
|
||||
// read the Steuerbescheide options
|
||||
ItemCollection ausgangsrechnungConfig = workflowService.evalWorkflowResult(event, "soa",
|
||||
document,
|
||||
false);
|
||||
if (ausgangsrechnungConfig == null || !ausgangsrechnungConfig.hasItem("excel-export")) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapterDebitor.class.getSimpleName(), CONFIG_ERROR,
|
||||
"missing soa configuration in model event - please check model configuration");
|
||||
}
|
||||
List<String> excelDefList = ausgangsrechnungConfig.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");
|
||||
|
||||
// adapt text....
|
||||
targetName = workflowService.adaptText(targetName, document);
|
||||
|
||||
try {
|
||||
appendExcelTemplate(document, textblock, template, targetName);
|
||||
insertInvoiceRows(document, 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");
|
||||
|
||||
logger.info("... update template with normal poi information..");
|
||||
this.updateFileData(document.getFileData(targetName), document, replaceDevList, eval);
|
||||
|
||||
} catch (PluginException | IOException | QueryException e) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"failed to update steuerbescheide: " + e.getMessage());
|
||||
}
|
||||
logger.info("... completed!");
|
||||
return document;
|
||||
// ermittle die Hauptwährungen
|
||||
ItemCollection configItemCollection = configService.loadConfiguration("AGL_CONFIGURATION");
|
||||
List<String> currencyList = configItemCollection.getItemValue("currency.out");
|
||||
if (currencyList == null || currencyList.size() < 1) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"missing Currency configuration - please check parameters");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsmethode die das fuehrende K/D aus der Debitorennummer entfernt
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getDbtNr(ItemCollection workitem) {
|
||||
String dbtNr = workitem.getItemValueString("dbtr.number");
|
||||
if (dbtNr.startsWith("D") || dbtNr.startsWith("K")) {
|
||||
dbtNr = dbtNr.substring(1);
|
||||
}
|
||||
return dbtNr;
|
||||
// read the options
|
||||
ItemCollection ausgangsrechnungConfig = workflowService.evalWorkflowResult(event, "soa",
|
||||
document,
|
||||
false);
|
||||
if (ausgangsrechnungConfig == null || !ausgangsrechnungConfig.hasItem("excel-export")) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapterDebitor.class.getSimpleName(), CONFIG_ERROR,
|
||||
"missing soa configuration in model event - please check model configuration");
|
||||
}
|
||||
List<String> excelDefList = ausgangsrechnungConfig.getItemValue("excel-export");
|
||||
ItemCollection excelDefCollection = XMLParser.parseItemStructure(excelDefList.get(0));
|
||||
|
||||
/**
|
||||
* This helper method inserts a row for each invoice at row 16
|
||||
* into the excel template file
|
||||
* <p>
|
||||
* The method copies the Row A16 as a reference row
|
||||
* <p>
|
||||
* The named cell 'TOTAL' should contain the summary formula. It will be
|
||||
* evaluated at the end.
|
||||
*
|
||||
* @throws PluginException
|
||||
* @throws QueryException
|
||||
*/
|
||||
private void insertInvoiceRows(ItemCollection document, String fileName)
|
||||
throws PluginException, QueryException {
|
||||
String textblock = excelDefCollection.getItemValueString("textblock");
|
||||
String template = excelDefCollection.getItemValueString("template");
|
||||
String targetName = excelDefCollection.getItemValueString("target-name");
|
||||
|
||||
// load dummy rechnungen
|
||||
List<ItemCollection> invoices = loadInvoices(getDbtNr(document));
|
||||
// adapt text....
|
||||
targetName = workflowService.adaptText(targetName, document);
|
||||
|
||||
FileData fileData = document.getFileData(fileName);
|
||||
try {
|
||||
FileData fileData = appendExcelTemplate(document, textblock, template, targetName);
|
||||
|
||||
// load XSSFWorkbook
|
||||
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);
|
||||
CellReference invoiceRefCell = new CellReference("A11");
|
||||
XSSFRow referenceRowInvoice = sheet.getRow(invoiceRefCell.getRow());
|
||||
int referenceRowPos = 10;
|
||||
int rowPos = referenceRowPos;
|
||||
int lastRow = 2999;
|
||||
logger.finest("Last rownum=" + lastRow);
|
||||
// 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);
|
||||
|
||||
// jetzt füge alle Rechnungen an.
|
||||
int totalRowCount = invoices.size();
|
||||
sheet.shiftRows(referenceRowPos, lastRow, totalRowCount, true, true);
|
||||
for (ItemCollection invoice : invoices) {
|
||||
logger.fine("......add invoice " + invoice.getUniqueID());
|
||||
// now create a new line..
|
||||
XSSFRow row = sheet.createRow(rowPos);
|
||||
row.copyRowFrom(referenceRowInvoice, new CellCopyPolicy());
|
||||
// insert values
|
||||
row.getCell(0)
|
||||
.setCellValue(invoice.getItemValueDate("$created"));
|
||||
row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("invoice.number"));
|
||||
row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDate("invoice.date"));
|
||||
row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDate("invoice.duedate"));
|
||||
row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("space.name"));
|
||||
row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("invoice.text"));
|
||||
// first add the columns for the currency list
|
||||
addCurrencyColumns(sheet, currencyList);
|
||||
|
||||
// Waehrung?
|
||||
if (invoice.getItemValueDouble("invoice.rate") == 0) {
|
||||
row.getCell(6, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.total"));
|
||||
row.getCell(7, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.saldo"));
|
||||
} else {
|
||||
row.getCell(8, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.total"));
|
||||
row.getCell(9, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.saldo"));
|
||||
}
|
||||
row.getCell(10, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("$workflowstatus"));
|
||||
// insertInvoiceRows(document, targetName);
|
||||
|
||||
rowPos++;
|
||||
}
|
||||
// write back the updated excel file
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
doc.write(byteArrayOutputStream);
|
||||
|
||||
// Leerzeile
|
||||
// categoryRow = sheet.createRow(rowPos);
|
||||
rowPos++;
|
||||
byte[] newContent = byteArrayOutputStream.toByteArray();
|
||||
FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(),
|
||||
null);
|
||||
document.addFileData(fileDataNew);
|
||||
logger.finest("......new document added");
|
||||
|
||||
// write back the file
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
doc.write(byteArrayOutputStream);
|
||||
|
||||
byte[] newContent = byteArrayOutputStream.toByteArray();
|
||||
FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(),
|
||||
null);
|
||||
// update the fileData
|
||||
document.addFileData(fileDataNew);
|
||||
|
||||
logger.finest("......new document added");
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method loads a text-block for a specified ref and appends the named
|
||||
* fileData object of this document.
|
||||
*
|
||||
* @param document
|
||||
* @throws PluginException
|
||||
*/
|
||||
private void appendExcelTemplate(ItemCollection document, String textblockRef, String template,
|
||||
String targetName)
|
||||
throws PluginException {
|
||||
|
||||
if ((template == null || template.isEmpty()) || (textblockRef == null || textblockRef.isEmpty())) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"invalid SOA configuration in model event - textblock/template reference not defined!");
|
||||
}
|
||||
|
||||
// load the text block
|
||||
FileData fileData = opListExportService.loadTextBlockFileData(textblockRef, template);
|
||||
|
||||
// do we found the document?
|
||||
if (fileData == null) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"invalid SOA configuration in model event - template=" + template
|
||||
+ " not found!");
|
||||
}
|
||||
fileData.setName(targetName);
|
||||
// append document
|
||||
logger.info("...append new SOA Template: " + targetName);
|
||||
document.addFileData(fileData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode läd alle offenen Steuerbescheide
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<ItemCollection> loadInvoices(String dbtrNumber) {
|
||||
List<ItemCollection> result = new ArrayList<>();
|
||||
|
||||
String query = "(type:workitem) AND dbtr.number:" + dbtrNumber
|
||||
+ " AND $modelversion:rechnungsausgang-*";
|
||||
try {
|
||||
result = documentService.find(
|
||||
query, 9999, 0,
|
||||
"invoice.number", false);
|
||||
} catch (QueryException e) {
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.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();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Process POI instructions
|
||||
// processPOIUpdate(document, event, targetName);
|
||||
// // 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");
|
||||
|
||||
// logger.info("... update template with normal poi information..");
|
||||
// this.updateFileData(document.getFileData(targetName), document,
|
||||
// replaceDevList, eval);
|
||||
|
||||
} catch (PluginException e) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"failed to update steuerbescheide: " + e.getMessage());
|
||||
}
|
||||
logger.info("... completed!");
|
||||
return document;
|
||||
}
|
||||
|
||||
/**
|
||||
* A SOA can be created for one or multiple currencies. This helper method adds
|
||||
* the Total and Saldo Colum for each currency
|
||||
*
|
||||
* The template provided only the columns for the first currency.
|
||||
*
|
||||
* @param sheet
|
||||
* @param currencyList
|
||||
*/
|
||||
private void addCurrencyColumns(XSSFSheet sheet, List<String> currencyList) {
|
||||
if (currencyList == null || currencyList.size() <= 1) {
|
||||
// no extra currencies defined!
|
||||
return;
|
||||
}
|
||||
int newColumns = (currencyList.size() - 1) * 2;
|
||||
|
||||
for (int i = 0; i < newColumns; i++) {
|
||||
logger.info(".. add currency column...");
|
||||
POIUtil.insertColumn(sheet, 6, 8 + i);
|
||||
// POIUtil.insertColumn(sheet, 6, 8 + i+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsmethode die das fuehrende K/D aus der Debitorennummer entfernt
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getDbtNr(ItemCollection workitem) {
|
||||
String dbtNr = workitem.getItemValueString("dbtr.number");
|
||||
if (dbtNr.startsWith("D") || dbtNr.startsWith("K")) {
|
||||
dbtNr = dbtNr.substring(1);
|
||||
}
|
||||
return dbtNr;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper method inserts a row for each invoice at row 16
|
||||
* into the excel template file
|
||||
* <p>
|
||||
* The method copies the Row A16 as a reference row
|
||||
* <p>
|
||||
* The named cell 'TOTAL' should contain the summary formula. It will be
|
||||
* evaluated at the end.
|
||||
*
|
||||
* @throws PluginException
|
||||
* @throws QueryException
|
||||
*/
|
||||
private void insertInvoiceRows(ItemCollection document, String fileName)
|
||||
throws PluginException, QueryException {
|
||||
|
||||
// load dummy rechnungen
|
||||
List<ItemCollection> invoices = loadInvoices(getDbtNr(document));
|
||||
|
||||
FileData fileData = document.getFileData(fileName);
|
||||
|
||||
// load XSSFWorkbook
|
||||
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);
|
||||
CellReference invoiceRefCell = new CellReference("A11");
|
||||
XSSFRow referenceRowInvoice = sheet.getRow(invoiceRefCell.getRow());
|
||||
int referenceRowPos = 10;
|
||||
int rowPos = referenceRowPos;
|
||||
int lastRow = 2999;
|
||||
logger.finest("Last rownum=" + lastRow);
|
||||
|
||||
// jetzt füge alle Rechnungen an.
|
||||
int totalRowCount = invoices.size();
|
||||
sheet.shiftRows(referenceRowPos, lastRow, totalRowCount, true, true);
|
||||
for (ItemCollection invoice : invoices) {
|
||||
logger.fine("......add invoice " + invoice.getUniqueID());
|
||||
// now create a new line..
|
||||
XSSFRow row = sheet.createRow(rowPos);
|
||||
row.copyRowFrom(referenceRowInvoice, new CellCopyPolicy());
|
||||
// insert values
|
||||
row.getCell(0)
|
||||
.setCellValue(invoice.getItemValueDate("$created"));
|
||||
row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("invoice.number"));
|
||||
row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDate("invoice.date"));
|
||||
row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDate("invoice.duedate"));
|
||||
row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("space.name"));
|
||||
row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("invoice.text"));
|
||||
|
||||
// Waehrung?
|
||||
if (invoice.getItemValueDouble("invoice.rate") == 0) {
|
||||
row.getCell(6, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.total"));
|
||||
row.getCell(7, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.saldo"));
|
||||
} else {
|
||||
row.getCell(8, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.total"));
|
||||
row.getCell(9, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueDouble("invoice.saldo"));
|
||||
}
|
||||
row.getCell(10, MissingCellPolicy.CREATE_NULL_AS_BLANK)
|
||||
.setCellValue(invoice.getItemValueString("$workflowstatus"));
|
||||
|
||||
rowPos++;
|
||||
}
|
||||
|
||||
// Leerzeile
|
||||
// categoryRow = sheet.createRow(rowPos);
|
||||
rowPos++;
|
||||
|
||||
// write back the file
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
doc.write(byteArrayOutputStream);
|
||||
|
||||
byte[] newContent = byteArrayOutputStream.toByteArray();
|
||||
FileData fileDataNew = new FileData(fileData.getName(), newContent, fileData.getContentType(),
|
||||
null);
|
||||
// update the fileData
|
||||
document.addFileData(fileDataNew);
|
||||
|
||||
logger.finest("......new document added");
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method loads a text-block for a specified ref and appends the named
|
||||
* fileData object of this document.
|
||||
*
|
||||
* @param document
|
||||
* @throws PluginException
|
||||
*/
|
||||
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(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"invalid SOA configuration in model event - textblock/template reference not defined!");
|
||||
}
|
||||
|
||||
// load the text block
|
||||
FileData fileData = opListExportService.loadTextBlockFileData(textblockRef, template);
|
||||
|
||||
// do we found the document?
|
||||
if (fileData == null) {
|
||||
throw new PluginException(AGLAnalyticExcelAdapter.class.getSimpleName(),
|
||||
OPListExportService.ERROR_CONFIG,
|
||||
"invalid SOA configuration in model event - template=" + template
|
||||
+ " not found!");
|
||||
}
|
||||
fileData.setName(targetName);
|
||||
// append document
|
||||
logger.info("...append new SOA Template: " + targetName);
|
||||
document.addFileData(fileData);
|
||||
return fileData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode läd alle offenen Steuerbescheide
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<ItemCollection> loadInvoices(String dbtrNumber) {
|
||||
List<ItemCollection> result = new ArrayList<>();
|
||||
|
||||
String query = "(type:workitem) AND dbtr.number:" + dbtrNumber
|
||||
+ " AND $modelversion:rechnungsausgang-*";
|
||||
try {
|
||||
result = documentService.find(
|
||||
query, 9999, 0,
|
||||
"invoice.number", false);
|
||||
} catch (QueryException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
4
pom.xml
4
pom.xml
|
|
@ -5,7 +5,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.alexander-logistics</groupId>
|
||||
<artifactId>office-alexander-logistics</artifactId>
|
||||
<version>1.3.0</version>
|
||||
<version>1.3.1</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Imixs Office Workflow - Custom Build</name>
|
||||
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
<org.imixs.workflow.version>6.0.9-SNAPSHOT</org.imixs.workflow.version>
|
||||
<org.imixs.marty.version>5.0.0</org.imixs.marty.version>
|
||||
<org.imixs.archive.version>3.0.2</org.imixs.archive.version>
|
||||
<org.imixs.adapters.version>3.0.2</org.imixs.adapters.version>
|
||||
<org.imixs.adapters.version>3.0.3-SNAPSHOT</org.imixs.adapters.version>
|
||||
<org.imixs.melman.version>2.0.2</org.imixs.melman.version>
|
||||
<microprofile.version>6.0</microprofile.version>
|
||||
<net.sf.saxon.version>9.9.1-4</net.sf.saxon.version>
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ th { font-weight: bold;}
|
|||
<bpmn2:flowNodeRef>DataObject_1</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>event_HrHS9A</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>dataObject_00mX6w</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>event_n40tzw</bpmn2:flowNodeRef>
|
||||
</bpmn2:lane>
|
||||
</bpmn2:laneSet>
|
||||
<bpmn2:startEvent id="StartEvent_1" name="Start">
|
||||
|
|
@ -124,6 +125,7 @@ th { font-weight: bold;}
|
|||
<bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing>
|
||||
<bpmn2:incoming>sequenceFlow_OL83kQ</bpmn2:incoming>
|
||||
<bpmn2:incoming>sequenceFlow_1K0l0g</bpmn2:incoming>
|
||||
<bpmn2:incoming>sequenceFlow_P2Q9fQ</bpmn2:incoming>
|
||||
</bpmn2:task>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow_10" sourceRef="Task_2" targetRef="EndEvent_3">
|
||||
<bpmn2:documentation id="documentation_WzPj2A"/>
|
||||
|
|
@ -322,36 +324,7 @@ th { font-weight: bold;}
|
|||
<target-name>soa_<itemvalue>dbtr.number</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</target-name>
|
||||
</soa>
|
||||
|
||||
<poi-update name="findreplace">
|
||||
<find>I6</find>
|
||||
<replace><itemvalue format="dd.MM.yyyy">$lasteventdate</itemvalue></replace>
|
||||
<type>date</type>
|
||||
</poi-update>
|
||||
<poi-update name="findreplace">
|
||||
<find>D6</find>
|
||||
<replace><itemvalue>dbtr.name</itemvalue></replace>
|
||||
<type>date</type>
|
||||
</poi-update>
|
||||
<poi-update name="findreplace">
|
||||
<find>G10</find>
|
||||
<replace>Total EUR</replace>
|
||||
</poi-update>
|
||||
<poi-update name="findreplace">
|
||||
<find>H10</find>
|
||||
<replace>Saldo EUR</replace>
|
||||
</poi-update>
|
||||
<poi-update name="findreplace">
|
||||
<find>I10</find>
|
||||
<replace>Total USD</replace>
|
||||
</poi-update>
|
||||
<poi-update name="findreplace">
|
||||
<find>J10</find>
|
||||
<replace>Saldo USD</replace>
|
||||
</poi-update>
|
||||
|
||||
|
||||
|
||||
<poi-update name="eval">TOTAL1;TOTAL2;TOTAL3;TOTAL4</poi-update>
|
||||
]]></imixs:value>
|
||||
</imixs:item>
|
||||
</bpmn2:extensionElements>
|
||||
|
|
@ -391,6 +364,84 @@ th { font-weight: bold;}
|
|||
<bpmn2:sequenceFlow id="sequenceFlow_LhcuMQ" sourceRef="Task_1" targetRef="event_HrHS9A">
|
||||
<bpmn2:documentation id="documentation_Ll2kVg"/>
|
||||
</bpmn2:sequenceFlow>
|
||||
<bpmn2:intermediateCatchEvent id="event_n40tzw" imixs:activityid="201" name="Excel Export">
|
||||
<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/>
|
||||
</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/>
|
||||
</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[Analysedaten Debitor archiviert]]></imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="keyupdateacl" type="xs:boolean">
|
||||
<imixs:value>false</imixs:value>
|
||||
</imixs:item>
|
||||
<imixs:item name="txtactivityresult" type="xs:string">
|
||||
<imixs:value><![CDATA[<soa name="excel-export">
|
||||
<textblock>SOA Template</textblock>
|
||||
<template>soa_template.xlsx</template>
|
||||
<target-name>soa_<itemvalue>dbtr.number</itemvalue>_<itemvalue format="yyyy-MM-dd">$lasteventdate</itemvalue>.xlsx</target-name>
|
||||
</soa>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]]></imixs:value>
|
||||
</imixs:item>
|
||||
</bpmn2:extensionElements>
|
||||
<bpmn2:documentation id="documentation_naV7Kg"><![CDATA[Excel Datei erzeugen]]></bpmn2:documentation>
|
||||
<bpmn2:signalEventDefinition id="signalEventDefinition_0WFWhQ" signalRef="Signal_1"/>
|
||||
<bpmn2:outgoing>sequenceFlow_P2Q9fQ</bpmn2:outgoing>
|
||||
</bpmn2:intermediateCatchEvent>
|
||||
<bpmn2:sequenceFlow id="sequenceFlow_P2Q9fQ" sourceRef="event_n40tzw" targetRef="Task_2">
|
||||
<bpmn2:documentation id="documentation_J7LEZw"/>
|
||||
</bpmn2:sequenceFlow>
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
|
||||
<bpmndi:BPMNPlane bpmnElement="Collaboration_1" id="BPMNPlane_1">
|
||||
|
|
@ -494,6 +545,18 @@ th { font-weight: bold;}
|
|||
<di:waypoint x="349.0" y="395.0"/>
|
||||
<di:waypoint x="467.0" y="395.0"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape bpmnElement="event_n40tzw" id="BPMNShape_0HF6DQ">
|
||||
<dc:Bounds height="36.0" width="36.0" x="741.0" y="224.0"/>
|
||||
<bpmndi:BPMNLabel id="BPMNLabel_QA6zUg">
|
||||
<dc:Bounds height="20.0" width="100.0" x="709.0" y="263.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_P2Q9fQ" id="BPMNEdge_v9l7hQ" sourceElement="BPMNShape_0HF6DQ" targetElement="BPMNShape_Task_2">
|
||||
<di:waypoint x="741.0" y="242.0"/>
|
||||
<di:waypoint x="710.5" y="242.0"/>
|
||||
<di:waypoint x="710.5" y="315.0"/>
|
||||
<di:waypoint x="680.0" y="315.0"/>
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
|
||||
<dc:Font name="arial" size="9.0"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue