feat: refs #7203 remove numbres alertLevel #2546

Merged
jgallego merged 2 commits from 7203-alertLevel into dev 2024-06-06 09:48:30 +00:00
16 changed files with 93 additions and 147 deletions

View File

@ -9,7 +9,7 @@
}, },
"vn": { "vn": {
"view": { "view": {
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345"
Review

descartar?

descartar?
} }
} }
} }

View File

@ -65,11 +65,12 @@ BEGIN
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
JOIN vn.state st ON st.id = tt.stateFk JOIN vn.state st ON st.id = tt.stateFk
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE sc.componentFk = 17 WHERE sc.componentFk = 17
AND sc.isGreuge = 0 AND sc.isGreuge = 0
AND t.shipped >= '2016-10-01' AND t.shipped >= '2016-10-01'
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
AND st.alertLevel >= 3; AND st.alertLevel >= al.id;
DELETE g.* DELETE g.*
FROM vn.greuge g FROM vn.greuge g

View File

@ -74,9 +74,10 @@ BEGIN
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseFk = vWarehouse AND t.warehouseFk = vWarehouse
AND s.alertLevel = 3 AND s.alertLevel = al.id
) t ) t
GROUP BY itemFk GROUP BY itemFk
HAVING quantity > 0; HAVING quantity > 0;

View File

@ -121,6 +121,7 @@ BEGIN
) )
SELECT t.id INTO vTicket SELECT t.id INTO vTicket
FROM vn.ticket t FROM vn.ticket t
JOIN vn.alertLevel al ON al.code = 'FREE'
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
JOIN hedera.`order` o JOIN hedera.`order` o
@ -131,7 +132,7 @@ BEGIN
WHERE o.id = vSelf WHERE o.id = vSelf
AND t.refFk IS NULL AND t.refFk IS NULL
AND tp.ticketFk IS NULL AND tp.ticketFk IS NULL
AND IFNULL(tls.alertLevel,0) = 0 AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id)
LIMIT 1; LIMIT 1;
-- Crea el ticket en el caso de no existir uno adecuado -- Crea el ticket en el caso de no existir uno adecuado

View File

@ -16,12 +16,13 @@ BEGIN
m.created, m.created,
TIMESTAMPADD(DAY, tp.life, t.shipped) expired, TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
m.quantity < 0 isIn, m.quantity < 0 isIn,
m.isPicked OR s.alertLevel > 1 isPicked m.isPicked OR s.alertLevel > al.id isPicked
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = m.itemFk JOIN vn.item i ON i.id = m.itemFk
JOIN vn.itemType tp ON tp.id = i.typeFk JOIN vn.itemType tp ON tp.id = i.typeFk
JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION'
WHERE ( WHERE (
vTableId IS NULL vTableId IS NULL
OR (vTableName = 'ticket' AND t.id = vTableId) OR (vTableName = 'ticket' AND t.id = vTableId)

View File

@ -153,7 +153,9 @@ BEGIN
FROM tmp.ticketToInvoice ti FROM tmp.ticketToInvoice ti
LEFT JOIN ticketState ts ON ti.id = ts.ticketFk LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
JOIN state s JOIN state s
WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); JOIN alertLevel al ON al.code = 'DELIVERED'
WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id)
AND s.`code` = getAlert3State(ti.id);
INSERT INTO ticketTracking(stateFk, ticketFk, userFk) INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
SELECT * FROM tmp.updateInter; SELECT * FROM tmp.updateInter;

View File

@ -6,14 +6,16 @@ BEGIN
(PRIMARY KEY (ticketFk)) (PRIMARY KEY (ticketFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT t.id ticketFk, t.clientFk SELECT t.id ticketFk, t.clientFk
FROM vn.ticket t FROM ticket t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN alertLevel al ON al.code = 'DELIVERED'
JOIN vn.client c ON c.id = t.clientFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN client c ON c.id = t.clientFk
WHERE c.typeFk IN ('normal','handMaking','internalUse') WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND ( AND (
t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate
OR ( OR (
ts.alertLevel < 3 ts.alertLevel < al.id
AND t.shipped >= vStartingDate AND t.shipped >= vStartingDate
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
) )

View File

@ -67,7 +67,7 @@ proc: BEGIN
wk.code salesPersonCode, wk.code salesPersonCode,
p.id provinceFk, p.id provinceFk,
tls.productionOrder, tls.productionOrder,
IFNULL(tls.alertLevel, 0) alertLevel, IFNULL(tls.alertLevel, al.id) alertLevel,
t.isBoxed palletized, t.isBoxed palletized,
IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion,
tlu.lastUpdated, tlu.lastUpdated,
@ -81,6 +81,7 @@ proc: BEGIN
rm.bufferFk rm.bufferFk
FROM tmp.productionTicket tt FROM tmp.productionTicket tt
JOIN ticket t ON tt.ticketFk = t.id JOIN ticket t ON tt.ticketFk = t.id
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id
LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN `state` st ON st.id = tst.state
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk

View File

@ -7,13 +7,16 @@ BEGIN
DECLARE vShipped DATE; DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT; DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT; DECLARE vAlertLevel INT;
DECLARE vAlertLevelFree INT;
SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id
INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree
FROM ticket t FROM ticket t
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket; WHERE t.id = vTicket;
IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN
IF vShipped >= util.VN_CURDATE() THEN IF vShipped >= util.VN_CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF; END IF;

View File

@ -1,49 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketMissed_List`(vTicketFk INT)
BEGIN
DECLARE vParkingFk INT;
DECLARE vParked DATETIME;
DECLARE vLevel INT;
DECLARE vCollectionFk INT;
SELECT IFNULL(`level`,0), IFNULL(collectionFk,0)
INTO vLevel, vCollectionFk
FROM vn.ticketCollection
WHERE ticketFk = vTicketFk
LIMIT 1;
SELECT created, parkingFk
INTO vParked, vParkingFk
FROM vn.ticketParking
WHERE ticketFk = vTicketFk;
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
JOIN vn.state s ON s.id = tst.state
WHERE (s.alertLevel < 2
AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea
AND (
(
( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked )
OR
( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) )
)
)) -- Etiquetas que no se han escaneado y ya estamos con una posterior
OR
(s.alertLevel > 1
AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea
AND tp.created < vParked
AND t.packages <=> 0);
END$$
DELIMITER ;

View File

@ -42,7 +42,9 @@ BEGIN
JOIN vn.zone z ON z.id = t.zoneFk JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk JOIN vn.agencyMode am ON am.id = z.agencyModeFk
JOIN vn.state s ON s.id = tst.state JOIN vn.state s ON s.id = tst.state
WHERE (s.alertLevel < 2 JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED'
JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION'
WHERE (s.alertLevel < alPacked.id
Review

tabulación

tabulación
AND tp.parkingFk = vParkingFk AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea AND sc.isPackagingArea
AND ( AND (
@ -55,7 +57,7 @@ BEGIN
) )
) -- Etiquetas que no se han escaneado y ya estamos con una posterior ) -- Etiquetas que no se han escaneado y ya estamos con una posterior
OR OR
(s.alertLevel > 1 (s.alertLevel > alOnPreparation.id
AND tp.parkingFk = vParkingFk AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea AND sc.isPackagingArea
AND tp.created < vParked AND tp.created < vParked

View File

@ -10,14 +10,17 @@ BEGIN
*/ */
DECLARE vAlertLevel INT; DECLARE vAlertLevel INT;
DECLARE vAlertLevelPacked INT;
SELECT s.alertLevel INTO vAlertLevel SELECT s.alertLevel, al.id
INTO vAlertLevel, vAlertLevelPacked
FROM state s FROM state s
JOIN ticketStateToday tst ON tst.state = s.id JOIN ticketStateToday tst ON tst.state = s.id
JOIN alertLevel al ON al.code = 'PACKED'
WHERE tst.ticketFk = vTicketFk WHERE tst.ticketFk = vTicketFk
LIMIT 1; LIMIT 1;
IF vAlertLevel < 2 THEN IF vAlertLevel < vAlertLevelPacked THEN
CALL vn.ticket_setState(vTicketFk, vStateCode); CALL vn.ticket_setState(vTicketFk, vStateCode);

View File

@ -1,26 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
/*
* @deprecated:utilizar ticket_setState
*/
DECLARE vAlertLevel INT;
SELECT s.alertLevel INTO vAlertLevel
FROM vn.state s
JOIN vn.ticketState ts ON ts.stateFk = s.id
WHERE ts.ticketFk = vTicketFk;
IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN
INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
SELECT id, vTicketFk, account.myUser_getId()
FROM vn.state
WHERE `code` = vStateCode collate utf8_unicode_ci;
END IF;
END$$
DELIMITER ;

View File

@ -13,10 +13,11 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket CREATE TEMPORARY TABLE tmp.ticket
SELECT ticketFk SELECT ticketFk
FROM tmp.productionBuffer FROM tmp.productionBuffer
JOIN alertLevel al ON al.code = 'FREE'
WHERE shipped = util.VN_CURDATE() WHERE shipped = util.VN_CURDATE()
AND problem LIKE '%I:%' AND problem LIKE '%I:%'
AND (HH <= vHour OR HH = vHour AND mm < vMinute) AND (HH <= vHour OR HH = vHour AND mm < vMinute)
AND alertLevel = 0; AND alertLevel = al.id;
OPEN cur1; OPEN cur1;

View File

@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse
BEFORE INSERT ON `expedition` BEFORE INSERT ON `expedition`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
DECLARE intcounter INT; DECLARE vMaxCounter INT;
DECLARE vShipFk INT;
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
@ -12,16 +11,17 @@ BEGIN
UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk;
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter

vIntCounter

vIntCounter
FROM expedition e FROM expedition e
INNER JOIN ticket t1 ON e.ticketFk = t1.id JOIN alertLevel al ON al.code = 'DELIVERED'
JOIN ticket t1 ON e.ticketFk = t1.id
LEFT JOIN ticketState ts ON ts.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
AND t1.warehouseFk = t2.warehouseFk AND t1.warehouseFk = t2.warehouseFk
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk
AND t1.agencyModeFk = t2.agencyModeFk; AND t1.agencyModeFk = t2.agencyModeFk;
SET NEW.`counter` = intcounter; SET NEW.`counter` = vMaxCounter;
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,6 +1,9 @@
{ {
"name": "RoleInherit", "name": "RoleInherit",
"base": "VnModel", "base": "VnModel",
"mixins": {
"Loggable": true
},
"options": { "options": {
"mysql": { "mysql": {
"table": "account.roleInherit" "table": "account.roleInherit"