fix: refs #5320 withoutHaving
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Sergio De la torre 2024-09-30 08:25:40 +02:00
parent 488427ec97
commit 1f5c0d3e94
1 changed files with 17 additions and 21 deletions

View File

@ -55,24 +55,20 @@ BEGIN
SELECT ts.saleFk, SELECT ts.saleFk,
ts.itemFk, ts.itemFk,
CAST(0 AS DECIMAL(10,0)) saleOrder, CAST(0 AS DECIMAL(10,0)) saleOrder,
IF(ish.visible > 0 OR iss.id, 1, 100000) * (IF(ish.visible > 0 OR iss.id, 1, 100000) *
IFNULL(p2.pickingOrder, p.pickingOrder) `order`, COALESCE(p2.pickingOrder, p.pickingOrder)) `order`,
TO_SECONDS(IF(iss.id, TO_SECONDS(COALESCE(iss.created, ish.created)) - TO_SECONDS(MAKEDATE(IFNULL(YEAR(iss.created), YEAR(ish.created)), 1)) priority,
iss.created - INTERVAL vCurrentYear YEAR,
ish.created - INTERVAL YEAR(ish.created) YEAR)) priority,
CONCAT( CONCAT(
IF(iss.id, IF(iss.id, CONCAT('< ', COALESCE(wk.`code`, '---'),' > '), ''),
CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), p.`code`
''), ) COLLATE utf8_general_ci placement,
p.`code`) COLLATE utf8_general_ci placement,
sh.priority shelvingPriority, sh.priority shelvingPriority,
sh.code COLLATE utf8_general_ci shelving, sh.code COLLATE utf8_general_ci shelving,
ish.created, ish.created,
ish.visible, ish.visible,
IFNULL( COALESCE(
IF(st.code = 'previousByPacking', ish.packing, g.`grouping`), IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),1) `grouping`,
1) `grouping`, (st.code = 'previousPrepared') isPreviousPrepared,
st.code = 'previousPrepared' isPreviousPrepared,
iss.id itemShelvingSaleFk, iss.id itemShelvingSaleFk,
ts.ticketFk, ts.ticketFk,
iss.id, iss.id,
@ -80,11 +76,11 @@ BEGIN
iss.userFk, iss.userFk,
ts.quantity ts.quantity
FROM tSale ts FROM tSale ts
LEFT JOIN (SELECT DISTINCT saleFk LEFT JOIN (SELECT st.saleFk
FROM saleTracking st FROM saleTracking st
JOIN state s ON s.id = st.stateFk JOIN state s ON s.id = st.stateFk
WHERE st.isChecked WHERE st.isChecked
AND s.semaphore = 1) st ON st.saleFk = ts.saleFk AND s.semaphore = 1) st ON st.saleFk = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.code = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
@ -93,14 +89,14 @@ BEGIN
JOIN warehouse w ON w.id = sc.warehouseFk JOIN warehouse w ON w.id = sc.warehouseFk
LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk
LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk
AND iss.itemShelvingFk = ish.id AND iss.itemShelvingFk = ish.id
LEFT JOIN worker wk ON wk.id = iss.userFk LEFT JOIN worker wk ON wk.id = iss.userFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
LEFT JOIN parking p2 ON p2.id = sg.parkingFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk
WHERE w.id = vWarehouseFk WHERE w.id = vWarehouseFk
AND NOT sc.isHideForPickers AND NOT sc.isHideForPickers
HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; AND ((iss.id IS NOT NULL AND st.saleFk IS NOT NULL) OR st.saleFk IS NULL);
CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2
(INDEX(saleFk), INDEX(olderPriority)) (INDEX(saleFk), INDEX(olderPriority))