more fields
This commit is contained in:
+43
-41
@@ -5,25 +5,27 @@ const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
||||
const alert = require('alert');
|
||||
const schedule = require("node-schedule");
|
||||
const DeviceExcludeMode = require("./models/DeviceExcludeMode");
|
||||
const Sender = require("./queue/Sender");
|
||||
const {Sender} = require("./queue/Sender");
|
||||
const mongoManager = new MongoManager();
|
||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||
// const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
||||
const NINETY_DAYS_IN_S = 30 * 3;
|
||||
let excelUtil = new ExcelUtil();
|
||||
let collectionName = formatDate(new Date())
|
||||
let excludeMode = DeviceExcludeMode.THREE
|
||||
let three_to_excludes = []
|
||||
let excludeMode = DeviceExcludeMode.ZERO
|
||||
|
||||
let three_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752"]
|
||||
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "07fbd156", "NFD669QK8XNFSCNN", "6X494TTWQGFALB79", "71a0371d", "YP6HVKLFE67T598L"]
|
||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518", "W8GMFELRHIKZS84T"]
|
||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
||||
attributedPorts = []
|
||||
const device_port_info = new Map();
|
||||
startPort = 9000
|
||||
|
||||
async function filterAlreadyBookedContacts(contactList) {
|
||||
console.log("getAllSuccessfulItemsForDay()")
|
||||
let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
let contactsToBook = [];
|
||||
contactList.forEach((contact) => {
|
||||
@@ -218,44 +220,44 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
let sender = new Sender()
|
||||
sender.initConnection().then((r) => {
|
||||
console.log("queue connected")
|
||||
console.log("connect to mongodb")
|
||||
mongoManager.connect().then(r => {
|
||||
console.log("successfully connected to mongodb")
|
||||
console.log("connect to mongodb")
|
||||
mongoManager.connect().then(r => {
|
||||
console.log("successfully connected to mongodb")
|
||||
filterAlreadyBookedContacts(contactList).then((listWithoutBlackContact) => {
|
||||
console.log("will call filterAlreadyAcceptedContacts")
|
||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||
android.devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
}
|
||||
let device_to_excludes = three_to_excludes;
|
||||
if (excludeMode === DeviceExcludeMode.FOUR) {
|
||||
device_to_excludes = four_to_excludes;
|
||||
} else if (excludeMode === DeviceExcludeMode.THREE) {
|
||||
device_to_excludes = three_to_excludes;
|
||||
} else if (excludeMode === DeviceExcludeMode.NINE) {
|
||||
device_to_excludes = nine_to_excludes;
|
||||
} else if (excludeMode === DeviceExcludeMode.SEVEN) {
|
||||
device_to_excludes = seven_to_excludes
|
||||
} else if (excludeMode === DeviceExcludeMode.SIX) {
|
||||
device_to_excludes = six_to_excludes
|
||||
} else if (excludeMode === DeviceExcludeMode.ZERO) {
|
||||
device_to_excludes = []
|
||||
}
|
||||
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
|
||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||
console.log("connected device number:" + filteredDeviceList.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||
let device = filteredDeviceList[i];
|
||||
let port = startForwordingForDevice(device)
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||
}
|
||||
})
|
||||
|
||||
filterAlreadyBookedContacts(contactList).then((listToBook) => {
|
||||
filterAlreadyAcceptedContacts(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 device_to_excludes = three_to_excludes;
|
||||
if (excludeMode === DeviceExcludeMode.FOUR) {
|
||||
device_to_excludes = four_to_excludes;
|
||||
} else if (excludeMode === DeviceExcludeMode.NINE) {
|
||||
device_to_excludes = nine_to_excludes;
|
||||
} else if (excludeMode === DeviceExcludeMode.SEVEN) {
|
||||
device_to_excludes = seven_to_excludes
|
||||
} else if (excludeMode === DeviceExcludeMode.SIX) {
|
||||
device_to_excludes = six_to_excludes
|
||||
}
|
||||
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
|
||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||
console.log("connected device number:" + filteredDeviceList.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||
let device = filteredDeviceList[i];
|
||||
let port = startForwordingForDevice(device)
|
||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
});
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user