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;
}
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;
});
}
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());
}
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()));
}
}
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;
}
}
Aggregations