Search in sources :

Example 6 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class UniqueUnitReporterOperation method unitInputAsXls.

@Override
public FileJacket unitInputAsXls(Date start, Date end, Step step) {
    String name = "Aufnahmemengereport";
    SubMonitor m = monitorFactory.newSubMonitor(name);
    m.start();
    UniqueUnitEao eao = new UniqueUnitEao(em);
    NavigableSet<TradeName> usedManufacturers = eao.findUsedManufactuers();
    NavigableMap<Date, BrandContractorCount> revenue = eao.countByInputDateContractor(start, end, step);
    STable template = new STable();
    template.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    template.setHeadlineFormat(new CFormat(BOLD_ITALIC, WHITE, BLUE, CENTER, new CBorder(BLACK)));
    template.add(new STableColumn(step.name(), 12));
    for (TradeName manufacturer : usedManufacturers) {
        template.add(new STableColumn(manufacturer.getName(), 15, new CFormat(RIGHT)));
    }
    template.add(new STableColumn("Summe", 18, new CFormat(RIGHT)));
    STable all = new STable(template);
    all.setModel(new STableModelList(buildSumModel(step, usedManufacturers, revenue)));
    CCalcDocument cdoc = new TempCalcDocument(name);
    cdoc.add(new CSheet("Input_All", all));
    for (TradeName contractor : contractors.all()) {
        STable simple = new STable(template);
        simple.setModel(new STableModelList(buildContractorModel(step, contractor, usedManufacturers, revenue)));
        cdoc.add(new CSheet("Input_" + contractor, simple));
    }
    FileJacket result = new FileJacket(name, ".xls", new JExcelLucidCalcWriter().write(cdoc));
    m.finish();
    return result;
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) BrandContractorCount(eu.ggnet.dwoss.uniqueunit.ee.eao.BrandContractorCount) JExcelLucidCalcWriter(eu.ggnet.lucidcalc.jexcel.JExcelLucidCalcWriter)

Example 7 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class StockTakingOperation method fullfillDetails.

/**
 * Takes the supplied list of refurbishIds, validates their existence in the supplied Stock or all if none supplied.
 *
 * @param inFile  a XLS File containing the refurbishIds in the first sheet, first column.
 * @param stockId the stock, may be null
 * @return a FileJacket with the Result as XLS Report.
 */
@Override
public FileJacket fullfillDetails(FileJacket inFile, Integer stockId) {
    SubMonitor m = monitorFactory.newSubMonitor("Inventur vervollständigen", 100);
    m.start();
    m.message("Datei einlesen");
    ReaderResult read = xlsToList(inFile);
    m.worked(3);
    m.setWorkRemaining(read.getRefurbisIds().size() * 2 + 10);
    UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    DossierEao dossierEao = new DossierEao(redTapeEm);
    List<Object[]> result = new ArrayList<>();
    Set<StockUnit> found = new HashSet<>();
    String stockTaking = "erfasst";
    for (String refurbishId : read.getRefurbisIds()) {
        m.worked(1, "vervollständige " + refurbishId);
        UniqueUnit uu = uniqueUnitEao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
        StockUnit stu = (uu == null ? null : stockUnitEao.findByUniqueUnitId(uu.getId()));
        if (stu != null)
            found.add(stu);
        if (uu == null) {
            result.add(new Object[] { stockTaking, "Fehler: Gerät exitiert nicht !", refurbishId, null, null, null, null, null, null, null, null, null, null, null });
        } else {
            String partNo = uu.getProduct().getPartNo();
            String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
            String name = ProductFormater.toName(uu.getProduct());
            if (stu == null) {
                result.add(new Object[] { stockTaking, "Nicht im Lager", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), null, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
            } else {
                // jetzt schauen was mit st ist
                String stock = (stu.getStock() == null ? stu.getTransaction().toSimpleLine() : stu.getStock().getName());
                if (stu.getLogicTransaction() == null) {
                    result.add(new Object[] { stockTaking, "verfügbar", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
                } else {
                    Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
                    result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", refurbishId, partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
                }
            }
        }
    }
    stockTaking = "nicht erfasst";
    m.message("lade fehlende Geräte");
    List<StockUnit> openUnits = (stockId == null ? stockUnitEao.findAll() : stockUnitEao.findByStockId(stockId));
    m.worked(8);
    openUnits.removeAll(found);
    m.setWorkRemaining(openUnits.size());
    for (StockUnit stu : openUnits) {
        m.worked(1, "vervollständige " + stu.getRefurbishId());
        UniqueUnit uu = uniqueUnitEao.findById(stu.getUniqueUnitId());
        String partNo = uu.getProduct().getPartNo();
        String contractorPartNo = uu.getProduct().getAdditionalPartNo(uu.getContractor());
        String name = ProductFormater.toName(uu.getProduct());
        // jetzt schauen was mit st ist
        String stock = (stu.getStock() == null ? stu.getTransaction().toString() : stu.getStock().getName());
        if (stu.getLogicTransaction() == null) {
            result.add(new Object[] { stockTaking, "verfügbar", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), null, null, null, contractorPartNo, null });
        } else {
            Dossier dos = dossierEao.findById(stu.getLogicTransaction().getDossierId());
            result.add(new Object[] { stockTaking, dos.isClosed() ? "abgeschlossen" : "in transfer", uu.getRefurbishId(), partNo, uu.getSerial(), name, uu.getContractor(), stock, uu.getSalesChannel(), dos.getCrucialDirective().getName(), dos.getCustomerId(), dos.getIdentifier(), contractorPartNo, customerService.asUiCustomer(dos.getCustomerId()).toNameCompanyLine() });
        }
    }
    for (String error : read.getErrors()) {
        result.add(new Object[] { "Lesefehler", error, null, null, null, null, null, null, null, null, null, null, null, null });
    }
    m.message("Erzeuge Tabelle");
    CSheet sheet = new CSheet("Inventur");
    STable table = new STable();
    table.setHeadlineFormat(new CFormat(BOLD_ITALIC, BLACK, WHITE, CENTER, new CBorder(BLACK)));
    table.add(new STableColumn("Inventur", 12)).add(new STableColumn("Status", 10)).add(new STableColumn("SopoNr", 10)).add(new STableColumn("ArtikelNr", 16));
    table.add(new STableColumn("Seriennummer", 30)).add(new STableColumn("Name", 50)).add(new STableColumn("Contractor", 14)).add(new STableColumn("Lager", 25));
    table.add(new STableColumn("Verkaufskanal", 16)).add(new STableColumn("Directive", 20)).add(new STableColumn("Kid", 8)).add(new STableColumn("VorgangsId", 10));
    table.add(new STableColumn("LieferantenPartNo", 16)).add(new STableColumn("Kunde", 40));
    table.setModel(new STableModelList(result));
    sheet.addBelow(table);
    CCalcDocument document = new TempCalcDocument();
    document.add(sheet);
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(document);
    m.finish();
    return new FileJacket("Inventur", ".xls", file);
}
Also used : SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) FileJacket(eu.ggnet.dwoss.util.FileJacket) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) DossierEao(eu.ggnet.dwoss.redtape.ee.eao.DossierEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) File(java.io.File)

Example 8 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class StockTakingOperation method units.

/**
 * Returns a List of Unit information identified by partNos and filtered by InputDate.
 * <p/>
 * @param partNos the partNos
 * @param start   the start of inputDate
 * @param end     the end of inputDate
 * @return a List of Unit information identified by partNos and filtered by InputDate.
 */
@Override
public List<UnitLine> units(Collection<String> partNos, Date start, Date end) {
    SubMonitor m = monitorFactory.newSubMonitor("Unit details", 100);
    m.start();
    m.message("lade Units");
    List<UniqueUnit> uus = new UniqueUnitEao(uuEm).findByProductPartNosInputDate(partNos, start, end);
    List<UnitLine> uls = new ArrayList<>(uus.size());
    for (UniqueUnit uu : uus) {
        uls.add(new UnitLine(uu, null));
    }
    m.finish();
    return uls;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 9 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class SalesListingProducerOperation method generateAllSalesListing.

@Override
public FileJacket generateAllSalesListing() {
    SubMonitor m = monitorFactory.newSubMonitor("All List", 5);
    m.message("loading Units");
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransaction();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    m.worked(3, "preparing Units");
    List<Object[]> retailers = new ArrayList<>(stockUnits.size());
    List<Object[]> customers = new ArrayList<>(stockUnits.size());
    for (Map.Entry<UniqueUnit, StockUnit> entry : toSortedMap(uniqueUnits, stockUnits, new UniqueUnitComparator()).entrySet()) {
        UniqueUnit uu = entry.getKey();
        StockUnit su = entry.getValue();
        Product p = uu.getProduct();
        Date firstPriced = null;
        for (PriceHistory priceHistory : uu.getPriceHistory()) {
            if (firstPriced == null || firstPriced.after(priceHistory.getDate()))
                firstPriced = priceHistory.getDate();
        }
        String source = "Automatisch";
        if (p != null && p.getFlags().contains(Product.Flag.PRICE_FIXED))
            source = "Manuell (Artikel)";
        else if (uu.getFlags().contains(UniqueUnit.Flag.PRICE_FIXED))
            source = "Manuell (Gerät)";
        Object[] row = { uu.getRefurbishId(), (p == null ? null : p.getPartNo()), (p == null ? null : p.getGroup().getNote()), (p == null ? null : p.getTradeName().getName()), (p == null ? null : p.getName()), (p == null ? null : p.getDescription()), uu.getWarranty().getName(), uu.getWarrentyValid(), UniqueUnitFormater.toSingleLineAccessories(uu), uu.getCondition().getNote(), UniqueUnitFormater.toSingleLineComment(uu), uu.getPrice(PriceType.RETAILER), uu.getPrice(PriceType.CUSTOMER), (!uu.hasPrice(PriceType.CUSTOMER) ? null : TwoDigits.roundedApply(uu.getPrice(PriceType.CUSTOMER), GlobalConfig.DEFAULT_TAX.getTax(), 0)), (su.getStock() == null ? su.getTransaction() : su.getStock().getName()), uu.getMfgDate(), uu.getInputDate(), firstPriced, source };
        if (uu.getSalesChannel() == SalesChannel.CUSTOMER && uu.hasPrice(PriceType.CUSTOMER))
            customers.add(row);
        else if (uu.getSalesChannel() == SalesChannel.RETAILER && (uu.hasPrice(PriceType.CUSTOMER) || uu.hasPrice(PriceType.RETAILER)))
            retailers.add(row);
    }
    m.worked(1, "creating File, Endkundengeräte: " + customers.size() + ", Händlergeräte: " + retailers.size());
    STable consumerTable = new STable();
    consumerTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
    consumerTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
    consumerTable.setRowHeight(1000);
    consumerTable.add(new STableColumn("SopoNr", 12));
    consumerTable.add(new STableColumn("ArtikelNr", 15));
    consumerTable.add(new STableColumn("Warengruppe", 18));
    consumerTable.add(new STableColumn("Hersteller", 15));
    consumerTable.add(new STableColumn("Bezeichnung", 30));
    consumerTable.add(new STableColumn("Beschreibung", 60, LFT));
    consumerTable.add(new STableColumn("Garantie", 18, LFT));
    consumerTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Zubehör", 30, LFT));
    consumerTable.add(new STableColumn("optische Bewertung", 25));
    consumerTable.add(new STableColumn("Bemerkung", 50, LFT));
    consumerTable.add(new STableColumn("Händler", 15, EURO));
    consumerTable.add(new STableColumn("Endkunde", 15, EURO));
    consumerTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
    consumerTable.add(new STableColumn("Lager", 18));
    consumerTable.add(new STableColumn("Mfg Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Aufnahme Datum", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Erstmalig Bepreist", 18, new CFormat(Representation.SHORT_DATE)));
    consumerTable.add(new STableColumn("Preis Quelle", 18));
    consumerTable.setModel(new STableModelList(customers));
    STable retailerTable = new STable(consumerTable);
    retailerTable.setModel(new STableModelList(retailers));
    CCalcDocument cdoc = new TempCalcDocument();
    cdoc.add(new CSheet("Endkunde", consumerTable));
    cdoc.add(new CSheet("Händler", retailerTable));
    FileJacket fj = new FileJacket("All", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc));
    m.finish();
    return fj;
}
Also used : Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 10 with SubMonitor

use of eu.ggnet.dwoss.progress.SubMonitor in project dwoss by gg-net.

the class SalesListingProducerOperation method prepareAndSend.

/**
 * Prepare and send filejackets to the specified email address.
 * <p>
 * @param fileJackets files to be send
 */
private void prepareAndSend(List<FileJacket> fileJackets) {
    SubMonitor m = monitorFactory.newSubMonitor("Transfer");
    m.message("sending Mail");
    m.start();
    try {
        ListingMailConfiguration config = listingService.get().listingMailConfiguration();
        MultiPartEmail email = mandator.prepareDirectMail();
        email.setFrom(config.getFromAddress());
        email.addTo(config.getToAddress());
        email.setSubject(config.getSubject());
        email.setMsg(config.toMessage());
        for (FileJacket fj : fileJackets) {
            email.attach(new javax.mail.util.ByteArrayDataSource(fj.getContent(), "application/xls"), fj.getHead() + fj.getSuffix(), "Die Händlerliste für die Marke ");
        }
        email.send();
        m.finish();
    } catch (EmailException e) {
        throw new RuntimeException(e);
    }
}
Also used : ListingMailConfiguration(eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration) java.util(java.util) eu.ggnet.dwoss.util(eu.ggnet.dwoss.util) MultiPartEmail(org.apache.commons.mail.MultiPartEmail) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) EmailException(org.apache.commons.mail.EmailException)

Aggregations

SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)63 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)23 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)21 FileJacket (eu.ggnet.dwoss.util.FileJacket)18 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)16 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)14 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)12 File (java.io.File)12 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)11 UiCustomer (eu.ggnet.dwoss.customer.opi.UiCustomer)9 ProductEao (eu.ggnet.dwoss.uniqueunit.ee.eao.ProductEao)8 MonitorFactory (eu.ggnet.dwoss.progress.MonitorFactory)7 Inject (javax.inject.Inject)7 Test (org.junit.Test)7 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)6 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)6 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)6 CFormat (eu.ggnet.lucidcalc.CFormat)6 CSheet (eu.ggnet.lucidcalc.CSheet)6 STable (eu.ggnet.lucidcalc.STable)6