Actualizar modules/travel/back/methods/travel/extraCommunityFilter.js
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Andrés 2024-12-03 17:49:48 +00:00
parent ff2f4f94f4
commit d7af439787
1 changed files with 23 additions and 27 deletions

View File

@ -1,4 +1,3 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const buildFilter = require('vn-loopback/util/filter').buildFilter; const buildFilter = require('vn-loopback/util/filter').buildFilter;
const mergeFilters = require('vn-loopback/util/filter').mergeFilters; const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
@ -115,42 +114,39 @@ module.exports = Self => {
`CREATE TEMPORARY TABLE tmp.travel `CREATE TEMPORARY TABLE tmp.travel
(INDEX (id)) (INDEX (id))
ENGINE = MEMORY ENGINE = MEMORY
SELECT SELECT t.id,
t.id,
t.ref, t.ref,
t.shipped, t.shipped,
t.landed, t.landed,
t.kg, t.kg,
am.id AS agencyModeFk, am.id agencyModeFk,
am.name AS agencyModeName, am.name agencyModeName,
wo.id AS warehouseOutFk, wo.id warehouseOutFk,
wo.name AS warehouseOutName, wo.name warehouseOutName,
w.name AS warehouseInFk, w.name warehouseInFk,
w.name AS warehouseInName, w.name warehouseInName,
SUM(b.stickers) AS stickers, SUM(b.stickers) stickers,
s.id AS cargoSupplierFk, s.id cargoSupplierFk,
s.nickname AS cargoSupplierNickname, s.nickname cargoSupplierNickname,
s.name AS supplierName, s.name supplierName,
CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg,
CAST( CAST(
SUM( SUM(
vc.aerealVolumetricDensity * vc.aerealVolumetricDensity *
b.stickers * b.stickers *
IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000
) as DECIMAL(10,0) ) AS DECIMAL(10,0)
) as volumeKg, ) volumeKg,
GREATEST(
CAST(SUM(b.weight * b.stickers) AS INT),
CAST( CAST(
GREATEST(
SUM(b.weight * b.stickers) ,
SUM(vc.aerealVolumetricDensity * SUM(vc.aerealVolumetricDensity *
b.stickers * b.stickers *
IF(pkg.volume, IF(pkg.volume,
pkg.volume, pkg.volume,
pkg.width * pkg.depth * pkg.height pkg.width * pkg.depth * pkg.height) / 1000000)
) / 1000000 ) / t.kg * 100 AS INT
) AS INT ) percentageKg
)
/ t.kg * 100, 0) percentageKg
FROM travel t FROM travel t
LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN supplier s ON s.id = t.cargoSupplierFk
LEFT JOIN entry e ON e.travelFk = t.id LEFT JOIN entry e ON e.travelFk = t.id