Merge branch 'feature/producer_consomer' of bitbucket.org:panleicim/appointment_tool_js into feature/producer_consomer
This commit is contained in:
@@ -102,3 +102,23 @@ adb -s G7AZCY07H415CT3 shell am start -n com.android.chrome/com.google.android.a
|
|||||||
adb -s 07fbd156 shell pm clear com.android.chrome
|
adb -s 07fbd156 shell pm clear com.android.chrome
|
||||||
adb -s 07fbd156 shell am set-debug-app --persistent com.android.chrome
|
adb -s 07fbd156 shell am set-debug-app --persistent com.android.chrome
|
||||||
adb -s 07fbd156 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
adb -s 07fbd156 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#xiao mi
|
||||||
|
adb -s 192.168.56.107:5555 shell pm clear com.android.chrome
|
||||||
|
adb -s 192.168.56.107:5555 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 192.168.56.107:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#xiao mi
|
||||||
|
adb -s 192.168.56.105:5555 shell pm clear com.android.chrome
|
||||||
|
adb -s 192.168.56.105:5555 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 192.168.56.105:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#xiao mi
|
||||||
|
adb -s 192.168.56.109:5555 shell pm clear com.android.chrome
|
||||||
|
adb -s 192.168.56.109:5555 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 192.168.56.109:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|
||||||
|
#xiao mi
|
||||||
|
adb -s 192.168.56.110:5555 shell pm clear com.android.chrome
|
||||||
|
adb -s 192.168.56.110:5555 shell am set-debug-app --persistent com.android.chrome
|
||||||
|
adb -s 192.168.56.110:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
|
||||||
|
|||||||
+65
-13
@@ -21,6 +21,52 @@ async function filterAlreadyBookedContacts(contactList) {
|
|||||||
return contactsToBook;
|
return contactsToBook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function filterAlreadyAccepteddContacts(contactList) {
|
||||||
|
let alreadyBookedContacts = await mongoManager.getAllAcceptedAppointments();
|
||||||
|
let contactsToBook = [];
|
||||||
|
contactList.forEach((contact) => {
|
||||||
|
let needToBook = true;
|
||||||
|
alreadyBookedContacts.forEach((acceptedItem) => {
|
||||||
|
if (acceptedItem.email === contact.mail) {
|
||||||
|
console.log("=====handle already accepted item before booking====");
|
||||||
|
console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||||
|
console.log("accepted email is " + acceptedItem.email);
|
||||||
|
needToBook = acceptedItem.accepted_at + THIRTY_DAYS_IN_S <= (new Date()) / 1000;
|
||||||
|
if (!needToBook) {
|
||||||
|
console.log("already accepted appointment --> skip");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (needToBook) {
|
||||||
|
contactsToBook.push(contact)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return contactsToBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function filterBlacklistedContacts(contactList) {
|
||||||
|
let blackListedContacts = await mongoManager.getAllBlackedListItems();
|
||||||
|
let contactsToBook = [];
|
||||||
|
contactList.forEach((contact) => {
|
||||||
|
let needToBook = true;
|
||||||
|
blackListedContacts.forEach((blackListItem) => {
|
||||||
|
if (blackListItem.mail === contact.mail) {
|
||||||
|
console.log("=====handle blacklist item before booking=====");
|
||||||
|
console.log("update_at_s is " + blackListItem.update_at_in_s)
|
||||||
|
console.log("black list email is " + blackListItem.mail)
|
||||||
|
needToBook = blackListItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000;
|
||||||
|
if (!needToBook) {
|
||||||
|
console.log("contact in blacklist -->skip");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (needToBook) {
|
||||||
|
contactsToBook.push(contact)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return contactsToBook;
|
||||||
|
}
|
||||||
|
|
||||||
async function needToBook(contact, mongoManager) {
|
async function needToBook(contact, mongoManager) {
|
||||||
console.log("check contact with email " + contact.mail)
|
console.log("check contact with email " + contact.mail)
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
@@ -99,21 +145,27 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
mongoManager.connect().then(r => {
|
mongoManager.connect().then(r => {
|
||||||
filterAlreadyBookedContacts(contactList).then(listToBook => {
|
filterAlreadyBookedContacts(contactList).then((listToBook)=>{
|
||||||
console.log("number of contacts to book:" + listToBook.length)
|
filterAlreadyAccepteddContacts(listToBook).then(notAcceptedContacts => {
|
||||||
android.devices().then((devices) => {
|
filterBlacklistedContacts(notAcceptedContacts).then(listWithoutBlackContact => {
|
||||||
if (devices.length === 0) {
|
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||||
alert("未找到连接的设备");
|
android.devices().then((devices) => {
|
||||||
return
|
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);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
let segmentNumber = listToBook.length / devices.length;
|
)
|
||||||
for (let i = 0; i < devices.length; i++) {
|
|
||||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
});
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = startBookWithNumbers
|
module.exports = startBookWithNumbers
|
||||||
Reference in New Issue
Block a user