Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -64,8 +64,10 @@ public class DocumentiDialogoImportServices {
|
||||
String csvDialogo = rawContentInput.toUpperCase();
|
||||
CsvMapper<DocumentiDialogoDTO.Import> mapper = new CsvMapper<DocumentiDialogoDTO.Import>();
|
||||
List<DocumentiDialogoDTO.Import> dialogoList = mapper.deserialize(csvDialogo, DocumentiDialogoDTO.Import.class, "\t");
|
||||
if (dialogoList == null)
|
||||
throw new Exception("Non ci sono dati da importare");
|
||||
if (dialogoList == null) {
|
||||
logger.trace("Non ci sono dati da importare, file vuoto");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dialogoList.isEmpty())
|
||||
throw new Exception("Errore nella mappatura del file. (DocumentiDialogoDTO.Import) ");
|
||||
|
||||
@@ -113,6 +113,7 @@ public class CambioTipoDocService {
|
||||
.setNumDocForn(doc.getNumDocForn());
|
||||
|
||||
newDoc.setOperation(OperationType.INSERT);
|
||||
newDoc.getDtbDocr().stream().forEach(r->r.setOperation(OperationType.INSERT));
|
||||
if (doc.getAllegati() != null && !doc.getAllegati().isEmpty()) {
|
||||
List<DrlDocAttached> drlDocAttacheds = new ArrayList<>();
|
||||
for (CambioTipoDocDTO.Allegati allegato : doc.getAllegati()) {
|
||||
|
||||
@@ -78,16 +78,16 @@ public class DocumentiDirettiService {
|
||||
entityList.addAll(mtbLisaCostoDataDelete);
|
||||
}
|
||||
List<MtbLisaCostoData> mtbLisaCostoData = documentService.popolaTabellaCosti(dtbDoct.getCodAnag(),
|
||||
dtbDoct.getCodDtip(),
|
||||
dtbDoct.getDataDoc(),
|
||||
dtbDoct.getSerDoc(),
|
||||
dtbDoct.getNumDoc(), false, false);
|
||||
dtbDoct.getCodDtip(),
|
||||
dtbDoct.getDataDoc(),
|
||||
dtbDoct.getSerDoc(),
|
||||
dtbDoct.getNumDoc(), false, false);
|
||||
if (mtbLisaCostoData != null)
|
||||
entityList.addAll(mtbLisaCostoData);
|
||||
}
|
||||
|
||||
List<EntityBase> entityRet = new ArrayList<>();
|
||||
for ( EntityBase e: entityList) {
|
||||
for (EntityBase e : entityList) {
|
||||
entityProcessor.processEntity(e, true, multiDBTransactionManager);
|
||||
entityRet.add(e);
|
||||
}
|
||||
@@ -98,10 +98,10 @@ public class DocumentiDirettiService {
|
||||
dtbDoct.getDataDoc(),
|
||||
dtbDoct.getSerDoc(),
|
||||
dtbDoct.getNumDoc(), false, false);
|
||||
if (mtbLisaCostoData != null){
|
||||
if (mtbLisaCostoData != null) {
|
||||
entityList.addAll(mtbLisaCostoData);
|
||||
|
||||
for ( EntityBase e: mtbLisaCostoData) {
|
||||
for (EntityBase e : mtbLisaCostoData) {
|
||||
entityProcessor.processEntity(e, true, multiDBTransactionManager);
|
||||
entityRet.add(e);
|
||||
}
|
||||
@@ -116,49 +116,48 @@ public class DocumentiDirettiService {
|
||||
}
|
||||
|
||||
private DtbDoct checkUDSForTransfer(DtbDoct dtbDoct, List<EntityBase> entityList, boolean isNewDoc) throws Exception {
|
||||
if (dtbDoct.getMtbColt().isEmpty())
|
||||
if (dtbDoct.getMtbColt().isEmpty() && isNewDoc)
|
||||
return null;
|
||||
String codDtipTrasf = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI", dtbDoct.getCodMdep());
|
||||
if (!UtilityString.isNullOrEmpty(codDtipTrasf))
|
||||
return null;
|
||||
//<editor-fold desc="Prendo tutti i colli, con le quantità associate che devono essere trasferite">
|
||||
String whereCondColli =
|
||||
StringUtils.join(dtbDoct.getMtbColt().stream().map(ul -> {
|
||||
try {
|
||||
return String.format("(%s)", ul.getPkWhereCond());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList()), " OR ");
|
||||
List<UlVenditaDTO> artsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("WITH uds AS (SELECT *\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" WHERE cod_mdep <> {}\n" +
|
||||
" AND (" + whereCondColli + "))\n" +
|
||||
"\n" +
|
||||
"SELECT mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" mtb_colt.cod_tcol,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" SUM(num_cnf) AS num_cnf\n" +
|
||||
"FROM uds mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione AND mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
"GROUP BY mtb_colt.data_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colt.num_collo, cod_mdep, partita_mag,cod_mart, mtb_colt.cod_tcol\n", dtbDoct.getCodMdep(), whereCondColli)
|
||||
, UlVenditaDTO.class);
|
||||
|
||||
|
||||
//controllo che ci sia qualcosa da trasferire
|
||||
if (UtilityList.isNullOrEmpty(artsToTransfer)) {
|
||||
return null;
|
||||
String whereCondColli = StringUtils.join(dtbDoct.getMtbColt().stream().filter(x -> !x.getOperation().equals(OperationType.DELETE)).map(ul -> {
|
||||
try {
|
||||
return String.format("(%s)", ul.getPkWhereCond());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList()), " OR ");
|
||||
List<UlVenditaDTO> artsToTransfer;
|
||||
if (UtilityString.isNullOrEmpty(whereCondColli)) {
|
||||
artsToTransfer = new ArrayList<>();
|
||||
} else {
|
||||
artsToTransfer = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), Query.format("WITH uds AS (SELECT *\n" +
|
||||
" FROM mtb_colt\n" +
|
||||
" WHERE cod_mdep <> {}\n" +
|
||||
" AND (" + whereCondColli + "))\n" +
|
||||
"\n" +
|
||||
"SELECT mtb_colt.data_collo,\n" +
|
||||
" mtb_colt.ser_collo,\n" +
|
||||
" mtb_colt.gestione,\n" +
|
||||
" mtb_colt.num_collo,\n" +
|
||||
" cod_mdep,\n" +
|
||||
" cod_mart,\n" +
|
||||
" partita_mag,\n" +
|
||||
" mtb_colt.cod_tcol,\n" +
|
||||
" SUM(qta_col) AS qta_col,\n" +
|
||||
" SUM(num_cnf) AS num_cnf\n" +
|
||||
"FROM uds mtb_colt\n" +
|
||||
" INNER JOIN mtb_colr ON mtb_colt.gestione = mtb_colr.gestione AND mtb_colt.data_collo = mtb_colr.data_collo AND\n" +
|
||||
" mtb_colt.ser_collo = mtb_colr.ser_collo AND mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||
"GROUP BY mtb_colt.data_collo, mtb_colt.ser_collo, mtb_colt.gestione, mtb_colt.num_collo, cod_mdep, partita_mag,cod_mart, mtb_colt.cod_tcol\n", dtbDoct.getCodMdep(), whereCondColli)
|
||||
, UlVenditaDTO.class);
|
||||
if (artsToTransfer == null) artsToTransfer = new ArrayList<>();
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="raccolgo le info basi del nuovo documento">
|
||||
String codDtipTrasf = setupGest.getSetupDepo(multiDBTransactionManager.getPrimaryConnection(), "PICKING", "LOGISTICA", "COD_DTIP_DOC_TRASF_INTERNI", dtbDoct.getCodMdep());
|
||||
if (UtilityString.isNullOrEmpty(codDtipTrasf)) {
|
||||
throw new Exception("Le UL incluse nel documento richiedono un trasferimento di deposito, ma nessun tipo documento è stato configurato per il deposito di arrivo.");
|
||||
}
|
||||
MtbDepo mtbDepo = new MtbDepo();
|
||||
mtbDepo.setCodMdep(dtbDoct.getCodMdep())
|
||||
.setOperation(OperationType.SELECT_OBJECT);
|
||||
@@ -191,14 +190,18 @@ public class DocumentiDirettiService {
|
||||
dtbDoct.setActivityId(activityId);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
List<DtbDoct> docTrasfList = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),Query.format("SELECT cod_anag,data_doc,ser_doc,num_doc,cod_dtip from dtb_doct where activity_id = {} and cod_dtip = {} ", activityId, codDtipTrasf), DtbDoct.class);
|
||||
if (docTrasfList == null) docTrasfList = new ArrayList<>();
|
||||
docTrasfList =docTrasfList.stream().peek(x->x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
||||
|
||||
List<String> depositiPartenza = artsToTransfer.stream().map(UlVenditaDTO::getCodMdep).distinct().collect(Collectors.toList());
|
||||
for (String codMdep : depositiPartenza) {
|
||||
//<editor-fold desc="Controllo se esiste già un documento di trasferimento">
|
||||
DtbDoct docTrasf = null;
|
||||
|
||||
if (!isNewDoc) {
|
||||
String sql = Query.format("SELECT cod_anag,data_doc,ser_doc,num_doc,cod_dtip from dtb_doct where activity_id = {} and cod_dtip = {} and cod_mdep = {}", activityId, codDtipTrasf, codMdep);
|
||||
docTrasf = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, DtbDoct.class);
|
||||
docTrasf = docTrasfList.stream().filter(x->x.getCodMdep().equals(codMdep)).findFirst().orElse(null);
|
||||
if (docTrasf != null) {
|
||||
docTrasf.setOperation(OperationType.UPDATE);
|
||||
List<DtbDocr> oldDocRows = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), "SELECT * from dtb_docr where " + docTrasf.getPkWhereCond(), DtbDocr.class);
|
||||
@@ -217,6 +220,7 @@ public class DocumentiDirettiService {
|
||||
.setCodDtip(codDtipTrasf)
|
||||
.setActivityId(activityId);
|
||||
docTrasf.setOperation(OperationType.INSERT);
|
||||
docTrasfList.add(docTrasf);
|
||||
}
|
||||
//</editor-fold>
|
||||
//<editor-fold desc="Raggruppo le quantità da trasferire per deposito/articolo/partita">
|
||||
@@ -274,8 +278,8 @@ public class DocumentiDirettiService {
|
||||
docTrasf.setOperation(OperationType.DELETE);
|
||||
//</editor-fold>
|
||||
|
||||
entityList.add(docTrasf);
|
||||
}
|
||||
entityList.addAll(docTrasfList);
|
||||
|
||||
|
||||
return dtbDoct;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package it.integry.ems.utility.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.response.StatusResponse;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems.status.ServiceChecker;
|
||||
import it.integry.ems.utility.dto.C2EArgDTO;
|
||||
import it.integry.ems.utility.dto.PdfDTO;
|
||||
@@ -129,20 +131,22 @@ public class UtilityController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_READ_REMOTE_FILE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) {
|
||||
ServiceRestResponse response;
|
||||
try {
|
||||
if (body.has("url")) {
|
||||
String url = body.get("url").asText();
|
||||
response = ServiceRestResponse.createPositiveResponse(UtilityService.readRemoteFile(url));
|
||||
} else {
|
||||
throw new Exception("La proprieta' \"url\" non è presente nel json");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
response = ServiceRestResponse.createNegativeResponse();
|
||||
response.setErrorMessage(e.getMessage());
|
||||
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) throws Exception {
|
||||
if (body.has("url")) {
|
||||
String url = body.get("url").asText();
|
||||
|
||||
StringBuilder responseString = new StringBuilder();
|
||||
final int status = HttpRestWrapper.callGenericGet(url, null, null, responseString, null);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode node = mapper.readTree(responseString.toString());
|
||||
|
||||
boolean success = node.get("success").asBoolean();
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(success);
|
||||
} else {
|
||||
throw new Exception("La proprieta' \"url\" non è presente nel json");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_MIGRATE_GEOLOCATION_FOR_RLAVR, method = RequestMethod.GET)
|
||||
|
||||
Reference in New Issue
Block a user