Implementazioni varie per magazzino automatico
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-10-24 13:20:44 +02:00
parent 3daf60767f
commit 7ee6e8d64a
7 changed files with 126 additions and 25 deletions

View File

@@ -0,0 +1,23 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20251024113416 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
executeStatement("ALTER TABLE mtb_missione_mag_auto_det " +
"ALTER COLUMN posizione_in VARCHAR (MAX);",
"ALTER TABLE mtb_missione_mag_auto_det " +
"ALTER COLUMN posizione_out VARCHAR (MAX);");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -65,6 +65,14 @@ public class CtbAmac extends EntityBase {
@SqlField(value = "flag_attivo", nullable = false, defaultObjectValue = "1")
private Boolean flagAttivo;
@SqlField(value = "cod_mdep")
@FK(tableName = MtbDepoPosizioni.ENTITY)
private String codMdep;
@SqlField(value = "posizione")
@FK(tableName = MtbDepoPosizioni.ENTITY)
private String posizione;
@EntityChild
private List<CrlAmacArt> crlAmacArt = new ArrayList<>();
@@ -234,6 +242,24 @@ public class CtbAmac extends EntityBase {
return this;
}
public String getCodMdep() {
return codMdep;
}
public CtbAmac setCodMdep(String codMdep) {
this.codMdep = codMdep;
return this;
}
public String getPosizione() {
return posizione;
}
public CtbAmac setPosizione(String posizione) {
this.posizione = posizione;
return this;
}
@Override
protected void insertChilds() throws Exception {
for (CrlAmacArt crlAmacArt : getCrlAmacArt()) {

View File

@@ -36,6 +36,7 @@ public class CtbCoan extends EntityBase {
@SqlField(value = "cod_prod", maxLength = 15, nullable = false)
@FK(tableName = MtbAart.ENTITY, columnName = "cod_mart")
@FK(tableName = MtbPartitaMag.ENTITY, columnName = "cod_mart")
private String codProd;
@SqlField(value = "partita_mag_prod", maxLength = 20, nullable = true)

View File

@@ -38,10 +38,10 @@ public class MtbMissioneMagAutoDet extends EntityBase {
@SqlField(value = "sscc", maxLength = 18, nullable = true)
private String sscc;
@SqlField(value = "posizione_in", maxLength = 40, nullable = true)
@SqlField(value = "posizione_in", maxLength = 8000, nullable = true)
private String posizioneIn;
@SqlField(value = "posizione_out", maxLength = 40, nullable = true)
@SqlField(value = "posizione_out", maxLength = 8000, nullable = true)
private String posizioneOut;
@SqlField(value = "error_message", maxLength = -1, nullable = true)

View File

@@ -4,12 +4,12 @@ import it.integry.common.var.CommonConstants;
import it.integry.ems.production.dto.DeleteCaricoDaProduzioneRequestDTO;
import it.integry.ems.production.dto.RettificaProdDTO;
import it.integry.ems.production.service.ProductionWarehouseService;
import it.integry.ems.response.EsitoType;
import it.integry.ems.production.utility.ProductionWarehouseUtility;
import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.config.EmsRestConstants;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;
@@ -23,35 +23,46 @@ public class ProductionWarehouseController {
private final Logger logger = LogManager.getLogger();
@Autowired
private ProductionWarehouseService warehouseService;
private final MultiDBTransactionManager multiDBTransactionManager;
private final ProductionWarehouseService warehouseService;
public ProductionWarehouseController(MultiDBTransactionManager multiDBTransactionManager, ProductionWarehouseService warehouseService) {
this.multiDBTransactionManager = multiDBTransactionManager;
this.warehouseService = warehouseService;
}
@RequestMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_RETTIFICA, method = RequestMethod.POST)
@GetMapping("retrieve-posizione-out-lavorazione")
public @ResponseBody ServiceRestResponse retrievePosizioneOutLavorazione(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
@RequestParam String barcodeUl) throws Exception {
return ServiceRestResponse.createPositiveResponse(ProductionWarehouseUtility.retrieveSuggestedPositionOfUL(
multiDBTransactionManager.getPrimaryConnection(),
barcodeUl
));
}
@PostMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_RETTIFICA)
public @ResponseBody
ServiceRestResponse rettificaGiacenzaProduzione(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
@RequestParam String codMdep,
@RequestParam String codDtip,
@RequestBody RettificaProdDTO rettificaProd) {
ServiceRestResponse response;
try {
response = new ServiceRestResponse(EsitoType.OK);
if (!rettificaProd.getRettificaULDTO().isEmpty()) {
response.setJsonObject(warehouseService.rettificaGiacenzaProduzione(rettificaProd, codMdep, codDtip));
} else {
response.setEsito(EsitoType.KO);
response.setErrorMessage("Nessuna collo di rettifica trovato");
}
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
response = new ServiceRestResponse(EsitoType.KO, profileDB, e);
@RequestBody RettificaProdDTO rettificaProd) throws Exception {
if (!rettificaProd.getRettificaULDTO().isEmpty()) {
return ServiceRestResponse.createPositiveResponse(warehouseService.rettificaGiacenzaProduzione(rettificaProd, codMdep, codDtip));
} else {
return ServiceRestResponse.createNegativeResponse("Nessuna collo di rettifica trovato");
}
return response;
}
@RequestMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_DELETE_CARICO, method = RequestMethod.POST)
@PostMapping(value = EmsRestConstants.PATH_WAREHOUSE_PRODUCTION_DELETE_CARICO)
public @ResponseBody
ServiceRestResponse deleteColloDaProduzione(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,

View File

@@ -0,0 +1,43 @@
package it.integry.ems.production.utility;
import it.integry.common.var.CommonConstants;
import it.integry.ems.sync.MultiDBTransaction.Connection;
import it.integry.ems_model.entity.DtbOrdSteps;
import it.integry.ems_model.entity.MtbColt;
import it.integry.ems_model.entity.key.DtbOrdtKey;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import it.integry.ems_model.utility.UtilityLocalDate;
import java.time.LocalDate;
import java.util.HashMap;
public class ProductionWarehouseUtility {
public static String retrieveSuggestedPositionOfUL(Connection connection, String barcodeUl) throws Exception {
String sql = "SELECT data_ord, num_ord, gestione, cod_jfas \n" +
"FROM " + MtbColt.ENTITY + " mt \n" +
"WHERE barcode_ul = " + UtilityDB.valueToString(barcodeUl);
final HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
if (result == null)
throw new IllegalArgumentException("Nessuna unità logistica trovata con barcode: " + barcodeUl);
LocalDate dataOrd = UtilityLocalDate.localDateFromDate(UtilityHashMap.getValueIfExists(result, "data_ord"));
Integer numOrd = UtilityHashMap.getValueIfExists(result, "num_ord");
String gestione = UtilityHashMap.getValueIfExists(result, "gestione");
String codJfas = UtilityHashMap.getValueIfExists(result, "cod_jfas");
if (dataOrd == null || numOrd == null || gestione == null || codJfas == null)
throw new IllegalArgumentException("Impossibile ricavare l'ordine dell'unità logistica con barcode: " + barcodeUl);
DtbOrdSteps orderLastStep = MesUtility.getOrderLastStep(connection, new DtbOrdtKey(gestione, dataOrd, numOrd), codJfas);
if (orderLastStep == null)
throw new IllegalArgumentException("Nessuno step rilevato sull'ordine " + numOrd + " del " + CommonConstants.DATE_DMY_SLASHED_FORMATTER.format(dataOrd));
return orderLastStep.getPosizioneOut();
}
}

View File

@@ -143,9 +143,6 @@ public class WMSMagazzinoAutomaticoService {
break;
case EUROFORK:
//TODO: Ricavare la posizione di destinazione. Se l'UL proviene da L7 allora va ricavata dallo step dell'ordine
// String posizioneDest = "WH101L002";
final MissioneMagazzinoAutomaticoRowDTO missionRow = new MissioneMagazzinoAutomaticoRowDTO()
.setSscc(mtbColtToPut.getBarcodeUl())
.setPosizioneOut(mtbColtToPut.getPosizione())