use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class ResolveRepaymentBean method resolveUnit.
@Override
public ResolveResult resolveUnit(String identifier, TradeName contractor, String arranger, String comment) throws UserInfoException {
// search with refurbishid and serial number.
List<SimpleReportLine> reportLines = reportLineEao.findReportLinesByIdentifiers(identifier.trim());
List<ReportLine> repaymentLines = getRepaymentLines(contractor);
ReportLine line = null;
List<Long> repaymentIds = repaymentLines.stream().map((l) -> l.getId()).collect(Collectors.toList());
for (SimpleReportLine reportLine : reportLines) {
if (repaymentIds.contains(reportLine.getId())) {
line = reportLineEao.findById(reportLine.getId());
}
}
if (line == null)
throw new UserInfoException("Es konnte keine ReportLine mit diesem Identifier gefunden werden");
if (!line.getReports().isEmpty())
throw new UserInfoException("ReportLine ist schon in einem Report.\nReports:" + line.getReports());
ReportLine reference = line.getReference(SingleReferenceType.WARRANTY);
// Rolling out the unit if still in Stock.
StockUnit stockUnit = // Saftynet, e.g. unit annex shoud not clear units.
line.getPositionType() == UNIT ? stockUnitEao.findByRefurbishId(line.getRefurbishId()) : null;
if (stockUnit != null && stockUnit.isInTransaction())
throw new UserInfoException("Unit is in einer StockTransaction. ID:" + stockUnit.getTransaction().getId());
ResolveResult msgs = new ResolveResult();
if (stockUnit == null) {
msgs.stockMessage = "Es existiert keine Stock Unit (mehr) zu dem Gerät";
msgs.redTapeMessage = "Keine StockUnit, Kein Vorgang";
} else {
LogicTransaction lt = stockUnit.getLogicTransaction();
long dossierId = lt.getDossierId();
Dossier dossier = dossierEao.findById(dossierId);
if (!repaymentCustomers.get(contractor).isPresent() || !repaymentCustomers.get(contractor).get().equals(dossier.getCustomerId())) {
throw new UserInfoException("Unit is nicht auf einem Auftrag eines Repayment Customers. DossierId:" + dossier.getId());
}
List<Document> activeDocuments = dossier.getActiveDocuments(DocumentType.BLOCK);
if (activeDocuments.size() != 1) {
throw new UserInfoException("Der Gutschriftsvorgang " + dossier.toSimpleLine() + " ist fehlerhaft, entweder kein oder zu viele akive Blocker");
}
Position pos = activeDocuments.get(0).getPositionByUniqueUnitId(stockUnit.getUniqueUnitId());
if (pos == null) {
throw new UserInfoException("Auf Gutschriftsvorgang " + dossier.toSimpleLine() + " ist das Gerät " + stockUnit.toSimple() + " nicht auffindbar");
}
msgs.redTapeMessage = "Kid: " + dossier.getCustomerId() + ", Vorgang:" + dossier.getIdentifier() + " wurde Gerät entfernt";
convertToComment(pos, arranger, comment);
lt.remove(stockUnit);
StockTransaction st = stEmo.requestRollOutPrepared(stockUnit.getStock().getId(), arranger, "Resolved Repayment");
st.addUnit(stockUnit);
msgs.stockMessage = stockUnit.toSimple() + " aus Lager ausgerollt auf StockTransaction(id=" + st.getId() + ")";
history.fire(new UnitHistory(stockUnit.getUniqueUnitId(), "Resolved Repayment", arranger));
stEmo.completeRollOut(arranger, Arrays.asList(st));
stockEm.flush();
if (lt.getUnits().isEmpty()) {
msgs.stockMessage += ", LogicTransaction " + lt.getId() + " ist jetzt leer, wird gelöscht";
stockEm.remove(lt);
}
}
Date startOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 1, 1).atStartOfDay(systemDefault()).toInstant());
Date endOfYear = Date.from(LocalDate.of(LocalDate.now().getYear(), 12, 31).atStartOfDay(systemDefault()).toInstant());
Report report = reportEmo.request(toReportName(contractor), contractor, startOfYear, endOfYear);
line.setComment(comment);
report.add(line);
msgs.reportMessage = "Repayment Unit " + line.getRefurbishId() + " line " + line.getId() + " resolved in " + report.getName();
if (reference != null) {
L.info("Warrenty Reference exist. Putted also into the report. ReportLine ID of Warrenty:{}", reference.getId());
reference.setComment(comment);
report.add(reference);
msgs.reportMessage += ", including warranty " + reference.getId();
}
return msgs;
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier 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);
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class DossierTableView method tableMouseClicked.
// </editor-fold>//GEN-END:initComponents
private void tableMouseClicked(java.awt.event.MouseEvent evt) {
// GEN-FIRST:event_tableMouseClicked
if (model == null || controller == null)
return;
int row = table.rowAtPoint(evt.getPoint());
table.setRowSelectionInterval(row, row);
Dossier selectedDos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
controller.selectionChanged(selectedDos);
if (evt.getClickCount() == 2 && table.getSelectedRow() != -1 && model != null) {
Dossier dos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
new HtmlDialog(SwingUtilities.getWindowAncestor(this), Dialog.ModalityType.MODELESS).setText(LegacyBridgeUtil.toHtmlDetailed(dos)).setVisible(true);
}
if (SwingUtilities.isRightMouseButton(evt)) {
dossierPopup.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class DossierTableView method tableKeyReleased.
// GEN-LAST:event_tableFilterButtonMousePressed
private void tableKeyReleased(java.awt.event.KeyEvent evt) {
// GEN-FIRST:event_tableKeyReleased
if (evt.getKeyCode() == KeyEvent.VK_UP || evt.getKeyCode() == KeyEvent.VK_DOWN) {
Dossier selectedDos = model.getDossier(table.convertRowIndexToModel(table.getSelectedRow()));
controller.selectionChanged(selectedDos);
}
}
use of eu.ggnet.dwoss.redtape.ee.entity.Dossier in project dwoss by gg-net.
the class DossierFilterController method setModel.
public void setModel(final DossierFilterModel model) {
this.model = model;
this.model.setFilter(filter);
for (Dossier dossier : dossiers) {
this.model.add(dossier);
}
restartDossierLoader();
}
Aggregations