Merge branch '1707route.ticket' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-12-13 09:46:13 +00:00 committed by Gitea
commit ab66557cd0
12 changed files with 1730 additions and 1818 deletions

View File

@ -1,123 +0,0 @@
DROP procedure IF EXISTS `vn2008`.`clean`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn2008`.`clean`(IN `v_full` TINYINT(1))
proc: BEGIN
DECLARE v_date DATETIME;
DECLARE v_date18 DATETIME;
DECLARE v_date26 DATETIME;
DECLARE v_date8 DATE;
DECLARE v_date6 DATE;
DECLARE v_date3Month DATE;
DECLARE vDate2000 DATE;
DECLARE vRangeDeleteTicket INT;
DECLARE strtable varchar(15) DEFAULT NULL;
DECLARE done BIT DEFAULT 0;
SET v_date = TIMESTAMPADD(MONTH, -2, CURDATE());
SET v_date18 = TIMESTAMPADD(MONTH, -18,CURDATE());
SET v_date26 = TIMESTAMPADD(MONTH, -26,CURDATE());
SET v_date3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
SET v_date8 = TIMESTAMPADD(DAY, -8,CURDATE());
SET v_date6 = TIMESTAMPADD(DAY, -6,CURDATE());
SET vRangeDeleteTicket = 60;
DELETE FROM cdr WHERE calldate < v_date;
DELETE FROM Monitoring WHERE ODBC_TIME < v_date;
DELETE FROM Conteo WHERE Fecha < v_date;
DELETE FROM XDiario WHERE FECHA < v_date3Month OR FECHA IS NULL;
DELETE FROM mail WHERE DATE_ODBC < v_date;
-- DELETE FROM Cajas WHERE CajaFecha < v_date18;
DELETE rr FROM Recibos_recorded rr JOIN Recibos r ON rr.Id_Recibos = r.Id WHERE r.Fechacobro < v_date;
SELECT MAX(idTickets_dits)
INTO @id
FROM Tickets_dits
WHERE ODBC_DATE < v_date;
DELETE FROM Tickets_dits WHERE idTickets_dits <= @id;
DELETE FROM expeditions_deleted WHERE odbc_date < v_date26;
DELETE FROM Entradas_dits WHERE ODBC_DATE < v_date18;
DELETE FROM log_articles WHERE ODBC_DATE < v_date;
DELETE FROM Splits WHERE Fecha < v_date18;
DELETE ts FROM Tickets_stack ts JOIN Tickets t ON ts.Id_Ticket = t.Id_Ticket WHERE t.Fecha < v_date;
DELETE tobs FROM movement_label tobs JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento
JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < v_date;
DELETE FROM chat WHERE odbc_date < v_date;
DELETE FROM Extractos WHERE Fecha < v_date;
DELETE FROM Remesas WHERE `Fecha Remesa` < v_date18;
DELETE FROM Stockcontrol WHERE Datestart < v_date18;
-- DELETE FROM reference_rate WHERE date < v_date18;
DELETE FROM hedera.`order` WHERE date_send < v_date18;
-- DELETE FROM Ordenes WHERE odbc_date < v_date18; JGF 2018-12-21 Si estan en un turno no hay que borrarlas.
SELECT MAX(inter_id)
INTO @id
FROM vncontrol.inter
WHERE odbc_date < v_date18;
DELETE FROM vncontrol.inter WHERE inter_id <= @id;
DELETE FROM Entradas_dits WHERE ODBC_DATE < v_date;
DELETE FROM cyc_declaration WHERE Fecha < v_date18;
DELETE FROM travel_reserve WHERE odbc_date < v_date;
-- DELETE FROM syslog.systemevents WHERE odbc_date < v_date8;
DELETE FROM cache.departure_limit WHERE Fecha < TIMESTAMPADD(MONTH,-1,CURDATE());
DELETE co
FROM Compres_ok co JOIN Compres c ON c.Id_Compra = co.Id_Compra
JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
JOIN travel t ON t.id = e.travel_id
WHERE t.landing <= v_date;
DELETE FROM vn2008.scan WHERE odbc_date < v_date6 AND id <> 1;
SET vDate2000 = TIMESTAMPADD(YEAR, 2000 - YEAR(CURDATE()), CURDATE());
IF v_full
THEN
DELETE t FROM Tickets t
LEFT JOIN Tickets_turno tt ON tt.Id_Ticket = t.Id_Ticket
WHERE Fecha NOT IN ('2000-01-01','2000-01-02')
AND YEAR(Fecha) = 2000
AND ABS(DATEDIFF(Fecha,vDate2000)) > vRangeDeleteTicket
AND tt.Id_Ticket IS NULL;
DELETE e.* FROM Entradas e
LEFT JOIN recibida_entrada re ON e.Id_Entrada = re.Id_Entrada
WHERE travel_id IS NULL
AND re.Id_Entrada IS NULL;
END IF;
-- Tickets Nulos PAK 11/10/2016
UPDATE vn2008.Tickets
SET empresa_id = 965
WHERE Id_Cliente = 31
AND empresa_id != 965;
-- Equipos duplicados
DELETE w.*
FROM vn2008.workerTeam w
JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated
FROM vn.workerTeam
GROUP BY team,workerFk
HAVING duplicated
) d ON d.team = w.team AND d.workerFk = w.user AND d.id != w.id;
-- CAP 29/10/2018 Mantenimiento tabla Movimientos_componentes
DELETE mc
FROM vn2008.Movimientos_componentes mc
JOIN vn2008.Movimientos mv
ON mv.Id_Movimiento=mc.Id_Movimiento
JOIN vn2008.Tickets t
ON t.Id_Ticket= mv.Id_Ticket
WHERE t.Fecha<v_date18;
END$$
DELIMITER ;

View File

@ -1,55 +0,0 @@
DROP procedure IF EXISTS `vn`.`clean`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`clean`()
BEGIN
DECLARE vDateShort DATETIME;
DECLARE vOneYearAgo DATE;
DECLARE vFourYearsAgo DATE;
DECLARE v18Month DATE;
DECLARE v26Month DATE;
DECLARE v3Month DATE;
SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE());
SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE());
SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE());
SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE());
SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
DELETE FROM `message` WHERE sendDate < vDateShort;
DELETE FROM messageInbox WHERE sendDate < vDateShort;
DELETE FROM messageInbox WHERE sendDate < vDateShort;
DELETE FROM workerTimeControl WHERE timed < vFourYearsAgo;
DELETE FROM itemShelving WHERE created < CURDATE() AND visible = 0;
DELETE FROM ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE());
DELETE FROM entryLog WHERE creationDate < vDateShort;
DELETE FROM expedition WHERE created < v26Month;
DELETE FROM sms WHERE created < v18Month;
DELETE FROM saleTracking WHERE created < vDateShort;
DELETE tobs FROM ticketObservation tobs
JOIN ticket t ON tobs.shipped = t.id WHERE t.shipped < vDateShort;
DELETE FROM sharingCart where ended < vDateShort;
DELETE FROM sharingClient where ended < vDateShort;
DELETE tw.* FROM ticketWeekly tw
LEFT JOIN sale s ON s.ticketFk = tw.ticketFk WHERE s.itemFk IS NULL;
DELETE FROM claim WHERE ticketCreated < v18Month;
DELETE FROM message WHERE sendDate < vDateShort;
DELETE sc FROM saleChecked sc
JOIN sale s ON mc.Id_Movimiento = s.id WHERE s.created < vDateShort;
DELETE bm
FROM buyMark bm
JOIN buy b ON b.id = bm.id
JOIN entry e ON e.id = b.entryFk
JOIN travel t ON t.id = e.travelFk
WHERE t.landed <= vDateShort;
DELETE FROM stowaway WHERE created < v3Month;
CALL shelving_clean;
CALL ticketPackagingRecovery;
END$$
DELIMITER ;

View File

@ -267,7 +267,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
(121, 'address 21', 'the bat cave', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 0), (121, 'address 21', 'the bat cave', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 0),
(122, 'address 22', 'NY roofs', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 0), (122, 'address 22', 'NY roofs', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 0),
(123, 'address 23', 'The phone box', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0, 0), (123, 'address 23', 'The phone box', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0, 0),
(124, 'address 24', 'Stark tower', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0, 0), (124, 'address 24', 'Stark tower Silla', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0, 0),
(125, 'address 25', 'The plastic cell', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0, 0), (125, 'address 25', 'The plastic cell', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0, 0),
(126, 'address 26', 'Many places', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0, 0), (126, 'address 26', 'Many places', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0, 0),
(127, 'address 27', 'Your pocket', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0, 0), (127, 'address 27', 'Your pocket', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0, 0),
@ -560,14 +560,18 @@ INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`)
VALUES VALUES
(12, 13, CURDATE()); (12, 13, CURDATE());
INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`) INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
VALUES VALUES
(1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1), (1, 'Silla','46460 Av Espioca 100-Silla');
(2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1),
(3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1), INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk`, `warehouseFk`, `description`, `m3`, `isActive`, `deliveryPointFk`)
(4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1), VALUES
(5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1), (1, '3333-BAT', 'WAYNE INDUSTRIES', 'BATMOBILE', 442, 1, 'The ultimate war machine', 50, 1, 1),
(6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0); (2, '1111-IMK', 'STARK INDUSTRIES', 'MARK-III', 442, 1, 'Iron-Man Heavy Armor MARK-III', 18, 1, 1),
(3, '2222-IMK', 'STARK INDUSTRIES', 'MARK-VI', 442, 1, 'Iron-Man Heavy Armor MARK-VI', 16, 1, 1),
(4, '3333-IMK', 'STARK INDUSTRIES', 'MARK-VII', 442, 1, 'Iron-Man Heavy Armor MARK-VII', 14, 1, 1),
(5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1, 1),
(6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0, 1);
INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`) INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`)
VALUES VALUES

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
module.exports = Self => {
Self.remoteMethod('getDeliveryPoint', {
description: 'get the deliveryPoint address ',
accessType: 'WRITE',
accepts: {
arg: 'vehicleId',
type: 'number',
required: true,
description: 'vehicle id asigned in the route',
http: {source: 'path'}
},
returns: {
type: 'String',
root: true
},
http: {
path: `/:vehicleId/getDeliveryPoint`
}
});
Self.getDeliveryPoint = async vehicleId => {
let vehicle = await Self.app.models.Vehicle.findById(vehicleId);
let deliveryPoint = await Self.app.models.DeliveryPoint.findById(vehicle.deliveryPointFk);
return deliveryPoint.ubication;
};
};

View File

@ -0,0 +1,13 @@
const app = require('vn-loopback/server/server');
describe('route getDeliveryPoint()', () => {
const routeId = 1;
const deliveryPointAddress = '46460 Av Espioca 100-Silla';
it('should get the delivery point addres of a route with assigned vehicle', async() => {
let route = await app.models.Route.findById(routeId);
let address = await app.models.Route.getDeliveryPoint(route.vehicleFk);
expect(address).toEqual(deliveryPointAddress);
});
});

View File

@ -7,5 +7,10 @@
}, },
"RouteLog": { "RouteLog": {
"dataSource": "vn" "dataSource": "vn"
},
"DeliveryPoint": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,22 @@
{
"name": "DeliveryPoint",
"base": "VnModel",
"options": {
"mysql": {
"table": "deliveryPoint"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "String"
},
"ubication": {
"type": "String"
}
}
}

View File

@ -4,4 +4,5 @@ module.exports = Self => {
require('../methods/route/getTickets')(Self); require('../methods/route/getTickets')(Self);
require('../methods/route/guessPriority')(Self); require('../methods/route/guessPriority')(Self);
require('../methods/route/updateVolume')(Self); require('../methods/route/updateVolume')(Self);
require('../methods/route/getDeliveryPoint')(Self);
}; };

View File

@ -41,6 +41,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Warehouse", "model": "Warehouse",
"foreignKey": "warehouseFk" "foreignKey": "warehouseFk"
},
"deliveryPoint": {
"type": "belongsTo",
"model": "DeliveryPoint",
"foreignKey": "deliveryPointFk"
} }
}, },
"scope": { "scope": {

View File

@ -85,20 +85,26 @@ class Controller {
} }
goToBuscaman() { goToBuscaman() {
// firstAddress is a temporal variable, will be replaced with #1298 let query = `Routes/${this.route.vehicleFk}/getDeliveryPoint`;
let firstAddress = `46460 Av Espioca 100-46460 Silla`; let deliveryPointAddress;
let addresses = firstAddress; let addresses;
let lines = this.getSelectedItems(this.tickets); this.$http.get(query).then(response => {
deliveryPointAddress = response.data;
}).then(() => {
addresses = deliveryPointAddress;
let lines = this.getSelectedItems(this.tickets);
let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; let url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=';
lines.forEach(line => { lines.forEach(line => {
addresses = addresses + '+to:' + line.address.postalCode + ' ' + line.address.street + '-' + line.address.postalCode + ' ' + line.address.city; addresses = addresses + '+to:' + line.address.postalCode + ' ' + line.address.city + ' ' + line.address.street;
});
window.open(url + addresses, '_blank');
}); });
window.open(url + addresses, '_blank');
} }
showDeleteConfirm(id) { showDeleteConfirm(id) {
this.selectedTicket = id; this.selectedTicket = id;
this.$.confirm.show(); this.$.confirm.show();

View File

@ -120,7 +120,11 @@ describe('Route', () => {
describe('goToBuscaman()', () => { describe('goToBuscaman()', () => {
it('should open buscaman with the given arguments', () => { it('should open buscaman with the given arguments', () => {
spyOn(window, 'open'); spyOn(window, 'open');
const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460 Av Espioca 100-46460 Silla+to:n19 my street-n19 London'; const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460 Av Espioca 100+to:n19 London my street';
controller.route = {vehicleFk: 1};
const url = `Routes/${controller.route.vehicleFk}/getDeliveryPoint`;
$httpBackend.expectGET(url).respond('46460 Av Espioca 100');
controller.tickets = [ controller.tickets = [
{ {
id: 1, id: 1,
@ -134,6 +138,7 @@ describe('Route', () => {
]; ];
controller.goToBuscaman(); controller.goToBuscaman();
$httpBackend.flush();
expect(window.open).toHaveBeenCalledWith(expectedUrl, '_blank'); expect(window.open).toHaveBeenCalledWith(expectedUrl, '_blank');
}); });