|
|
|
@@ -18,6 +18,8 @@ import it.integry.ems_model.entity.*;
|
|
|
|
import it.integry.ems_model.service.SetupGest;
|
|
|
|
import it.integry.ems_model.service.SetupGest;
|
|
|
|
import it.integry.ems_model.types.OperationType;
|
|
|
|
import it.integry.ems_model.types.OperationType;
|
|
|
|
import it.integry.ems_model.utility.*;
|
|
|
|
import it.integry.ems_model.utility.*;
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.annotation.Scope;
|
|
|
|
import org.springframework.context.annotation.Scope;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@@ -31,11 +33,13 @@ import java.time.LocalDateTime;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
@Scope("request")
|
|
|
|
@Scope("request")
|
|
|
|
public class OrtoFruttaProductionService {
|
|
|
|
public class OrtoFruttaProductionService {
|
|
|
|
|
|
|
|
private final Logger logger = LogManager.getLogger();
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MultiDBTransactionManager multiDBTransactionManager;
|
|
|
|
private MultiDBTransactionManager multiDBTransactionManager;
|
|
|
|
@@ -128,8 +132,8 @@ public class OrtoFruttaProductionService {
|
|
|
|
String activityId = collo.getActivityId();
|
|
|
|
String activityId = collo.getActivityId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Genero se non esiste l'id attività
|
|
|
|
//Genero l'id attività se non esiste
|
|
|
|
if (activityId == null) {
|
|
|
|
if (UtilityString.isNullOrEmpty(activityId)) {
|
|
|
|
StbActivity activity = new StbActivity()
|
|
|
|
StbActivity activity = new StbActivity()
|
|
|
|
.setFlagTipologia("A")
|
|
|
|
.setFlagTipologia("A")
|
|
|
|
.setActivityTypeId("ACCETTAZIONE_DA_RACCOLTA")
|
|
|
|
.setActivityTypeId("ACCETTAZIONE_DA_RACCOLTA")
|
|
|
|
@@ -186,7 +190,8 @@ public class OrtoFruttaProductionService {
|
|
|
|
part
|
|
|
|
part
|
|
|
|
.setCodMart(dto.getCodMart())
|
|
|
|
.setCodMart(dto.getCodMart())
|
|
|
|
.setPartitaMag(dto.getPartitaRaccolta())
|
|
|
|
.setPartitaMag(dto.getPartitaRaccolta())
|
|
|
|
.setOperation(OperationType.NO_OP);
|
|
|
|
.setDescrizione(dto.getRagSocProduttore()+" - "+dto.getVarieta())
|
|
|
|
|
|
|
|
.setOperation(OperationType.INSERT_OR_UPDATE);
|
|
|
|
part.setMtbPartitaMagCarat(datiPartita);
|
|
|
|
part.setMtbPartitaMagCarat(datiPartita);
|
|
|
|
|
|
|
|
|
|
|
|
entityProcessor.processEntity(part, true, multiDBTransactionManager);
|
|
|
|
entityProcessor.processEntity(part, true, multiDBTransactionManager);
|
|
|
|
@@ -199,19 +204,6 @@ public class OrtoFruttaProductionService {
|
|
|
|
"SETUP",
|
|
|
|
"SETUP",
|
|
|
|
"SER_DOC_CAR");
|
|
|
|
"SER_DOC_CAR");
|
|
|
|
|
|
|
|
|
|
|
|
//todo: caso da gestire - cambio fornitore del documento
|
|
|
|
|
|
|
|
if (dto.getOriginal() != null && dto.isCertificatoEdited()) {
|
|
|
|
|
|
|
|
DtbDoct oldDoc = new DtbDoct();
|
|
|
|
|
|
|
|
oldDoc
|
|
|
|
|
|
|
|
.setCodAnag(dto.getOriginal().getCodAnag())
|
|
|
|
|
|
|
|
.setCodDtip(dto.getOriginal().getCodDtip())
|
|
|
|
|
|
|
|
.setDataDoc(UtilityLocalDate.localDateToDate(dto.getOriginal().getDataDoc()))
|
|
|
|
|
|
|
|
.setSerDoc(serDocLavCar)
|
|
|
|
|
|
|
|
.setNumDoc(dto.getOriginal().getNumDoc())
|
|
|
|
|
|
|
|
.setOperation(OperationType.DELETE);
|
|
|
|
|
|
|
|
entityProcessor.processEntity(oldDoc, true, multiDBTransactionManager);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DtbDoct docLav = new DtbDoct();
|
|
|
|
DtbDoct docLav = new DtbDoct();
|
|
|
|
docLav
|
|
|
|
docLav
|
|
|
|
.setCodDtip(UtilityString.isNull(dto.getCodDtip(), codDtipLavCar))
|
|
|
|
.setCodDtip(UtilityString.isNull(dto.getCodDtip(), codDtipLavCar))
|
|
|
|
@@ -234,7 +226,7 @@ public class OrtoFruttaProductionService {
|
|
|
|
.setOperation(OperationType.INSERT_OR_UPDATE);
|
|
|
|
.setOperation(OperationType.INSERT_OR_UPDATE);
|
|
|
|
|
|
|
|
|
|
|
|
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
|
|
|
entityProcessor.processEntity(docLav, true, multiDBTransactionManager);
|
|
|
|
UtilityEntity.throwEntityException(docLav);
|
|
|
|
|
|
|
|
DtbDocr rowsDocLav = new DtbDocr();
|
|
|
|
DtbDocr rowsDocLav = new DtbDocr();
|
|
|
|
rowsDocLav.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), docLav);
|
|
|
|
rowsDocLav.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(), docLav);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -246,6 +238,9 @@ public class OrtoFruttaProductionService {
|
|
|
|
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
|
|
|
.setNumDoc(EmsRestConstants.INTEGER_NULL)
|
|
|
|
.setSerDoc(EmsRestConstants.NULL)
|
|
|
|
.setSerDoc(EmsRestConstants.NULL)
|
|
|
|
.setCodDtip(EmsRestConstants.NULL)
|
|
|
|
.setCodDtip(EmsRestConstants.NULL)
|
|
|
|
|
|
|
|
.setDataOrd(UtilityLocalDate.localDateToDate(dto.getDataOrd()))
|
|
|
|
|
|
|
|
.setCodMdep(dto.getCodMdepProd())
|
|
|
|
|
|
|
|
.setNumOrd(dto.getNumOrd())
|
|
|
|
.setDataDocProvv(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()))
|
|
|
|
.setDataDocProvv(UtilityLocalDate.localDateToDate(dto.getDataDocProvv()))
|
|
|
|
.setNumDocProvv(dto.getNumDocProvv())
|
|
|
|
.setNumDocProvv(dto.getNumDocProvv())
|
|
|
|
.setCodDtipProvv(dto.getCodDtipProvv())
|
|
|
|
.setCodDtipProvv(dto.getCodDtipProvv())
|
|
|
|
@@ -260,20 +255,23 @@ public class OrtoFruttaProductionService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
collo.setDataVers(dto.getDataVers());
|
|
|
|
collo.setDataVers(dto.getDataVers());
|
|
|
|
|
|
|
|
MtbColr rowToEmpty = new MtbColr();
|
|
|
|
|
|
|
|
rowToEmpty.deleteAllEntities(multiDBTransactionManager.getPrimaryConnection(),collo);
|
|
|
|
MtbColr row = collo.getMtbColr().stream().filter(x -> x.getCodMart().equalsIgnoreCase(dto.getCodMart())).findFirst().orElse(new MtbColr());
|
|
|
|
MtbColr row = collo.getMtbColr().stream().filter(x -> x.getCodMart().equalsIgnoreCase(dto.getCodMart())).findFirst().orElse(new MtbColr());
|
|
|
|
if (row.getNumOrd() == null) {
|
|
|
|
if (row.getNumOrd() == null) {
|
|
|
|
collo.getMtbColr().add(row);
|
|
|
|
collo.getMtbColr().add(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
row
|
|
|
|
row
|
|
|
|
|
|
|
|
.setNumOrd(dto.getNumOrd())
|
|
|
|
|
|
|
|
.setDataOrd(UtilityLocalDate.localDateToDate(dto.getDataOrd()))
|
|
|
|
.setQtaCol(dto.getQtaCol())
|
|
|
|
.setQtaCol(dto.getQtaCol())
|
|
|
|
|
|
|
|
.setPartitaMag(dto.getPartitaRaccolta())
|
|
|
|
.setPesoNettoKg(dto.getPesoNettoPedane())
|
|
|
|
.setPesoNettoKg(dto.getPesoNettoPedane())
|
|
|
|
.setPesoLordoKg(dto.getPesoLordoCamion())
|
|
|
|
.setPesoLordoKg(dto.getPesoLordoCamion())
|
|
|
|
.setOperation(OperationType.INSERT_OR_UPDATE);
|
|
|
|
.setOperation(OperationType.INSERT_OR_UPDATE);
|
|
|
|
if (!UtilityBigDecimal.isNullOrZero(dto.getNumCnf()))
|
|
|
|
if (!UtilityBigDecimal.isNullOrZero(dto.getNumCnf()))
|
|
|
|
row.setNumCnf(dto.getNumCnf())
|
|
|
|
row.setNumCnf(dto.getNumCnf())
|
|
|
|
.setQtaCnf(dto.getQtaCol().divide(dto.getNumCnf(), 2, RoundingMode.HALF_UP));
|
|
|
|
.setQtaCnf(dto.getQtaCol().divide(dto.getNumCnf(), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
|
|
|
|
|
sql = "SELECT art_tcol.* from mtb_aart " +
|
|
|
|
sql = "SELECT art_tcol.* from mtb_aart " +
|
|
|
|
" inner join mtb_tcol on mtb_tcol.cod_tcol = mtb_aart.cod_tcol_UI " +
|
|
|
|
" inner join mtb_tcol on mtb_tcol.cod_tcol = mtb_aart.cod_tcol_UI " +
|
|
|
|
" inner join mtb_aart art_tcol on art_tcol.cod_mart = mtb_tcol.cod_mart " +
|
|
|
|
" inner join mtb_aart art_tcol on art_tcol.cod_mart = mtb_tcol.cod_mart " +
|
|
|
|
@@ -351,7 +349,6 @@ public class OrtoFruttaProductionService {
|
|
|
|
colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO().setCodMdep(posizione.getCodMdep()).setPosizione(posizione.getPosizione()));
|
|
|
|
colloDest = wmsLavorazioneService.createUDC(new CreateUDCRequestDTO().setCodMdep(posizione.getCodMdep()).setPosizione(posizione.getPosizione()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wmsGenericService.spostaArtsTraUL(collo, colloDest);
|
|
|
|
wmsGenericService.spostaArtsTraUL(collo, colloDest);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -426,14 +423,7 @@ public class OrtoFruttaProductionService {
|
|
|
|
"SETUP",
|
|
|
|
"SETUP",
|
|
|
|
"SER_DOC_SCAR");
|
|
|
|
"SER_DOC_SCAR");
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "SELECT riga_ord from dtb_ordr where gestione = " + UtilityDB.valueToString(dto.getGestione()) + " " +
|
|
|
|
String sql = Query.format("SELECT * from dtb_doct where cod_anag = %s AND cod_dtip = %s and activity_id = %s ", dto.getCodAnag(), codDtip, activityId);
|
|
|
|
" and data_ord =" + UtilityDB.valueToString(dataOrd) + " " +
|
|
|
|
|
|
|
|
"AND num_ord = " + UtilityDB.valueToString(dto.getNumOrd()) + " " +
|
|
|
|
|
|
|
|
"AND cod_mart = " + UtilityDB.valueToString(ordAcq.getDtbOrdr().get(0).getCodMart()) + " " +
|
|
|
|
|
|
|
|
"AND partita_mag = " + UtilityDB.valueToString(ordAcq.getDtbOrdr().get(0).getPartitaMag());
|
|
|
|
|
|
|
|
Integer rigaOrd = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql = Query.format("SELECT * from dtb_doct where cod_anag = %s AND cod_dtip = %s and activity_id = %s ", dto.getCodAnag(), codDtip, activityId);
|
|
|
|
|
|
|
|
PreparedStatement ps = multiDBTransactionManager.getPrimaryConnection().prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
|
|
PreparedStatement ps = multiDBTransactionManager.getPrimaryConnection().prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
|
|
DtbDoct slav = UtilityDB.executePreparedStatementDTOOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), ps, DtbDoct.class);
|
|
|
|
DtbDoct slav = UtilityDB.executePreparedStatementDTOOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), ps, DtbDoct.class);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -458,6 +448,15 @@ public class OrtoFruttaProductionService {
|
|
|
|
.setCodMdep(ordAcq.getCodMdep())
|
|
|
|
.setCodMdep(ordAcq.getCodMdep())
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql = "SELECT riga_ord from dtb_ordr where gestione = " + UtilityDB.valueToString(dto.getGestione()) + " " +
|
|
|
|
|
|
|
|
" and data_ord =" + UtilityDB.valueToString(dataOrd) + " " +
|
|
|
|
|
|
|
|
"AND num_ord = " + UtilityDB.valueToString(dto.getNumOrd()) + " " +
|
|
|
|
|
|
|
|
"AND cod_mart = " + UtilityDB.valueToString(ordAcq.getDtbOrdr().get(0).getCodMart()) + " " +
|
|
|
|
|
|
|
|
"AND partita_mag = " + UtilityDB.valueToString(ordAcq.getDtbOrdr().get(0).getPartitaMag());
|
|
|
|
|
|
|
|
Integer rigaOrd = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal qtaScarto = !UtilityBigDecimal.isNullOrZero(dto.getTassoRiduzione()) ? dto.getQtaCol().multiply(dto.getTassoRiduzione()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
|
|
|
BigDecimal qtaScarto = !UtilityBigDecimal.isNullOrZero(dto.getTassoRiduzione()) ? dto.getQtaCol().multiply(dto.getTassoRiduzione()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
|
|
|
BigDecimal qtaCnf = dto.getQtaCol().divide(dto.getNumCnf(), 3, RoundingMode.HALF_UP);
|
|
|
|
BigDecimal qtaCnf = dto.getQtaCol().divide(dto.getNumCnf(), 3, RoundingMode.HALF_UP);
|
|
|
|
BigDecimal qtaDoc = dto.getQtaCol().subtract(qtaScarto);
|
|
|
|
BigDecimal qtaDoc = dto.getQtaCol().subtract(qtaScarto);
|
|
|
|
@@ -487,15 +486,14 @@ public class OrtoFruttaProductionService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dto.getOriginal() != null && dto.isDDTEdited()) {
|
|
|
|
if (dto.getOriginal() != null && dto.isDDTEdited()) {
|
|
|
|
DtbDoct oldDoc = new DtbDoct();
|
|
|
|
String sql = Query.format("SELECT * from dtb_doct where cod_anag = %s AND cod_dtip = %s and activity_id = %s ", dto.getOriginal().getCodAnag(), dto.getOriginal().getCodDtipProvv(), activityId);
|
|
|
|
oldDoc
|
|
|
|
PreparedStatement ps = multiDBTransactionManager.getPrimaryConnection().prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
|
|
.setCodAnag(dto.getOriginal().getCodAnag())
|
|
|
|
DtbDoct oldDoc = UtilityDB.executePreparedStatementDTOOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), ps, DtbDoct.class);
|
|
|
|
.setCodDtip(dto.getOriginal().getCodDtipProvv())
|
|
|
|
|
|
|
|
.setDataDoc(UtilityLocalDate.localDateToDate(dto.getOriginal().getDataDocProvv()))
|
|
|
|
if (oldDoc != null) {
|
|
|
|
.setSerDoc(dto.getOriginal().getSerDocProvv())
|
|
|
|
oldDoc.setOperation(OperationType.DELETE);
|
|
|
|
.setNumDoc(dto.getOriginal().getNumDocProvv())
|
|
|
|
entityProcessor.processEntity(oldDoc, true, multiDBTransactionManager);
|
|
|
|
.setOperation(OperationType.DELETE);
|
|
|
|
}
|
|
|
|
entityProcessor.processEntity(oldDoc, true, multiDBTransactionManager);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sql = Query.format("SELECT * from dtb_doct where data_doc = %s and num_doc = %s AND ser_doc = %s and cod_anag = %s AND cod_dtip = %s and activity_id = %s ",
|
|
|
|
String sql = Query.format("SELECT * from dtb_doct where data_doc = %s and num_doc = %s AND ser_doc = %s and cod_anag = %s AND cod_dtip = %s and activity_id = %s ",
|
|
|
|
@@ -609,6 +607,16 @@ public class OrtoFruttaProductionService {
|
|
|
|
|
|
|
|
|
|
|
|
//controllo versamenti certificato
|
|
|
|
//controllo versamenti certificato
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkVersamenti(activityId);
|
|
|
|
|
|
|
|
deleteDocumentiEntrata(activityId);
|
|
|
|
|
|
|
|
deleteCaratEntrata(activityId);
|
|
|
|
|
|
|
|
deleteColliEntrata(activityId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return collo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkVersamenti(String activityId) throws Exception {
|
|
|
|
String checkVersamentiSql = Query.format("SELECT count(distinct mtb_colr.num_collo) as nVersamenti\n" +
|
|
|
|
String checkVersamentiSql = Query.format("SELECT count(distinct mtb_colr.num_collo) as nVersamenti\n" +
|
|
|
|
"FROM mtb_colt collo\n" +
|
|
|
|
"FROM mtb_colt collo\n" +
|
|
|
|
" inner JOIN mtb_colr\n" +
|
|
|
|
" inner JOIN mtb_colr\n" +
|
|
|
|
@@ -622,17 +630,41 @@ public class OrtoFruttaProductionService {
|
|
|
|
|
|
|
|
|
|
|
|
if (!UtilityInteger.isNullOrZero(nVersamenti))
|
|
|
|
if (!UtilityInteger.isNullOrZero(nVersamenti))
|
|
|
|
throw new Exception("Non è consentito eliminare un certificato già versato, correggere gli scarichi e riprovare!");
|
|
|
|
throw new Exception("Non è consentito eliminare un certificato già versato, correggere gli scarichi e riprovare!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteDocumentiEntrata(String activityId) throws Exception {
|
|
|
|
List<DtbDoct> docs = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
List<DtbDoct> docs = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
Query.format("SELECT * from dtb_doct where activity_id = {}", activityId),
|
|
|
|
Query.format("SELECT * from dtb_doct where activity_id = {}", activityId),
|
|
|
|
DtbDoct.class);
|
|
|
|
DtbDoct.class);
|
|
|
|
|
|
|
|
|
|
|
|
if (!UtilityList.isNullOrEmpty(docs)) {
|
|
|
|
if (!UtilityList.isNullOrEmpty(docs)) {
|
|
|
|
docs = docs.stream().peek(x -> x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
|
|
|
docs = docs.stream().peek(x -> x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
|
|
|
entityProcessor.processEntityList(docs, true);
|
|
|
|
entityProcessor.processEntityList(docs, multiDBTransactionManager,true);
|
|
|
|
UtilityEntity.throwEntitiesException(docs);
|
|
|
|
UtilityEntity.throwEntitiesException(docs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteCaratEntrata(String activityId) throws Exception {
|
|
|
|
|
|
|
|
List<MtbPartitaMagCarat> carats = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
|
|
|
|
Query.format("SELECT * from mtb_partita_mag_carat where activity_id = {}", activityId),
|
|
|
|
|
|
|
|
MtbPartitaMagCarat.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//todo: usare mtbPartitaMag come contenitore per
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!UtilityList.isNullOrEmpty(carats)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
carats = carats.stream().peek(x -> x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
MtbPartitaMag partita = new MtbPartitaMag();
|
|
|
|
|
|
|
|
partita.setCodMart(carats.get(0).getCodMart())
|
|
|
|
|
|
|
|
.setPartitaMag(carats.get(0).getPartitaMag())
|
|
|
|
|
|
|
|
.setMtbPartitaMagCarat(carats)
|
|
|
|
|
|
|
|
.setOperation(OperationType.UPDATE);
|
|
|
|
|
|
|
|
entityProcessor.processEntity(partita, true,multiDBTransactionManager);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteColliEntrata(String activityId) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
List<MtbColt> colts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
List<MtbColt> colts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
Query.format("SELECT * from mtb_colt where activity_id = {}", activityId),
|
|
|
|
Query.format("SELECT * from mtb_colt where activity_id = {}", activityId),
|
|
|
|
@@ -644,16 +676,46 @@ public class OrtoFruttaProductionService {
|
|
|
|
UtilityEntity.throwEntitiesException(colts);
|
|
|
|
UtilityEntity.throwEntitiesException(colts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<MtbPartitaMagCarat> carats = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
|
|
|
}
|
|
|
|
Query.format("SELECT * from mtb_colt where activity_id = {}", activityId),
|
|
|
|
|
|
|
|
MtbPartitaMagCarat.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!UtilityList.isNullOrEmpty(carats)) {
|
|
|
|
|
|
|
|
carats = carats.stream().peek(x -> x.setOperation(OperationType.DELETE)).collect(Collectors.toList());
|
|
|
|
public AccettazioneOrtoFruttaDTO accettazioneCambioLotto(AccettazioneOrtoFruttaDTO dto) throws Exception {
|
|
|
|
entityProcessor.processEntityList(carats, true);
|
|
|
|
String activityId = dto.getActivityId();
|
|
|
|
UtilityEntity.throwEntitiesException(carats);
|
|
|
|
if (UtilityString.isNullOrEmpty(activityId)) {
|
|
|
|
|
|
|
|
String sql = Query.format("SELECT activity_id from mtb_colt where data_collo = {} and ser_collo = {} and num_collo = {} and gestione = {}", dto.getDataCollo(), dto.getSerCollo(), dto.getNumCollo(), dto.getGestione());
|
|
|
|
|
|
|
|
activityId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UtilityString.isNullOrEmpty(activityId))
|
|
|
|
|
|
|
|
throw new Exception("Dati incompleti per la cencellazione del certificato!");
|
|
|
|
|
|
|
|
|
|
|
|
return collo;
|
|
|
|
deleteDocumentiEntrata(activityId);
|
|
|
|
|
|
|
|
deleteCaratEntrata(activityId);
|
|
|
|
|
|
|
|
accettazioneDaRaccolta(dto);
|
|
|
|
|
|
|
|
updateVersamenti(dto);
|
|
|
|
|
|
|
|
return dto;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateVersamenti(AccettazioneOrtoFruttaDTO dto) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sql = Query.format("SELECT * from mtb_colr where data_collo_rif = {} and ser_collo_rif = {} and num_collo_rif = {} and gestione_rif = {}", dto.getDataCollo(), dto.getSerCollo(), dto.getNumCollo(), dto.getGestione());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MtbColr> righeScarichi = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColr.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (UtilityList.isNullOrEmpty(righeScarichi)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
righeScarichi.stream().peek(x -> x.setPartitaMag(dto.getPartitaMag()).setCodMart(dto.getCodMart()).setOperation(OperationType.UPDATE)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<MtbColt, List<MtbColr>> mapScarichi = righeScarichi.stream().collect(Collectors.groupingBy(MtbColt::fromMtbColr));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MtbColt> scarichi = mapScarichi.keySet().stream().peek(x -> {
|
|
|
|
|
|
|
|
x.getMtbColr().addAll(mapScarichi.get(x));
|
|
|
|
|
|
|
|
x.setOperation(OperationType.UPDATE);
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entityProcessor.processEntityList(scarichi, true);
|
|
|
|
|
|
|
|
UtilityEntity.throwEntitiesException(scarichi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|