diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 88ed42e83..b33224e80 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -105,7 +105,7 @@ proc: BEGIN AND DATE(t.shipped) = zc.dated LEFT JOIN ticketParking tp ON tp.ticketFk = t.id LEFT JOIN parking pk ON pk.id = tp.parkingFk - LEFT JOIN tmp.ticketProblem tpr ON tpr.ticketFk = tt.ticketFk + LEFT JOIN tmp.ticketProblems tpr ON tpr.ticketFk = tt.ticketFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 00a8ee727..f718893eb 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -7,7 +7,7 @@ BEGIN * Calcula los problemas para un conjunto de tickets. * Agrupados por ticket * - * @table tmp.tmp.ticket(ticketFk) Identificadores de los tickets a calcular + * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular * @return tmp.ticketProblems */ DECLARE vWarehouseFk INT; @@ -163,7 +163,7 @@ BEGIN END LOOP; CLOSE vCursor; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketProblem ( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketProblems ( ticketFk INT(11), isFreezed BOOL DEFAULT FALSE, risk DECIMAL(10,1) DEFAULT 0, @@ -199,13 +199,18 @@ BEGIN LEFT(CONCAT('F: ',GROUP_CONCAT(CONCAT(i.id, ' ', i.longName) SEPARATOR ', ')), 250) itemShortage, LEFT(CONCAT('R: ',GROUP_CONCAT(CONCAT(i2.id, ' ', i2.longName) SEPARATOR ', ')), 250) itemDelay, LEFT(CONCAT('I: ',GROUP_CONCAT(CONCAT(i3.id, ' ', i3.longName) SEPARATOR ', ')), 250) itemLost, - LEFT(CONCAT('RE: ',GROUP_CONCAT(CONCAT(i4.id, ' ', i4.longName) SEPARATOR ', ')), 250) componentLack, + LEFT(CONCAT('C: ',GROUP_CONCAT(CONCAT(i4.id, ' ', i4.longName) SEPARATOR ', ')), 250) componentLack, LEFT(CONCAT('RE: ',GROUP_CONCAT(CONCAT(i5.id, ' ', i5.longName) SEPARATOR ', ')), 250) rounding FROM tmp.ticket tt JOIN ticket t ON t.id = tt.ticketFk JOIN client c ON c.id = t.clientFk LEFT JOIN sale s ON s.ticketFk = t.id LEFT JOIN tmp.saleProblems ts ON ts.saleFk = s.id + LEFT JOIN item i ON i.id = s.itemFk AND ts.hasItemShortage + LEFT JOIN item i2 ON i2.id = s.itemFk AND ts.hasItemDelay + LEFT JOIN item i3 ON i3.id = s.itemFk AND ts.hasItemLost + LEFT JOIN item i4 ON i4.id = s.itemFk AND FIND_IN_SET('hasComponentLack', s.problem) + LEFT JOIN item i5 ON i5.id = s.itemFk AND ts.hasRounding LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = util.VN_CURDATE() WHERE s.problem <> '' OR t.problem <> '' OR t.risk diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 9b22cb2d2..70c750ef5 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -376,7 +376,7 @@ module.exports = Self => { stmts.push(` DROP TEMPORARY TABLE tmp.filter, - tmp.ticketProblem, + tmp.ticketProblems, tmp.sale_getWarnings, tmp.ticket_warnings `);