-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_seq.js
More file actions
21 lines (21 loc) · 1009 Bytes
/
Copy pathtest_seq.js
File metadata and controls
21 lines (21 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const http = require('http');
function post(path, data) {
return new Promise((resolve, reject) => {
const body = JSON.stringify(data);
const req = http.request({hostname:'localhost',port:3006,path,method:'POST',headers:{'Content-Type':'application/json','Content-Length':body.length}}, res => {
let b=''; res.on('data',d=>b+=d); res.on('end',()=>resolve(JSON.parse(b)));
}); req.write(body); req.end();
});
}
(async () => {
const r = await post('/api/schedule', { strategies: ['forward'] });
const plan = r.data.plans.forward;
const byMps = {};
plan.schedules.forEach(s => { if(!byMps[s.mpsId]) byMps[s.mpsId]=[]; byMps[s.mpsId].push(s); });
for (const [id, scheds] of Object.entries(byMps)) {
scheds.sort((a,b) => a.date.localeCompare(b.date) || a.processSeq - b.processSeq);
console.log(scheds[0].productName + ':');
scheds.forEach(s => console.log(' ' + s.date + ' seq=' + s.processSeq + ' ' + s.processName + ' ' + s.dailyQty));
console.log('');
}
})();