更新 ele/auto-meal-complete.user.js
This commit is contained in:
parent
9b38968350
commit
f510d55e8e
@ -89,7 +89,10 @@
|
|||||||
"orderId": orderId
|
"orderId": orderId
|
||||||
})
|
})
|
||||||
debug('订单 #' + daySn + ' 上报出餐结束.')
|
debug('订单 #' + daySn + ' 上报出餐结束.')
|
||||||
ele.submitOrders.push({ completeTime: new Date().toLocaleTimeString(), daySn, orderId, tip, cookTime })
|
ele.submitOrders.push({
|
||||||
|
completeTime: new Date().toLocaleTimeString(),
|
||||||
|
daySn, orderId, tip, cookTime
|
||||||
|
})
|
||||||
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
||||||
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
||||||
}
|
}
|
||||||
@ -104,47 +107,68 @@
|
|||||||
let daySn = cook.header.daySn
|
let daySn = cook.header.daySn
|
||||||
if (!cook.mealPreparationInfo || cook.mealPreparationInfo.mealComplete) continue
|
if (!cook.mealPreparationInfo || cook.mealPreparationInfo.mealComplete) continue
|
||||||
// 骑手到店 并且大于最小上报时长 直接上报出餐
|
// 骑手到店 并且大于最小上报时长 直接上报出餐
|
||||||
let cookTime = (Date.now() - new Date(cook.activeTime).getTime()) / 1000
|
let cookTime = cook.mealPreparationInfo.cookTime -= 5
|
||||||
let leftTime = cook.mealPreparationInfo.commonShowTime
|
let leftTime = cook.mealPreparationInfo.commonShowTime -= 5
|
||||||
let deliveOnShop = cook.deliveryInfo.distTraceView.traceView.status == '骑士已到店'
|
let submitLeft = cook.mealPreparationInfo.submitLeft -= 5
|
||||||
|| (cook.deliveryInfo.deliveryDistance
|
if (cook.mealPreparationInfo.minMealCompleteTimeCount < 0) {
|
||||||
&& !cook.deliveryInfo.deliveryDistance.endsWith('km')
|
if (cook.deliveryInfo.deliveOnShop && leftTime < ele.autoSubmitLeftTimeWhenOnShop) {
|
||||||
&& parseInt(cook.deliveryInfo.deliveryDistance) < 100)
|
debug('订单 #' + daySn + ' 骑手已到店.')
|
||||||
if (deliveOnShop && cook.mealPreparationInfo.minMealCompleteTimeCount < 0
|
debug('订单 #' + daySn + ' 剩余出餐时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
||||||
&& leftTime < ele.autoSubmitLeftTimeWhenOnShop) {
|
return mealComplete(cook, cookTime, '骑手已到店')
|
||||||
debug('订单 #' + daySn + ' 骑手已到店.')
|
}
|
||||||
debug('订单 #' + daySn + ' 剩余出餐时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTimeWhenOnShop + 's 模拟提交出餐.')
|
if (leftTime < ele.autoSubmitLeftTime) {
|
||||||
return mealComplete(cook, cookTime, '骑手已到店')
|
// 大于最小上报时长 并且距离上报超时不足 直接上报出餐
|
||||||
|
debug('订单 #' + daySn + ' 骑手未到店.')
|
||||||
|
debug('订单 #' + daySn + ' 剩余出餐时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTime + 's 模拟提交出餐.')
|
||||||
|
return mealComplete(cook, cookTime, '骑手未到店')
|
||||||
|
}
|
||||||
|
if (submitLeft < 0) {
|
||||||
|
// 非预订单且备餐时间大于最大时间
|
||||||
|
debug('订单 #' + daySn + ' 备餐时间过长.')
|
||||||
|
debug('订单 #' + daySn + ' 备餐时间 ' + cookTime + 's 大于 ' + ele.autoSubmitMaxCookTime + 's 模拟提交出餐.')
|
||||||
|
return mealComplete(cook, cookTime, '备餐已完成')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (leftTime < ele.autoSubmitLeftTime) {
|
debug('订单 #' + daySn + ' 还剩 ' + leftTime + 's 上报超时 将于 ' + submitLeft + 's 后自动上报.')
|
||||||
// 大于最小上报时长 并且距离上报超时不足 直接上报出餐
|
|
||||||
debug('订单 #' + daySn + ' 骑手未到店.')
|
|
||||||
debug('订单 #' + daySn + ' 剩余出餐时间 ' + leftTime + 's 小于 ' + ele.autoSubmitLeftTime + 's 模拟提交出餐.')
|
|
||||||
return mealComplete(cook, cookTime, '骑手未到店')
|
|
||||||
}
|
|
||||||
debug('订单 #' + daySn + ' 还剩 ' + leftTime + 's 上报超时 将于 '
|
|
||||||
+ (Math.max(cook.mealPreparationInfo.minMealCompleteTimeCount,
|
|
||||||
leftTime - (deliveOnShop ? ele.autoSubmitLeftTimeWhenOnShop : ele.autoSubmitLeftTime))) + 's 后自动上报.')
|
|
||||||
cook.mealPreparationInfo.minMealCompleteTimeCount -= 5
|
|
||||||
cook.mealPreparationInfo.commonShowTime -= 5
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function syncOrderTime(cook) {
|
||||||
|
if (cook.printDataInfo.statusForPrint == "预订单" && cook.header.orderPromptDesc.indexOf('备餐提醒时间')) {
|
||||||
|
try { cook.activeTime = new Date().toLocaleDateString() + ' ' + cook.header.orderPromptDesc.match(/\d{2}:\d{2}/g)[1] } catch (error) { }
|
||||||
|
}
|
||||||
|
let deliveOnShop = cook.deliveryInfo.deliveOnShop = cook.deliveryInfo.distTraceView.traceView.status == '骑士已到店'
|
||||||
|
|| (cook.deliveryInfo.deliveryDistance
|
||||||
|
&& !cook.deliveryInfo.deliveryDistance.endsWith('km')
|
||||||
|
&& parseInt(cook.deliveryInfo.deliveryDistance) < 100)
|
||||||
|
let cookTime = cook.mealPreparationInfo.cookTime = ((Date.now() - new Date(cook.activeTime).getTime()) / 1000).toFixed(0)
|
||||||
|
cook.mealPreparationInfo.submitLeft = Math.min(ele.autoSubmitMaxCookTime - cookTime,
|
||||||
|
Math.max(cook.mealPreparationInfo.minMealCompleteTimeCount,
|
||||||
|
cook.mealPreparationInfo.commonShowTime - (deliveOnShop ? ele.autoSubmitLeftTimeWhenOnShop : ele.autoSubmitLeftTime),
|
||||||
|
)).toFixed(0)
|
||||||
|
}
|
||||||
async function syncOrders() {
|
async function syncOrders() {
|
||||||
|
let originCount = ele.processOrders.length
|
||||||
let orders = await queryInProcessOrders()
|
let orders = await queryInProcessOrders()
|
||||||
ele.processOrders = orders.result || []
|
ele.processOrders = orders.result || []
|
||||||
debug('更新订单数据 目前进行中订单: ' + ele.processOrders.length + '个')
|
for (const order of ele.processOrders) {
|
||||||
|
syncOrderTime(order)
|
||||||
|
}
|
||||||
|
debug(originCount != ele.processOrders.length ? '更新订单数据 目前进行中订单: ' + ele.processOrders.length + '个' : '')
|
||||||
}
|
}
|
||||||
function debug(msg) {
|
function debug(msg) {
|
||||||
try {
|
try {
|
||||||
ele.logs.push('[' + (new Date().toLocaleTimeString()) + '] ' + msg)
|
if (msg) {
|
||||||
if (ele.logs.length > ele.maxLogLength) {
|
ele.logs.push('[' + (new Date().toLocaleTimeString()) + '] ' + msg)
|
||||||
ele.logs = ele.logs.slice(ele.logs.length - ele.maxLogLength)
|
if (ele.logs.length > ele.maxLogLength) {
|
||||||
|
ele.logs = ele.logs.slice(ele.logs.length - ele.maxLogLength)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let title = `${ele.title} Version: ${ele.version} By ${ele.author}`
|
let title = `${ele.title} Version: ${ele.version} By ${ele.author}`
|
||||||
let configInfo = `当前配置: </br>
|
let configInfo = `当前配置: </br>
|
||||||
<div class="ant-alert-content">
|
<div class="ant-alert-content">
|
||||||
骑手到店 提前 ${ele.autoSubmitLeftTimeWhenOnShop}s 出餐
|
订单 刷新间隔: ${ele.syncInterval}s 检测间隔: ${ele.checkInterval}s</br>
|
||||||
骑手未到店 提前 ${ele.autoSubmitLeftTime}s 出餐</br>
|
出餐 最长时间: ${ele.autoSubmitMaxCookTime}s
|
||||||
|
骑手未到店: ${ele.autoSubmitLeftTime}s 骑手已到店: ${ele.autoSubmitLeftTimeWhenOnShop}s</br>
|
||||||
</div>`
|
</div>`
|
||||||
let submitInfo = `已自动出餐的订单信息: </br>
|
let submitInfo = `已自动出餐的订单信息: </br>
|
||||||
<div class="ant-alert-content">
|
<div class="ant-alert-content">
|
||||||
@ -154,7 +178,7 @@
|
|||||||
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip).join('</br>')
|
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip).join('</br>')
|
||||||
: '当前没有自动出餐的订单.'}
|
: '当前没有自动出餐的订单.'}
|
||||||
</div>`
|
</div>`
|
||||||
let orderInfo = `进行中的订单信息: </br>
|
let orderInfo = `进行中的订单信息 更新时间:${new Date().toLocaleTimeString()}</br>
|
||||||
<div class="ant-alert-content">
|
<div class="ant-alert-content">
|
||||||
${ele.processOrders.length
|
${ele.processOrders.length
|
||||||
? ele.processOrders.map(o => ' 订单: #' + o.header.daySn
|
? ele.processOrders.map(o => ' 订单: #' + o.header.daySn
|
||||||
@ -169,23 +193,23 @@
|
|||||||
${ele.logs.join('</br>')}
|
${ele.logs.join('</br>')}
|
||||||
</div>`
|
</div>`
|
||||||
window.appContainerNoticeBar.innerHTML = `
|
window.appContainerNoticeBar.innerHTML = `
|
||||||
<div style="margin-left: 35px; margin-top: 20px; display: flex;">
|
<div style="margin-left: 35px; margin-top: 20px; display: flex;">
|
||||||
<div style="flex: 1 1 0%;">
|
<div style="flex: 1 1 0%;">
|
||||||
${title}
|
${title}
|
||||||
<div style="margin-top: 20px;">
|
<div style="margin-top: 20px;">
|
||||||
${configInfo}
|
${configInfo}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 20px;">
|
<div style="margin-top: 20px;">
|
||||||
${orderInfo}
|
${orderInfo}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex: 1 1 0%;">
|
<div style="flex: 1 1 0%;">
|
||||||
${submitInfo}
|
${submitInfo}
|
||||||
</div>
|
</div>
|
||||||
<div style="flex: 1 1 0%;">
|
<div style="flex: 1 1 0%;">
|
||||||
${logs}
|
${logs}
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
}
|
}
|
||||||
@ -199,6 +223,7 @@
|
|||||||
while (!document.getElementById('app-container-notice-bar')) {
|
while (!document.getElementById('app-container-notice-bar')) {
|
||||||
await sleep(300)
|
await sleep(300)
|
||||||
}
|
}
|
||||||
|
console.log(`${ele.title} Version: ${ele.version} By ${ele.author}`)
|
||||||
window.appContainerNoticeBar = document.getElementById('app-container-notice-bar')
|
window.appContainerNoticeBar = document.getElementById('app-container-notice-bar')
|
||||||
debug('页面注入成功 开始运行...')
|
debug('页面注入成功 开始运行...')
|
||||||
syncOrders()
|
syncOrders()
|
||||||
@ -219,8 +244,9 @@
|
|||||||
processOrders: [],
|
processOrders: [],
|
||||||
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)),
|
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)),
|
||||||
autoCheckTask: undefined,
|
autoCheckTask: undefined,
|
||||||
autoSubmitLeftTime: 200,
|
autoSubmitLeftTime: 180,
|
||||||
autoSubmitLeftTimeWhenOnShop: 320,
|
autoSubmitMaxCookTime: 420,
|
||||||
|
autoSubmitLeftTimeWhenOnShop: 300,
|
||||||
debug: debug,
|
debug: debug,
|
||||||
syncOrders: syncOrders,
|
syncOrders: syncOrders,
|
||||||
checkCooking: checkCooking,
|
checkCooking: checkCooking,
|
||||||
|
Loading…
Reference in New Issue
Block a user