Closure by date
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
6cb620a41d
commit
060fc2ac21
|
@ -6,6 +6,10 @@ const config = require('../core/config');
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
app.get('/api/closure/all', async function(req, res, next) {
|
app.get('/api/closure/all', async function(req, res, next) {
|
||||||
try {
|
try {
|
||||||
|
const reqArgs = req.args;
|
||||||
|
if (!reqArgs.to)
|
||||||
|
throw new Error('The argument to is required');
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
message: 'Task executed successfully'
|
message: 'Task executed successfully'
|
||||||
});
|
});
|
||||||
|
@ -19,9 +23,11 @@ module.exports = app => {
|
||||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
JOIN alertLevel al ON al.alertLevel = ts.alertLevel
|
||||||
WHERE al.code = 'PACKED'
|
WHERE al.code = 'PACKED'
|
||||||
AND DATE(t.shipped) BETWEEN DATE_ADD(CURDATE(), INTERVAL -2 DAY) AND CURDATE()
|
AND DATE(t.shipped) BETWEEN DATE_ADD(:to, INTERVAL -2 DAY) AND :to
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
GROUP BY e.ticketFk`);
|
GROUP BY e.ticketFk`, {
|
||||||
|
to: reqArgs.to
|
||||||
|
});
|
||||||
const ticketIds = tickets.map(ticket => ticket.id);
|
const ticketIds = tickets.map(ticket => ticket.id);
|
||||||
|
|
||||||
await closeAll(ticketIds, req.args);
|
await closeAll(ticketIds, req.args);
|
||||||
|
@ -33,10 +39,12 @@ module.exports = app => {
|
||||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||||
JOIN zone z ON z.id = t.zoneFk
|
JOIN zone z ON z.id = t.zoneFk
|
||||||
SET t.routeFk = NULL
|
SET t.routeFk = NULL
|
||||||
WHERE shipped BETWEEN CURDATE() AND util.dayEnd(CURDATE())
|
WHERE shipped BETWEEN DATE_ADD(:to, INTERVAL -2 DAY) AND util.dayEnd(:to)
|
||||||
AND al.code NOT IN('DELIVERED','PACKED')
|
AND al.code NOT IN('DELIVERED','PACKED')
|
||||||
AND t.routeFk
|
AND t.routeFk
|
||||||
AND z.name LIKE '%MADRID%'`);
|
AND z.name LIKE '%MADRID%'`, {
|
||||||
|
to: reqArgs.to
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue