feat(ticket_boxing): return video stream
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-08-02 15:15:05 +02:00
parent 7d4dd7bb52
commit 8a08b6f399
6 changed files with 258 additions and 166 deletions

View File

@ -1,16 +1,25 @@
CREATE TABLE `vn`.`packingSiteConfig` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`shinobiUrl` varchar(255) NOT NULL,
`shinobiToken` varchar(255) NOT NULL,
`shinobiGroupKey` varchar(255) NOT NULL,
`avgBoxingTime` INT(3) NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `vn`.`packingSiteConfig` SET
shinobiUrl = 'http://shinobi.verdnatura.es',
shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP',
shinobiGroupKey = 'xVqft9LFXg',
avgBoxingTime = 30;
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee');
SELECT e.id expeditionFk, e.ticketFk, ps.code, ps.monitorId
FROM expedition e
JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk
JOIN packingSite ps ON ps.hostFk = h.id
WHERE e.ticketFk = 1;

View File

@ -0,0 +1,56 @@
ALTER TABLE `vn`.`packingSite` ADD monitorId varchar(255) NULL;
UPDATE `vn`.`packingSite`
SET monitorId = 'VbiUcajdaT'
WHERE code = 'h1';
UPDATE `vn`.`packingSite`
SET monitorId = 'qKMPn9aaVe'
WHERE code = 'h2';
UPDATE `vn`.`packingSite`
SET monitorId = '3CtdIAGPAv'
WHERE code = 'h3';
UPDATE `vn`.`packingSite`
SET monitorId = 'Xme2hiqz1f'
WHERE code = 'h4';
UPDATE `vn`.`packingSite`
SET monitorId = 'aulxefgfJU'
WHERE code = 'h5';
UPDATE `vn`.`packingSite`
SET monitorId = '6Ou0D1bhBw'
WHERE code = 'h6';
UPDATE `vn`.`packingSite`
SET monitorId = 'eVUvnE6pNw'
WHERE code = 'h7';
UPDATE `vn`.`packingSite`
SET monitorId = '0wsmSvqmrs'
WHERE code = 'h8';
UPDATE `vn`.`packingSite`
SET monitorId = 'r2l2RyyF4I'
WHERE code = 'h9';
UPDATE `vn`.`packingSite`
SET monitorId = 'EdjHLIiDVD'
WHERE code = 'h10';
UPDATE `vn`.`packingSite`
SET monitorId = 'czC45kmwqI'
WHERE code = 'h11';
UPDATE `vn`.`packingSite`
SET monitorId = 'PNsmxPaCwQ'
WHERE code = 'h12';
UPDATE `vn`.`packingSite`
SET monitorId = 'agVssO0FDC'
WHERE code = 'h13';
UPDATE `vn`.`packingSite`
SET monitorId = 'f2SPNENHPo'
WHERE code = 'h14';
UPDATE `vn`.`packingSite`
SET monitorId = '6UR7gUZxks'
WHERE code = 'h15';
UPDATE `vn`.`packingSite`
SET monitorId = 'bOB0f8WZ2V'
WHERE code = 'h16';
UPDATE `vn`.`packingSite`
SET monitorId = 'MIR1nXaL0n'
WHERE code = 'h17';
UPDATE `vn`.`packingSite`
SET monitorId = '0Oj9SgGTXR'
WHERE code = 'h18';

View File

@ -883,18 +883,18 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`)
(3, 'Perdida', 'LOST');
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`)
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`)
VALUES
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1),
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1),
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2),
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2),
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3),
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3),
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL),
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1),
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2),
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3);
(1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1, 'pc1'),
(2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1, NULL),
(3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2, NULL),
(4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2, NULL),
(5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3, NULL),
(6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3, NULL),
(7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL,NULL),
(8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1, NULL),
(9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2, NULL),
(10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL);
INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`)
@ -2611,3 +2611,12 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk
INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`)
VALUES
(1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13);
INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`)
VALUES
(1, 'pc1', 'pc host', 1, 1);
INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`)
VALUES
(1, 'h1', 1, 'VbiUcajdaT');

View File

@ -18,10 +18,23 @@ module.exports = Self => {
description: 'Time to add'
}
],
returns: {
type: ['object'],
root: true,
},
returns: [
{
arg: 'body',
type: 'file',
root: true
},
{
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
},
{
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: `/getVideo`,
verb: 'GET',
@ -37,31 +50,33 @@ module.exports = Self => {
const expedition = await models.Expedition.findById(id, null, myOptions);
const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions);
const token = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP';
const groupKey = 'xVqft9LFXg';
const monitorId = 'VbiUcajdaT';// 'xVqft9LFXg';
const monitorId = 'VbiUcajdaT';
console.log(packingSiteConfig);
const start = '2022-07-27T09:00:00';// new Date('2022-07-27'); // new Date(expedition.created);
const end = '2022-07-27T09:15:00';// start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime));
const addTime = (time ? time : packingSiteConfig.avgBoxingTime) * 1000;
const start = new Date(expedition.created);// '2022-07-27T09:00:00';// new Date('2022-07-27'); //
const end = new Date(start.getTime() + addTime);
console.log(addTime);
console.log(start.toISOString().split('.')[0]);
console.log(end.toISOString().split('.')[0]);
const videoUrl = `/${token}/videos/${groupKey}/${monitorId}?start=${start}&end=${end}`;
const url = `${packingSiteConfig.shinobiUrl}${videoUrl}`;
const data = await axios.post(url);
const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`;
const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`;
const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}&endIsStartTo`;
console.log(data.data.videos);
console.log('-----------------------');
console.log('-----------------------');
console.log('-----------------------');
console.log('-----------------------');
axios({
console.log(url);
const videoList = await axios.post(url);
console.log(videoList.data);
const lastVideo = videoList.data.videos[videoList.data.videos.length - 1].href;
console.log(lastVideo);
const stream = await axios({
method: 'get',
url: `${packingSiteConfig.shinobiUrl}${data.data.videos[0].href}`,
url: `${packingSiteConfig.shinobiUrl}${lastVideo}`,
responseType: 'stream'
})
.then(response => {
console.log(response);
return response;
});
}).then(response => {
return response.data;
});
return [stream, 'video/mp4', `filename="${id}.mp4"`];
};
};

View File

@ -18,6 +18,9 @@
"shinobiGroupKey":{
"type":"string"
},
"shinobiToken":{
"type":"string"
},
"avgBoxingTime":{
"type":"number"
}

View File

@ -1,5 +1,5 @@
<vn-card>
<video id="videobcg" muted="muted" controls class="video">
<source src="http://localhost:5000/api/Boxings/getVideo?id=1" type="video/mp4" autoplay="autoplay" >
<video id="videobcg" muted controls class="video" autoplay>
<source src="http://localhost:5000/api/Boxings/getVideo?id=1" type="video/mp4">
</video>
</vn-card>