feat: refs #7882 Added osrmservice #3281
|
@ -32,12 +32,12 @@ module.exports = Self => {
|
|||
|
||||
let coords = [];
|
||||
if (firstAddressId) {
|
||||
const firstAddress = await models.Address.findById(firstAddressId);
|
||||
if (firstAddress.latitude && firstAddress.longitude) {
|
||||
const address = await models.Address.findById(firstAddressId);
|
||||
if (address.latitude && address.longitude) {
|
||||
coords.push({
|
||||
addressId: firstAddress.id,
|
||||
latitude: firstAddress.latitude.toFixed(6),
|
||||
longitude: firstAddress.longitude.toFixed(6)
|
||||
addressId: address.id,
|
||||
latitude: address.latitude.toFixed(6),
|
||||
longitude: address.longitude.toFixed(6)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ module.exports = Self => {
|
|||
${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true
|
||||
`);
|
||||
const tolerance = osrmConfig.tolerance;
|
||||
for (waypoint of response.data.waypoints) {
|
||||
for (const waypoint of response.data.waypoints) {
|
||||
const longitude = waypoint.location[0];
|
||||
const latitude = waypoint.location[1];
|
||||
|
||||
|
|
|
@ -75,11 +75,11 @@ module.exports = function(Self) {
|
|||
},
|
||||
{
|
||||
arg: 'longitude',
|
||||
type: 'number',
|
||||
type: 'any',
|
||||
},
|
||||
{
|
||||
arg: 'latitude',
|
||||
type: 'number',
|
||||
type: 'any',
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
|
|
@ -28,17 +28,17 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const ticketsIds = await models.Ticket.find({
|
||||
const tickets = await models.Ticket.find({
|
||||
where: {routeFk: id}
|
||||
}, myOptions);
|
||||
|
||||
let ticketAddress = [];
|
||||
for (const ticketId of ticketsIds) {
|
||||
for (const ticket of tickets) {
|
||||
ticketAddress.push({
|
||||
ticketId: ticketId.id,
|
||||
addressId: ticketId.addressFk,
|
||||
zoneId: ticketId.zoneFk,
|
||||
priority: ticketId.priority
|
||||
ticketId: ticket.id,
|
||||
addressId: ticket.addressFk,
|
||||
zoneId: ticket.zoneFk,
|
||||
priority: ticket.priority
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue