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