更新 ele/auto-meal-complete.user.js
This commit is contained in:
parent
6d22e5ce34
commit
002b6575e6
@ -88,7 +88,7 @@
|
||||
debug('订单 #' + daySn + ' 上报出餐结束.')
|
||||
ele.submitOrders.push({
|
||||
completeTime: new Date().toLocaleTimeString(),
|
||||
daySn, orderId, tip, cookTime
|
||||
daySn, orderId, tip, cookTime, result
|
||||
})
|
||||
if (ele.submitOrders.length > ele.maxLogOrderLength) {
|
||||
ele.submitOrders = ele.submitOrders.slice(ele.submitOrders.length - ele.maxLogOrderLength)
|
||||
@ -134,20 +134,25 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
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) { }
|
||||
function syncOrderTime(order) {
|
||||
if (order.printDataInfo.statusForPrint == "预订单" && order.header.orderPromptDesc.indexOf('备餐提醒时间')) {
|
||||
try { order.activeTime = new Date().toLocaleDateString() + ' ' + order.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.max(cook.mealPreparationInfo.minMealCompleteTimeCount, Math.min(ele.autoSubmitMaxCookTime - cookTime,
|
||||
cook.mealPreparationInfo.commonShowTime - (deliveOnShop ? ele.autoSubmitLeftTimeWhenOnShop : ele.autoSubmitLeftTime))
|
||||
let deliveOnShop = false
|
||||
if (order.deliveryInfo) {
|
||||
deliveOnShop = order.deliveryInfo.deliveOnShop = order.deliveryInfo.distTraceView.traceView.status == '骑士已到店'
|
||||
|| (order.deliveryInfo.deliveryDistance
|
||||
&& !order.deliveryInfo.deliveryDistance.endsWith('km')
|
||||
&& parseInt(order.deliveryInfo.deliveryDistance) < 100)
|
||||
}
|
||||
if (order.mealPreparationInfo) {
|
||||
let cookTime = order.mealPreparationInfo.cookTime = ((Date.now() - new Date(order.activeTime).getTime()) / 1000).toFixed(0)
|
||||
order.mealPreparationInfo.submitLeft =
|
||||
Math.max(order.mealPreparationInfo.minMealCompleteTimeCount, Math.min(ele.autoSubmitMaxCookTime - cookTime,
|
||||
order.mealPreparationInfo.commonShowTime - (deliveOnShop ? ele.autoSubmitLeftTimeWhenOnShop : ele.autoSubmitLeftTime))
|
||||
).toFixed(0)
|
||||
}
|
||||
}
|
||||
async function syncOrders() {
|
||||
let originCount = ele.processOrders.length
|
||||
let orders = await queryInProcessOrders()
|
||||
@ -160,6 +165,7 @@
|
||||
} else {
|
||||
updateInfo()
|
||||
}
|
||||
heartbeat()
|
||||
}
|
||||
function debug(msg) {
|
||||
ele.logs.push('[' + (new Date().toLocaleTimeString()) + '] ' + msg)
|
||||
@ -192,8 +198,8 @@
|
||||
<div class="ant-alert-content">
|
||||
${ele.submitOrders.length
|
||||
? ele.submitOrders
|
||||
.map(o => '[' + o.completeTime + '] 订单: #' + o.daySn
|
||||
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip).join('</br>')
|
||||
.map(o => `<div title='` + JSON.stringify(o.result || {}, null, 4) + `'>[` + o.completeTime + '] 订单: #' + o.daySn
|
||||
+ ' 出餐用时 ' + convertSecondsToMinutesSeconds(o.cookTime) + ' ' + o.tip +'</div>').join('')
|
||||
: '当前没有自动出餐的订单.'}
|
||||
</div>`
|
||||
let logs = `运行日志: </br>
|
||||
@ -213,13 +219,13 @@
|
||||
</div>
|
||||
<div style="flex: 1 1 0%;">
|
||||
${submitInfo}
|
||||
</div>
|
||||
<div style="flex: 1 1 0%;">
|
||||
<div style="margin-top: 20px;">
|
||||
${logs}
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
} catch (error) {
|
||||
console.log(msg)
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
async function scheduleCheck() {
|
||||
@ -227,6 +233,12 @@
|
||||
await sleep(ele.checkInterval * 1000)
|
||||
scheduleCheck()
|
||||
}
|
||||
async function heartbeat() {
|
||||
const script = document.createElement('script');
|
||||
script.src = `https://kuma.yumc.pw/api/push/L7kq99ruju?status=up&msg=OK&ping=`;
|
||||
document.body.appendChild(script);
|
||||
script.onload = () => script.remove()
|
||||
}
|
||||
async function main() {
|
||||
while (!document.getElementById('app-container-notice-bar')) {
|
||||
await sleep(300)
|
||||
@ -246,14 +258,14 @@
|
||||
shopId: parseInt(localStorage.shopId),
|
||||
checkInterval: 5,
|
||||
syncInterval: 15,
|
||||
maxLogLength: 20,
|
||||
maxLogOrderLength: 20,
|
||||
maxLogLength: 10,
|
||||
maxLogOrderLength: 10,
|
||||
autoSubmitLeftTime: 180,
|
||||
autoSubmitMaxCookTime: 420,
|
||||
autoSubmitLeftTimeWhenOnShop: 300,
|
||||
autoSubmitLeftTimeWhenOnShop: 240,
|
||||
logs: [],
|
||||
processOrders: [],
|
||||
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)),
|
||||
submitOrders: JSON.parse(localStorage.getItem(SubmitOrdersKey)) || [],
|
||||
debug: debug,
|
||||
syncOrders: syncOrders,
|
||||
checkCooking: checkCooking,
|
||||
|
Loading…
Reference in New Issue
Block a user