Finish Hotfix-86
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20241007093433 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if(!isCustomer(IntegryCustomer.RossoGargano)) return;
|
||||
|
||||
executeStatement(
|
||||
"update ctb_part \n" +
|
||||
"set ctb_part.cod_abi = vs_banca.cod_abi,\n" +
|
||||
"ctb_part.cod_cab = vs_banca.cod_cab,\n" +
|
||||
"ctb_part.iban = vs_banca.iban,\n" +
|
||||
"ctb_part.cod_banc = gtb_banc_azi.cod_banc_azi\n" +
|
||||
"from rossogarganoExchange.dbo.pnota inner join rg_crl_movt on pnota.pn_data_competenza = rg_crl_movt.pn_data_competenza\n" +
|
||||
"and pnota.pn_nro_reg = rg_crl_movt.pn_nro_reg\n" +
|
||||
"inner join ctb_parr on rg_crl_movt.num_cmov = ctb_parr.num_cmov\n" +
|
||||
"inner join ctb_part on ctb_parr.tipo_anag = ctb_part.tipo_anag\n" +
|
||||
"and ctb_parr.cod_anag = ctb_part.cod_anag\n" +
|
||||
"and ctb_parr.anno_part = ctb_part.anno_part\n" +
|
||||
"and ctb_parr.ser_doc = ctb_part.ser_doc\n" +
|
||||
"and ctb_parr.num_doc = ctb_part.num_doc\n" +
|
||||
"left outer join (select cbanca_key1,\n" +
|
||||
"\tiif (CBANCA.CBANCA_PAESE = 'IT', IIF(LEN(CBANCA.CBANCA_CC) > 0, CBANCA.CBANCA_PAESE + CBANCA.CBANCA_CTRL + CBANCA.CBANCA_CIN + CBANCA.CBANCA_ABI + CBANCA.CBANCA_CAB + CBANCA.CBANCA_CC,NULL) , CBANCA.CBANCA_BBAN) AS IBAN,\n" +
|
||||
"\tCBANCA.CBANCA_ABI AS COD_ABI,\n" +
|
||||
"\tCBANCA.CBANCA_CAB AS COD_CAB,\n" +
|
||||
"\tCBANCA.CBANCA_CC AS NUM_CC,\n" +
|
||||
"\tiif(len(CBANCA.CBANCA_BIC)=0,null, trim(CBANCA.CBANCA_BIC) ) AS COD_BIc\n" +
|
||||
"\tfrom RossoGarganoExchange.dbo.cbanca) vs_banca on pnota.pn_vs_banca_cc = vs_banca.cbanca_key1\n" +
|
||||
"left outer join (select cbanca_key1,\n" +
|
||||
"\tcbanca_c_coge\n" +
|
||||
"\tfrom RossoGarganoExchange.dbo.cbanca) ns_banca on ns_banca.cbanca_key1 like '%' + pnota.pn_ns_banca_cc \n" +
|
||||
"left outer join ctb_cont on ns_banca.cbanca_c_coge = ctb_cont.diacod\n" +
|
||||
"left outer join gtb_banc_azi on ctb_cont.cod_ccon = gtb_banc_azi.cod_ccon_ordinario\n" +
|
||||
"where Len(pnota.pn_vs_banca_cc) <> 0 OR Len(pnota.pn_ns_banca_cc) <> 0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
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;
|
||||
|
||||
public class Migration_20241007142159 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "ATTIVO", "N",
|
||||
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "EMAIL_FOR_LOG", null,
|
||||
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "FILE_FILTER", null,
|
||||
"Inserire il criterio di filtro dei file o il nome del file specifio (seguire la sintassi di java)", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "GG_CANC_FILE", null,
|
||||
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "IMPORT_REST", "S",
|
||||
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "LISTENING", "N",
|
||||
"Se LISTENIG = 'N' la procedura di importazione non si potrà mai mettere in ascolto sulla directory perchè nella procedura vengono prese in considerazione più file.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "PATH_FILE", null,
|
||||
"Directory contente i file da importare.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "PATH_FILE_IMPORTED", null,
|
||||
"Directory dove vengono spostati i file dopo l'importazione.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "TIPO_DOCUMENTO", null,
|
||||
"Tipi documento su cui assegnare i riferimenti.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "PARTITA_IVA", null,
|
||||
"Partita Iva del fornitore.", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
createSetup("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "USE_PART_IVA_AZIENDA", "S",
|
||||
"Usa partita iva per riconoscere l'azienda.", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("IMPORT_DOCUMENTI", "APULIA_RIFORD", "USE_PART_IVA_AZIENDA", "N",
|
||||
"Usa partita iva per riconoscere l'azienda.", false, "SI_NO", false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Carelli_Carelli)) return;
|
||||
|
||||
updateSetupValue("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "TIPO_DOCUMENTO", "BA|BA1|FTIA|FRCDF|FAD" );
|
||||
updateSetupValue("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "ATTIVO", "S" );
|
||||
updateSetupValue("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "LISTENING", "S" );
|
||||
updateSetupValue("IMPORT_DOCUMENTI", "PAZIENZA_RIFORD", "PARTITA_IVA", "07716650721" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1018,6 +1018,39 @@ public class RossoGarganoSyncService {
|
||||
String tipoReg = ctbMovt.getCodIreg().substring(0, 1);
|
||||
int annoPart = UtilityDate.getYear(ctbMovt.getDataDoc());
|
||||
|
||||
//Recuperare la banca del cliente o dell'azienda
|
||||
String vsBanca = (String) dati.get("PN_VS_BANCA_CC");
|
||||
String nsBanca = (String) dati.get("PN_NS_BANCA_CC");
|
||||
|
||||
String iban = null, codAbi = null, codCab = null, codBanc = null;
|
||||
if (!UtilityString.isNullOrEmpty(vsBanca)){
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT iif (CBANCA.CBANCA_PAESE = 'IT', IIF(LEN(CBANCA.CBANCA_CC) > 0, CBANCA.CBANCA_PAESE + CBANCA.CBANCA_CTRL + CBANCA.CBANCA_CIN + CBANCA.CBANCA_ABI + CBANCA.CBANCA_CAB + CBANCA.CBANCA_CC,NULL) , CBANCA.CBANCA_BBAN) AS IBAN,\n" +
|
||||
"CBANCA.CBANCA_ABI AS COD_ABI,\n" +
|
||||
"CBANCA.CBANCA_CAB AS COD_CAB\n" +
|
||||
" FROM cbanca\n"+
|
||||
" WHERE cbanca_key1 = %s", vsBanca) ;
|
||||
HashMap<String, Object> datiBanca = UtilityDB.executeSimpleQueryOnlyFirstRow(suorceData, sql);
|
||||
if (UtilityHashMap.isPresent(datiBanca)){
|
||||
iban = (String) datiBanca.get("IBAN");
|
||||
codAbi = (String) datiBanca.get("COD_ABI");
|
||||
codCab = (String) datiBanca.get("COD_CAB");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(nsBanca)){
|
||||
String dbName =multiDBTransactionManager.getPrimaryDatasource().getDbName();
|
||||
String sql =
|
||||
"SELECT gtb_banc_azi.cod_banc\n" +
|
||||
" FROM cbanca \n" +
|
||||
" INNER JOIN "+ dbName+ ".dbo.ctb_cont on cbanca.cbanca_c_coge = ctb_cont.diacod \n"+
|
||||
" INNER JOIN "+ dbName+ ".dbo.gtb_banc_azi on ctb_cont.cod_ccon = gtb_banc_azi.cod_ccon_ordinario \n"+
|
||||
" WHERE cbanca_key1 like '%" + nsBanca + "'" ;
|
||||
codBanc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(suorceData, sql);
|
||||
}
|
||||
|
||||
CtbPart ctbPart =
|
||||
new CtbPart()
|
||||
.setDataDoc(ctbMovt.getDataDoc())
|
||||
@@ -1030,7 +1063,11 @@ public class RossoGarganoSyncService {
|
||||
.setTotImponib(imponib)
|
||||
.setTotIva(iva)
|
||||
.setCodVage((String) dati.get("PN_COD_AGENTE"))
|
||||
.setCodPaga((String) dati.get("PN_COD_PAGAMENTO"));
|
||||
.setCodPaga((String) dati.get("PN_COD_PAGAMENTO"))
|
||||
.setCodAbi(codAbi)
|
||||
.setCodCab(codCab)
|
||||
.setIban(iban)
|
||||
.setCodBanc(codBanc);
|
||||
ctbPart.setOperation(OperationType.INSERT);
|
||||
// List<CtbScad> listaScadenze = new ArrayList<>();
|
||||
//
|
||||
|
||||
@@ -156,6 +156,7 @@ public class DocumentiImporter extends BaseEntityImporter<List<EntityBase>> impl
|
||||
.importDocumentiVenditaGelorent(type, format, requestDto.getRawContent(), anomalie);
|
||||
break;
|
||||
case APULIA_RIFORD:
|
||||
case PAZIENZA_RIFORD:
|
||||
entities = getContextBean(DocumentiAcquistoImportService.class)
|
||||
.importApuliaRifOrd(type, format, requestDto, anomalie, headless);
|
||||
break;
|
||||
@@ -220,6 +221,7 @@ public class DocumentiImporter extends BaseEntityImporter<List<EntityBase>> impl
|
||||
SCAR_MP_DA_DIST("SCAR_MP_DA_DIST"),
|
||||
GELORENT("GELORENT"),
|
||||
APULIA_RIFORD("APULIA_RIFORD"),
|
||||
PAZIENZA_RIFORD("PAZIENZA_RIFORD"),
|
||||
CASSETTO_FISCALE("CASSETTO_FISCALE");
|
||||
|
||||
private String text;
|
||||
|
||||
@@ -890,8 +890,10 @@ public class DocumentiAcquistoImportService {
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
String tipiDoc = setup.get("TIPI_DOCUMENTO");
|
||||
String pIva = setup.get("PARTITA_IVA");
|
||||
|
||||
int ggImport = Integer.parseInt(setup.get("GG_IMPORT"));
|
||||
boolean usePartIvaAzienda = UtilityString.equalsIgnoreCase(setup.get("USE_PART_IVA_AZIENDA"), "S");
|
||||
int ggImport = 0;
|
||||
if ( setup.get("GG_IMPORT") != null )
|
||||
ggImport = Integer.parseInt(setup.get("GG_IMPORT"));
|
||||
|
||||
if (pIva == null || pIva.isEmpty()) {
|
||||
throw new Exception("Partita iva mancante");
|
||||
@@ -900,11 +902,12 @@ public class DocumentiAcquistoImportService {
|
||||
String fileName = requestDTO.getFileName();
|
||||
fileName = FilenameUtils.removeExtension(fileName);
|
||||
|
||||
Date dataFile = UtilityDate.StringToDate(fileName.substring(fileName.length() - 8), "yyyyMMdd");
|
||||
if (UtilityDate.DaysAfter(dataFile, UtilityDate.getTodayWithoutTime()) < ggImport) {
|
||||
throw new Exception("File con data antecedente alla data prevista per l'importazione");
|
||||
if (ggImport != 0 ) {
|
||||
Date dataFile = UtilityDate.StringToDate(fileName.substring(fileName.length() - 8), "yyyyMMdd");
|
||||
if (UtilityDate.DaysAfter(dataFile, UtilityDate.getTodayWithoutTime()) < ggImport) {
|
||||
throw new Exception("File con data antecedente alla data prevista per l'importazione");
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Row> rowIterator = UtilityExcel.readXlsxFile(requestDTO);
|
||||
List<RifOrdApuliaDTO> rifOrdApuliaList = new ArrayList<>();
|
||||
|
||||
@@ -915,23 +918,24 @@ public class DocumentiAcquistoImportService {
|
||||
String codiceAzienda = UtilityExcel.getCellAsString(row, 4);
|
||||
String codicePv = UtilityExcel.getCellAsString(row, 5);
|
||||
|
||||
String numFattura;
|
||||
Date dataFattura;
|
||||
Date dataFattura;
|
||||
|
||||
if (UtilityExcel.getCellAsString(row, 6).equalsIgnoreCase("0")) {
|
||||
String numFattura = UtilityExcel.getCellAsString(row, 6, false);
|
||||
if (UtilityString.isNullOrEmpty(numFattura ) || numFattura.equalsIgnoreCase("0")) {
|
||||
numFattura = UtilityExcel.getCellAsString(row, 1);
|
||||
dataFattura = UtilityExcel.getCellAsDate(row, 2, "yyyyMMdd");
|
||||
} else {
|
||||
numFattura = UtilityExcel.getCellAsString(row, 6);
|
||||
|
||||
dataFattura = UtilityExcel.getCellAsDate(row, 7, "yyyyMMdd");
|
||||
}
|
||||
|
||||
//Controllo che il numero dell'ordine sia formato solo da numeri
|
||||
if (numOrd.matches("\\d+")) {
|
||||
String finalNumFattura = numFattura;
|
||||
com.annimon.stream.Optional<RifOrdApuliaDTO> rifOrdApuliaDTOOptional = Stream.of(rifOrdApuliaList)
|
||||
.filter(i -> i.getCodicePv().equals(codicePv)
|
||||
&& i.getDataFattura().equals(dataFattura)
|
||||
&& i.getNumFattura().equals(numFattura)
|
||||
&& i.getNumFattura().equals(finalNumFattura)
|
||||
)
|
||||
.findFirst();
|
||||
|
||||
@@ -972,34 +976,42 @@ public class DocumentiAcquistoImportService {
|
||||
|
||||
for (AdvancedDataSource ds : multiDBTransactionManager.getActiveConnections()) {
|
||||
Connection connection = ds.getConnection();
|
||||
String codClie = null;
|
||||
|
||||
sql = "select cod_clie from gtb_anag inner join atb_forn on gtb_anag.cod_anag = atb_forn.cod_anag\n" +
|
||||
"where gtb_anag.part_iva = " + UtilityDB.valueToString(pIva) + " \n" +
|
||||
"and atb_forn.cod_clie is not null";
|
||||
String codClie = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
if (usePartIvaAzienda) {
|
||||
sql = "SELECT part_iva FROM azienda";
|
||||
codClie = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
} else {
|
||||
sql = "select cod_clie from gtb_anag inner join atb_forn on gtb_anag.cod_anag = atb_forn.cod_anag\n" +
|
||||
"where gtb_anag.part_iva = " + UtilityDB.valueToString(pIva) + " \n" +
|
||||
"and atb_forn.cod_clie is not null";
|
||||
codClie = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
if (codClie == null) {
|
||||
anomalie.add(
|
||||
AnomalieDTO.info(
|
||||
"Codice cliente non trovato: " +
|
||||
CommonConstants.A_CAPO +
|
||||
CommonConstants.TAB +
|
||||
CommonConstants.TAB +
|
||||
"ProfileDb: " + ds.getProfileName()
|
||||
)
|
||||
);
|
||||
if (codClie == null) {
|
||||
anomalie.add(
|
||||
AnomalieDTO.info(
|
||||
"Codice cliente non trovato: " +
|
||||
CommonConstants.A_CAPO +
|
||||
CommonConstants.TAB +
|
||||
CommonConstants.TAB +
|
||||
"ProfileDb: " + ds.getProfileName()
|
||||
)
|
||||
);
|
||||
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String finalCodClie = codClie;
|
||||
List<RifOrdApuliaDTO> list = Stream.of(rifOrdApuliaGroup)
|
||||
.filter(entry -> entry.getKey().equalsIgnoreCase(codClie))
|
||||
.filter(entry -> entry.getKey().equalsIgnoreCase(finalCodClie))
|
||||
.findFirst()
|
||||
.map(Map.Entry::getValue)
|
||||
.orElseGet(ArrayList::new);
|
||||
|
||||
if (list != null && !list.isEmpty()) {
|
||||
for (RifOrdApuliaDTO rifOrdApulia : list) {
|
||||
|
||||
sql = "select distinct mtb_depo_intercode.cod_mdep, mtb_depo_intercode.cod_forn, stb_gest_setup_depo.value as profile_db\n" +
|
||||
"from mtb_depo_intercode inner join gtb_anag on gtb_anag.cod_anag = mtb_depo_intercode.cod_forn \n" +
|
||||
"left outer join stb_gest_setup_depo on mtb_depo_intercode.cod_mdep = stb_gest_setup_depo.cod_mdep and\n" +
|
||||
@@ -1007,7 +1019,8 @@ public class DocumentiAcquistoImportService {
|
||||
"stb_gest_setup_depo.section = 'DATI_DEPOSITO' and \n" +
|
||||
"stb_gest_setup_depo.key_section = 'profile_db'\n" +
|
||||
"where gtb_anag.part_iva = " + UtilityDB.valueToString(pIva) + "\n" +
|
||||
"and intercode like '%<D>'+ " + UtilityDB.valueToString(rifOrdApulia.getCodicePv());
|
||||
"and ( intercode like '%<D>'+ " + UtilityDB.valueToString(rifOrdApulia.getCodicePv()) + " OR \n"+
|
||||
" mtb_depo_intercode.cod_mdep = " + UtilityDB.valueToString(rifOrdApulia.getCodicePv()) + ")";
|
||||
|
||||
HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user