feat: previas con sitema de reservas refs #6861 #2176

Merged
carlosap merged 64 commits from 6861-Pasar-modo-trabajo-de-previa-a-reservas into dev 2024-06-25 11:21:03 +00:00
10 changed files with 94 additions and 111 deletions
Showing only changes of commit ed7218c133 - Show all commits

View File

@ -23,7 +23,7 @@ BEGIN
DECLARE vConcept VARCHAR(50);
DECLARE vItemName VARCHAR(50);
DECLARE vHasThrow BOOLEAN DEFAULT FALSE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
@ -48,21 +48,14 @@ BEGIN
IF vAvailable < vQuantity THEN
SET vHasThrow = TRUE;
SELECT vAvailable, vQuantity;
ELSE
START TRANSACTION;
SELECT `name`,
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
INTO vItemName, vConcept
FROM item
WHERE id = vItemFk;
INSERT INTO ticketLog
SET originFk = vTicketFk,
userFk = getUser(),
`action` = 'update',
`description` = CONCAT('Añadido articulo ', vItemName, ' cantidad:', vQuantity);
START TRANSACTION;
INSERT INTO sale
SET itemFk = vItemFk,
jgallego marked this conversation as resolved
Review

açò no ho fa el log asoles¿?

açò no ho fa el log asoles¿?
@ -84,12 +77,13 @@ BEGIN
IF vHasThrow THEN
CALL util.throw("No hay disponibilidad para el artículo seleccionado");
carlosap marked this conversation as resolved Outdated

castella no.

castella no.
ELSE
IF vSaleGroupFk THEN
INSERT INTO saleGroupDetail
SET saleFk = vSaleFk,
saleGroupFk = vSaleGroupFk;
COMMIT;
IF vSaleGroupFk THEN
jgallego marked this conversation as resolved Outdated

no pots posar ací el throw?

no pots posar ací el throw?

No hi ha un error especific per a caada error, s'aprofita la variable vHasThrow en varios puestos

No hi ha un error especific per a caada error, s'aprofita la variable vHasThrow en varios puestos
INSERT INTO saleGroupDetail
SET saleFk = vSaleFk,
saleGroupFk = vSaleGroupFk;
END IF;
END IF ;
COMMIT;
END IF;
END$$
DELIMITER ;

View File

@ -1,11 +1,14 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`(
vUserFk INT,
OUT vCollectionFk INT)
proc:BEGIN
/* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
OUT vCollectionFk INT
)
BEGIN
jgallego marked this conversation as resolved Outdated

formato del comentari

formato del comentari
/**
* Comprueba si existen colecciones libres que se ajustan al perfil del usuario
* y le asigna la más antigua.
* Añade un registro al semillero de colecciones y hace la reserva para la colección
*
* @param vUserFk Id de usuario
* @param vCollectionFk Id de colección
*/
@ -28,17 +31,16 @@ proc:BEGIN
CALL collection_get(vUserFk);
SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0,
collection_assign_lockname
pc.collection_assign_lockname
jgallego marked this conversation as resolved Outdated

alias

alias
INTO vHasTooMuchCollections,
vLockName
FROM tCollection
JOIN productionConfig pc ;
FROM tCollection tc
JOIN productionConfig pc;
DROP TEMPORARY TABLE tCollection;
jgallego marked this conversation as resolved
Review

si hi ha un throw el leave es innecesari

si hi ha un throw el leave es innecesari
IF vHasTooMuchCollections THEN
CALL util.throw('Hay colecciones pendientes');
jgallego marked this conversation as resolved Outdated

castella no

castella no
LEAVE proc;
END IF;
SELECT warehouseFk, itemPackingTypeFk

View File

@ -26,7 +26,7 @@ BEGIN
JOIN vn.saleTracking st ON st.saleFk = sa.saleFk
JOIN vn.`state` s ON s.id = st.stateFk
WHERE st.isChecked
AND s.semaphore = 1
AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY')
jgallego marked this conversation as resolved Outdated

numero no, cal vore quin es l'objectiu del 1

numero no, cal vore quin es l'objectiu del 1
GROUP BY sa.saleFk
) SELECT s.saleFk
FROM sales s

View File

@ -0,0 +1,50 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_moveReserv`(
vItemShelvingFk INT(10),
vItemFk INT(10)
)
BEGIN
/**
* Elimina reservas de un itemShelvingSale e intenta reservar en otra ubicación
*
* @param vItemShelvingFk Id itemShelving
*/
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
SELECT id INTO vItemShelvingFk
FROM itemShelving
WHERE id = vItemShelvingFk
AND FALSE
carlosap marked this conversation as resolved Outdated

açò sempre dona false? es raro

açò sempre dona false? es raro
FOR UPDATE;
UPDATE itemShelving
SET visible = 0,
available = 0
WHERE id = vItemShelvingFk
AND itemFk = vItemFk;
INSERT INTO itemShelvingSaleReserv (saleFk)
SELECT DISTINCT iss.saleFk
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND ish.itemFk = vItemFk
AND NOT iss.isPicked;
DELETE iss
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND ish.itemFk = vItemFk
AND NOT iss.isPicked;
COMMIT;
CALL itemShelvingSale_doReserve();
END$$
DELIMITER ;

View File

@ -1,5 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setSaleGroup`(
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`(
vSaleGroupFk INT(10)
)
BEGIN

View File

@ -46,10 +46,8 @@ BEGIN
CALL util.throw('La cantidad no puede distinta a la reserva');
END IF;
START TRANSACTION;
UPDATE itemShelvingSale
SET isPicked = TRUE,
quantity = vQuantity
@ -62,41 +60,10 @@ BEGIN
FOR UPDATE;
UPDATE itemShelving
SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0, visible - vQuantity))
SET visible = GREATEST(0, visible - vQuantity)
WHERE id = vItemShelvingFk;
COMMIT;
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
UPDATE itemShelving
SET visible = 0,
available = 0
WHERE id = vItemShelvingFk
AND itemFk = vItemFk;
CALL itemShelvingSale_addBySale(vSaleFk);
START TRANSACTION;
INSERT INTO itemShelvingSaleReserv (saleFk)
SELECT DISTINCT iss.saleFk
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND ish.itemFk = vItemFk
AND NOT iss.isPicked;
DELETE iss
FROM itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
WHERE iss.itemShelvingFk = vItemShelvingFk
AND ish.itemFk = vItemFk
AND NOT iss.isPicked;
COMMIT;
CALL itemShelvingSale_doReserve();
END IF;
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
INTO vRemainingQuantity, vTotalQuantity
@ -104,8 +71,6 @@ BEGIN
WHERE saleFk = vSaleFk;
IF vRemainingQuantity = 0 THEN
START TRANSACTION;
CALL saleTracking_new(
vSaleFk,
TRUE,
@ -119,8 +84,12 @@ BEGIN
SET s.quantity = vTotalQuantity,
isPicked = TRUE
WHERE s.id = vSaleFk;
COMMIT;
END IF;
COMMIT;

itemShelvingSaleReserve

itemShelvingSaleReserve
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
CALL itemShelvingSale_moveReserv(vItemShelvingFk, vQuantity);
END IF;
END$$
DELIMITER ;

View File

@ -1,7 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`(
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
vItemShelvingFk INT,
vShelvingFk VARCHAR(3))
vShelvingFk VARCHAR(10)
)
BEGIN
/**
* Transfiere producto de una ubicación a otra, fusionando si coincide el

View File

@ -1,5 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getPartial`()
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`()
BEGIN
/**
* Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas

View File

@ -2,28 +2,24 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
DETERMINISTIC
BEGIN
/**
* Devuelve si sectorCollection tiene reservas
* @param vSelf Id de sectorCollection
*
* returns BOOLEAN
*/
* Devuelve si sectorCollection tiene reservas
* @param vSelf Id de sectorCollection
*
* returns BOOLEAN
*/
DECLARE vHasSalesReserved BOOLEAN;
SELECT DISTINCT COUNT(*)>0 INTO vHasSalesReserved
FROM vn.sectorCollection sc
JOIN vn.sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
JOIN vn.saleGroup sg ON sg.id = scsg.saleGroupFk
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
JOIN vn.sale s ON s.id = sgd.saleFk
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.saleTracking st ON st.saleFk = s.id
SELECT DISTINCT COUNT(*) INTO vHasSalesReserved
FROM sectorCollection sc
JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
jgallego marked this conversation as resolved Outdated

sols un bot

sols un bot
JOIN saleGroup sg ON sg.id = scsg.saleGroupFk
jgallego marked this conversation as resolved Outdated

> 0 redundant

`>` 0 redundant
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
jgallego marked this conversation as resolved Outdated

sense vn.

sense vn.
JOIN sale s ON s.id = sgd.saleFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id
JOIN saleTracking st ON st.saleFk = s.id
WHERE sc.id = vSelf;
RETURN vHasSalesReserved;
END$$
DELIMITER ;

View File

@ -1,29 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
AFTER INSERT ON `itemShelving`
FOR EACH ROW
BEGIN
INSERT INTO vn.itemShelvingLog(
itemShelvingFk,
workerFk,
accion,
itemFk,
shelvingFk,
visible,
`grouping`,
packing,
available
)
VALUES (
NEW.id,
NEW.userFk,
'CREA REGISTRO',
NEW.itemFk,
NEW.shelvingFk,
NEW.visible,
NEW.`grouping`,
NEW.packing,
NEW.available
);
END$$
DELIMITER ;