Search in sources :

Example 11 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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 12 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class UnitListenerOperation method addHistory.

/**
 * Listens for UnitHistoies.
 *
 * @param history
 */
public void addHistory(@Observes UnitHistory history) {
    L.debug("Observed: " + history);
    UniqueUnit uu = em.find(UniqueUnit.class, history.getUniqueUnitId());
    if (uu != null)
        uu.addHistory(history.getComment() + " - " + history.getArranger());
    else
        L.warn("No UniqueUnit for Event " + history);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 13 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit in project dwoss by gg-net.

the class UniqueUnitEao method find.

/**
 * Returns a list of UniqueUnits which match the search string.
 *
 * @param search the search string, may start or end with '*' as wildcard, may not be null
 * @return a list of UniqueUnits which match the search string.
 */
public List<UniqueUnit> find(String search) {
    List<UniqueUnit> result = Collections.EMPTY_LIST;
    if (search == null)
        return result;
    // TODO: Replace native Query
    Query query = em.createNativeQuery("SELECT a.id FROM UniqueUnit as a join UniqueUnit_identifiers as b on a.id = b.UniqueUnit_id where b.identifiers like :search");
    query.setParameter("search", search.replaceAll("\\*", "%"));
    List<Integer> ids = (List<Integer>) query.getResultList();
    return findByIds(ids);
}
Also used : BigInteger(java.math.BigInteger) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) JPAQuery(com.mysema.query.jpa.impl.JPAQuery)

Example 14 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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 15 with UniqueUnit

use of eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit 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

UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)88 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)38 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)31 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)27 Test (org.junit.Test)21 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)20 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)16 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)13 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)8 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)8 UnitCollection (eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection)7 java.util (java.util)7 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 Position (eu.ggnet.dwoss.redtape.ee.entity.Position)6 ProductSpec (eu.ggnet.dwoss.spec.ee.entity.ProductSpec)6 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)6 UniqueUnitAgent (eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent)6 FileJacket (eu.ggnet.dwoss.util.FileJacket)6 DocumentType (eu.ggnet.dwoss.rules.DocumentType)5 Collectors (java.util.stream.Collectors)5