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

View File

@ -395,27 +395,6 @@ const store = new Vuex.Store({
Message.warning(res.data.msg) 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: 创建新站点 * @description: 创建新站点
* @param {*} form 表单.站点信息 * @param {*} form 表单.站点信息

View File

@ -19,6 +19,30 @@ export async function apiCrosFrequency (params) {
} }
return res 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 提交数据,参数可以是数组 提交多个字段和字段内容 () 并更新订单列表 * @description: 向改变订单承接任务api 提交数据,参数可以是数组 提交多个字段和字段内容 () 并更新订单列表
* @param {*} id 订单id * @param {*} id 订单id