insert columns
This commit is contained in:
parent
8790248d88
commit
2a12ecaf3c
2 changed files with 24 additions and 47 deletions
|
|
@ -114,6 +114,11 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
"missing Currency configuration - please check parameters");
|
||||
}
|
||||
|
||||
// compute all departments
|
||||
List<ItemCollection> 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<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.
|
||||
*
|
||||
* 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<String> currencyList) {
|
||||
if (currencyList == null || currencyList.size() <= 1) {
|
||||
// no extra currencies defined!
|
||||
return;
|
||||
}
|
||||
private void addCurrencyColumns(XSSFWorkbook doc, XSSFSheet sheet, List<String> currencyList,
|
||||
List<ItemCollection> 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,13 +213,20 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
// Beschriftungen eintragen
|
||||
int col = 1;
|
||||
XSSFCell cell = null;
|
||||
XSSFRow labelRow = sheet.getRow(10);
|
||||
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 = labelRow.getCell(col);
|
||||
cell = currencyRow.getCell(col);
|
||||
cell.setCellValue(currency);
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper method inserts a row for each invoice of the OPListe at row 16
|
||||
|
|
@ -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<ItemCollection> spaces)
|
||||
throws PluginException, QueryException {
|
||||
|
||||
Map<String, Double> totalsUeberfaelligCurrency1 = new HashMap<String, Double>();
|
||||
|
|
@ -270,11 +252,6 @@ public class OPListExportAdapterByWeek extends POIFindReplaceAdapter {
|
|||
Map<String, Double> totalsFaelligCurrency2 = new HashMap<String, Double>();
|
||||
List<String> spaceNames = new ArrayList<String>();
|
||||
|
||||
// compute all departments
|
||||
List<ItemCollection> spaces = teamService.getSpaces();
|
||||
// sort by space.name
|
||||
Collections.sort(spaces, new ItemCollectionComparator("space.name", true));
|
||||
|
||||
Map<String, WeekInvoiceData> weekDataMap = new HashMap<String, WeekInvoiceData>();
|
||||
FileData fileData = document.getFileData(fileName);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue