[TOSCA]
importazione vettori e data consegna al cliente da Excel [GRAMM] corretto controllo in chiusura ordine
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.GtbAnag;
|
||||
import it.integry.ems_model.entity.StbPublications;
|
||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||
import it.integry.ems_model.entity.VtbVett;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
public class Migration_20241114130118 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Tosca_Cloud))
|
||||
return;
|
||||
StbPublications anagPublication = new StbPublications();
|
||||
anagPublication
|
||||
.setId(10L)
|
||||
.setPublicationDescription("Sincronizzazione Anagrafiche");
|
||||
anagPublication.setOperation(OperationType.NO_OP);
|
||||
|
||||
StbPublicationsDetail detailVtbVett = new StbPublicationsDetail();
|
||||
detailVtbVett
|
||||
.setActive(true)
|
||||
.setStbPublicationId(10L)
|
||||
.setReadyToTransmit(true)
|
||||
.setEntityName(VtbVett.ENTITY)
|
||||
.setExportHistory(false)
|
||||
.setOperation(OperationType.INSERT);
|
||||
anagPublication.getStbPublicationsDetails().add(detailVtbVett);
|
||||
anagPublication.manageWithParentConnection(advancedDataSource.getConnection(),droolsDataCompleting);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.integry.ems.customizations.sales.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
public class ToscaOrdineVenditaDTO {
|
||||
@@ -15,13 +14,19 @@ public class ToscaOrdineVenditaDTO {
|
||||
private String flowDirection;
|
||||
private Integer flowTypeId;
|
||||
private String flowTypeName;
|
||||
private Long CounterPId;
|
||||
private String CounterPNr;
|
||||
private String CounterPName;
|
||||
private Long counterPId;
|
||||
private String counterPNr;
|
||||
private String counterPName;
|
||||
private Long transporterId;
|
||||
private String transporterNumber;
|
||||
private String transporterName;
|
||||
private Date deliveryDate;
|
||||
|
||||
|
||||
private String codAnag;
|
||||
private String codMart;
|
||||
private String codMdep;
|
||||
private String codVvet;
|
||||
|
||||
|
||||
public String getTransactionNumber() {
|
||||
@@ -115,29 +120,29 @@ public class ToscaOrdineVenditaDTO {
|
||||
}
|
||||
|
||||
public Long getCounterPId() {
|
||||
return CounterPId;
|
||||
return counterPId;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setCounterPId(Long counterPId) {
|
||||
CounterPId = counterPId;
|
||||
this.counterPId = counterPId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCounterPNr() {
|
||||
return CounterPNr;
|
||||
return counterPNr;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setCounterPNr(String counterPNr) {
|
||||
CounterPNr = counterPNr;
|
||||
this.counterPNr = counterPNr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCounterPName() {
|
||||
return CounterPName;
|
||||
return counterPName;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setCounterPName(String counterPName) {
|
||||
CounterPName = counterPName;
|
||||
this.counterPName = counterPName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -167,4 +172,49 @@ public class ToscaOrdineVenditaDTO {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getTransporterId() {
|
||||
return transporterId;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setTransporterId(Long transporterId) {
|
||||
this.transporterId = transporterId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTransporterNumber() {
|
||||
return transporterNumber;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setTransporterNumber(String transporterNumber) {
|
||||
this.transporterNumber = transporterNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTransporterName() {
|
||||
return transporterName;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setTransporterName(String transporterName) {
|
||||
this.transporterName = transporterName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDeliveryDate() {
|
||||
return deliveryDate;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setDeliveryDate(Date deliveryDate) {
|
||||
this.deliveryDate = deliveryDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVvet() {
|
||||
return codVvet;
|
||||
}
|
||||
|
||||
public ToscaOrdineVenditaDTO setCodVvet(String codVvet) {
|
||||
this.codVvet = codVvet;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,24 +2,22 @@ package it.integry.ems.customizations.sales.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.customizations.sales.dto.ToscaOrdineVenditaDTO;
|
||||
import it.integry.ems.production.service.MesProductionServiceV2;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.entity.DtbOrdr;
|
||||
import it.integry.ems_model.entity.DtbOrdt;
|
||||
import it.integry.ems_model.entity.GtbAnag;
|
||||
import it.integry.ems_model.entity.VtbClie;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.bcel.classfile.Utility;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityExcel;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -42,6 +40,7 @@ public class ToscaSalesService {
|
||||
List<ToscaOrdineVenditaDTO> ordiniDaImportare = parseFile(inputStream);
|
||||
|
||||
importAnagrafiche(ordiniDaImportare);
|
||||
importVettori(ordiniDaImportare);
|
||||
|
||||
Map<String, List<ToscaOrdineVenditaDTO>> ordini = ordiniDaImportare.stream().collect(Collectors.groupingBy(ToscaOrdineVenditaDTO::getTransactionNumber));
|
||||
|
||||
@@ -76,6 +75,10 @@ public class ToscaSalesService {
|
||||
.setCounterPId(Long.valueOf(UtilityExcel.getCellAsString(row, 10)))
|
||||
.setCounterPNr(UtilityExcel.getCellAsString(row, 11))
|
||||
.setCounterPName(UtilityExcel.getCellAsString(row, 12))
|
||||
.setTransporterId(Long.valueOf(UtilityExcel.getCellAsString(row, 13)))
|
||||
.setTransporterNumber(UtilityExcel.getCellAsString(row, 14))
|
||||
.setTransporterName(UtilityExcel.getCellAsString(row, 15))
|
||||
.setDeliveryDate(UtilityExcel.getCellAsDate(row, 16, CommonConstants.DATE_FORMAT_DMY_DASHED))
|
||||
.setCodAnag(findCodAnagFromDiacod(newDTO.getCounterPNr()))
|
||||
.setCodMart(findCodMartFromDiacod(String.valueOf(newDTO.getItemNumber())))
|
||||
.setCodMdep(findCodMdepFromDiacod(newDTO.getDepotNumber()))
|
||||
@@ -106,7 +109,8 @@ public class ToscaSalesService {
|
||||
ToscaOrdineVenditaDTO testata = rows.get(0);
|
||||
DtbOrdt ordine = getOrdineVendita(transactionNumber, testata.getCodMdep());
|
||||
ordine.setCodAnag(testata.getCodAnag())
|
||||
.setCodMdep(testata.getCodMdep());
|
||||
.setCodMdep(testata.getCodMdep())
|
||||
.setCodVvet(testata.getCodVvet());
|
||||
|
||||
for (ToscaOrdineVenditaDTO row : rows) {
|
||||
DtbOrdr dbRow = ordine.getDtbOrdr().stream().filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart())).findFirst().orElse(new DtbOrdr());
|
||||
@@ -115,6 +119,7 @@ public class ToscaSalesService {
|
||||
.setCodMart(row.getCodMart())
|
||||
.setQtaOrd(row.getQuantityDelivered().abs())
|
||||
.setDataCons(row.getDateTransaction())
|
||||
.setDataConsAnag(row.getDeliveryDate())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (dbRow.getRigaOrd() == null) {
|
||||
ordine.getDtbOrdr().add(dbRow);
|
||||
@@ -188,6 +193,53 @@ public class ToscaSalesService {
|
||||
}
|
||||
}
|
||||
|
||||
private void importVettori(List<ToscaOrdineVenditaDTO> ordiniDaImportare) throws Exception {
|
||||
String sql = "SELECT vtb_vett.cod_vvet, gtb_anag.cod_anag,gtb_anag.diacod from gtb_anag inner join vtb_vett on vtb_vett.cod_anag = gtb_anag.cod_anag where diacod is not null ";
|
||||
List<HashMap<String, Object>> clientiEsistenti = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
List<EntityBase> entityToProcess = new ArrayList<>();
|
||||
if (UtilityList.isNullOrEmpty(clientiEsistenti))
|
||||
clientiEsistenti = new ArrayList<>();
|
||||
|
||||
for (ToscaOrdineVenditaDTO order : ordiniDaImportare) {
|
||||
if (!UtilityString.isNullOrEmpty(order.getCodVvet()))
|
||||
continue;
|
||||
|
||||
String codVvet = (String) (clientiEsistenti.stream()
|
||||
.filter(x -> ((String) x.get("diacod")).equalsIgnoreCase(order.getTransporterNumber())).
|
||||
findFirst()
|
||||
.orElse(new HashMap<>())
|
||||
.get("cod_vvet"));
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codVvet)) {
|
||||
order.setCodVvet(codVvet);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String ragSoc = order.getTransporterName();
|
||||
GtbAnag gtbAnag = new GtbAnag();
|
||||
gtbAnag
|
||||
.setPrecode("F")
|
||||
.setRagSoc(ragSoc.length() >= 40 ? ragSoc.substring(0, 39) : ragSoc)
|
||||
.setNote(ragSoc)
|
||||
.setDiacod(order.getTransporterNumber())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityToProcess.add(gtbAnag);
|
||||
|
||||
VtbVett vettore = new VtbVett();
|
||||
vettore.setRagSoc(ragSoc);
|
||||
vettore.setNote(String.valueOf(order.getTransporterId()));
|
||||
vettore.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityToProcess.add(vettore);
|
||||
entityProcessor.processEntityList(entityToProcess, true);
|
||||
HashMap<String, Object> newAnag = new HashMap<>();
|
||||
newAnag.put("cod_vvet", vettore.getCodVvet());
|
||||
newAnag.put("cod_anag", gtbAnag.getCodAnag());
|
||||
newAnag.put("diacod", order.getCounterPNr());
|
||||
clientiEsistenti.add(newAnag);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearOldOrders(List<String> rifOrd) throws Exception {
|
||||
|
||||
String sql = "SELECT dtb_ordr.*\n" +
|
||||
@@ -196,7 +248,7 @@ public class ToscaSalesService {
|
||||
" AND dtb_ordr.data_ord = dtb_ordt.data_ord\n" +
|
||||
" AND dtb_ordr.num_ord = dtb_ordt.num_ord\n" +
|
||||
"where dtb_ordt.gestione = 'V'\n" +
|
||||
"and dtb_ordr.flag_evaso_forzato = 'N' and dtb_ordt.rif_ord not in ("+UtilityDB.listValueToString(rifOrd)+");\n" +
|
||||
"and dtb_ordr.flag_evaso_forzato = 'N' and dtb_ordt.rif_ord not in (" + UtilityDB.listValueToString(rifOrd) + ");\n" +
|
||||
"\n";
|
||||
|
||||
List<DtbOrdr> righeOrdiniDaAnnullare = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbOrdr.class);
|
||||
|
||||
@@ -1032,7 +1032,7 @@ public class DocumentProdService {
|
||||
partitaMag = (String) datiOrd.get("partita_mag");
|
||||
}
|
||||
|
||||
if (carico.isTerminaLavorazione()) {
|
||||
if (!carico.isTerminaLavorazione()) {
|
||||
if (codJfas != null) {
|
||||
condFase = "mtb_colt.cod_jfas = " + UtilityDB.valueToString(codJfas);
|
||||
}
|
||||
|
||||
@@ -1348,6 +1348,7 @@ public class MesProductionServiceV2 {
|
||||
.setCodMart(oldRow.getCodMart())
|
||||
.setCodMdep(ordine.getCodMdep())
|
||||
.setNumCnf(oldRow.getNumCnf())
|
||||
.setQtaOrd(ordine.getQtaProd())
|
||||
.setColliPedana(oldRow.getColliPedana());
|
||||
ordine = productionService.saveOrdineProd(newOrdDTO);
|
||||
ordine.setOperation(OperationType.SELECT_OBJECT);
|
||||
|
||||
Reference in New Issue
Block a user