7195_roadmap2 #2554

Merged
sergiodt merged 12 commits from 7195_roadmap2 into dev 2024-07-03 06:56:50 +00:00
7 changed files with 133 additions and 23 deletions

View File

@ -22,7 +22,7 @@
"isInventory": {
"type": "number"
},
"isManaged":{
"isManaged": {
"type": "boolean"
},
"countryFk": {
@ -36,6 +36,13 @@
"foreignKey": "countryFk"
}
},
"relations": {
"address": {
"type": "belongsTo",
"model": "Address",
"foreignKey": "addressFk"
}
},
"acls": [
{
"accessType": "READ",
@ -44,5 +51,11 @@
"permission": "ALLOW"
}
],
"scope" : {"where": {"isForTicket": {"neq": 0}}}
"scope": {
"where": {
"isForTicket": {
"neq": 0
}
}
}
}

View File

@ -0,0 +1,8 @@
-- Place your SQL code here
USE vn;
ALTER TABLE vn.roadmap ADD kmStart mediumint(9) DEFAULT NULL NULL;
ALTER TABLE vn.roadmap ADD kmEnd mediumint(9) DEFAULT NULL NULL;
ALTER TABLE vn.roadmap ADD started DATETIME NULL;
ALTER TABLE vn.roadmap ADD finished DATETIME NULL;

View File

@ -0,0 +1,62 @@
module.exports = Self => {
Self.remoteMethod('getPalletMatchState', {
description: 'Get list of pallet from truckFk with true or false if state is matched',
sergiodt marked this conversation as resolved Outdated

posa algo mes concret del que fa el proc

posa algo mes concret del que fa el proc

Afegit

Afegit
accessType: 'WRITE',
accepts: [{
arg: 'truckFk',
type: 'number',
required: true,
description: 'The truckFk id'
},
{
arg: 'state',
type: 'string',
required: true,
description: 'State code'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getPalletMatchState`,
verb: 'GET'
}
});
Self.getPalletMatchState = async(truckFk, state, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const result = await Self.rawSql(`
WITH tPallet AS(
SELECT ep.id pallet, e.id expedition, e.stateTypeFk
sergiodt marked this conversation as resolved Outdated

es molt confús que tornes com a roadMapStop un id d'un camio..de fet, pots mirar inclús de no tornar-ho perque sols et tornarà coses d'ixe truck

es molt confús que tornes com a roadMapStop un id d'un camio..de fet, pots mirar inclús de no tornar-ho perque sols et tornarà coses d'ixe truck

Llevat

Llevat
FROM vn.expeditionPallet ep
JOIN vn.expeditionScan es ON es.palletFk = ep.id
JOIN expedition e ON e.id = es.expeditionFk
WHERE ep.truckFk = ?
),totalPalletExpedition AS(
SELECT t.*, COUNT(expedition) totalPalletExpedition
FROM tPallet t
GROUP BY expedition
),totalPalletExpeditionCode AS(
SELECT t.*, COUNT(expedition) totalPalletExpeditionCode
FROM tPallet t
JOIN vn.expeditionStateType est ON est.id = t.stateTypeFk
WHERE code = ?
GROUP BY expedition
)
SELECT t.pallet,
tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode hasMatchStateCode
FROM tPallet t
sergiodt marked this conversation as resolved
Review

aci sobra el if, sols (tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode) ja torna true o false

aci sobra el if, sols (tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode) ja torna true o false
Review

Llevat

Llevat
LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition
LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition
GROUP BY t.pallet;`,
[truckFk, state],
myOptions);
return result;
};
};

View File

@ -0,0 +1,12 @@
const {models} = require('vn-loopback/server/server');
describe('roadMapStop getPalletMatchState()', () => {
it('should return list of pallet with true or false if state is matched', async() => {
sergiodt marked this conversation as resolved Outdated

fit no

fit no

Llevat

Llevat
const truckFk = 1;
const state = 'ON DELIVERY';
const result = await models.RoadmapStop.getPalletMatchState(truckFk, state);
expect(result[0].hasMatchStateCode).toBe(1);
});
});

View File

@ -41,6 +41,18 @@
},
"driverName": {
"type": "string"
},
"kmStart": {
"type": "number"
},
"kmEnd": {
"type": "number"
},
"started": {
"type": "date"
},
"finished": {
"type": "date"
}
},
"relations": {
@ -57,7 +69,7 @@
"roadmapStop": {
"type": "hasMany",
"model": "RoadmapStop",
"foreignKey": "roadmapFk"
"foreignKey": "roadMapFk"
}
}
}

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/roadmapStop/getPalletMatchState')(Self);
};

View File

@ -36,7 +36,7 @@
},
"address": {
"type": "belongsTo",
"model": "Address",
"model": "RoadmapAddress",
"foreignKey": "addressFk"
}
}