refactor: refs #7920 Major changes
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2024-11-13 09:03:44 +01:00
parent c2381f0feb
commit 779a75cd78
28 changed files with 1892 additions and 1823 deletions

View File

@ -32,7 +32,7 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tVisible
SELECT itemFk, SUM(visible) totalVisible
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
WHERE sc.warehouseFk = vWarehouseFk

View File

@ -9,7 +9,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;

View File

@ -10,7 +10,7 @@ BEGIN
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;

View File

@ -83,7 +83,7 @@ BEGIN
AND s.semaphore = 1
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk

View File

@ -1,10 +1,15 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(
vShelvingCode VARCHAR(3),
vFromEntryFk INT,
vToEntryFk INT
)
BEGIN
/**
* Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr<EFBFBD>cula
* Divide las compras entre dos entradas de
* acuerdo con lo ubicado en una matricula.
*
* @param vShelvingFk Identificador de vn.shelving
* @param vShelvingCode Código de vn.shelving
* @param vFromEntryFk Entrada origen
* @param vToEntryFk Entrada destino
*/
@ -23,7 +28,7 @@ BEGIN
WHERE b.entryFk = vFromEntryFk
ORDER BY b.stickers DESC
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci
WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci
AND NOT ish.isSplit
GROUP BY ish.id;
@ -107,9 +112,10 @@ BEGIN
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
END IF;
UPDATE itemShelving
SET isSplit = TRUE
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
UPDATE itemShelving ish
JOIN shelving sh ON sh.id = ish.shelvingFk
SET ish.isSplit = TRUE
WHERE sh.code = vShelvingCode COLLATE utf8_general_ci;
END LOOP;
CLOSE cur;
END$$

View File

@ -1,5 +1,9 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(
vShelvingCode VARCHAR(10),
vQuantity INT,
vItemFk INT
)
BEGIN
SELECT ish.itemFk,
@ -9,21 +13,21 @@ BEGIN
ish.itemShelvingFk,
ish.shelving,
ish.stock,
LEAST(ish.stock,quantity) as total,
LEAST(ish.stock,vQuantity) total,
CONCAT(
CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)),
CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
' x ',
ish.packing,
IF (
LEAST(ish.stock,quantity) MOD ish.packing,
CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))),
LEAST(ish.stock, vQuantity) MOD ish.packing,
CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
''
),
' = ',
LEAST(ish.stock,quantity)
) as proposal
FROM vn.itemShelvingPlacementSupplyStock ish
WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci
LEAST(ish.stock, vQuantity)
) proposal
FROM itemShelvingPlacementSupplyStock ish
WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
AND ish.itemFk = vItemFk;
END$$

View File

@ -1,5 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT )
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(
vSectorFk INT
)
BEGIN
DECLARE vId INT;
@ -7,31 +9,35 @@ BEGIN
DECLARE vNextParkingFk INT;
SELECT sh.parkingFk INTO vLastParkingFk
FROM vn.itemShelvingPlacementSupply isps
JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
FROM itemShelvingPlacementSupply isps
JOIN itemShelving ish ON ish.id = isps.itemShelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE isps.userFk = getUser()
ORDER BY isps.created DESC
LIMIT 1;
SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
SELECT ipsl.id INTO vId
FROM vn.itemPlacementSupplyList ipsl
JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
FROM itemPlacementSupplyList ipsl
JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
WHERE ipsl.saldo > 0
AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser())
AND ipsl.sectorFk = vSector
ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created
AND ipsl.sectorFk = vSectorFk
ORDER BY ipsl.repoUserFk DESC,
ipsl.priority DESC,
(ispss.parkingFk = vNextParkingFk) DESC,
ispss.parking DESC,
ipsl.created
LIMIT 1;
UPDATE vn.itemPlacementSupply
UPDATE itemPlacementSupply
SET repoUserFk = getUser()
WHERE id = vId;
SELECT * FROM vn.itemPlacementSupplyList
SELECT * FROM itemPlacementSupplyList
WHERE id = vId
AND sectorFk = vSector;
AND sectorFk = vSectorFk;
END$$
DELIMITER ;

View File

@ -1,5 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(
vItemFk INT,
vSectorFk INT
)
BEGIN
/**
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
@ -13,11 +16,11 @@ BEGIN
SUM(ish.visible) stockTotal,
ish.created,
p.pickingOrder
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk
FROM itemShelving ish
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN warehouse w ON w.id = sc.warehouseFk
WHERE ish.visible > 0
AND ish.itemFk = vItemFk
GROUP BY ish.id

View File

@ -20,7 +20,7 @@ BEGIN
LEFT JOIN (
SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking pk ON pk.id = sh.parkingFk
WHERE ish.created BETWEEN vFromTimed AND vToTimed
GROUP BY itemFk

View File

@ -27,7 +27,7 @@ proc: BEGIN
ish.available
FROM sale s
JOIN itemShelving ish ON ish.itemFk = s.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN productionConfig pc
@ -61,7 +61,7 @@ proc: BEGIN
FROM sale s
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE s.id = vSaleFk;

View File

@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`(
vShelvingFk VARCHAR(8),
vShelvingCode VARCHAR(10),
vBarcode VARCHAR(22),
vQuantity INT,
vPackagingFk VARCHAR(10),
@ -12,7 +12,7 @@ BEGIN
/**
* Añade registro o lo actualiza si ya existe.
*
* @param vShelvingFk matrícula del carro
* @param vShelvingCode matrícula del carro
* @param vBarcode el id del registro
* @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
@ -23,10 +23,15 @@ BEGIN
**/
DECLARE vItemFk INT;
DECLARE vBuyFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN
@ -40,7 +45,7 @@ BEGIN
END IF;
IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking
AND buyFk = vBuyFk) THEN
@ -48,7 +53,9 @@ BEGIN
UPDATE itemShelving
SET visible = visible + vQuantity,
available = available + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking;
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking;
ELSE

View File

@ -1,29 +1,38 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(
vClaimFk INT,
vShelvingCode VARCHAR(10)
)
BEGIN
/**
* Insert items of claim into itemShelving.
*
* @param vClaimFk The claim
* @param vShelvingFk The shelving
* @param vShelvingCode The shelving code
* @table tmp.buyUltimate
*/
DECLARE vWarehouseFk INT;
DECLARE vShelvingFk INT;
SELECT t.warehouseFk INTO vWarehouseFk
FROM claim c
JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
FROM claim c
JOIN claimBeginning cb ON c.id = cb.claimFk
JOIN sale s ON s.id = cb.saleFk
JOIN ticket t ON t.id = s.ticketFk
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
AND bu.warehouseFk = t.warehouseFk
JOIN buy b ON b.id = bu.buyFk
WHERE c.id = vClaimFk;
END$$

View File

@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
vShelvingFk VARCHAR(3),
vShelvingCode VARCHAR(10),
vList TEXT,
vIsChecking BOOL,
vWarehouseFk INT
@ -13,7 +13,7 @@ BEGIN
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
* ese shelving, actualizando los valores del campo itemShelving.isChecked
*
* @param vShelvingFk Identificador de shelving
* @param vShelvingCode Código de shelving
* @param vList JSON array con esta estructura: '[value1, value2, ...]'
* @param vIsChecking Define si hay que añadir o comprobar los items
* @param vWarehouseFk Identificador de warehouse
@ -24,6 +24,11 @@ BEGIN
DECLARE vPath VARCHAR(6);
DECLARE vItemFk INT;
DECLARE vIsChecked BOOL;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
WHILE vCounter < vListLength DO
SET vPath = CONCAT('$[', vCounter, ']');
@ -34,17 +39,17 @@ BEGIN
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;
END IF;
IF NOT vIsChecking OR NOT vIsChecked THEN
CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
END IF;
UPDATE itemShelving
SET isChecked = vIsChecked
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND isChecked IS NULL;

View File

@ -1,10 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8))
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(
vShelvingCode VARCHAR(10)
)
BEGIN
/**
* Lista artículos de itemshelving
* Lista artículos de itemShelving.
*
* @param vSelf matrícula del carro
* @param vShelvingCode Matrícula del carro
**/
SELECT ish.itemFk item,
i.name,
@ -22,9 +24,9 @@ BEGIN
ish.buyFk
FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
LEFT JOIN parking p ON s.parkingFk = p.id
JOIN shelving s ON s.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = s.parkingFk
JOIN hedera.imageConfig ic
WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode;
END$$
DELIMITER ;

View File

@ -1,21 +1,31 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10))
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
vShelvingCode VARCHAR(10)
)
BEGIN
/**
* Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula
* del carro que se le ha pasado.
* Devuelve un listado de posibles ubicaciones alternativas a ubicar
* los item de la matricula del carro que se le ha pasado.
*
* @param vShelvingFk matricula del carro
* @param vShelvingCode Matricula del carro
*/
SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2
JOIN shelving sh ON sh.code = is2.shelvingFk
JOIN shelving sh ON sh.id = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId()
LEFT JOIN operator o ON o.sectorFk = s.id
AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
AND is3.shelvingFk = vShelvingFk
WHERE is2.shelvingFk <> vShelvingFk
GROUP BY is2.id
ORDER BY p.pickingOrder DESC;
END$$

View File

@ -16,7 +16,7 @@ BEGIN
ish.itemFk itemFk,
sh.priority
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking pk ON pk.id = sh.parkingFk
WHERE ish.itemFk = vItemFk
ORDER BY sh.priority DESC, created ASC;

View File

@ -1,14 +1,14 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
vBarcodeItem INT,
vShelvingFK VARCHAR(10)
vShelvingCode VARCHAR(10)
)
BEGIN
/**
* Obtiene el precio y visible de un item
*
* @param vBarcodeItem barcode de artículo
* @param vShelvingFK Ubicación actual del artículo
* @param vShelvingCode Ubicación actual del artículo
*/
DECLARE vIsItem BOOL;
DECLARE vBuyFk INT;
@ -44,12 +44,13 @@ BEGIN
FROM vn.buy b
WHERE b.id = vBuyFk
) SELECT v.itemFk,
vShelvingFK,
vShelvingCode,
v.itemCost,
SUM(ish.visible) visible
FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.id = ish.shelvingFK
JOIN visible v
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci
WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
AND ish.itemFk = v.itemFk;
END$$
DELIMITER ;

View File

@ -1,14 +1,20 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3))
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(
vShelvingCode VARCHAR(10)
)
BEGIN
/* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
/**
* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
*
* @param vShelvingFk Matrícula del carro o pallet
* @param vShelvingCode Matrícula del carro o pallet
*/
DECLARE vWarehouseFk INT;
DECLARE vStockScopeDays INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT s.warehouseFk, stockScopeDays
INTO vWarehouseFk, vStockScopeDays
@ -30,7 +36,7 @@ BEGIN
ENGINE = MEMORY
SELECT itemFk, SUM(visible) visible
FROM itemShelving
WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
WHERE shelvingFk = vShelvingFk
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay
@ -52,7 +58,7 @@ BEGIN
SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE()
FROM itemShelving ish
JOIN tmp.tItems i ON i.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON sh.parkingFk = p.id
JOIN sector s ON s.id = p.sectorFk
WHERE s.isReserve
@ -110,7 +116,7 @@ BEGIN
UPDATE tmp.tStockByDay sbd
JOIN (SELECT ish.itemFK, SUM(ish.visible) amount
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
WHERE s.warehouseFk = vWarehouseFk
@ -150,10 +156,10 @@ BEGIN
p.sectorFk,
ish.shelvingFk
FROM itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = parkingFk
LEFT JOIN vn.sector s ON s.id = p.sectorFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci
WHERE ish.shelvingFk = vShelvingFk
) sub4 ON sub4.itemFk = ts.itemFk
LEFT JOIN sector s ON s.id = sub4.sectorFk
LEFT JOIN item i ON i.id = ts.itemFk

View File

@ -42,7 +42,7 @@ BEGIN
JOIN item i ON i.id = ish.itemFk
JOIN itemType it ON it.id = i.typeFk
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared

View File

@ -1,6 +1,6 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`(
vShelvingFk VARCHAR(10) COLLATE utf8_general_ci,
vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT,
vQuantity INT
)
@ -9,9 +9,9 @@ BEGIN
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
* @param vShelvingFk id of the shelve where the item is located.
* @param vItemFk article of which the self-consumption ticket is to be created.
* @param vQuantity amount that will stay on the shelve
* @param vShelvingCode Code of the shelve where the item is located
* @param vItemFk Item of which the self-consumption ticket is to be created
* @param vQuantity Amount that will stay on the shelve
*/
DECLARE vVisible INT;
DECLARE vClientFk INT;
@ -21,6 +21,11 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vItemShelvingFk INT;
DECLARE vAddressFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code = vShelvingCode;
SELECT c.id,
pc.clientSelfConsumptionFk,
@ -37,7 +42,7 @@ BEGIN
JOIN parking p ON p.sectorFk = s.id
JOIN shelving s2 ON s2.parkingFk = p.id
JOIN productionConfig pc
WHERE s2.code = vShelvingFk;
WHERE s2.id = vShelvingFk;
IF vClientFk IS NULL THEN
CALL util.throw('The company does not have a customer assigned');
@ -47,7 +52,7 @@ BEGIN
CALL util.throw('The shelf cannot have NULL or negative quantities');
END IF;
IF vShelvingFk IS NULL THEN
IF vShelvingCode IS NULL THEN
CALL util.throw('The shelf is necessary');
END IF;

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
vItemShelvingFk INT,
vShelvingFk VARCHAR(10)
vShelvingCode VARCHAR(10)
)
BEGIN
/**
@ -9,9 +9,14 @@ BEGIN
* fusionando si coincide el packing y la fecha.
*
* @param vItemShelvingFk Identificador de itemShelving
* @param vShelvingFk Identificador de shelving
* @param vShelvingCode Código de shelving
*/
DECLARE vNewItemShelvingFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT MAX(ish.id) INTO vNewItemShelvingFk
FROM itemShelving ish
@ -26,7 +31,7 @@ BEGIN
AND ish2.packing = ish.packing
AND DATE(ish2.created) = DATE(ish.created)
AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci;
WHERE ish.shelvingFk = vShelvingFk;
IF vNewItemShelvingFk THEN
UPDATE itemShelving ish
@ -38,9 +43,7 @@ BEGIN
DELETE FROM itemShelving
WHERE id = vItemShelvingFk;
ELSE
IF (SELECT EXISTS(SELECT id FROM shelving
WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN
UPDATE itemShelving
SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk;

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
vSelf INT,
vShelvingFK VARCHAR(10),
vShelvingCode VARCHAR(10),
vBuyingValue DECIMAL(10,4),
vQuantity INT
)
@ -12,7 +12,7 @@ BEGIN
* de almacén y shelvings correspondientes
*
* @param vSelf Id de artículo a devaluar
* @param vShelvingFK Ubicación actual del artículo
* @param vShelvingCode Código de shelving / ubicación
* @param vBuyingValue Nuevo precio de coste
* @param vQuantity Cantidad del ítem a pasar a A2
*/
@ -109,10 +109,11 @@ BEGIN
CALL util.throw ('The item has not a buy');
END IF;
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible
FROM itemShelving
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
AND itemFk = vSelf
SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible
FROM itemShelving ish
JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
AND ish.itemFk = vSelf
LIMIT 1;
IF vCurrentVisible IS NULL THEN
@ -388,16 +389,17 @@ BEGIN
userFk,
isChecked)
SELECT vItemA2Fk,
shelvingFk,
ish.shelvingFk,
vQuantity ,
`grouping`,
packing,
packagingFk,
ish.`grouping`,
ish.packing,
ish.packagingFk,
account.myUser_getId(),
isChecked
FROM itemShelving
WHERE itemFK = vSelf
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci
ish.isChecked
FROM itemShelving ish
JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE ish.itemFK = vSelf
AND sh.code = vShelvingCode COLLATE utf8mb3_general_ci
ON DUPLICATE KEY UPDATE
visible = vQuantity + VALUES(visible);

View File

@ -217,7 +217,7 @@ proc: BEGIN
st.code = 'previousPrepared' isPreviousPrepared,
sc.itemPackingTypeFk
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk

View File

@ -74,7 +74,7 @@ w1: WHILE vQuantity >= vPacking DO
p.pickingOrder,
ish.created
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemShelvingSale iss
ON iss.itemShelvingFk = ish.id
@ -264,7 +264,7 @@ w1: WHILE vQuantity >= vPacking DO
SELECT shelvingFk, p.code
INTO vShelving, vParkingCode
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
WHERE ish.id = vItemShelvingFk;

View File

@ -41,7 +41,7 @@ BEGIN
AND iss.created >= vDated
GROUP BY iss.itemShelvingFk, s.itemFk) tISS
ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk

View File

@ -87,7 +87,7 @@ BEGIN
SUM(ish.visible) visible,
s.warehouseFk warehouseFk
FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, s.warehouseFk;

View File

@ -12,12 +12,12 @@ BEGIN
DELETE ish.*
FROM itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
WHERE sh.parkingFk IS NULL
AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
UPDATE shelving sh
LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code`
LEFT JOIN itemShelving its ON its.shelvingFk = sh.id
SET isPrinted = 0,
parkingFk = NULL
WHERE its.id IS NULL
@ -27,11 +27,11 @@ UPDATE shelving sh
OR
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
)
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
SELECT DISTINCT LEFT(its.shelvingFk, 2)
SELECT DISTINCT LEFT(sh.code, 2)
FROM itemShelving its
WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]'
JOIN shelving sh ON sh.id = its.shelvingFk
WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]'
), TRUE);
END$$