anomalie merce
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251209114959 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table dbo.mtb_cols add valore varchar(200)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,9 @@ public class MtbCols extends EntityBase {
|
||||
@SqlField(value = "causale", nullable = false)
|
||||
private Causale causale;
|
||||
|
||||
@SqlField(value = "valore", nullable = true)
|
||||
private String valore;
|
||||
|
||||
public MtbCols() {
|
||||
super(logger);
|
||||
}
|
||||
@@ -157,9 +160,18 @@ public class MtbCols extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getValore() {
|
||||
return valore;
|
||||
}
|
||||
|
||||
public MtbCols setValore(String valore) {
|
||||
this.valore = valore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum Causale implements IBaseEnum<Causale> {
|
||||
|
||||
CREAZIONE((short) 0), RETTIFICA((short) 1), POSIZIONAMENTO((short) 2), VERSAMENTO((short) 3);
|
||||
CREAZIONE((short) 0), RETTIFICA((short) 1), POSIZIONAMENTO((short) 2), VERSAMENTO((short) 3), ANOMALIA_ASSOCIATA((short) 4), ANOMALIA_RIMOSSA((short) 5);
|
||||
|
||||
private final short value;
|
||||
|
||||
|
||||
@@ -85,13 +85,24 @@ public class AnomalieController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/{id}/detachUls")
|
||||
@PostMapping(value = "/detachUls")
|
||||
public ServiceRestResponse detachUls(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@PathVariable Long id,
|
||||
@RequestBody List<String> ulsToRemove) throws Exception {
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(anomalieProdService.detachUls(multiDBTransactionManager, id, ulsToRemove));
|
||||
return ServiceRestResponse.createPositiveResponse(anomalieProdService.detachUls(multiDBTransactionManager, ulsToRemove));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@PostMapping(value = "/{id}/attachUls")
|
||||
public ServiceRestResponse attachUls(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String profileDB,
|
||||
@PathVariable Long id,
|
||||
@RequestBody List<String> ulsToAttach) throws Exception {
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(anomalieProdService.attachUls(multiDBTransactionManager, id, ulsToAttach));
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
|
||||
@@ -31,6 +31,8 @@ public class DettaglioULDTO {
|
||||
private String serCollo;
|
||||
@SqlField("num_collo")
|
||||
private Integer numCollo;
|
||||
@SqlField("id_anomalia")
|
||||
private Long idAnomalia;
|
||||
|
||||
public String getBarcodeUl() {
|
||||
return barcodeUl;
|
||||
@@ -139,4 +141,13 @@ public class DettaglioULDTO {
|
||||
this.numCollo = numCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Long getIdAnomalia() {
|
||||
return idAnomalia;
|
||||
}
|
||||
|
||||
public DettaglioULDTO setIdAnomalia(Long idAnomalia) {
|
||||
this.idAnomalia = idAnomalia;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems.retail.dto.AnomalieMerceDTO;
|
||||
import it.integry.ems.retail.dto.DettaglioULDTO;
|
||||
import it.integry.ems.retail.dto.SaveAnomaliaRequestDTO;
|
||||
import it.integry.ems.retail.dto.SaveLivelloAnomaliaRequestDTO;
|
||||
import it.integry.ems.retail.utility.AnomalieUlUtility;
|
||||
import it.integry.ems.retail.wms.Utility.WMSUtility;
|
||||
import it.integry.ems.retail.wms.generic.dto.MvwSitArtUdcDetInventarioDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
@@ -68,7 +69,7 @@ public class AnomalieUlService {
|
||||
}
|
||||
|
||||
public List<DettaglioULDTO> getUlAnomalia(Connection connection, Long idAnomalia) throws Exception {
|
||||
List<DettaglioULDTO> ulDetails = UtilityDB.executeSimpleQueryDTO(connection, "select mtb_colt.gestione, mtb_colt.ser_collo, mtb_colt.data_collo, mtb_colt.num_collo, barcode_ul, cod_mart, progressivo_ul, qta_col, cod_jfas\n" +
|
||||
List<DettaglioULDTO> ulDetails = UtilityDB.executeSimpleQueryDTO(connection, "select mtb_colt.gestione, mtb_colt.ser_collo, mtb_colt.data_collo, mtb_colt.num_collo, barcode_ul, cod_mart, progressivo_ul, qta_col, cod_jfas, id_anomalia\n" +
|
||||
"from mtb_colt\n" +
|
||||
" inner join mtb_colr on mtb_colt.gestione = mtb_colr.gestione and mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||
" mtb_colt.num_collo = mtb_colr.num_collo and mtb_colt.ser_collo = mtb_colr.ser_collo\n" +
|
||||
@@ -89,16 +90,28 @@ public class AnomalieUlService {
|
||||
return ulDetails;
|
||||
}
|
||||
|
||||
public List<MtbColt> detachUls(MultiDBTransactionManager multiDBTransactionManager, Long idAnomalia, List<String> ulsToRemove) throws Exception {
|
||||
String sql = "SELECT * from mtb_colt where barcode_ul in (" + UtilityDB.listValueToString(ulsToRemove) + ") and id_anomalia = " + idAnomalia;
|
||||
public List<MtbColt> detachUls(MultiDBTransactionManager multiDBTransactionManager, List<String> ulsToRemove) throws Exception {
|
||||
String sql = "SELECT * from mtb_colt where barcode_ul in (" + UtilityDB.listValueToString(ulsToRemove) + ") and id_anomalia is not null";
|
||||
|
||||
List<MtbColt> uls = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MtbColt.class);
|
||||
|
||||
uls.forEach(x -> x.setIdAnomalia(EmsRestConstants.LONG_NULL).setOperation(OperationType.UPDATE));
|
||||
uls.forEach(x -> AnomalieUlUtility.detachAnomaliaFromUl(x));
|
||||
entityProcessor.processEntityList(uls, multiDBTransactionManager, true);
|
||||
return uls;
|
||||
}
|
||||
|
||||
public List<MtbColt> attachUls(MultiDBTransactionManager multiDBTransactionManager, Long idAnomalia, List<String> ulsToAttach) throws Exception {
|
||||
|
||||
List<MtbColt> uls = WMSUtility.retrieveUlsByBarcodes(multiDBTransactionManager.getPrimaryConnection(), ulsToAttach).stream().collect(Collectors.toList());
|
||||
if (UtilityList.isNullOrEmpty(uls))
|
||||
return new ArrayList<>();
|
||||
|
||||
uls.forEach(x -> AnomalieUlUtility.attachAnomaliaToUl(x, idAnomalia));
|
||||
entityProcessor.processEntityList(uls, multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(uls);
|
||||
return uls;
|
||||
}
|
||||
|
||||
public MtbAnomalieUl saveAnomalia(MultiDBTransactionManager multiDBTransactionManager, SaveAnomaliaRequestDTO saveRequestDTO) throws Exception {
|
||||
|
||||
MtbAnomalieUl anomalia = new MtbAnomalieUl();
|
||||
@@ -117,7 +130,7 @@ public class AnomalieUlService {
|
||||
getUlAnomalia(multiDBTransactionManager.getPrimaryConnection(), anomalia.getId()).stream().forEach(x -> {
|
||||
if (!saveRequestDTO.getBarcodeList().contains(x.getBarcodeUl())) {
|
||||
MtbColt mtbColt = new MtbColt(x.getGestione(), x.getDataCollo(), x.getNumCollo(), x.getSerCollo());
|
||||
mtbColt.setIdAnomalia(EmsRestConstants.LONG_NULL).setOperation(OperationType.UPDATE);
|
||||
AnomalieUlUtility.detachAnomaliaFromUl(mtbColt.setIdAnomalia(x.getIdAnomalia()));
|
||||
ulsAffected.add(mtbColt);
|
||||
}
|
||||
});
|
||||
@@ -127,7 +140,7 @@ public class AnomalieUlService {
|
||||
MtbColt ul = newAnomalies.get(barcode);
|
||||
if (ul == null)
|
||||
return;
|
||||
ul.setIdAnomalia(anomalia.getId()).setOperation(OperationType.UPDATE);
|
||||
AnomalieUlUtility.attachAnomaliaToUl(ul, anomalia.getId());
|
||||
ulsAffected.add(ul);
|
||||
});
|
||||
|
||||
@@ -145,10 +158,10 @@ public class AnomalieUlService {
|
||||
.setOperation(OperationType.DELETE);
|
||||
|
||||
List<MtbColt> ulAnomalia = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(),
|
||||
"SELECT gestione,data_collo,ser_collo,num_collo from mtb_colt where id_anomalia = " + id,
|
||||
"SELECT gestione,data_collo,ser_collo,num_collo, id_anomalia from mtb_colt where id_anomalia = " + id,
|
||||
MtbColt.class);
|
||||
|
||||
ulAnomalia.forEach(x -> x.setIdAnomalia(EmsRestConstants.LONG_NULL).setOperation(OperationType.UPDATE));
|
||||
ulAnomalia.forEach(x -> AnomalieUlUtility.detachAnomaliaFromUl(x));
|
||||
entities.addAll(ulAnomalia);
|
||||
entities.add(anomalia);
|
||||
entityProcessor.processEntityList(entities, multiDBTransactionManager, true);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package it.integry.ems.retail.utility;
|
||||
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.MtbCols;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
public class AnomalieUlUtility {
|
||||
|
||||
public static MtbColt attachAnomaliaToUl(MtbColt ul, Long idAnomalia) {
|
||||
ul.setIdAnomalia(idAnomalia)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
MtbCols cols = new MtbCols()
|
||||
.setCodMdep(ul.getCodMdep())
|
||||
.setCausale(MtbCols.Causale.ANOMALIA_ASSOCIATA)
|
||||
.setValore(idAnomalia.toString());
|
||||
cols.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
ul.getMtbCols().add(cols);
|
||||
return ul;
|
||||
}
|
||||
|
||||
public static MtbColt detachAnomaliaFromUl(MtbColt ul) {
|
||||
MtbCols cols = new MtbCols()
|
||||
.setCodMdep(ul.getCodMdep())
|
||||
.setCausale(MtbCols.Causale.ANOMALIA_RIMOSSA)
|
||||
.setValore(ul.getIdAnomalia().toString());
|
||||
ul.setIdAnomalia(EmsRestConstants.LONG_NULL)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
cols.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
ul.getMtbCols().add(cols);
|
||||
return ul;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user