Initial team BPM workspace with managed connections, scanning and mail templates
This commit is contained in:
commit
34770ed338
101 files changed
+6499
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// Plan calculation only. A mail connector must exist before execution is enabled.
|
||||
function dayPolicy(date,schedule,overrides=[]) {
|
||||
const key=typeof date==='string'?date:new Intl.DateTimeFormat('en-CA',{timeZone:'Asia/Shanghai'}).format(date);
|
||||
const override=overrides.find(item=>item.date===key);
|
||||
if(override)return {scan:override.kind==='pause'?false:override.scan,send:override.kind==='pause'?false:override.send,kind:override.kind,note:override.note || ''};
|
||||
const working=schedule.weekends || ![0,6].includes(new Date(key+'T00:00:00Z').getUTCDay());
|
||||
return {scan:working,send:working,kind:working?'workday':'restday',note:''};
|
||||
}
|
||||
function nextSlots(schedule, from=new Date(), count=2, overrides=[]) {
|
||||
const shifted=new Date(from.getTime()+8*3600000);
|
||||
const midnight=Date.UTC(shifted.getUTCFullYear(),shifted.getUTCMonth(),shifted.getUTCDate());
|
||||
const slots=[];
|
||||
for(let day=0;day<370 && slots.length<count;day++) {
|
||||
const date=new Date(midnight+day*86400000);
|
||||
if(!dayPolicy(date.toISOString().slice(0,10),schedule,overrides).send)continue;
|
||||
for(const time of [...schedule.times].sort()) {
|
||||
const [hour,minute]=time.split(':').map(Number);
|
||||
const utc=date.getTime()+hour*3600000+minute*60000-8*3600000;
|
||||
if(utc>from.getTime())slots.push(new Date(utc).toISOString());
|
||||
if(slots.length>=count)break;
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
module.exports={nextSlots,dayPolicy};
|
||||
Reference in new issue
Block a user