Vario
This commit is contained in:
@@ -24,9 +24,11 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseMigration implements MigrationModelInterface {
|
||||
@@ -62,6 +64,14 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
}
|
||||
|
||||
|
||||
protected @NotNull List<HashMap<String, Object>> executeQuery(String sql) throws SQLException, IOException {
|
||||
return UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
||||
}
|
||||
|
||||
protected @NotNull <T>List<T> executeQueryDTO(String sql, Class<T> clazz) throws Exception {
|
||||
return UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, clazz);
|
||||
}
|
||||
|
||||
protected void executeStatement(String... sqls) throws SQLException, IOException {
|
||||
executeStatement(advancedDataSource.getConnection(), sqls);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.MrlDepoArtEsclusiWms;
|
||||
import it.integry.ems_model.entity.MtbDepo;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
public class Migration_20241107192339 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomerDb(IntegryCustomerDB.Maggio_MaggioSrl)) {
|
||||
MtbDepo mtbDepo = new MtbDepo()
|
||||
.setCodMdep("01");
|
||||
mtbDepo.setOperation(OperationType.NO_OP);
|
||||
|
||||
MrlDepoArtEsclusiWms mrlDepoArtEsclusiWms = new MrlDepoArtEsclusiWms()
|
||||
.setCodMdep("01")
|
||||
.setCodMgrp("COM")
|
||||
.setCodMsgr("15");
|
||||
mrlDepoArtEsclusiWms.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
mtbDepo.getMrlDepoArtEsclusiWms().add(mrlDepoArtEsclusiWms);
|
||||
|
||||
mtbDepo.manageWithParentConnection(advancedDataSource.getConnection());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class SettingsModel implements InitializingBean {
|
||||
@@ -94,8 +96,14 @@ public class SettingsModel implements InitializingBean {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArrayList<AvailableConnectionsModel> getAvailableConnections() {
|
||||
return availableConnections.get();
|
||||
public List<AvailableConnectionsModel> getAvailableConnections() {
|
||||
return getAvailableConnections(false);
|
||||
}
|
||||
|
||||
public List<AvailableConnectionsModel> getAvailableConnections(boolean onlyInternal) {
|
||||
return availableConnections.get().stream()
|
||||
.filter(x -> !onlyInternal || x.getInternalDb())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void addAvailableConnection(AvailableConnectionsModel availableConnectionsModel) {
|
||||
|
||||
@@ -3,17 +3,16 @@ package it.integry.ems_model.entity;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import java.util.ArrayList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
@PropertyReactive
|
||||
@Table(MrlDepoArtEsclusiWms.ENTITY)
|
||||
@JsonTypeName(MrlDepoArtEsclusiWms.ENTITY)
|
||||
public class MrlDepoArtEsclusiWms extends EntityBase {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
private final static Logger logger = LogManager.getLogger(MrlDepoArtEsclusiWms.class);
|
||||
|
||||
public static final String ENTITY = "mrl_depo_art_esclusi_wms";
|
||||
|
||||
@@ -54,63 +53,71 @@ public class MrlDepoArtEsclusiWms extends EntityBase {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public MrlDepoArtEsclusiWms setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public void setCodMdep(String codMdep) {
|
||||
public MrlDepoArtEsclusiWms setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMgrp() {
|
||||
return codMgrp;
|
||||
}
|
||||
|
||||
public void setCodMgrp(String codMgrp) {
|
||||
public MrlDepoArtEsclusiWms setCodMgrp(String codMgrp) {
|
||||
this.codMgrp = codMgrp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsgr() {
|
||||
return codMsgr;
|
||||
}
|
||||
|
||||
public void setCodMsgr(String codMsgr) {
|
||||
public MrlDepoArtEsclusiWms setCodMsgr(String codMsgr) {
|
||||
this.codMsgr = codMsgr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMsfa() {
|
||||
return codMsfa;
|
||||
}
|
||||
|
||||
public void setCodMsfa(String codMsfa) {
|
||||
public MrlDepoArtEsclusiWms setCodMsfa(String codMsfa) {
|
||||
this.codMsfa = codMsfa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMtip() {
|
||||
return codMtip;
|
||||
}
|
||||
|
||||
public void setCodMtip(String codMtip) {
|
||||
public MrlDepoArtEsclusiWms setCodMtip(String codMtip) {
|
||||
this.codMtip = codMtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMstp() {
|
||||
return codMstp;
|
||||
}
|
||||
|
||||
public void setCodMstp(String codMstp) {
|
||||
public MrlDepoArtEsclusiWms setCodMstp(String codMstp) {
|
||||
this.codMstp = codMstp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public void setCodMart(String codMart) {
|
||||
public MrlDepoArtEsclusiWms setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.base.Joiner;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.dto.ExtendedStbActivity;
|
||||
import it.integry.ems.dto.Result;
|
||||
import it.integry.ems.expansion.RunnableArgsThrowable;
|
||||
import it.integry.ems.file_sharer.IFileSharerAttachment;
|
||||
import it.integry.ems.file_sharer.sharers.email.EmailFileAttachment;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -17,6 +19,7 @@ import it.integry.ems.license.LicenseStatusDTO;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems.report.dto.PairsDTO;
|
||||
import it.integry.ems.response.*;
|
||||
import it.integry.ems.retail.ReportVariazioni.dto.VariazioniDettaglioDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.service.MailService;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
@@ -35,7 +38,9 @@ import it.integry.ems.system.exception.NotValidLicenseException;
|
||||
import it.integry.ems.system.request.SystemChangePasswordRequest;
|
||||
import it.integry.ems.system.request.SystemLoginRequest;
|
||||
import it.integry.ems.system.service.SystemService;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems.utility.UtilityFile;
|
||||
import it.integry.ems.utility.UtilityPrinter;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -48,9 +53,7 @@ import it.integry.ems_model.utility.*;
|
||||
import it.integry.ems_model.utility.dto.ConvertQueryDTO;
|
||||
import it.integry.security.cache.SecretKeyCacheComponent;
|
||||
import it.integry.security.dto.LoginRequestDTO;
|
||||
import net.schmizz.sshj.SSHClient;
|
||||
import net.schmizz.sshj.sftp.SFTPClient;
|
||||
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
|
||||
import kotlin.Triple;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
@@ -67,9 +70,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@@ -1407,22 +1414,88 @@ public class SystemController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_TEST, method = RequestMethod.POST)
|
||||
public ServiceRestResponse test(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration) throws Exception {
|
||||
|
||||
|
||||
String sql = "SELECT dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.ser_doc\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
"WHERE dtb_doct.data_doc BETWEEN '2023/01/01' AND '2023-12-31'--BETWEEN '2024/01/01' AND GETDATE()\n" +
|
||||
" AND dtb_doct.gestione = 'V'\n" +
|
||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND dtb_tipi.segno_qta_scar <> 0\n" +
|
||||
"ORDER BY dtb_doct.data_doc, dtb_doct.num_doc";
|
||||
|
||||
final List<HashMap<String, Object>> documents = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
String tempDir = Paths.get(UtilityDirs.getTempDirectoryPath(), "vgalimenti-export-" + dateTimeFormatter.format(LocalDateTime.now())).toString();
|
||||
|
||||
List<RunnableArgsThrowable<Triple<String, String, List<VariazioniDettaglioDTO>>>> calls = new ArrayList<>();
|
||||
|
||||
|
||||
for (HashMap<String, Object> document : documents) {
|
||||
ArrayList<PairsDTO> params = new ArrayList<>();
|
||||
String codAnag = UtilityHashMap.getValueIfExists(document, "cod_anag");
|
||||
String serDoc = UtilityHashMap.getValueIfExists(document, "ser_doc");
|
||||
Integer numDoc = UtilityHashMap.getValueIfExists(document, "num_doc");
|
||||
Date dataDoc = UtilityHashMap.getValueIfExists(document, "data_doc");
|
||||
String codDtip = UtilityHashMap.getValueIfExists(document, "cod_dtip");
|
||||
|
||||
params.add(new PairsDTO("cod_anag", codAnag));
|
||||
params.add(new PairsDTO("ser_doc", serDoc));
|
||||
params.add(new PairsDTO("num_doc", numDoc));
|
||||
params.add(new PairsDTO("data_doc", dataDoc));
|
||||
params.add(new PairsDTO("cod_dtip", codDtip));
|
||||
|
||||
JasperDTO jasperDTO = new JasperDTO()
|
||||
.setParams(params)
|
||||
.setReportId(20L);
|
||||
|
||||
calls.add(() -> {
|
||||
try {
|
||||
SSHClient client = new SSHClient();
|
||||
client.addHostKeyVerifier(new PromiscuousVerifier());
|
||||
client.connect("edis.chep.com");
|
||||
client.authPassword("C0094362", "C526342");
|
||||
final byte[] bytes = reportProcessor.processReport(jasperDTO);
|
||||
|
||||
UtilityFile.saveFile(tempDir, String.format("%s_%s_%s_%d_%s.pdf",
|
||||
UtilityDate.formatDate(dataDoc, "yyyyMMdd"),
|
||||
codDtip,
|
||||
serDoc,
|
||||
numDoc,
|
||||
codAnag
|
||||
), bytes);
|
||||
|
||||
} catch (Exception ex) {
|
||||
// throw ex;
|
||||
// logger.error(request.getRequestURI(), "Errore durante la generazione del pdf per il DDT [" +
|
||||
// "num_doc: " + numDoc + ", " +
|
||||
// "data_doc: " + dataDoc + ", " +
|
||||
// "ser_doc: " + serDoc + ", " +
|
||||
// "cod_anag: " + codAnag + ", " +
|
||||
// "cod_dtip: " + codDtip + "] " + ex.getMessage());
|
||||
|
||||
throw new RuntimeException(new Exception("Errore durante la generazione del pdf per il DDT [" +
|
||||
"num_doc: " + numDoc + ", " +
|
||||
"data_doc: " + dataDoc + ", " +
|
||||
"ser_doc: " + serDoc + ", " +
|
||||
"cod_anag: " + codAnag + ", " +
|
||||
"cod_dtip: " + codDtip + "] " + ex.getMessage()));
|
||||
}
|
||||
|
||||
// break;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
final ArrayList<Result<Triple<String, String, List<VariazioniDettaglioDTO>>>> results = UtilityThread.executeParallel(calls, 6);
|
||||
|
||||
SFTPClient sftpClient = client.newSFTPClient();
|
||||
sftpClient.ls("/");
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception ex) {
|
||||
logger.error(request.getRequestURI(), ex);
|
||||
return new ServiceRestResponse(EsitoType.KO, configuration, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_STB_EMAIL_CONTENT_FATTURE_PASSIVE_DELETER, method = RequestMethod.POST)
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ExchangeDocumentImportService {
|
||||
.forEach(testata -> {
|
||||
testata.setUserName(EXCHANGE_USER);
|
||||
testata.setUsername(EXCHANGE_USER);
|
||||
testata.setUpdProgMaga(false);
|
||||
//testata.setUpdProgMaga(false);
|
||||
|
||||
testata.setDtbDocr(righe.parallelStream()
|
||||
.filter(riga ->
|
||||
|
||||
Reference in New Issue
Block a user