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,22 +23,19 @@ BEGIN
|
||||||
DECLARE vXtraLongAgj INT;
|
DECLARE vXtraLongAgj INT;
|
||||||
DECLARE vDefaultKlo INT;
|
DECLARE vDefaultKlo INT;
|
||||||
|
|
||||||
SELECT
|
SELECT usefulAuctionLeftSegmentLength,
|
||||||
ec.usefulAuctionLeftSegmentLength,
|
standardBarcodeLength,
|
||||||
ec.standardBarcodeLength,
|
floridayBarcodeLength,
|
||||||
ec.floridayBarcodeLength,
|
floramondoBarcodeLength,
|
||||||
ec.floramondoBarcodeLength,
|
defaultKlo
|
||||||
ec.defaultKlo
|
INTO vUsefulAuctionLeftSegmentLength,
|
||||||
INTO
|
|
||||||
vUsefulAuctionLeftSegmentLength,
|
|
||||||
vStandardBarcodeLength,
|
vStandardBarcodeLength,
|
||||||
vFloridayBarcodeLength,
|
vFloridayBarcodeLength,
|
||||||
vFloramondoBarcodeLength,
|
vFloramondoBarcodeLength,
|
||||||
vDefaultKlo
|
vDefaultKlo
|
||||||
FROM edi.ektConfig ec;
|
FROM ektConfig;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ekt;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ekt
|
||||||
CREATE TEMPORARY TABLE tmp.ekt
|
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id ektFk FROM ekt LIMIT 0;
|
SELECT id ektFk FROM ekt LIMIT 0;
|
||||||
|
|
||||||
|
@ -46,19 +43,19 @@ BEGIN
|
||||||
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
WHEN LENGTH(vBarcode) <= vFloridayBarcodeLength THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.cps = vBarcode
|
WHERE e.cps = vBarcode
|
||||||
OR e.batchNumber = vBarcode;
|
OR e.batchNumber = vBarcode;
|
||||||
|
|
||||||
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
WHEN LENGTH(vBarcode) = vFloramondoBarcodeLength THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.pro = MID(vBarcode,2,6)
|
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
|
ELSE
|
||||||
SET vBarcode = LPAD(vBarcode,vStandardBarcodeLength,'0');
|
SET vBarcode = LPAD(vBarcode, vStandardBarcodeLength, '0');
|
||||||
SET vAuction = MID(vBarcode, 1, 3);
|
SET vAuction = MID(vBarcode, 1, 3);
|
||||||
SET vKlo = MID(vBarcode, 4, 2);
|
SET vKlo = MID(vBarcode, 4, 2);
|
||||||
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
SET vFec = MAKEDATE(YEAR(util.VN_CURDATE()), MID(vBarcode, 6, 3));
|
||||||
|
@ -74,13 +71,17 @@ BEGIN
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM ekt
|
FROM ekt
|
||||||
WHERE fec >= vFec - INTERVAL 1 DAY
|
WHERE fec >= vFec - INTERVAL 1 DAY
|
||||||
AND ((
|
AND (
|
||||||
vKlo = vDefaultKlo
|
(vKlo = vDefaultKlo
|
||||||
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
AND (klo = vKlo OR klo IS NULL OR klo = 0)
|
||||||
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj))
|
AND agj IN (vShortAgj, vLongAgj, vXtraLongAgj)
|
||||||
OR (klo = vKlo
|
) OR (
|
||||||
|
klo = vKlo
|
||||||
AND auction = vAuction
|
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
|
ORDER BY agj DESC, fec DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
@ -91,9 +92,11 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.batchNumber
|
WHERE e.batchNumber = LEFT(
|
||||||
= LEFT(vBarcode,vUsefulAuctionLeftSegmentLength)
|
vBarcode,
|
||||||
|
vUsefulAuctionLeftSegmentLength
|
||||||
|
)
|
||||||
AND e.batchNumber > 0;
|
AND e.batchNumber > 0;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
@ -103,7 +106,7 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.putOrderFk = vBarcode;
|
WHERE e.putOrderFk = vBarcode;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
@ -113,9 +116,8 @@ BEGIN
|
||||||
IF NOT vIsFound THEN
|
IF NOT vIsFound THEN
|
||||||
INSERT INTO tmp.ekt
|
INSERT INTO tmp.ekt
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM edi.ektRecent e
|
FROM ektRecent e
|
||||||
WHERE e.deliveryNumber
|
WHERE e.deliveryNumber = MID(vBarcode, 4, 13)
|
||||||
= MID(vBarcode, 4, 13)
|
|
||||||
AND e.deliveryNumber > 0;
|
AND e.deliveryNumber > 0;
|
||||||
|
|
||||||
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
SELECT COUNT(*) FROM tmp.ekt INTO vIsFound;
|
||||||
|
|
Loading…
Reference in New Issue