feat: refs #7882 Osrm service
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2024-12-09 14:45:31 +01:00
parent 85baf151d9
commit cba5d88c5e
3 changed files with 42 additions and 4 deletions

View File

@ -27,19 +27,31 @@ module.exports = Self => {
if (!osrmConfig) throw new UserError(`OSRM service is not configured`);
let coords = [];
for (const addressId of addressIds) {
const address = await models.Address.findById(addressId);
const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona
if (address.latitude && address.longitude) {
coords.push({
addressId,
addressId: address.id,
latitude: address.latitude.toFixed(6),
longitude: address.longitude.toFixed(6)
});
}
for (const addressId of addressIds) {
const address = await models.Address.findById(addressId);
if (address.latitude && address.longitude) {
coords.push({
addressId,
latitude: address.latitude.toFixed(6),
longitude: address.longitude.toFixed(6)
});
}
}
const concatCoords = coords
.map(coord => `${coord.longitude},${coord.latitude}`)
.join(';');
const response = await axios.post(`
${osrmConfig.url}/trip/v1/driving/${concatCoords}
${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true
`);
const tolerance = osrmConfig.tolerance;
for (waypoint of response.data.waypoints) {

View File

@ -0,0 +1,25 @@
module.exports = Self => {
Self.remoteMethod('optimizeStops', {
description: 'Updates the ticket priority of tickets without priority',
accepts: [
{
arg: 'routeFk',
type: 'number',
required: true
}
],
returns: {
type: 'object',
root: true
},
http: {
path: '/optimizeStops',
verb: 'post'
}
});
Self.optimizeStops = async(routeFk, options) => {
return;
};
};

View File

@ -16,4 +16,5 @@ module.exports = Self => {
require('../methods/route/downloadZip')(Self);
require('../methods/route/getExpeditionSummary')(Self);
require('../methods/route/getByWorker')(Self);
require('../methods/route/optimizeStops')(Self);
};