add scheduler btn
This commit is contained in:
+29
-20
@@ -3,6 +3,7 @@ const ExcelUtil = require("./excel/ExcelUtil");
|
||||
const CommandorPage = require("./workers/CommandorPage");
|
||||
const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
||||
const alert = require('alert');
|
||||
const schedule = require("node-schedule");
|
||||
|
||||
const mongoManager = new MongoManager();
|
||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||
@@ -132,6 +133,14 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) {
|
||||
console.log("scheduleBookWithNumbers() called")
|
||||
schedule.scheduleJob('45 9 * * *', function () {
|
||||
console.log("start startBookWithNumbers")
|
||||
startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse = false, alertBeep = false)
|
||||
})
|
||||
}
|
||||
|
||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) {
|
||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||
let contactList;
|
||||
@@ -145,27 +154,27 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
return
|
||||
}
|
||||
mongoManager.connect().then(r => {
|
||||
filterAlreadyBookedContacts(contactList).then((listToBook)=>{
|
||||
filterAlreadyBookedContacts(contactList).then((listToBook) => {
|
||||
filterAlreadyAccepteddContacts(listToBook).then(notAcceptedContacts => {
|
||||
filterBlacklistedContacts(notAcceptedContacts).then(listWithoutBlackContact => {
|
||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||
android.devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
}
|
||||
let segmentNumber = listWithoutBlackContact.length / devices.length;
|
||||
console.log("connected device number:" + devices.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
||||
}
|
||||
})
|
||||
filterBlacklistedContacts(notAcceptedContacts).then(listWithoutBlackContact => {
|
||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||
android.devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
}
|
||||
let segmentNumber = listWithoutBlackContact.length / devices.length;
|
||||
console.log("connected device number:" + devices.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
});
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = startBookWithNumbers
|
||||
module.exports = {startBookWithNumbers, scheduleBookWithNumbers}
|
||||
Reference in New Issue
Block a user