5342-monitor.tickets_isFragile #1393
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE `vn`.`itemType` ADD isFragile tinyint(1) NULL;
|
||||
ALTER TABLE `vn`.`itemType` MODIFY COLUMN isFragile tinyint(1) DEFAULT 0 NOT NULL;
|
||||
UPDATE `vn`.`itemType`
|
||||
SET isFragile = 1
|
||||
WHERE code IN ('ZKA', 'ZKE');
|
|
@ -1,35 +0,0 @@
|
|||
DROP PROCEDURE IF EXISTS `vn`.`sale_getWarnings`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`sale_getWarnings`()
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula las advertencias de cada venta para un conjunto de tickets.
|
||||
*
|
||||
* @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular
|
||||
* @return tmp.sale_warnings
|
||||
*/
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings;
|
||||
CREATE TEMPORARY TABLE tmp.sale_warnings (
|
||||
ticketFk INT(11),
|
||||
saleFk INT(11),
|
||||
isFragile INTEGER(1) DEFAULT 0,
|
||||
PRIMARY KEY (ticketFk, saleFk)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
-- Frágil
|
||||
INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile)
|
||||
SELECT tt.ticketFk, s.id, TRUE
|
||||
FROM tmp.sale_getWarnings tt
|
||||
LEFT JOIN sale s ON s.ticketFk = tt.ticketFk
|
||||
LEFT JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk
|
||||
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE dm.code IN ('AGENCY', 'DELIVERY')
|
||||
AND (ic.code = 'plant' OR it.code IN ('ZKA', 'ZKE'));
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -11,7 +11,26 @@ BEGIN
|
|||
* @table tmp.sale_getWarnings(ticketFk) Identificadores de los tickets a calcular
|
||||
* @return tmp.ticket_warnings
|
||||
*/
|
||||
CALL sale_getWarnings();
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.sale_warnings;
|
||||
CREATE TEMPORARY TABLE tmp.sale_warnings (
|
||||
ticketFk INT(11),
|
||||
saleFk INT(11),
|
||||
isFragile INTEGER(1) DEFAULT 0,
|
||||
PRIMARY KEY (ticketFk, saleFk)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
-- Frágil
|
||||
INSERT INTO tmp.sale_warnings(ticketFk, saleFk, isFragile)
|
||||
SELECT tt.ticketFk, s.id, TRUE
|
||||
FROM tmp.sale_getWarnings tt
|
||||
LEFT JOIN sale s ON s.ticketFk = tt.ticketFk
|
||||
LEFT JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||
vicent marked this conversation as resolved
Outdated
|
||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
LEFT JOIN agencyMode am ON am.id = tt.agencyModeFk
|
||||
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE dm.code IN ('AGENCY')
|
||||
AND (ic.code = 'plant' OR it.isFragile);
|
||||
vicent marked this conversation as resolved
Outdated
jgallego
commented
si ací deixes plant no es queda tot igual, canvia tot per a que siga isFragile, sino el dia que creen un tipo de planta que no siga fragile, no podrien. si ací deixes plant no es queda tot igual, canvia tot per a que siga isFragile, sino el dia que creen un tipo de planta que no siga fragile, no podrien.
vicent
commented
no entenc molt bé, que cree un camp isFragile per a itemCategory? no entenc molt bé, que cree un camp isFragile per a itemCategory?
jgallego
commented
seria una opció pero jo no faria ixa, jo rellenaria amb true tots els valors d'ItemType que pertanyan a plantes. seria una opció pero jo no faria ixa, jo rellenaria amb true tots els valors d'ItemType que pertanyan a plantes.
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_warnings;
|
||||
CREATE TEMPORARY TABLE tmp.ticket_warnings
|
||||
|
@ -19,17 +38,10 @@ BEGIN
|
|||
ENGINE = MEMORY
|
||||
SELECT
|
||||
sw.ticketFk,
|
||||
MAX(sw.isFragile) AS isFragile,
|
||||
0 AS totalWarnings
|
||||
MAX(sw.isFragile) AS isFragile
|
||||
FROM tmp.sale_warnings sw
|
||||
GROUP BY sw.ticketFk;
|
||||
|
||||
UPDATE tmp.ticket_warnings tw
|
||||
SET tw.totalWarnings =
|
||||
(
|
||||
(tw.isFragile)
|
||||
);
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.sale_warnings;
|
||||
END$$
|
||||
|
|
|
@ -402,6 +402,9 @@ module.exports = Self => {
|
|||
tmp.filter,
|
||||
tmp.ticket_problems,
|
||||
tmp.sale_getProblems,
|
||||
tmp.sale_warnings,
|
||||
tmp.sale_getWarnings,
|
||||
tmp.ticket_warnings,
|
||||
tmp.risk`);
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
|
|
Loading…
Reference in New Issue
açò es molt raro, no se lo que fa, no te join..per a canviar-ho pots canviar-ho dalt directe no?
Eliminar este trozo de código.