Search in sources :

Example 31 with StockUnit

use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.

the class PriceCoreOperation method loadAndCalculate.

/**
 * Loads all AVAILABLE SopoUnits from the Sopodb an puts them trough the PriceEngine
 *
 * @param monitor
 * @return
 */
public List<PriceEngineResult> loadAndCalculate(IMonitor monitor) {
    L.info("Starting loadAndCalculate()");
    final SubMonitor m = SubMonitor.convert(monitor, 100);
    m.start();
    final StockUnitEao stockUnitEao = new StockUnitEao(stockEm);
    final UniqueUnitEao uniqueUnitEao = new UniqueUnitEao(uuEm);
    final ProductSpecEao productSpecEao = new ProductSpecEao(specEm);
    m.message("loading Units");
    List<Integer> uuids = stockUnitEao.findByNoLogicTransactionAsUniqueUnitId();
    List<UniqueUnit> uus = uniqueUnitEao.findByIds(uuids);
    m.worked(10, "updating Eols");
    updateEols(uus);
    m.worked(5, "loading ProductSpecs");
    Set<Product> products = toProducts(uus);
    List<ProductSpec> productSpecs = productSpecEao.findByProductIds(toProductIds(products));
    Map<Product, ProductSpec> productToSpecs = toProductProductSpec(products, productSpecs);
    m.worked(10);
    final List<PriceEngineResult> pers = new ArrayList<>();
    m.setWorkRemaining(uus.size() + 5);
    for (UniqueUnit uu : uus) {
        m.worked(1, "Calculating RefurbishId(" + uu.getRefurbishId() + ")");
        StockUnit su = stockUnitEao.findByUniqueUnitId(uu.getId());
        pers.add(priceEngine.estimate(uu, productToSpecs.get(uu.getProduct()), su.getStock() != null ? su.getStock().getName() : "kein Lager"));
    }
    m.finish();
    L.info("Finished loadAndCalculate(), estimated {} Units", pers.size());
    return pers;
}
Also used : PriceEngineResult(eu.ggnet.dwoss.price.engine.PriceEngineResult) SubMonitor(eu.ggnet.dwoss.progress.SubMonitor) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) UniqueUnitEao(eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao) UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockUnitEao(eu.ggnet.dwoss.stock.ee.eao.StockUnitEao) ProductSpecEao(eu.ggnet.dwoss.spec.ee.eao.ProductSpecEao) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 32 with StockUnit

use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.

the class PositionViewCask method accept.

@Override
public void accept(Position pos) {
    head.setText("(" + pos.getId() + ") " + pos.getName());
    Ui.exec(() -> {
        StringBuilder sb = new StringBuilder();
        sb.append(PositionFormater.toHtmlDetailed(pos)).append("<br />");
        if (pos.getType() == PositionType.UNIT) {
            StockUnit su = Dl.remote().lookup(StockAgent.class).findStockUnitByUniqueUnitIdEager(pos.getUniqueUnitId());
            UniqueUnit uu = Dl.remote().lookup(UniqueUnitAgent.class).findByIdEager(UniqueUnit.class, pos.getUniqueUnitId());
            if (su != null)
                sb.append(StockUnitFormater.detailedTransactionToHtml(su));
            if (uu != null)
                sb.append(UniqueUnitFormater.toHtmlPriceInformation(uu.getPrices(), uu.getPriceHistory())).append(UniqueUnitFormater.toHtmlUniqueUnitHistory(uu));
        }
        Platform.runLater(() -> {
            webView.getEngine().loadContent(sb.toString());
            progressIndicator.setVisible(false);
        });
        return null;
    });
}
Also used : UniqueUnit(eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) UniqueUnitAgent(eu.ggnet.dwoss.uniqueunit.ee.UniqueUnitAgent) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 33 with StockUnit

use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.

the class ConsumerFactoryOfStockTransactions method of.

@Override
public List<DescriptiveConsumer<PicoUnit>> of(PicoUnit t) {
    StockAgent stockAgent = Dl.remote().lookup(StockAgent.class);
    StockUnit su = stockAgent.findStockUnitByUniqueUnitIdEager(t.uniqueUnitId);
    if (su == null || su.isInTransaction())
        return Collections.EMPTY_LIST;
    Guardian guardian = Dl.local().lookup(Guardian.class);
    if (!guardian.hasRight(CREATE_TRANSACTION_FOR_SINGLE_UNIT))
        return Collections.EMPTY_LIST;
    return stockAgent.findAll(Stock.class).stream().filter(s -> !s.equals(su.getStock())).map(destination -> {
        return new DescriptiveConsumer<>("Umfuhr von " + su.getStock().getName() + " nach " + destination.getName(), (PicoUnit t1) -> {
            Ui.exec(() -> {
                Ui.build().dialog().eval(() -> new CreateQuestionModel(su, destination, "Umfuhr direkt durch Nutzer erzeugt"), () -> new CreateQuestionView()).opt().map(v -> ReplyUtil.wrap(() -> Dl.remote().lookup(StockTransactionProcessor.class).perpareTransfer(v.stockUnits, v.destination.getId(), Dl.local().lookup(Guardian.class).getUsername(), v.comment))).filter(Ui.failure()::handle).ifPresent(u -> Ui.build().alert("Umfuhr angelegt"));
            });
        });
    }).collect(Collectors.toList());
}
Also used : StockTransactionProcessor(eu.ggnet.dwoss.stock.ee.StockTransactionProcessor) DescriptiveConsumer(eu.ggnet.saft.core.ops.DescriptiveConsumer) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) Ui(eu.ggnet.saft.Ui) Collectors(java.util.stream.Collectors) Dl(eu.ggnet.saft.Dl) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) Guardian(eu.ggnet.saft.core.auth.Guardian) List(java.util.List) ReplyUtil(eu.ggnet.dwoss.common.ReplyUtil) Stock(eu.ggnet.dwoss.stock.ee.entity.Stock) DescriptiveConsumerFactory(eu.ggnet.saft.core.ops.DescriptiveConsumerFactory) CREATE_TRANSACTION_FOR_SINGLE_UNIT(eu.ggnet.dwoss.rights.api.AtomicRight.CREATE_TRANSACTION_FOR_SINGLE_UNIT) Collections(java.util.Collections) StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) Guardian(eu.ggnet.saft.core.auth.Guardian) PicoUnit(eu.ggnet.dwoss.uniqueunit.api.PicoUnit) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 34 with StockUnit

use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.

the class CreateQuestionView method accept.

@Override
public void accept(CreateQuestionModel model) {
    this.model = model;
    vbox.setPadding(new Insets(10));
    vbox.getChildren().add(new Label("Umfuhr von " + model.source.getName() + " nach " + model.destination.getName() + " für folgende(s) Gerät(e):"));
    for (StockUnit stockUnit : model.stockUnits) {
        vbox.getChildren().add(new Label("- [" + stockUnit.getRefurbishId() + "] " + stockUnit.getName()));
    }
}
Also used : Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Example 35 with StockUnit

use of eu.ggnet.dwoss.stock.ee.entity.StockUnit in project dwoss by gg-net.

the class CreateSimpleAction method handleResult.

private CreateQuestionModel handleResult(CreateSelectionController c) {
    try {
        if (StringUtils.isBlank(c.refurbishIds()))
            throw new UserInfoException("Keine SopoNr eingeben");
        if (StringUtils.isBlank(c.comment()))
            throw new UserInfoException("Keine Kommentar eingegeben");
        if (c.target() == null)
            throw new UserInfoException("Kein Ziellager ausgewählt");
        List<String> refurbishIds = parseRefurbishIds(c.refurbishIds());
        if (refurbishIds.isEmpty())
            throw new UserInfoException("Keine SopoNr in " + c.refurbishIds() + " erkannt");
        List<StockUnit> stockUnits = Dl.remote().lookup(StockAgent.class).findStockUnitsByRefurbishIdEager(refurbishIds);
        if (stockUnits.isEmpty())
            throw new UserInfoException("Keine der SopoNr(n) " + refurbishIds + " ist im Lager");
        if (stockUnits.stream().anyMatch(s -> s.isInTransaction()))
            throw new UserInfoException("Mindestens eine SopoNr ist auf einer Transaktion");
        if (unmatchingSourceAndDestination(stockUnits))
            throw new UserInfoException("Mindestens eine SopoNr ist nicht auf dem selben Ausgangslager");
        return new CreateQuestionModel(stockUnits.get(0).getStock(), c.target(), stockUnits, c.comment());
    } catch (UserInfoException ex) {
        Ui.handle(ex);
        return null;
    }
}
Also used : StockAgent(eu.ggnet.dwoss.stock.ee.StockAgent) UserInfoException(eu.ggnet.dwoss.util.UserInfoException) StockUnit(eu.ggnet.dwoss.stock.ee.entity.StockUnit)

Aggregations

StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)63 UniqueUnit (eu.ggnet.dwoss.uniqueunit.ee.entity.UniqueUnit)29 StockUnitEao (eu.ggnet.dwoss.stock.ee.eao.StockUnitEao)27 LogicTransaction (eu.ggnet.dwoss.stock.ee.entity.LogicTransaction)22 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)20 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)20 Test (org.junit.Test)19 UniqueUnitEao (eu.ggnet.dwoss.uniqueunit.ee.eao.UniqueUnitEao)18 Product (eu.ggnet.dwoss.uniqueunit.ee.entity.Product)13 SubMonitor (eu.ggnet.dwoss.progress.SubMonitor)11 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)9 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)8 StockTransactionEmo (eu.ggnet.dwoss.stock.ee.emo.StockTransactionEmo)8 UserInfoException (eu.ggnet.dwoss.util.UserInfoException)7 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)6 LogicTransactionEao (eu.ggnet.dwoss.stock.ee.eao.LogicTransactionEao)6 StockTransactionPosition (eu.ggnet.dwoss.stock.ee.entity.StockTransactionPosition)6 java.util (java.util)6 Inject (javax.inject.Inject)6 StockTransactionStatus (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatus)5