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