Finish Hotfix-100
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -8,6 +8,7 @@ import it.integry.ems.properties.EmsProperties;
|
|||||||
import it.integry.ems.response.EsitoType;
|
import it.integry.ems.response.EsitoType;
|
||||||
import it.integry.ems.response.FileItem;
|
import it.integry.ems.response.FileItem;
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
@@ -192,67 +193,66 @@ public class EmailWatcherListener extends TimerTask {
|
|||||||
private void notifyErrorToEmail(String emailListen, String mittente, String messageObj, Date messageDate,
|
private void notifyErrorToEmail(String emailListen, String mittente, String messageObj, Date messageDate,
|
||||||
String emailDbg, String errorMessage) throws Exception {
|
String emailDbg, String errorMessage) throws Exception {
|
||||||
if (!UtilityString.isNullOrEmpty(emailDbg)) {
|
if (!UtilityString.isNullOrEmpty(emailDbg)) {
|
||||||
DataSource ds = new DataSource();
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(emailListenerInfo.getDatabase())) {
|
||||||
ds.initialize(emailListenerInfo.getDatabase());
|
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||||
|
|
||||||
String nomeAzienda = "";
|
String nomeAzienda = "";
|
||||||
PreparedStatement ps = ds.getConnection().prepareStatement("select nome_ditta from azienda");
|
PreparedStatement ps = mdb.prepareStatement("select nome_ditta from azienda");
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
nomeAzienda = rs.getString("nome_ditta");
|
nomeAzienda = rs.getString("nome_ditta");
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
|
||||||
|
String htmlMailBody = "Gentile Amministratore,<br> si e' verificato il seguente errore <br><b>" + errorMessage + "</b><br> del servizio " + emailListenerInfo.getServiceRest() +
|
||||||
|
"<br> in ascolto sulla mail " + emailListen + " provocato dal messaggio (mittente " + mittente + ") con oggetto " + messageObj + " in data " + sdf.format(messageDate);
|
||||||
|
|
||||||
|
String mailSubject = nomeAzienda + " - ERRORE SU " + InetAddress.getLocalHost().getHostName() +
|
||||||
|
" Servizio " + emailListenerInfo.getServiceRest() + ";Database " + emailListenerInfo.getDatabase();
|
||||||
|
|
||||||
|
// AttachmentDTO dto = new AttachmentDTO();
|
||||||
|
// dto.setFileByte(files);
|
||||||
|
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
//jsonObjectMapper.writeValue(writer, dto);
|
||||||
|
|
||||||
|
String jsonBody = writer.toString();
|
||||||
|
|
||||||
|
String database = emailListenerInfo.getDatabase();
|
||||||
|
|
||||||
|
String auth = RestUtil.generateAuth(database, database, "POST", jsonBody,
|
||||||
|
"application/json", prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
||||||
|
|
||||||
|
final Client client = ClientBuilder.newClient();
|
||||||
|
WebTarget resource = client.target(prop.getEndPointWS()).path(
|
||||||
|
prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL)
|
||||||
|
.resolveTemplate("mode", "async");
|
||||||
|
resource = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||||
|
.queryParam("from", "").queryParam("to", emailDbg)
|
||||||
|
.queryParam("subject", mailSubject).queryParam("msgText", htmlMailBody)
|
||||||
|
.queryParam("isHtml", true);
|
||||||
|
|
||||||
|
resource.request().header("Authorization", database + ":" + auth)
|
||||||
|
.async()
|
||||||
|
.post(Entity.json(jsonBody), new InvocationCallback<Response>() {
|
||||||
|
@Override
|
||||||
|
public void completed(Response response) {
|
||||||
|
String value = response.readEntity(String.class);
|
||||||
|
logger.info(response.getStatus() + " - " + value);
|
||||||
|
response.close();
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
logger.error(throwable);
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
ps.close();
|
|
||||||
ds.forceClose();
|
|
||||||
|
|
||||||
String htmlMailBody = "Gentile Amministratore,<br> si e' verificato il seguente errore <br><b>" + errorMessage + "</b><br> del servizio " + emailListenerInfo.getServiceRest() +
|
|
||||||
"<br> in ascolto sulla mail " + emailListen + " provocato dal messaggio (mittente " + mittente + ") con oggetto " + messageObj + " in data " + sdf.format(messageDate);
|
|
||||||
|
|
||||||
String mailSubject = nomeAzienda + " - ERRORE SU " + InetAddress.getLocalHost().getHostName() +
|
|
||||||
" Servizio " + emailListenerInfo.getServiceRest() + ";Database " + emailListenerInfo.getDatabase();
|
|
||||||
|
|
||||||
// AttachmentDTO dto = new AttachmentDTO();
|
|
||||||
// dto.setFileByte(files);
|
|
||||||
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
//jsonObjectMapper.writeValue(writer, dto);
|
|
||||||
|
|
||||||
String jsonBody = writer.toString();
|
|
||||||
|
|
||||||
String database = emailListenerInfo.getDatabase();
|
|
||||||
|
|
||||||
String auth = RestUtil.generateAuth(database, database, "POST", jsonBody,
|
|
||||||
"application/json", prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
|
||||||
|
|
||||||
final Client client = ClientBuilder.newClient();
|
|
||||||
WebTarget resource = client.target(prop.getEndPointWS()).path(
|
|
||||||
prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL)
|
|
||||||
.resolveTemplate("mode", "async");
|
|
||||||
resource = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
|
||||||
.queryParam("from", "").queryParam("to", emailDbg)
|
|
||||||
.queryParam("subject", mailSubject).queryParam("msgText", htmlMailBody)
|
|
||||||
.queryParam("isHtml", true);
|
|
||||||
|
|
||||||
resource.request().header("Authorization", database + ":" + auth)
|
|
||||||
.async()
|
|
||||||
.post(Entity.json(jsonBody), new InvocationCallback<Response>() {
|
|
||||||
@Override
|
|
||||||
public void completed(Response response) {
|
|
||||||
String value = response.readEntity(String.class);
|
|
||||||
logger.info(response.getStatus() + " - " + value);
|
|
||||||
response.close();
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed(Throwable throwable) {
|
|
||||||
throwable.printStackTrace();
|
|
||||||
logger.error(throwable);
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -524,35 +524,6 @@ public class OrdiniAcquistoExportServices {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityExportResponse exportOrdiniVendita(String type, String format) throws Exception {
|
|
||||||
Connection connection = multiDBTransactionManager.getPrimaryConnection();
|
|
||||||
|
|
||||||
DataSource dsSlim2k = new DataSource();
|
|
||||||
Map<String, String> setup = setupGest.getImportSetupSection(connection, type, format);
|
|
||||||
EntityExportResponse<List<File>> entityExportResponse = new EntityExportResponse<List<File>>();
|
|
||||||
String profileSlim2k = setup.get("PROFILE");
|
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(profileSlim2k)) {
|
|
||||||
throw new Exception("Profile non configurato per la procedura di importazione liste di scarico SLIM2K");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
dsSlim2k.initialize(profileSlim2k);
|
|
||||||
String listaSingoloOrdine = setup.get("LISTA_SINGOLO_ORDINE");
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
if (!dsSlim2k.isClosed()) {
|
|
||||||
dsSlim2k.forceClose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return entityExportResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityExportResponse exportOrdiniSlim2K(String type, String format) throws Exception {
|
public EntityExportResponse exportOrdiniSlim2K(String type, String format) throws Exception {
|
||||||
EntityExportResponse<List<File>> entityExportResponse = new EntityExportResponse<List<File>>();
|
EntityExportResponse<List<File>> entityExportResponse = new EntityExportResponse<List<File>>();
|
||||||
|
|
||||||
|
|||||||
@@ -92,94 +92,91 @@ public class ProductServices {
|
|||||||
|
|
||||||
public List<MtbAart> exportArtDialogo(String whereCond) throws Exception {
|
public List<MtbAart> exportArtDialogo(String whereCond) throws Exception {
|
||||||
//PROCEDURA DI IMPORTAZIONE ARTICOLI FORMAT - CARELLI
|
//PROCEDURA DI IMPORTAZIONE ARTICOLI FORMAT - CARELLI
|
||||||
String query;
|
|
||||||
FileItem fileItem;
|
|
||||||
DataSource dsArticoli = new DataSource();
|
|
||||||
|
|
||||||
HashMap<String, String> setup = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "w_marti_rc", "DIALOGO");
|
HashMap<String, String> setup = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "w_marti_rc", "DIALOGO");
|
||||||
|
|
||||||
String profileDbArt = setup.get("PROFILE_DB");
|
String profileDbArt = setup.get("PROFILE_DB");
|
||||||
|
|
||||||
dsArticoli.initialize(profileDbArt);
|
try(MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDbArt)) {
|
||||||
|
|
||||||
String queryArticoli =
|
String queryArticoli =
|
||||||
"SELECT mtb_aart.cod_mart " +
|
"SELECT mtb_aart.cod_mart " +
|
||||||
" FROM mtb_aart LEFT OUTER JOIN mtb_lisa ON mtb_aart.cod_mart = mtb_lisa.cod_mart " +
|
" FROM mtb_aart LEFT OUTER JOIN mtb_lisa ON mtb_aart.cod_mart = mtb_lisa.cod_mart " +
|
||||||
"LEFT OUTER JOIN mvw_barcode ON mtb_aart.cod_mart = mvw_barcode.cod_mart " +
|
"LEFT OUTER JOIN mvw_barcode ON mtb_aart.cod_mart = mvw_barcode.cod_mart " +
|
||||||
" WHERE mtb_aart.cod_mart NOT IN (SELECT cod_mart FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.mtb_aart)";
|
" WHERE mtb_aart.cod_mart NOT IN (SELECT cod_mart FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.mtb_aart)";
|
||||||
queryArticoli = UtilityDB.addwhereCond(queryArticoli, whereCond, true);
|
queryArticoli = UtilityDB.addwhereCond(queryArticoli, whereCond, true);
|
||||||
|
|
||||||
String sql = setup.get("QUERY");
|
String sql = setup.get("QUERY");
|
||||||
sql = UtilityDB.addwhereCond(sql, "mtb_aart.cod_mart IN (" + queryArticoli + ") ", false);
|
sql = UtilityDB.addwhereCond(sql, "mtb_aart.cod_mart IN (" + queryArticoli + ") ", false);
|
||||||
|
|
||||||
ResultSetMapper rsArt = new ResultSetMapper();
|
ResultSetMapper rsArt = new ResultSetMapper();
|
||||||
List<MtbAart> articoli = rsArt.mapQuerySetToList(dsArticoli.getConnection(), sql, MtbAart.class, OperationType.SELECT_OBJECT);
|
List<MtbAart> articoli = rsArt.mapQuerySetToList(mdb.getPrimaryConnection(), sql, MtbAart.class, OperationType.SELECT_OBJECT);
|
||||||
|
|
||||||
if (articoli == null || articoli.isEmpty()) {
|
if (articoli == null || articoli.isEmpty()) {
|
||||||
throw new Exception("Nessun articolo trovato");
|
throw new Exception("Nessun articolo trovato");
|
||||||
}
|
|
||||||
|
|
||||||
sql =
|
|
||||||
"SELECT mtb_aart_bar_code.cod_mart, " +
|
|
||||||
" cod_barre, " +
|
|
||||||
" qta_cnf " +
|
|
||||||
" FROM mtb_aart_bar_code " +
|
|
||||||
"WHERE mtb_aart_bar_code.cod_mart IN (" + queryArticoli + ") ";
|
|
||||||
|
|
||||||
ResultSetMapper rsBarcode = new ResultSetMapper();
|
|
||||||
List<MtbAartBarCode> barcode = rsBarcode.mapQuerySetToList(dsArticoli.getConnection(), sql, MtbAartBarCode.class, OperationType.SELECT_OBJECT);
|
|
||||||
|
|
||||||
sql =
|
|
||||||
"SELECT mtb_lisa.cod_mart, " +
|
|
||||||
" cod_alis, " +
|
|
||||||
" cod_art_for, " +
|
|
||||||
" unt_mis_acq, " +
|
|
||||||
" flag_attivo " +
|
|
||||||
" FROM mtb_lisa " +
|
|
||||||
" WHERE mtb_lisa.cod_mart IN (" + queryArticoli + ") ";
|
|
||||||
|
|
||||||
|
|
||||||
List<MtbLisa> listini = rsBarcode.mapQuerySetToList(dsArticoli.getConnection(), sql, MtbLisa.class, OperationType.SELECT_OBJECT);
|
|
||||||
|
|
||||||
sql = "SELECT where_cond_sql FROM stb_subscription WHERE user_name = " + UtilityDB.valueToString(multiDBTransactionManager.getPrimaryDatasource().getDbName());
|
|
||||||
|
|
||||||
String whereCondSync = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(dsArticoli.getConnection(), sql);
|
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(whereCondSync) && !listini.isEmpty()) {
|
|
||||||
List<MtbLisa> myObjs = new ArrayList<>();
|
|
||||||
myObjs.addAll(listini);
|
|
||||||
|
|
||||||
String selectSql = "SELECT * FROM " + listini.get(0).getClass().getCanonicalName() + " WHERE " + whereCondSync;
|
|
||||||
|
|
||||||
// Create a new Query.
|
|
||||||
Query q = new Query();
|
|
||||||
q.parse(selectSql);
|
|
||||||
|
|
||||||
QueryResults qr = q.execute(myObjs);
|
|
||||||
List<?> res = qr.getResults();
|
|
||||||
|
|
||||||
if (res != null && res.size() >= 0) {
|
|
||||||
listini = (List<MtbLisa>) res;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (MtbAart art : articoli) {
|
sql =
|
||||||
art.setOnlyPkMaster(false);
|
"SELECT mtb_aart_bar_code.cod_mart, " +
|
||||||
|
" cod_barre, " +
|
||||||
|
" qta_cnf " +
|
||||||
|
" FROM mtb_aart_bar_code " +
|
||||||
|
"WHERE mtb_aart_bar_code.cod_mart IN (" + queryArticoli + ") ";
|
||||||
|
|
||||||
List<MtbAartBarCode> mtbAartBarCode = Stream.of(barcode).filter(x -> x.getCodMart().equalsIgnoreCase(art.getCodMart())).toList();
|
ResultSetMapper rsBarcode = new ResultSetMapper();
|
||||||
if (mtbAartBarCode != null) {
|
List<MtbAartBarCode> barcode = rsBarcode.mapQuerySetToList(mdb.getPrimaryConnection(), sql, MtbAartBarCode.class, OperationType.SELECT_OBJECT);
|
||||||
art.setMtbAartBarCode(mtbAartBarCode);
|
|
||||||
}
|
sql =
|
||||||
if (!listini.isEmpty()) {
|
"SELECT mtb_lisa.cod_mart, " +
|
||||||
List<MtbLisa> mtbLisa = Stream.of(listini).filter(x -> x.getCodMart().equalsIgnoreCase(art.getCodMart())).toList();
|
" cod_alis, " +
|
||||||
if (mtbLisa != null) {
|
" cod_art_for, " +
|
||||||
art.setMtbLisa(mtbLisa);
|
" unt_mis_acq, " +
|
||||||
|
" flag_attivo " +
|
||||||
|
" FROM mtb_lisa " +
|
||||||
|
" WHERE mtb_lisa.cod_mart IN (" + queryArticoli + ") ";
|
||||||
|
|
||||||
|
|
||||||
|
List<MtbLisa> listini = rsBarcode.mapQuerySetToList(mdb.getPrimaryConnection(), sql, MtbLisa.class, OperationType.SELECT_OBJECT);
|
||||||
|
|
||||||
|
sql = "SELECT where_cond_sql FROM stb_subscription WHERE user_name = " + UtilityDB.valueToString(multiDBTransactionManager.getPrimaryDatasource().getDbName());
|
||||||
|
|
||||||
|
String whereCondSync = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(mdb.getPrimaryConnection(), sql);
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(whereCondSync) && !listini.isEmpty()) {
|
||||||
|
List<MtbLisa> myObjs = new ArrayList<>();
|
||||||
|
myObjs.addAll(listini);
|
||||||
|
|
||||||
|
String selectSql = "SELECT * FROM " + listini.get(0).getClass().getCanonicalName() + " WHERE " + whereCondSync;
|
||||||
|
|
||||||
|
// Create a new Query.
|
||||||
|
Query q = new Query();
|
||||||
|
q.parse(selectSql);
|
||||||
|
|
||||||
|
QueryResults qr = q.execute(myObjs);
|
||||||
|
List<?> res = qr.getResults();
|
||||||
|
|
||||||
|
if (res != null && res.size() >= 0) {
|
||||||
|
listini = (List<MtbLisa>) res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
for (MtbAart art : articoli) {
|
||||||
|
art.setOnlyPkMaster(false);
|
||||||
|
|
||||||
return articoli;
|
List<MtbAartBarCode> mtbAartBarCode = Stream.of(barcode).filter(x -> x.getCodMart().equalsIgnoreCase(art.getCodMart())).toList();
|
||||||
|
if (mtbAartBarCode != null) {
|
||||||
|
art.setMtbAartBarCode(mtbAartBarCode);
|
||||||
|
}
|
||||||
|
if (!listini.isEmpty()) {
|
||||||
|
List<MtbLisa> mtbLisa = Stream.of(listini).filter(x -> x.getCodMart().equalsIgnoreCase(art.getCodMart())).toList();
|
||||||
|
if (mtbLisa != null) {
|
||||||
|
art.setMtbLisa(mtbLisa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return articoli;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String exportArtDialogoExclude(String[] elencoCampi, String nomeCampo) {
|
private String exportArtDialogoExclude(String[] elencoCampi, String nomeCampo) {
|
||||||
@@ -784,17 +781,17 @@ public class ProductServices {
|
|||||||
|
|
||||||
public void popolaTabellaRiassegnazione() throws Exception {
|
public void popolaTabellaRiassegnazione() throws Exception {
|
||||||
String profileDB = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_mriassegna_costo_dlg", "TABELLA COSTI", "PROFILE_DB");
|
String profileDB = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "w_mriassegna_costo_dlg", "TABELLA COSTI", "PROFILE_DB");
|
||||||
Connection conn = null;
|
try(MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDB)) {
|
||||||
if (!UtilityString.isNullOrEmpty(profileDB) && !profileDB.equalsIgnoreCase(multiDBTransactionManager.getPrimaryDatasource().getProfile())) {
|
Connection conn = null;
|
||||||
DataSource ds = new DataSource();
|
if (!UtilityString.isNullOrEmpty(profileDB) && !profileDB.equalsIgnoreCase(multiDBTransactionManager.getPrimaryDatasource().getProfile())) {
|
||||||
ds.initialize(profileDB);
|
conn = mdb.getPrimaryConnection();
|
||||||
conn = ds.getConnection();
|
} else {
|
||||||
} else {
|
conn = multiDBTransactionManager.getPrimaryConnection();
|
||||||
conn = multiDBTransactionManager.getPrimaryConnection();
|
}
|
||||||
|
CallableStatement cs = conn.prepareCall("{call popolaTabelleCosti}");
|
||||||
|
cs.execute();
|
||||||
|
cs.close();
|
||||||
}
|
}
|
||||||
CallableStatement cs = conn.prepareCall("{call popolaTabelleCosti}");
|
|
||||||
cs.execute();
|
|
||||||
cs.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void aggCostiDaTabella(Date dataIniz, Date dataFine, String whereCond) throws Exception {
|
public void aggCostiDaTabella(Date dataIniz, Date dataFine, String whereCond) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user