【类 型】:fix 任务提交 取消 完成 用事务 操作表

【原  因】:会同时操作 站点表的航线绑定  还是造作订单表 的订单状态等
【过  程】:
【影  响】:
This commit is contained in:
szdot 2024-07-29 03:04:29 +08:00
parent b0de7b20ac
commit 7096eb0ff2
3 changed files with 155 additions and 126 deletions

View File

@ -82,15 +82,13 @@
:loading="true" disabled>
<font class="m-l-5">航点写入中···</font>
</el-button>
<el-button size="mini" class="f-s-14"
v-else-if="plane.planeState.state & 4" type="warning"
<el-button size="mini" class="f-s-14" v-else-if="plane.planeState.state & 4" type="warning"
icon="f-s-14 iconfont icon-jiesuo"
@click="publishFun('{setPlaneState:{bit:3,state:1,count:2,param:[1,0]}}'); speakText('解锁飞机')">
<font class="m-l-5">解锁飞机</font>
</el-button>
<el-button size="mini" class="f-s-14"
v-else-if="plane.planeState.state & 16"
type="success" icon="f-s-14 iconfont icon-yangshi_icon_tongyong_departure"
<el-button size="mini" class="f-s-14" v-else-if="plane.planeState.state & 16" type="success"
icon="f-s-14 iconfont icon-yangshi_icon_tongyong_departure"
@click="publishFun('{setPlaneState:{bit:5,state:1}'); speakText('准备起飞,执行送餐任务')">
<font class="m-l-5">执行任务</font>
</el-button>
@ -259,7 +257,7 @@
</template>
<script>
import { questAss } from '@/utils/api/table'
import { lockSite } from '@/utils/api/table'
import mqtt from '@/utils/mqtt'
import { speakText } from '@/utils/index'
@ -348,7 +346,6 @@ export default {
}
},
methods: {
questAss,
speakText,
/**
* @description: 摄像头 滑动条松开
@ -417,90 +414,99 @@ export default {
}
},
/**
* @description: 执行任务前 先检测订单是否 合法 例如订单重量会不会超出飞机载重上限
* @description: 执行任务前 先检测订单是否合法例如订单重量会不会超出飞机载重上限
*/
checkQuest () {
let checkOrder //
//
let checkOrder //
//
if (this.executeOrder) {
checkOrder = this.executeOrder
} else {
checkOrder = this.currentOrder
}
//
//
if (this.questForm.id === '' && !checkOrder) {
this.$message.error('未选择订单任务!')
return
}
// 退
// 退
if (checkOrder.refund_status === '申请中') {
this.$message.error('此订单已被申请退款或者订单已经被取消!')
return
}
//
//
if (checkOrder.bind_route === null) {
this.$message.error('此站点,未绑定任务航点')
return
}
/* 如果是正在执行订单 直接调用重新提交 */
//
if (this.executeOrder) {
this.continueQuest()
return
}
/* 综合检查 这部分针对 新提交订单 */
/* 综合检查,针对新提交订单 */
//
const weightCheck = new Promise((resolve, reject) => {
if (Number(checkOrder.total_weight) >= Number(this.plane.weight_max)) {
//
this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', {
confirmButtonText: '继续',
cancelButtonText: '放弃',
type: 'warning'
})
.then(() => {
resolve()
resolve() //
})
.catch(action => {
.catch(() => {
this.$message({
type: 'info',
message: '取消提交订单'
})
reject(new Error('Weight check failed'))
reject(new Error('Weight check failed')) //
})
} else {
resolve()
resolve() //
}
})
//
const runningCheck = new Promise((resolve, reject) => {
const runningCheck = weightCheck.then(() => {
return new Promise((resolve, reject) => {
if ((checkOrder.runing ?? '').split(',').some(item => item !== '')) {
//
this.$confirm('此订单的目标站点,已经有飞机正在执行任务。请注意安全!', '检测订单', {
confirmButtonText: '继续',
cancelButtonText: '放弃',
type: 'warning'
})
.then(() => {
resolve()
resolve() //
})
.catch(action => {
.catch(() => {
this.$message({
type: 'info',
message: '取消提交订单'
})
reject(new Error('Running check failed'))
reject(new Error('Running check failed')) //
})
} else {
resolve()
resolve() //
}
})
//
Promise.all([weightCheck, runningCheck])
})
//
runningCheck
.then(() => {
this.runQuest()
this.runQuest() //
})
.catch((error) => {
console.log(error.message)
console.log(error.message) //
})
},
/**
@ -582,13 +588,18 @@ export default {
this.$message.error('操作失败,航线异常')
return
}
let res = await this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning })// 线
if (res.data.status === 1) {
res = await this.questAss(this.currentOrder.id, ['shipment_status', 'by_plane_id'], ['已发货', this.plane.id])//
//
const res = await lockSite({
site_id: this.currentOrder.receive_site_id,
shop_id: this.plane.shop_id,
runing: newRuning,
order_id: this.currentOrder.id,
shipment_status: '已发货',
by_plane_id: this.plane.id
})
if (res.data.status === 1) {
this.publishFun(routeData)//
}
}
},
/**
* @description: 匹配声音航点字符串 比如$food_sn$ food_sn匹配成 送餐订单里面的对应字段
@ -626,17 +637,19 @@ export default {
/**
* @description: 取消任务
*/
reQuest () {
async reQuest () {
if (!this.executeOrder) { // ""
this.$message.warning('当前没有执行任务')
return
}
this.$confirm('取消已发货状态,并使飞机复位?', '提示', {
try {
const confirmation = await this.$confirm('取消已发货状态,并使飞机复位?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
/* 关联当前订单的站点 搜寻注册的飞机 并预设newRuning 用于注销runing字段航线 */
})
if (confirmation) {
//
const runingArray = this.executeOrder.runing.split(',')
//
@ -647,34 +660,41 @@ export default {
}
//
const newRuning = runingArray.join(',')
/* 确认 把订单从发货退回到已接单 站点runing字段飞机航线注销 重置飞机状态 */
this.$store.dispatch('fetchLockSite', { id: this.executeOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 退
if (res.data.status === 1) {
this.questAss(this.executeOrder.id, ['shipment_status', 'by_plane_id'], ['已接单', 'null']).then(res => { // 线
//
const res = await lockSite({
site_id: this.executeOrder.receive_site_id,
shop_id: this.plane.shop_id,
runing: newRuning,
order_id: this.executeOrder.id,
shipment_status: '已接单',
by_plane_id: 'null'
})
if (res.data.status === 1) {
this.publishFun('{"resetState":1}') //
}
})
}
})
}).catch(() => {
} catch (error) {
this.$message.info('取消操作!')
})
}
},
/**
* @description: 已送达任务
*/
overQuest () {
if (!this.executeOrder) { // ""
async overQuest () {
if (!this.executeOrder) {
this.$message.warning('当前没有执行任务')
return
}
this.$confirm('确认订单已送达?', '提示', {
try {
const confirmation = await this.$confirm('确认订单已送达?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
/* 关联当前订单的站点 搜寻注册的飞机 并预设newRuning 用于注销runing字段航线 */
})
if (confirmation) {
//
const runingArray = this.executeOrder.runing.split(',')
//
@ -685,19 +705,25 @@ export default {
}
//
const newRuning = runingArray.join(',')
/* 确认 把订单从发货退回到已接单 站点runing字段飞机航线注销 重置飞机状态 */
this.$store.dispatch('fetchLockSite', { id: this.executeOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { //
if (res.data.status === 1) {
this.questAss(this.executeOrder.id, 'shipment_status', '已送达').then(res => { // 线
//
const res = await lockSite({
site_id: this.executeOrder.receive_site_id,
shop_id: this.plane.shop_id,
runing: newRuning,
order_id: this.executeOrder.id,
shipment_status: '已送达',
by_plane_id: this.plane.id
})
if (res.data.status === 1) {
this.publishFun('{"resetState":1}') //
}
})
}
})
}).catch(() => {
} catch (error) {
console.error('Confirmation dialog error:', error)
this.$message.info('取消操作!')
})
}
},
/**
* @description: 在地图上绘制航线

View File

@ -395,27 +395,6 @@ const store = new Vuex.Store({
Message.warning(res.data.msg)
}
},
/**
* @description: 锁定站点
* @param {*} form 表单.站点信息
* @return {*} 服务器返回信息
*/
async fetchLockSite ({ dispatch }, form) {
const params = new URLSearchParams()
params.append('id', form.id)
params.append('shop_id', form.shop_id)
params.append('runing', form.runing)
const res = await api.post('lockSite', params)
if (res.data.status === 1) {
await dispatch('fetchSiteList')// 刷新站点列表
dispatch('fetchRouteList')// 刷新航线列表
dispatch('fetchPaidOrderList')// 刷订单点列表
Message.success(res.data.msg)
} else {
Message.error(res.data.msg)
}
return res
},
/**
* @description: 创建新站点
* @param {*} form 表单.站点信息

View File

@ -19,6 +19,30 @@ export async function apiCrosFrequency (params) {
}
return res
}
/**
* @description: 锁定站点 相关操作 同步操作订单表 和站点表接口
* @param {*} form 表单.站点信息
* @return {*} 服务器返回信息
*/
export async function lockSite (form) {
const params = new URLSearchParams()
params.append('site_id', form.site_id)
params.append('shop_id', form.shop_id)
params.append('runing', form.runing)
params.append('order_id', form.order_id)
params.append('shipment_status', form.shipment_status)
params.append('by_plane_id', form.by_plane_id)
const res = await api.post('lockSite', params)
if (res.data.status === 1) {
await store.dispatch('fetchSiteList')// 刷新站点列表
store.dispatch('fetchRouteList')// 刷新航线列表
store.dispatch('fetchPaidOrderList')// 刷订单点列表
Message.success(res.data.msg)
} else {
Message.error(res.data.msg)
}
return res
}
/**
* @description: 向改变订单承接任务api 提交数据,参数可以是数组 提交多个字段和字段内容 () 并更新订单列表
* @param {*} id 订单id