Rimosse classi e servizi obsoleti che utilizzavano DataSource in maniera diretta.
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:
19
.idea/copilot.data.migration.agent.xml
generated
Normal file
19
.idea/copilot.data.migration.agent.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AgentMigrationStateService">
|
||||
<option name="pendingSessionIds">
|
||||
<option value="c2adff55-0384-4ed3-8e89-6740a0a19622" />
|
||||
</option>
|
||||
<option name="pendingTurns">
|
||||
<map>
|
||||
<entry key="c2adff55-0384-4ed3-8e89-6740a0a19622">
|
||||
<value>
|
||||
<set>
|
||||
<option value="0ff64af0-e1e5-4e48-9056-263f3dd7e63f" />
|
||||
</set>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,15 +2,16 @@ package it.integry.ems.directory;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.FileItem;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -30,6 +31,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@@ -53,42 +55,44 @@ public class EmailWatcherListener extends TimerTask {
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
try {
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(emailListenerInfo.getDatabase())) {
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
String flagAttivo = null, username = null, password = null,
|
||||
imap = null, pop3 = null, pop3Port = null, imapPort = null;
|
||||
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(emailListenerInfo.getDatabase());
|
||||
|
||||
String[] params = emailListenerInfo.getSetupGestBranch().split("\\|");
|
||||
|
||||
if (params.length >= 2) {
|
||||
flagAttivo = setupGest.getSetup(ds.getConnection(), params[0], params[1], "ATTIVO");
|
||||
username = setupGest.getSetup(ds.getConnection(), params[0], params[1], "USERNAME");
|
||||
final HashMap<String, String> setupData = setupGest.getSetupSection(conn, params[0], params[1]);
|
||||
|
||||
flagAttivo = UtilityHashMap.getValueIfExists(setupData, "ATTIVO");
|
||||
username = UtilityHashMap.getValueIfExists(setupData, "USERNAME");
|
||||
if (UtilityString.isNullOrEmpty(username))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/USERNAME non configurato correttamente");
|
||||
|
||||
password = setupGest.getSetup(ds.getConnection(), params[0], params[1], "PASSWORD");
|
||||
password = UtilityHashMap.getValueIfExists(setupData, "PASSWORD");
|
||||
if (UtilityString.isNullOrEmpty(password))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/PASSWORD non configurato correttamente");
|
||||
|
||||
pop3 = setupGest.getSetup(ds.getConnection(), params[0], params[1], "POP3");
|
||||
pop3 = UtilityHashMap.getValueIfExists(setupData, "POP3");
|
||||
if (UtilityString.isNullOrEmpty(pop3))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/POP3 non configurato correttamente");
|
||||
|
||||
pop3Port = setupGest.getSetup(ds.getConnection(), params[0], params[1], "POP3_PORT");
|
||||
pop3Port = UtilityHashMap.getValueIfExists(setupData, "POP3_PORT");
|
||||
if (UtilityString.isNullOrEmpty(pop3Port))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/POP3_PORT non configurato correttamente");
|
||||
|
||||
imap = setupGest.getSetup(ds.getConnection(), params[0], params[1], "IMAP");
|
||||
imap = UtilityHashMap.getValueIfExists(setupData, "IMAP");
|
||||
if (UtilityString.isNullOrEmpty(imap))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/IMAP non configurato correttamente");
|
||||
|
||||
imapPort = setupGest.getSetup(ds.getConnection(), params[0], params[1], "IMAP_PORT");
|
||||
imapPort = UtilityHashMap.getValueIfExists(setupData, "IMAP_PORT");
|
||||
if (UtilityString.isNullOrEmpty(imapPort))
|
||||
throw new Exception(params[0] + "/" + params[1] + "/IMAP_PORT non configurato correttamente");
|
||||
}
|
||||
ds.close();
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(flagAttivo) && "S".equals(flagAttivo)) {
|
||||
Properties sysProperties = System.getProperties();
|
||||
Session session = Session.getDefaultInstance(sysProperties);
|
||||
@@ -160,7 +164,7 @@ public class EmailWatcherListener extends TimerTask {
|
||||
|
||||
String value = response.readEntity(String.class);
|
||||
|
||||
String emailDbg = setupGest.getSetup(ds.getConnection(), params[0], params[1], "EMAIL_DBG");
|
||||
String emailDbg = setupGest.getSetup(conn, params[0], params[1], "EMAIL_DBG");
|
||||
if (value.charAt(0) == '{') {
|
||||
ServiceRestResponse respWra = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||
if (respWra.getEsito() == EsitoType.KO) {
|
||||
|
||||
@@ -3,12 +3,12 @@ package it.integry.ems.contabil.Import.service;
|
||||
import com.annimon.stream.ComparatorCompat;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.common.var.EmsDBConst;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.contabil.Import.dto.MovPagheDTO;
|
||||
import it.integry.ems.contabil.Import.dto.MovimentiContabiliDocfinanceDTO;
|
||||
import it.integry.ems.contabil.bancaditalia.service.TassiDiCambioService;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.file_formatter.csv.CsvMapper;
|
||||
import it.integry.ems.file_formatter.txt.TxtMapper;
|
||||
import it.integry.ems.rules.businessLogic.AccountingBusinessLogic;
|
||||
@@ -37,38 +37,45 @@ import java.util.stream.Collectors;
|
||||
public class ContabilImportService {
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private MailService mailService;
|
||||
|
||||
@Autowired
|
||||
private TassiDiCambioService tassiDiCambioService;
|
||||
|
||||
@Autowired
|
||||
private EmsDBConst emsDBConst;
|
||||
|
||||
public List<EntityBase> importMovIngragruppo(String type, String format, String whereCond) throws Exception {
|
||||
List<EntityBase> movimenti = new ArrayList<>();
|
||||
|
||||
DataSource dbPrimary = new DataSource();
|
||||
String dbDistriburtore = null;
|
||||
HashMap<String, Object> datiAzienda = Azienda.getDatiAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||
if (datiAzienda == null || UtilityString.isNullOrEmpty(datiAzienda.get("db_distributore"))) {
|
||||
|
||||
String dbDistriburtore = multiDBTransactionManager.getDistributoreProfileName();
|
||||
if (UtilityString.isNullOrEmpty(dbDistriburtore))
|
||||
throw new Exception("DB Distributore non trovato.");
|
||||
} else {
|
||||
dbDistriburtore = (String) datiAzienda.get("db_distributore");
|
||||
dbPrimary.initialize(dbDistriburtore);
|
||||
}
|
||||
|
||||
|
||||
Azienda datiAzienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
Connection dbDistributoreConnectin = multiDBTransactionManager.addAndGetDistributoreConnection();
|
||||
|
||||
String sql =
|
||||
"SELECT aziende_gruppo.cod_anag " +
|
||||
" FROM aziende_gruppo, gtb_anag " +
|
||||
" WHERE aziende_gruppo.cod_anag = gtb_anag.cod_anag and " +
|
||||
" gtb_anag.part_iva = " + UtilityDB.valueToString(datiAzienda.get("part_iva"));
|
||||
String codAnagAzienda = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(dbPrimary.getConnection(), sql);
|
||||
" gtb_anag.part_iva = " + UtilityDB.valueToString(datiAzienda.getPartIva());
|
||||
String codAnagAzienda = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(dbDistributoreConnectin, sql);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codAnagAzienda)) {
|
||||
if (UtilityString.isNullOrEmpty(codAnagAzienda))
|
||||
throw new Exception("Azienda non appartenente al gruppo o db distributore errato.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
String selectMov =
|
||||
@@ -93,7 +100,7 @@ public class ContabilImportService {
|
||||
" FROM ctb_movt " +
|
||||
" WHERE ctb_movt.stam_gio = 'N' AND ctb_movt.num_cmov in (" + selectMov + ")";
|
||||
ResultSetMapper ctbMovtMapper = new ResultSetMapper();
|
||||
List<CtbMovt> listaMov = ctbMovtMapper.mapQuerySetToList(dbPrimary.getConnection(), sql, CtbMovt.class, OperationType.INSERT);
|
||||
List<CtbMovt> listaMov = ctbMovtMapper.mapQuerySetToList(dbDistributoreConnectin, sql, CtbMovt.class, OperationType.INSERT);
|
||||
|
||||
for (CtbMovt ctbMovt : listaMov) {
|
||||
Integer numCmovOrig = ctbMovt.getNumCmov();
|
||||
@@ -105,7 +112,7 @@ public class ContabilImportService {
|
||||
"SELECT * FROM ctb_movi WHERE ctb_movi.num_cmov = " + UtilityDB.valueToString(numCmovOrig);
|
||||
|
||||
ResultSetMapper ctbMoviMapper = new ResultSetMapper();
|
||||
List<CtbMovi> ctbMovi = ctbMoviMapper.mapQuerySetToList(dbPrimary.getConnection(), sqlRighe, CtbMovi.class, OperationType.INSERT);
|
||||
List<CtbMovi> ctbMovi = ctbMoviMapper.mapQuerySetToList(dbDistributoreConnectin, sqlRighe, CtbMovi.class, OperationType.INSERT);
|
||||
|
||||
if (ctbMovi != null) {
|
||||
ctbMovt.setCtbMovi(ctbMovi);
|
||||
@@ -115,7 +122,7 @@ public class ContabilImportService {
|
||||
"SELECT * FROM ctb_movr WHERE ctb_movr.num_cmov = " + UtilityDB.valueToString(numCmovOrig);
|
||||
|
||||
ResultSetMapper ctbMovrMapper = new ResultSetMapper();
|
||||
List<CtbMovr> ctbMovr = ctbMovrMapper.mapQuerySetToList(dbPrimary.getConnection(), sqlRighe, CtbMovr.class, OperationType.INSERT);
|
||||
List<CtbMovr> ctbMovr = ctbMovrMapper.mapQuerySetToList(dbDistributoreConnectin, sqlRighe, CtbMovr.class, OperationType.INSERT);
|
||||
|
||||
if (ctbMovr != null) {
|
||||
ctbMovt.setCtbMovr(ctbMovr);
|
||||
@@ -133,7 +140,7 @@ public class ContabilImportService {
|
||||
" ORDER BY ctb_scad.id_riga";
|
||||
|
||||
ResultSetMapper ctbScadMapper = new ResultSetMapper();
|
||||
List<CtbScad> ctbScad = ctbScadMapper.mapQuerySetToList(dbPrimary.getConnection(), sqlRighe, CtbScad.class, OperationType.INSERT);
|
||||
List<CtbScad> ctbScad = ctbScadMapper.mapQuerySetToList(dbDistributoreConnectin, sqlRighe, CtbScad.class, OperationType.INSERT);
|
||||
|
||||
if (ctbScad != null) {
|
||||
ctbMovt.setCtbScad(ctbScad);
|
||||
@@ -144,10 +151,10 @@ public class ContabilImportService {
|
||||
movimenti.add(ctbMovt);
|
||||
try {
|
||||
String sqlUpdate = "UPDATE ctb_movt SET ctb_movt.stam_gio = 'S' WHERE ctb_movt.num_cmov = " + UtilityDB.valueToString(numCmovOrig);
|
||||
dbPrimary.getConnection().createStatement().executeUpdate(sqlUpdate);
|
||||
dbPrimary.getConnection().commit();
|
||||
dbDistributoreConnectin.createStatement().executeUpdate(sqlUpdate);
|
||||
dbDistributoreConnectin.commit();
|
||||
} catch (Exception e) {
|
||||
dbPrimary.getConnection().rollback();
|
||||
dbDistributoreConnectin.rollback();
|
||||
throw new Exception("Errore durante l'aggiornametno del movimento contabile sul db " + dbDistriburtore + "." + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.contabil.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.contabil.dto.AutofatturaDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.rules.businessLogic.AccountingBusinessLogic;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.document.Import.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.document.Import.dto.ConsortileFilterDTO;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.rules.completing.DocumentRules;
|
||||
@@ -371,8 +370,6 @@ public class DocumentiConsortileService {
|
||||
|
||||
// Connessione al database dell'azienda agricola
|
||||
if (j == 0) {
|
||||
DataSource dsSync = new DataSource();
|
||||
dsSync.initialize(profileDB);
|
||||
multiDBTransactionManagerAzAgr.setPrimaryDB(profileDB);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +84,6 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
CsvINVOICExportService INVOICservice = context.getBean(CsvINVOICExportService.class);
|
||||
entityExportResponse = INVOICservice.exportCsvINVOICC(type, format, whereCond, username, jsonBody);
|
||||
break;
|
||||
case PLURIMA:
|
||||
entityExportResponse = documentiExportManagerService.exportDocumentiPlurima(type, format, jsonBody, wtbUserInfo, anomalie);
|
||||
break;
|
||||
case COOP_PDF:
|
||||
DocumentiCoopPdfExportService documentiCoopExportService = context.getBean(DocumentiCoopPdfExportService.class);
|
||||
entityExportResponse = documentiCoopExportService.export(type, format, whereCond);
|
||||
@@ -228,7 +225,6 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
INVOIC_CSV("INVOIC_CSV"),
|
||||
SICILIANI_ORGCONS("SICILIANI_ORGCONS"),
|
||||
SICILIANI_TAGLIACUCI("SICILIANI_TAGLIACUCI"),
|
||||
PLURIMA("PLURIMA"),
|
||||
COOP_PDF("COOP_PDF"),
|
||||
COOP("COOP"),
|
||||
SIAN("SIAN"),
|
||||
|
||||
@@ -1,382 +0,0 @@
|
||||
package it.integry.ems.document.export.dto;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlurimaDocumentDTO {
|
||||
|
||||
@SqlField("cod_anag")
|
||||
private String codAnag;
|
||||
|
||||
@SqlField("cod_dtip")
|
||||
private String codDtip;
|
||||
|
||||
@SqlField("data_doc")
|
||||
private Date dataDoc;
|
||||
|
||||
@SqlField("ser_doc")
|
||||
private String serDoc;
|
||||
|
||||
@SqlField("num_doc")
|
||||
private Integer numDoc;
|
||||
|
||||
@SqlField("cod_vdes")
|
||||
private String codVdes;
|
||||
|
||||
@SqlField("data_reg")
|
||||
private Date dataReg;
|
||||
|
||||
@SqlField("RIGO")
|
||||
private Integer rigo;
|
||||
|
||||
@SqlField("PROGRGENERALE")
|
||||
private Long progrGenerale;
|
||||
|
||||
@SqlField("NUMDOCMAGAZZINO")
|
||||
private String numDocMagazzino;
|
||||
|
||||
@SqlField("MCAUSALE")
|
||||
private String mCausale;
|
||||
|
||||
@SqlField("MARTICOLO")
|
||||
private String mArticolo;
|
||||
|
||||
@SqlField("MDESCRARTICOLO")
|
||||
private String mDescrArticolo;
|
||||
|
||||
@SqlField("MUNITA")
|
||||
private String mUnita;
|
||||
|
||||
@SqlField("MQUANTITA")
|
||||
private BigDecimal mQuantita;
|
||||
|
||||
@SqlField("MQUANTITAV")
|
||||
private BigDecimal mQuantitaV;
|
||||
|
||||
@SqlField("VALORE")
|
||||
private BigDecimal valore;
|
||||
|
||||
@SqlField("VALOREUNITARIO")
|
||||
private BigDecimal valoreUnitario;
|
||||
|
||||
@SqlField("PREZZO")
|
||||
private BigDecimal prezzo;
|
||||
|
||||
@SqlField("SCONTOARTICOLO")
|
||||
private BigDecimal scontoArticolo;
|
||||
|
||||
@SqlField("SCONTOC1")
|
||||
private BigDecimal scontoC1;
|
||||
|
||||
@SqlField("SCONTOC2")
|
||||
private BigDecimal scontoC2;
|
||||
|
||||
@SqlField("SCONTOP")
|
||||
private BigDecimal scontoP;
|
||||
|
||||
@SqlField("LOTTOMAG")
|
||||
private String lottoMag;
|
||||
|
||||
@SqlField("IVAMAG")
|
||||
private String ivaMag;
|
||||
|
||||
@SqlField("MAGENTE")
|
||||
private String mAgente;
|
||||
|
||||
@SqlField("MCOLLI")
|
||||
private BigDecimal mColli;
|
||||
|
||||
@SqlField("DATAINSERIMENTO")
|
||||
private Date dataInserimento;
|
||||
|
||||
@SqlField("USERNAME")
|
||||
private String username;
|
||||
|
||||
@SqlField("SYS_UPDATEUSER")
|
||||
private String sysUpdateUser;
|
||||
|
||||
@SqlField("DATAMODIFICA")
|
||||
private Date dataModifica;
|
||||
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodDtip() {
|
||||
return codDtip;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setCodDtip(String codDtip) {
|
||||
this.codDtip = codDtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setDataDoc(Date dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSerDoc() {
|
||||
return serDoc;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setSerDoc(String serDoc) {
|
||||
this.serDoc = serDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumDoc() {
|
||||
return numDoc;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setNumDoc(Integer numDoc) {
|
||||
this.numDoc = numDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setCodVdes(String codVdes) {
|
||||
this.codVdes = codVdes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataReg() {
|
||||
return dataReg;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setDataReg(Date dataReg) {
|
||||
this.dataReg = dataReg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getRigo() {
|
||||
return rigo;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setRigo(Integer rigo) {
|
||||
this.rigo = rigo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getProgrGenerale() {
|
||||
return progrGenerale;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setProgrGenerale(Long progrGenerale) {
|
||||
this.progrGenerale = progrGenerale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNumDocMagazzino() {
|
||||
return numDocMagazzino;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setNumDocMagazzino(String numDocMagazzino) {
|
||||
this.numDocMagazzino = numDocMagazzino;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getmCausale() {
|
||||
return mCausale;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmCausale(String mCausale) {
|
||||
this.mCausale = mCausale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getmArticolo() {
|
||||
return mArticolo;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmArticolo(String mArticolo) {
|
||||
this.mArticolo = mArticolo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getmDescrArticolo() {
|
||||
return mDescrArticolo;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmDescrArticolo(String mDescrArticolo) {
|
||||
this.mDescrArticolo = mDescrArticolo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getmUnita() {
|
||||
return mUnita;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmUnita(String mUnita) {
|
||||
this.mUnita = mUnita;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getmQuantita() {
|
||||
return mQuantita;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmQuantita(BigDecimal mQuantita) {
|
||||
this.mQuantita = mQuantita;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getmQuantitaV() {
|
||||
return mQuantitaV;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmQuantitaV(BigDecimal mQuantitaV) {
|
||||
this.mQuantitaV = mQuantitaV;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValore() {
|
||||
return valore;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setValore(BigDecimal valore) {
|
||||
this.valore = valore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValoreUnitario() {
|
||||
return valoreUnitario;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setValoreUnitario(BigDecimal valoreUnitario) {
|
||||
this.valoreUnitario = valoreUnitario;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getPrezzo() {
|
||||
return prezzo;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setPrezzo(BigDecimal prezzo) {
|
||||
this.prezzo = prezzo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getScontoArticolo() {
|
||||
return scontoArticolo;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setScontoArticolo(BigDecimal scontoArticolo) {
|
||||
this.scontoArticolo = scontoArticolo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getScontoC1() {
|
||||
return scontoC1;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setScontoC1(BigDecimal scontoC1) {
|
||||
this.scontoC1 = scontoC1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getScontoC2() {
|
||||
return scontoC2;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setScontoC2(BigDecimal scontoC2) {
|
||||
this.scontoC2 = scontoC2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getScontoP() {
|
||||
return scontoP;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setScontoP(BigDecimal scontoP) {
|
||||
this.scontoP = scontoP;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLottoMag() {
|
||||
return lottoMag;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setLottoMag(String lottoMag) {
|
||||
this.lottoMag = lottoMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIvaMag() {
|
||||
return ivaMag;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setIvaMag(String ivaMag) {
|
||||
this.ivaMag = ivaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getmAgente() {
|
||||
return mAgente;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmAgente(String mAgente) {
|
||||
this.mAgente = mAgente;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getmColli() {
|
||||
return mColli;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setmColli(BigDecimal mColli) {
|
||||
this.mColli = mColli;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataInserimento() {
|
||||
return dataInserimento;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setDataInserimento(Date dataInserimento) {
|
||||
this.dataInserimento = dataInserimento;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setUsername(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSysUpdateUser() {
|
||||
return sysUpdateUser;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setSysUpdateUser(String sysUpdateUser) {
|
||||
this.sysUpdateUser = sysUpdateUser;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataModifica() {
|
||||
return dataModifica;
|
||||
}
|
||||
|
||||
public PlurimaDocumentDTO setDataModifica(Date dataModifica) {
|
||||
this.dataModifica = dataModifica;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package it.integry.ems.document.export.service;
|
||||
|
||||
import com.ancientprogramming.fixedformat4j.format.FixedFormatManager;
|
||||
import com.ancientprogramming.fixedformat4j.format.impl.FixedFormatManagerImpl;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -11,10 +10,8 @@ import com.google.common.io.Files;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.document.export.dto.DocumentiDialogoDTO;
|
||||
import it.integry.ems.document.export.dto.EssegrandeIntercodeFornitoriDTO;
|
||||
import it.integry.ems.document.export.dto.PlurimaDocumentDTO;
|
||||
import it.integry.ems.document.export.dto.swingerDTO.AsnFooter;
|
||||
import it.integry.ems.document.export.dto.swingerDTO.AsnHeader;
|
||||
import it.integry.ems.document.export.dto.swingerDTO.AsnItem;
|
||||
@@ -41,10 +38,11 @@ import org.springframework.stereotype.Service;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
import static it.integry.ems_model.coollection.Coollection.eq;
|
||||
|
||||
@@ -53,11 +51,14 @@ import static it.integry.ems_model.coollection.Coollection.eq;
|
||||
public class DocumentiExportManagerService {
|
||||
|
||||
@Autowired
|
||||
EntityProcessor entityProcessor;
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private EmsProperties emsProperties;
|
||||
|
||||
@@ -70,490 +71,6 @@ public class DocumentiExportManagerService {
|
||||
}
|
||||
}
|
||||
|
||||
public EntityExportResponse exportDocumentiPlurima(String type, String format, JsonNode body, final WtbUsersInfo user, List<AnomalieDTO> anomalieList) throws Exception {
|
||||
List<DtbDoct> estremiTestateDocumenti = null;
|
||||
List<DtbDoct> elencoDocSalvati = new ArrayList<>();
|
||||
|
||||
PreparedStatement info;
|
||||
|
||||
Date dataDoc = new Date();
|
||||
Date dataReg = new Date();
|
||||
|
||||
|
||||
String whereCond = "", gestione = "", codAnag = "", serDoc = "", codDtip = "",
|
||||
codVdes = "", message = "", profileSource = "", queryPlurima = "", codFornPlurima = "", queryInsert = "", queryUpdate = "";
|
||||
|
||||
//CAMPI FISSI DA INSERIRE SU DB PLURIMA
|
||||
String SERIEMAG = "", MMAGAZZINO = "B", FLAGTRASFERITO = "N";
|
||||
|
||||
Integer numDoc = new Integer(0);
|
||||
Integer countRows = new Integer(0);
|
||||
|
||||
Integer progressivoMag = new Integer(0);
|
||||
Long progrGenerale = 0L;
|
||||
Integer RIGOGIORNALE = new Integer(0);
|
||||
Integer BFRIGO = new Integer(0);
|
||||
Integer PID = new Integer(0);
|
||||
Integer RIF_RIGA_COMMESSA = new Integer(0);
|
||||
Integer PARTITACDEPOSITO = new Integer(0);
|
||||
|
||||
Connection connect = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
Map<String, String> setup = setupGest.getExportSetupSection(connect, type, format);
|
||||
|
||||
profileSource = setup.get("PROFILEDB");
|
||||
if (UtilityString.isNullOrEmpty(profileSource)) {
|
||||
throw new Exception("CONFIGURARE PROFILEDB PLURIMA IN STB_GEST_SETUP.");
|
||||
}
|
||||
codFornPlurima = setup.get("COD_FORN_PLURIMA");
|
||||
if (UtilityString.isNullOrEmpty(codFornPlurima)) {
|
||||
throw new Exception("CONFIGURARE CODICE FORNITORE PLURIMA IN STB_GEST_SETUP.");
|
||||
}
|
||||
|
||||
if (body == null) throw new Exception("Non è possibile continuare poichè il body della richiesta è vuoto");
|
||||
|
||||
Connection connectPlurima = null;
|
||||
try {
|
||||
DataSource dsPlurima = new DataSource();
|
||||
dsPlurima.initialize(profileSource);
|
||||
connectPlurima = dsPlurima.getConnection();
|
||||
} catch (Exception ex) {
|
||||
throw new Exception("Impossibile collegarsi al db di PLURIMA. " + ex.getMessage());
|
||||
}
|
||||
|
||||
if (body.has("gestione") && !UtilityString.isNullOrEmpty(body.get("gestione").asText())) {
|
||||
gestione = body.get("gestione").asText();
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(gestione)) {
|
||||
throw new Exception("Non è possibile esportare documenti senza passare il parametro gestione.");
|
||||
} else {
|
||||
SERIEMAG = "I" + gestione;
|
||||
|
||||
if (body.has("whereCond") && !UtilityString.isNullOrEmpty(body.get("whereCond").asText())) {
|
||||
whereCond = body.get("whereCond").asText();
|
||||
}
|
||||
if (body.has("codDtip") && !UtilityString.isNullOrEmpty(body.get("codDtip").asText())) {
|
||||
codDtip = body.get("codDtip").asText();
|
||||
}
|
||||
if (body.has("codAnag") && !UtilityString.isNullOrEmpty(body.get("codAnag").asText())) {
|
||||
codAnag = body.get("codAnag").asText();
|
||||
}
|
||||
if (body.has("serDoc") && !UtilityString.isNullOrEmpty(body.get("serDoc").asText())) {
|
||||
serDoc = body.get("serDoc").asText();
|
||||
}
|
||||
if (body.has("numDoc") && !UtilityString.isNullOrEmpty(body.get("numDoc").asText())) {
|
||||
numDoc = Integer.valueOf(body.get("numDoc").asText());
|
||||
}
|
||||
if (body.has("dataDoc") && !UtilityString.isNullOrEmpty(body.get("dataDoc").asText())) {
|
||||
dataDoc = UtilityDate.StringToDate(body.get("dataDoc").asText(), CommonConstants.DATE_FORMAT_YMD);
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codDtip) && !UtilityString.isNullOrEmpty(codAnag) && !UtilityString.isNullOrEmpty(serDoc) && numDoc != 0) {
|
||||
whereCond = "dtb_doct.cod_Dtip = " + UtilityDB.valueToString(codDtip) + " AND dtb_doct.cod_anag = " + UtilityDB.valueToString(codAnag) + " AND dtb_doct.data_doc = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_YMD) + " AND dtb_doct.ser_Doc = " + UtilityDB.valueToString(serDoc) + " AND dtb_doct.num_doc = " + UtilityDB.valueToString(numDoc);
|
||||
}
|
||||
|
||||
|
||||
String sql = "SELECT dtb_doct.cod_anag, " +
|
||||
" dtb_doct.cod_dtip, " +
|
||||
" dtb_doct.data_doc, " +
|
||||
" dtb_doct.ser_doc, " +
|
||||
" dtb_doct.num_doc, " +
|
||||
" dtb_doct.cod_vdes," +
|
||||
" dtb_doct.data_reg, " +
|
||||
" dtb_docr.id_riga as RIGO," +
|
||||
" ROW_NUMBER() over (order by dtb_doct.gestione, dtb_doct.cod_dtip, dtb_doct.ser_doc, dtb_doct.num_doc) as PROGRGENERALE,--Inserire Progressivo da 400.001 a 1.000.000 \n" +
|
||||
" CONVERT(varchar(8),dtb_doct.num_doc)+ case When dtb_doct.ser_doc <> '/' then '/'+dtb_doct.ser_doc else '' end as NUMDOCMAGAZZINO," +
|
||||
" dtb_tipi_anag.inter_code as MCAUSALE, " +
|
||||
" dtb_docr.cod_mart as MARTICOLO, " +
|
||||
" left(dtb_docr.descrizione_estesa,60) as MDESCRARTICOLO," +
|
||||
" dtb_docr.unt_doc as MUNITA, 0 as MCOEFFICIENTE," +
|
||||
" dtb_docr.qta_doc*dtb_docr.rap_conv as MQUANTITA," +
|
||||
" dtb_docr.qta_doc*dtb_docr.rap_conv as MQUANTITAV," +
|
||||
" round(dtb_docr.qta_doc*dtb_docr.val_unt*(1-sconto1/100)*(1-sconto2/100)*(1-sconto3/100)*(1-sconto5/100)*(1-sconto6/100)*(1-sconto7/100)*(1-sconto8/100),2) *dtb_doct.cambio as VALORE," +
|
||||
" (dtb_docr.qta_doc*dtb_docr.val_unt*(1-sconto1/100)*(1-sconto2/100)*(1-sconto3/100)*(1-sconto5/100)*(1-sconto6/100)*(1-sconto7/100)*(1-sconto8/100) *dtb_doct.cambio)/(dtb_docr.qta_doc*dtb_docr.rap_conv) as VALOREUNITARIO," +
|
||||
" CASE WHEN dtb_docr.val_unt = 0 THEN 0 ELSE dtb_docr.val_unt/dtb_docr.rap_conv END as PREZZO," +
|
||||
" dtb_docr.sconto5 as SCONTOARTICOLO," +
|
||||
" dtb_doct.sconto1 as SCONTOC1," +
|
||||
" dtb_doct.sconto2 as SCONTOC2," +
|
||||
" dtb_doct.sconto4 as SCONTOP," +
|
||||
" LEFT(dtb_docr.partita_mag, 10) as LOTTOMAG," +
|
||||
" dtb_docr.cod_aliq as IVAMAG," +
|
||||
" isNull(dtb_doct.cod_vage,'') as MAGENTE," +
|
||||
" dtb_docr.num_cnf as MCOLLI," +
|
||||
" dtb_doct.data_ins as DATAINSERIMENTO," +
|
||||
" left(dtb_doct.compilato_Da,20) as USERNAME," +
|
||||
" dtb_doct.data_ult_mod as DATAMODIFICA, " +
|
||||
" left(dtb_doct.modificato_da,20) as SYS_UPDATEUSER " +
|
||||
" FROM dtb_docr, dtb_tipi_anag, dtb_doct LEFT OUTER JOIN dtb_docu_log ON dtb_doct.cod_anag = dtb_docu_log.cod_anag AND " +
|
||||
" dtb_doct.cod_dtip = dtb_docu_log.cod_dtip AND " +
|
||||
" dtb_doct.data_doc = dtb_docu_log.data_doc AND " +
|
||||
" dtb_doct.ser_doc = dtb_docu_log.ser_doc AND " +
|
||||
" dtb_doct.num_doc = dtb_docu_log.num_doc " +
|
||||
" WHERE dtb_doct.cod_anag = dtb_docr.cod_anag and " +
|
||||
" dtb_doct.cod_dtip = dtb_docr.cod_dtip and " +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc and " +
|
||||
" dtb_doct.ser_doc = dtb_docr.ser_doc and " +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc and " +
|
||||
" dtb_doct.cod_dtip = dtb_tipi_anag.cod_dtip and " +
|
||||
" dtb_tipi_anag.cod_anag = " + UtilityDB.valueToString(codFornPlurima) + " and " +
|
||||
" dtb_doct.gestione = " + UtilityDB.valueToString(gestione) + " AND " +
|
||||
" dtb_docu_log.cod_anag IS NULL " +
|
||||
" ORDER BY dtb_doct.cod_anag, " +
|
||||
" dtb_doct.cod_dtip, " +
|
||||
" dtb_doct.data_doc, " +
|
||||
" dtb_doct.ser_doc, " +
|
||||
" dtb_doct.num_doc, " +
|
||||
" dtb_docr.id_riga ";
|
||||
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, true);
|
||||
|
||||
info = connect.prepareStatement(sql);
|
||||
ResultSet rs = info.executeQuery();
|
||||
|
||||
List<PlurimaDocumentDTO> plurimaDocumentDTOList = new ResultSetMapper()
|
||||
.mapResultSetToList(rs, PlurimaDocumentDTO.class);
|
||||
|
||||
rs.close();
|
||||
info.close();
|
||||
|
||||
countRows = plurimaDocumentDTOList != null ? plurimaDocumentDTOList.size() : 0;
|
||||
|
||||
if (countRows > 0) {
|
||||
|
||||
estremiTestateDocumenti = Stream.of(plurimaDocumentDTOList)
|
||||
.map(plurimaDocumentDTO -> {
|
||||
DtbDoct dtbDoct = new DtbDoct();
|
||||
dtbDoct.setCodAnag(plurimaDocumentDTO.getCodAnag());
|
||||
dtbDoct.setCodDtip(plurimaDocumentDTO.getCodDtip());
|
||||
dtbDoct.setDataDoc(plurimaDocumentDTO.getDataDoc());
|
||||
dtbDoct.setSerDoc(plurimaDocumentDTO.getSerDoc());
|
||||
dtbDoct.setNumDoc(plurimaDocumentDTO.getNumDoc());
|
||||
dtbDoct.setCodVdes(plurimaDocumentDTO.getCodVdes());
|
||||
dtbDoct.setUsername(user.getUserName());
|
||||
dtbDoct.setDataReg(plurimaDocumentDTO.getDataReg());
|
||||
|
||||
return dtbDoct;
|
||||
})
|
||||
.distinctBy(dtbDoct -> dtbDoct.getCodAnag() + " - " +
|
||||
dtbDoct.getCodDtip() + " - " +
|
||||
UtilityDate.formatDate(dtbDoct.getDataDoc(), CommonConstants.DATETIME_FORMAT_YMD) + " - " +
|
||||
dtbDoct.getSerDoc() + " - " +
|
||||
dtbDoct.getNumDoc())
|
||||
.toList();
|
||||
|
||||
for (final DtbDoct testataDoc : estremiTestateDocumenti) {
|
||||
codAnag = testataDoc.getCodAnag();
|
||||
codDtip = testataDoc.getCodDtip();
|
||||
dataDoc = testataDoc.getDataDoc();
|
||||
serDoc = testataDoc.getSerDoc();
|
||||
numDoc = testataDoc.getNumDoc();
|
||||
codVdes = testataDoc.getCodVdes();
|
||||
String numDocPlurima = String.valueOf(numDoc);
|
||||
|
||||
if (!serDoc.equalsIgnoreCase("/")) {
|
||||
numDocPlurima += "/" + serDoc;
|
||||
}
|
||||
|
||||
queryPlurima =
|
||||
"SELECT count(*) FROM MAGAZZINO " +
|
||||
" WHERE seriemagazzino = " + UtilityDB.valueToString(SERIEMAG) + " AND " +
|
||||
" numdocmagazzino = " + UtilityDB.valueToString(numDocPlurima) + " AND " +
|
||||
" datadocmag = " + UtilityDB.valueDateToString(dataDoc, CommonConstants.DATE_FORMAT_DMY) + " AND " +
|
||||
" contomag like '%" + codAnag.substring(1, 5) + "'";
|
||||
Integer rowDocPlurima = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connectPlurima, queryPlurima);
|
||||
|
||||
if (rowDocPlurima == 0) {
|
||||
try {
|
||||
queryPlurima = "Select isNull(MAX(progrgenerale),400000) from MAGAZZINO where progrGenerale between 400000 and 1000000 ";
|
||||
Integer maxProgGen = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connectPlurima, queryPlurima);
|
||||
|
||||
queryPlurima = "Select isNull(MAX(PROGRESSIVOMAG),0) from MAGAZZINO where SERIEMAGAZZINO = 'IA' and anno = YEAR(" + UtilityDB.valueDateToString(dataReg, CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
Integer maxProgMag = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connectPlurima, queryPlurima);
|
||||
|
||||
queryPlurima = "Select ISNULL(dest.GRUPPOCONTO, anag.GRUPPOCONTO) as GRUPPOMAG," +
|
||||
" ISNULL(dest.SOTTOCONTO, anag.SOTTOCONTO) as CONTOMAG," +
|
||||
" anag.DGRUPPOFATTURA as GRUPPOFATTURA, " +
|
||||
" anag.DCONTOFATTURA as CONTOFATTURA " +
|
||||
" FROM [PIANOCONTI] anag Left Outer Join PIANOCONTI dest ON dest.SOTTOCONTO like '%'+RIGHT(" + UtilityDB.valueToString(codVdes) + ",4) and dest.CLIFOR = LEFT(" + UtilityDB.valueToString(codAnag) + ",1) " +
|
||||
" WHERE anag.SOTTOCONTO like '0%'+RIGHT(" + UtilityDB.valueToString(codAnag) + ",4) and anag.CLIFOR = LEFT(" + UtilityDB.valueToString(codAnag) + ",1) ";
|
||||
|
||||
HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connectPlurima, queryPlurima);
|
||||
|
||||
String contoMag = "";
|
||||
String contoFattura = "";
|
||||
Integer gruppoMag = 0;
|
||||
Integer gruppoFattura = 0;
|
||||
|
||||
if (result != null) {
|
||||
gruppoMag = UtilityHashMap.getValueIfExists(result, "GRUPPOMAG");
|
||||
contoMag = UtilityHashMap.getValueIfExists(result, "CONTOMAG");
|
||||
gruppoFattura = UtilityHashMap.getValueIfExists(result, "GRUPPOFATTURA");
|
||||
contoFattura = UtilityHashMap.getValueIfExists(result, "CONTOFATTURA");
|
||||
}
|
||||
|
||||
|
||||
List<PlurimaDocumentDTO> singlePlurimaDocumentRows = Stream.of(plurimaDocumentDTOList)
|
||||
.filter(plurimaDocumentDTO -> testataDoc.getCodAnag().equalsIgnoreCase(plurimaDocumentDTO.getCodAnag()) &&
|
||||
testataDoc.getCodDtip().equalsIgnoreCase(plurimaDocumentDTO.getCodDtip()) &&
|
||||
testataDoc.getDataDoc().equals(plurimaDocumentDTO.getDataDoc()) &&
|
||||
testataDoc.getSerDoc().equalsIgnoreCase(plurimaDocumentDTO.getSerDoc()) &&
|
||||
testataDoc.getNumDoc().equals(plurimaDocumentDTO.getNumDoc()))
|
||||
.toList();
|
||||
|
||||
|
||||
for (PlurimaDocumentDTO plurimaDocumentDTO : singlePlurimaDocumentRows) {
|
||||
|
||||
progressivoMag = maxProgMag + 1;
|
||||
progrGenerale = plurimaDocumentDTO.getProgrGenerale() + maxProgGen;
|
||||
|
||||
queryInsert = "INSERT INTO MAGAZZINO ([ANNO]" +
|
||||
",[SERIEMAGAZZINO]" +
|
||||
",[PROGRESSIVOMAG]" +
|
||||
",[FLAGCONTROMAG]" +
|
||||
",[RIGO]" +
|
||||
",[PROGRGENERALE]" +
|
||||
",[DATAOPMAGAZZINO]" +
|
||||
",[NUMDOCMAGAZZINO]" +
|
||||
",[DATADOCMAG]" +
|
||||
",[NUMFATTURAMAG]" +
|
||||
",[DATAFATTURAMAG]" +
|
||||
",[MCAUSALE]" +
|
||||
",[MMAGAZZINO]" +
|
||||
",[GRUPPOMAG]" +
|
||||
",[CONTOMAG]" +
|
||||
",[GRUPPOPROP]" +
|
||||
",[CONTOPROP]" +
|
||||
",[GRUPPOFATTURA]" +
|
||||
",[CONTOFATTURA]" +
|
||||
",[CONTROMAG]" +
|
||||
",[TIPORIGOMAG]" +
|
||||
",[MARTICOLO]" +
|
||||
",[CODICEEAN]" +
|
||||
",[VARIANTE1]" +
|
||||
",[VARIANTE2]" +
|
||||
",[VARIANTE3]" +
|
||||
",[VARIANTE4]" +
|
||||
",[VARIANTE5]" +
|
||||
",[MDESCRARTICOLO]" +
|
||||
",[MUNITA]" +
|
||||
",[MCOEFFICIENTE]" +
|
||||
",[MQUANTITA]" +
|
||||
",[MQUANTITAV]" +
|
||||
",[MQUANTITA2]" +
|
||||
",[VALORE]" +
|
||||
",[VALOREUNITARIO]" +
|
||||
",[PREZZO]" +
|
||||
",[PREZZOEXTRA]" +
|
||||
",[MVALUTA]" +
|
||||
",[MCAMBIO]" +
|
||||
",[SCONTOARTICOLO]" +
|
||||
",[SCONTOC1]" +
|
||||
",[SCONTOC2]" +
|
||||
",[SCONTOP]" +
|
||||
",[MPROVVARTICOLO]" +
|
||||
",[MPROVVCLIENTE]" +
|
||||
",[LOTTOMAG]" +
|
||||
",[CONDPAGMAG]" +
|
||||
",[IVAMAG]" +
|
||||
",[MAGENTE]" +
|
||||
",[DATAPRIMAMAG]" +
|
||||
",[MCOMMESSA]" +
|
||||
",[MCOLLI]" +
|
||||
",[MMODOCONSEGNA]" +
|
||||
",[MVETTORE]" +
|
||||
",[VALOREUSER]" +
|
||||
",[DESCRUSER1]" +
|
||||
",[DESCRUSER2]" +
|
||||
",[DESCRUSER3]" +
|
||||
",[DESCRUSER4]" +
|
||||
",[DESCRUSER5]" +
|
||||
",[QUANTITAUSER01]" +
|
||||
",[QUANTITAUSER02]" +
|
||||
",[QUANTITAUSER03]" +
|
||||
",[QUANTITAUSER04]" +
|
||||
",[QUANTITAUSER05]" +
|
||||
",[FLAGTRASFERITO]" +
|
||||
",[NOTEMAG]" +
|
||||
",[PROVENIENZA]" +
|
||||
",[PID]" +
|
||||
",[RIF_RIGA_COMMESSA]" +
|
||||
",[PARTITACDEPOSITO]" +
|
||||
",[CONTROLLOBF]" +
|
||||
",[DATAINSERIMENTO]" +
|
||||
",[USERNAME]" +
|
||||
",[DATAMODIFICA]" +
|
||||
",[COSTOMEDIO]" +
|
||||
",[SETTORE]" +
|
||||
",[OGGETTO]" +
|
||||
",[RIGOGIORNALE]" +
|
||||
",[SYS_CREATEDATE]" +
|
||||
",[SYS_CREATEUSER]" +
|
||||
",[SYS_UPDATEDATE]" +
|
||||
",[SYS_UPDATEUSER]" +
|
||||
",[MCENTROCOSTO]" +
|
||||
",[MVOCESPESA]" +
|
||||
",[MCIG]" +
|
||||
",[MCUP]" +
|
||||
",[BFRIGO]" +
|
||||
",[BFVERIFICA]) VALUES (" +
|
||||
UtilityDate.formatDate(dataDoc, "YYYY") + "," +
|
||||
UtilityDB.valueToString(SERIEMAG) + "," +
|
||||
progressivoMag + "," +
|
||||
"''," +
|
||||
plurimaDocumentDTO.getRigo() + "," +
|
||||
progrGenerale + "," +
|
||||
UtilityDB.valueDateToString(plurimaDocumentDTO.getDataReg(), CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getNumDocMagazzino()) + "," +
|
||||
UtilityDB.valueDateToString(dataDoc, CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
"''," +
|
||||
" null, " +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmCausale()) + "," +
|
||||
UtilityDB.valueToString(MMAGAZZINO) + "," +
|
||||
UtilityDB.valueToString(gruppoMag) + "," +
|
||||
UtilityDB.valueToString(contoMag) + "," +
|
||||
"0, " +
|
||||
"''," +
|
||||
UtilityDB.valueToString(gruppoFattura) + "," +
|
||||
UtilityDB.valueToString(contoFattura) + "," +
|
||||
"''," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmArticolo()) + "," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmDescrArticolo()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmUnita()) + "," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //MCOEFFICIENTE
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmQuantita()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmQuantitaV()) + "," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getValore()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getValoreUnitario()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getPrezzo()) + "," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //PREZZOEXTRA
|
||||
"''," + //MVALUTA
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //MCAMBIO
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getScontoArticolo()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getScontoC1()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getScontoC2()) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getScontoP()) + "," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //MPROVVARTICOLO
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //MPROVVCLIENTE
|
||||
(UtilityString.isNullOrEmpty(plurimaDocumentDTO.getLottoMag()) ? "''" : UtilityDB.valueToString(plurimaDocumentDTO.getLottoMag())) + "," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getIvaMag()) + "," +
|
||||
(UtilityString.isNullOrEmpty(plurimaDocumentDTO.getmAgente()) ? "''" : UtilityDB.valueToString(plurimaDocumentDTO.getmAgente())) + "," +
|
||||
"NULL," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getmColli()) + "," +
|
||||
"''," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //VALOREUSER
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //QUANTITAUSER01
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //QUANTITAUSER02
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //QUANTITAUSER03
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //QUANTITAUSER04
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //QUANTITAUSER05
|
||||
UtilityDB.valueToString(FLAGTRASFERITO) + "," +
|
||||
"''," +
|
||||
"''," +
|
||||
PID + "," +
|
||||
RIF_RIGA_COMMESSA + "," +
|
||||
PARTITACDEPOSITO + "," +
|
||||
"''," +
|
||||
UtilityDB.valueDateToString(plurimaDocumentDTO.getDataInserimento(), CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getUsername()) + "," +
|
||||
UtilityDB.valueDateToString(plurimaDocumentDTO.getDataModifica(), CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
UtilityDB.valueToString(BigDecimal.ZERO) + "," + //COSTOMEDIO
|
||||
"''," +
|
||||
"''," +
|
||||
RIGOGIORNALE + "," +
|
||||
UtilityDB.valueDateToString(plurimaDocumentDTO.getDataInserimento(), CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getUsername()) + "," +
|
||||
UtilityDB.valueDateToString(plurimaDocumentDTO.getDataModifica(), CommonConstants.DATETIME_FORMAT_DMY) + "," +
|
||||
UtilityDB.valueToString(plurimaDocumentDTO.getSysUpdateUser()) + "," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
"''," +
|
||||
BFRIGO + "," +
|
||||
"'')";
|
||||
|
||||
PreparedStatement ps = connectPlurima.prepareStatement(queryInsert);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
|
||||
queryUpdate = "Update SALDIMAGAZZINO " +
|
||||
" set SALDIMAGAZZINO.qGiacenza += SaldiDoc.qGiacenza," +
|
||||
" SALDIMAGAZZINO.qCarichi += SaldiDoc.qCarichi," +
|
||||
" SALDIMAGAZZINO.VCarichi += SaldiDoc.VCarichi," +
|
||||
" SALDIMAGAZZINO.qScarichi += SaldiDoc.qScarichi," +
|
||||
" SALDIMAGAZZINO.VScarichi += SaldiDoc.VSCarichi," +
|
||||
" SALDIMAGAZZINO.qFiscale += SaldiDoc.qFiscale," +
|
||||
" SALDIMAGAZZINO.VFiscale += SaldiDoc.VFiscale " +
|
||||
" from SALDIMAGAZZINO," +
|
||||
"(select mmagazzino, marticolo, sum(MQUANTITA*TMMC.GIACENZA) as qGiacenza," +
|
||||
" sum(MQUANTITA*TMMC.CARICHI) as qCarichi," +
|
||||
" sum(VALORE*TMMC.CARICHI*TMMC.FISCALE) as VCarichi," +
|
||||
" sum(MQUANTITA*TMMC.SCARICHI) as qScarichi," +
|
||||
" sum(VALORE*TMMC.SCARICHI*TMMC.FISCALE) as VSCarichi," +
|
||||
" sum(MQUANTITA*TMMC.GIACENZA*TMMC.FISCALE) as QFiscale," +
|
||||
" sum(VALORE*TMMC.GIACENZA*TMMC.FISCALE) as VFiscale " +
|
||||
" from MAGAZZINO, TMMC " +
|
||||
" where anno = YEAR(" + UtilityDB.valueDateToString(testataDoc.getDataReg(), CommonConstants.DATE_FORMAT_YMD) + ") and " +
|
||||
" SERIEMAGAZZINO = " + UtilityDB.valueToString(SERIEMAG) + " and " +
|
||||
" PROGRESSIVOMAG = " + progressivoMag + " and " +
|
||||
" MAGAZZINO.MCAUSALE = TMMC.MCAUSALE " +
|
||||
" group by MMAGAZZINO, marticolo" +
|
||||
" )SaldiDoc" +
|
||||
" Where SALDIMAGAZZINO.MARTICOLO = SaldiDoc.MARTICOLO and " +
|
||||
" SALDIMAGAZZINO.MMAGAZZINO = SaldiDoc.MMAGAZZINO";
|
||||
|
||||
Statement cmd = connectPlurima.createStatement();
|
||||
cmd.executeUpdate(queryUpdate);
|
||||
cmd.close();
|
||||
connectPlurima.commit();
|
||||
DtbDoct docSaved = (DtbDoct) testataDoc.clone();
|
||||
elencoDocSalvati.add(docSaved);
|
||||
} catch (Exception ep) {
|
||||
connectPlurima.rollback();
|
||||
String error = "Impossibile salvare il documento n. " + numDocPlurima + " del " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(dataDoc) + " fornitore " + codAnag + CommonConstants.A_CAPO +
|
||||
ep.getMessage();
|
||||
if (ep instanceof SQLException) {
|
||||
error += CommonConstants.A_CAPO + queryInsert;
|
||||
}
|
||||
|
||||
anomalieList.add(AnomalieDTO.error(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!elencoDocSalvati.isEmpty()) {
|
||||
message += elencoDocSalvati.size() + " documenti esportati con successo";
|
||||
} else {
|
||||
message += "Nessun documento esportato.";
|
||||
}
|
||||
|
||||
EntityExportResponse<List<File>> entityResponse = new EntityExportResponse<>();
|
||||
entityResponse.setExtraInfo(elencoDocSalvati);
|
||||
entityResponse.setMessageContent(message);
|
||||
|
||||
return entityResponse;
|
||||
}
|
||||
|
||||
public EntityExportResponse exportDocumentiBonMarket(String type, String format, String whereCond) throws Exception {
|
||||
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
@@ -50,9 +50,6 @@ public class OrdiniImporter extends BaseEntityImporter<List<EntityBase>> impleme
|
||||
case SLAV2ORDL:
|
||||
result = getContextBean(ProductionSincroService.class).scaricoVsOrd(requestDto.getWhereCond());
|
||||
break;
|
||||
case BIOLEXCH:
|
||||
result = getContextBean(OrdiniBiolevanteExchService.class).importOrdiniBiolevExch();
|
||||
break;
|
||||
case MAXIDATA:
|
||||
result = getContextBean(ProduzioniLamonarcaMaxidataService.class).importProduzioniLamonarca();
|
||||
break;
|
||||
@@ -106,7 +103,6 @@ public class OrdiniImporter extends BaseEntityImporter<List<EntityBase>> impleme
|
||||
PUDDY("PUDDY"),
|
||||
PUDDY_INCASSI_PREV("PUDDY_INCASSI_PREV"),
|
||||
SLAV2ORDL("SLAV2ORDL"),
|
||||
BIOLEXCH("BIOLEXCH"),
|
||||
CONSORTILE("CONSORTILE"),
|
||||
ORDINIDAAPPROV("ORDINIDAAPPROV"),
|
||||
MAXIDATA("MAXIDATA"),
|
||||
|
||||
@@ -1,492 +0,0 @@
|
||||
package it.integry.ems.order.Import.service;
|
||||
|
||||
import it.integry.ems._context.ApplicationContextProvider;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.product.importaz.service.ImportAnagListiniService;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.entity._enum.FlagEvaso;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class OrdiniBiolevanteExchService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
private Date mLastProcedureStartTime = null;
|
||||
|
||||
public List<EntityBase> importOrdiniBiolevExch() throws Exception {
|
||||
ImportAnagListiniService importAnagListiniService = ContextLoader.getCurrentWebApplicationContext().getBean(ImportAnagListiniService.class);
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
EntityProcessor entityProcessor = ApplicationContextProvider.getApplicationContext().getBean(EntityProcessor.class);
|
||||
|
||||
String profileSource, sql, codJcom, descrCommessaFormato, ragSoc, destinatario, descrCommessa = "", codTcol,
|
||||
gestione = "V", rifOrd, codAnag, codVdes, untOrd, codTcolUl, codMart, codMdep, diacod,
|
||||
addressId, codMdepDefault, serie, serieOld = "", note, noteOrd, noteRigaOrd, termCons;
|
||||
Date dataOrd, dataCons, dataOrdOld = null, dataConsOld = null;
|
||||
BigDecimal qtaOrd;
|
||||
BigDecimal prezzo;
|
||||
BigDecimal numCnf;
|
||||
BigDecimal colliPedana;
|
||||
Integer numOrd;
|
||||
Integer rigaOrd;
|
||||
Integer numOrdProv;
|
||||
Integer numOrdProvOld = 0;
|
||||
|
||||
PreparedStatement info;
|
||||
ResultSet res;
|
||||
List<EntityBase> entityList = new ArrayList<EntityBase>();
|
||||
List<EntityBase> toBeProcessed = new ArrayList<EntityBase>();
|
||||
List<DtbOrdr> dtbOrdrList = new ArrayList<DtbOrdr>();
|
||||
DtbOrdt dtbOrdt = new DtbOrdt();
|
||||
List<EntityBase> arrayLisv = new ArrayList<EntityBase>();
|
||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||
|
||||
Map<String, String> setup = setupGest.getImportSetupSection(conn, "ORDINI VENDITA", "BIOLEXCH");
|
||||
|
||||
profileSource = setup.get("PROFILEDB");
|
||||
if (UtilityString.isNullOrEmpty(profileSource)) {
|
||||
throw new Exception("CONFIGURARE PROFILEDB EXCH2WINGEST IN STB_GEST_SETUP.");
|
||||
}
|
||||
|
||||
DataSource dsExch2Wingest = new DataSource();
|
||||
dsExch2Wingest.initialize(profileSource);
|
||||
Connection connExch2Wingest = dsExch2Wingest.getConnection();
|
||||
|
||||
if (mLastProcedureStartTime != null)
|
||||
throw new Exception("Non è possibile far partire la procedura di importazione ordini in quanto già lanciata alle " + UtilityDB.valueDateToString(mLastProcedureStartTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
try {
|
||||
codMdepDefault = setup.get("COD_MDEP_DEFAULT");
|
||||
descrCommessaFormato = setupGest.getSetup(conn, "w_dordi_rc", "CREA_COMMESSA", "FORMATO_DESCRIZIONE");
|
||||
if (UtilityString.isNullOrEmpty(descrCommessaFormato)) {
|
||||
throw new Exception("CONFIGURARE UN FORMATO DI DESCRIZIONE PER LA CREAZIONE DELLA COMMESSA IN STB_GEST_SETUP.");
|
||||
}
|
||||
|
||||
// QUERY PER CONTROLLARE SE LA PROCEDURA E' GIA' IN ESECUZIONE
|
||||
mLastProcedureStartTime = new Date();
|
||||
|
||||
// QUERY aggiunta per annullare ordini non presenti su db di scambio
|
||||
// " and rif_ord like '20[1-2][0-9][A-Z] [0-9][0-9][0-9][0-9][0-9][0-9]'" +
|
||||
//
|
||||
sql = "update Biolevante.dbo.dtb_ordt set flag_annulla = 'S' " +
|
||||
" where gestione = 'V' " +
|
||||
" and num_ord_provv is not null " +
|
||||
" and serie is not null " +
|
||||
" and flag_annulla = 'N' " +
|
||||
" and Convert(varchar(4), Year(data_ord))+serie +' '+replicate('0', 6 - Len(num_ord_provv))+Convert(varchar(6),num_ord_provv) not in (select distinct OrdNum from BiolevanteExch.dbo.ShippingOrders)";
|
||||
Statement cmd = multiDBTransactionManager.getPrimaryConnection().createStatement();
|
||||
cmd.executeUpdate(sql);
|
||||
multiDBTransactionManager.getPrimaryConnection().commit();
|
||||
cmd.close();
|
||||
|
||||
|
||||
// COMMESSE
|
||||
sql = "select distinct PlurimaShippingOrders.CommissionID as cod_jcom, " +
|
||||
" Companies.compName as rag_soc, " +
|
||||
" Addresses.address as destinatario" +
|
||||
" from PlurimaShippingOrders LEFT OUTER JOIN Addresses ON PlurimaShippingOrders.compId = Addresses.compId AND PlurimaShippingOrders.addressId = Addresses.addressId, Companies " +
|
||||
"where PlurimaShippingOrders.compId = Companies.CompId and isnull(PlurimaShippingOrders.CommissionID,'') <>''";
|
||||
|
||||
info = connExch2Wingest.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
codJcom = res.getString("cod_jcom");
|
||||
ragSoc = res.getString("rag_soc");
|
||||
destinatario = res.getString("destinatario");
|
||||
|
||||
if (descrCommessaFormato.compareTo("RAG_SOC") == 0) {
|
||||
descrCommessa = ragSoc;
|
||||
} else if (descrCommessaFormato.compareTo("RAG_SOC+DEST") == 0) {
|
||||
descrCommessa = ragSoc + " " + destinatario;
|
||||
}
|
||||
JtbComt jtbComt = new JtbComt();
|
||||
jtbComt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
jtbComt.setCodJcom(codJcom);
|
||||
jtbComt.setDescrizione(descrCommessa);
|
||||
|
||||
toBeProcessed.add(jtbComt);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
sql = "select distinct PlurimaShippingOrders.palletType as cod_tcol " +
|
||||
" from PlurimaShippingOrders " +
|
||||
"where isnull(PlurimaShippingOrders.palletType,'') <>''";
|
||||
|
||||
info = connExch2Wingest.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
codTcol = res.getString("cod_tcol");
|
||||
|
||||
MtbTcol mtbTcol = new MtbTcol();
|
||||
mtbTcol.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
mtbTcol.setCodTcol(codTcol);
|
||||
mtbTcol.setFlagUiUl("UL");
|
||||
|
||||
toBeProcessed.add(mtbTcol);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
sql = "select PlurimaShippingOrders.OrdDate as data_ord, " +
|
||||
" PlurimaShippingOrders.OrdNum as num_ord, " +
|
||||
" PlurimaShippingOrders.OrdRow as riga_ord, " +
|
||||
" PlurimaShippingOrders.CompId as diacod, " +
|
||||
" PlurimaShippingOrders.addressId as cod_vdes, " +
|
||||
" PlurimaShippingOrders.WareHouse as cod_mdep, " +
|
||||
" PlurimaShippingOrders.ShipDate as data_cons, " +
|
||||
" PlurimaShippingOrders.itemId as cod_mart, " +
|
||||
" CASE WHEN isnull(PlurimaShippingOrders.UM,'') = '' THEN Biolevante.dbo.mtb_aart.unt_mis ELSE PlurimaShippingOrders.UM END as unt_ord, " +
|
||||
" PlurimaShippingOrders.qty as qta_ord, " +
|
||||
" PlurimaShippingOrders.NumPack as num_cnf, " +
|
||||
" PlurimaShippingOrders.commissionId as cod_jcom, " +
|
||||
" PlurimaShippingOrders.custNpackPallet as colli_pedana, " +
|
||||
" PlurimaShippingOrders.palletType as cod_tcol_ul, " +
|
||||
" PlurimaShippingOrders.prezzo," +
|
||||
" PlurimaShippingOrders.serie, " +
|
||||
" PlurimaShippingOrders.num_ord_prov, " +
|
||||
" PlurimaShippingOrders.rifOrd, " +
|
||||
" PlurimaShippingOrders.note, " +
|
||||
" PlurimaShippingOrders.NoteOrd, " +
|
||||
" PlurimaShippingOrders.NoteRigaOrd, " +
|
||||
" PlurimaShippingOrders.TermCons, " +
|
||||
" PlurimaShippingOrders.pedane " +
|
||||
" from PlurimaShippingOrders, Items LEFT OUTER JOIN Biolevante.dbo.mtb_aart ON Items.ItemId = Biolevante.dbo.mtb_aart.cod_mart, ItemGroups, ItemSgroups " +
|
||||
"where PlurimaShippingOrders.ItemId = Items.ItemID AND " +
|
||||
" Items.GroupId = ItemGroups.GroupId AND " +
|
||||
" Items.SgroupId = ItemSgroups.SgroupId AND " +
|
||||
" PlurimaShippingOrders.CompId not in (SELECT value_string FROM Biolevante.dbo.parseStringIntoArray(" + UtilityDB.valueToString(setup.get("ESLCUDI_CLIENTI")) + ", '|')) " +
|
||||
" order by PlurimaShippingOrders.OrdDate, " +
|
||||
" PlurimaShippingOrders.OrdNum," +
|
||||
" PlurimaShippingOrders.ShipDate, " +
|
||||
" PlurimaShippingOrders.OrdRow ";
|
||||
|
||||
info = connExch2Wingest.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
dataOrd = res.getDate("data_ord");
|
||||
rigaOrd = res.getInt("riga_ord");
|
||||
diacod = res.getString("diacod");
|
||||
addressId = res.getString("cod_vdes");
|
||||
codMdep = res.getString("cod_mdep");
|
||||
dataCons = res.getDate("data_cons");
|
||||
codMart = res.getString("cod_mart");
|
||||
untOrd = res.getString("unt_ord");
|
||||
qtaOrd = res.getBigDecimal("qta_ord");
|
||||
numCnf = res.getBigDecimal("num_cnf");
|
||||
codJcom = res.getString("cod_jcom").trim();
|
||||
colliPedana = res.getBigDecimal("colli_pedana");
|
||||
codTcolUl = res.getString("cod_tcol_ul");
|
||||
prezzo = res.getBigDecimal("prezzo");
|
||||
serie = res.getString("serie");
|
||||
numOrdProv = res.getInt("num_ord_prov");
|
||||
rifOrd = UtilityString.left(UtilityString.streNull(res.getString("rifOrd")).trim(), 40);
|
||||
note = UtilityString.left(res.getString("note"), 255);
|
||||
String flagStato = isArticoloAttivo(conn, codMart);
|
||||
noteOrd = res.getString("NoteOrd");
|
||||
noteRigaOrd = res.getString("NoteRigaOrd");
|
||||
termCons = res.getString("TermCons");
|
||||
Integer pedane = res.getInt("pedane");
|
||||
|
||||
String untMisVen = getUntMisVen(conn, codMart, untOrd);
|
||||
|
||||
final VtbDest vtbDest = findAnag(conn, diacod, addressId);
|
||||
|
||||
if (vtbDest.getCodAnag() != null) {
|
||||
if (UtilityString.streNull(flagStato).compareTo("A") == 0 && !UtilityString.isNullOrEmpty(untMisVen)) {
|
||||
|
||||
VtbList vtbListRet = findCodVlis(conn, vtbDest.getCodAnag());
|
||||
if (vtbListRet.getCodVlis() == null) {
|
||||
VtbList vtbList = new VtbList();
|
||||
vtbList.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
vtbList.setCodVlis(vtbDest.getCodAnag());
|
||||
vtbList.setDescrizione(vtbListRet.getDescrizione());
|
||||
arrayLisv.add(vtbList);
|
||||
|
||||
GtbAnag gtbAnag = new GtbAnag();
|
||||
gtbAnag.setCodAnag(vtbDest.getCodAnag());
|
||||
VtbClie vtbClie = new VtbClie();
|
||||
vtbClie.setOperation(OperationType.UPDATE);
|
||||
vtbClie.setCodAnag(vtbDest.getCodAnag());
|
||||
vtbClie.setCodVlis(vtbDest.getCodAnag());
|
||||
gtbAnag.setVtbClie(vtbClie);
|
||||
toBeProcessed.add(gtbAnag);
|
||||
}
|
||||
if (findCodMartMtbLisv(conn, vtbDest.getCodAnag(), codMart) == 0) {
|
||||
MtbLisvData mtbLisvData = new MtbLisvData();
|
||||
mtbLisvData.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
mtbLisvData.setCodVlis(vtbDest.getCodAnag());
|
||||
mtbLisvData.setUntMisVen(untMisVen);
|
||||
mtbLisvData.setRapConv(BigDecimal.ONE);
|
||||
mtbLisvData.setDataIniz(dataOrd);
|
||||
mtbLisvData.setCodMart(codMart);
|
||||
mtbLisvData.setPrzBase(BigDecimal.ZERO);
|
||||
|
||||
arrayLisv.add(mtbLisvData);
|
||||
}
|
||||
}
|
||||
|
||||
if (serie.compareTo(serieOld) != 0 || dataOrd.compareTo(dataOrdOld) != 0 || numOrdProv.compareTo(numOrdProvOld) != 0) {
|
||||
if (!dtbOrdrList.isEmpty()) {
|
||||
dtbOrdt.setDtbOrdr(dtbOrdrList);
|
||||
toBeProcessed.add(dtbOrdt);
|
||||
}
|
||||
|
||||
numOrd = findOrder(conn, dataOrd, serie, numOrdProv);
|
||||
codAnag = vtbDest.getCodAnag();
|
||||
codVdes = vtbDest.getCodVdes();
|
||||
|
||||
dtbOrdrList = new ArrayList<>();
|
||||
|
||||
dtbOrdt = new DtbOrdt();
|
||||
if (numOrd == 0) {
|
||||
dtbOrdt.setOperation(OperationType.INSERT);
|
||||
} else {
|
||||
dtbOrdt.setOperation(OperationType.DELETE_THEN_INSERT);
|
||||
}
|
||||
dtbOrdt.setNumOrd(numOrd);
|
||||
dtbOrdt.setDataOrd(dataOrd);
|
||||
if (UtilityString.streNull(rifOrd).compareTo("") == 0) {
|
||||
rifOrd = "[NULL]";
|
||||
}
|
||||
dtbOrdt.setRifOrd(rifOrd);
|
||||
dtbOrdt.setFlagAnnulla("N");
|
||||
dtbOrdt.setNumOrdProvv(numOrdProv);
|
||||
dtbOrdt.setSerie(serie);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(codMdepDefault)) {
|
||||
dtbOrdt.setCodMdep(codMdepDefault);
|
||||
} else {
|
||||
dtbOrdt.setCodMdep(codMdep);
|
||||
}
|
||||
|
||||
dtbOrdt.setCodAnag(codAnag);
|
||||
dtbOrdt.setCodVdes(codVdes);
|
||||
dtbOrdt.setGestione(gestione);
|
||||
dtbOrdt.setPostiPallet(pedane);
|
||||
dtbOrdt.setDataInizTrasp(dataCons);
|
||||
if (!UtilityString.isNullOrEmpty(codJcom)) {
|
||||
dtbOrdt.setCodJcom(codJcom);
|
||||
}
|
||||
if (!UtilityString.isNullOrEmpty(noteOrd)) {
|
||||
dtbOrdt.setNote(noteOrd);
|
||||
}
|
||||
if (!UtilityString.isNullOrEmpty(termCons)) {
|
||||
dtbOrdt.setTermCons(termCons);
|
||||
}
|
||||
}
|
||||
|
||||
DtbOrdr dtbOrdr = new DtbOrdr();
|
||||
if (dtbOrdt.getOperation() == OperationType.INSERT) {
|
||||
dtbOrdr.setOperation(OperationType.INSERT);
|
||||
} else {
|
||||
dtbOrdr.setOperation(OperationType.DELETE_THEN_INSERT);
|
||||
}
|
||||
dtbOrdr.setCodMart(codMart);
|
||||
dtbOrdr.setDescrizione(null);
|
||||
dtbOrdr.setDescrizioneEstesa(null);
|
||||
dtbOrdr.setUntOrd(untOrd);
|
||||
dtbOrdr.setQtaOrd(qtaOrd);
|
||||
dtbOrdr.setValUnt(prezzo);
|
||||
dtbOrdr.setRigaOrd(rigaOrd);
|
||||
if (numCnf.equals(BigDecimal.ZERO)) {
|
||||
numCnf = BigDecimal.ONE;
|
||||
}
|
||||
dtbOrdr.setNumCnf(numCnf);
|
||||
dtbOrdr.setNote(note);
|
||||
if (codJcom.compareTo("") != 0) {
|
||||
dtbOrdr.setCodJcom(codJcom);
|
||||
}
|
||||
dtbOrdr.setColliPedana(colliPedana);
|
||||
dtbOrdr.setCodTcolUl(codTcolUl);
|
||||
dtbOrdr.setDataCons(dataCons);
|
||||
if (UtilityString.streNull(flagStato).compareTo("I") == 0) {
|
||||
dtbOrdr.setFlagEvaso(FlagEvaso.ANNULLATO);
|
||||
}
|
||||
if (!UtilityString.isNullOrEmpty(noteRigaOrd)) {
|
||||
dtbOrdr.setNote(noteRigaOrd);
|
||||
}
|
||||
dtbOrdrList.add(dtbOrdr);
|
||||
}
|
||||
|
||||
dataOrdOld = dataOrd;
|
||||
dataConsOld = dataCons;
|
||||
serieOld = serie;
|
||||
numOrdProvOld = numOrdProv;
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
if (!dtbOrdrList.isEmpty()) {
|
||||
dtbOrdt.setDtbOrdr(dtbOrdrList);
|
||||
toBeProcessed.add(dtbOrdt);
|
||||
}
|
||||
|
||||
|
||||
if (!arrayLisv.isEmpty()) {
|
||||
|
||||
arrayLisv = importAnagListiniService.importAnagListinoAcq(arrayLisv, "V", null, null);
|
||||
|
||||
for (EntityBase entityBase : arrayLisv) {
|
||||
if (entityBase.getException() != null) {
|
||||
throw entityBase.getException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!toBeProcessed.isEmpty()) {
|
||||
entityList = entityProcessor.processEntityList(toBeProcessed, false);
|
||||
for (EntityBase entityBase : entityList) {
|
||||
if (entityBase.getException() != null) {
|
||||
throw entityBase.getException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mLastProcedureStartTime = null;
|
||||
|
||||
} catch (Exception ex) {
|
||||
mLastProcedureStartTime = null;
|
||||
|
||||
logger.error(ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
mLastProcedureStartTime = null;
|
||||
}
|
||||
return entityList;
|
||||
}
|
||||
|
||||
private Integer findOrder(Connection connect, Date dataOrd, String serie, Integer numOrdProv) throws Exception {
|
||||
Integer numOrd = 0;
|
||||
ResultSet res;
|
||||
PreparedStatement info;
|
||||
String sql;
|
||||
|
||||
sql = "SELECT num_ord " +
|
||||
" FROM dtb_ordt " +
|
||||
" WHERE gestione = 'V' and serie = " + UtilityDB.valueToString(serie) + " and num_ord_provv = " + UtilityDB.valueToString(numOrdProv) + " and data_ord = " + UtilityDB.valueDateToString(dataOrd, "yyyy-MM-dd");
|
||||
|
||||
info = connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
numOrd = res.getInt("num_ord");
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
|
||||
return numOrd;
|
||||
}
|
||||
|
||||
private VtbDest findAnag(Connection connect, String diacod, String addressId) throws Exception {
|
||||
String codAnag = null, codVdes = null;
|
||||
VtbDest entity = new VtbDest();
|
||||
ResultSet res;
|
||||
PreparedStatement info;
|
||||
String sql;
|
||||
|
||||
sql = "SELECT gtb_anag.cod_anag, cod_vdes " +
|
||||
" FROM gtb_anag LEFT OUTER JOIN vtb_dest ON gtb_anag.cod_anag = vtb_dest.cod_anag AND vtb_dest.cod_ean = " + UtilityDB.valueToString(addressId) +
|
||||
" WHERE diacod = " + UtilityDB.valueToString(diacod);
|
||||
|
||||
info = connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
codAnag = res.getString("cod_anag");
|
||||
codVdes = res.getString("cod_vdes");
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
entity.setCodAnag(codAnag);
|
||||
entity.setCodVdes(codVdes);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private VtbList findCodVlis(Connection connect, String codAnag) throws Exception {
|
||||
String codVlis = null, descrizione = null;
|
||||
Integer count = 0;
|
||||
VtbList entity = new VtbList();
|
||||
ResultSet res;
|
||||
PreparedStatement info;
|
||||
String sql;
|
||||
|
||||
sql = "SELECT count(vtb_list.cod_vlis), gtb_anag.rag_soc " +
|
||||
" FROM gtb_anag LEFT OUTER JOIN vtb_list ON vtb_list.cod_vlis = gtb_anag.cod_anag " +
|
||||
" WHERE gtb_anag.cod_anag = " + UtilityDB.valueToString(codAnag) +
|
||||
" GROUP BY gtb_anag.rag_soc";
|
||||
|
||||
info = connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
count = res.getInt(1);
|
||||
descrizione = res.getString(2);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
if (count > 0) {
|
||||
codVlis = codAnag;
|
||||
}
|
||||
entity.setCodVlis(codVlis);
|
||||
entity.setDescrizione(descrizione);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
private Integer findCodMartMtbLisv(Connection connect, String codAnag, String codMart) throws Exception {
|
||||
Integer count = 0;
|
||||
ResultSet res;
|
||||
PreparedStatement info;
|
||||
String sql;
|
||||
|
||||
sql = "SELECT count(mtb_lisv_data.cod_mart) " +
|
||||
" FROM mtb_lisv_data " +
|
||||
" WHERE mtb_lisv_data.cod_vlis = " + UtilityDB.valueToString(codAnag) + " AND " +
|
||||
" mtb_lisv_data.cod_mart = " + UtilityDB.valueToString(codMart);
|
||||
|
||||
info = connect.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
res = info.executeQuery();
|
||||
while (res.next()) {
|
||||
count = res.getInt(1);
|
||||
}
|
||||
res.close();
|
||||
info.close();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private String isArticoloAttivo(Connection connect, String codMart) throws Exception {
|
||||
String sql = "SELECT flag_stato " +
|
||||
" FROM mtb_aart " +
|
||||
" WHERE cod_mart = " + UtilityDB.valueToString(codMart);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connect, sql);
|
||||
}
|
||||
|
||||
private String getUntMisVen(Connection connect, String codMart, String untOrd) throws Exception {
|
||||
String sql = "SELECT CASE WHEN '" + untOrd + "' = mtb_aart.unt_mis THEN mtb_aart.unt_mis ELSE (CASE WHEN '" + untOrd + "' = mtb_aart.unt_mis2 THEN mtb_aart.unt_mis2 ELSE (CASE WHEN '" + untOrd + "' = mtb_aart.unt_mis3 THEN mtb_aart.unt_mis3 ELSE '' END) END) END as untMisVen " +
|
||||
" FROM mtb_aart " +
|
||||
" WHERE cod_mart = " + UtilityDB.valueToString(codMart);
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connect, sql);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package it.integry.ems.order.conquist.controller;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.order.conquist.dto.TrackingDTO;
|
||||
import it.integry.ems.order.conquist.service.ConquistEcommerceService;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.FileItem;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
|
||||
public class ConquistEcommerceController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private ConquistEcommerceService conquistEcommerceService;
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_IMPORT_CLIENTI_CQ, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importClienti(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration, @RequestBody String csv) {
|
||||
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
conquistEcommerceService.importClienti(csv);
|
||||
response = new ServiceRestResponse(EsitoType.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
e.printStackTrace();
|
||||
response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_CLIENTI_CQ, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse exportClienti(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) {
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
FileItem item = conquistEcommerceService.exportClienti();
|
||||
response = new ServiceRestResponse(EsitoType.OK);
|
||||
response.setXml(item);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_PRODOTTI_CQ, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse exportProdotti(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) {
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
FileItem item = conquistEcommerceService.exportProdotti();
|
||||
response = new ServiceRestResponse(EsitoType.OK);
|
||||
response.setXml(item);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_TRACKING_CQ, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse exportTracking(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody List<TrackingDTO> list) {
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
FileItem item = conquistEcommerceService.exportTracking(list);
|
||||
response = new ServiceRestResponse(EsitoType.OK);
|
||||
response.setXml(item);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@RequestMapping(value = EmsRestConstants.PATH_IMPORT_ORDINI_CQ, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importOrdini(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration, @RequestBody String csv) {
|
||||
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
conquistEcommerceService.importOrdini(csv);
|
||||
response = new ServiceRestResponse(EsitoType.OK);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
e.printStackTrace();
|
||||
response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package it.integry.ems.order.conquist.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ClienteDTO {
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password;
|
||||
|
||||
@JsonProperty("first_name")
|
||||
private String firstName;
|
||||
|
||||
@JsonProperty("last_name")
|
||||
private String lastName;
|
||||
|
||||
@JsonProperty("address_1")
|
||||
private String address1;
|
||||
|
||||
@JsonProperty("civico")
|
||||
private String civico;
|
||||
|
||||
@JsonProperty("zip")
|
||||
private String zip;
|
||||
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
|
||||
@JsonProperty("phone_1")
|
||||
private String phone1;
|
||||
|
||||
@JsonProperty("carta_fidelity")
|
||||
private String cartaFidelity;
|
||||
|
||||
@JsonProperty("usergroup_name")
|
||||
private String usergroupName;
|
||||
|
||||
@JsonProperty("address_type")
|
||||
private String addressType;
|
||||
|
||||
@JsonProperty("address_type_name")
|
||||
private String addressTypeName;
|
||||
|
||||
@JsonProperty("sesso")
|
||||
private String sesso;
|
||||
|
||||
@JsonProperty("datanascita")
|
||||
private String datanascita;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getAddress1() {
|
||||
return address1;
|
||||
}
|
||||
|
||||
public void setAddress1(String address1) {
|
||||
this.address1 = address1;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getPhone1() {
|
||||
return phone1;
|
||||
}
|
||||
|
||||
public void setPhone1(String phone1) {
|
||||
this.phone1 = phone1;
|
||||
}
|
||||
|
||||
public String getCartaFidelity() {
|
||||
return cartaFidelity;
|
||||
}
|
||||
|
||||
public void setCartaFidelity(String cartaFidelity) {
|
||||
this.cartaFidelity = cartaFidelity;
|
||||
}
|
||||
|
||||
public String getUsergroupName() {
|
||||
return usergroupName;
|
||||
}
|
||||
|
||||
public void setUsergroupName(String usergroupName) {
|
||||
this.usergroupName = usergroupName;
|
||||
}
|
||||
|
||||
public String getAddressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
public void setAddressType(String addressType) {
|
||||
this.addressType = addressType;
|
||||
}
|
||||
|
||||
public String getAddressTypeName() {
|
||||
return addressTypeName;
|
||||
}
|
||||
|
||||
public void setAddressTypeName(String addressTypeName) {
|
||||
this.addressTypeName = addressTypeName;
|
||||
}
|
||||
|
||||
public String getSesso() {
|
||||
return sesso;
|
||||
}
|
||||
|
||||
public void setSesso(String sesso) {
|
||||
this.sesso = sesso;
|
||||
}
|
||||
|
||||
public String getDatanascita() {
|
||||
return datanascita;
|
||||
}
|
||||
|
||||
public void setDatanascita(String datanascita) {
|
||||
this.datanascita = datanascita;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,471 +0,0 @@
|
||||
package it.integry.ems.order.conquist.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class OrdineDTO {
|
||||
|
||||
@JsonProperty("order_number")
|
||||
private String orderNumber;
|
||||
|
||||
@JsonProperty("created_on")
|
||||
private Date createdOn;
|
||||
|
||||
@JsonProperty("virtuemart_order_id")
|
||||
private Integer virtuemartOrderId;
|
||||
|
||||
@JsonProperty("virtuemart_product_id")
|
||||
private Integer virtuemartProductId;
|
||||
|
||||
@JsonProperty("full_name")
|
||||
private String fullName;
|
||||
|
||||
@JsonProperty("address_1")
|
||||
private String address1;
|
||||
|
||||
@JsonProperty("civico")
|
||||
private String civico;
|
||||
|
||||
@JsonProperty("zip")
|
||||
private String zip;
|
||||
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
|
||||
@JsonProperty("country_name")
|
||||
private String countryName;
|
||||
|
||||
@JsonProperty("state_name")
|
||||
private String stateName;
|
||||
|
||||
@JsonProperty("phone_1")
|
||||
private String phone1;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("customer_note")
|
||||
private String customerNote;
|
||||
|
||||
@JsonProperty("order_item_sku")
|
||||
private String orderItemSku;
|
||||
|
||||
@JsonProperty("order_item_name")
|
||||
private String orderItemName;
|
||||
|
||||
@JsonProperty("product_quantity")
|
||||
private Integer productQuantity;
|
||||
|
||||
@JsonProperty("product_item_price")
|
||||
private BigDecimal productItemPrice;
|
||||
|
||||
@JsonProperty("product_tax")
|
||||
private BigDecimal productTax;
|
||||
|
||||
@JsonProperty("product_final_price")
|
||||
private BigDecimal productFinalPrice;
|
||||
|
||||
@JsonProperty("order_shipment")
|
||||
private BigDecimal orderShipment;
|
||||
|
||||
@JsonProperty("order_shipment_tax")
|
||||
private BigDecimal orderShipmentTax;
|
||||
|
||||
@JsonProperty("order_payment")
|
||||
private BigDecimal orderPayment;
|
||||
|
||||
@JsonProperty("order_payment_tax")
|
||||
private BigDecimal orderPaymentTax;
|
||||
|
||||
@JsonProperty("order_total")
|
||||
private BigDecimal orderTotal;
|
||||
|
||||
@JsonProperty("total_order_items")
|
||||
private Integer totalOrderItems;
|
||||
|
||||
@JsonProperty("virtuemart_shipmentmethod_id")
|
||||
private String virtuemartShipmentmethodId;
|
||||
|
||||
@JsonProperty("virtuemart_paymentmethod_id")
|
||||
private String virtuemartPaymentmethodId;
|
||||
|
||||
@JsonProperty("user_currency")
|
||||
private String userCurrency;
|
||||
|
||||
@JsonProperty("order_status")
|
||||
private String orderStatus;
|
||||
|
||||
@JsonProperty("order_status_name")
|
||||
private String orderStatusName;
|
||||
|
||||
@JsonProperty("richiesta_fattura")
|
||||
private String richiestaFattura;
|
||||
|
||||
@JsonProperty("company")
|
||||
private String company;
|
||||
|
||||
@JsonProperty("codice_fiscale")
|
||||
private String codiceFiscale;
|
||||
|
||||
@JsonProperty("partita_iva")
|
||||
private String partitaIva;
|
||||
|
||||
@JsonProperty("cap_fattura")
|
||||
private String capFattura;
|
||||
|
||||
@JsonProperty("indirizzo_fattura")
|
||||
private String indirizzoFattura;
|
||||
|
||||
@JsonProperty("civico_fattura")
|
||||
private String civicoFattura;
|
||||
|
||||
@JsonProperty("citta_fattura")
|
||||
private String cittaFattura;
|
||||
|
||||
@JsonProperty("provincia_fattura")
|
||||
private String provinciaFattura;
|
||||
|
||||
@JsonProperty("negozio_scelto")
|
||||
private String negozioScelto;
|
||||
|
||||
public String getOrderNumber() {
|
||||
return orderNumber;
|
||||
}
|
||||
|
||||
public void setOrderNumber(String orderNumber) {
|
||||
this.orderNumber = orderNumber;
|
||||
}
|
||||
|
||||
public Date getCreatedOn() {
|
||||
return createdOn;
|
||||
}
|
||||
|
||||
public void setCreatedOn(Date createdOn) {
|
||||
this.createdOn = createdOn;
|
||||
}
|
||||
|
||||
public Integer getVirtuemartOrderId() {
|
||||
return virtuemartOrderId;
|
||||
}
|
||||
|
||||
public void setVirtuemartOrderId(Integer virtuemartOrderId) {
|
||||
this.virtuemartOrderId = virtuemartOrderId;
|
||||
}
|
||||
|
||||
public Integer getVirtuemartProductId() {
|
||||
return virtuemartProductId;
|
||||
}
|
||||
|
||||
public void setVirtuemartProductId(Integer virtuemartProductId) {
|
||||
this.virtuemartProductId = virtuemartProductId;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getAddress1() {
|
||||
return address1;
|
||||
}
|
||||
|
||||
public void setAddress1(String address1) {
|
||||
this.address1 = address1;
|
||||
}
|
||||
|
||||
public String getCivico() {
|
||||
return civico;
|
||||
}
|
||||
|
||||
public void setCivico(String civico) {
|
||||
this.civico = civico;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCountryName() {
|
||||
return countryName;
|
||||
}
|
||||
|
||||
public void setCountryName(String countryName) {
|
||||
this.countryName = countryName;
|
||||
}
|
||||
|
||||
public String getStateName() {
|
||||
return stateName;
|
||||
}
|
||||
|
||||
public void setStateName(String stateName) {
|
||||
this.stateName = stateName;
|
||||
}
|
||||
|
||||
public String getPhone1() {
|
||||
return phone1;
|
||||
}
|
||||
|
||||
public void setPhone1(String phone1) {
|
||||
this.phone1 = phone1;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCustomerNote() {
|
||||
return customerNote;
|
||||
}
|
||||
|
||||
public void setCustomerNote(String customerNote) {
|
||||
this.customerNote = customerNote;
|
||||
}
|
||||
|
||||
public String getOrderItemSku() {
|
||||
return orderItemSku;
|
||||
}
|
||||
|
||||
public void setOrderItemSku(String orderItemSku) {
|
||||
this.orderItemSku = orderItemSku;
|
||||
}
|
||||
|
||||
public String getOrderItemName() {
|
||||
return orderItemName;
|
||||
}
|
||||
|
||||
public void setOrderItemName(String orderItemName) {
|
||||
this.orderItemName = orderItemName;
|
||||
}
|
||||
|
||||
public Integer getProductQuantity() {
|
||||
return productQuantity;
|
||||
}
|
||||
|
||||
public void setProductQuantity(Integer productQuantity) {
|
||||
this.productQuantity = productQuantity;
|
||||
}
|
||||
|
||||
public BigDecimal getProductItemPrice() {
|
||||
return productItemPrice;
|
||||
}
|
||||
|
||||
public void setProductItemPrice(BigDecimal productItemPrice) {
|
||||
this.productItemPrice = productItemPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getProductTax() {
|
||||
return productTax;
|
||||
}
|
||||
|
||||
public void setProductTax(BigDecimal productTax) {
|
||||
this.productTax = productTax;
|
||||
}
|
||||
|
||||
public BigDecimal getProductFinalPrice() {
|
||||
return productFinalPrice;
|
||||
}
|
||||
|
||||
public void setProductFinalPrice(BigDecimal productFinalPrice) {
|
||||
this.productFinalPrice = productFinalPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderShipment() {
|
||||
return orderShipment;
|
||||
}
|
||||
|
||||
public void setOrderShipment(BigDecimal orderShipment) {
|
||||
this.orderShipment = orderShipment;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderShipmentTax() {
|
||||
return orderShipmentTax;
|
||||
}
|
||||
|
||||
public void setOrderShipmentTax(BigDecimal orderShipmentTax) {
|
||||
this.orderShipmentTax = orderShipmentTax;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderPayment() {
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
public void setOrderPayment(BigDecimal orderPayment) {
|
||||
this.orderPayment = orderPayment;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderPaymentTax() {
|
||||
return orderPaymentTax;
|
||||
}
|
||||
|
||||
public void setOrderPaymentTax(BigDecimal orderPaymentTax) {
|
||||
this.orderPaymentTax = orderPaymentTax;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderTotal() {
|
||||
return orderTotal;
|
||||
}
|
||||
|
||||
public void setOrderTotal(BigDecimal orderTotal) {
|
||||
this.orderTotal = orderTotal;
|
||||
}
|
||||
|
||||
public Integer getTotalOrderItems() {
|
||||
return totalOrderItems;
|
||||
}
|
||||
|
||||
public void setTotalOrderItems(Integer totalOrderItems) {
|
||||
this.totalOrderItems = totalOrderItems;
|
||||
}
|
||||
|
||||
public String getVirtuemartShipmentmethodId() {
|
||||
return virtuemartShipmentmethodId;
|
||||
}
|
||||
|
||||
public void setVirtuemartShipmentmethodId(String virtuemartShipmentmethodId) {
|
||||
this.virtuemartShipmentmethodId = virtuemartShipmentmethodId;
|
||||
}
|
||||
|
||||
public String getVirtuemartPaymentmethodId() {
|
||||
return virtuemartPaymentmethodId;
|
||||
}
|
||||
|
||||
public void setVirtuemartPaymentmethodId(String virtuemartPaymentmethodId) {
|
||||
this.virtuemartPaymentmethodId = virtuemartPaymentmethodId;
|
||||
}
|
||||
|
||||
public String getUserCurrency() {
|
||||
return userCurrency;
|
||||
}
|
||||
|
||||
public void setUserCurrency(String userCurrency) {
|
||||
this.userCurrency = userCurrency;
|
||||
}
|
||||
|
||||
public String getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getOrderStatusName() {
|
||||
return orderStatusName;
|
||||
}
|
||||
|
||||
public void setOrderStatusName(String orderStatusName) {
|
||||
this.orderStatusName = orderStatusName;
|
||||
}
|
||||
|
||||
public String getRichiestaFattura() {
|
||||
return richiestaFattura;
|
||||
}
|
||||
|
||||
public void setRichiestaFattura(String richiestaFattura) {
|
||||
this.richiestaFattura = richiestaFattura;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String getCodiceFiscale() {
|
||||
return codiceFiscale;
|
||||
}
|
||||
|
||||
public void setCodiceFiscale(String codiceFiscale) {
|
||||
this.codiceFiscale = codiceFiscale;
|
||||
}
|
||||
|
||||
public String getPartitaIva() {
|
||||
return partitaIva;
|
||||
}
|
||||
|
||||
public void setPartitaIva(String partitaIva) {
|
||||
this.partitaIva = partitaIva;
|
||||
}
|
||||
|
||||
public String getCapFattura() {
|
||||
return capFattura;
|
||||
}
|
||||
|
||||
public void setCapFattura(String capFattura) {
|
||||
this.capFattura = capFattura;
|
||||
}
|
||||
|
||||
public String getIndirizzoFattura() {
|
||||
return indirizzoFattura;
|
||||
}
|
||||
|
||||
public void setIndirizzoFattura(String indirizzoFattura) {
|
||||
this.indirizzoFattura = indirizzoFattura;
|
||||
}
|
||||
|
||||
public String getCivicoFattura() {
|
||||
return civicoFattura;
|
||||
}
|
||||
|
||||
public void setCivicoFattura(String civicoFattura) {
|
||||
this.civicoFattura = civicoFattura;
|
||||
}
|
||||
|
||||
public String getCittaFattura() {
|
||||
return cittaFattura;
|
||||
}
|
||||
|
||||
public void setCittaFattura(String cittaFattura) {
|
||||
this.cittaFattura = cittaFattura;
|
||||
}
|
||||
|
||||
public String getProvinciaFattura() {
|
||||
return provinciaFattura;
|
||||
}
|
||||
|
||||
public void setProvinciaFattura(String provinciaFattura) {
|
||||
this.provinciaFattura = provinciaFattura;
|
||||
}
|
||||
|
||||
public String getNegozioScelto() {
|
||||
return negozioScelto;
|
||||
}
|
||||
|
||||
public void setNegozioScelto(String negozioScelto) {
|
||||
this.negozioScelto = negozioScelto;
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
package it.integry.ems.order.conquist.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ProdottoDTO {
|
||||
@JsonProperty("product_sku")
|
||||
private String productSku;
|
||||
|
||||
@JsonProperty("product_parent_sku")
|
||||
private String productParentSku;
|
||||
|
||||
@JsonProperty("multi_variant_title")
|
||||
private String multiVariantTitle;
|
||||
|
||||
@JsonProperty("multi_variant_fields")
|
||||
private String multiVariantFields;
|
||||
|
||||
@JsonProperty("product_name")
|
||||
private String productName;
|
||||
|
||||
@JsonProperty("colore")
|
||||
private String colore;
|
||||
|
||||
@JsonProperty("taglia")
|
||||
private String taglia;
|
||||
|
||||
@JsonProperty("product_desc")
|
||||
private String productDesc;
|
||||
|
||||
@JsonProperty("product_s_desc")
|
||||
private String productSDesc;
|
||||
|
||||
@JsonProperty("category_path")
|
||||
private String categoryPath;
|
||||
|
||||
@JsonProperty("manufacturer_name")
|
||||
private String manufacturerName;
|
||||
|
||||
@JsonProperty("published")
|
||||
private String published;
|
||||
|
||||
@JsonProperty("product_price")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@JsonProperty("product_discount_id")
|
||||
private String productDiscountId;
|
||||
|
||||
@JsonProperty("product_tax_id")
|
||||
private String productTaxId;
|
||||
|
||||
@JsonProperty("product_in_stock")
|
||||
private Integer productInStock;
|
||||
|
||||
@JsonProperty("file_url")
|
||||
private String fileUrl;
|
||||
|
||||
@JsonProperty("file_url_thumb")
|
||||
private String fileUrlThumb;
|
||||
|
||||
@JsonProperty("file_title")
|
||||
private String fileTitle;
|
||||
|
||||
@JsonProperty("file_description")
|
||||
private String fileDescription;
|
||||
|
||||
@JsonProperty("file_meta")
|
||||
private String fileMeta;
|
||||
|
||||
@JsonProperty("file_ordering")
|
||||
private String fileOrdering;
|
||||
|
||||
@JsonProperty("product_mpn")
|
||||
private String productMpn;
|
||||
|
||||
@JsonProperty("product_override_price")
|
||||
private BigDecimal productOverridePrice;
|
||||
|
||||
public String getProductSku() {
|
||||
return productSku;
|
||||
}
|
||||
|
||||
public void setProductSku(String productSku) {
|
||||
this.productSku = productSku;
|
||||
}
|
||||
|
||||
public String getProductParentSku() {
|
||||
return productParentSku;
|
||||
}
|
||||
|
||||
public void setProductParentSku(String productParentSku) {
|
||||
this.productParentSku = productParentSku;
|
||||
}
|
||||
|
||||
public String getMultiVariantTitle() {
|
||||
return multiVariantTitle;
|
||||
}
|
||||
|
||||
public void setMultiVariantTitle(String multiVariantTitle) {
|
||||
this.multiVariantTitle = multiVariantTitle;
|
||||
}
|
||||
|
||||
public String getMultiVariantFields() {
|
||||
return multiVariantFields;
|
||||
}
|
||||
|
||||
public void setMultiVariantFields(String multiVariantFields) {
|
||||
this.multiVariantFields = multiVariantFields;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getColore() {
|
||||
return colore;
|
||||
}
|
||||
|
||||
public void setColore(String colore) {
|
||||
this.colore = colore;
|
||||
}
|
||||
|
||||
public String getTaglia() {
|
||||
return taglia;
|
||||
}
|
||||
|
||||
public void setTaglia(String taglia) {
|
||||
this.taglia = taglia;
|
||||
}
|
||||
|
||||
public String getProductDesc() {
|
||||
return productDesc;
|
||||
}
|
||||
|
||||
public void setProductDesc(String productDesc) {
|
||||
this.productDesc = productDesc;
|
||||
}
|
||||
|
||||
public String getProductSDesc() {
|
||||
return productSDesc;
|
||||
}
|
||||
|
||||
public void setProductSDesc(String productSDesc) {
|
||||
this.productSDesc = productSDesc;
|
||||
}
|
||||
|
||||
public String getCategoryPath() {
|
||||
return categoryPath;
|
||||
}
|
||||
|
||||
public void setCategoryPath(String categoryPath) {
|
||||
this.categoryPath = categoryPath;
|
||||
}
|
||||
|
||||
public String getManufacturerName() {
|
||||
return manufacturerName;
|
||||
}
|
||||
|
||||
public void setManufacturerName(String manufacturerName) {
|
||||
this.manufacturerName = manufacturerName;
|
||||
}
|
||||
|
||||
public String getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(String published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
public BigDecimal getProductPrice() {
|
||||
return productPrice;
|
||||
}
|
||||
|
||||
public void setProductPrice(BigDecimal productPrice) {
|
||||
this.productPrice = productPrice;
|
||||
}
|
||||
|
||||
public String getProductDiscountId() {
|
||||
return productDiscountId;
|
||||
}
|
||||
|
||||
public void setProductDiscountId(String productDiscountId) {
|
||||
this.productDiscountId = productDiscountId;
|
||||
}
|
||||
|
||||
public String getProductTaxId() {
|
||||
return productTaxId;
|
||||
}
|
||||
|
||||
public void setProductTaxId(String productTaxId) {
|
||||
this.productTaxId = productTaxId;
|
||||
}
|
||||
|
||||
public Integer getProductInStock() {
|
||||
return productInStock;
|
||||
}
|
||||
|
||||
public void setProductInStock(Integer productInStock) {
|
||||
this.productInStock = productInStock;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
public void setFileUrl(String fileUrl) {
|
||||
this.fileUrl = fileUrl;
|
||||
}
|
||||
|
||||
public String getFileUrlThumb() {
|
||||
return fileUrlThumb;
|
||||
}
|
||||
|
||||
public void setFileUrlThumb(String fileUrlThumb) {
|
||||
this.fileUrlThumb = fileUrlThumb;
|
||||
}
|
||||
|
||||
public String getFileTitle() {
|
||||
return fileTitle;
|
||||
}
|
||||
|
||||
public void setFileTitle(String fileTitle) {
|
||||
this.fileTitle = fileTitle;
|
||||
}
|
||||
|
||||
public String getFileDescription() {
|
||||
return fileDescription;
|
||||
}
|
||||
|
||||
public void setFileDescription(String fileDescription) {
|
||||
this.fileDescription = fileDescription;
|
||||
}
|
||||
|
||||
public String getFileMeta() {
|
||||
return fileMeta;
|
||||
}
|
||||
|
||||
public void setFileMeta(String fileMeta) {
|
||||
this.fileMeta = fileMeta;
|
||||
}
|
||||
|
||||
public String getFileOrdering() {
|
||||
return fileOrdering;
|
||||
}
|
||||
|
||||
public void setFileOrdering(String fileOrdering) {
|
||||
this.fileOrdering = fileOrdering;
|
||||
}
|
||||
|
||||
public String getProductMpn() {
|
||||
return productMpn;
|
||||
}
|
||||
|
||||
public void setProductMpn(String productMpn) {
|
||||
this.productMpn = productMpn;
|
||||
}
|
||||
|
||||
public BigDecimal getProductOverridePrice() {
|
||||
return productOverridePrice;
|
||||
}
|
||||
|
||||
public void setProductOverridePrice(BigDecimal productOverridePrice) {
|
||||
this.productOverridePrice = productOverridePrice;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package it.integry.ems.order.conquist.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class TrackingDTO {
|
||||
@JsonProperty("virtuemart_order_id")
|
||||
private String virtuemartOrderId;
|
||||
|
||||
@JsonProperty("virtuemart_product_sku")
|
||||
private String virtuemartProductSku;
|
||||
|
||||
@JsonProperty("order_status")
|
||||
private String orderStatus;
|
||||
|
||||
public String getVirtuemartOrderId() {
|
||||
return virtuemartOrderId;
|
||||
}
|
||||
|
||||
public void setVirtuemartOrderId(String virtuemartOrderId) {
|
||||
this.virtuemartOrderId = virtuemartOrderId;
|
||||
}
|
||||
|
||||
public String getVirtuemartProductSku() {
|
||||
return virtuemartProductSku;
|
||||
}
|
||||
|
||||
public void setVirtuemartProductSku(String virtuemartProductSku) {
|
||||
this.virtuemartProductSku = virtuemartProductSku;
|
||||
}
|
||||
|
||||
public String getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
package it.integry.ems.order.conquist.job;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.schedule.cron_job.QuartzJobBeanWithConf;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.StbEmailRecovery;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.ws.rs.client.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URL;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class ConquistBollaProntaJob extends QuartzJobBeanWithConf {
|
||||
|
||||
private EmsProperties emsProperties;
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
private SetupGest setupGest;
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
public EmsProperties getEmsProperties() {
|
||||
return emsProperties;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setEmsProperties(EmsProperties emsProperties) {
|
||||
this.emsProperties = emsProperties;
|
||||
}
|
||||
|
||||
public ResponseJSONObjectMapper getJsonObjectMapper() {
|
||||
return jsonObjectMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setJsonObjectMapper(ResponseJSONObjectMapper jsonObjectMapper) {
|
||||
this.jsonObjectMapper = jsonObjectMapper;
|
||||
}
|
||||
|
||||
public SetupGest getSetupGest() {
|
||||
return setupGest;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSetupGest(SetupGest setupGest) {
|
||||
this.setupGest = setupGest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
String database = profileDb;
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileDb);
|
||||
|
||||
Boolean enabled = Boolean.parseBoolean(setupGest.getSetup(ds.getConnection(),
|
||||
"IMPORT_ORDINI WEB", "CONQUIST", "BOLLA_PRONTA_ENABLED"));
|
||||
|
||||
if (enabled && "/ems-api".equals(emsProperties.getRootApi())) {
|
||||
String codMdep = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "COD_MDEP");
|
||||
final String from = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "MAIL_FROM");
|
||||
final String ccn = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "MAIL_CCN");
|
||||
|
||||
String mailTemplateUrl = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "MAIL_TEMPLATE_URL");
|
||||
if (UtilityString.isNullOrEmpty(mailTemplateUrl))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/MAIL_TEMPLATE_URL non configurato correttamente");
|
||||
URL url = new URL(mailTemplateUrl + "/mail_bolla_pronta.html");
|
||||
InputStream is = url.openStream();
|
||||
final String mailText = IOUtils.toString(is);
|
||||
final String subject = "Ordine in spedizione";
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
String sql = "select vtb_fidelity_anag.e_mail from dtb_doct, dtb_ordt"
|
||||
+ " where dtb_doct.data_doc = " + UtilityDB.valueDateToString(calendar.getTime(), CommonConstants.DATE_FORMAT_YMD)
|
||||
+ " and dtb_doct.cod_mdep=" + UtilityDB.valueToString(codMdep)
|
||||
+ " and dtb_ordt.ean_fidelity = vtb_fidelity_anag.ean_fidelity and dtb_ordt.data_ord = dtb_doct.data_ord"
|
||||
+ " and dtb_ordt.gestione = dtb_doct.gestione and dtb_ordt.num_ord = dtb_doct.num_ord";
|
||||
PreparedStatement ps = ds.getConnection().prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
String email = rs.getString("e_mail");
|
||||
final String emailCliente = email;
|
||||
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", "",
|
||||
"application/json", emsProperties.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
WebTarget resource = client.target(emsProperties.getEndPointWS()).path(
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_SEND_MAIL)
|
||||
.resolveTemplate("mode", "async");
|
||||
resource = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.queryParam("from", from).queryParam("to", emailCliente)
|
||||
.queryParam("ccn", ccn)
|
||||
.queryParam("subject", subject)
|
||||
.queryParam("msgText", mailText);
|
||||
|
||||
resource.request().header("Authorization", database + ":" + auth)
|
||||
.async()
|
||||
.post(Entity.json(""), new InvocationCallback<Response>() {
|
||||
@Override
|
||||
public void completed(Response response) {
|
||||
String value = response.readEntity(String.class);
|
||||
logger.info(response.getStatus() + " - " + value);
|
||||
response.close();
|
||||
client.close();
|
||||
try {
|
||||
ServiceRestResponse respWr = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||
if (respWr.getEsito() == EsitoType.KO) {
|
||||
StbEmailRecovery emailRecovery = new StbEmailRecovery();
|
||||
emailRecovery.setOperation(OperationType.INSERT);
|
||||
emailRecovery.setFromMail(from);
|
||||
emailRecovery.setToMail(emailCliente);
|
||||
emailRecovery.setDataIns(new Date());
|
||||
emailRecovery.setSubject(subject);
|
||||
emailRecovery.setMsgtext(mailText);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
jsonObjectMapper.writeValue(writer, emailRecovery);
|
||||
|
||||
String jsonBody = writer.toString();
|
||||
|
||||
String database = profileDb;
|
||||
String auth = RestUtil.generateAuth(database, database, "POST",
|
||||
jsonBody, "application/json", emsProperties.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(emsProperties.getEndPointWS())
|
||||
.path(emsProperties.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY);
|
||||
Response responseProcess = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.request()
|
||||
.header("Authorization", database + ":" + auth)
|
||||
.post(Entity.json(jsonBody));
|
||||
|
||||
String str = responseProcess.readEntity(String.class);
|
||||
ServiceRestResponse resp = jsonObjectMapper.readValue(str, ServiceRestResponse.class);
|
||||
|
||||
responseProcess.close();
|
||||
client.close();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
logger.error(throwable);
|
||||
client.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error(ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package it.integry.ems.order.conquist.job;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.output.FileWriterWithEncoding;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
|
||||
@Deprecated
|
||||
public class ConquistExportJob extends QuartzJobBean {
|
||||
|
||||
private EmsProperties emsProperties;
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
private SetupGest setupGest;
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
public EmsProperties getEmsProperties() {
|
||||
return emsProperties;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setEmsProperties(EmsProperties emsProperties) {
|
||||
this.emsProperties = emsProperties;
|
||||
}
|
||||
|
||||
public ResponseJSONObjectMapper getJsonObjectMapper() {
|
||||
return jsonObjectMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setJsonObjectMapper(ResponseJSONObjectMapper jsonObjectMapper) {
|
||||
this.jsonObjectMapper = jsonObjectMapper;
|
||||
}
|
||||
|
||||
public SetupGest getSetupGest() {
|
||||
return setupGest;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSetupGest(SetupGest setupGest) {
|
||||
this.setupGest = setupGest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(emsProperties.getDefaultDatabase());
|
||||
|
||||
Boolean enabled = Boolean.parseBoolean(setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "ENABLED"));
|
||||
|
||||
if (enabled && "/ems-api".equals(emsProperties.getRootApi())) {
|
||||
|
||||
String folder = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(folder))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/FOLDER non configurato correttamente");
|
||||
|
||||
File f;
|
||||
String database = emsProperties.getDefaultDatabase();
|
||||
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", "",
|
||||
"text/plain", emsProperties.getRootApi() + EmsRestConstants.PATH_EXPORT_CLIENTI_CQ);
|
||||
|
||||
Client client = ClientBuilder.newClient();
|
||||
WebTarget resource = client.target(emsProperties.getEndPointWS()).path(
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_EXPORT_CLIENTI_CQ);
|
||||
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.request().header("Authorization", database + ":" + auth)
|
||||
.post(Entity.text(""));
|
||||
|
||||
String value = responseEms.readEntity(String.class);
|
||||
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||
value = null;
|
||||
if (resp.getEsito() == EsitoType.OK) {
|
||||
String b64 = resp.getXml().getFileb64Content();
|
||||
String data = new String(Base64.decodeBase64(b64));
|
||||
|
||||
f = new File(folder + "/export/" + resp.getXml().getFileName());
|
||||
|
||||
//FileWriter fw = new FileWriter(f, true);
|
||||
FileWriterWithEncoding fw = new FileWriterWithEncoding(f, "UTF-8", true);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
|
||||
bw.write(data);
|
||||
bw.close();
|
||||
fw.close();
|
||||
b64 = null;
|
||||
data = null;
|
||||
}
|
||||
responseEms.close();
|
||||
client.close();
|
||||
|
||||
auth = RestUtil.generateAuth(database, database, "POST", "",
|
||||
"text/plain", emsProperties.getRootApi() + EmsRestConstants.PATH_EXPORT_PRODOTTI_CQ);
|
||||
|
||||
client = ClientBuilder.newClient();
|
||||
resource = client.target(emsProperties.getEndPointWS()).path(
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_EXPORT_PRODOTTI_CQ);
|
||||
responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.request().header("Authorization", database + ":" + auth)
|
||||
.post(Entity.text(""));
|
||||
|
||||
value = responseEms.readEntity(String.class);
|
||||
resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||
value = null;
|
||||
if (resp.getEsito() == EsitoType.OK) {
|
||||
String b64 = resp.getXml().getFileb64Content();
|
||||
String data = new String(Base64.decodeBase64(b64));
|
||||
f = new File(folder + "/export/" + resp.getXml().getFileName());
|
||||
|
||||
FileWriterWithEncoding fw = new FileWriterWithEncoding(f, "UTF-8", true);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(data);
|
||||
bw.close();
|
||||
fw.close();
|
||||
b64 = null;
|
||||
data = null;
|
||||
}
|
||||
responseEms.close();
|
||||
client.close();
|
||||
|
||||
}
|
||||
ds.close();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
package it.integry.ems.order.conquist.job;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
//copiata in /import generica
|
||||
public class ConquistImportJob extends QuartzJobBean {
|
||||
|
||||
private EmsProperties emsProperties;
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
private SetupGest setupGest;
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
public EmsProperties getEmsProperties() {
|
||||
return emsProperties;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setEmsProperties(EmsProperties emsProperties) {
|
||||
this.emsProperties = emsProperties;
|
||||
}
|
||||
|
||||
public ResponseJSONObjectMapper getJsonObjectMapper() {
|
||||
return jsonObjectMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setJsonObjectMapper(ResponseJSONObjectMapper jsonObjectMapper) {
|
||||
this.jsonObjectMapper = jsonObjectMapper;
|
||||
}
|
||||
|
||||
public SetupGest getSetupGest() {
|
||||
return setupGest;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSetupGest(SetupGest setupGest) {
|
||||
this.setupGest = setupGest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(emsProperties.getDefaultDatabase());
|
||||
|
||||
Boolean enabled = Boolean.parseBoolean(setupGest.getSetup(ds.getConnection(),
|
||||
"IMPORT_ORDINI WEB", "CONQUIST", "ENABLED"));
|
||||
|
||||
String folder = setupGest.getSetup(ds.getConnection(), "IMPORT_ORDINI WEB",
|
||||
"CONQUIST", "FOLDER");
|
||||
|
||||
ds.close();
|
||||
|
||||
if (enabled && "/ems-api".equals(emsProperties.getRootApi())) {
|
||||
|
||||
if (UtilityString.isNullOrEmpty(folder))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/FOLDER non configurato correttamente");
|
||||
|
||||
String csv, auth;
|
||||
String database = emsProperties.getDefaultDatabase();
|
||||
|
||||
File errorDirectory = new File(folder + "/import/error");
|
||||
if (!errorDirectory.exists())
|
||||
errorDirectory.mkdir();
|
||||
|
||||
File[] files = getFileList(folder, "clienti_");
|
||||
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",
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
||||
|
||||
Client client = ClientBuilder.newClient();
|
||||
WebTarget resource = client.target(emsProperties.getEndPointWS()).path(
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIENTI_CQ);
|
||||
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.request().header("Authorization", database + ":" + auth)
|
||||
.post(Entity.text(csv));
|
||||
|
||||
String value = responseEms.readEntity(String.class);
|
||||
logger.info("CLIENTI RESPONSE: " + value);
|
||||
if (!UtilityString.isNullOrEmpty(value)) {
|
||||
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();
|
||||
|
||||
logger.error("ERRORE IMPORTAZIONE CLIENTI CQ: " + value);
|
||||
throw new Exception("Errore importazione clienti CQ");
|
||||
} else if (resp.getEsito() == EsitoType.OK) {
|
||||
File dest = new File(folder + "/import/imported/" + f.getName());
|
||||
FileOutputStream fos = new FileOutputStream(dest);
|
||||
FileInputStream is = new FileInputStream(f);
|
||||
IOUtils.copy(is, fos);
|
||||
is.close();
|
||||
fos.close();
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
responseEms.close();
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
files = getFileList(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",
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_IMPORT_ORDINI_CQ);
|
||||
|
||||
Client client = ClientBuilder.newClient();
|
||||
WebTarget resource = client.target(emsProperties.getEndPointWS()).path(
|
||||
emsProperties.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();
|
||||
|
||||
logger.error("ERRORE IMPORTAZIONE ORDINI CQ: " + value);
|
||||
throw new Exception("Errore importazione ORDINI CQ");
|
||||
} else {
|
||||
File dest = new File(folder + "/import/imported/" + f.getName());
|
||||
FileOutputStream fos = new FileOutputStream(dest);
|
||||
FileInputStream is = new FileInputStream(f);
|
||||
IOUtils.copy(is, fos);
|
||||
is.close();
|
||||
fos.close();
|
||||
f.delete();
|
||||
}
|
||||
|
||||
responseEms.close();
|
||||
client.close();
|
||||
|
||||
// cancellazione file ordini
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private File[] getFileList(String folder, final String fileNameFilter) {
|
||||
File directory = new File(folder + "/import");
|
||||
File[] files = directory.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.startsWith(fileNameFilter);
|
||||
}
|
||||
});
|
||||
|
||||
Arrays.sort(files, (f1, f2) -> {
|
||||
|
||||
String[] dataF1 = f1.getName().replace(".csv", "").split("_");
|
||||
String[] dataF2 = f2.getName().replace(".csv", "").split("_");
|
||||
|
||||
Date d1 = new Date();
|
||||
try {
|
||||
d1 = new SimpleDateFormat("yyyyMMddHHmmss").parse(dataF1[1] + dataF1[2]);
|
||||
} catch (Exception e) {
|
||||
logger.error("getFileList", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
Date d2 = new Date();
|
||||
try {
|
||||
d2 = new SimpleDateFormat("yyyyMMddHHmmss").parse(dataF2[1] + dataF2[2]);
|
||||
} catch (Exception e) {
|
||||
logger.error("getFileList", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return d1.compareTo(d2);
|
||||
});
|
||||
return files;
|
||||
}
|
||||
}
|
||||
@@ -1,913 +0,0 @@
|
||||
package it.integry.ems.order.conquist.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.file_formatter.csv.CsvMapper;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.order.conquist.dto.ClienteDTO;
|
||||
import it.integry.ems.order.conquist.dto.OrdineDTO;
|
||||
import it.integry.ems.order.conquist.dto.ProdottoDTO;
|
||||
import it.integry.ems.order.conquist.dto.TrackingDTO;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.AttachmentDTO;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.FileItem;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.AnagImportService;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.coollection.Coollection;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityBarcode;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
|
||||
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.ws.rs.client.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class ConquistEcommerceService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
@Autowired
|
||||
private EmsProperties prop;
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
@Autowired
|
||||
private ResponseJSONObjectMapper objectMapper;
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
@Autowired
|
||||
private AnagImportService anagImportService;
|
||||
|
||||
public void importClienti(String csv) throws Exception {
|
||||
Map<String, String> mapSetupGest = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "IMPORT_ORDINI WEB", "CONQUIST");
|
||||
|
||||
String defaultTipoFidelity = mapSetupGest.get("COD_FIDELITY");
|
||||
String pathFidelityTemplate = mapSetupGest.get("PATH_FIDELITY");
|
||||
|
||||
final String mailSubject = mapSetupGest.get("MAIL_SUBJECT");
|
||||
|
||||
String mailTemplateUrl = mapSetupGest.get("MAIL_TEMPLATE_URL");
|
||||
if (UtilityString.isNullOrEmpty(mailTemplateUrl))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/MAIL_TEMPLATE_URL non configurato correttamente");
|
||||
URL url = new URL(mailTemplateUrl + "/mail_model.html");
|
||||
InputStream is = url.openStream();
|
||||
String mailText = IOUtils.toString(is);
|
||||
|
||||
final String from = mapSetupGest.get("MAIL_FROM");
|
||||
|
||||
final String ccn = mapSetupGest.get("MAIL_CCN");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(defaultTipoFidelity))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/COD_FIDELITY non configurato correttamente");
|
||||
|
||||
Map<String, EntityBase> map = new HashMap<String, EntityBase>();
|
||||
|
||||
CsvMapper<ClienteDTO> mapper = new CsvMapper<ClienteDTO>();
|
||||
List<ClienteDTO> clienti = mapper.deserialize(csv, ClienteDTO.class, "\t");
|
||||
if (clienti == null)
|
||||
throw new Exception("Nessun cliente da importare");
|
||||
|
||||
Integer counter = -1;
|
||||
ArrayNode list = objectMapper.createArrayNode();
|
||||
for (ClienteDTO clienteDTO : clienti) {
|
||||
VtbFidelityAnag anagOld = new VtbFidelityAnag();
|
||||
//GENERAZIONE EAN FIDELITY ED INVIO MAIL
|
||||
String sql =
|
||||
"SELECT ean_fidelity " +
|
||||
"FROM vtb_fidelity_anag " +
|
||||
"WHERE e_mail =" + UtilityDB.valueToString(clienteDTO.getEmail()) + " AND " +
|
||||
"cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity);
|
||||
PreparedStatement psCheck = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rsCheck = psCheck.executeQuery();
|
||||
|
||||
if (rsCheck.next()) {
|
||||
clienteDTO.setCartaFidelity(rsCheck.getString(1));
|
||||
} else {
|
||||
//if(!rsCheck.next() && UtilityString.isNullOrEmpty(clienteDTO.getCartaFidelity())) {
|
||||
if (UtilityString.isNullOrEmpty(clienteDTO.getCartaFidelity())) {
|
||||
sql = "SELECT concat(max(left(ean_fidelity, 3)), max_code) last_code"
|
||||
+ " FROM vtb_fidelity_anag, (SELECT max(right(ean_fidelity, 2)) as max_code"
|
||||
+ " FROM vtb_fidelity_anag where ean_fidelity like '[0-9]%' AND "
|
||||
+ " cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity) + ") tmp"
|
||||
+ " where ean_fidelity like '[0-9]%' AND " +
|
||||
" cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity)
|
||||
+ " and right(ean_fidelity, 2) = tmp.max_code"
|
||||
+ " group by max_code";
|
||||
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
String lastCode = rs.getString("last_code");
|
||||
counter++;
|
||||
Integer val = Integer.parseInt(lastCode.substring(0, 3)) + counter;
|
||||
if (val == 999) {
|
||||
val = 0;
|
||||
String nextVal = UtilityString.getNextString(lastCode.substring(3));
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad(val.toString(), 3, '0') + nextVal);
|
||||
} else {
|
||||
val++;
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad(val.toString(), 3, '0') + lastCode.substring(3));
|
||||
}
|
||||
} else {
|
||||
//AA=27
|
||||
String nextVal = UtilityString.getNextString(27);
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad("0", 3, '0') + nextVal);
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
/*
|
||||
PDDocument pdfDoc = PDDocument.load(new File(pathFidelityTemplate + "/FIDELITY_CARD_TEMPLATE.pdf"));
|
||||
PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();
|
||||
PDAcroForm acroForm = docCatalog.getAcroForm();
|
||||
|
||||
//CAMPO IN CHIARO
|
||||
acroForm.getField("plain").setValue(clienteDTO.getCartaFidelity());
|
||||
acroForm.getField("plain").setReadOnly(true);
|
||||
//CAMPO CODIFICATO
|
||||
acroForm.getField("barcode").setValue(UtilityBarcode.encodeCode128(clienteDTO.getCartaFidelity()));
|
||||
acroForm.getField("barcode").setReadOnly(true);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
pdfDoc.save(baos);
|
||||
baos.close();
|
||||
pdfDoc.close();
|
||||
|
||||
mailText = mailText.replace("%%NUM_FIDELITY%%", clienteDTO.getCartaFidelity());
|
||||
|
||||
List<FileItem> listAttachment = new ArrayList<FileItem>();
|
||||
listAttachment.add(new FileItem("Quore fidelity card.pdf", baos.toByteArray()));
|
||||
|
||||
AttachmentDTO dto = new AttachmentDTO();
|
||||
dto.setFileByte(listAttachment);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
objectMapper.writeValue(writer, dto);
|
||||
|
||||
String jsonBody = writer.toString();
|
||||
String database = ds.getProfile();
|
||||
final String to = clienteDTO.getEmail();
|
||||
final String mailTextFinal = mailText;
|
||||
String now = new SimpleDateFormat(CommonConstants.DATETIME_FORMAT_YMD).format(new Date());
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", jsonBody,
|
||||
"application/json", prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL, now);
|
||||
|
||||
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", from).queryParam("to", to)
|
||||
.queryParam("ccn", ccn)
|
||||
.queryParam("subject", mailSubject).queryParam("msgText", mailTextFinal)
|
||||
.queryParam("isHtml", true);
|
||||
|
||||
resource.request().header("Authorization", database + ":" + auth)
|
||||
.header("SignDate", now).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();
|
||||
try {
|
||||
ServiceRestResponse respWr = objectMapper.readValue(value, ServiceRestResponse.class);
|
||||
if(respWr.getEsito()==EsitoType.KO) {
|
||||
|
||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(ds);
|
||||
|
||||
StbEmailRecovery emailRecovery = new StbEmailRecovery();
|
||||
emailRecovery.setOperation(OperationType.INSERT);
|
||||
emailRecovery.setFromMail(from);
|
||||
emailRecovery.setToMail(to);
|
||||
emailRecovery.setDataIns(new Date());
|
||||
emailRecovery.setSubject(mailSubject);
|
||||
emailRecovery.setMsgtext(mailTextFinal);
|
||||
entityProcessor.processEntity(emailRecovery, multiDBTransactionManager);
|
||||
multiDBTransactionManager.closeAll();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
logger.error(throwable);
|
||||
client.close();
|
||||
}
|
||||
}); */
|
||||
}
|
||||
rsCheck.close();
|
||||
psCheck.close();
|
||||
|
||||
anagOld.setCodFidelity(defaultTipoFidelity);
|
||||
anagOld.setEanFidelity(clienteDTO.getCartaFidelity());
|
||||
anagOld.setOperation(OperationType.SELECT_OBJECT);
|
||||
anagOld = (VtbFidelityAnag) entityProcessor.processEntity(anagOld, multiDBTransactionManager);
|
||||
|
||||
VtbFidelityAnag fidelityAnag = new VtbFidelityAnag();
|
||||
fidelityAnag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
fidelityAnag.setNome(clienteDTO.getFirstName());
|
||||
fidelityAnag.setCognome(clienteDTO.getLastName());
|
||||
fidelityAnag.setUserName(clienteDTO.getUsername());
|
||||
fidelityAnag.setNominativo(clienteDTO.getFirstName() + " " + clienteDTO.getLastName());
|
||||
|
||||
fidelityAnag.setIndirizzo(clienteDTO.getAddress1());
|
||||
fidelityAnag.setCap(clienteDTO.getZip());
|
||||
fidelityAnag.setCitta(clienteDTO.getCity());
|
||||
fidelityAnag.setTelefono(clienteDTO.getPhone1());
|
||||
fidelityAnag.seteMail(clienteDTO.getEmail());
|
||||
fidelityAnag.setEanFidelity(clienteDTO.getCartaFidelity());
|
||||
fidelityAnag.setCodFidelity(defaultTipoFidelity);
|
||||
|
||||
fidelityAnag.setSesso(clienteDTO.getSesso());
|
||||
if (!UtilityString.isNullOrEmpty(clienteDTO.getDatanascita()) && !"0000-00-00".equals(clienteDTO.getDatanascita()))
|
||||
fidelityAnag.setDataNascita(UtilityString.parseDate(clienteDTO.getDatanascita()));
|
||||
fidelityAnag.setDataMod(new Date());
|
||||
if (anagOld != null) {
|
||||
//cambiati dati fondamentali, i dati verranno salvati su tabella di log
|
||||
if (!(anagOld.geteMail() != null && anagOld.geteMail().equals(clienteDTO.getEmail())) ||
|
||||
!(anagOld.getTelefono() != null && anagOld.getTelefono().equals(clienteDTO.getPhone1()))) {
|
||||
map.put(anagOld.getEanFidelity(), anagOld);
|
||||
}
|
||||
}
|
||||
list.addPOJO(fidelityAnag);
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
StringWriter writer = new StringWriter();
|
||||
objectMapper.writeValue(writer, list);
|
||||
|
||||
String database = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
String jsonBody = writer.toString();
|
||||
|
||||
String auth = RestUtil.generateAuth(database, database, "POST",
|
||||
jsonBody, "application/json", prop.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY_LIST);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(prop.getEndPointWS())
|
||||
.path(prop.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY_LIST);
|
||||
Response response = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.request()
|
||||
.header("Authorization", database + ":" + auth)
|
||||
.post(Entity.json(jsonBody));
|
||||
|
||||
DataSource dsConquist = new DataSource();
|
||||
dsConquist.initialize("MAFRAT2CONQUIST");
|
||||
String str = response.readEntity(String.class);
|
||||
response.close();
|
||||
client.close();
|
||||
|
||||
ServiceRestResponse[] respList = objectMapper.readValue(str, ServiceRestResponse[].class);
|
||||
for (ServiceRestResponse serviceRestResponse : respList) {
|
||||
if (serviceRestResponse.getEsito() == EsitoType.OK) {
|
||||
if (serviceRestResponse.getEntity() != null) {
|
||||
VtbFidelityAnag entity = (VtbFidelityAnag) serviceRestResponse.getEntity();
|
||||
if (entity != null && map.get(entity.getEanFidelity()) != null) {
|
||||
VtbFidelityAnag anagOld = (VtbFidelityAnag) map.get(entity.getEanFidelity());
|
||||
String insert = "INSERT INTO vtb_fidelity_anag_log"
|
||||
+ " (ean_fidelity, data_variaz, cod_fidelity, nominativo, indirizzo, cap, citta, prov, telefono, e_mail, cod_mdep, data_ins, data_mod)"
|
||||
+ " VALUES (" + UtilityDB.valueToString(anagOld.getEanFidelity()) + ", "
|
||||
+ " GetDate(), "
|
||||
+ UtilityDB.valueToString(anagOld.getCodFidelity()) + "," + UtilityDB.valueToString(anagOld.getNominativo()) + "," + UtilityDB.valueToString(anagOld.getIndirizzo()) + ", "
|
||||
+ UtilityDB.valueToString(anagOld.getCap()) + ", " + UtilityDB.valueToString(anagOld.getCitta()) + ", " + UtilityDB.valueToString(anagOld.getProv()) + ", "
|
||||
+ UtilityDB.valueToString(anagOld.getTelefono()) + ", " + UtilityDB.valueToString(anagOld.geteMail()) + ", " + UtilityDB.valueToString(anagOld.getCodMdep()) + ", "
|
||||
+ UtilityDB.valueDateToString(new Date(), "yyyy-MM-dd HH:mm:ss.SSS") + ", " + UtilityDB.valueDateToString(new Date(), CommonConstants.DATETIME_FORMAT_YMD) + ")";
|
||||
|
||||
PreparedStatement ps = dsConquist.getConnection().prepareStatement(insert);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception(serviceRestResponse.getErrorMessage());
|
||||
}
|
||||
}
|
||||
dsConquist.getConnection().commit();
|
||||
dsConquist.close();
|
||||
|
||||
String sql = "SELECT ean_fidelity, e_mail " +
|
||||
"FROM vtb_fidelity_anag " +
|
||||
"WHERE cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity) + " AND " +
|
||||
"Convert(varchar(10), data_ins, 121) = Convert(varchar(10), getDate(), 121)";
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String eanFildelity = rs.getString(1);
|
||||
final String to = rs.getString(2);
|
||||
PDDocument pdfDoc = PDDocument.load(new File(pathFidelityTemplate + "/FIDELITY_CARD_TEMPLATE.pdf"));
|
||||
PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();
|
||||
PDAcroForm acroForm = docCatalog.getAcroForm();
|
||||
|
||||
//CAMPO IN CHIARO
|
||||
acroForm.getField("plain").setValue(eanFildelity);
|
||||
acroForm.getField("plain").setReadOnly(true);
|
||||
//CAMPO CODIFICATO
|
||||
acroForm.getField("barcode").setValue(UtilityBarcode.encodeCode128(eanFildelity));
|
||||
acroForm.getField("barcode").setReadOnly(true);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
pdfDoc.save(baos);
|
||||
baos.close();
|
||||
pdfDoc.close();
|
||||
|
||||
mailText = mailText.replace("%%NUM_FIDELITY%%", eanFildelity);
|
||||
|
||||
List<FileItem> listAttachment = new ArrayList<FileItem>();
|
||||
listAttachment.add(new FileItem("Quore fidelity card.pdf", baos.toByteArray()));
|
||||
|
||||
AttachmentDTO dto = new AttachmentDTO();
|
||||
dto.setFileByte(listAttachment);
|
||||
writer = new StringWriter();
|
||||
objectMapper.writeValue(writer, dto);
|
||||
|
||||
jsonBody = writer.toString();
|
||||
database = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
final String mailTextFinal = mailText;
|
||||
auth = RestUtil.generateAuth(database, database, "POST", jsonBody,
|
||||
"application/json", prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
||||
|
||||
final Client clientEmail = ClientBuilder.newClient();
|
||||
WebTarget resourceEmail = clientEmail.target(prop.getEndPointWS()).path(
|
||||
prop.getRootApi() + EmsRestConstants.PATH_SEND_MAIL)
|
||||
.resolveTemplate("mode", "async");
|
||||
resourceEmail = resourceEmail.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.queryParam("from", from).queryParam("to", to)
|
||||
.queryParam("ccn", ccn)
|
||||
.queryParam("subject", mailSubject).queryParam("msgText", mailTextFinal)
|
||||
.queryParam("isHtml", true);
|
||||
|
||||
resourceEmail.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();
|
||||
try {
|
||||
ServiceRestResponse respWr = objectMapper.readValue(value, ServiceRestResponse.class);
|
||||
if (respWr.getEsito() == EsitoType.KO) {
|
||||
|
||||
StbEmailRecovery emailRecovery = new StbEmailRecovery();
|
||||
emailRecovery.setOperation(OperationType.INSERT);
|
||||
emailRecovery.setFromMail(from);
|
||||
emailRecovery.setToMail(to);
|
||||
emailRecovery.setDataIns(new Date());
|
||||
emailRecovery.setSubject(mailSubject);
|
||||
emailRecovery.setMsgtext(mailTextFinal);
|
||||
entityProcessor.processEntity(emailRecovery, multiDBTransactionManager);
|
||||
multiDBTransactionManager.close();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
logger.error(throwable);
|
||||
client.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Già esportato. Vedi modulo ems-system.
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
public FileItem exportClienti() throws Exception {
|
||||
String header = "name\tusername\temail\tpassword\tfirst_name\tlast_name\taddress_1\tzip\tcity\tphone_1\tcarta_fidelity\tusergroup_name\taddress_type\taddress_type_name\tsesso\tdatanascita\tcivico";
|
||||
String sql = "SELECT nome + ' ' + cognome as name, user_name as username, ean_fidelity as carta_fidelity, e_mail as email, nome as first_name, cognome as last_name, indirizzo as address_1,"
|
||||
+ " cap as zip, citta as city, telefono as phone_1, "
|
||||
+ " 'Registered' as usergroup_name, 'Billing address' as address_type, "
|
||||
+ " sesso, convert(varchar(10),data_nascita,120) as datanascita, '' as civico"
|
||||
+ " FROM vtb_fidelity_anag where user_name is not null";
|
||||
|
||||
List<ClienteDTO> clienti = new ResultSetMapper()
|
||||
.mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, ClienteDTO.class);
|
||||
|
||||
String folder = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||
File f = new File(folder + "/export/clienti.csv");
|
||||
Boolean hasHeader = true;
|
||||
if (f.exists())
|
||||
hasHeader = false;
|
||||
|
||||
CsvMapper<ClienteDTO> mapper = new CsvMapper<ClienteDTO>();
|
||||
String csv = mapper.serialize(clienti, "\t", header, hasHeader);
|
||||
FileItem item = new FileItem("clienti.csv", csv.getBytes(), "csv");
|
||||
|
||||
// String upd = "UPDATE vtb_fidelity_anag set inviato='S' where nominativo <> 'NUOVO CLIENTE FIDELIZZATO' and inviato = 'N'";
|
||||
// PreparedStatement ps = multiDBTransactionManager.prepareStatement(upd);
|
||||
// ps.executeUpdate();
|
||||
// ps.close();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Già esportato. Vedi modulo ems-product
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Deprecated
|
||||
public FileItem exportProdotti() throws Exception {
|
||||
|
||||
String header = "product_sku\tproduct_parent_sku\tmulti_variant_title\tmulti_variant_fields\tproduct_name\tcolore\ttaglia\tproduct_desc\tproduct_s_desc\tcategory_path\t"
|
||||
+ "manufacturer_name\tpublished\tproduct_price\tproduct_discount_id\tproduct_tax_id\tproduct_in_stock\tfile_url\tfile_url_thumb\tfile_title\tfile_description\t"
|
||||
+ "file_meta\tfile_ordering\tproduct_mpn\tproduct_override_price";
|
||||
|
||||
String sql = "SELECT cod_style, product_sku, product_parent_sku, multi_variant_title,"
|
||||
+ "multi_variant_fields, product_name, colore, taglia, product_desc, product_s_desc,"
|
||||
+ "category_path, manufacturer_name, published, product_price, product_discount_id,"
|
||||
+ "product_tax_id, product_in_stock, file_ordering, product_mpn, file_url,"
|
||||
+ "file_url_thumb, file_title, file_meta, product_override_price "
|
||||
+ "FROM Mafrat2Conquist.dbo.IMPORT_PRODOTTI "
|
||||
+ "order by cod_style, isnull(CASE WHEN product_sku = product_parent_sku then Null else product_parent_sku end, '')";
|
||||
|
||||
List<ProdottoDTO> prodotti = new ResultSetMapper()
|
||||
.mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), sql, ProdottoDTO.class);
|
||||
|
||||
String folder = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||
File f = new File(folder + "/export/prodotti.csv");
|
||||
Boolean hasHeader = true;
|
||||
if (f.exists())
|
||||
hasHeader = false;
|
||||
|
||||
CsvMapper<ProdottoDTO> mapper = new CsvMapper<ProdottoDTO>();
|
||||
String csv = mapper.serialize(prodotti, "\t", header, hasHeader);
|
||||
FileItem item = new FileItem("prodotti.csv", csv.getBytes(), "csv");
|
||||
return item;
|
||||
}
|
||||
|
||||
public FileItem exportTracking(List<TrackingDTO> trackingList) throws Exception {
|
||||
|
||||
String header = "virtuemart_order_id\tvirtuemart_product_sku\torder_status";
|
||||
|
||||
String folder = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "IMPORT_ORDINI WEB", "CONQUIST", "FOLDER");
|
||||
File f = new File(folder + "/export/tracking.csv");
|
||||
Boolean hasHeader = true;
|
||||
if (f.exists())
|
||||
hasHeader = false;
|
||||
|
||||
CsvMapper<TrackingDTO> mapper = new CsvMapper<TrackingDTO>();
|
||||
String csv = mapper.serialize(trackingList, "\t", header, hasHeader);
|
||||
FileItem item = new FileItem("tracking.csv", csv.getBytes(), "csv");
|
||||
return item;
|
||||
}
|
||||
|
||||
public List<ServiceRestResponse> importOrdini(String csv) throws Exception {
|
||||
CsvMapper<OrdineDTO> mapper = new CsvMapper<OrdineDTO>();
|
||||
List<OrdineDTO> ordini = mapper.deserialize(csv, OrdineDTO.class, "\t");
|
||||
if (ordini == null)
|
||||
throw new Exception("Nessun ordine da importare");
|
||||
|
||||
|
||||
List<EntityBase> list = new ArrayList<EntityBase>();
|
||||
Map<String, String> mapCurrency = new HashMap<String, String>();
|
||||
|
||||
Date dataOrdOld = new Date();
|
||||
Integer numOrdOld = 0;
|
||||
Integer productId = 0;
|
||||
WdtbOrdt ordineWeb = null;
|
||||
GtbAnag anag = null;
|
||||
|
||||
Map<String, String> mapSetupGest = setupGest.getSetupSection(multiDBTransactionManager.getPrimaryConnection(), "IMPORT_ORDINI WEB", "CONQUIST");
|
||||
|
||||
String codMdep = mapSetupGest.get("COD_MDEP");
|
||||
// String codPaga = mapSetupGest.get("COD_PAGA");
|
||||
String codPagaContr = mapSetupGest.get("COD_PAGA_CONTR");
|
||||
String codVage = mapSetupGest.get("COD_VAGE");
|
||||
String serie = mapSetupGest.get("SERIE");
|
||||
String defaultCodAnag = mapSetupGest.get("COD_ANAG");
|
||||
final String from = mapSetupGest.get("MAIL_FROM");
|
||||
|
||||
String mailTemplateUrl = mapSetupGest.get("MAIL_TEMPLATE_URL");
|
||||
if (UtilityString.isNullOrEmpty(mailTemplateUrl))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/MAIL_TEMPLATE_URL non configurato correttamente");
|
||||
URL url = new URL(mailTemplateUrl + "/mail_presa_ordine.html");
|
||||
InputStream is = url.openStream();
|
||||
String mailText = IOUtils.toString(is);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codMdep))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/COD_MDEP non configurato correttamente");
|
||||
|
||||
// if(UtilityString.isNullOrEmpty(codPaga))
|
||||
// throw new Exception("IMPORT_ORDINI WEB/CONQUIST/COD_PAGA non configurato correttamente");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(serie))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/SERIE non configurato correttamente");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(defaultCodAnag))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/COD_ANAG non configurato correttamente");
|
||||
|
||||
final String ccn = mapSetupGest.get("MAIL_CCN");
|
||||
|
||||
String negozioScelto = "", email = "";
|
||||
Boolean rigaDestPresente = false;
|
||||
|
||||
ordini = Coollection.from(ordini).orderBy("orderNumber").all();
|
||||
Boolean existOrd = false;
|
||||
|
||||
for (int i = 0; i < ordini.size(); i++) {
|
||||
|
||||
OrdineDTO ordine = ordini.get(i);
|
||||
|
||||
if (dataOrdOld != null && ordine.getCreatedOn() != null & dataOrdOld.compareTo(ordine.getCreatedOn()) != 0 &&
|
||||
!numOrdOld.equals(ordine.getVirtuemartOrderId())) {
|
||||
Date d = new Date();
|
||||
negozioScelto = "";
|
||||
rigaDestPresente = false;
|
||||
email = "";
|
||||
|
||||
//controllo esistenza ordine
|
||||
String sql =
|
||||
"SELECT count(*) " +
|
||||
" FROM wdtb_ordt " +
|
||||
" WHERE wdtb_ordt.rif_ord = " + UtilityDB.valueToString(ordine.getOrderNumber()) + " AND " +
|
||||
"wdtb_ordt.num_ord_rif = " + UtilityDB.valueToString(ordine.getVirtuemartOrderId()) + " AND " +
|
||||
"wdtb_ordt.data_ord_rif = " + UtilityDB.valueDateToString(ordine.getCreatedOn(), CommonConstants.DATE_FORMAT_YMD);
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
existOrd = false;
|
||||
if (rs.next()) {
|
||||
existOrd = rs.getInt(1) > 0;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
if (!existOrd) {
|
||||
ordineWeb = new WdtbOrdt();
|
||||
ordineWeb.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
ordineWeb.setWdtbOrdr(new ArrayList<WdtbOrdr>());
|
||||
ordineWeb.setGestione("V");
|
||||
ordineWeb.setCodVage(codVage);
|
||||
|
||||
if (mapCurrency.get(ordine.getUserCurrency()) == null) {
|
||||
sql = "SELECT cod_divi FROM gtb_divi "
|
||||
+ "where cod_divi_iso = " + UtilityDB.valueToString(ordine.getUserCurrency());
|
||||
ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
mapCurrency.put(ordine.getUserCurrency(), rs.getString("cod_divi"));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
ordineWeb.setCodDivi(mapCurrency.get(ordine.getUserCurrency()));
|
||||
ordineWeb.setCodMdep(codMdep);
|
||||
|
||||
ordineWeb.setDataOrd(d);
|
||||
ordineWeb.setRifOrd(ordine.getOrderNumber());
|
||||
ordineWeb.setDataOrdRif(ordine.getCreatedOn());
|
||||
ordineWeb.setNumOrdRif(ordine.getVirtuemartOrderId());
|
||||
ordineWeb.setSerie(serie);
|
||||
ordineWeb.setDataInsOrd(d);
|
||||
ordineWeb.setCompilatoDa("IMPORT_CONQUIST");
|
||||
ordineWeb.setNote(ordine.getCustomerNote());
|
||||
if (ordine.getOrderPayment().compareTo(BigDecimal.ZERO) > 0) {
|
||||
ordineWeb.setCodPaga(codPagaContr);
|
||||
}
|
||||
|
||||
list.add(ordineWeb);
|
||||
|
||||
dataOrdOld = ordine.getCreatedOn();
|
||||
numOrdOld = ordine.getVirtuemartOrderId();
|
||||
//annullamento del product ID
|
||||
productId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!existOrd) {
|
||||
if (rigaDestPresente && UtilityString.isNullOrEmpty(negozioScelto)) {
|
||||
createOrGetDestMerce(ordineWeb, ordine, negozioScelto, email, defaultCodAnag, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
if (dataOrdOld.compareTo(ordine.getCreatedOn()) == 0 && numOrdOld.equals(ordine.getVirtuemartOrderId()) &&
|
||||
!productId.equals(ordine.getVirtuemartProductId())) {
|
||||
|
||||
dataOrdOld = ordine.getCreatedOn();
|
||||
numOrdOld = ordine.getVirtuemartOrderId();
|
||||
productId = ordine.getVirtuemartProductId();
|
||||
negozioScelto = ordine.getNegozioScelto();
|
||||
email = ordine.getEmail();
|
||||
|
||||
WdtbOrdr row = new WdtbOrdr();
|
||||
row.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
ordineWeb.getWdtbOrdr().add(row);
|
||||
|
||||
String sql = "select ttb_bar_code.cod_style, ttb_bar_code.cod_col, "
|
||||
+ " ttb_bar_code.cod_tagl, mtb_aart.descrizione, mtb_aart.cod_aliq, aliq.perc_aliq"
|
||||
+ " from mtb_aart, ttb_bar_code, gtb_aliq aliq"
|
||||
+ " where cod_barre = " + UtilityDB.valueToString(ordine.getOrderItemSku())
|
||||
+ " and mtb_aart.cod_mart = ttb_bar_code.cod_style and mtb_aart.cod_aliq = aliq.cod_aliq";
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
row.setCodMart(rs.getString("cod_style"));
|
||||
row.setCodCol(rs.getString("cod_col"));
|
||||
row.setCodTagl(rs.getString("cod_tagl"));
|
||||
row.setDescrizione(rs.getString("descrizione"));
|
||||
row.setCodAliq(rs.getString("cod_aliq"));
|
||||
row.setPercAliq(rs.getBigDecimal("perc_aliq"));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
row.setQtaOrd(BigDecimal.valueOf(ordine.getProductQuantity()));
|
||||
row.setValUnt(ordine.getProductFinalPrice().subtract(ordine.getProductTax()).
|
||||
setScale(EmsRestConstants.cifreDecMax, BigDecimal.ROUND_HALF_UP));
|
||||
|
||||
if (i + 1 < ordini.size() && productId.equals(ordini.get(i + 1).getVirtuemartProductId())) {
|
||||
rigaDestPresente = true;
|
||||
}
|
||||
|
||||
if ("1".equals(ordine.getRichiestaFattura())) {
|
||||
anag = new GtbAnag();
|
||||
if (!UtilityString.isNullOrEmpty(ordine.getEmail())) {
|
||||
anag.seteMail(ordine.getEmail());
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(ordine.getPartitaIva()))
|
||||
anag.setPartIva(ordine.getPartitaIva());
|
||||
if (!UtilityString.isNullOrEmpty(ordine.getCodiceFiscale()))
|
||||
anag.setCodFisc(ordine.getCodiceFiscale());
|
||||
}
|
||||
|
||||
List<EntityBase> listCheckAnag = checkClieDestExists(multiDBTransactionManager.getPrimaryConnection().getProfileName(), anag);
|
||||
if (!listCheckAnag.isEmpty()) {
|
||||
EntityBase entity = listCheckAnag.get(0);
|
||||
if (entity instanceof GtbAnag) {
|
||||
GtbAnag anagFinded = ((GtbAnag) entity);
|
||||
ordineWeb.setCodAnag(anagFinded.getCodAnag());
|
||||
}
|
||||
} else {
|
||||
anag.setRagSoc(ordine.getFullName());
|
||||
anag.setIndirizzo(ordine.getIndirizzoFattura() + " " + ordine.getCivicoFattura());
|
||||
anag.setCap(ordine.getCapFattura());
|
||||
anag.setCitta(ordine.getCittaFattura());
|
||||
anag.setProv(ordine.getProvinciaFattura());
|
||||
anag.setOperation(OperationType.INSERT);
|
||||
anag.setPrecode("Q");
|
||||
VtbClie clie = new VtbClie();
|
||||
clie.setOperation(OperationType.INSERT);
|
||||
clie.setGtbAnag(anag);
|
||||
|
||||
entityProcessor.processEntity(clie, multiDBTransactionManager);
|
||||
ordineWeb.setCodAnag(clie.getCodAnag());
|
||||
}
|
||||
if (!rigaDestPresente) {
|
||||
// aggancio destinazione
|
||||
createOrGetDestMerce(ordineWeb, ordine, negozioScelto, email, defaultCodAnag, multiDBTransactionManager);
|
||||
}
|
||||
} else {
|
||||
ordineWeb.setCodAnag(defaultCodAnag);
|
||||
if (!rigaDestPresente) {
|
||||
createOrGetDestMerce(ordineWeb, ordine, negozioScelto, email, defaultCodAnag, multiDBTransactionManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
list = entityProcessor.processEntityList(list, true);
|
||||
|
||||
for (EntityBase entityBase : list) {
|
||||
if (entityBase.getException() == null) {
|
||||
|
||||
WdtbOrdt ordT = (WdtbOrdt) entityBase;
|
||||
String sql;
|
||||
if (ordT.getCodAnag().equals(defaultCodAnag)) {
|
||||
sql = "select e_mail from vtb_dest where cod_vdes = " + UtilityDB.valueToString(ordT.getCodVdes())
|
||||
+ " and cod_anag = " + UtilityDB.valueToString(ordT.getCodAnag());
|
||||
} else {
|
||||
sql = "select e_mail from gtb_anag where cod_anag = " + UtilityDB.valueToString(ordT.getCodAnag());
|
||||
}
|
||||
|
||||
mailText = mailText.replace("%%NUM_ORD_CQ%%", ordT.getNumOrdRif().toString());
|
||||
final String mailTextFinal = mailText;
|
||||
|
||||
PreparedStatement ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
final String emailCliente = rs.getString("e_mail");
|
||||
final String subj = "Quore - Conferma d'ordine";
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(emailCliente)) {
|
||||
String database = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", "",
|
||||
"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", from).queryParam("to", emailCliente)
|
||||
.queryParam("ccn", ccn)
|
||||
.queryParam("subject", subj)
|
||||
.queryParam("msgText", mailTextFinal)
|
||||
.queryParam("isHtml", true);
|
||||
|
||||
resource.request().header("Authorization", database + ":" + auth)
|
||||
.async()
|
||||
.post(Entity.json(""), new InvocationCallback<Response>() {
|
||||
@Override
|
||||
public void completed(Response response) {
|
||||
String value = response.readEntity(String.class);
|
||||
logger.info(response.getStatus() + " - " + value);
|
||||
response.close();
|
||||
client.close();
|
||||
try {
|
||||
ServiceRestResponse respWr = objectMapper.readValue(value, ServiceRestResponse.class);
|
||||
if (respWr.getEsito() == EsitoType.KO) {
|
||||
|
||||
StbEmailRecovery emailRecovery = new StbEmailRecovery();
|
||||
emailRecovery.setOperation(OperationType.INSERT);
|
||||
emailRecovery.setFromMail(from);
|
||||
emailRecovery.setToMail(emailCliente);
|
||||
emailRecovery.setDataIns(new Date());
|
||||
emailRecovery.setSubject(subj);
|
||||
emailRecovery.setMsgtext(mailTextFinal);
|
||||
entityProcessor.processEntity(emailRecovery, multiDBTransactionManager);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
logger.error(throwable);
|
||||
client.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return UtilityEntity.toServiceRestResponse(list);
|
||||
}
|
||||
|
||||
private void createOrGetDestMerce(WdtbOrdt ordineWeb, OrdineDTO ordine,
|
||||
String negozioScelto, String email, String defaultCodAnag,
|
||||
MultiDBTransactionManager multiDBTransactionManager)
|
||||
throws Exception {
|
||||
String sql;
|
||||
PreparedStatement ps;
|
||||
ResultSet rs;
|
||||
|
||||
if (UtilityString.isNullOrEmpty(negozioScelto)) {
|
||||
//destinarario fisico
|
||||
List<VtbDest> listDest = new ArrayList<VtbDest>();
|
||||
GtbAnag anagSearch = new GtbAnag();
|
||||
anagSearch.setCodAnag(ordineWeb.getCodAnag());
|
||||
VtbDest dest = new VtbDest();
|
||||
dest.setDestinatario(ordine.getFullName());
|
||||
dest.setIndirizzo(ordine.getAddress1() + " " + ordine.getCivico());
|
||||
dest.setCitta(ordine.getCity());
|
||||
dest.setCap(ordine.getZip());
|
||||
dest.setOperation(OperationType.INSERT);
|
||||
|
||||
listDest.add(dest);
|
||||
anagSearch.setVtbDest(listDest);
|
||||
List<EntityBase> listCheckAnag = checkClieDestExists(multiDBTransactionManager.getPrimaryConnection().getProfileName(), anagSearch);
|
||||
if (!listCheckAnag.isEmpty()) {
|
||||
EntityBase entity = listCheckAnag.get(0);
|
||||
if (entity instanceof VtbDest) {
|
||||
VtbDest destFinded = ((VtbDest) entity);
|
||||
destFinded.seteMail(email);
|
||||
destFinded.setTel(ordine.getPhone1());
|
||||
destFinded.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(destFinded, multiDBTransactionManager);
|
||||
|
||||
ordineWeb.setCodVdes(destFinded.getCodVdes());
|
||||
}
|
||||
}
|
||||
//gestire eccezione anagrafica non presente
|
||||
} else {
|
||||
//ritiro da negozio
|
||||
sql = "select * from vtb_dest where cod_affiliazione = " + UtilityDB.valueToString(negozioScelto)
|
||||
+ " and cod_anag = " + UtilityDB.valueToString(defaultCodAnag);
|
||||
/*
|
||||
VtbDest dest = new VtbDest();
|
||||
dest.setNativeSql(sql);
|
||||
dest.setOperation(OperationType.SELECT);
|
||||
|
||||
EntityBase[] entityList = (EntityBase[]) entityProcessor.processEntity(dest, multiDBTransactionManager);
|
||||
*/
|
||||
ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
|
||||
List<VtbDest> listVtbDest = new ResultSetMapper()
|
||||
.mapResultSetToList(rs, VtbDest.class, OperationType.SELECT_OBJECT);
|
||||
|
||||
if (listVtbDest != null && !listVtbDest.isEmpty()) {
|
||||
VtbDest dest = listVtbDest.get(0);
|
||||
|
||||
//se il destinatario è un negozio, ma il cliente richiede fattura, copio il destinarario nel cliente anagrafato
|
||||
if (!dest.getCodAnag().equals(ordineWeb.getCodAnag())) {
|
||||
dest.setCodAnag(ordineWeb.getCodAnag());
|
||||
dest.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(dest, multiDBTransactionManager);
|
||||
}
|
||||
ordineWeb.setCodVdes(dest.getCodVdes());
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
sql = "select ean_fidelity from vtb_fidelity_anag "
|
||||
+ "where e_mail = " + UtilityDB.valueToString(email);
|
||||
ps = multiDBTransactionManager.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
ordineWeb.setEanFidelity(rs.getString("ean_fidelity"));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
private List<EntityBase> checkClieDestExists(String database, GtbAnag gtbAnag) throws Exception {
|
||||
|
||||
return anagImportService.importClieAnagInternal(gtbAnag, "Q");
|
||||
/*
|
||||
// put the resultset in a containing structure
|
||||
StringWriter writer = new StringWriter();
|
||||
objectMapper.writeValue(writer, gtbAnag);
|
||||
|
||||
String jsonBody = writer.toString();
|
||||
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", jsonBody, "application/json",
|
||||
prop.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIE_ANAG);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(prop.getEndPointWS()).path(
|
||||
prop.getRootApi() + EmsRestConstants.PATH_IMPORT_CLIE_ANAG);
|
||||
Response response = resource.queryParam(CommonConstants.PROFILE_DB, database)
|
||||
.queryParam("precode", "Q").request()
|
||||
.header("Authorization", database + ":" + auth)
|
||||
.post(Entity.json(jsonBody));
|
||||
|
||||
String entityStr = response.readEntity(String.class);
|
||||
logger.info(entityStr);
|
||||
ServiceRestResponse value = objectMapper.readValue(entityStr, ServiceRestResponse.class);
|
||||
|
||||
response.close();
|
||||
client.close();
|
||||
|
||||
return value;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.order.service;
|
||||
import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.order.dto.*;
|
||||
import it.integry.ems.order.dto.ordikids.request.OrdiKids;
|
||||
@@ -24,7 +23,6 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.service.AnagImportService;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||
@@ -32,25 +30,17 @@ import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.types.TypeDbObject;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@@ -1263,164 +1253,6 @@ public class OrderImportService {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<ServiceRestResponse> importOrdiniFromSilviaHeach() throws Exception {
|
||||
|
||||
String profileDBAppoggio = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"IMPORT_ORDINI_WEB", "SILVIAN_HEACH", "PROFILE_DB_SCAMBIO");
|
||||
|
||||
String codMdep = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"IMPORT_ORDINI_WEB", "SILVIAN_HEACH", "COD_MDEP");
|
||||
if (UtilityString.isNullOrEmpty(codMdep))
|
||||
codMdep = "";
|
||||
|
||||
List<ServiceRestResponse> list = new ArrayList<ServiceRestResponse>();
|
||||
|
||||
DataSource dsScambio = new DataSource();
|
||||
dsScambio.initialize(profileDBAppoggio);
|
||||
Connection connScambio = dsScambio.getConnection();
|
||||
//intercode nelle note poichè serve successivamente a prendere il cliente
|
||||
String sql = "SELECT CONVERT(varchar(50), intecode_dest) as note, cod_anag_mafrat as cod_anag,"
|
||||
+ " cod_vdes_mafrat as cod_vdes,"
|
||||
+ " serie, T.num_ord, T.data_ord, cod_divi,"
|
||||
+ " cambio, sconto1, sconto2, sconto3,"
|
||||
+ " sconto4, cod_paga, cod_vage_mafrat as cod_vage, " + UtilityDB.valueToString(codMdep) + " as cod_mdep,"
|
||||
+ " CONVERT(datetime, CONVERT(varchar(8), data_ord_orig), 112) as data_ord_rif,"
|
||||
+ " convert(int, num_ord_orig) as num_ord_rif"
|
||||
+ " FROM GetTestataOrdini() AS T left outer join ord_imported"
|
||||
+ " on T.data_ord_orig = ord_imported.data_ord AND T.num_ord_orig = ord_imported.num_ord"
|
||||
+ " where ord_imported.data_import is null";
|
||||
|
||||
PreparedStatement ps = connScambio.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
List<WdtbOrdt> ordini = new ResultSetMapper()
|
||||
.mapResultSetToList(rs, WdtbOrdt.class);
|
||||
ps.close();
|
||||
|
||||
if (ordini == null)
|
||||
throw new Exception("[SH] Non ci sono ordini da importare");
|
||||
|
||||
String errorMsg = "";
|
||||
|
||||
for (WdtbOrdt wdtbOrdt : ordini) {
|
||||
//ordine vendita
|
||||
wdtbOrdt.setGestione("V");
|
||||
wdtbOrdt.setOperation(OperationType.INSERT);
|
||||
|
||||
if (wdtbOrdt.getCodAnag() == null && wdtbOrdt.getCodVdes() == null) {
|
||||
//WdtbNewCliOrd
|
||||
WdtbNewCliOrd wdtbNewCliOrd = addSilviaHeachClie(connScambio, wdtbOrdt.getNote());
|
||||
if (wdtbNewCliOrd == null) {
|
||||
errorMsg += wdtbOrdt.getDataOrd() + " " + wdtbOrdt.getNumOrd() + " NON IMPORTATO, CLIENTE NON TROVATO PER INTERCODE: " + wdtbOrdt.getNote();
|
||||
logger.info(wdtbOrdt.getNumOrd() + " NON IMPORTATO, CLIENTE NON TROVATO PER INTERCODE: " + wdtbOrdt.getNote());
|
||||
continue;
|
||||
}
|
||||
|
||||
wdtbNewCliOrd.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
wdtbOrdt.setWdtbNewCliOrd(wdtbNewCliOrd);
|
||||
wdtbOrdt.setCodAnag(wdtbNewCliOrd.getCodAnag());
|
||||
wdtbOrdt.setCodVdes(wdtbNewCliOrd.getCodVdes());
|
||||
}
|
||||
|
||||
String dataOrig = new SimpleDateFormat("yyyyMMdd").format(wdtbOrdt.getDataOrdRif());
|
||||
//ISNULL(descrizione, 'TEST') as descrizione
|
||||
String sqlRow = "SELECT descrizione, serie, num_ord, data_ord, convert(int, riga_ord) as riga_ord, cod_style as cod_mart, cod_col, cod_tagl, perc_prov, "
|
||||
+ "qtaord as qta_ord, przord as val_unt, convert(int, id_art) as id_art, convert(varchar(50), gruppo_cons) as gruppo_cons, note, sconto5, sconto6, sconto7, sconto8 "
|
||||
+ "FROM GetRigheOrdini(" + dataOrig + ", " + wdtbOrdt.getNumOrdRif() + ")";
|
||||
PreparedStatement psRow = connScambio.prepareStatement(sqlRow);
|
||||
ResultSet rsRow = psRow.executeQuery();
|
||||
|
||||
List<WdtbOrdr> rowList = new ResultSetMapper()
|
||||
.mapResultSetToList(rsRow, WdtbOrdr.class);
|
||||
rsRow.close();
|
||||
wdtbOrdt.setWdtbOrdr(rowList);
|
||||
|
||||
// salvataggio ordini web
|
||||
StringWriter writer = new StringWriter();
|
||||
jsonObjectMapper.writeValue(writer, wdtbOrdt);
|
||||
|
||||
String jsonBody = writer.toString();
|
||||
|
||||
String profileDB = multiDBTransactionManager.getPrimaryConnection().getProfileName();
|
||||
|
||||
String auth = RestUtil.generateAuth(profileDB, profileDB, "POST", jsonBody,
|
||||
"application/json",
|
||||
properties.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(properties.getEndPointWS()).path(
|
||||
properties.getRootApi() + EmsRestConstants.PATH_PROCESS_ENTITY);
|
||||
Response responseEms = resource.queryParam(CommonConstants.PROFILE_DB, profileDB)
|
||||
.request()
|
||||
.header("Authorization", profileDB + ":" + auth)
|
||||
.post(Entity.json(jsonBody));
|
||||
|
||||
String value = responseEms.readEntity(String.class);
|
||||
ServiceRestResponse resp = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||
|
||||
responseEms.close();
|
||||
client.close();
|
||||
|
||||
list.add(resp);
|
||||
|
||||
if (resp.getEsito() == EsitoType.OK) {
|
||||
if (resp.getEntity() instanceof WdtbOrdt) {
|
||||
WdtbOrdt ordT = (WdtbOrdt) resp.getEntity();
|
||||
|
||||
String dataOrdRif = new SimpleDateFormat("yyyyMMdd").format(ordT.getDataOrdRif());
|
||||
PreparedStatement psUpdate = dsScambio.getConnection().prepareStatement("INSERT INTO ord_imported(data_ord, num_ord, data_import) "
|
||||
+ "values (" + dataOrdRif + "," + ordT.getNumOrdRif() + ", GETDATE())");
|
||||
psUpdate.execute();
|
||||
psUpdate.close();
|
||||
dsScambio.getConnection().commit();
|
||||
}
|
||||
} else {
|
||||
errorMsg += dataOrig + " - " + wdtbOrdt.getNumOrdRif() + " " + resp.getErrorMessage() + "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(errorMsg)) {
|
||||
String emailTo = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"IMPORT_ORDINI_WEB", "SILVIAN_HEACH", "ERROR_EMAIL_TO");
|
||||
if (UtilityString.isNullOrEmpty(emailTo))
|
||||
throw new Exception("Importazione ordini SH, ERROR_EMAIL_TO non configurata!");
|
||||
|
||||
String emailCC = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"IMPORT_ORDINI_WEB", "SILVIAN_HEACH", "ERROR_EMAIL_CC");
|
||||
mailService.sendMail(emailTo, emailCC, "ERRORE IMPORTAZIONE ORDINI SH", errorMsg);
|
||||
}
|
||||
|
||||
dsScambio.close();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private WdtbNewCliOrd addSilviaHeachClie(Connection connScambio, String intercode) throws Exception {
|
||||
|
||||
String codFornIntercode = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"IMPORT_ORDINI_WEB", "SILVIAN_HEACH", "COD_FORN_INTERCODE");
|
||||
|
||||
String sql = "SELECT '" + codFornIntercode + "|' + convert(varchar, cod_vdes) as intercode, destinazione as destinatario,"
|
||||
+ " rag_soc, indirizzo, convert(varchar, cap) as cap, citta, prov, nazione, telefono, fax, part_iva,"
|
||||
+ " cod_fisc, note, num_cell, e_mail, 'SH001' as cod_anag, '001' as cod_vdes, cod_paga, cod_vage,"
|
||||
+ " destinazione, indirizzo_des, convert(varchar, cap_des) as cap_des, citta_des, prov_des, nazione_des,"
|
||||
+ " telefono_des, fax_des, note_des, num_cell_des, e_mail_des"
|
||||
+ " FROM getClienteOrdine(" + UtilityDB.valueToString(intercode) + ")";
|
||||
|
||||
PreparedStatement ps = connScambio.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
List<WdtbNewCliOrd> newClie = new ResultSetMapper()
|
||||
.mapResultSetToList(rs, WdtbNewCliOrd.class);
|
||||
ps.close();
|
||||
|
||||
if (newClie != null && !newClie.isEmpty())
|
||||
return newClie.get(0);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<ServiceRestResponse> splitOrderSurgelati(String whereCond) throws Exception {
|
||||
Integer index = 0, numGrpBolla = 0, existGruppoSurgelati = 0;
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
package it.integry.ems.system.imports;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.file_formatter.csv.CsvMapper;
|
||||
import it.integry.ems.file_sharer.IFileSharerAttachment;
|
||||
import it.integry.ems.file_sharer.sharers.email.EmailFileAttachment;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.imports.dto.ClienteDTO;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.StbEmailRecovery;
|
||||
import it.integry.ems_model.entity.VtbFidelityAnag;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityBarcode;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
|
||||
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Scope(value = "request")
|
||||
public class AnagraficaVirtuemartService {
|
||||
|
||||
@Autowired
|
||||
private SetupGest setupGest;
|
||||
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
@Autowired
|
||||
private EmsProperties emsProperties;
|
||||
|
||||
@Autowired
|
||||
private MailService mailService;
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
public List<EntityBase> importClienti(String type, String format, String rawContent) throws Exception {
|
||||
|
||||
List<EntityBase> entities = new ArrayList<EntityBase>();
|
||||
|
||||
HashMap<String, String> setupGestImportMap = (HashMap<String, String>) setupGest.getImportSetupSection(multiDBTransactionManager.getPrimaryConnection(), type, format);
|
||||
|
||||
String defaultTipoFidelity = UtilityHashMap.getValueIfExists(setupGestImportMap, "COD_FIDELITY");
|
||||
String pathFidelityTemplate = UtilityHashMap.getValueIfExists(setupGestImportMap, "PATH_FIDELITY");
|
||||
String mailSubject = UtilityHashMap.getValueIfExists(setupGestImportMap, "MAIL_SUBJECT");
|
||||
String mailTemplateUrl = UtilityHashMap.getValueIfExists(setupGestImportMap, "MAIL_TEMPLATE_URL");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mailTemplateUrl))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/MAIL_TEMPLATE_URL non configurato correttamente");
|
||||
|
||||
URL url = new URL(mailTemplateUrl + "/mail_model.html");
|
||||
InputStream is = url.openStream();
|
||||
String mailText = IOUtils.toString(is);
|
||||
is.close();
|
||||
|
||||
String from = UtilityHashMap.getValueIfExists(setupGestImportMap, "MAIL_FROM");
|
||||
String ccn = UtilityHashMap.getValueIfExists(setupGestImportMap, "MAIL_CCN");
|
||||
|
||||
if (UtilityString.isNullOrEmpty(defaultTipoFidelity))
|
||||
throw new Exception("IMPORT_ORDINI WEB/CONQUIST/COD_FIDELITY non configurato correttamente");
|
||||
|
||||
Map<String, EntityBase> map = new HashMap<String, EntityBase>();
|
||||
|
||||
CsvMapper<ClienteDTO> mapper = new CsvMapper<ClienteDTO>();
|
||||
List<ClienteDTO> clienti = mapper.deserialize(rawContent, ClienteDTO.class, "\t");
|
||||
if (clienti == null)
|
||||
throw new Exception("Nessun cliente da importare");
|
||||
|
||||
int counter = -1;
|
||||
|
||||
for (ClienteDTO clienteDTO : clienti) {
|
||||
VtbFidelityAnag anagOld = new VtbFidelityAnag();
|
||||
//GENERAZIONE EAN FIDELITY ED INVIO MAIL
|
||||
String sql =
|
||||
"SELECT ean_fidelity " +
|
||||
"FROM vtb_fidelity_anag " +
|
||||
"WHERE e_mail =" + UtilityDB.valueToString(clienteDTO.getEmail()) + " AND " +
|
||||
"cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity);
|
||||
|
||||
List<HashMap<String, Object>> resultsEanFidelty = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (!resultsEanFidelty.isEmpty()) {
|
||||
HashMap<String, Object> firstEanFidelty = resultsEanFidelty.get(0);
|
||||
clienteDTO.setCartaFidelity((String) UtilityHashMap.getValueIfExists(firstEanFidelty, "ean_fidelity"));
|
||||
} else {
|
||||
if (UtilityString.isNullOrEmpty(clienteDTO.getCartaFidelity())) {
|
||||
sql = "SELECT concat(max(left(ean_fidelity, 3)), max_code) last_code"
|
||||
+ " FROM vtb_fidelity_anag, (SELECT max(right(ean_fidelity, 2)) as max_code"
|
||||
+ " FROM vtb_fidelity_anag where ean_fidelity like '[0-9]%' AND "
|
||||
+ " cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity) + ") tmp"
|
||||
+ " where ean_fidelity like '[0-9]%' AND " +
|
||||
" cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity)
|
||||
+ " and right(ean_fidelity, 2) = tmp.max_code"
|
||||
+ " group by max_code";
|
||||
|
||||
|
||||
List<HashMap<String, Object>> resultsFidelityAnag = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
|
||||
if (!resultsFidelityAnag.isEmpty()) {
|
||||
String lastCode = UtilityHashMap.getValueIfExists(resultsFidelityAnag.get(0), "last_code");
|
||||
|
||||
counter++;
|
||||
int val = Integer.parseInt(lastCode.substring(0, 3)) + counter;
|
||||
|
||||
if (val == 999) {
|
||||
val = 0;
|
||||
String nextVal = UtilityString.getNextString(lastCode.substring(3));
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad(String.valueOf(val), 3, '0') + nextVal);
|
||||
} else {
|
||||
val++;
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad(String.valueOf(val), 3, '0') + lastCode.substring(3));
|
||||
}
|
||||
} else {
|
||||
//AA=27
|
||||
String nextVal = UtilityString.getNextString(27);
|
||||
clienteDTO.setCartaFidelity(UtilityString.leftPad("0", 3, '0') + nextVal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
anagOld.setCodFidelity(defaultTipoFidelity);
|
||||
anagOld.setEanFidelity(clienteDTO.getCartaFidelity());
|
||||
anagOld.setOperation(OperationType.SELECT_OBJECT);
|
||||
anagOld = entityProcessor.processEntity(anagOld, multiDBTransactionManager);
|
||||
|
||||
VtbFidelityAnag fidelityAnag = new VtbFidelityAnag();
|
||||
fidelityAnag.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
fidelityAnag.setNome(clienteDTO.getFirstName());
|
||||
fidelityAnag.setCognome(clienteDTO.getLastName());
|
||||
fidelityAnag.setUserName(clienteDTO.getUsername());
|
||||
fidelityAnag.setNominativo(clienteDTO.getFirstName() + " " + clienteDTO.getLastName());
|
||||
|
||||
fidelityAnag.setIndirizzo(clienteDTO.getAddress1());
|
||||
fidelityAnag.setCap(clienteDTO.getZip());
|
||||
fidelityAnag.setCitta(clienteDTO.getCity());
|
||||
fidelityAnag.setTelefono(clienteDTO.getPhone1());
|
||||
fidelityAnag.seteMail(clienteDTO.getEmail());
|
||||
fidelityAnag.setEanFidelity(clienteDTO.getCartaFidelity());
|
||||
fidelityAnag.setCodFidelity(defaultTipoFidelity);
|
||||
|
||||
fidelityAnag.setSesso(clienteDTO.getSesso());
|
||||
if (!UtilityString.isNullOrEmpty(clienteDTO.getDatanascita()) && !"0000-00-00".equals(clienteDTO.getDatanascita()))
|
||||
fidelityAnag.setDataNascita(UtilityString.parseDate(clienteDTO.getDatanascita()));
|
||||
fidelityAnag.setDataMod(new Date());
|
||||
if (anagOld != null) {
|
||||
//cambiati dati fondamentali, i dati verranno salvati su tabella di log
|
||||
if (!(anagOld.geteMail() != null && anagOld.geteMail().equals(clienteDTO.getEmail())) ||
|
||||
!(anagOld.getTelefono() != null && anagOld.getTelefono().equals(clienteDTO.getPhone1()))) {
|
||||
map.put(anagOld.getEanFidelity(), anagOld);
|
||||
}
|
||||
}
|
||||
entities.add(fidelityAnag);
|
||||
}
|
||||
|
||||
if (!entities.isEmpty()) {
|
||||
List<EntityBase> fideltyAnagsImported = entityProcessor.processEntityList(entities, true);
|
||||
|
||||
String insertSQL = "";
|
||||
for (EntityBase vtbFidelityAnagEB : fideltyAnagsImported) {
|
||||
|
||||
if (vtbFidelityAnagEB != null) {
|
||||
VtbFidelityAnag vtbFidelityAnag = (VtbFidelityAnag) fideltyAnagsImported;
|
||||
|
||||
String tempInsert = "INSERT INTO vtb_fidelity_anag_log "
|
||||
+ " (ean_fidelity, data_variaz, cod_fidelity, nominativo, indirizzo, cap, citta, prov, telefono, e_mail, cod_mdep, data_ins, data_mod)"
|
||||
+ " VALUES (" + UtilityDB.valueToString(vtbFidelityAnag.getEanFidelity()) + ", "
|
||||
+ " GetDate(), "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getCodFidelity()) + ","
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getNominativo()) + ","
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getIndirizzo()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getCap()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getCitta()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getProv()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getTelefono()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.geteMail()) + ", "
|
||||
+ UtilityDB.valueToString(vtbFidelityAnag.getCodMdep()) + ", "
|
||||
+ UtilityDB.valueDateToString(new Date(), "yyyy-MM-dd HH:mm:ss.SSS") + ", "
|
||||
+ UtilityDB.valueDateToString(new Date(), CommonConstants.DATETIME_FORMAT_YMD) + "); ";
|
||||
|
||||
insertSQL += tempInsert;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(insertSQL)) {
|
||||
DataSource dsConquist = new DataSource();
|
||||
dsConquist.initialize("MAFRAT2CONQUIST");
|
||||
|
||||
PreparedStatement ps = dsConquist.getConnection().prepareStatement(insertSQL);
|
||||
ps.executeUpdate();
|
||||
|
||||
dsConquist.getConnection().commit();
|
||||
dsConquist.close();
|
||||
}
|
||||
|
||||
String sql = "SELECT ean_fidelity, e_mail " +
|
||||
"FROM vtb_fidelity_anag " +
|
||||
"WHERE cod_fidelity = " + UtilityDB.valueToString(defaultTipoFidelity) + " AND " +
|
||||
"Convert(varchar(10), data_ins, 121) = Convert(varchar(10), getDate(), 121)";
|
||||
|
||||
List<HashMap<String, Object>> resultsFideltyMail = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
for (HashMap<String, Object> resultFideltyMail : resultsFideltyMail) {
|
||||
String eanFildelity = UtilityHashMap.getValueIfExists(resultFideltyMail, "ean_fidelity");
|
||||
String to = UtilityHashMap.getValueIfExists(resultFideltyMail, "e_mail");
|
||||
|
||||
PDDocument pdfDoc = PDDocument.load(new File(pathFidelityTemplate + "/FIDELITY_CARD_TEMPLATE.pdf"));
|
||||
PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();
|
||||
PDAcroForm acroForm = docCatalog.getAcroForm();
|
||||
|
||||
//CAMPO IN CHIARO
|
||||
acroForm.getField("plain").setValue(eanFildelity);
|
||||
acroForm.getField("plain").setReadOnly(true);
|
||||
//CAMPO CODIFICATO
|
||||
acroForm.getField("barcode").setValue(UtilityBarcode.encodeCode128(eanFildelity));
|
||||
acroForm.getField("barcode").setReadOnly(true);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
pdfDoc.save(baos);
|
||||
baos.close();
|
||||
pdfDoc.close();
|
||||
|
||||
mailText = mailText.replace("%%NUM_FIDELITY%%", eanFildelity);
|
||||
|
||||
EmailFileAttachment emailFileAttachment = new EmailFileAttachment("Quore fidelity card.pdf", baos.toByteArray());
|
||||
List<IFileSharerAttachment> emailFileAttachmentList = new ArrayList<IFileSharerAttachment>();
|
||||
emailFileAttachmentList.add(emailFileAttachment);
|
||||
|
||||
mailService.sendMailPrimary(multiDBTransactionManager.getPrimaryConnection(), from, null, to, null, ccn,
|
||||
mailSubject, mailText, true, false, null, null, emailFileAttachmentList, false, null);
|
||||
|
||||
StbEmailRecovery emailRecovery = new StbEmailRecovery();
|
||||
emailRecovery.setOperation(OperationType.INSERT);
|
||||
emailRecovery.setFromMail(from);
|
||||
emailRecovery.setToMail(to);
|
||||
emailRecovery.setDataIns(new Date());
|
||||
emailRecovery.setSubject(mailSubject);
|
||||
emailRecovery.setMsgtext(mailText);
|
||||
entityProcessor.processEntity(emailRecovery, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package it.integry.ems.system.imports.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ClienteDTO {
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password;
|
||||
|
||||
@JsonProperty("first_name")
|
||||
private String firstName;
|
||||
|
||||
@JsonProperty("last_name")
|
||||
private String lastName;
|
||||
|
||||
@JsonProperty("address_1")
|
||||
private String address1;
|
||||
|
||||
@JsonProperty("civico")
|
||||
private String civico;
|
||||
|
||||
@JsonProperty("zip")
|
||||
private String zip;
|
||||
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
|
||||
@JsonProperty("phone_1")
|
||||
private String phone1;
|
||||
|
||||
@JsonProperty("carta_fidelity")
|
||||
private String cartaFidelity;
|
||||
|
||||
@JsonProperty("usergroup_name")
|
||||
private String usergroupName;
|
||||
|
||||
@JsonProperty("address_type")
|
||||
private String addressType;
|
||||
|
||||
@JsonProperty("address_type_name")
|
||||
private String addressTypeName;
|
||||
|
||||
@JsonProperty("sesso")
|
||||
private String sesso;
|
||||
|
||||
@JsonProperty("datanascita")
|
||||
private String datanascita;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getAddress1() {
|
||||
return address1;
|
||||
}
|
||||
|
||||
public void setAddress1(String address1) {
|
||||
this.address1 = address1;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getPhone1() {
|
||||
return phone1;
|
||||
}
|
||||
|
||||
public void setPhone1(String phone1) {
|
||||
this.phone1 = phone1;
|
||||
}
|
||||
|
||||
public String getCartaFidelity() {
|
||||
return cartaFidelity;
|
||||
}
|
||||
|
||||
public void setCartaFidelity(String cartaFidelity) {
|
||||
this.cartaFidelity = cartaFidelity;
|
||||
}
|
||||
|
||||
public String getUsergroupName() {
|
||||
return usergroupName;
|
||||
}
|
||||
|
||||
public void setUsergroupName(String usergroupName) {
|
||||
this.usergroupName = usergroupName;
|
||||
}
|
||||
|
||||
public String getAddressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
public void setAddressType(String addressType) {
|
||||
this.addressType = addressType;
|
||||
}
|
||||
|
||||
public String getAddressTypeName() {
|
||||
return addressTypeName;
|
||||
}
|
||||
|
||||
public void setAddressTypeName(String addressTypeName) {
|
||||
this.addressTypeName = addressTypeName;
|
||||
}
|
||||
|
||||
public String getSesso() {
|
||||
return sesso;
|
||||
}
|
||||
|
||||
public void setSesso(String sesso) {
|
||||
this.sesso = sesso;
|
||||
}
|
||||
|
||||
public String getDatanascita() {
|
||||
return datanascita;
|
||||
}
|
||||
|
||||
public void setDatanascita(String datanascita) {
|
||||
this.datanascita = datanascita;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,472 +0,0 @@
|
||||
package it.integry.ems.system.imports.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class OrdineDTO {
|
||||
|
||||
@JsonProperty("order_number")
|
||||
private String orderNumber;
|
||||
|
||||
@JsonProperty("created_on")
|
||||
private Date createdOn;
|
||||
|
||||
@JsonProperty("virtuemart_order_id")
|
||||
private Integer virtuemartOrderId;
|
||||
|
||||
@JsonProperty("virtuemart_product_id")
|
||||
private Integer virtuemartProductId;
|
||||
|
||||
@JsonProperty("full_name")
|
||||
private String fullName;
|
||||
|
||||
@JsonProperty("address_1")
|
||||
private String address1;
|
||||
|
||||
@JsonProperty("civico")
|
||||
private String civico;
|
||||
|
||||
@JsonProperty("zip")
|
||||
private String zip;
|
||||
|
||||
@JsonProperty("city")
|
||||
private String city;
|
||||
|
||||
@JsonProperty("country_name")
|
||||
private String countryName;
|
||||
|
||||
@JsonProperty("state_name")
|
||||
private String stateName;
|
||||
|
||||
@JsonProperty("phone_1")
|
||||
private String phone1;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("customer_note")
|
||||
private String customerNote;
|
||||
|
||||
@JsonProperty("order_item_sku")
|
||||
private String orderItemSku;
|
||||
|
||||
@JsonProperty("order_item_name")
|
||||
private String orderItemName;
|
||||
|
||||
@JsonProperty("product_quantity")
|
||||
private Integer productQuantity;
|
||||
|
||||
@JsonProperty("product_item_price")
|
||||
private BigDecimal productItemPrice;
|
||||
|
||||
@JsonProperty("product_tax")
|
||||
private BigDecimal productTax;
|
||||
|
||||
@JsonProperty("product_final_price")
|
||||
private BigDecimal productFinalPrice;
|
||||
|
||||
@JsonProperty("order_shipment")
|
||||
private BigDecimal orderShipment;
|
||||
|
||||
@JsonProperty("order_shipment_tax")
|
||||
private BigDecimal orderShipmentTax;
|
||||
|
||||
@JsonProperty("order_payment")
|
||||
private BigDecimal orderPayment;
|
||||
|
||||
@JsonProperty("order_payment_tax")
|
||||
private BigDecimal orderPaymentTax;
|
||||
|
||||
@JsonProperty("order_total")
|
||||
private BigDecimal orderTotal;
|
||||
|
||||
@JsonProperty("total_order_items")
|
||||
private Integer totalOrderItems;
|
||||
|
||||
@JsonProperty("virtuemart_shipmentmethod_id")
|
||||
private String virtuemartShipmentmethodId;
|
||||
|
||||
@JsonProperty("virtuemart_paymentmethod_id")
|
||||
private String virtuemartPaymentmethodId;
|
||||
|
||||
@JsonProperty("user_currency")
|
||||
private String userCurrency;
|
||||
|
||||
@JsonProperty("order_status")
|
||||
private String orderStatus;
|
||||
|
||||
@JsonProperty("order_status_name")
|
||||
private String orderStatusName;
|
||||
|
||||
@JsonProperty("richiesta_fattura")
|
||||
private String richiestaFattura;
|
||||
|
||||
@JsonProperty("company")
|
||||
private String company;
|
||||
|
||||
@JsonProperty("codice_fiscale")
|
||||
private String codiceFiscale;
|
||||
|
||||
@JsonProperty("partita_iva")
|
||||
private String partitaIva;
|
||||
|
||||
@JsonProperty("cap_fattura")
|
||||
private String capFattura;
|
||||
|
||||
@JsonProperty("indirizzo_fattura")
|
||||
private String indirizzoFattura;
|
||||
|
||||
@JsonProperty("civico_fattura")
|
||||
private String civicoFattura;
|
||||
|
||||
@JsonProperty("citta_fattura")
|
||||
private String cittaFattura;
|
||||
|
||||
@JsonProperty("provincia_fattura")
|
||||
private String provinciaFattura;
|
||||
|
||||
@JsonProperty("negozio_scelto")
|
||||
private String negozioScelto;
|
||||
|
||||
public String getOrderNumber() {
|
||||
return orderNumber;
|
||||
}
|
||||
|
||||
public void setOrderNumber(String orderNumber) {
|
||||
this.orderNumber = orderNumber;
|
||||
}
|
||||
|
||||
public Date getCreatedOn() {
|
||||
return createdOn;
|
||||
}
|
||||
|
||||
public void setCreatedOn(Date createdOn) {
|
||||
this.createdOn = createdOn;
|
||||
}
|
||||
|
||||
public Integer getVirtuemartOrderId() {
|
||||
return virtuemartOrderId;
|
||||
}
|
||||
|
||||
public void setVirtuemartOrderId(Integer virtuemartOrderId) {
|
||||
this.virtuemartOrderId = virtuemartOrderId;
|
||||
}
|
||||
|
||||
public Integer getVirtuemartProductId() {
|
||||
return virtuemartProductId;
|
||||
}
|
||||
|
||||
public void setVirtuemartProductId(Integer virtuemartProductId) {
|
||||
this.virtuemartProductId = virtuemartProductId;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getAddress1() {
|
||||
return address1;
|
||||
}
|
||||
|
||||
public void setAddress1(String address1) {
|
||||
this.address1 = address1;
|
||||
}
|
||||
|
||||
public String getCivico() {
|
||||
return civico;
|
||||
}
|
||||
|
||||
public void setCivico(String civico) {
|
||||
this.civico = civico;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCountryName() {
|
||||
return countryName;
|
||||
}
|
||||
|
||||
public void setCountryName(String countryName) {
|
||||
this.countryName = countryName;
|
||||
}
|
||||
|
||||
public String getStateName() {
|
||||
return stateName;
|
||||
}
|
||||
|
||||
public void setStateName(String stateName) {
|
||||
this.stateName = stateName;
|
||||
}
|
||||
|
||||
public String getPhone1() {
|
||||
return phone1;
|
||||
}
|
||||
|
||||
public void setPhone1(String phone1) {
|
||||
this.phone1 = phone1;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCustomerNote() {
|
||||
return customerNote;
|
||||
}
|
||||
|
||||
public void setCustomerNote(String customerNote) {
|
||||
this.customerNote = customerNote;
|
||||
}
|
||||
|
||||
public String getOrderItemSku() {
|
||||
return orderItemSku;
|
||||
}
|
||||
|
||||
public void setOrderItemSku(String orderItemSku) {
|
||||
this.orderItemSku = orderItemSku;
|
||||
}
|
||||
|
||||
public String getOrderItemName() {
|
||||
return orderItemName;
|
||||
}
|
||||
|
||||
public void setOrderItemName(String orderItemName) {
|
||||
this.orderItemName = orderItemName;
|
||||
}
|
||||
|
||||
public Integer getProductQuantity() {
|
||||
return productQuantity;
|
||||
}
|
||||
|
||||
public void setProductQuantity(Integer productQuantity) {
|
||||
this.productQuantity = productQuantity;
|
||||
}
|
||||
|
||||
public BigDecimal getProductItemPrice() {
|
||||
return productItemPrice;
|
||||
}
|
||||
|
||||
public void setProductItemPrice(BigDecimal productItemPrice) {
|
||||
this.productItemPrice = productItemPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getProductTax() {
|
||||
return productTax;
|
||||
}
|
||||
|
||||
public void setProductTax(BigDecimal productTax) {
|
||||
this.productTax = productTax;
|
||||
}
|
||||
|
||||
public BigDecimal getProductFinalPrice() {
|
||||
return productFinalPrice;
|
||||
}
|
||||
|
||||
public void setProductFinalPrice(BigDecimal productFinalPrice) {
|
||||
this.productFinalPrice = productFinalPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderShipment() {
|
||||
return orderShipment;
|
||||
}
|
||||
|
||||
public void setOrderShipment(BigDecimal orderShipment) {
|
||||
this.orderShipment = orderShipment;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderShipmentTax() {
|
||||
return orderShipmentTax;
|
||||
}
|
||||
|
||||
public void setOrderShipmentTax(BigDecimal orderShipmentTax) {
|
||||
this.orderShipmentTax = orderShipmentTax;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderPayment() {
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
public void setOrderPayment(BigDecimal orderPayment) {
|
||||
this.orderPayment = orderPayment;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderPaymentTax() {
|
||||
return orderPaymentTax;
|
||||
}
|
||||
|
||||
public void setOrderPaymentTax(BigDecimal orderPaymentTax) {
|
||||
this.orderPaymentTax = orderPaymentTax;
|
||||
}
|
||||
|
||||
public BigDecimal getOrderTotal() {
|
||||
return orderTotal;
|
||||
}
|
||||
|
||||
public void setOrderTotal(BigDecimal orderTotal) {
|
||||
this.orderTotal = orderTotal;
|
||||
}
|
||||
|
||||
public Integer getTotalOrderItems() {
|
||||
return totalOrderItems;
|
||||
}
|
||||
|
||||
public void setTotalOrderItems(Integer totalOrderItems) {
|
||||
this.totalOrderItems = totalOrderItems;
|
||||
}
|
||||
|
||||
public String getVirtuemartShipmentmethodId() {
|
||||
return virtuemartShipmentmethodId;
|
||||
}
|
||||
|
||||
public void setVirtuemartShipmentmethodId(String virtuemartShipmentmethodId) {
|
||||
this.virtuemartShipmentmethodId = virtuemartShipmentmethodId;
|
||||
}
|
||||
|
||||
public String getVirtuemartPaymentmethodId() {
|
||||
return virtuemartPaymentmethodId;
|
||||
}
|
||||
|
||||
public void setVirtuemartPaymentmethodId(String virtuemartPaymentmethodId) {
|
||||
this.virtuemartPaymentmethodId = virtuemartPaymentmethodId;
|
||||
}
|
||||
|
||||
public String getUserCurrency() {
|
||||
return userCurrency;
|
||||
}
|
||||
|
||||
public void setUserCurrency(String userCurrency) {
|
||||
this.userCurrency = userCurrency;
|
||||
}
|
||||
|
||||
public String getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getOrderStatusName() {
|
||||
return orderStatusName;
|
||||
}
|
||||
|
||||
public void setOrderStatusName(String orderStatusName) {
|
||||
this.orderStatusName = orderStatusName;
|
||||
}
|
||||
|
||||
public String getRichiestaFattura() {
|
||||
return richiestaFattura;
|
||||
}
|
||||
|
||||
public void setRichiestaFattura(String richiestaFattura) {
|
||||
this.richiestaFattura = richiestaFattura;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String getCodiceFiscale() {
|
||||
return codiceFiscale;
|
||||
}
|
||||
|
||||
public void setCodiceFiscale(String codiceFiscale) {
|
||||
this.codiceFiscale = codiceFiscale;
|
||||
}
|
||||
|
||||
public String getPartitaIva() {
|
||||
return partitaIva;
|
||||
}
|
||||
|
||||
public void setPartitaIva(String partitaIva) {
|
||||
this.partitaIva = partitaIva;
|
||||
}
|
||||
|
||||
public String getCapFattura() {
|
||||
return capFattura;
|
||||
}
|
||||
|
||||
public void setCapFattura(String capFattura) {
|
||||
this.capFattura = capFattura;
|
||||
}
|
||||
|
||||
public String getIndirizzoFattura() {
|
||||
return indirizzoFattura;
|
||||
}
|
||||
|
||||
public void setIndirizzoFattura(String indirizzoFattura) {
|
||||
this.indirizzoFattura = indirizzoFattura;
|
||||
}
|
||||
|
||||
public String getCivicoFattura() {
|
||||
return civicoFattura;
|
||||
}
|
||||
|
||||
public void setCivicoFattura(String civicoFattura) {
|
||||
this.civicoFattura = civicoFattura;
|
||||
}
|
||||
|
||||
public String getCittaFattura() {
|
||||
return cittaFattura;
|
||||
}
|
||||
|
||||
public void setCittaFattura(String cittaFattura) {
|
||||
this.cittaFattura = cittaFattura;
|
||||
}
|
||||
|
||||
public String getProvinciaFattura() {
|
||||
return provinciaFattura;
|
||||
}
|
||||
|
||||
public void setProvinciaFattura(String provinciaFattura) {
|
||||
this.provinciaFattura = provinciaFattura;
|
||||
}
|
||||
|
||||
public String getNegozioScelto() {
|
||||
return negozioScelto;
|
||||
}
|
||||
|
||||
public void setNegozioScelto(String negozioScelto) {
|
||||
this.negozioScelto = negozioScelto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package it.integry.ems.system.job;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.schedule.cron_job.QuartzJobBeanWithConf;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.security.utility.RestUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Date;
|
||||
|
||||
public class RecoveryMailJob extends QuartzJobBeanWithConf {
|
||||
|
||||
private EmsProperties emsProperties;
|
||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
||||
private SetupGest setupGest;
|
||||
|
||||
private Logger logger = LogManager.getLogger();
|
||||
|
||||
public EmsProperties getEmsProperties() {
|
||||
return emsProperties;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setEmsProperties(EmsProperties emsProperties) {
|
||||
this.emsProperties = emsProperties;
|
||||
}
|
||||
|
||||
public ResponseJSONObjectMapper getJsonObjectMapper() {
|
||||
return jsonObjectMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setJsonObjectMapper(ResponseJSONObjectMapper jsonObjectMapper) {
|
||||
this.jsonObjectMapper = jsonObjectMapper;
|
||||
}
|
||||
|
||||
public SetupGest getSetupGest() {
|
||||
return setupGest;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSetupGest(SetupGest setupGest) {
|
||||
this.setupGest = setupGest;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) {
|
||||
try {
|
||||
String database = profileDb;
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(database);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(branch)) {
|
||||
String[] params = branch.split("\\|");
|
||||
Boolean enabled = setupGest.getSetupBoolean(ds.getConnection(), params[0], params[1], params[2] + "ENABLED");
|
||||
|
||||
if (enabled && "/ems-api".equals(emsProperties.getRootApi())) {
|
||||
String sql = "SELECT * FROM stb_email_recovery";
|
||||
PreparedStatement ps = ds.getConnection().prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String to = rs.getString("to");
|
||||
String from = rs.getString("from");
|
||||
String mailText = rs.getString("msg_text");
|
||||
Date dataIns = rs.getTimestamp("data_ins");
|
||||
String mailSubject = rs.getString("subject");
|
||||
String jsonBody = rs.getString("attachments");
|
||||
String auth = RestUtil.generateAuth(database, database, "POST", jsonBody, "application/json",
|
||||
emsProperties.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
||||
|
||||
final Client client = ClientBuilder.newClient();
|
||||
final WebTarget resource = client.target(emsProperties.getEndPointWS())
|
||||
.path(emsProperties.getRootApi() + EmsRestConstants.PATH_SEND_MAIL);
|
||||
Response response = resource.queryParam(CommonConstants.PROFILE_DB, database).queryParam("from", from)
|
||||
.queryParam("to", to).queryParam("subject", mailSubject).queryParam("msgText", mailText)
|
||||
.request()
|
||||
.header("Authorization", database + ":" + auth)
|
||||
.post(Entity.json(jsonBody));
|
||||
String str = response.readEntity(String.class);
|
||||
ServiceRestResponse resp = jsonObjectMapper.readValue(str, ServiceRestResponse.class);
|
||||
if (resp.getEsito() == EsitoType.OK) {
|
||||
String delete = "delete from stb_email_recovery where [from]=" + UtilityDB.valueToString(from)
|
||||
+ " and [to]=" + UtilityDB.valueToString(to) + " and data_ins=" + UtilityDB.valueDateToString(dataIns, CommonConstants.DATETIME_FORMAT_YMD);
|
||||
PreparedStatement psDelete = ds.getConnection().prepareStatement(delete);
|
||||
psDelete.executeUpdate();
|
||||
psDelete.close();
|
||||
ds.getConnection().commit();
|
||||
}
|
||||
|
||||
response.close();
|
||||
client.close();
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
ds.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="warn" shutdownHook="enable" shutdownTimeout="10000">
|
||||
<Properties>
|
||||
<Property name="basePath">${sys:catalina.home}/logs/</Property>
|
||||
<Property name="maxBackupIndex">30</Property>
|
||||
<Property name="logPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1.1.9}.java:%L %X{username} - %m%n</Property>
|
||||
<!-- Enhanced pattern to better show DEBUG information -->
|
||||
<Property name="consolePattern">
|
||||
%d{yyyy-MM-dd HH:mm:ss} %style{%-40c{1.}}{cyan} %highlight{ %.-1p }{FATAL=bg_red blink black bold, ERROR=bg_red black, WARN=bright bg_yellow black, INFO=bg_green, DEBUG=bg_cyan black, TRACE=bg_white black} %highlight{%msg%n%throwable}{FATAL=red blink bold, ERROR=red, WARN=bright yellow, INFO=green, DEBUG=cyan, TRACE=white}
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Appenders>
|
||||
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${consolePattern}" disableAnsi="false"/>
|
||||
</Console>
|
||||
|
||||
<!-- JDBC Appender for database logging -->
|
||||
<JDBC name="SqLiteDatabase" tableName="app_logs">
|
||||
<ConnectionFactory class="it.integry.core.log.ConnectionFactory" method="getSqlConnection"/>
|
||||
<Column name="id" pattern="%u" isUnicode="false"/>
|
||||
<Column name="entry_date" isEventTimestamp="true"/>
|
||||
<Column name="level" pattern="%level" isUnicode="false"/>
|
||||
<Column name="logger" pattern="%logger" isUnicode="false"/>
|
||||
<Column name="message" pattern="%message" isUnicode="false"/>
|
||||
<Column name="exception" pattern="%throwable" isUnicode="false"/>
|
||||
</JDBC>
|
||||
|
||||
<RollingFile name="primaryFileLogger"
|
||||
fileName="${basePath}/ems.log"
|
||||
filePattern="${basePath}/ems-%d{yyyy-MM-dd}_%i.log"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>${logPattern}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="20 MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="${maxBackupIndex}"/>
|
||||
</RollingFile>
|
||||
|
||||
<RollingFile name="errorFileLogger"
|
||||
fileName="${basePath}/ems-error.log"
|
||||
filePattern="${basePath}/ems-error-%d{yyyy-MM-dd}_%i.log"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>${logPattern}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="20 MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="${maxBackupIndex}"/>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<!-- Root Logger -->
|
||||
<AsyncRoot level="INFO">
|
||||
<AppenderRef ref="console"/>
|
||||
<AppenderRef ref="primaryFileLogger"/>
|
||||
</AsyncRoot>
|
||||
|
||||
<!-- Spring Framework Loggers -->
|
||||
<!-- <AsyncLogger name="org.springframework" level="DEBUG" additivity="false">-->
|
||||
<!-- <AppenderRef ref="console"/>-->
|
||||
<!-- <AppenderRef ref="primaryFileLogger"/>-->
|
||||
<!-- </AsyncLogger>-->
|
||||
|
||||
<!-- <AsyncLogger name="org.springframework.web" level="INFO" additivity="false">-->
|
||||
<!-- <AppenderRef ref="console"/>-->
|
||||
<!-- <AppenderRef ref="primaryFileLogger"/>-->
|
||||
<!-- </AsyncLogger>-->
|
||||
|
||||
<!-- <AsyncLogger name="org.springframework.security" level="INFO" additivity="false">-->
|
||||
<!-- <AppenderRef ref="console"/>-->
|
||||
<!-- <AppenderRef ref="primaryFileLogger"/>-->
|
||||
<!-- </AsyncLogger>-->
|
||||
<!-- -->
|
||||
<!-- <AsyncLogger name="springfox" level="INFO" additivity="false" />-->
|
||||
|
||||
<!-- <!– JBoss RESTEasy Loggers –>-->
|
||||
<!-- <AsyncLogger name="org.jboss.resteasy" level="INFO" additivity="false"/>-->
|
||||
|
||||
<!-- Application Logger -->
|
||||
<AsyncLogger name="it.integry" level="DEBUG" additivity="false" includeLocation="true">
|
||||
<AppenderRef ref="console" />
|
||||
<AppenderRef ref="primaryFileLogger" />
|
||||
<AppenderRef ref="errorFileLogger" level="ERROR"/>
|
||||
<AppenderRef ref="SqLiteDatabase" />
|
||||
</AsyncLogger>
|
||||
</Loggers>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="warn" shutdownHook="enable" shutdownTimeout="10000">
|
||||
<Properties>
|
||||
<Property name="basePath">${sys:catalina.home}/logs/</Property>
|
||||
<Property name="maxBackupIndex">30</Property>
|
||||
<Property name="logPattern">%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1.1.9}.java:%L %X{username} - %m%n</Property>
|
||||
<!-- Enhanced pattern to better show DEBUG information -->
|
||||
<Property name="consolePattern">
|
||||
%d{yyyy-MM-dd HH:mm:ss} %style{%-40c{1.}}{cyan} %highlight{ %.-1p }{FATAL=bg_red blink black bold, ERROR=bg_red black, WARN=bright bg_yellow black, INFO=bg_green, DEBUG=bg_cyan black, TRACE=bg_white black} %highlight{%msg%n%throwable}{FATAL=red blink bold, ERROR=red, WARN=bright yellow, INFO=green, DEBUG=cyan, TRACE=white}
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Appenders>
|
||||
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${consolePattern}" disableAnsi="false"/>
|
||||
</Console>
|
||||
|
||||
<!-- JDBC Appender for database logging -->
|
||||
<JDBC name="SqLiteDatabase" tableName="app_logs">
|
||||
<ConnectionFactory class="it.integry.core.log.ConnectionFactory" method="getSqlConnection"/>
|
||||
<Column name="id" pattern="%u" isUnicode="false"/>
|
||||
<Column name="entry_date" isEventTimestamp="true"/>
|
||||
<Column name="level" pattern="%level" isUnicode="false"/>
|
||||
<Column name="logger" pattern="%logger" isUnicode="false"/>
|
||||
<Column name="message" pattern="%message" isUnicode="false"/>
|
||||
<Column name="exception" pattern="%throwable" isUnicode="false"/>
|
||||
</JDBC>
|
||||
|
||||
<RollingFile name="primaryFileLogger"
|
||||
fileName="${basePath}/ems.log"
|
||||
filePattern="${basePath}/ems-%d{yyyy-MM-dd}_%i.log"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>${logPattern}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="20 MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="${maxBackupIndex}"/>
|
||||
</RollingFile>
|
||||
|
||||
<RollingFile name="errorFileLogger"
|
||||
fileName="${basePath}/ems-error.log"
|
||||
filePattern="${basePath}/ems-error-%d{yyyy-MM-dd}_%i.log"
|
||||
ignoreExceptions="false">
|
||||
<PatternLayout>
|
||||
<Pattern>${logPattern}</Pattern>
|
||||
</PatternLayout>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
<SizeBasedTriggeringPolicy size="20 MB"/>
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="${maxBackupIndex}"/>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<!-- Root Logger -->
|
||||
<AsyncRoot level="INFO">
|
||||
<AppenderRef ref="console"/>
|
||||
<AppenderRef ref="primaryFileLogger"/>
|
||||
</AsyncRoot>
|
||||
|
||||
<!-- Spring Framework Loggers -->
|
||||
<!-- <AsyncLogger name="org.springframework" level="DEBUG" additivity="false">-->
|
||||
<!-- <AppenderRef ref="console"/>-->
|
||||
<!-- <AppenderRef ref="primaryFileLogger"/>-->
|
||||
<!-- </AsyncLogger>-->
|
||||
|
||||
<AsyncLogger name="org.springframework.web" level="INFO" additivity="false">
|
||||
<AppenderRef ref="console"/>
|
||||
<AppenderRef ref="primaryFileLogger"/>
|
||||
</AsyncLogger>
|
||||
|
||||
<!-- <AsyncLogger name="org.springframework.security" level="INFO" additivity="false">-->
|
||||
<!-- <AppenderRef ref="console"/>-->
|
||||
<!-- <AppenderRef ref="primaryFileLogger"/>-->
|
||||
<!-- </AsyncLogger>-->
|
||||
<!-- -->
|
||||
<!-- <AsyncLogger name="springfox" level="INFO" additivity="false" />-->
|
||||
|
||||
<!-- <!– JBoss RESTEasy Loggers –>-->
|
||||
<!-- <AsyncLogger name="org.jboss.resteasy" level="INFO" additivity="false"/>-->
|
||||
|
||||
<!-- Application Logger -->
|
||||
<AsyncLogger name="it.integry" level="DEBUG" additivity="false" includeLocation="true">
|
||||
<AppenderRef ref="console" />
|
||||
<AppenderRef ref="primaryFileLogger" />
|
||||
<AppenderRef ref="errorFileLogger" level="ERROR"/>
|
||||
<AppenderRef ref="SqLiteDatabase" />
|
||||
</AsyncLogger>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user