Cambiati alcuni datasource
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:
18
.idea/copilotDiffState.xml
generated
18
.idea/copilotDiffState.xml
generated
File diff suppressed because one or more lines are too long
@@ -19,6 +19,15 @@ public class DataSource extends BasicDataSource {
|
|||||||
|
|
||||||
private AvailableConnectionsModel connectionModel;
|
private AvailableConnectionsModel connectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instanzia un nuovo datasource.
|
||||||
|
* @deprecated
|
||||||
|
* Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(String)} per ottenere una connessione.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public DataSource() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public EmsRestConstants.DB_TYPE getTypeDB() {
|
public EmsRestConstants.DB_TYPE getTypeDB() {
|
||||||
return connectionModel.getConnectionType();
|
return connectionModel.getConnectionType();
|
||||||
@@ -31,6 +40,7 @@ public class DataSource extends BasicDataSource {
|
|||||||
* @return una connessione dal pool
|
* @return una connessione dal pool
|
||||||
* @throws SQLException se si verifica un errore di accesso al database
|
* @throws SQLException se si verifica un errore di accesso al database
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
// Restituisce una nuova connessione dal pool di BasicDataSource, wrappata nel nostro tipo Connection
|
// Restituisce una nuova connessione dal pool di BasicDataSource, wrappata nel nostro tipo Connection
|
||||||
final Connection connection = Connection.fromConnection(super.getConnection());
|
final Connection connection = Connection.fromConnection(super.getConnection());
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ import java.util.TimerTask;
|
|||||||
|
|
||||||
public class EmailWatcherListener extends TimerTask {
|
public class EmailWatcherListener extends TimerTask {
|
||||||
|
|
||||||
private Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
private EmailListenerInfo emailListenerInfo;
|
private final EmailListenerInfo emailListenerInfo;
|
||||||
private EmsProperties prop;
|
private final EmsProperties prop;
|
||||||
private SetupGest setupGest;
|
private final SetupGest setupGest;
|
||||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
private final ResponseJSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
public EmailWatcherListener(EmailListenerInfo emailListenerInfo, EmsProperties prop,
|
public EmailWatcherListener(EmailListenerInfo emailListenerInfo, EmsProperties prop,
|
||||||
SetupGest setupGest, ResponseJSONObjectMapper jsonObjectMapper) {
|
SetupGest setupGest, ResponseJSONObjectMapper jsonObjectMapper) {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import it.integry.ems.Import.base.IEntityImporter;
|
|||||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||||
import it.integry.ems.Import.enums.EntityImportType;
|
import it.integry.ems.Import.enums.EntityImportType;
|
||||||
import it.integry.ems.datasource.DataSource;
|
|
||||||
import it.integry.ems.dto.*;
|
import it.integry.ems.dto.*;
|
||||||
import it.integry.ems.exception.MissingDataException;
|
import it.integry.ems.exception.MissingDataException;
|
||||||
import it.integry.ems.export.base.EntityExportResponse;
|
import it.integry.ems.export.base.EntityExportResponse;
|
||||||
@@ -32,6 +31,7 @@ import it.integry.ems.service.dto.AttachmentDTO;
|
|||||||
import it.integry.ems.service.dto.EntityFieldDTO;
|
import it.integry.ems.service.dto.EntityFieldDTO;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
@@ -130,6 +130,9 @@ public class EmsServices {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SettingsController settingsController;
|
private SettingsController settingsController;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BasicConnectionPool basicConnectionPool;
|
||||||
|
|
||||||
public EntityImportResponse<List<EntityBase>> importEntity(String type, String format, ImportRequestDTO body, boolean headless) throws Exception {
|
public EntityImportResponse<List<EntityBase>> importEntity(String type, String format, ImportRequestDTO body, boolean headless) throws Exception {
|
||||||
logger.debug("Starting import [Type: " + type + ", Format: " + format + "]");
|
logger.debug("Starting import [Type: " + type + ", Format: " + format + "]");
|
||||||
String gestName = "IMPORT_" + type;
|
String gestName = "IMPORT_" + type;
|
||||||
@@ -279,7 +282,7 @@ public class EmsServices {
|
|||||||
|
|
||||||
boolean anyError = checkForErrorsAndAddToResponse(entityImporter, tmpResult, result, gestName, format, fileContent, fileName, anomaliaIsError, headless);
|
boolean anyError = checkForErrorsAndAddToResponse(entityImporter, tmpResult, result, gestName, format, fileContent, fileName, anomaliaIsError, headless);
|
||||||
|
|
||||||
if (!anyError && fileContent != null && !anomaliaIsError){
|
if (!anyError && fileContent != null && !anomaliaIsError) {
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
FileUtils.writeByteArrayToFile(file, fileContent);
|
FileUtils.writeByteArrayToFile(file, fileContent);
|
||||||
moveFileImported(type, format, file, entityImporter, tmpResult);
|
moveFileImported(type, format, file, entityImporter, tmpResult);
|
||||||
@@ -505,7 +508,7 @@ public class EmsServices {
|
|||||||
@Nullable String mimeType,
|
@Nullable String mimeType,
|
||||||
@Nullable MrlPartitaMagAttached mrlPartitaMagAttached,
|
@Nullable MrlPartitaMagAttached mrlPartitaMagAttached,
|
||||||
@Nullable Date datetimeAttach) throws Exception {
|
@Nullable Date datetimeAttach) throws Exception {
|
||||||
return uploadStbFilesAttached(idAttach, filename, fileContent,descrizione,mimeType, null, mrlPartitaMagAttached, datetimeAttach);
|
return uploadStbFilesAttached(idAttach, filename, fileContent, descrizione, mimeType, null, mrlPartitaMagAttached, datetimeAttach);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +573,7 @@ public class EmsServices {
|
|||||||
if (mrlPartitaMagAttached != null)
|
if (mrlPartitaMagAttached != null)
|
||||||
stbFilesAttached.setMrlPartitaMagAttached(mrlPartitaMagAttached);
|
stbFilesAttached.setMrlPartitaMagAttached(mrlPartitaMagAttached);
|
||||||
|
|
||||||
if (drlDocAttached != null )
|
if (drlDocAttached != null)
|
||||||
stbFilesAttached.setDrlDocAttached(drlDocAttached);
|
stbFilesAttached.setDrlDocAttached(drlDocAttached);
|
||||||
|
|
||||||
entityProcessor.processEntity(stbFilesAttached, multiDBTransactionManager);
|
entityProcessor.processEntity(stbFilesAttached, multiDBTransactionManager);
|
||||||
@@ -714,7 +717,7 @@ public class EmsServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UtilityList.isNullOrEmpty(createZipDTO.getListDtbDocPdf())){
|
if (!UtilityList.isNullOrEmpty(createZipDTO.getListDtbDocPdf())) {
|
||||||
List<DtbDocPdf> listDtbDocPdf = createZipDTO.getListDtbDocPdf().stream()
|
List<DtbDocPdf> listDtbDocPdf = createZipDTO.getListDtbDocPdf().stream()
|
||||||
.peek(dtbDocPdf -> dtbDocPdf.setOperation(OperationType.SELECT_OBJECT))
|
.peek(dtbDocPdf -> dtbDocPdf.setOperation(OperationType.SELECT_OBJECT))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -996,7 +999,6 @@ public class EmsServices {
|
|||||||
" FROM azienda";
|
" FROM azienda";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (Connection connection : mdb.getActiveConnections()) {
|
for (Connection connection : mdb.getActiveConnections()) {
|
||||||
HashMap<String, Object> resultDbInfo = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
HashMap<String, Object> resultDbInfo = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||||
|
|
||||||
@@ -1021,44 +1023,81 @@ public class EmsServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void importClientieOrdiniQuore() throws Exception {
|
private void importClientieOrdiniQuore() throws Exception {
|
||||||
DataSource ds = new DataSource();
|
try (Connection connection = basicConnectionPool.getConnection(settingsModel.getDefaultProfile())) {
|
||||||
ds.initialize(settingsModel.getDefaultProfile());
|
boolean enabled = Boolean.parseBoolean(setupGest.getSetup(connection,
|
||||||
|
"IMPORT_ORDINI WEB", "CONQUIST", "ENABLED"));
|
||||||
|
String folder = setupGest.getSetup(connection, "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||||
|
|
||||||
Boolean enabled = Boolean.parseBoolean(setupGest.getSetup(ds.getConnection(),
|
if (UtilityString.isNullOrEmpty(folder))
|
||||||
"IMPORT_ORDINI WEB", "CONQUIST", "ENABLED"));
|
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/FOLDER non configurato correttamente");
|
||||||
String folder = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
|
||||||
ds.close();
|
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(folder))
|
if (enabled && "/ems-api".equals(properties.getRootApi())) {
|
||||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/FOLDER non configurato correttamente");
|
String csv, auth;
|
||||||
|
String database = settingsModel.getDefaultProfile();
|
||||||
|
|
||||||
if (enabled && "/ems-api".equals(properties.getRootApi())) {
|
File errorDirectory = new File(folder + "/import/error");
|
||||||
String csv, auth;
|
if (!errorDirectory.exists())
|
||||||
String database = settingsModel.getDefaultProfile();
|
errorDirectory.mkdir();
|
||||||
|
|
||||||
File errorDirectory = new File(folder + "/import/error");
|
File[] files = getFileListQuore(folder, "clienti_");
|
||||||
if (!errorDirectory.exists())
|
for (int i = 0; i < files.length; i++) {
|
||||||
errorDirectory.mkdir();
|
File f = files[i];
|
||||||
|
if (f.exists()) {
|
||||||
|
csv = FileUtils.readFileToString(f);
|
||||||
|
|
||||||
File[] files = getFileListQuore(folder, "clienti_");
|
auth = RestUtil.generateAuth(database, database, "POST", "", "text/plain",
|
||||||
for (int i = 0; i < files.length; i++) {
|
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
||||||
File f = files[i];
|
|
||||||
if (f.exists()) {
|
|
||||||
csv = FileUtils.readFileToString(f);
|
|
||||||
|
|
||||||
auth = RestUtil.generateAuth(database, database, "POST", "", "text/plain",
|
Client client = ClientBuilder.newClient();
|
||||||
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
WebTarget resource = client.target(properties.getEndPointWS()).path(
|
||||||
|
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
||||||
|
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||||
|
.request().header("Authorization", database + ":" + auth)
|
||||||
|
.post(Entity.text(csv));
|
||||||
|
|
||||||
Client client = ClientBuilder.newClient();
|
String value = responseEms.readEntity(String.class);
|
||||||
WebTarget resource = client.target(properties.getEndPointWS()).path(
|
logger.info("CLIENTI RESPONSE: " + value);
|
||||||
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
if (!UtilityString.isNullOrEmpty(value)) {
|
||||||
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||||
.request().header("Authorization", database + ":" + auth)
|
|
||||||
.post(Entity.text(csv));
|
|
||||||
|
|
||||||
String value = responseEms.readEntity(String.class);
|
if (resp.getEsito() == EsitoType.KO) {
|
||||||
logger.info("CLIENTI RESPONSE: " + value);
|
File dest = new File(folder + "/import/error/" + f.getName());
|
||||||
if (!UtilityString.isNullOrEmpty(value)) {
|
FileOutputStream fos = new FileOutputStream(dest);
|
||||||
|
FileInputStream is = new FileInputStream(f);
|
||||||
|
IOUtils.copy(is, fos);
|
||||||
|
is.close();
|
||||||
|
fos.close();
|
||||||
|
f.delete();
|
||||||
|
|
||||||
|
logger.error("ERRORE IMPORTAZIONE CLIENTI CQ: " + value);
|
||||||
|
throw new Exception("Errore importazione clienti CQ");
|
||||||
|
} else if (resp.getEsito() == EsitoType.OK) {
|
||||||
|
// cancellazione file clienti
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
responseEms.close();
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
files = getFileListQuore(folder, "ordini_");
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
File f = files[i];
|
||||||
|
if (f.exists()) {
|
||||||
|
csv = FileUtils.readFileToString(f);
|
||||||
|
|
||||||
|
auth = RestUtil.generateAuth(database, database, "POST", "", "text/plain",
|
||||||
|
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_ORDINI_CQ);
|
||||||
|
|
||||||
|
Client client = ClientBuilder.newClient();
|
||||||
|
WebTarget resource = client.target(properties.getEndPointWS()).path(
|
||||||
|
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_ORDINI_CQ);
|
||||||
|
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||||
|
.request().header("Authorization", database + ":" + auth)
|
||||||
|
.post(Entity.text(csv));
|
||||||
|
|
||||||
|
String value = responseEms.readEntity(String.class);
|
||||||
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||||
|
|
||||||
if (resp.getEsito() == EsitoType.KO) {
|
if (resp.getEsito() == EsitoType.KO) {
|
||||||
@@ -1070,54 +1109,15 @@ public class EmsServices {
|
|||||||
fos.close();
|
fos.close();
|
||||||
f.delete();
|
f.delete();
|
||||||
|
|
||||||
logger.error("ERRORE IMPORTAZIONE CLIENTI CQ: " + value);
|
logger.error("ERRORE IMPORTAZIONE ORDINI CQ: " + value);
|
||||||
throw new Exception("Errore importazione clienti CQ");
|
throw new Exception("Errore importazione ORDINI CQ");
|
||||||
} else if (resp.getEsito() == EsitoType.OK) {
|
|
||||||
// cancellazione file clienti
|
|
||||||
f.delete();
|
|
||||||
}
|
}
|
||||||
}
|
responseEms.close();
|
||||||
responseEms.close();
|
client.close();
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files = getFileListQuore(folder, "ordini_");
|
// cancellazione file ordini
|
||||||
for (int i = 0; i < files.length; i++) {
|
|
||||||
File f = files[i];
|
|
||||||
if (f.exists()) {
|
|
||||||
csv = FileUtils.readFileToString(f);
|
|
||||||
|
|
||||||
auth = RestUtil.generateAuth(database, database, "POST", "", "text/plain",
|
|
||||||
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_ORDINI_CQ);
|
|
||||||
|
|
||||||
Client client = ClientBuilder.newClient();
|
|
||||||
WebTarget resource = client.target(properties.getEndPointWS()).path(
|
|
||||||
properties.getRootApi() + EmsRestConstants.PATH_IMPORT_ORDINI_CQ);
|
|
||||||
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
|
||||||
.request().header("Authorization", database + ":" + auth)
|
|
||||||
.post(Entity.text(csv));
|
|
||||||
|
|
||||||
String value = responseEms.readEntity(String.class);
|
|
||||||
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
|
||||||
|
|
||||||
if (resp.getEsito() == EsitoType.KO) {
|
|
||||||
File dest = new File(folder + "/import/error/" + f.getName());
|
|
||||||
FileOutputStream fos = new FileOutputStream(dest);
|
|
||||||
FileInputStream is = new FileInputStream(f);
|
|
||||||
IOUtils.copy(is, fos);
|
|
||||||
is.close();
|
|
||||||
fos.close();
|
|
||||||
f.delete();
|
f.delete();
|
||||||
|
|
||||||
logger.error("ERRORE IMPORTAZIONE ORDINI CQ: " + value);
|
|
||||||
throw new Exception("Errore importazione ORDINI CQ");
|
|
||||||
}
|
}
|
||||||
responseEms.close();
|
|
||||||
client.close();
|
|
||||||
|
|
||||||
// cancellazione file ordini
|
|
||||||
f.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import it.integry.ems.activity.dto.DescrizioneTipiAttivitaDTO;
|
|||||||
import it.integry.ems.activity.dto.ModellinoDTO;
|
import it.integry.ems.activity.dto.ModellinoDTO;
|
||||||
import it.integry.ems.activity.dto.SteUPEntryDTO;
|
import it.integry.ems.activity.dto.SteUPEntryDTO;
|
||||||
import it.integry.ems.activity.dto.SteUpScoreDTO;
|
import it.integry.ems.activity.dto.SteUpScoreDTO;
|
||||||
import it.integry.ems.datasource.DataSource;
|
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableColumn;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableColumn;
|
||||||
@@ -22,6 +21,7 @@ import it.integry.ems.service.MailService;
|
|||||||
import it.integry.ems.service.ReportProcessor;
|
import it.integry.ems.service.ReportProcessor;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.system.service.SystemService;
|
import it.integry.ems.system.service.SystemService;
|
||||||
@@ -84,7 +84,8 @@ public class SteUPService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SettingsModel settingsModel;
|
private SettingsModel settingsModel;
|
||||||
|
@Autowired
|
||||||
|
private BasicConnectionPool basicConnectionPool;
|
||||||
|
|
||||||
|
|
||||||
private UserDTO authUser(String md5User) throws Exception {
|
private UserDTO authUser(String md5User) throws Exception {
|
||||||
@@ -122,10 +123,10 @@ public class SteUPService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public HashMap<String, Object> login(String profileDb, String username, String password) throws Exception {
|
public HashMap<String, Object> login(String profileDb, String username, String password) throws Exception {
|
||||||
return login(profileDb, UtilityHash.generateMd5(String.format("%s%s", username, password)));
|
return login(profileDb, UtilityHash.generateMd5(String.format("%s%s", username, password)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Object> login(String profileDb, String md5User) throws Exception {
|
public HashMap<String, Object> login(String profileDb, String md5User) throws Exception {
|
||||||
HashMap<String, Object> toReturn = new HashMap<>();
|
HashMap<String, Object> toReturn = new HashMap<>();
|
||||||
|
|
||||||
@@ -655,7 +656,7 @@ public class SteUPService {
|
|||||||
String content = new String(contentB64);
|
String content = new String(contentB64);
|
||||||
barcodes = UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO);
|
barcodes = UtilityString.splitStringToMultipleLine(content, CommonConstants.A_CAPO);
|
||||||
saveFile = false;
|
saveFile = false;
|
||||||
} else if (UtilityDebug.isDebugExecution() ) {
|
} else if (UtilityDebug.isDebugExecution()) {
|
||||||
barcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
barcodes = UtilityDB.executeSimpleQueryOnlyFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||||
"select cod_mart from stb_activity where parent_activity_id = 'C0000843821'");
|
"select cod_mart from stb_activity where parent_activity_id = 'C0000843821'");
|
||||||
} else {
|
} else {
|
||||||
@@ -691,7 +692,7 @@ public class SteUPService {
|
|||||||
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
} else if (activityTypeId.equalsIgnoreCase(tipoAttivitaRotturaStock)) {
|
||||||
List<HashMap<String, Object>> pluRepo = getGrigliaPluRepo(codMdep, codJfas, activityTypeId, null, dataCreation, true, barcodes);
|
List<HashMap<String, Object>> pluRepo = getGrigliaPluRepo(codMdep, codJfas, activityTypeId, null, dataCreation, true, barcodes);
|
||||||
if (repartiFreschi != null && repartiFreschi.contains(codJfas)) {
|
if (repartiFreschi != null && repartiFreschi.contains(codJfas)) {
|
||||||
if ( barcodes != null && !barcodes.isEmpty()) {
|
if (barcodes != null && !barcodes.isEmpty()) {
|
||||||
List<String> finalBarcodes = barcodes;
|
List<String> finalBarcodes = barcodes;
|
||||||
barcodes = new ArrayList<>();
|
barcodes = new ArrayList<>();
|
||||||
|
|
||||||
@@ -712,7 +713,7 @@ public class SteUPService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
barcodes.addAll(pluRepo.stream().filter(x -> x.get("barcode") != null).map(x->x.get("barcode").toString()).collect(Collectors.toList()));
|
barcodes.addAll(pluRepo.stream().filter(x -> x.get("barcode") != null).map(x -> x.get("barcode").toString()).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
// barcodes = pluRepo.stream().filter(a-> !finalBarcodes.contains(((String) a.get("barcode")))).map(a->(String) a.get("barcode")).collect(Collectors.toList());
|
// barcodes = pluRepo.stream().filter(a-> !finalBarcodes.contains(((String) a.get("barcode")))).map(a->(String) a.get("barcode")).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
@@ -861,11 +862,11 @@ public class SteUPService {
|
|||||||
sql =
|
sql =
|
||||||
"SELECT griglia.cod_mart, \n" +
|
"SELECT griglia.cod_mart, \n" +
|
||||||
"descrizione, \n" +
|
"descrizione, \n" +
|
||||||
(chkRotturaStock?"mvw_barcode.cod_barre":"griglia.bar_code") + " as barcode, \n" +
|
(chkRotturaStock ? "mvw_barcode.cod_barre" : "griglia.bar_code") + " as barcode, \n" +
|
||||||
"cod_msgr\n " +
|
"cod_msgr\n " +
|
||||||
" from steup_getGrigliaVendita(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ") griglia " +
|
" from steup_getGrigliaVendita(" + UtilityDB.valueToString(codMdep) + "," + UtilityDB.valueToString(codJfas) + ") griglia " +
|
||||||
(chkRotturaStock?" INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart ":"") +
|
(chkRotturaStock ? " INNER JOIN mvw_barcode on griglia.cod_mart_kit = mvw_barcode.cod_mart " : "") +
|
||||||
" WHERE griglia.cod_mart NOT IN (SELECT cod_mart\n" +
|
" WHERE griglia.cod_mart NOT IN (SELECT cod_mart\n" +
|
||||||
" FROM (SELECT cod_mart,\n" +
|
" FROM (SELECT cod_mart,\n" +
|
||||||
" cod_mdep,\n" +
|
" cod_mdep,\n" +
|
||||||
" data_validita,\n" +
|
" data_validita,\n" +
|
||||||
@@ -949,61 +950,58 @@ public class SteUPService {
|
|||||||
|
|
||||||
public void uploadAttachmentTmp() throws Exception {
|
public void uploadAttachmentTmp() throws Exception {
|
||||||
|
|
||||||
DataSource ds = new DataSource();
|
try (Connection connection = basicConnectionPool.getConnection("WINACT")) {
|
||||||
String integry = "WINACT";
|
|
||||||
ds.initialize(integry);
|
|
||||||
|
|
||||||
String sql =
|
String sql =
|
||||||
"select a.activity_id, t.activity_id_new, f.file_name, f.last_upd " +
|
"select a.activity_id, t.activity_id_new, f.file_name, f.last_upd " +
|
||||||
"from stb_activity a inner join stb_activity_file f on a.activity_id = f.id " +
|
"from stb_activity a inner join stb_activity_file f on a.activity_id = f.id " +
|
||||||
"inner join winact_tmp_isp t on a.activity_id = t.activity_id " +
|
"inner join winact_tmp_isp t on a.activity_id = t.activity_id " +
|
||||||
"where parent_activity_id in ( " +
|
"where parent_activity_id in ( " +
|
||||||
"select activity_id " +
|
"select activity_id " +
|
||||||
"from stb_activity " +
|
"from stb_activity " +
|
||||||
"where parent_activity_id is null " +
|
"where parent_activity_id is null " +
|
||||||
"and effective_date = '2021/12/03' ) and activity_id_new in ('C0000348319')";
|
"and effective_date = '2021/12/03' ) and activity_id_new in ('C0000348319')";
|
||||||
|
|
||||||
List<HashMap<String, Object>> resDati = UtilityDB.executeSimpleQuery(ds.getConnection(), sql);
|
List<HashMap<String, Object>> resDati = UtilityDB.executeSimpleQuery(connection, sql);
|
||||||
|
|
||||||
for (HashMap<String, Object> dati : resDati) {
|
for (HashMap<String, Object> dati : resDati) {
|
||||||
System.out.println(dati.get("activity_id_new") + " " + dati.get("file_name"));
|
logger.debug(dati.get("activity_id_new") + " " + dati.get("file_name"));
|
||||||
|
|
||||||
sql =
|
sql = "SELECT content " +
|
||||||
"SELECT content " +
|
" FROM stb_activity_file " +
|
||||||
" FROM stb_activity_file " +
|
" WHERE id = " + UtilityDB.valueToString(dati.get("activity_id")) + " AND " +
|
||||||
" WHERE id = " + UtilityDB.valueToString(dati.get("activity_id")) + " AND " +
|
"file_name = " + UtilityDB.valueToString(dati.get("file_name"));
|
||||||
"file_name = " + UtilityDB.valueToString(dati.get("file_name"));
|
|
||||||
|
|
||||||
byte[] content = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(ds.getConnection(), sql);
|
byte[] content = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
StbActivityFile stbActivityFile =
|
StbActivityFile stbActivityFile =
|
||||||
new StbActivityFile()
|
new StbActivityFile()
|
||||||
.setFileName((String) dati.get("file_name"))
|
.setFileName((String) dati.get("file_name"))
|
||||||
.setContent(content)
|
.setContent(content)
|
||||||
.setLastUpd((Date) dati.get("last_upd"));
|
.setLastUpd((Date) dati.get("last_upd"));
|
||||||
|
|
||||||
stbActivityFile.setOperation(OperationType.INSERT_OR_UPDATE);
|
stbActivityFile.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
List<StbActivityFile> files = new ArrayList<>();
|
List<StbActivityFile> files = new ArrayList<>();
|
||||||
files.add(stbActivityFile);
|
files.add(stbActivityFile);
|
||||||
|
|
||||||
StbActivity stbActivity =
|
StbActivity stbActivity =
|
||||||
new StbActivity()
|
new StbActivity()
|
||||||
.setActivityId((String) dati.get("activity_id_new"))
|
.setActivityId((String) dati.get("activity_id_new"))
|
||||||
.setStbActivityFile(files);
|
.setStbActivityFile(files);
|
||||||
|
|
||||||
|
|
||||||
stbActivity.setOperation(OperationType.NO_OP);
|
stbActivity.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
entityProcessor.processEntity(stbActivity, multiDBTransactionManager);
|
entityProcessor.processEntity(stbActivity, multiDBTransactionManager);
|
||||||
|
|
||||||
|
if (stbActivity.getException() != null) {
|
||||||
|
logger.error("uploadAttachment", stbActivity.getException());
|
||||||
|
}
|
||||||
|
|
||||||
if (stbActivity.getException() != null) {
|
|
||||||
logger.error("uploadAttachment", stbActivity.getException());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
multiDBTransactionManager.commitAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
multiDBTransactionManager.commitAll();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -200,8 +200,6 @@ public class DocumentiConsortileService {
|
|||||||
|
|
||||||
// Connessione al database dell'azienda agricola
|
// Connessione al database dell'azienda agricola
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
DataSource dsSync = new DataSource();
|
|
||||||
dsSync.initialize(profileDB);
|
|
||||||
multiDBTransactionManagerAzAgr.setPrimaryDs(profileDB);
|
multiDBTransactionManagerAzAgr.setPrimaryDs(profileDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user