This commit is contained in:
parent
edff15662c
commit
1561e15d5e
|
@ -1,48 +1,59 @@
|
||||||
{
|
{
|
||||||
"name": "Warehouse",
|
"name": "Warehouse",
|
||||||
"description": "Warehouses from where orders are sent",
|
"description": "Warehouses from where orders are sent",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "warehouse"
|
"table": "warehouse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"id": true,
|
"id": true,
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"forceId": false
|
"forceId": false
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"code": {
|
"code": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"isInventory": {
|
"isInventory": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"isManaged":{
|
"isManaged": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"countryFk": {
|
"countryFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"country": {
|
"country": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Country",
|
"model": "Country",
|
||||||
"foreignKey": "countryFk"
|
"foreignKey": "countryFk"
|
||||||
}
|
},
|
||||||
},
|
"address": {
|
||||||
"acls": [
|
"type": "belongsTo",
|
||||||
{
|
"model": "Address",
|
||||||
"accessType": "READ",
|
"foreignKey": "addressFk"
|
||||||
"principalType": "ROLE",
|
}
|
||||||
"principalId": "$everyone",
|
},
|
||||||
"permission": "ALLOW"
|
"acls": [
|
||||||
}
|
{
|
||||||
],
|
"accessType": "READ",
|
||||||
"scope" : {"where": {"isForTicket": {"neq": 0}}}
|
"principalType": "ROLE",
|
||||||
}
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scope": {
|
||||||
|
"where": {
|
||||||
|
"isForTicket": {
|
||||||
|
"neq": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
|
@ -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',
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
|
@ -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() => {
|
||||||
|
const truckFk = 1;
|
||||||
|
const state = 'ON DELIVERY';
|
||||||
|
const result = await models.RoadmapStop.getPalletMatchState(truckFk, state);
|
||||||
|
|
||||||
|
expect(result[0].hasMatchStateCode).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,63 +1,75 @@
|
||||||
{
|
{
|
||||||
"name": "Roadmap",
|
"name": "Roadmap",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "roadmap"
|
"table": "roadmap"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true,
|
"id": true,
|
||||||
"description": "Identifier"
|
"description": "Identifier"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"tractorPlate": {
|
"tractorPlate": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"trailerPlate": {
|
"trailerPlate": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"phone": {
|
"phone": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"supplierFk": {
|
"supplierFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"etd": {
|
"etd": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
},
|
},
|
||||||
"observations": {
|
"observations": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"price": {
|
"price": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"driverName": {
|
"driverName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
},
|
||||||
},
|
"kmStart": {
|
||||||
"relations": {
|
"type": "number"
|
||||||
"worker": {
|
},
|
||||||
"type": "belongsTo",
|
"kmEnd": {
|
||||||
"model": "Worker",
|
"type": "number"
|
||||||
"foreignKey": "id"
|
},
|
||||||
},
|
"started": {
|
||||||
"supplier": {
|
"type": "date"
|
||||||
"type": "belongsTo",
|
},
|
||||||
"model": "Supplier",
|
"finished": {
|
||||||
"foreignKey": "supplierFk"
|
"type": "date"
|
||||||
},
|
}
|
||||||
"roadmapStop": {
|
},
|
||||||
"type": "hasMany",
|
"relations": {
|
||||||
"model": "RoadmapStop",
|
"worker": {
|
||||||
"foreignKey": "roadmapFk"
|
"type": "belongsTo",
|
||||||
}
|
"model": "Worker",
|
||||||
}
|
"foreignKey": "id"
|
||||||
}
|
},
|
||||||
|
"supplier": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Supplier",
|
||||||
|
"foreignKey": "supplierFk"
|
||||||
|
},
|
||||||
|
"roadmapStop": {
|
||||||
|
"type": "hasMany",
|
||||||
|
"model": "RoadmapStop",
|
||||||
|
"foreignKey": "roadmapFk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
require('../methods/roadmapStop/getPalletMatchState')(Self);
|
||||||
|
};
|
|
@ -1,43 +1,43 @@
|
||||||
{
|
{
|
||||||
"name": "RoadmapStop",
|
"name": "RoadmapStop",
|
||||||
"base": "VnModel",
|
"base": "VnModel",
|
||||||
"options": {
|
"options": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"table": "roadmapStop"
|
"table": "roadmapStop"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true,
|
"id": true,
|
||||||
"description": "Identifier"
|
"description": "Identifier"
|
||||||
},
|
},
|
||||||
"roadmapFk": {
|
"roadmapFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"addressFk": {
|
"addressFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"eta": {
|
"eta": {
|
||||||
"type": "date"
|
"type": "date"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
"roadmap": {
|
"roadmap": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Roadmap",
|
"model": "Roadmap",
|
||||||
"foreignKey": "roadmapFk"
|
"foreignKey": "roadmapFk"
|
||||||
},
|
},
|
||||||
"address": {
|
"address": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "Address",
|
"model": "RoadmapAddress",
|
||||||
"foreignKey": "addressFk"
|
"foreignKey": "addressFk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue