Tracciato MIRARCHI

This commit is contained in:
2024-06-17 19:23:29 +02:00
parent ba0e4650ce
commit b69d79381b
5 changed files with 129 additions and 49 deletions

View File

@@ -0,0 +1,22 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240617175328 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "MIRARCHI", "TIPO_CALC", "PEDANE", "Tipologia calcolo ripartizione costi", false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -0,0 +1,22 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240617184702 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
createSetup("IMPORT_DOCUMENTI_TRASPORTO", "MIRARCHI", "TIPO_RIPARTIZIONE_COSTI_PER_PEDANA_A", "PEZZI", "Se il tipo di calcolo è a PEDANA allora si può decidere se la ripartizione dei costi deve essere fatta a pedana, a colli o a pezzi. E' stato necessario perchè spesso il numero di pedane del vettore è diverso dal numero di pedane che calcoliamo noi nei documenti", false, null, false, false, false, false, false, null, false, null);
}
@Override
public void down() throws Exception {
}
}

View File

@@ -21,6 +21,7 @@ public class DocCostiTrasportoController {
@Autowired
private DocCostiTrasporto documentService;
/*LA PROCEDURA PAPAGNI NON E' STATA REALIZZATA CON LA PROCEDURA GENERITA, MA FATTA AD HOC*/
@RequestMapping(value = EmsRestConstants.PATH_IMPORT_COSTI_TRASPORTO_PAPAGNI, method = RequestMethod.POST)
public @ResponseBody
ServiceRestResponse importCostiTrasportoPapagni(HttpServletRequest request,
@@ -38,26 +39,9 @@ public class DocCostiTrasportoController {
}
}
@RequestMapping(value = EmsRestConstants.PATH_IMPORT_COSTI_TRASPORTO_STEF, method = RequestMethod.POST)
public @ResponseBody
ServiceRestResponse importCostiTrasportoStef(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
@RequestBody ImportRequestDTO requestDataDTO) throws Exception {
List<ReturnDocCostiTrasportoDTO> docTrasp = new ArrayList<>();
try {
docTrasp = documentService.importDocumentiTrasportoStef(requestDataDTO);
return ServiceRestResponse.createPositiveResponse(docTrasp);
} catch (Exception e) {
return ServiceRestResponse.createNegativeResponse(e);
}
}
@RequestMapping(value = EmsRestConstants.PATH_IMPORT_COSTI_TRASPORTO, method = RequestMethod.POST)
public @ResponseBody
ServiceRestResponse importCostiTrasportoMirarchi(HttpServletRequest request,
ServiceRestResponse importCostiTrasporto(HttpServletRequest request,
@RequestParam(value = "type", required = false, defaultValue = "V") String type,
@RequestParam(value = "formato", required = false, defaultValue = "V") String format,
@RequestBody ImportRequestDTO requestDataDTO) throws Exception {
@@ -66,16 +50,22 @@ public class DocCostiTrasportoController {
List<ReturnDocCostiTrasportoDTO> docTrasp = new ArrayList<>();
try {
switch (type) {
switch (format) {
case "MIRARCHI":
docTrasp = documentService.importDocumentiTrasportoMirarchi(requestDataDTO, type, format);
break;
case "STEF":
docTrasp = documentService.importDocumentiTrasportoStef(requestDataDTO);
break;
case "EBC":
break;
case "ROTUNNO":
break;
case "DIPA":
break;
case "PAPAGNI":
docTrasp = documentService.importDocumentiTrasportoPapagni(requestDataDTO);
break;
}
return ServiceRestResponse.createPositiveResponse(docTrasp);

View File

@@ -21,6 +21,9 @@ public class DocTraspImportDTO {
private BigDecimal peso;
private BigDecimal colli;
private BigDecimal pallet;
private String gestione;
private String checkAnnoDoc;
private String checkVettore;
public Date getDataDoc() {
return dataDoc;
@@ -174,4 +177,28 @@ public class DocTraspImportDTO {
this.checkSerDoc = checkSerDoc;
return this;
}
public String getGestione() {
return gestione;
}
public void setGestione(String gestione) {
this.gestione = gestione;
}
public String getCheckAnnoDoc() {
return checkAnnoDoc;
}
public void setCheckAnnoDoc(String checkAnnoDoc) {
this.checkAnnoDoc = checkAnnoDoc;
}
public String getCheckVettore() {
return checkVettore;
}
public void setCheckVettore(String checkVettore) {
this.checkVettore = checkVettore;
}
}

View File

@@ -92,6 +92,7 @@ public class DocCostiTrasporto {
Integer idRiga = doc.getIdRiga();
String elencoDocDaEscludere = doc.getElencoDocDaEscludere();
String note = "";
String gestione = doc.getGestione();
String untMis = getUntMisFromTipoCalc(tipoCalc);
@@ -108,6 +109,24 @@ public class DocCostiTrasporto {
if (serDoc != null || doc.getCheckSerDoc().equals("S")) {
whereCondSerDoc = "dtb_doct.ser_doc = " + UtilityDB.valueToString(serDoc) ;
}
String whereCondGestione = "";
if (gestione != null){
whereCondGestione = "dtb_doct.gestione = " + UtilityDB.valueToString(gestione) ;
}
String whereCondDataAnnoDoc = "";
if (doc.getCheckAnnoDoc() == null || doc.getCheckAnnoDoc().equals("S")){
whereCondDataAnnoDoc = "(dtb_doct.data_doc = " + UtilityDB.valueDateToString(dataSped, CommonConstants.DATE_FORMAT_YMD) + " OR " +
" DATEPART(year, dtb_doct.data_doc) = " + UtilityDB.valueDateToString(dataSped, "YYYY") + ")";
} else {
whereCondDataAnnoDoc = "(dtb_doct.data_doc = " + UtilityDB.valueDateToString(dataSped, CommonConstants.DATE_FORMAT_YMD) + ")";
}
String whereCondVettore = "";
if (doc.getCheckVettore() !=null && doc.getCheckVettore().equals("S")) {
whereCondVettore = "(dtb_doct.cod_vvet = " + UtilityDB.valueToString(codVvet) + ")";
}
// Ricerca documento nel gestionale
sql =
@@ -123,29 +142,30 @@ public class DocCostiTrasporto {
" inner join gtb_anag on dtb_doct.cod_anag = gtb_anag.cod_anag " +
" where tipo_emissione = 'DIRETTA' and " +
" dtb_doct.gestione in ('A','V') AND " +
" (dtb_doct.data_doc = " + UtilityDB.valueDateToString(dataSped, CommonConstants.DATE_FORMAT_YMD) + " OR " +
" DATEPART(year, dtb_doct.data_doc) = " + UtilityDB.valueDateToString(dataSped, "YYYY") + ") AND " +
" dtb_doct.num_doc = " + UtilityDB.valueToString(numDoc) + " AND " +
" dtb_doct.cod_dtip not in (select * from dbo.ParseStringIntoArray("+ UtilityDB.valueToString(elencoDocDaEscludere) + ",'|'))";
sql = UtilityDB.addwhereCond(sql, whereCondSerDoc, true);
sql = UtilityDB.addwhereCond(sql, whereCondGestione, true);
sql = UtilityDB.addwhereCond(sql, whereCondDataAnnoDoc, true);
sql = UtilityDB.addwhereCond(sql, whereCondVettore, true);
PreparedStatement ps = connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet res = ps.executeQuery();
int rowCounter = UtilityDB.countRow(res);
while (res.next()) {
if (res.next()) {
codAnag = res.getString(1);
codDtip = res.getString(2);
ragSocDB = res.getString(3);
cittaDB = res.getString(4);
dataDoc = res.getDate(5);
serDoc = res.getString(6);
if (ragSocDB.compareTo(ragSoc) != 0) {
if (ragSoc != null && ragSocDB.compareTo(ragSoc) != 0) {
note += "@RAG_SOC=" + ragSoc + " da database";
}
if (cittaDB.compareTo(citta) != 0) {
if (citta != null && cittaDB.compareTo(citta) != 0) {
note += "@CITTA=" + citta + " da database";
}
break;
}
ps.close();
res.close();
@@ -177,7 +197,7 @@ public class DocCostiTrasporto {
UtilityString.equalsIgnoreCase(x.getSerDoc(), finalSerDoc) &&
x.getNumDoc().intValue() == finalNumDoc.intValue()).toList();
if (existDoc.size() != 0){
if (!existDoc.isEmpty()){
note += "@DOC_MORE=Il documento " + rifDoc + " è presente più volte ma con data spedizione differente nel file";
dataDoc = dataSped;
}
@@ -187,7 +207,7 @@ public class DocCostiTrasporto {
purtroppo STEF non fornisce nel file per ogni cliente che tipo di costo è stato associato.
Siamo costretti a fare il controllo qui perchè nel file non abbiamo il codice cliente e solo in questo punto viene identificato*/
if (format.equalsIgnoreCase(STEF)){
if (codAnag != null && elencoClientiTipoCalcPallet != null && elencoClientiTipoCalcPallet.indexOf(codAnag) >= 0){
if (codAnag != null && elencoClientiTipoCalcPallet != null && elencoClientiTipoCalcPallet.contains(codAnag)){
tipoCalc = "PEDANE";
untMis = getUntMisFromTipoCalc(tipoCalc);
tassato = doc.getPallet();
@@ -514,6 +534,10 @@ public class DocCostiTrasporto {
public List<ReturnDocCostiTrasportoDTO> importDocumentiTrasportoMirarchi(ImportRequestDTO requestDataDTO, String type, String format) throws Exception {
Integer idRiga = 0;
String checkSerieDoc = "N";
String gestione = "V";
String checkAnnoDoc = "N";
String checlVettore = "S";
List<ReturnDocCostiTrasportoDTO> docCostiTrasp = new ArrayList<>();
List<DocTraspImportDTO> listDocTrasp = new ArrayList<>();
HashMap<String, String> returns = new HashMap<String, String>();
@@ -530,39 +554,31 @@ public class DocCostiTrasporto {
Iterator<Row> rowIterator = mySheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
String rifDoc = dataFormatter.formatCellValue(row.getCell(1));
String dataSpedizione = String.valueOf(row.getCell(2));
String citta = dataFormatter.formatCellValue(row.getCell(3));
String UM = dataFormatter.formatCellValue(row.getCell(5));
BigDecimal tassato = new BigDecimal(String.valueOf(row.getCell(6)));
BigDecimal totaleNolo = new BigDecimal(String.valueOf(row.getCell(8)));
Date dataSped = new SimpleDateFormat("dd-MMM-yyyy").parse(dataSpedizione);
idRiga++;
if (idRiga == 1){
continue;
}
String rifDoc = dataFormatter.formatCellValue(row.getCell(0));
String dataSpedizione = String.valueOf(row.getCell(1));
String ragSoc = dataFormatter.formatCellValue(row.getCell(2));
BigDecimal tassato = new BigDecimal(String.valueOf(row.getCell(5)));
BigDecimal totaleNolo = new BigDecimal(String.valueOf(row.getCell(7)));
Date dataDoc = new SimpleDateFormat("dd-MMM-yyyy").parse(dataSpedizione);
String untMis = getUntMisFromTipoCalc(tipoCalc);
idRiga ++;
returns = getSerNumDoc(rifDoc);
String numDocFile = returns.get("numDoc");
String serDoc = returns.get("serDoc");
Integer numDoc = null;
if (rifDoc != null && UtilityString.isNumber(rifDoc)){
numDoc = Integer.valueOf(rifDoc);
}
Date dataDoc = null;
try {
dataDoc = new SimpleDateFormat("yyyyMMdd").parse(dataSpedizione);
} catch (Exception e){
logger.warn("Data documento non presente o non valida");
}
String checkSerieDoc = "N";
if (UtilityString.isNumber(rifDoc)){numDoc = Integer.valueOf(rifDoc);}
DocTraspImportDTO docTrasp = new DocTraspImportDTO();
docTrasp.setDataDoc(dataDoc);
docTrasp.setNumDoc(numDoc);
docTrasp.setSerDoc(serDoc);
docTrasp.setCitta(citta);
docTrasp.setRagSoc(ragSoc);
docTrasp.setNolo(totaleNolo);
docTrasp.setTassato(tassato);
docTrasp.setTipoCalc(tipoCalc);
@@ -570,7 +586,10 @@ public class DocCostiTrasporto {
docTrasp.setDataSped(dataDoc);
docTrasp.setRifDoc(rifDoc);
docTrasp.setIdRiga(idRiga);
docTrasp.setGestione(gestione);
docTrasp.setCheckSerDoc(checkSerieDoc);
docTrasp.setCheckAnnoDoc(checkAnnoDoc);
docTrasp.setCheckVettore(checlVettore);
listDocTrasp.add(docTrasp);
}
docCostiTrasp = checkAndImportDoc(listDocTrasp, format);