Search in sources :

Example 6 with TempCalcDocument

use of eu.ggnet.lucidcalc.TempCalcDocument in project dwoss by gg-net.

the class AuditReporterOperation method onRollIn.

/**
 * Returns an audit report of units which are input between the dates.
 * <p/>
 * @return an audit report of units which are input between the dates.
 */
@Override
public FileJacket onRollIn() {
    SubMonitor m = monitorFactory.newSubMonitor("AuditReport", 100);
    m.message("loading UniqueUnits");
    m.start();
    List<StockTransaction> rollInTransactions = new StockTransactionEao(stocks.getEntityManager()).findByTypeAndStatus(StockTransactionType.ROLL_IN, StockTransactionStatusType.PREPARED);
    List<Integer> uuIds = toUniqueUnitIds(rollInTransactions);
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uus.getEntityManager()).findByIds(uuIds);
    m.worked(5, "preparing Document");
    List<Object[]> rows = new ArrayList<>();
    for (UniqueUnit uu : uniqueUnits) {
        rows.add(new Object[] { uu.getRefurbishId(), uu.getProduct().getGroup().getNote(), uu.getProduct().getPartNo(), uu.getSerial(), ProductFormater.toName(uu.getProduct()), uu.getContractor(), UniqueUnitFormater.toSingleLineAccessories(uu), UniqueUnitFormater.toSingleLineComment(uu), UniqueUnitFormater.toSingleLineInternalComment(uu), uu.getCondition().getNote(), uu.getShipmentLabel(), uu.getProduct().getDescription(), "" });
    }
    CSheet sheet = new CSheet("Audit");
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("SopoNr", 7)).add(new STableColumn("Warengruppe", 13)).add(new STableColumn("ArtikelNr", 15)).add(new STableColumn("Seriennummer", 27));
    table.add(new STableColumn("Name", 30)).add(new STableColumn("Lieferant", 12)).add(new STableColumn("Zubehör", 50)).add(new STableColumn("Bemerkung", 50));
    table.add(new STableColumn("Interne Bemerkung", 30)).add(new STableColumn("Zustand", 12)).add(new STableColumn("Shipment", 12)).add(new STableColumn("Beschreibung", 50));
    table.setModel(new STableModelList(rows));
    sheet.addBelow(table);
    CCalcDocument document = new TempCalcDocument();
    document.add(sheet);
    FileJacket fj = new FileJacket("Audit", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document));
    m.finish();
    return fj;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ArrayList(java.util.ArrayList) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) StockTransactionEao(eu.ggnet.dwoss.stock.ee.eao.StockTransactionEao) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder) StockTransaction(eu.ggnet.dwoss.stock.ee.entity.StockTransaction)

Example 7 with TempCalcDocument

use of eu.ggnet.lucidcalc.TempCalcDocument in project dwoss by gg-net.

the class AuditReporterOperation method byRange.

/**
 * Returns an audit report of units which are on a roll in transaction, but not yet rolled in.
 * <p/>
 * @return an audit report of units which are on a roll in transaction, but not yet rolled in.
 */
@Override
public FileJacket byRange(Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("AuditReport", 100);
    m.message("loading UniqueUnits");
    m.start();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uus.getEntityManager()).findBetweenInputDates(start, end);
    m.worked(5, "preparing Document");
    List<Object[]> rows = new ArrayList<>();
    for (UniqueUnit uu : uniqueUnits) {
        rows.add(new Object[] { uu.getRefurbishId(), uu.getProduct().getGroup().getNote(), uu.getProduct().getPartNo(), uu.getSerial(), ProductFormater.toName(uu.getProduct()), uu.getContractor(), UniqueUnitFormater.toSingleLineAccessories(uu), UniqueUnitFormater.toSingleLineComment(uu), UniqueUnitFormater.toSingleLineInternalComment(uu), uu.getCondition().getNote(), uu.getShipmentLabel(), uu.getProduct().getDescription(), "" });
    }
    CSheet sheet = new CSheet("Audit");
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("SopoNr", 7)).add(new STableColumn("Warengruppe", 13)).add(new STableColumn("ArtikelNr", 15)).add(new STableColumn("Seriennummer", 27));
    table.add(new STableColumn("Name", 30)).add(new STableColumn("Lieferant", 12)).add(new STableColumn("Zubehör", 50)).add(new STableColumn("Bemerkung", 50));
    table.add(new STableColumn("Interne Bemerkung", 30)).add(new STableColumn("Zustand", 12)).add(new STableColumn("Shipment", 12)).add(new STableColumn("Beschreibung", 50));
    table.setModel(new STableModelList(rows));
    sheet.addBelow(table);
    CCalcDocument document = new TempCalcDocument();
    document.add(sheet);
    FileJacket fj = new FileJacket("Audit", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document));
    m.finish();
    return fj;
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) ArrayList(java.util.ArrayList) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) STableColumn(eu.ggnet.lucidcalc.STableColumn) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder)

Example 8 with TempCalcDocument

use of eu.ggnet.lucidcalc.TempCalcDocument in project dwoss by gg-net.

the class ReturnsExporter method returnsToXls.

public static File returnsToXls(List<ReportLine> lines) {
    List<Object[]> linesData = new ArrayList<>();
    for (ReportLine reportLine : lines) {
        Object[] data = new Object[] { reportLine.getDossierIdentifier(), reportLine.getActual(), reportLine.getRefurbishId(), reportLine.getPartNo(), reportLine.getName(), reportLine.getSerial(), reportLine.getMfgDate(), reportLine.getReportingDate() };
        linesData.add(data);
    }
    STable newTable = new STable();
    newTable.setTableFormat(new CFormat("Verdana", 10, new CBorder(Color.BLACK, CBorder.LineStyle.THIN)));
    newTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.CENTER, CFormat.VerticalAlignment.MIDDLE));
    newTable.add(new STableColumn("Auftrag", 15));
    newTable.add(new STableColumn("Datum", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.add(new STableColumn("SopoNr", 10));
    newTable.add(new STableColumn("ArtikelNr", 15));
    newTable.add(new STableColumn("Bezeichnung", 40));
    newTable.add(new STableColumn("Seriennummer", 35));
    newTable.add(new STableColumn("MFGDate", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.add(new STableColumn("reported Am", 10, new CFormat(CFormat.Representation.SHORT_DATE)));
    newTable.setModel(new STableModelList<>(linesData));
    STable table = new STable(newTable);
    table.setModel(new STableModelList<>(linesData));
    ReturnsExporter.SResult summary = createReturnsSummary(table, lines.size());
    SBlock block = new SBlock();
    block.setFormat(new CFormat(Color.BLACK, Color.LIGHT_GRAY, CFormat.HorizontalAlignment.LEFT));
    block.add(new SCell("Rückläufer"), "");
    CSheet sheet = new CSheet("Rückläufer Report");
    sheet.setShowGridLines(false);
    sheet.addBelow(block);
    sheet.addBelow(newTable);
    sheet.addBelow(4, 1, summary.block);
    CCalcDocument doc = new TempCalcDocument("Rückläufer");
    doc.add(sheet);
    LucidCalcWriter writer = LucidCalc.createWriter(LucidCalc.Backend.XLS);
    return writer.write(doc);
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) SCell(eu.ggnet.lucidcalc.SCell) LucidCalcWriter(eu.ggnet.lucidcalc.LucidCalcWriter) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) SBlock(eu.ggnet.lucidcalc.SBlock) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) CFormat(eu.ggnet.lucidcalc.CFormat) CBorder(eu.ggnet.lucidcalc.CBorder)

Example 9 with TempCalcDocument

use of eu.ggnet.lucidcalc.TempCalcDocument in project dwoss by gg-net.

the class TableToExcelExporter method export.

/**
 * Export a JTable view to a temporary .xls file.
 * Supported cell renderer:<ol>
 * </ol>
 * <p/>
 * @param table
 * @param fileName
 * @return
 * @throws de.dw.util.UserInfoException
 */
public static FileJacket export(JTable table, String fileName) throws UserInfoException {
    int visibleRowCount = table.getRowCount();
    if (visibleRowCount < 1)
        throw new UserInfoException("Die Tabelle enthält keine Daten.");
    int columnCount = table.getColumnCount();
    TableModel model = table.getModel();
    List<Object[]> rows = new ArrayList<>();
    for (int i = 0; i < visibleRowCount; i++) {
        Object[] row = new Object[columnCount + 1];
        for (int j = 0; j < columnCount; j++) {
            // convert value of table to specified value
            Object value = model.getValueAt(table.convertRowIndexToModel(i), table.convertColumnIndexToModel(j));
            if (value instanceof Date) {
                row[j] = SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, Locale.GERMANY).format(value);
                continue;
            }
            // check for enums with getNote() or getName() via PojoUtil reflection
            if (value instanceof Enum) {
                try {
                    row[j] = PojoUtil.getValue("note", value);
                    continue;
                } catch (RuntimeException e) {
                    try {
                        row[j] = PojoUtil.getValue("name", value);
                        continue;
                    } catch (RuntimeException ex) {
                    }
                }
            }
            row[j] = value;
        }
        rows.add(row);
    }
    STable sTable = new STable();
    for (int i = 0; i < columnCount; i++) {
        int width = table.getColumnModel().getColumn(i).getWidth();
        sTable.add(new STableColumn(table.getColumnName(i), width / 5));
    }
    sTable.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument(fileName);
    cdoc.add(new CSheet("Sheet1", sTable));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    return new FileJacket(fileName, ".xls", file);
}
Also used : ArrayList(java.util.ArrayList) CCalcDocument(eu.ggnet.lucidcalc.CCalcDocument) CSheet(eu.ggnet.lucidcalc.CSheet) FileJacket(eu.ggnet.dwoss.util.FileJacket) Date(java.util.Date) STableColumn(eu.ggnet.lucidcalc.STableColumn) STable(eu.ggnet.lucidcalc.STable) STableModelList(eu.ggnet.lucidcalc.STableModelList) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) TempCalcDocument(eu.ggnet.lucidcalc.TempCalcDocument) File(java.io.File) TableModel(javax.swing.table.TableModel)

Aggregations

CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)9 CSheet (eu.ggnet.lucidcalc.CSheet)9 STable (eu.ggnet.lucidcalc.STable)9 STableColumn (eu.ggnet.lucidcalc.STableColumn)9 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)9 FileJacket (eu.ggnet.dwoss.util.FileJacket)7 CFormat (eu.ggnet.lucidcalc.CFormat)7 STableModelList (eu.ggnet.lucidcalc.STableModelList)7 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)6 CBorder (eu.ggnet.lucidcalc.CBorder)6 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)5 File (java.io.File)5 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)4 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)3 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)3 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)3 ArrayList (java.util.ArrayList)3 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)2 SBlock (eu.ggnet.lucidcalc.SBlock)2 SimpleDateFormat (java.text.SimpleDateFormat)2