diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java index 6e9ce69..b0dd286 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/OPListExportAdapterByWeek.java @@ -114,6 +114,11 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { "missing Currency configuration - please check parameters"); } + // compute all departments + List spaces = teamService.getSpaces(); + // sort by space.name + Collections.sort(spaces, new ItemCollectionComparator("space.name", true)); + // read the template options ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "opliste", document, @@ -143,7 +148,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { XSSFSheet sheet = doc.getSheetAt(0); // first add the columns for the currency list - addCurrencyColumns(doc, sheet, currencyList); + addCurrencyColumns(doc, sheet, currencyList, spaces); // insertInvoiceRows(sheet, document, targetName, filter, currencyList); @@ -186,50 +191,20 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { 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 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. - * + * Hilfsmethode fügt die Spalten anhand der Währungen für jede Abteilung ein. * * @param sheet * @param currencyList */ - private void addCurrencyColumns(XSSFWorkbook doc, XSSFSheet sheet, List currencyList) { - if (currencyList == null || currencyList.size() <= 1) { - // no extra currencies defined! - return; - } + private void addCurrencyColumns(XSSFWorkbook doc, XSSFSheet sheet, List currencyList, + List spaces) { - // zusaetzliche Zellen einfuegen... - int newColumns = (currencyList.size() - 1) * 1; + // zusaetzliche spalten einfuegen... + int newColumns = (currencyList.size() * spaces.size()) - 1; for (int i = 0; i < newColumns; i++) { logger.fine(".. add currency column..."); POIUtil.insertColumn(sheet, 1, 2 + i); @@ -238,11 +213,18 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { // 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++; + XSSFRow spaceRow = sheet.getRow(9); + XSSFRow currencyRow = sheet.getRow(10); + for (ItemCollection space : spaces) { + // Set Abteilung Beschriftung + String name = space.getItemValueString("space.name"); + spaceRow.getCell(col).setCellValue(name); + // add currencies + for (String currency : currencyList) { + cell = currencyRow.getCell(col); + cell.setCellValue(currency); + col++; + } } } @@ -261,7 +243,7 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { * @throws QueryException */ private void insertInvoiceRows(ItemCollection document, String fileName, String currency1, - String currency2) + String currency2, List spaces) throws PluginException, QueryException { Map totalsUeberfaelligCurrency1 = new HashMap(); @@ -270,11 +252,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter { Map totalsFaelligCurrency2 = new HashMap(); List spaceNames = new ArrayList(); - // compute all departments - List spaces = teamService.getSpaces(); - // sort by space.name - Collections.sort(spaces, new ItemCollectionComparator("space.name", true)); - Map weekDataMap = new HashMap(); FileData fileData = document.getFileData(fileName); diff --git a/templates/op-liste_kw_template.xlsx b/templates/op-liste_kw_template.xlsx index 220211b..9d05546 100644 Binary files a/templates/op-liste_kw_template.xlsx and b/templates/op-liste_kw_template.xlsx differ