Search in sources :

Example 21 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class AddUnitHistoryOperation method addCommentHistory.

/**
 * This method is used to add a Comment History to a UniqueUnit.
 * @param refurbishId the refurbish id
 * @param comment the comment that will be added
 * @param arranger the arranger
 */
@Override
public void addCommentHistory(String refurbishId, String comment, String arranger) {
    UniqueUnitEao eao = new UniqueUnitEao(entityManager);
    UniqueUnit uu = eao.findByIdentifier(UniqueUnit.Identifier.REFURBISHED_ID, refurbishId);
    if (uu != null)
        uu.addHistory(comment + " - " + arranger);
    else
        L.warn("No UniqueUnit for refurbishId " + refurbishId);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 22 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao in project dwoss by gg-net.

the class UniqueUnitReporterOperation method quality.

// TODO: Document Me
@Override
public FileJacket quality(Date start, Date end, TradeName contractor) {
    SubMonitor m = monitorFactory.newSubMonitor("Gerätequalitätsreport", 10);
    m.start();
    m.message("Loading reciepted Units");
    List<UniqueUnit> units = new UniqueUnitEao(em).findBetweenInputDatesAndContractor(start, end, contractor);
    m.worked(5, "Sorting Data");
    Set<String> months = new HashSet<>();
    Date actual = start;
    while (actual.before(end)) {
        months.add(YEAR_MONTH.format(actual));
        actual = DateUtils.addDays(actual, 1);
    }
    // prepare Map sorted by months that contains a map sorted by condition
    SortedMap<String, UnitQualityContainer> unitMap = new TreeMap<>();
    for (String month : months) {
        unitMap.put(month, new UnitQualityContainer());
    }
    m.worked(1);
    // count monthly receipted units sorted by condition
    for (UniqueUnit uniqueUnit : units) {
        actual = uniqueUnit.getInputDate();
        switch(uniqueUnit.getCondition()) {
            case AS_NEW:
                unitMap.get(YEAR_MONTH.format(actual)).incrementAsNew();
                break;
            case ALMOST_NEW:
                unitMap.get(YEAR_MONTH.format(actual)).incrementAlmostNew();
                break;
            case USED:
                unitMap.get(YEAR_MONTH.format(actual)).incrementUsed();
                break;
        }
    }
    m.worked(2, "Creating Document");
    List<Object[]> rows = new ArrayList<>();
    for (String month : unitMap.keySet()) {
        rows.add(new Object[] { month, unitMap.get(month).getAsNew(), unitMap.get(month).getAlmostNew(), unitMap.get(month).getUsed() });
        m.worked(5);
    }
    STable table = new STable();
    table.setTableFormat(new CFormat(BLACK, WHITE, new CBorder(BLACK)));
    table.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.YELLOW, CFormat.HorizontalAlignment.LEFT, CFormat.VerticalAlignment.BOTTOM, CFormat.Representation.DEFAULT));
    table.add(new STableColumn("Monat", 15)).add(new STableColumn("neuwertig", 15)).add(new STableColumn("nahezu neuwerig", 15)).add(new STableColumn("gebraucht", 15));
    table.setModel(new STableModelList(rows));
    CCalcDocument cdoc = new TempCalcDocument("Qualitaet_");
    cdoc.add(new CSheet("Sheet1", table));
    File file = LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc);
    m.finish();
    return new FileJacket("Aufnahme_nach_Qualität_" + contractor + "_" + DateFormats.ISO.format(start) + "_" + DateFormats.ISO.format(end), ".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) File(java.io.File)

Example 23 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao 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 24 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao 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 25 with UniqueUnitEao

use of eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao 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)

Aggregations

UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)49 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)38 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)21 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)19 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)17 FileJacket (eu.ggnet.dwoss.util.FileJacket)10 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)9 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)6 File (java.io.File)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)5 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)5 CCalcDocument (eu.ggnet.lucidcalc.CCalcDocument)5 CFormat (eu.ggnet.lucidcalc.CFormat)5 CSheet (eu.ggnet.lucidcalc.CSheet)5 STable (eu.ggnet.lucidcalc.STable)5 STableColumn (eu.ggnet.lucidcalc.STableColumn)5 STableModelList (eu.ggnet.lucidcalc.STableModelList)5 TempCalcDocument (eu.ggnet.lucidcalc.TempCalcDocument)5 PriceEngineResult (eu.ggnet.dwoss.price.engine.PriceEngineResult)4 DocumentEao (eu.ggnet.dwoss.redtape.ee.eao.DocumentEao)4