Gestito plu mancante come anomalie in importagione digi
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -17,7 +17,7 @@ public class BilanceImporter extends BaseEntityImporter<List<EntityBase>> implem
|
||||
if (enumFormat != null){
|
||||
switch (enumFormat) {
|
||||
case DIGI:
|
||||
entities = getContextBean(BilanceService.class).importBilance(type, format, requestDto);
|
||||
entities = getContextBean(BilanceService.class).importBilance(type, format, requestDto, anomalie);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Tipo " + format + " non supportato");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.retail.service;
|
||||
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
@@ -35,16 +36,19 @@ public class BilanceService {
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
public List<EntityBase> importBilance(String type, String format, ImportRequestDTO requestDto) throws Exception {
|
||||
public List<EntityBase> importBilance(String type, String format, ImportRequestDTO requestDto, List<AnomalieDTO> anomalie) throws Exception {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
List<EntityBase> returnList = new ArrayList<>();
|
||||
|
||||
String pathFile = setupGest.getImportSetup(conn, type, format, "PATH_FILE");
|
||||
if (UtilityString.isNullOrEmpty(pathFile)) throw new Exception(("Directory non configurata per l'importazione delle bilance"));
|
||||
if (!UtilityFile.directoryExists(pathFile)) throw new Exception("La directory specificata non esiste: " + pathFile);
|
||||
if (UtilityString.isNullOrEmpty(pathFile))
|
||||
throw new Exception(("Directory non configurata per l'importazione delle bilance"));
|
||||
if (!UtilityFile.directoryExists(pathFile))
|
||||
throw new Exception("La directory specificata non esiste: " + pathFile);
|
||||
|
||||
String pathFileImported = setupGest.getImportSetup(conn, type, format, "PATH_FILE_IMPORTED");
|
||||
if (UtilityString.isNullOrEmpty(pathFileImported)) throw new Exception("Directory per i file importati non configurata");
|
||||
if (UtilityString.isNullOrEmpty(pathFileImported))
|
||||
throw new Exception("Directory per i file importati non configurata");
|
||||
if (!UtilityFile.directoryExists(pathFileImported)) UtilityFile.directoryCreate(pathFileImported);
|
||||
|
||||
List<File> listFileToImport = new ArrayList<>();
|
||||
@@ -60,6 +64,7 @@ public class BilanceService {
|
||||
for (File file : listFileToImport) {
|
||||
String fileName = file.getName();
|
||||
String fileCodMdep = fileName.substring(0, 2);
|
||||
boolean fileWithError = false;
|
||||
|
||||
if (!codMdepList.contains(fileCodMdep))
|
||||
continue; // Skip files not matching any deposit code
|
||||
@@ -87,12 +92,19 @@ public class BilanceService {
|
||||
"WHERE plu = %s",
|
||||
plu
|
||||
);
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
pesata.setCodMart(UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql));
|
||||
if (codMart == null) {
|
||||
anomalie.add(AnomalieDTO.error("Codice PLU non trovato: " + plu + " nel file " + fileName));
|
||||
fileWithError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
pesata.setCodMart(codMart);
|
||||
pesate.add(pesata);
|
||||
}
|
||||
|
||||
if (pesate.isEmpty()) continue; // Skip files with no valid data
|
||||
if (pesate.isEmpty() || fileWithError) continue; // Skip files with no valid data
|
||||
|
||||
List<EntityBase> entityList = entityProcessor.processEntityList(pesate, true);
|
||||
UtilityEntity.throwEntitiesException(entityList);
|
||||
|
||||
Reference in New Issue
Block a user