Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240729095756 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
if(isCustomer(IntegryCustomer.Frudis)) {
|
||||
updateSetupValue("w_aelefor_disp", "DATAWINDOW", "d_aschforfor_rep", "D_ASCHFORFOR_REP_frudis");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
@@ -92,13 +94,26 @@ public class UtilityZip {
|
||||
return zipOutputStream;
|
||||
}
|
||||
|
||||
|
||||
public static void addFileToArchive(ZipOutputStream zipOutputStream, String fileName, byte[] content) throws IOException {
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
|
||||
zipEntry.setSize(content.length);
|
||||
|
||||
zipOutputStream.putNextEntry(zipEntry);
|
||||
zipOutputStream.write(content);
|
||||
zipOutputStream.closeEntry();
|
||||
boolean fileAddedToZip = false;
|
||||
int retries = 0;
|
||||
do {
|
||||
try {
|
||||
if (retries > 0)
|
||||
fileName = FilenameUtils.getBaseName(fileName) + "_" + retries+"." + FilenameUtils.getExtension(fileName);
|
||||
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||
zipEntry.setSize(content.length);
|
||||
zipOutputStream.putNextEntry(zipEntry);
|
||||
zipOutputStream.write(content);
|
||||
zipOutputStream.closeEntry();
|
||||
fileAddedToZip = true;
|
||||
} catch (ZipException e) {
|
||||
if (!e.getMessage().startsWith("duplicate entry:"))
|
||||
throw e;
|
||||
} finally {
|
||||
retries++;
|
||||
}
|
||||
} while (!fileAddedToZip && retries < 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1276,6 +1276,7 @@ public class ProductionPlanService {
|
||||
" CASE\n" +
|
||||
" WHEN ms.descrizione = 'BUSTE' THEN 'BAG'\n" +
|
||||
" WHEN ms.descrizione = 'CESTINI' THEN 'PUNNET'\n" +
|
||||
" ELSE 'CARTON'\n" +
|
||||
" END AS type,\n" +
|
||||
// " ma.tara_kg AS weight_kg,\n" +
|
||||
" ma.note,\n" +
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package it.integry.ems.production.agribook;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.production.agribook.model.AgribookNewFieldRequestDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,12 +27,23 @@ public class AgribookFieldController {
|
||||
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse retreiveFields(HttpServletRequest request,
|
||||
@RequestParam(required = false) String codMdep) {
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(agribookFieldService.retrieveFields(codMdep));
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestParam(required = false) String codMdep) throws Exception {
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);) {
|
||||
return ServiceRestResponse.createPositiveResponse(agribookFieldService.retrieveFields(internalDb,codMdep));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "new", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse createField(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestBody AgribookNewFieldRequestDTO dto
|
||||
|
||||
) throws Exception {
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);) {
|
||||
return ServiceRestResponse.createPositiveResponse(agribookFieldService.createField(internalDb, dto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,172 @@
|
||||
package it.integry.ems.production.agribook;
|
||||
|
||||
import it.integry.ems.production.agribook.model.AgribookFieldDTO;
|
||||
import it.integry.ems.production.agribook.model.AgribookNewFieldRequestDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.MtbDepoPosizioni;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xlsx4j.sml.Col;
|
||||
|
||||
import javax.rmi.CORBA.Util;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.time.DayOfWeek;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class AgribookFieldService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
public List<AgribookFieldDTO> retrieveFields(String codMdep) throws Exception {
|
||||
public List<AgribookFieldDTO> retrieveFields(MultiDBTransactionManager multiDBTransactionManager,String codMdep) throws Exception {
|
||||
|
||||
String sql = "SELECT * FROM " + MtbDepoPosizioni.ENTITY;
|
||||
|
||||
if(!UtilityString.isNullOrEmpty(codMdep)) sql += " WHERE cod_mdep = " + UtilityDB.valueToString(codMdep);
|
||||
if (!UtilityString.isNullOrEmpty(codMdep)) sql += " WHERE cod_mdep = " + UtilityDB.valueToString(codMdep);
|
||||
|
||||
sql += " ORDER BY descrizione";
|
||||
|
||||
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, AgribookFieldDTO.class);
|
||||
}
|
||||
|
||||
public List<EntityBase> createField(MultiDBTransactionManager connection, AgribookNewFieldRequestDTO dto) throws Exception {
|
||||
|
||||
List<EntityBase> entityList = new ArrayList<>();
|
||||
String codVdes = UtilityString.isNull(dto.getCodVdes(), this.suggestCodVdes(connection,dto.getCodAnag()));
|
||||
if (dto.isNewDes()) {
|
||||
if (UtilityString.isNullOrEmpty(codVdes)) {
|
||||
throw new Exception("Impossibile calcolare il codice destinatario!");
|
||||
}
|
||||
|
||||
VtbDest vtbDest = new VtbDest();
|
||||
vtbDest
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setCodVdes(codVdes)
|
||||
.setDestinatario(dto.getDestinatario())
|
||||
.setIndirizzo(dto.getIndirizzo())
|
||||
.setCap(dto.getCap())
|
||||
.setCitta(dto.getCitta())
|
||||
.setProv(dto.getProv())
|
||||
.setNazione("IT")
|
||||
.setLat(dto.getLat())
|
||||
.setLng(dto.getLng())
|
||||
.setPartIva(dto.getPartIva())
|
||||
.setRagSocLegale(dto.getRagSocLegale())
|
||||
.setCodFiscLegale(dto.getCodFiscLegale())
|
||||
.setPartIvaLegale(dto.getPartIvaLegale())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
GtbAnag gtbanag = new GtbAnag();
|
||||
gtbanag.setCodAnag(dto.getCodAnag())
|
||||
.setVtbDest(Collections.singletonList(vtbDest))
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityList.add(gtbanag);
|
||||
}
|
||||
|
||||
String codMdepDest = this.getCodMdepDest(connection, dto.getCodAnag(), codVdes);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codMdepDest)) {
|
||||
codMdepDest = this.suggestCodMdep(connection,dto.getCodAnag(), codVdes);
|
||||
if (UtilityString.isNullOrEmpty(codMdepDest)) {
|
||||
throw new Exception("Codice nuovo deposito calcolato non valido");
|
||||
}
|
||||
|
||||
MtbDepo mtbDepo = new MtbDepo();
|
||||
mtbDepo
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setCodVdes(codVdes)
|
||||
.setCodMdep(codMdepDest)
|
||||
.setDescrizione(dto.getDestinatario())
|
||||
.setDatiCatastali(dto.getDatiCatastali())
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
entityList.add(mtbDepo);
|
||||
}
|
||||
|
||||
MtbPartitaMag partitaMag = new MtbPartitaMag();
|
||||
partitaMag
|
||||
.setCodMart(dto.getCodMart())
|
||||
.setPartitaMag(dto.getPartitaMag())
|
||||
.setDescrizione(dto.getDestinatario())
|
||||
.setNote(dto.getNote())
|
||||
.setQtaAttesa(dto.getQtaAttesa())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(dto.getVarieta())) {
|
||||
MtbPartitaMagCarat carat = this.getVarieta(connection,dto.getCodMart(),dto.getPartitaMag());
|
||||
if (carat == null) {
|
||||
carat = new MtbPartitaMagCarat();
|
||||
carat.setCarat("VARIETA");
|
||||
}
|
||||
carat
|
||||
.setValCarat(dto.getVarieta())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
partitaMag.setMtbPartitaMagCarat(Collections.singletonList(carat));
|
||||
|
||||
}
|
||||
|
||||
entityList.add(partitaMag);
|
||||
|
||||
|
||||
|
||||
DtbOrdr ordr = new DtbOrdr();
|
||||
ordr.setCodMart(dto.getCodMart())
|
||||
.setUntOrd(dto.getUntMis())
|
||||
.setQtaOrd(dto.getQtaAttesa())
|
||||
.setValUnt(dto.getValUnt())
|
||||
.setPartitaMag(dto.getPartitaMag())
|
||||
.setCodMdep(codMdepDest)
|
||||
.setDataCons(UtilityLocalDate.localDateToDate(dto.getDataInizProd().with(DayOfWeek.MONDAY)))
|
||||
.setOperation(OperationType.INSERT);
|
||||
DtbOrdt ordt = new DtbOrdt();
|
||||
ordt
|
||||
.setGestione("A")
|
||||
.setDataOrd(UtilityLocalDate.localDateToDate(dto.getDataOrd()))
|
||||
.setNumOrd(0)
|
||||
.setCodAnag(dto.getCodAnag())
|
||||
.setCodMdep(codMdepDest)
|
||||
.setCodVdes(codVdes)
|
||||
.setDataInizProd(UtilityLocalDate.localDateToDate(dto.getDataInizProd()))
|
||||
.setDtbOrdr(Collections.singletonList(ordr))
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
entityList.add(ordt);
|
||||
return entityProcessor.processEntityList(entityList, connection, true);
|
||||
|
||||
}
|
||||
|
||||
private MtbPartitaMagCarat getVarieta(MultiDBTransactionManager connection,String codMart, String partitaMag) throws Exception {
|
||||
String sql = "SELECT * FROM " + MtbPartitaMagCarat.ENTITY+" Where cod_mart = "+UtilityDB.valueToString(codMart)+" and partita_mag = "+UtilityDB.valueToString(partitaMag)+" AND carat = 'VARIETA'";
|
||||
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection.getPrimaryConnection(),sql,MtbPartitaMagCarat.class);
|
||||
}
|
||||
|
||||
private String suggestCodMdep(MultiDBTransactionManager multiDBTransactionManager,String codAnag, String codVdes) throws Exception {
|
||||
String sql = "SELECT dbo.f_suggestCodeCodMdep("+UtilityDB.valueToString(codAnag)+","+UtilityDB.valueToString(codVdes)+") AS cod_mdep";
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),sql);
|
||||
}
|
||||
|
||||
private String getCodMdepDest(MultiDBTransactionManager multiDBTransactionManager, String codAnag, String codVdes) throws Exception {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"SELECT cod_mdep from mtb_depo where " +
|
||||
" cod_anag = " + UtilityDB.valueToString(codAnag) + " " +
|
||||
" and cod_vdes = " + UtilityDB.valueToString(codVdes));
|
||||
}
|
||||
|
||||
private String suggestCodVdes(MultiDBTransactionManager multiDBTransactionManager,String codAnag) throws Exception {
|
||||
String sql = "SELECT dbo.f_suggestCodeCodVdes("+UtilityDB.valueToString(codAnag)+", 0) AS cod_vdes";
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(),sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -40,8 +41,8 @@ public class AgribookOrderAttachmentController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@PathVariable("codMart") String codMart,
|
||||
@PathVariable("partitaMag") String partitaMag,
|
||||
@RequestParam(value = "mediaType", required = false) String mediaType) {
|
||||
try {
|
||||
@RequestParam(value = "mediaType", required = false) String mediaType) throws Exception {
|
||||
|
||||
if (mediaType != null &&
|
||||
!UtilityString.equalsIgnoreCase(mediaType, "document") &&
|
||||
!UtilityString.equalsIgnoreCase(mediaType, "media")) {
|
||||
@@ -50,10 +51,7 @@ public class AgribookOrderAttachmentController {
|
||||
|
||||
List<AgribookOrderAttachmentDTO> agribookOrderAttachmentList = agribookOrderAttachmentService.retrieveByOrder(codMart, partitaMag, mediaType);
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderAttachmentList);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +62,8 @@ public class AgribookOrderAttachmentController {
|
||||
@PathVariable("codMart") String codMart,
|
||||
@PathVariable("partitaMag") String partitaMag,
|
||||
@RequestParam(value = "datetimeAttach", required = false) String datetimeAttach,
|
||||
@RequestPart() MultipartFile[] files) {
|
||||
try {
|
||||
@RequestPart() MultipartFile[] files) throws Exception {
|
||||
|
||||
if (files == null || files.length == 0) {
|
||||
throw new Exception("Nessun file è stato rilevato");
|
||||
}
|
||||
@@ -103,10 +101,7 @@ public class AgribookOrderAttachmentController {
|
||||
|
||||
|
||||
return ServiceRestResponse.createEntityPositiveResponse(resultData);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,13 +42,10 @@ public class AgribookOrderController {
|
||||
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse retrieveOrders(HttpServletRequest request,
|
||||
@RequestParam(required = false) Integer year) {
|
||||
try {
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.retrieveOrders(year));
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
@RequestParam(required = false) Integer year) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.retrieveOrders(year));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,20 +54,17 @@ public class AgribookOrderController {
|
||||
ServiceRestResponse updatePercClassi(HttpServletRequest request,
|
||||
@RequestParam String codMart,
|
||||
@RequestParam String partitaMag,
|
||||
@RequestBody AgribookUpdatePercClassiRequestDTO updatePercClassiRequestDTO) {
|
||||
try {
|
||||
agribookOrderService.updatePercClassi(
|
||||
codMart,
|
||||
partitaMag,
|
||||
updatePercClassiRequestDTO.getPercClasse1(),
|
||||
updatePercClassiRequestDTO.getPercClasse2(),
|
||||
updatePercClassiRequestDTO.getPercClassePremium());
|
||||
@RequestBody AgribookUpdatePercClassiRequestDTO updatePercClassiRequestDTO) throws Exception {
|
||||
|
||||
agribookOrderService.updatePercClassi(
|
||||
codMart,
|
||||
partitaMag,
|
||||
updatePercClassiRequestDTO.getPercClasse1(),
|
||||
updatePercClassiRequestDTO.getPercClasse2(),
|
||||
updatePercClassiRequestDTO.getPercClassePremium());
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveQtaResidua", method = RequestMethod.POST)
|
||||
@@ -78,19 +72,16 @@ public class AgribookOrderController {
|
||||
ServiceRestResponse saveQtaResidua(HttpServletRequest request,
|
||||
@RequestParam String codMart,
|
||||
@RequestParam String partitaMag,
|
||||
@RequestBody AgribookSaveQtaResiduaRequestDTO saveQtaResiduaDTO) {
|
||||
try {
|
||||
agribookOrderService.saveQtaResidua(
|
||||
codMart, partitaMag,
|
||||
saveQtaResiduaDTO.getCodAnag(),
|
||||
saveQtaResiduaDTO.getCodVdes(),
|
||||
saveQtaResiduaDTO.getQtaOrd());
|
||||
@RequestBody AgribookSaveQtaResiduaRequestDTO saveQtaResiduaDTO) throws Exception {
|
||||
|
||||
agribookOrderService.saveQtaResidua(
|
||||
codMart, partitaMag,
|
||||
saveQtaResiduaDTO.getCodAnag(),
|
||||
saveQtaResiduaDTO.getCodVdes(),
|
||||
saveQtaResiduaDTO.getQtaOrd());
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "savePiantePartita", method = RequestMethod.POST)
|
||||
@@ -100,169 +91,157 @@ public class AgribookOrderController {
|
||||
@RequestParam String partitaMag,
|
||||
@RequestParam String codAnag,
|
||||
@RequestParam(required = false) String codVdes,
|
||||
@RequestParam int piantePartita) {
|
||||
try {
|
||||
agribookOrderService.savePiantePartita(codMart, partitaMag, codAnag, codVdes, piantePartita);
|
||||
@RequestParam int piantePartita) throws Exception {
|
||||
|
||||
agribookOrderService.savePiantePartita(codMart, partitaMag, codAnag, codVdes, piantePartita);
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createPositiveResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "syncQtaPrevRacc", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse syncQtaPrevRacc(HttpServletRequest request) {
|
||||
try {
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.syncQtaPrevRacc());
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
ServiceRestResponse syncQtaPrevRacc(HttpServletRequest request) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.syncQtaPrevRacc());
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "syncQtaResidua", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse syncQtaResidua(HttpServletRequest request) {
|
||||
try {
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.syncQtaResidua(null));
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
}
|
||||
ServiceRestResponse syncQtaResidua(HttpServletRequest request) throws Exception {
|
||||
|
||||
return ServiceRestResponse.createEntityPositiveResponse(agribookOrderService.syncQtaResidua(null));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "importCoordsTest", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importCoordsTest(HttpServletRequest request, @RequestParam String csvPath) {
|
||||
try {
|
||||
|
||||
File fileToImport = new File(csvPath);
|
||||
|
||||
List<String> lines = UtilityFile.readLinesFromFile(fileToImport);
|
||||
|
||||
List<AgribookImportCoordsTestCSVDTO> importedLines = Stream.of(lines)
|
||||
.skip(1)
|
||||
.filter(x -> x.split(";").length > 0)
|
||||
.map(x -> {
|
||||
AgribookImportCoordsTestCSVDTO importt = new AgribookImportCoordsTestCSVDTO();
|
||||
|
||||
String[] columns = x.split(";", -1);
|
||||
importt.setPartitaMag(columns[0])
|
||||
.setLat(UtilityString.isNullOrEmpty(columns[1]) ? null : new BigDecimal(columns[1]))
|
||||
.setLng(UtilityString.isNullOrEmpty(columns[2]) ? null : new BigDecimal(columns[2]))
|
||||
.setVarieta(columns[3])
|
||||
.setNomeDeposito(columns[4])
|
||||
.setNomeProduttore(columns[5])
|
||||
.setComune(columns[6]);
|
||||
|
||||
return importt;
|
||||
})
|
||||
.toList();
|
||||
ServiceRestResponse importCoordsTest(HttpServletRequest request, @RequestParam String csvPath) throws Exception {
|
||||
|
||||
|
||||
List<AgribookOrderDTO> orders = agribookOrderService.retrieveOrders(2022);
|
||||
File fileToImport = new File(csvPath);
|
||||
|
||||
for (AgribookImportCoordsTestCSVDTO importData : importedLines) {
|
||||
AgribookOrderDTO matchOrder = Stream.of(orders)
|
||||
.filter(x -> x.getPartitaMag().equalsIgnoreCase(importData.getPartitaMag()))
|
||||
.findFirst().orElse(null);
|
||||
List<String> lines = UtilityFile.readLinesFromFile(fileToImport);
|
||||
|
||||
if (matchOrder != null) {
|
||||
importData.setMatchOrder(matchOrder);
|
||||
} else throw new Exception("No one order match");
|
||||
}
|
||||
List<AgribookImportCoordsTestCSVDTO> importedLines = Stream.of(lines)
|
||||
.skip(1)
|
||||
.filter(x -> x.split(";").length > 0)
|
||||
.map(x -> {
|
||||
AgribookImportCoordsTestCSVDTO importt = new AgribookImportCoordsTestCSVDTO();
|
||||
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
EntityProcessor entityProcessor = ContextLoader.getCurrentWebApplicationContext().getBean(EntityProcessor.class);
|
||||
UtilityService utilityService = ContextLoader.getCurrentWebApplicationContext().getBean(UtilityService.class);
|
||||
String[] columns = x.split(";", -1);
|
||||
importt.setPartitaMag(columns[0])
|
||||
.setLat(UtilityString.isNullOrEmpty(columns[1]) ? null : new BigDecimal(columns[1]))
|
||||
.setLng(UtilityString.isNullOrEmpty(columns[2]) ? null : new BigDecimal(columns[2]))
|
||||
.setVarieta(columns[3])
|
||||
.setNomeDeposito(columns[4])
|
||||
.setNomeProduttore(columns[5])
|
||||
.setComune(columns[6]);
|
||||
|
||||
List<MtbDepoPosizioni> mtbDepoPosizioni =
|
||||
UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), "SELECT * FROM mtb_depo_posizioni", MtbDepoPosizioni.class);
|
||||
return importt;
|
||||
})
|
||||
.toList();
|
||||
|
||||
|
||||
final List<Map.Entry<HashMap<String, BigDecimal>, List<AgribookImportCoordsTestCSVDTO>>> entries = Stream.of(importedLines)
|
||||
.filter(x -> x.getLat() != null && x.getLng() != null)
|
||||
.groupBy(x -> {
|
||||
HashMap<String, BigDecimal> coords = new HashMap<>();
|
||||
coords.put("lat", x.getLat());
|
||||
coords.put("lng", x.getLng());
|
||||
return coords;
|
||||
})
|
||||
.toList();
|
||||
List<AgribookOrderDTO> orders = agribookOrderService.retrieveOrders(2022);
|
||||
|
||||
for (Map.Entry<HashMap<String, BigDecimal>, List<AgribookImportCoordsTestCSVDTO>> x : entries) {
|
||||
for (AgribookImportCoordsTestCSVDTO importData : importedLines) {
|
||||
AgribookOrderDTO matchOrder = Stream.of(orders)
|
||||
.filter(x -> x.getPartitaMag().equalsIgnoreCase(importData.getPartitaMag()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
String codMdep = x.getValue().get(0).getMatchOrder().getCodMdep();
|
||||
BigDecimal lat = x.getValue().get(0).getLat();
|
||||
BigDecimal lng = x.getValue().get(0).getLng();
|
||||
if (matchOrder != null) {
|
||||
importData.setMatchOrder(matchOrder);
|
||||
} else throw new Exception("No one order match");
|
||||
}
|
||||
|
||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||
EntityProcessor entityProcessor = ContextLoader.getCurrentWebApplicationContext().getBean(EntityProcessor.class);
|
||||
UtilityService utilityService = ContextLoader.getCurrentWebApplicationContext().getBean(UtilityService.class);
|
||||
|
||||
List<MtbDepoPosizioni> mtbDepoPosizioni =
|
||||
UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), "SELECT * FROM mtb_depo_posizioni", MtbDepoPosizioni.class);
|
||||
|
||||
|
||||
final List<Map.Entry<HashMap<String, BigDecimal>, List<AgribookImportCoordsTestCSVDTO>>> entries = Stream.of(importedLines)
|
||||
.filter(x -> x.getLat() != null && x.getLng() != null)
|
||||
.groupBy(x -> {
|
||||
HashMap<String, BigDecimal> coords = new HashMap<>();
|
||||
coords.put("lat", x.getLat());
|
||||
coords.put("lng", x.getLng());
|
||||
return coords;
|
||||
})
|
||||
.toList();
|
||||
|
||||
for (Map.Entry<HashMap<String, BigDecimal>, List<AgribookImportCoordsTestCSVDTO>> x : entries) {
|
||||
|
||||
String codMdep = x.getValue().get(0).getMatchOrder().getCodMdep();
|
||||
BigDecimal lat = x.getValue().get(0).getLat();
|
||||
BigDecimal lng = x.getValue().get(0).getLng();
|
||||
|
||||
// //Creazione posizione con coords
|
||||
IndirizzoDTO indirizzoDTO = utilityService.getPositionFromCoords(lat, lng);
|
||||
IndirizzoDTO indirizzoDTO = utilityService.getPositionFromCoords(lat, lng);
|
||||
|
||||
|
||||
MtbDepoPosizioni matchPosizione = Stream.of(mtbDepoPosizioni)
|
||||
.filter(y -> y.getCodMdep().equalsIgnoreCase(codMdep) &&
|
||||
Objects.equals(y.getIdPosizione(), indirizzoDTO.getIdPosizione()))
|
||||
.findFirst().orElse(null);
|
||||
MtbDepoPosizioni matchPosizione = Stream.of(mtbDepoPosizioni)
|
||||
.filter(y -> y.getCodMdep().equalsIgnoreCase(codMdep) &&
|
||||
Objects.equals(y.getIdPosizione(), indirizzoDTO.getIdPosizione()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
AtomicReference<String> atomicCodCampo = new AtomicReference<>();
|
||||
AtomicReference<String> atomicDescrCampo = new AtomicReference<>();
|
||||
AtomicReference<String> atomicCodCampo = new AtomicReference<>();
|
||||
AtomicReference<String> atomicDescrCampo = new AtomicReference<>();
|
||||
|
||||
if (matchPosizione == null) {
|
||||
if (matchPosizione == null) {
|
||||
|
||||
int counter = 1;
|
||||
int counter = 1;
|
||||
|
||||
do {
|
||||
atomicCodCampo.set(codMdep + "_G" + String.format("%02d", counter));
|
||||
atomicDescrCampo.set("GEOPOINT " + String.format("%02d", counter++));
|
||||
} while (mtbDepoPosizioni.stream().anyMatch(y -> y.getPosizione().equalsIgnoreCase(atomicCodCampo.get())));
|
||||
do {
|
||||
atomicCodCampo.set(codMdep + "_G" + String.format("%02d", counter));
|
||||
atomicDescrCampo.set("GEOPOINT " + String.format("%02d", counter++));
|
||||
} while (mtbDepoPosizioni.stream().anyMatch(y -> y.getPosizione().equalsIgnoreCase(atomicCodCampo.get())));
|
||||
|
||||
|
||||
matchPosizione = new MtbDepoPosizioni()
|
||||
.setCodMdep(codMdep)
|
||||
.setPosizione(atomicCodCampo.get())
|
||||
.setDescrizione(atomicDescrCampo.get())
|
||||
.setIdPosizione(indirizzoDTO.getIdPosizione());
|
||||
matchPosizione.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
matchPosizione = new MtbDepoPosizioni()
|
||||
.setCodMdep(codMdep)
|
||||
.setPosizione(atomicCodCampo.get())
|
||||
.setDescrizione(atomicDescrCampo.get())
|
||||
.setIdPosizione(indirizzoDTO.getIdPosizione());
|
||||
matchPosizione.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
MtbDepo mtbDepo = new MtbDepo()
|
||||
.setCodMdep(codMdep)
|
||||
.setMtbDepoPosizioni(new ArrayList<>());
|
||||
mtbDepo.setOperation(OperationType.NO_OP);
|
||||
mtbDepo.getMtbDepoPosizioni().add(matchPosizione);
|
||||
entityProcessor.processEntity(mtbDepo, true, multiDBTransactionManager);
|
||||
MtbDepo mtbDepo = new MtbDepo()
|
||||
.setCodMdep(codMdep)
|
||||
.setMtbDepoPosizioni(new ArrayList<>());
|
||||
mtbDepo.setOperation(OperationType.NO_OP);
|
||||
mtbDepo.getMtbDepoPosizioni().add(matchPosizione);
|
||||
entityProcessor.processEntity(mtbDepo, true, multiDBTransactionManager);
|
||||
|
||||
mtbDepoPosizioni.add(matchPosizione);
|
||||
mtbDepoPosizioni.add(matchPosizione);
|
||||
}
|
||||
|
||||
for (AgribookImportCoordsTestCSVDTO coord : x.getValue()) {
|
||||
if (coord.getMatchOrder().getMtbPartitaMag() != null) {
|
||||
MtbPartitaMag partitaMagToUpdate = (MtbPartitaMag) coord.getMatchOrder().getMtbPartitaMag();
|
||||
|
||||
partitaMagToUpdate.setPosizione(matchPosizione.getPosizione());
|
||||
partitaMagToUpdate.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(partitaMagToUpdate, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
for (AgribookImportCoordsTestCSVDTO coord : x.getValue()) {
|
||||
if (coord.getMatchOrder().getMtbPartitaMag() != null) {
|
||||
MtbPartitaMag partitaMagToUpdate = (MtbPartitaMag) coord.getMatchOrder().getMtbPartitaMag();
|
||||
|
||||
partitaMagToUpdate.setPosizione(matchPosizione.getPosizione());
|
||||
partitaMagToUpdate.setOperation(OperationType.UPDATE);
|
||||
entityProcessor.processEntity(partitaMagToUpdate, true, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(importedLines);
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
return ServiceRestResponse.createNegativeResponse(e);
|
||||
|
||||
}
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(importedLines);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveCoords", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse saveCoords(@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody List<AgribookSaveCoordsDTO> agribookSaveCoordsDTOS) throws Exception {
|
||||
@RequestBody List<AgribookSaveCoordsDTO> agribookSaveCoordsDTOS) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(agribookOrderService.saveCoords(agribookSaveCoordsDTOS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
package it.integry.ems.production.agribook.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class AgribookNewFieldRequestDTO {
|
||||
|
||||
private String codAnag;
|
||||
private String codVdes;
|
||||
private boolean newDes;
|
||||
private String codMart;
|
||||
private String partitaMag;
|
||||
private BigDecimal qtaAttesa;
|
||||
private BigDecimal valUnt;
|
||||
private String untMis;
|
||||
private String destinatario;
|
||||
private String indirizzo;
|
||||
private String cap;
|
||||
private String citta;
|
||||
private String prov;
|
||||
private BigDecimal lat;
|
||||
private BigDecimal lng;
|
||||
private String ragSocLegale;
|
||||
private String partIvaLegale;
|
||||
private String codFiscLegale;
|
||||
private String indirizzoLegale;
|
||||
private String capLegale;
|
||||
private String cittaLegale;
|
||||
private String provLegale;
|
||||
private String partIva;
|
||||
private String datiCatastali;
|
||||
private String note;
|
||||
private String varieta;
|
||||
private LocalDate dataInizProd;
|
||||
private LocalDate dataOrd;
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCodVdes(String codVdes) {
|
||||
this.codVdes = codVdes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNewDes() {
|
||||
return newDes;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setNewDes(boolean newDes) {
|
||||
this.newDes = newDes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaAttesa() {
|
||||
return qtaAttesa;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setQtaAttesa(BigDecimal qtaAttesa) {
|
||||
this.qtaAttesa = qtaAttesa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDestinatario() {
|
||||
return destinatario;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setDestinatario(String destinatario) {
|
||||
this.destinatario = destinatario;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIndirizzo() {
|
||||
return indirizzo;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setIndirizzo(String indirizzo) {
|
||||
this.indirizzo = indirizzo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCap() {
|
||||
return cap;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCap(String cap) {
|
||||
this.cap = cap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCitta() {
|
||||
return citta;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCitta(String citta) {
|
||||
this.citta = citta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProv() {
|
||||
return prov;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setProv(String prov) {
|
||||
this.prov = prov;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setLat(BigDecimal lat) {
|
||||
this.lat = lat;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setLng(BigDecimal lng) {
|
||||
this.lng = lng;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRagSocLegale() {
|
||||
return ragSocLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setRagSocLegale(String ragSocLegale) {
|
||||
this.ragSocLegale = ragSocLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartIvaLegale() {
|
||||
return partIvaLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setPartIvaLegale(String partIvaLegale) {
|
||||
this.partIvaLegale = partIvaLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodFiscLegale() {
|
||||
return codFiscLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCodFiscLegale(String codFiscLegale) {
|
||||
this.codFiscLegale = codFiscLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartIva() {
|
||||
return partIva;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setPartIva(String partIva) {
|
||||
this.partIva = partIva;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDatiCatastali() {
|
||||
return datiCatastali;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setDatiCatastali(String datiCatastali) {
|
||||
this.datiCatastali = datiCatastali;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getVarieta() {
|
||||
return varieta;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setVarieta(String varieta) {
|
||||
this.varieta = varieta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValUnt() {
|
||||
return valUnt;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setValUnt(BigDecimal valUnt) {
|
||||
this.valUnt = valUnt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataInizProd() {
|
||||
return dataInizProd;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setDataInizProd(LocalDate dataInizProd) {
|
||||
this.dataInizProd = dataInizProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDate getDataOrd() {
|
||||
return dataOrd;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setDataOrd(LocalDate dataOrd) {
|
||||
this.dataOrd = dataOrd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIndirizzoLegale() {
|
||||
return indirizzoLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setIndirizzoLegale(String indirizzoLegale) {
|
||||
this.indirizzoLegale = indirizzoLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCapLegale() {
|
||||
return capLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCapLegale(String capLegale) {
|
||||
this.capLegale = capLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCittaLegale() {
|
||||
return cittaLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setCittaLegale(String cittaLegale) {
|
||||
this.cittaLegale = cittaLegale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProvLegale() {
|
||||
return provLegale;
|
||||
}
|
||||
|
||||
public AgribookNewFieldRequestDTO setProvLegale(String provLegale) {
|
||||
this.provLegale = provLegale;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class AccettazioneOrtoFruttaDTO {
|
||||
private BigDecimal qtaCnf;
|
||||
private String ragSocProduttore;
|
||||
private String partIvaProduttore;
|
||||
private Object varieta;
|
||||
private String varieta;
|
||||
private String ragSocOp;
|
||||
private String partIvaOp;
|
||||
private String ragSocCoop;
|
||||
@@ -277,11 +277,11 @@ public class AccettazioneOrtoFruttaDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getVarieta() {
|
||||
public String getVarieta() {
|
||||
return varieta;
|
||||
}
|
||||
|
||||
public AccettazioneOrtoFruttaDTO setVarieta(Object varieta) {
|
||||
public AccettazioneOrtoFruttaDTO setVarieta(String varieta) {
|
||||
this.varieta = varieta;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ public class OrtoFruttaProductionService {
|
||||
MtbPartitaMagCarat modalitaRaccolta = new MtbPartitaMagCarat();
|
||||
String caratLottoProd = "Lotto Produttore";
|
||||
String caratModalitaRaccolta = "Modalita Raccolta";
|
||||
String caratVarietaRaccolta = "Varieta";
|
||||
if (dto.getOriginal() != null) {
|
||||
datiPartita = UtilityDB.executeSimpleQueryDTO(
|
||||
multiDBTransactionManager.getPrimaryConnection(),
|
||||
@@ -182,6 +183,12 @@ public class OrtoFruttaProductionService {
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
modalitaRaccolta
|
||||
.setCarat(caratVarietaRaccolta)
|
||||
.setValCarat(dto.getVarieta())
|
||||
.setActivityId(activityId)
|
||||
.setDataRilevazione(LocalDateTime.now())
|
||||
.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
datiPartita = new ArrayList<>();
|
||||
datiPartita.add(lottoProd);
|
||||
datiPartita.add(modalitaRaccolta);
|
||||
|
||||
@@ -68,7 +68,8 @@ public class ExchangeColliImportController {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestParam() String codAnag,
|
||||
@RequestParam() String dataCert,
|
||||
@RequestParam(required = false) String codMart,
|
||||
@RequestParam() String partitaMag,
|
||||
@RequestParam() String codMart,
|
||||
@RequestParam(required = false) String codVdes
|
||||
) throws Exception {
|
||||
LocalDate dataCertificato = LocalDate.parse(dataCert);
|
||||
@@ -76,7 +77,7 @@ public class ExchangeColliImportController {
|
||||
codAnag,
|
||||
dataCertificato,
|
||||
codMart,
|
||||
codVdes));
|
||||
codVdes,partitaMag));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,4 +41,17 @@ public class ExchangeOrdiniImportController {
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
@RequestMapping(value = "importCampi", method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse importCampiRaccolta(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
|
||||
@RequestParam() String profileDbExchange) throws Exception {
|
||||
|
||||
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(profileDb);
|
||||
MultiDBTransactionManager exchangeDb = new MultiDBTransactionManager(profileDbExchange)) {
|
||||
exchangeOrdiniImportService.importCampiDiRaccolta(internalDb, exchangeDb, requestDataDTO);
|
||||
}
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,615 @@
|
||||
package it.integry.ems.system.exchange.dto;
|
||||
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.exception.EntityException;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ExchangeCampiRaccoltaDTO implements EquatableEntityInterface<ExchangeCampiRaccoltaDTO> {
|
||||
private OperationType operation;
|
||||
|
||||
@SqlField("partitaMag")
|
||||
private String partitaMag;
|
||||
@SqlField("codAnag")
|
||||
private String codAnag;
|
||||
@SqlField("ragSoc")
|
||||
private String ragSoc;
|
||||
@SqlField("codVdes")
|
||||
private String codVdes;
|
||||
@SqlField("produttore")
|
||||
private String produttore;
|
||||
@SqlField("cooperativa")
|
||||
private String cooperativa;
|
||||
@SqlField("indirizzoCoop")
|
||||
private String indirizzoCoop;
|
||||
@SqlField("cittaCoop")
|
||||
private String cittaCoop;
|
||||
@SqlField("capCoop")
|
||||
private String capCoop;
|
||||
@SqlField("provCoop")
|
||||
private String provCoop;
|
||||
@SqlField("partIvaCoop")
|
||||
private String partIvaCoop;
|
||||
@SqlField("op")
|
||||
private String op;
|
||||
@SqlField("codAnagProd")
|
||||
private String codAnagProd;
|
||||
@SqlField("ragSocProd")
|
||||
private String ragSocProd;
|
||||
@SqlField("indirizzoProd")
|
||||
private String indirizzoProd;
|
||||
@SqlField("cittaProd")
|
||||
private String cittaProd;
|
||||
@SqlField("capProd")
|
||||
private String capProd;
|
||||
@SqlField("provProd")
|
||||
private String provProd;
|
||||
@SqlField("partIvaProd")
|
||||
private String partIvaProd;
|
||||
@SqlField("codMartMp")
|
||||
private String codMartMp;
|
||||
@SqlField("codMartMg")
|
||||
private String codMartMg;
|
||||
@SqlField("varieta")
|
||||
private String varieta;
|
||||
@SqlField("lottoFornitore")
|
||||
private String lottoFornitore;
|
||||
@SqlField("valUnt")
|
||||
private BigDecimal valUnt;
|
||||
@SqlField("untMis")
|
||||
private String untMis;
|
||||
@SqlField("qtaAttesa")
|
||||
private BigDecimal qtaAttesa;
|
||||
@SqlField("dataInizProd")
|
||||
private LocalDate dataInizProd;
|
||||
@SqlField("newDest")
|
||||
private boolean newDest;
|
||||
@SqlField("newPartita")
|
||||
private boolean newPartita;
|
||||
@SqlField("note")
|
||||
private String note;
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRagSoc() {
|
||||
return ragSoc;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setRagSoc(String ragSoc) {
|
||||
this.ragSoc = ragSoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodVdes() {
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCodVdes(String codVdes) {
|
||||
this.codVdes = codVdes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProduttore() {
|
||||
return produttore;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setProduttore(String produttore) {
|
||||
this.produttore = produttore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCooperativa() {
|
||||
return cooperativa;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCooperativa(String cooperativa) {
|
||||
this.cooperativa = cooperativa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIndirizzoCoop() {
|
||||
return indirizzoCoop;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setIndirizzoCoop(String indirizzoCoop) {
|
||||
this.indirizzoCoop = indirizzoCoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCittaCoop() {
|
||||
return cittaCoop;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCittaCoop(String cittaCoop) {
|
||||
this.cittaCoop = cittaCoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCapCoop() {
|
||||
return capCoop;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCapCoop(String capCoop) {
|
||||
this.capCoop = capCoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProvCoop() {
|
||||
return provCoop;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setProvCoop(String provCoop) {
|
||||
this.provCoop = provCoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartIvaCoop() {
|
||||
return partIvaCoop;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setPartIvaCoop(String partIvaCoop) {
|
||||
this.partIvaCoop = partIvaCoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setOp(String op) {
|
||||
this.op = op;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAnagProd() {
|
||||
return codAnagProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCodAnagProd(String codAnagProd) {
|
||||
this.codAnagProd = codAnagProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRagSocProd() {
|
||||
return ragSocProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setRagSocProd(String ragSocProd) {
|
||||
this.ragSocProd = ragSocProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIndirizzoProd() {
|
||||
return indirizzoProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setIndirizzoProd(String indirizzoProd) {
|
||||
this.indirizzoProd = indirizzoProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCittaProd() {
|
||||
return cittaProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCittaProd(String cittaProd) {
|
||||
this.cittaProd = cittaProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCapProd() {
|
||||
return capProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCapProd(String capProd) {
|
||||
this.capProd = capProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProvProd() {
|
||||
return provProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setProvProd(String provProd) {
|
||||
this.provProd = provProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartIvaProd() {
|
||||
return partIvaProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setPartIvaProd(String partIvaProd) {
|
||||
this.partIvaProd = partIvaProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMartMp() {
|
||||
return codMartMp;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCodMartMp(String codMartMp) {
|
||||
this.codMartMp = codMartMp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMartMg() {
|
||||
return codMartMg;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setCodMartMg(String codMartMg) {
|
||||
this.codMartMg = codMartMg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getVarieta() {
|
||||
return varieta;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setVarieta(String varieta) {
|
||||
this.varieta = varieta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLottoFornitore() {
|
||||
return lottoFornitore;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setLottoFornitore(String lottoFornitore) {
|
||||
this.lottoFornitore = lottoFornitore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getValUnt() {
|
||||
return valUnt;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setValUnt(BigDecimal valUnt) {
|
||||
this.valUnt = valUnt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaAttesa() {
|
||||
return qtaAttesa;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setQtaAttesa(BigDecimal qtaAttesa) {
|
||||
this.qtaAttesa = qtaAttesa;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsKey(ExchangeCampiRaccoltaDTO other) {
|
||||
|
||||
return codAnag.equalsIgnoreCase(other.getCodAnag()) &&
|
||||
codVdes.equalsIgnoreCase(other.getCodVdes()) &&
|
||||
codMartMp.equalsIgnoreCase(other.getCodMartMp()) &&
|
||||
lottoFornitore.equalsIgnoreCase(other.getLottoFornitore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsContent(ExchangeCampiRaccoltaDTO other) {
|
||||
return
|
||||
codAnag.equalsIgnoreCase(other.getCodAnag()) &&
|
||||
ragSoc.equalsIgnoreCase(other.getRagSoc()) &&
|
||||
codVdes.equalsIgnoreCase(other.getCodVdes()) &&
|
||||
produttore.equalsIgnoreCase(other.getProduttore()) &&
|
||||
cooperativa.equalsIgnoreCase(other.getCooperativa()) &&
|
||||
indirizzoCoop.equalsIgnoreCase(other.getIndirizzoCoop()) &&
|
||||
cittaCoop.equalsIgnoreCase(other.getCittaCoop()) &&
|
||||
capCoop.equalsIgnoreCase(other.getCapCoop()) &&
|
||||
provCoop.equalsIgnoreCase(other.getProvCoop()) &&
|
||||
partIvaCoop.equalsIgnoreCase(other.getPartIvaCoop()) &&
|
||||
op.equalsIgnoreCase(other.getOp()) &&
|
||||
codAnagProd.equalsIgnoreCase(other.getCodAnagProd()) &&
|
||||
ragSocProd.equalsIgnoreCase(other.getRagSocProd()) &&
|
||||
indirizzoProd.equalsIgnoreCase(other.getIndirizzoProd()) &&
|
||||
cittaProd.equalsIgnoreCase(other.getCittaProd()) &&
|
||||
capProd.equalsIgnoreCase(other.getCapProd()) &&
|
||||
provProd.equalsIgnoreCase(other.getProvProd()) &&
|
||||
partIvaProd.equalsIgnoreCase(other.getPartIvaProd()) &&
|
||||
codMartMp.equalsIgnoreCase(other.getCodMartMp()) &&
|
||||
codMartMg.equalsIgnoreCase(other.getCodMartMg()) &&
|
||||
varieta.equalsIgnoreCase(other.getVarieta()) &&
|
||||
lottoFornitore.equalsIgnoreCase(other.getLottoFornitore()) &&
|
||||
valUnt.equals(other.getValUnt()) &&
|
||||
qtaAttesa.equals(other.getQtaAttesa())
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPreSave() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIdentiy(Connection connection) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execStoredProcedure() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDefault(String fieldName) throws IllegalAccessException, IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyDefault() throws IllegalAccessException, IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends EntityBase> select(Connection connection) throws Exception {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getOnlyPkMaster() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnlyPkMaster(Boolean onlyPkMaster) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationType getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOperation(OperationType opType) {
|
||||
this.operation = opType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsername(String username) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationName(String applicationName) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDbName(String dbName) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationNameDB(String profileDB) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface clone() throws CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityBase selectAndMergeEntity(Connection connection, EntityBase entity) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void manageWithParentConnection(Connection connection) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void manageWithParentConnection(Connection connection, OperationType op, DroolsDataCompleting dataCompleting, EntityPropertyHolder propertyHolder) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DroolsDataCompleting getCompletingManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompletingManager(DroolsDataCompleting dataCompleting) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntityHolder(EntityPropertyHolder entityHolder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataCompleting(Connection connection) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecalcColumns(List<String> recalcColumns) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getExcludedColumns() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExcludedColumns(List<String> excludedColumns) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentPKAndImportFromParent(EntityBase parent, Boolean isChild) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImportFromParent(EntityBase parent, Boolean isChild) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNativeSql() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trimPK() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excludeField(String sqlField, String columnName) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface deepClone() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityException getException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getTransactionGroupId() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransactionGroupId(Long transactionGroupId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTransactionGroupId() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueryTimeoutSeconds() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface setQueryTimeoutSeconds(int queryTimeoutSeconds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParent(EntityInterface entityInterface) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LocalDate getDataInizProd() {
|
||||
return dataInizProd;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setDataInizProd(LocalDate dataInizProd) {
|
||||
this.dataInizProd = dataInizProd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNewDest() {
|
||||
return newDest;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setNewDest(boolean newDest) {
|
||||
this.newDest = newDest;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNewPartita() {
|
||||
return newPartita;
|
||||
}
|
||||
|
||||
public ExchangeCampiRaccoltaDTO setNewPartita(boolean newPartita) {
|
||||
this.newPartita = newPartita;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class ExchangeColliImportService {
|
||||
}
|
||||
|
||||
|
||||
public List<CertificatiSinfoOneDTO> getCertificati(String profileDb, String codAnag, LocalDate dataCert, String codMart, String codVdes) throws Exception {
|
||||
public List<CertificatiSinfoOneDTO> getCertificati(String profileDb, String codAnag, LocalDate dataCert, String codMart, String codVdes, String partitaMag) throws Exception {
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileDb)) {
|
||||
|
||||
@@ -220,8 +220,8 @@ public class ExchangeColliImportService {
|
||||
" produttore AS produttore,\n" +
|
||||
" OP AS op,\n" +
|
||||
" TRIM(num_bolla) AS numBolla,\n" +
|
||||
" TRIM(PMB_TIPO_POMODORO) AS codMart,\n" +
|
||||
" TRIM(PMB_SEME) AS varieta,\n" +
|
||||
" TRIM(cod_mart_mp) AS codMart,\n" +
|
||||
" varieta,\n" +
|
||||
" TRIM(lotto_fornitore) AS lottoFornitore,\n" +
|
||||
" CONVERT(NUMERIC(15, 3), peso_lordo_kg) AS pesoLordoKg,\n" +
|
||||
" CONVERT(NUMERIC(15, 3), peso_netto_kg) AS pesoNettoKg,\n" +
|
||||
@@ -235,12 +235,13 @@ public class ExchangeColliImportService {
|
||||
" data_ora_lordo AS dataOraLordo,\n" +
|
||||
" CONVERT(NUMERIC(15, 3), sconto8) AS sconto8,\n" +
|
||||
" cod_vettore AS cod_vvet,\n" +
|
||||
" vettore AS vettore,\n" +
|
||||
" vettore AS vettore,\n" +
|
||||
" CONVERT(NUMERIC(15, 3), PMB_SCARTO_CQ) AS scartoCq\n " +
|
||||
"FROM s1_Certificati\n" +
|
||||
"WHERE cod_anag = {}\n" +
|
||||
" AND data_cert = {}\n" +
|
||||
" AND PMB_TIPO_POMODORO = {}", codAnag, dataCert, codMart),
|
||||
" AND {} like '%%'+TRIM(lotto_fornitore) \n" +
|
||||
" AND cod_mart_mp = {}", codAnag, dataCert,partitaMag, codMart),
|
||||
CertificatiSinfoOneDTO.class);
|
||||
String codDtipLavCar = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "CRUSCOTTO_PRODUZIONE",
|
||||
"SETUP",
|
||||
|
||||
@@ -10,10 +10,7 @@ import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -26,7 +23,9 @@ public class ExchangeImportSchemaManagerService {
|
||||
DocumentiLavorazione(3),
|
||||
Articoli(4),
|
||||
PartiteMagazzinoLavorazione(5),
|
||||
VersamentoGrezzo(6);
|
||||
VersamentoGrezzo(6),
|
||||
CampiRaccolta(7);
|
||||
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -67,6 +66,7 @@ public class ExchangeImportSchemaManagerService {
|
||||
put(SchemaType.Articoli, Arrays.asList("mtb_aart", "mtb_grup", "mtb_sgrp", "mtb_sfam", "mtb_tipi", "mtb_aart_marchio"));
|
||||
put(SchemaType.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
|
||||
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
|
||||
put(SchemaType.CampiRaccolta, Collections.singletonList("campi_raccolta"));
|
||||
}};
|
||||
|
||||
public void syncSchema(Connection connection, SchemaType schemaType, boolean createTempTablesToo) throws Exception {
|
||||
|
||||
@@ -2,8 +2,11 @@ package it.integry.ems.system.exchange.service;
|
||||
|
||||
import it.integry.ems.expansion.RunnableThrowable;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.production.agribook.AgribookFieldService;
|
||||
import it.integry.ems.production.agribook.model.AgribookNewFieldRequestDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.dto.ExchangeCampiRaccoltaDTO;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.entity.DtbOrdSteps;
|
||||
import it.integry.ems_model.entity.DtbOrdr;
|
||||
@@ -12,6 +15,7 @@ import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
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;
|
||||
@@ -47,6 +51,9 @@ public class ExchangeOrdiniImportService {
|
||||
@Autowired
|
||||
private ExchangePartiteMagazzinoImportService exchangePartiteMagazzinoImportService;
|
||||
|
||||
@Autowired
|
||||
private AgribookFieldService agribookFieldService;
|
||||
|
||||
public void importOrdiniLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
|
||||
boolean useTempTable = true;
|
||||
@@ -189,7 +196,6 @@ public class ExchangeOrdiniImportService {
|
||||
return dtbOrdtLav;
|
||||
}
|
||||
|
||||
|
||||
private void singleUpdateImported(Connection connection, DtbOrdt importedDtbOrdt, boolean useTempTable) throws Exception {
|
||||
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
|
||||
put("data_ord", importedDtbOrdt.getDataOrd());
|
||||
@@ -211,4 +217,122 @@ public class ExchangeOrdiniImportService {
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "dtb_ordr_lav", importedRowKeys, useTempTable);
|
||||
}
|
||||
|
||||
public void importCampiDiRaccolta(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
|
||||
|
||||
try {
|
||||
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.CampiRaccolta, true);
|
||||
|
||||
final List<ExchangeCampiRaccoltaDTO> exchangeCampiRaccOld = retrieveCampiDiRaccolta(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
UtilityLocalDate.getNow().minusMonths(1),
|
||||
true,false);
|
||||
|
||||
final List<ExchangeCampiRaccoltaDTO> exchangeCampiRaccNew = retrieveCampiDiRaccolta(
|
||||
exchangeMultiDb.getPrimaryConnection(),
|
||||
UtilityLocalDate.getNow().minusMonths(1),
|
||||
false, true);
|
||||
|
||||
List<EquatableEntityInterface> allData = exchangeImportDataManagerService
|
||||
.runSync(ExchangeCampiRaccoltaDTO.class, exchangeCampiRaccOld, exchangeCampiRaccNew);
|
||||
|
||||
final Exception[] firstExceptionToThrow = {null};
|
||||
|
||||
final AtomicInteger[] importedCounter = {new AtomicInteger()};
|
||||
|
||||
for (EquatableEntityInterface dataToSave : allData) {
|
||||
ExchangeCampiRaccoltaDTO field = (ExchangeCampiRaccoltaDTO)dataToSave;
|
||||
try {
|
||||
importField(internalMultiDb,field);
|
||||
|
||||
singleFieldUpdateImported(exchangeMultiDb.getPrimaryConnection(), field, true);
|
||||
internalMultiDb.commitAll();
|
||||
exchangeMultiDb.commitAll();
|
||||
logger.debug("Importati {} campi di {}", importedCounter[0].incrementAndGet(), allData.size());
|
||||
} catch (Exception ex) {
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
|
||||
|
||||
|
||||
logger.error("Errore durante l'importazione dell'campo [fornitore: " + field.getCodAnag() + " - "+field.getCodVdes()+"," +
|
||||
"articolo: " + field.getCodMartMp() + "," +
|
||||
"partita: " + field.getLottoFornitore() + "]", ex);
|
||||
internalMultiDb.rollbackAll();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (firstExceptionToThrow[0] != null) throw firstExceptionToThrow[0];
|
||||
} finally {
|
||||
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.CampiRaccolta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void importField(MultiDBTransactionManager multiDb,ExchangeCampiRaccoltaDTO field) throws Exception{
|
||||
if (UtilityString.isNullOrEmpty(field.getCodAnag())){
|
||||
return;
|
||||
}
|
||||
if (field.isNewPartita()){
|
||||
AgribookNewFieldRequestDTO dto = new AgribookNewFieldRequestDTO();
|
||||
dto.setCodAnag(field.getCodAnag())
|
||||
.setCodVdes(field.getCodVdes())
|
||||
.setNewDes(field.isNewDest())
|
||||
.setCodMart(field.getCodMartMp())
|
||||
.setPartitaMag(field.getPartitaMag())
|
||||
.setQtaAttesa(field.getQtaAttesa())
|
||||
.setValUnt(field.getValUnt())
|
||||
.setUntMis(field.getUntMis())
|
||||
.setDestinatario(field.getProduttore())
|
||||
.setIndirizzo(field.getIndirizzoProd())
|
||||
.setCap(field.getCapProd())
|
||||
.setCitta(field.getCittaProd())
|
||||
.setProv(field.getProvProd())
|
||||
.setLat(null)
|
||||
.setLng(null)
|
||||
.setRagSocLegale(field.getCooperativa())
|
||||
.setPartIvaLegale(field.getPartIvaCoop())
|
||||
.setCodFiscLegale(field.getPartIvaCoop())
|
||||
.setIndirizzoLegale(field.getIndirizzoCoop())
|
||||
.setCapLegale(field.getCapCoop())
|
||||
.setCittaLegale(field.getCittaCoop())
|
||||
.setProvLegale(field.getProvCoop())
|
||||
.setPartIva(field.getPartIvaProd())
|
||||
.setDatiCatastali(null)
|
||||
.setNote(field.getNote())
|
||||
.setVarieta(field.getVarieta())
|
||||
.setDataInizProd(field.getDataInizProd())
|
||||
.setDataOrd(field.getDataInizProd());
|
||||
agribookFieldService.createField(multiDb,dto);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ExchangeCampiRaccoltaDTO> retrieveCampiDiRaccolta(Connection connection, LocalDate minDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
|
||||
String campiRaccOriginalTableName = "campi_raccolta";
|
||||
String campiRaccTableName = campiRaccOriginalTableName + (useTempTable ? "_tmp" : "");
|
||||
|
||||
|
||||
if (useTempTable) {
|
||||
UtilityDB.executeStatement(connection,
|
||||
"INSERT INTO " + campiRaccTableName +
|
||||
" SELECT * FROM " + campiRaccOriginalTableName
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return exchangeImportDataManagerService.retrieveDataFromExchange(connection, ExchangeCampiRaccoltaDTO.class,
|
||||
campiRaccTableName, Query.format("dataInizProd > {}", minDate), retrieveAlreadyImported);
|
||||
}
|
||||
|
||||
private void singleFieldUpdateImported(Connection connection, ExchangeCampiRaccoltaDTO importedField, boolean useTempTable) throws Exception {
|
||||
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
|
||||
put("codAnag", importedField.getCodAnag());
|
||||
put("codVdes", importedField.getCodVdes());
|
||||
put("codMartMp", importedField.getCodMartMp());
|
||||
put("lottoFornitore", importedField.getLottoFornitore());
|
||||
}};
|
||||
|
||||
exchangeImportDataManagerService.updateImportedStatus(connection, "campi_raccolta", importedKey, useTempTable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user