Merge branch 'dev' into 6005-backupLabeler
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-11-23 07:33:46 +00:00
commit 68dca67442
5 changed files with 123 additions and 99 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- (Ticket -> Adelantar) Permite mover lineas sin generar negativos
- (Ticket -> Adelantar) Permite modificar la fecha de los tickets
- (Trabajadores -> Notificaciones) Nueva sección (lilium)
### Changed
### Fixed

View File

@ -83201,7 +83201,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `zoneEstimatedDelivery` AS select `t`.`zoneFk` AS `zoneFk`,cast(`util`.`VN_CURDATE`() + interval hour(ifnull(`zc`.`hour`,`z`.`hour`)) * 60 + minute(ifnull(`zc`.`hour`,`z`.`hour`)) minute as time) AS `hourTheoretical`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `totalVolume`,cast(sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) as decimal(5,1)) AS `remainingVolume`,greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) AS `speed`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `hourEffective`,floor(-sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0))) AS `minutesLess`,cast(`zc`.`hour` + interval -sum(if(`s`.`alertLevel` < 2,`sv`.`volume`,0)) * 60 / greatest(ifnull(`lhp`.`m3`,0),ifnull(`dl`.`minSpeed`,0)) minute as time) AS `etc` from (((((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on(`tst`.`ticket` = `t`.`id`)) join `vn`.`state` `s` on(`s`.`id` = `tst`.`state`)) join `vn`.`saleVolume` `sv` on(`sv`.`ticketFk` = `t`.`id`)) left join `vn`.`lastHourProduction` `lhp` on(`lhp`.`warehouseFk` = `t`.`warehouseFk`)) join `vn`.`warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) join `vn`.`warehouseAlias` `wa` on(`wa`.`id` = `w`.`aliasFk`)) straight_join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`zoneClosure` `zc` on(`zc`.`zoneFk` = `t`.`zoneFk` and `zc`.`dated` = `util`.`VN_CURDATE`())) left join `cache`.`departure_limit` `dl` on(`dl`.`warehouse_id` = `t`.`warehouseFk` and `dl`.`fecha` = `util`.`VN_CURDATE`())) where `w`.`hasProduction` <> 0 and cast(`t`.`shipped` as date) = `util`.`VN_CURDATE`() group by `t`.`zoneFk` */;
/*!50001 VIEW `zoneEstimatedDelivery` AS SELECT `t`.`zoneFk` AS `zoneFk`, `zc`.`hour` AS `zoneClosureHour`, `z`.`hour` AS `zoneHour`, `sv`.`volume` AS `volume`, `al`.`hasToRecalcPrice` AS `hasToRecalcPrice`, `lhp`.`m3` AS `m3`, `dl`.`minSpeed` AS `minSpeed` FROM ((((((((((`vn`.`ticket` `t` JOIN `vn`.`ticketStateToday` `tst` ON (`tst`.`ticket` = `t`.`id`)) JOIN `vn`.`state` `s` ON (`s`.`id` = `tst`.`state`)) JOIN `vn`.`saleVolume` `sv` ON (`sv`.`ticketFk` = `t`.`id`)) LEFT JOIN `vn`.`lastHourProduction` `lhp` ON (`lhp`.`warehouseFk` = `t`.`warehouseFk`)) JOIN `vn`.`warehouse` `w` ON (`w`.`id` = `t`.`warehouseFk`)) JOIN `vn`.`warehouseAlias` `wa` ON (`wa`.`id` = `w`.`aliasFk`)) STRAIGHT_JOIN `vn`.`zone` `z` ON (`z`.`id` = `t`.`zoneFk`)) LEFT JOIN `vn`.`zoneClosure` `zc` ON (`zc`.`zoneFk` = `t`.`zoneFk` AND `zc`.`dated` = `util`.`VN_CURDATE`())) LEFT JOIN `cache`.`departure_limit` `dl` ON (`dl`.`warehouse_id` = `t`.`warehouseFk` AND `dl`.`fecha` = `util`.`VN_CURDATE`())) JOIN `vn`.`alertLevel` `al` ON (`al`.`id` = `s`.`alertLevel`)) WHERE `w`.`hasProduction` <> 0 AND CAST(`t`.`shipped` AS date) = `util`.`VN_CURDATE`() */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;

View File

@ -163,19 +163,16 @@ module.exports = Self => {
const stmts = [];
let stmt;
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter');
stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`);
stmts.push(`SET SESSION optimizer_search_depth = 0`);
stmt = new ParameterizedSQL(
`CREATE TEMPORARY TABLE tmp.filter
stmt = new ParameterizedSQL(`
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT
t.id,
SELECT t.id,
t.shipped,
CAST(DATE(t.shipped) AS CHAR) AS shippedDate,
CAST(DATE(t.shipped) AS CHAR) shippedDate,
t.nickname,
t.refFk,
t.routeFk,
@ -183,27 +180,27 @@ module.exports = Self => {
t.clientFk,
t.totalWithoutVat,
t.totalWithVat,
io.id AS invoiceOutId,
io.id invoiceOutId,
a.provinceFk,
p.name AS province,
w.name AS warehouse,
am.name AS agencyMode,
am.id AS agencyModeFk,
st.name AS state,
wk.lastName AS salesPerson,
ts.stateFk AS stateFk,
ts.alertLevel AS alertLevel,
ts.code AS alertLevelCode,
u.name AS userName,
p.name province,
w.name warehouse,
am.name agencyMode,
am.id agencyModeFk,
st.name state,
wk.lastName salesPerson,
ts.stateFk stateFk,
ts.alertLevel alertLevel,
ts.code alertLevelCode,
u.name userName,
c.salesPersonFk,
c.credit,
z.hour AS zoneLanding,
z.name AS zoneName,
z.id AS zoneFk,
z.hour zoneLanding,
z.name zoneName,
z.id zoneFk,
st.classColor,
TIME_FORMAT(t.shipped, '%H:%i') AS preparationHour,
TIME_FORMAT(z.hour, '%H:%i') AS theoreticalhour,
TIME_FORMAT(zed.etc, '%H:%i') AS practicalHour
TIME_FORMAT(t.shipped, '%H:%i') preparationHour,
TIME_FORMAT(z.hour, '%H:%i') theoreticalhour,
TIME_FORMAT(zed.etc, '%H:%i') practicalHour
FROM ticket t
LEFT JOIN invoiceOut io ON t.refFk = io.ref
LEFT JOIN zone z ON z.id = t.zoneFk
@ -216,7 +213,18 @@ module.exports = Self => {
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = wk.id
LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
LEFT JOIN (
SELECT zoneFk,
CAST(
IFNULL(zoneClosureHour, zoneHour) +
SUM(IF(hasToRecalcPrice, volume, 0)) * 60 /
GREATEST(IFNULL(m3, 0), IFNULL(minSpeed, 0))
AS time
) etc
FROM zoneEstimatedDelivery
GROUP BY zoneFk
) zed ON zed.zoneFk = t.zoneFk
`);
if (args.orderFk) {
stmt.merge({

View File

@ -139,13 +139,14 @@ module.exports = Self => {
filter = mergeFilters(filter, {where});
const stmts = [];
let stmt;
stmts.push(`SET @_optimizer_search_depth = @@optimizer_search_depth`);
stmts.push(`SET SESSION optimizer_search_depth = 0`);
stmt = new ParameterizedSQL(
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
stmt = new ParameterizedSQL(`
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
(INDEX (id))
ENGINE = MEMORY
SELECT
o.id,
SELECT o.id,
o.total,
o.date_send landed,
o.date_make created,
@ -163,7 +164,7 @@ module.exports = Self => {
zed.zoneFk,
zed.hourTheoretical,
zed.hourEffective,
am.name AS agencyName
am.name agencyName
FROM hedera.order o
LEFT JOIN address a ON a.id = o.address_id
LEFT JOIN agencyMode am ON am.id = o.agency_id
@ -173,12 +174,30 @@ module.exports = Self => {
LEFT JOIN company co ON co.id = o.company_id
LEFT JOIN orderTicket ot ON ot.orderFk = o.id
LEFT JOIN ticket t ON t.id = ot.ticketFk
LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
LEFT JOIN (
SELECT zoneFk,
CAST(
util.VN_CURDATE() +
INTERVAL HOUR(IFNULL(zoneClosureHour, zoneHour)) * 60 +
MINUTE(IFNULL(zoneClosureHour, zoneHour)) MINUTE
AS time
) hourTheoretical,
CAST(
IFNULL(zoneClosureHour, zoneHour) +
SUM(IF(hasToRecalcPrice, volume, 0)) * 60 /
GREATEST(IFNULL(m3, 0), IFNULL(minSpeed, 0))
AS time
) hourEffective
FROM zoneEstimatedDelivery
GROUP BY zoneFk
) zed ON zed.zoneFk = t.zoneFk
`);
stmt.merge(conn.makeWhere(filter.where));
stmt.merge(`GROUP BY id`);
stmt.merge(conn.makePagination(filter));
stmts.push(stmt);
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
stmt = new ParameterizedSQL(`SELECT * FROM tmp.filter`);
stmt.merge(conn.makeOrderBy(filter.order));

View File

@ -11,28 +11,24 @@
"id": true,
"type": "number"
},
"hourTheoretical": {
"zoneClosureHour": {
"type": "date"
},
"totalVolume": {
"zoneHour": {
"type": "date"
},
"volume": {
"type": "number"
},
"remainingVolume": {
"hasToRecalcPrice": {
"type": "boolean"
},
"m3": {
"type": "number"
},
"speed": {
"minSpeed": {
"type": "number"
},
"hourEffective": {
"type": "date"
},
"minutesLess": {
"type": "date"
},
"etc": {
"type": "date"
}
},
"relations": {
"zone": {