feat: previas con sitema de reservas refs #6861
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2024-06-11 12:44:25 +02:00
parent 32aafc3545
commit ed7218c133
10 changed files with 94 additions and 111 deletions

View File

@ -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,
@ -84,12 +77,13 @@ BEGIN
IF vHasThrow THEN
CALL util.throw("No hay disponibilidad para el artículo seleccionado");
ELSE
IF vSaleGroupFk THEN
INSERT INTO saleGroupDetail
SET saleFk = vSaleFk,
saleGroupFk = vSaleGroupFk;
COMMIT;
IF vSaleGroupFk THEN
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
/**
* 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
INTO vHasTooMuchCollections,
vLockName
FROM tCollection
JOIN productionConfig pc ;
FROM tCollection tc
JOIN productionConfig pc;
DROP TEMPORARY TABLE tCollection;
IF vHasTooMuchCollections THEN
CALL util.throw('Hay colecciones pendientes');
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')
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
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;
END IF;
COMMIT;
COMMIT;
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
JOIN saleGroup sg ON sg.id = scsg.saleGroupFk
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
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 ;