Search in sources :

Example 46 with UniqueUnit

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

the class SalesListingProducerOperation method generateXlsListings.

/**
 * Generates XLS files for units in a specific sales channel.
 * The lists are seperated by brand.
 * <p>
 * @param channel the saleschannel
 * @return XLS files for units in a specific sales channel.
 */
private Map<TradeName, Collection<FileJacket>> generateXlsListings(SalesChannel channel) {
    SubMonitor m = monitorFactory.newSubMonitor("Listen für " + channel.getName() + " erstellen", 100);
    m.start();
    List<StockUnit> stockUnits = new StockUnitEao(stockEm).findByNoLogicTransactionAndPresentStock();
    List<UniqueUnit> uniqueUnits = new UniqueUnitEao(uuEm).findByIds(toUniqueUnitIds(stockUnits));
    Map<TradeName, List<UniqueUnit>> units = uniqueUnits.stream().collect(Collectors.groupingBy(uu -> uu.getProduct().getTradeName()));
    m.worked(2, "prüfe und filtere Geräte");
    Map<TradeName, Collection<FileJacket>> files = new HashMap<>();
    for (TradeName k : units.keySet()) {
        List<UniqueUnit> uus = units.get(k);
        Collections.sort(uus, new UniqueUnitComparator());
        List<Object[]> rows = new ArrayList<>();
        for (UniqueUnit get : uus) {
            UniqueUnit uu = get;
            Product p = uu.getProduct();
            // Cases to filter out.
            if (uu.getSalesChannel() != channel)
                continue;
            if (!uu.hasPrice((channel == SalesChannel.CUSTOMER ? PriceType.CUSTOMER : PriceType.RETAILER)))
                continue;
            Object[] row = { uu.getRefurbishId(), p.getPartNo(), p.getGroup().getNote(), p.getTradeName().getName(), p.getName(), 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)) };
            rows.add(row);
        }
        if (rows.isEmpty())
            continue;
        m.worked(5, "creating File, Geräte: " + rows.size());
        STable unitTable = new STable();
        unitTable.setTableFormat(new CFormat(CENTER, TOP, new CBorder(Color.GRAY, CBorder.LineStyle.THIN), true));
        unitTable.setHeadlineFormat(new CFormat(CFormat.FontStyle.BOLD, Color.BLACK, Color.LIGHT_GRAY, CENTER, MIDDLE));
        unitTable.setRowHeight(1000);
        unitTable.add(new STableColumn("SopoNr", 12));
        unitTable.add(new STableColumn("ArtikelNr", 15));
        unitTable.add(new STableColumn("Warengruppe", 18));
        unitTable.add(new STableColumn("Hersteller", 15));
        unitTable.add(new STableColumn("Bezeichnung", 30));
        unitTable.add(new STableColumn("Beschreibung", 60, LFT));
        unitTable.add(new STableColumn("Garantie", 18, LFT));
        unitTable.add(new STableColumn("Garantie bis", 18, new CFormat(Representation.SHORT_DATE)));
        unitTable.add(new STableColumn("Zubehör", 30, LFT));
        unitTable.add(new STableColumn("optische Bewertung", 25));
        unitTable.add(new STableColumn("Bemerkung", 50, LFT));
        unitTable.add(new STableColumn("Händler", 15, EURO));
        unitTable.add(new STableColumn("Endkunde", 15, EURO));
        unitTable.add(new STableColumn("E.inc.Mwst", 15, EURO));
        unitTable.setModel(new STableModelList(rows));
        CCalcDocument cdoc = new TempCalcDocument();
        cdoc.add(new CSheet("Sonderposten", unitTable));
        files.put(k, Arrays.asList(new FileJacket(k.getName() + " Liste", ".xls", LucidCalc.createWriter(LucidCalc.Backend.XLS).write(cdoc))));
    }
    m.finish();
    return files;
}
Also used : Color(java.awt.Color) java.util(java.util) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) URL(java.net.URL) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Representation(eu.ggnet.lucidcalc.CFormat.Representation) LoggerFactory(org.slf4j.LoggerFactory) UploadCommand(eu.ggnet.dwoss.mandator.api.service.FtpConfiguration.UploadCommand) eu.ggnet.dwoss.rules(eu.ggnet.dwoss.rules) TOP(eu.ggnet.lucidcalc.CFormat.VerticalAlignment.TOP) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StringUtils(org.apache.commons.lang3.StringUtils) Mandator(eu.ggnet.dwoss.mandator.api.value.Mandator) Stocks(eu.ggnet.dwoss.stock.ee.assist.Stocks) Inject(javax.inject.Inject) MIDDLE(eu.ggnet.lucidcalc.CFormat.VerticalAlignment.MIDDLE) ListingMailConfiguration(eu.ggnet.dwoss.mandator.api.value.partial.ListingMailConfiguration) JRSaver(net.sf.jasperreports.engine.util.JRSaver) eu.ggnet.dwoss.mandator.api.service(eu.ggnet.dwoss.mandator.api.service) UniqueUnits(eu.ggnet.dwoss.uniqueunit.ee.assist.UniqueUnits) Instance(javax.enterprise.inject.Instance) net.sf.jasperreports.engine(net.sf.jasperreports.engine) UniqueUnitFormater(eu.ggnet.dwoss.uniqueunit.ee.format.UniqueUnitFormater) eu.ggnet.dwoss.util(eu.ggnet.dwoss.util) Stateless(javax.ejb.Stateless) PriceHistory(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceHistory) Logger(org.slf4j.Logger) PriceType(eu.ggnet.dwoss.uniqueunit.ee.entity.PriceType) LEFT(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.LEFT) DecimalFormat(java.text.DecimalFormat) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) MultiPartEmail(org.apache.commons.mail.MultiPartEmail) Collectors(java.util.stream.Collectors) JRBeanCollectionDataSource(net.sf.jasperreports.engine.data.JRBeanCollectionDataSource) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) CENTER(eu.ggnet.lucidcalc.CFormat.HorizontalAlignment.CENTER) eu.ggnet.lucidcalc(eu.ggnet.lucidcalc) MonitorFactory(eu.ggnet.dwoss.progress.MonitorFactory) EmailException(org.apache.commons.mail.EmailException) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) GlobalConfig(eu.ggnet.dwoss.configuration.GlobalConfig) InputStream(java.io.InputStream) 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) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)

Example 47 with UniqueUnit

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

the class ProductGenerator method generateProduct.

/**
 * Generate a specific amount of products with random data.
 *
 * @param amount of products that get created
 * @return list of Product
 */
public List<Product> generateProduct(int amount) {
    List<Product> products = new ArrayList<>();
    for (int i = 0; i < amount; i++) {
        Product p = new Product(productGroups.get(rand.nextInt(productGroups.size())), tradeNames.get(rand.nextInt(tradeNames.size())), "" + rand.nextInt(15000), names.get(rand.nextInt(names.size())));
        p.setImageId(rand.nextInt(15000));
        p.setGtin(rand.nextInt(15000));
        p.setEol(dates.get(rand.nextInt(dates.size())));
        p.setPrice(priceTypes.get(rand.nextInt(priceTypes.size())), rand.nextInt(9999), "");
        ucGen.generateUnitCollections().forEach((generateUnitCollection) -> {
            p.getUnitCollections().add(generateUnitCollection);
        });
        for (UnitCollection collection : p.getUnitCollections()) {
            for (UniqueUnit unit : collection.getUnits()) {
                unit.setProduct(p);
            }
        }
        for (int j = 0; j < 5; j++) {
            p.getUniqueUnits().add(uuGen.makeUniqueUnit(p.getTradeName(), p.getGroup()));
        }
        products.add(p);
    }
    return products;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Example 48 with UniqueUnit

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

the class ProductGenerator method generateProduct.

/**
 * Generate a specific amount of products with random data.
 *
 * @param amount of products that get created
 * @return list of Product
 */
public List<Product> generateProduct(int amount) {
    List<Product> products = new ArrayList<>();
    for (int i = 0; i < amount; i++) {
        Product p = new Product(productGroups.get(rand.nextInt(productGroups.size())), tradeNames.get(rand.nextInt(tradeNames.size())), "" + rand.nextInt(15000), names.get(rand.nextInt(names.size())));
        p.setImageId(rand.nextInt(15000));
        p.setGtin(rand.nextInt(15000));
        p.setEol(dates.get(rand.nextInt(dates.size())));
        p.setPrice(priceTypes.get(rand.nextInt(priceTypes.size())), rand.nextInt(9999), "");
        ucGen.generateUnitCollections().forEach((generateUnitCollection) -> {
            p.getUnitCollections().add(generateUnitCollection);
        });
        for (UnitCollection collection : p.getUnitCollections()) {
            for (UniqueUnit unit : collection.getUnits()) {
                unit.setProduct(p);
            }
        }
        for (int j = 0; j < 5; j++) {
            p.getUniqueUnits().add(uuGen.makeUniqueUnit(p.getTradeName(), p.getGroup()));
        }
        products.add(p);
    }
    return products;
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) UnitCollection(eu.ggnet.dwoss.uniqueunit.ee.entity.UnitCollection) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product)

Example 49 with UniqueUnit

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

the class UnitOverseerBean method lockStockUnit.

/**
 * Find an available StockUnit and locks it by add to a LogicTransaction via DossierId.
 * <p/>
 * If no unit is found a LayerEightException is thrown.
 * <p/>
 * @param dossierId     The Dossiers ID
 * @param refurbishedId The refurbished id for the Unique Unit search
 * @throws IllegalStateException if the refurbishId is not available
 */
@Override
public void lockStockUnit(long dossierId, String refurbishedId) throws IllegalStateException {
    if (!internalFind(refurbishedId).isAvailable())
        throw new IllegalStateException("Trying to lock refusbishId " + refurbishedId + ", but it is not available!");
    UniqueUnit uu = new UniqueUnitEao(uuEm).findByIdentifier(Identifier.REFURBISHED_ID, refurbishedId);
    StockUnit stockUnit = new StockUnitEao(stockEm).findByUniqueUnitId(uu.getId());
    LogicTransaction lt = new LogicTransactionEmo(stockEm).request(dossierId);
    lt.add(stockUnit);
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) LogicTransaction(eu.ggnet.dwoss.stock.ee.entity.LogicTransaction) LogicTransactionEmo(eu.ggnet.dwoss.stock.ee.emo.LogicTransactionEmo) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)

Example 50 with UniqueUnit

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

the class UnitOverseerBean method toDetailedHtml.

/**
 * Find a Unit and its representative and return a html formated String representing it.
 * Ensure to add the html start/end tags manually
 * <p/>
 * @param refurbishId the refurbishedId or serial
 * @param username
 * @return a html formated String representing a Unit.
 */
@Override
public String toDetailedHtml(String refurbishId, String username) {
    UniqueUnitEao uuEao = new UniqueUnitEao(uuEm);
    UniqueUnit uniqueUnit = uuEao.findByIdentifier(Identifier.REFURBISHED_ID, refurbishId);
    // Try Serail if Sopo does not match.
    if (uniqueUnit == null)
        uniqueUnit = uuEao.findByIdentifier(Identifier.SERIAL, refurbishId);
    if (uniqueUnit != null)
        return toDetailedHtmlUnit(uniqueUnit, hasRight(username, AtomicRight.VIEW_COST_AND_REFERENCE_PRICES));
    // Unique Unit is null, optional fallback to legacy system.
    if (!bridgeInstance.isUnsatisfied() && !bridgeInstance.get().isUnitIdentifierAvailable(refurbishId))
        return "<i><u>Informationen aus Legacy System Sopo:</u></i>" + bridgeInstance.get().toDetailedHtmlUnit(refurbishId);
    return "<h1>Keine Informationen zu SopoNr/Seriennummer " + refurbishId + "</h1>";
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) 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