refactor: refs #7398 Refactor and change ekt_scan
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
1f370c8814
commit
2ffdce3c64
|
@ -23,42 +23,39 @@ BEGIN
|
|||
DECLARE vXtraLongAgj INT;
|
||||
DECLARE vDefaultKlo INT;
|
||||
|
||||
SELECT
|
||||
ec.usefulAuctionLeftSegmentLength,
|
||||
ec.standardBarcodeLength,
|
||||
ec.floridayBarcodeLength,
|
||||
ec.floramondoBarcodeLength,
|
||||
ec.defaultKlo
|
||||
INTO
|
||||
vUsefulAuctionLeftSegmentLength,
|
||||
SELECT usefulAuctionLeftSegmentLength,
|
||||
standardBarcodeLength,
|
||||
floridayBarcodeLength,
|
||||
floramondoBarcodeLength,
|
||||
defaultKlo
|
||||
INTO vUsefulAuctionLeftSegmentLength,
|
||||
vStandardBarcodeLength,
|
||||
vFloridayBarcodeLength,
|
||||
vFloramondoBarcodeLength,
|
||||
vDefaultKlo
|
||||
FROM edi.ektConfig ec;
|
||||
FROM ektConfig;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ekt;
|
||||
CREATE TEMPORARY TABLE tmp.ekt
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
|
||||
ENGINE = MEMORY
|
||||
SELECT id ektFk FROM ekt LIMIT 0;
|
||||
|
||||
CASE
|
||||
CASE
|
||||
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
WHERE e.cps = vBarcode
|
||||
OR e.batchNumber = vBarcode;
|
||||
|
||||
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT e.id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
WHERE e.pro = MID(vBarcode,2,6)
|
||||
AND CAST(e.ptd AS SIGNED) = MID(vBarcode,8,5);
|
||||
AND CAST(e.ptd AS SIGNED) = MID(vBarcode, 8, 5);
|
||||
|
||||
ELSE
|
||||
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0');
|
||||
SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
|
||||
SET vAuction = MID(vBarcode, 1, 3);
|
||||
SET vKlo = MID(vBarcode, 4, 2);
|
||||
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
||||
|
@ -69,21 +66,25 @@ BEGIN
|
|||
-- Clásico de subasta
|
||||
-- Trade standard
|
||||
-- Trade que construye como la subasta
|
||||
-- Trade como el anterior pero sin trade code
|
||||
-- Trade como el anterior pero sin trade code
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM ekt
|
||||
WHERE fec >= vFec - INTERVAL 1 DAY
|
||||
AND ((
|
||||
vKlo = vDefaultKlo
|
||||
AND (
|
||||
(vKlo = vDefaultKlo
|
||||
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj))
|
||||
OR (klo = vKlo
|
||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
|
||||
) OR (
|
||||
klo = vKlo
|
||||
AND auction = vAuction
|
||||
AND agj = vShortAgj)
|
||||
AND agj = vShortAgj
|
||||
) OR (
|
||||
klo = auction -- No se si se refiere a esto
|
||||
)
|
||||
)
|
||||
ORDER BY agj DESC, fec DESC
|
||||
LIMIT 1;
|
||||
ORDER BY agj DESC, fec DESC
|
||||
LIMIT 1;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
||||
|
@ -91,9 +92,11 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
WHERE e.batchNumber
|
||||
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength)
|
||||
FROM ektRecent e
|
||||
WHERE e.batchNumber = LEFT(
|
||||
vBarcode,
|
||||
vUsefulAuctionLeftSegmentLength
|
||||
)
|
||||
AND e.batchNumber > 0;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
@ -103,7 +106,7 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
FROM ektRecent e
|
||||
WHERE e.putOrderFk = vBarcode;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
@ -113,9 +116,8 @@ BEGIN
|
|||
IF NOT vIsFound THEN
|
||||
INSERT INTO tmp.ekt
|
||||
SELECT id
|
||||
FROM edi.ektRecent e
|
||||
WHERE e.deliveryNumber
|
||||
= MID(vBarcode, 4, 13)
|
||||
FROM ektRecent e
|
||||
WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
|
||||
AND e.deliveryNumber > 0;
|
||||
|
||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||
|
@ -124,7 +126,7 @@ BEGIN
|
|||
|
||||
IF vIsFound THEN
|
||||
UPDATE ekt e
|
||||
JOIN tmp.ekt t ON t.ektFk = e.id
|
||||
JOIN tmp.ekt t ON t.ektFk = e.id
|
||||
SET e.scanned = TRUE;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
Loading…
Reference in New Issue