完善新增运送清单和订单
This commit is contained in:
200
LOADING_ORDER_PAGE_FIX.md
Normal file
200
LOADING_ORDER_PAGE_FIX.md
Normal file
@@ -0,0 +1,200 @@
|
||||
# 装车订单页面修复说明
|
||||
|
||||
## 问题分析
|
||||
|
||||
`loadingOrder.vue` 页面目前使用错误的接口:
|
||||
- **当前使用:** `orderList(params)` → 调用 `/delivery/pageDeliveryOrderList`
|
||||
- **应该使用:** `orderPageQuery(params)` → 调用 `/order/list`
|
||||
|
||||
## 问题根源
|
||||
|
||||
1. **接口混用:** `orderList` 查询的是 `delivery` 装车运单表,而不是 `order` 订单表
|
||||
2. **字段不匹配:** 页面显示的字段(供应商、采购商、结算方式等)应该来自 `order` 表
|
||||
3. **数据结构错误:** 返回的是运单数据,而不是订单数据
|
||||
|
||||
## 修复方案
|
||||
|
||||
### 1. 修改导入的接口函数
|
||||
|
||||
**文件:** `loadingOrder.vue` 第83行
|
||||
|
||||
```javascript
|
||||
// 修改前
|
||||
import { orderList, orderDel, updateDeliveryStatus, clearDeviceDeliveryId } from '@/api/shipping.js';
|
||||
|
||||
// 修改后
|
||||
import { orderPageQuery, orderDelete, orderUpdate } from '@/api/shipping.js';
|
||||
import { orderList, updateDeliveryStatus, clearDeviceDeliveryId } from '@/api/shipping.js'; // 保留旧的装车订单相关接口
|
||||
```
|
||||
|
||||
### 2. 修改列表查询接口
|
||||
|
||||
**文件:** `loadingOrder.vue` 第236行
|
||||
|
||||
```javascript
|
||||
// 修改前
|
||||
orderList(params)
|
||||
|
||||
// 修改后
|
||||
orderPageQuery(params)
|
||||
```
|
||||
|
||||
### 3. 修改表格列字段
|
||||
|
||||
**文件:** `loadingOrder.vylus` 第21-50行
|
||||
|
||||
```vue
|
||||
<!-- 修改前 -->
|
||||
<el-table-column label="订单编号" prop="deliveryNumber" />
|
||||
<el-table-column label="供应商" prop="supplierName" />
|
||||
<el-table-column label="采购商" prop="buyerName" />
|
||||
<el-table-column label="结算方式" prop="settlementMethod" />
|
||||
<el-table-column label="创建人" prop="createByName" />
|
||||
|
||||
<!-- 修改后 -->
|
||||
<el-table-column label="订单ID" prop="id" />
|
||||
<el-table-column label="买方" prop="buyerName" />
|
||||
<el-table-column label="卖方" prop="sellerName" />
|
||||
<el-table-column label="结算方式" prop="settlementTypeDesc" />
|
||||
<el-table-column label="创建人" prop="createdByName" />
|
||||
```
|
||||
|
||||
### 4. 修改删除函数
|
||||
|
||||
**文件:** `loadingOrder.vue` 第388行
|
||||
|
||||
```javascript
|
||||
// 修改前
|
||||
const del = (id) => {
|
||||
ElMessageBox.confirm('请确认是否删除订单?删除后将同时清空该订单关联的所有智能设备的delivery_id和weight字段', '提示', {
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
clearDeviceDeliveryId(id).then(() => {
|
||||
orderDel(id).then(() => {
|
||||
ElMessage.success('订单删除成功,相关设备的绑定和重量信息已清空');
|
||||
getDataList();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 修改后
|
||||
const del = (id) => {
|
||||
ElMessageBox.confirm('请确认是否删除订单?删除后将不可恢复', '提示', {
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
orderDelete(id).then((res) => {
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('订单删除成功');
|
||||
getDataList();
|
||||
} else {
|
||||
ElMessage.error(res.msg || '删除订单失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('删除订单失败:', error);
|
||||
ElMessage.error('删除订单失败');
|
||||
});
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
### 5. 简化搜索表单
|
||||
|
||||
**文件:** `loadingOrder.vue` 第102-132行
|
||||
|
||||
```javascript
|
||||
// 修改搜索表单字段,只保留订单相关的搜索
|
||||
const formItemList = reactive([
|
||||
{
|
||||
label: '买方',
|
||||
type: 'input',
|
||||
param: 'buyerName',
|
||||
span: 6,
|
||||
placeholder: '请输入买方',
|
||||
},
|
||||
{
|
||||
label: '卖方',
|
||||
type: 'input',
|
||||
param: 'sellerName',
|
||||
span: 6,
|
||||
placeholder: '请输入卖方',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
type: 'daterange',
|
||||
param: 'createTimeRange',
|
||||
span: 6,
|
||||
startPlaceholder: المملكة '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
},
|
||||
]);
|
||||
```
|
||||
|
||||
### 6. 移除不需要的功能
|
||||
|
||||
由于 `order` 表是简化的订单管理,需要移除以下不需要的功能:
|
||||
- 分配设备
|
||||
- 查看设备
|
||||
- 装车
|
||||
- 编辑状态
|
||||
|
||||
```vue
|
||||
<!-- 简化操作列 -->
|
||||
<el-table-column label="操作" width="200">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="showEditDialog(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" @click="del(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
```
|
||||
|
||||
## 数据对比
|
||||
|
||||
### order 表返回的数据结构
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"buyerId": "10,11",
|
||||
"sellerId": "5,6",
|
||||
"settlementType": 1,
|
||||
"buyerName": "张三,李四",
|
||||
"sellerName": "王五,赵六",
|
||||
"settlementTypeDesc": "上车重量",
|
||||
"createdByName": "管理员",
|
||||
"createTime": "2025-01-20 10:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
### delivery 表返回的数据结构
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 89,
|
||||
"deliveryNumber": "ZC20251027161826",
|
||||
"deliveryTitle": "2222",
|
||||
"ratedQuantity": 30,
|
||||
"supplierId": "1,2",
|
||||
"buyerId": 10,
|
||||
"status": 1,
|
||||
"createByName": "管理员"
|
||||
}
|
||||
```
|
||||
|
||||
## 执行步骤
|
||||
|
||||
1. 修改 `loadingOrder.vue` 文件(按上述方案)
|
||||
2. 删除不需要的对话框组件引用
|
||||
3. 调整页面布局以适应新的数据结构
|
||||
4. 测试功能确保正常
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **向后兼容:** 旧的装车订单功能(delivery表)仍然保留,只是这个页面应该展示订单表
|
||||
2. **数据一致性:** 确保数据库已执行 `add_order_id_to_delivery.sql`
|
||||
3. **权限设置:** 确保有 `order:list`, `order:add`, `order:edit`, `order:delete` 权限
|
||||
|
||||
94
LOADING_ORDER_QUICK_FIX.md
Normal file
94
LOADING_ORDER_QUICK_FIX.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# loadingOrder.vue 快速修复指南
|
||||
|
||||
## 问题确认
|
||||
|
||||
**问题:** 接口 `/delivery/pageDeliveryOrderList` 返回10条装车订单数据,但order表只有2条数据。
|
||||
|
||||
**原因:** 前端 `loadingOrder.vue` 应该调用 `/order/list` 接口,而不是 `/delivery/pageDeliveryOrderList`
|
||||
|
||||
## 快速修复步骤
|
||||
|
||||
### 方法1:修改前端API路由(推荐)
|
||||
|
||||
编辑 `pc-cattle-transportation/src/views/shipping/loadingOrder.vue` 第230行:
|
||||
|
||||
```javascript
|
||||
// 当前代码(第83行已经修改了import)
|
||||
orderPageQuery(params)
|
||||
|
||||
// 这个函数会调用 /order/list 接口
|
||||
```
|
||||
|
||||
**确保第83行已修改:**
|
||||
```javascript
|
||||
import { orderPageQuery, orderDelete } from '@/api/shipping.js';
|
||||
```
|
||||
|
||||
### 方法2:检查API映射
|
||||
|
||||
查看 `pc-cattle-transportation/src/api/shipping.js` 确认 `orderPageQuery` 函数:
|
||||
|
||||
```javascript
|
||||
export function orderPageQuery(data) {
|
||||
return request({
|
||||
url: '/order/list', // 确认这里指向正确的接口
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### 方法3:直接修改URL
|
||||
|
||||
在 `loadingOrder.vue` 的 `getDataList` 函数中:
|
||||
|
||||
```javascript
|
||||
// 临时测试:直接使用订单接口
|
||||
import request from '@/utils/axios.ts';
|
||||
|
||||
const getDataList = () => {
|
||||
data.dataListLoading = true;
|
||||
const params = {
|
||||
...form,
|
||||
...baseSearchRef.value.penetrateParams(),
|
||||
};
|
||||
|
||||
// 直接调用订单接口
|
||||
request({
|
||||
url: '/order/list',
|
||||
method: 'POST',
|
||||
data: params
|
||||
}).then((res) => {
|
||||
console.log('订单列表返回结果:', res);
|
||||
// ... 处理返回数据
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
## 验证
|
||||
|
||||
刷新页面后,应该只看到2条数据(来自order表),而不是10条(来自delivery表)。
|
||||
|
||||
## 数据结构对比
|
||||
|
||||
### order表的数据(应该返回)
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"buyerId": "19",
|
||||
"sellerId": "61",
|
||||
"settlementType": 1,
|
||||
"settlementTypeDesc": "上车重量"
|
||||
}
|
||||
```
|
||||
|
||||
### delivery表的数据(不应该返回)
|
||||
```json
|
||||
{
|
||||
"id": 89,
|
||||
"deliveryNumber": "ZC20251027161826",
|
||||
"deliveryTitle": "2222",
|
||||
"ratedQuantity": 30
|
||||
}
|
||||
```
|
||||
|
||||
137
ORDER_DELIVERY_RELATIONSHIP_SUMMARY.md
Normal file
137
ORDER_DELIVERY_RELATIONSHIP_SUMMARY.md
Normal file
@@ -0,0 +1,137 @@
|
||||
# 订单表与装车订单表关联关系说明
|
||||
|
||||
## 问题说明
|
||||
|
||||
用户创建了新的 `order` 订单表,但装车订单接口 `/delivery/pageDeliveryOrderList` 仍然返回的是 `delivery` 装车运单表的数据,没有关联到新的 `order` 表。
|
||||
|
||||
## 解决方案
|
||||
|
||||
### 1. 数据库层面
|
||||
**文件:** `add_order_id_to_delivery.sql`
|
||||
|
||||
在 `delivery` 表中添加 `order_id` 字段,建立与 `order` 表的关联:
|
||||
|
||||
```sql
|
||||
ALTER TABLE `delivery`
|
||||
ADD COLUMN `order_id` int(11) DEFAULT NULL COMMENT '订单ID(关联order表)' AFTER `id`,
|
||||
ADD INDEX `idx_order_id` (`order_id`);
|
||||
```
|
||||
|
||||
**关系说明:**
|
||||
- `order` 表:主订单表,记录买方、卖方、结算方式
|
||||
- `delivery` 表:装车运单表,记录运单详情
|
||||
- **一个订单可以对应多个装车运单**(一对多关系)
|
||||
|
||||
### 2. 实体类更新
|
||||
**文件:** `Delivery.java`
|
||||
|
||||
添加两个字段:
|
||||
- `orderId`:订单ID,用于存储关联的订单
|
||||
- `orderInfo`:订单信息对象,用于查询时填充订单详细信息
|
||||
|
||||
### 3. 服务层更新
|
||||
**文件:** `DeliveryServiceImpl.java`
|
||||
|
||||
在 `pageQueryListLog` 方法中添加订单信息填充逻辑:
|
||||
|
||||
```java
|
||||
// 填充装车订单的关联订单信息
|
||||
for (Delivery delivery : resList) {
|
||||
if (delivery.getOrderId() != null) {
|
||||
Order order = orderMapper.selectById(delivery.getOrderId());
|
||||
if (order != null) {
|
||||
delivery.setOrderInfo(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 数据流程
|
||||
|
||||
1. **创建订单(Order)**
|
||||
- 用户在订单管理中创建订单
|
||||
- 记录:买方、卖方、结算方式
|
||||
- 保存到 `order` 表
|
||||
|
||||
2. **创建装车订单(Delivery)**
|
||||
- 用户在装车订单中创建运单
|
||||
- 记录:运单详情(起始地、目的地、车牌等)
|
||||
- 保存时关联 `order_id`
|
||||
- 保存到 `delivery` 表
|
||||
|
||||
3. **查询装车订单列表**
|
||||
- 调用 `/delivery/pageDeliveryOrderList`
|
||||
- 查询 `delivery` 表
|
||||
- 根据 `order_id` 关联查询 `order` 表
|
||||
- 返回装车订单信息 + 订单信息
|
||||
|
||||
## 返回数据格式
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"total": 10,
|
||||
"rows": [
|
||||
{
|
||||
"id": 89,
|
||||
"orderId": 1, // 关联的订单ID
|
||||
"deliveryNumber": "ZC20251027161826",
|
||||
"deliveryTitle": "2222",
|
||||
"orderInfo": { // 订单详细信息
|
||||
"id": 1,
|
||||
"buyerId": "10,11",
|
||||
"sellerId": "5,6",
|
||||
"settlementType": 1,
|
||||
"buyerName": "张三,李四",
|
||||
"sellerName": "王五,赵六",
|
||||
"settlementTypeDesc": "上车重量"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 使用步骤
|
||||
|
||||
1. **执行数据库迁移**
|
||||
```sql
|
||||
-- 先执行创建订单表的SQL
|
||||
SOURCE create_order_table.sql;
|
||||
|
||||
-- 然后为delivery表添加order_id字段
|
||||
SOURCE add_order_id_to_delivery.sql;
|
||||
```
|
||||
|
||||
2. **重启后端服务**
|
||||
|
||||
3. **前端调用**
|
||||
- 创建订单时:调用 `/order/add`
|
||||
- 创建装车订单时:需要传入 `orderId`
|
||||
- 查询装车订单列表:调用 `/delivery/pageDeliveryOrderList`
|
||||
- 返回的数据中包含 `orderInfo` 字段
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. 不计 `delivery` 已存在数据,`order_id` 为 `NULL`
|
||||
2. 新增运单时需关联 `order_id`
|
||||
3. 查询装车订单时会自动填充 `orderInfo`
|
||||
4. 支持一个订单对应多个装车运单(一对多关系)
|
||||
|
||||
## 前端集成建议
|
||||
|
||||
在装车订单列表中显示订单信息:
|
||||
|
||||
```vue
|
||||
<el-table-column label="买方" prop="orderInfo.buyerName" />
|
||||
<el-table-column label="卖方" prop="orderInfo.sellerName" />
|
||||
<el-table-column label="结算方式" prop="orderInfo.settlementTypeDesc" />
|
||||
```
|
||||
|
||||
## 数据一致性
|
||||
|
||||
- 删除订单时:应检查是否有关联的装车订单
|
||||
- 可级联删除或禁止删除(推荐阻止删除以避免数据不一致)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,29 +18,29 @@
|
||||
|
||||
<div class="main-container">
|
||||
<el-table :data="rows" :key="data.tableKey" border v-loading="data.dataListLoading" element-loading-text="数据加载中..." style="width: 100%">
|
||||
<el-table-column label="订单编号" prop="deliveryNumber" width="180">
|
||||
<el-table-column label="订单ID" prop="id" width="100">
|
||||
<template #default="scope">
|
||||
{{ scope.row.deliveryNumber || '--' }}
|
||||
{{ scope.row.id || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="供应商" prop="supplierName" width="150">
|
||||
<template #default="scope">
|
||||
{{ scope.row.supplierName || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="采购商" prop="buyerName" width="150">
|
||||
<el-table-column label="买方" prop="buyerName" width="200">
|
||||
<template #default="scope">
|
||||
{{ scope.row.buyerName || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结算方式" prop="settlementMethod" width="150">
|
||||
<el-table-column label="卖方" prop="sellerName" width="200">
|
||||
<template #default="scope">
|
||||
{{ getSettlementMethod(scope.row) }}
|
||||
{{ scope.row.sellerName || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建人" prop="createByName" width="120">
|
||||
<el-table-column label="结算方式" prop="settlementTypeDesc" width="150">
|
||||
<template #default="scope">
|
||||
{{ scope.row.createByName || '--' }}
|
||||
{{ scope.row.settlementTypeDesc || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建人" prop="createdByName" width="120">
|
||||
<template #default="scope">
|
||||
{{ scope.row.createdByName || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" prop="createTime" width="180">
|
||||
@@ -48,15 +48,10 @@
|
||||
{{ scope.row.createTime || '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="420">
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" :disabled="scope.row.status != 1" v-hasPermi="['loading:edit']" @click="showEditDialog(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" :disabled="scope.row.status != 1" v-hasPermi="['loading:assign']" @click="showAssignDialog(scope.row)">分配设备</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['loading:view']" @click="showDetailDialog(scope.row)">详情</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['loading:device']" @click="showLookDialog(scope.row)">查看设备</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['loading:status']" @click="editStatus(scope.row)">编辑状态</el-button>
|
||||
<el-button link type="primary" :disabled="scope.row.status != 1" v-hasPermi="['loading:delete']" @click="del(scope.row.id)">删除</el-button>
|
||||
<el-button link type="primary" :disabled="scope.row.status != 1" v-hasPermi="['loading:load']" @click="loadClick(scope.row)">装车</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['order:edit']" @click="showEditDialog(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['order:delete']" @click="del(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty>
|
||||
@@ -65,67 +60,56 @@
|
||||
</el-table>
|
||||
<pagination v-model:limit="form.pageSize" v-model:page="form.pageNum" :total="data.total" @pagination="getDataList" />
|
||||
<OrderDialog ref="OrderDialogRef" @success="getDataList" />
|
||||
<LookDialog ref="LookDialogRef" />
|
||||
<AssignDialog ref="AssignDialogRef" @success="getDataList" />
|
||||
<DetailDialog ref="DetailDialogRef" />
|
||||
<editDialog ref="editDialogRef" @success="getDataList" />
|
||||
<LoadDialog ref="LoadDialogRef" @success="getDataList" />
|
||||
<CreateDeliveryDialog ref="CreateDeliveryDialogRef" @success="getDataList" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, nextTick, watch } from 'vue';
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Picture } from '@element-plus/icons-vue';
|
||||
import baseSearch from '@/components/common/searchCustom/index.vue';
|
||||
import { orderList, orderDel, updateDeliveryStatus, clearDeviceDeliveryId } from '@/api/shipping.js';
|
||||
import { pageDeviceList } from '@/api/abroad.js';
|
||||
import { getImageList, handleImageError } from '@/utils/imageUtils.js';
|
||||
import { orderPageQuery, orderDelete } from '@/api/shipping.js';
|
||||
import OrderDialog from './orderDialog.vue';
|
||||
import LookDialog from './lookDialog.vue';
|
||||
import AssignDialog from './assignDialog.vue';
|
||||
import DetailDialog from './detailDialog.vue';
|
||||
import editDialog from './editDialog.vue';
|
||||
import LoadDialog from './loadDialog.vue';
|
||||
import CreateDeliveryDialog from './createDeliveryDialog.vue';
|
||||
|
||||
const baseSearchRef = ref();
|
||||
const DetailDialogRef = ref();
|
||||
const OrderDialogRef = ref();
|
||||
const LookDialogRef = ref();
|
||||
const editDialogRef = ref();
|
||||
const AssignDialogRef = ref();
|
||||
const LoadDialogRef = ref();
|
||||
const CreateDeliveryDialogRef = ref();
|
||||
const formItemList = reactive([
|
||||
{
|
||||
label: '运单号',
|
||||
type: 'input',
|
||||
param: 'deliveryNumber',
|
||||
span: 6,
|
||||
placeholder: '请输入运单号',
|
||||
},
|
||||
{
|
||||
label: '供应商',
|
||||
type: 'input',
|
||||
param: 'supplierName',
|
||||
span: 6,
|
||||
placeholder: '请输入供应商',
|
||||
},
|
||||
{
|
||||
label: '采购商',
|
||||
label: '买方',
|
||||
type: 'input',
|
||||
param: 'buyerName',
|
||||
span: 6,
|
||||
placeholder: '请输入采购商',
|
||||
placeholder: '请输入买方',
|
||||
},
|
||||
{
|
||||
label: '卖方',
|
||||
type: 'input',
|
||||
param: 'sellerName',
|
||||
span: 6,
|
||||
placeholder: '请输入卖方',
|
||||
},
|
||||
{
|
||||
label: '结算方式',
|
||||
type: 'select',
|
||||
param: 'settlementType',
|
||||
span: 6,
|
||||
selectOptions: [
|
||||
{ text: '上车重量', value: 1 },
|
||||
{ text: '下车重量', value: 2 },
|
||||
{ text: '按肉价结算', value: 3 }
|
||||
],
|
||||
placeholder: '请选择结算方式',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
type: 'daterange',
|
||||
param: 'createTimeRange',
|
||||
span: 6,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
format: 'YYYY-MM-DD',
|
||||
startPlaceholder: '开始日期',
|
||||
endPlaceholder: '结束日期',
|
||||
},
|
||||
@@ -135,7 +119,6 @@ const data = reactive({
|
||||
dataListLoading: false,
|
||||
tableKey: 0, // 用于强制重新渲染表格
|
||||
forceUpdate: 0, // 用于强制更新
|
||||
deviceCounts: {}, // 存储每个订单的设备数量 {orderId: {host: 0, ear: 0, collar: 0, total: 0}}
|
||||
});
|
||||
|
||||
// 使用ref确保响应式更新
|
||||
@@ -144,62 +127,6 @@ const form = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
// 获取指定订单的设备数量
|
||||
const getDeviceCounts = async (deliveryId) => {
|
||||
try {
|
||||
console.log('=== 获取装车订单设备数量,deliveryId:', deliveryId);
|
||||
|
||||
// 获取所有设备类型的数据
|
||||
const [hostRes, earRes, collarRes] = await Promise.all([
|
||||
pageDeviceList({ pageNum: 1, pageSize: 100, deliveryId: parseInt(deliveryId), deviceType: 1 }),
|
||||
pageDeviceList({ pageNum: 1, pageSize: 100, deliveryId: parseInt(deliveryId), deviceType: 2 }),
|
||||
pageDeviceList({ pageNum: 1, pageSize: 100, deliveryId: parseInt(deliveryId), deviceType: 4 })
|
||||
]);
|
||||
|
||||
const hostCount = hostRes.code === 200 ? hostRes.data.length : 0;
|
||||
const earCount = earRes.code === 200 ? earRes.data.length : 0;
|
||||
const collarCount = collarRes.code === 200 ? collarRes.data.length : 0;
|
||||
const totalCount = hostCount + earCount + collarCount;
|
||||
|
||||
console.log('=== 装车订单设备数量统计:', {
|
||||
deliveryId,
|
||||
hostCount,
|
||||
earCount,
|
||||
collarCount,
|
||||
totalCount
|
||||
});
|
||||
|
||||
// 存储设备数量
|
||||
data.deviceCounts[deliveryId] = {
|
||||
host: hostCount,
|
||||
ear: earCount,
|
||||
collar: collarCount,
|
||||
total: totalCount
|
||||
};
|
||||
|
||||
return {
|
||||
host: hostCount,
|
||||
ear: earCount,
|
||||
collar: collarCount,
|
||||
total: totalCount
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取装车订单设备数量失败:', error);
|
||||
return { host: 0, ear: 0, collar: 0, total: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
// 获取订单的设备总数
|
||||
const getTotalDeviceCount = (deliveryId) => {
|
||||
const counts = data.deviceCounts[deliveryId];
|
||||
return counts ? counts.total : 0;
|
||||
};
|
||||
|
||||
// 获取订单的耳标数量
|
||||
const getEarTagCount = (deliveryId) => {
|
||||
const counts = data.deviceCounts[deliveryId];
|
||||
return counts ? counts.ear : 0;
|
||||
};
|
||||
|
||||
const searchFrom = () => {
|
||||
console.log('=== 搜索功能被触发 ===');
|
||||
@@ -224,122 +151,37 @@ const getDataList = () => {
|
||||
delete params.createTimeRange; // 删除原始参数
|
||||
}
|
||||
|
||||
console.log('运送清单列表查询参数:', params);
|
||||
console.log('=== 前端搜索参数调试 ===');
|
||||
console.log('deliveryNumber:', params.deliveryNumber);
|
||||
console.log('licensePlate:', params.licensePlate);
|
||||
console.log('deliveryTitle:', params.deliveryTitle);
|
||||
console.log('endLocation:', params.endLocation);
|
||||
console.log('status:', params.status);
|
||||
console.log('startTime:', params.startTime);
|
||||
console.log('endTime:', params.endTime);
|
||||
orderList(params)
|
||||
// 清理字符串参数中的空白字符
|
||||
if (params.buyerName && typeof params.buyerName === 'string') {
|
||||
params.buyerName = params.buyerName.trim();
|
||||
if (params.buyerName === '') delete params.buyerName;
|
||||
}
|
||||
if (params.sellerName && typeof params.sellerName === 'string') {
|
||||
params.sellerName = params.sellerName.trim();
|
||||
if (params.sellerName === '') delete params.sellerName;
|
||||
}
|
||||
|
||||
console.log('订单列表查询参数:', params);
|
||||
// 调用订单列表接口,而不是装车订单接口
|
||||
orderPageQuery(params)
|
||||
.then((res) => {
|
||||
console.log('运送清单列表返回结果:', res);
|
||||
console.log('订单列表返回结果:', res);
|
||||
data.dataListLoading = false;
|
||||
|
||||
// 调试:检查所有数据
|
||||
console.log('=== 装车订单数据调试 ===');
|
||||
console.log('API响应:', res);
|
||||
console.log('数据行数:', res.data.rows ? res.data.rows.length : 0);
|
||||
// 直接赋值订单数据
|
||||
console.log('=== 订单数据 ===');
|
||||
console.log('完整响应:', res);
|
||||
console.log('res.data:', res.data);
|
||||
console.log('数据行数:', res.data?.rows?.length || 0);
|
||||
|
||||
// 前端精确搜索:根据条件精确搜索
|
||||
if (searchParams.buyerName && res.data.rows && res.data.rows.length > 0) {
|
||||
// 精确匹配采购商名称
|
||||
const filteredRows = res.data.rows.filter(row => row.buyerName === searchParams.buyerName);
|
||||
if (filteredRows.length > 0) {
|
||||
res.data.rows = filteredRows;
|
||||
res.data.total = filteredRows.length;
|
||||
} else {
|
||||
res.data.rows = [];
|
||||
res.data.total = 0;
|
||||
}
|
||||
rows.value = res.data?.rows || [];
|
||||
data.total = res.data?.total || 0;
|
||||
|
||||
console.log('更新后rows长度:', rows.value.length);
|
||||
console.log('更新后total:', data.total);
|
||||
if (rows.value.length > 0) {
|
||||
console.log('第一行订单数据:', rows.value[0]);
|
||||
}
|
||||
if (searchParams.supplierName && res.data.rows && res.data.rows.length > 0) {
|
||||
// 精确匹配供应商名称
|
||||
const filteredRows = res.data.rows.filter(row => row.supplierName === searchParams.supplierName);
|
||||
if (filteredRows.length > 0) {
|
||||
res.data.rows = filteredRows;
|
||||
res.data.total = filteredRows.length;
|
||||
} else {
|
||||
res.data.rows = [];
|
||||
res.data.total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (res.data.rows && res.data.rows.length > 0) {
|
||||
// 调试所有行的基本信息
|
||||
res.data.rows.forEach((row, index) => {
|
||||
console.log(`=== 第${index + 1}行数据 ===`);
|
||||
console.log('车牌号:', row.licensePlate);
|
||||
console.log('司机姓名:', row.driverName);
|
||||
console.log('carFrontPhoto:', row.carFrontPhoto);
|
||||
console.log('carBehindPhoto:', row.carBehindPhoto);
|
||||
console.log('driverId:', row.driverId);
|
||||
|
||||
// 特别关注车牌号wwwww
|
||||
if (row.licensePlate === 'wwwww') {
|
||||
console.log('*** 找到车牌号wwwww的数据 ***');
|
||||
console.log('完整行数据:', row);
|
||||
|
||||
// 前端测试分割逻辑
|
||||
console.log('=== 前端测试分割逻辑 ===');
|
||||
const testCarImg = "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/16/4c4e20251016142427.jpg,https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/16/4c4e20251016142429.jpg";
|
||||
console.log('测试car_img:', testCarImg);
|
||||
|
||||
const carImgUrls = testCarImg.split(',');
|
||||
console.log('分割后数组:', carImgUrls);
|
||||
console.log('分割后长度:', carImgUrls.length);
|
||||
|
||||
if (carImgUrls.length >= 2) {
|
||||
const carBehindPhoto = carImgUrls[0].trim();
|
||||
const carFrontPhoto = carImgUrls[1].trim();
|
||||
console.log('车尾照片 (carBehindPhoto):', carBehindPhoto);
|
||||
console.log('车头照片 (carFrontPhoto):', carFrontPhoto);
|
||||
|
||||
// 测试getImageList函数
|
||||
console.log('车尾照片getImageList结果:', getImageList(carBehindPhoto));
|
||||
console.log('车头照片getImageList结果:', getImageList(carFrontPhoto));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('没有数据行');
|
||||
}
|
||||
|
||||
// 使用setTimeout确保DOM完全更新
|
||||
setTimeout(async () => {
|
||||
// 强制重新赋值,确保响应式更新
|
||||
rows.value = [...res.data.rows];
|
||||
data.total = res.data.total;
|
||||
|
||||
// 为每个订单获取设备数量
|
||||
if (res.data.rows && res.data.rows.length > 0) {
|
||||
console.log('=== 开始为每个装车订单获取设备数量');
|
||||
for (const row of res.data.rows) {
|
||||
if (row.id) {
|
||||
await getDeviceCounts(row.id);
|
||||
}
|
||||
}
|
||||
console.log('=== 所有装车订单设备数量获取完成');
|
||||
}
|
||||
|
||||
// 更新表格key,强制重新渲染
|
||||
data.tableKey = Date.now();
|
||||
// 强制更新
|
||||
data.forceUpdate = Date.now();
|
||||
|
||||
console.log('数据更新完成,当前rows长度:', rows.value.length);
|
||||
if (rows.value.length > 0) {
|
||||
console.log('更新后的第一行数据:', rows.value[0]);
|
||||
}
|
||||
|
||||
// 再次延迟更新,确保表格重新渲染
|
||||
setTimeout(() => {
|
||||
data.forceUpdate = Date.now();
|
||||
console.log('二次强制更新完成');
|
||||
}, 200);
|
||||
}, 50);
|
||||
})
|
||||
.catch(() => {
|
||||
data.dataListLoading = false;
|
||||
@@ -351,10 +193,10 @@ const showAddDialog = (row) => {
|
||||
OrderDialogRef.value.onShowDialog(row);
|
||||
}
|
||||
};
|
||||
// 编辑装车订单
|
||||
// 编辑订单
|
||||
const showEditDialog = (row) => {
|
||||
if (editDialogRef.value) {
|
||||
editDialogRef.value.onShowDialog(row);
|
||||
if (OrderDialogRef.value) {
|
||||
OrderDialogRef.value.onShowDialog(row);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -365,192 +207,27 @@ const showCreateDeliveryDialog = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 查看耳标设备
|
||||
const showLookDialog = (row) => {
|
||||
if (LookDialogRef.value) {
|
||||
LookDialogRef.value.onShowLookDialog(row);
|
||||
}
|
||||
};
|
||||
|
||||
// 分配耳标设备
|
||||
const showAssignDialog = (row) => {
|
||||
if (AssignDialogRef.value) {
|
||||
AssignDialogRef.value.onShowAssignDialog(row);
|
||||
}
|
||||
};
|
||||
// 详情
|
||||
const showDetailDialog = (row) => {
|
||||
if (DetailDialogRef.value) {
|
||||
DetailDialogRef.value.onShowDetailDialog(row);
|
||||
}
|
||||
};
|
||||
// 删除
|
||||
// 删除订单(逻辑删除)
|
||||
const del = (id) => {
|
||||
ElMessageBox.confirm('请确认是否删除订单?删除后将同时清空该订单关联的所有智能设备的delivery_id和weight字段', '提示', {
|
||||
ElMessageBox.confirm('请确认是否删除订单?删除后将不可恢复', '提示', {
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
// 先清空设备的delivery_id
|
||||
clearDeviceDeliveryId(id).then(() => {
|
||||
console.log('设备delivery_id清空成功');
|
||||
|
||||
// 然后删除订单
|
||||
orderDel(id).then(() => {
|
||||
ElMessage.success('订单删除成功,相关设备的绑定和重量信息已清空');
|
||||
// 调用订单删除接口
|
||||
orderDelete(id).then((res) => {
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('订单删除成功');
|
||||
getDataList();
|
||||
}).catch((error) => {
|
||||
console.error('删除订单失败:', error);
|
||||
ElMessage.error('删除订单失败');
|
||||
});
|
||||
} else {
|
||||
ElMessage.error(res.msg || '删除订单失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('清空设备delivery_id失败:', error);
|
||||
ElMessage.error('清空设备绑定失败');
|
||||
console.error('删除订单失败:', error);
|
||||
ElMessage.error('删除订单失败');
|
||||
});
|
||||
});
|
||||
};
|
||||
// 装车
|
||||
const loadClick = (row) => {
|
||||
console.log('装车按钮点击,row数据:', row);
|
||||
if (LoadDialogRef.value) {
|
||||
// 直接传递row数据作为API数据
|
||||
LoadDialogRef.value.onShowDialog(row, row);
|
||||
}
|
||||
};
|
||||
// 编辑状态
|
||||
const editStatus = (row) => {
|
||||
ElMessageBox.prompt('请输入状态(1-待装车 2-已装车/预付款已支付 3-已装车/尾款待支付 4-已核验/待买家付款 5-尾款已付款 6-发票待开/进项票 7-发票待开/销项)', '修改状态', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputPattern: /^[1234567]$/,
|
||||
inputErrorMessage: '请输入1、2、3、4、5、6或7',
|
||||
inputValue: String(row.status || 1)
|
||||
}).then(({ value }) => {
|
||||
updateDeliveryStatus({ id: row.id, status: parseInt(value) })
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('状态更新成功');
|
||||
getDataList();
|
||||
} else {
|
||||
ElMessage.error(res.msg || '状态更新失败');
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('状态更新失败');
|
||||
});
|
||||
}).catch(() => {
|
||||
// 用户取消
|
||||
});
|
||||
};
|
||||
// 状态文本转换
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
1: '待装车',
|
||||
2: '已装车/预付款已支付',
|
||||
3: '已装车/尾款待支付',
|
||||
4: '已核验/待买家付款',
|
||||
5: '尾款已付款',
|
||||
6: '发票待开/进项票',
|
||||
7: '发票待开/销项'
|
||||
};
|
||||
return statusMap[status] || '未知状态';
|
||||
};
|
||||
|
||||
// 状态标签类型
|
||||
const getStatusTagType = (status) => {
|
||||
const typeMap = {
|
||||
1: 'warning', // 待装车 - 橙色
|
||||
2: 'info', // 已装车/预付款已支付 - 蓝色
|
||||
3: 'warning', // 已装车/尾款待支付 - 橙色
|
||||
4: 'success', // 已核验/待买家付款 - 绿色
|
||||
5: 'success', // 尾款已付款 - 绿色
|
||||
6: 'info', // 发票待开/进项票 - 蓝色
|
||||
7: 'info' // 发票待开/销项 - 蓝色
|
||||
};
|
||||
return typeMap[status] || 'info';
|
||||
};
|
||||
|
||||
// 前端处理车身照片分割逻辑
|
||||
const getProcessedCarPhotos = (row) => {
|
||||
console.log('=== 前端处理车身照片 ===');
|
||||
console.log('输入行数据:', row);
|
||||
console.log('carFrontPhoto:', row.carFrontPhoto);
|
||||
console.log('carBehindPhoto:', row.carBehindPhoto);
|
||||
|
||||
// 检查是否有车身照片数据
|
||||
if (!row.carFrontPhoto && !row.carBehindPhoto) {
|
||||
console.log('没有车身照片数据');
|
||||
return [];
|
||||
}
|
||||
|
||||
// 如果后端已经正确分割,直接使用
|
||||
if (row.carFrontPhoto && row.carBehindPhoto &&
|
||||
!row.carFrontPhoto.includes(',') && !row.carBehindPhoto.includes(',')) {
|
||||
console.log('后端已正确分割,直接使用');
|
||||
return [row.carBehindPhoto, row.carFrontPhoto]; // 车尾在前,车头在后
|
||||
}
|
||||
|
||||
// 如果后端没有正确分割,使用前端分割逻辑
|
||||
let carImgUrls = [];
|
||||
|
||||
// 尝试从carFrontPhoto获取完整数据
|
||||
if (row.carFrontPhoto && row.carFrontPhoto.includes(',')) {
|
||||
console.log('从carFrontPhoto分割:', row.carFrontPhoto);
|
||||
carImgUrls = row.carFrontPhoto.split(',').map(url => url.trim()).filter(url => url !== '');
|
||||
}
|
||||
// 尝试从carBehindPhoto获取完整数据
|
||||
else if (row.carBehindPhoto && row.carBehindPhoto.includes(',')) {
|
||||
console.log('从carBehindPhoto分割:', row.carBehindPhoto);
|
||||
carImgUrls = row.carBehindPhoto.split(',').map(url => url.trim()).filter(url => url !== '');
|
||||
}
|
||||
// 如果都没有逗号,尝试合并两个字段
|
||||
else if (row.carFrontPhoto && row.carBehindPhoto) {
|
||||
console.log('合并两个字段:', row.carFrontPhoto, row.carBehindPhoto);
|
||||
carImgUrls = [row.carBehindPhoto, row.carFrontPhoto].filter(url => url && url.trim() !== '');
|
||||
}
|
||||
// 单个字段
|
||||
else if (row.carFrontPhoto) {
|
||||
carImgUrls = [row.carFrontPhoto];
|
||||
}
|
||||
else if (row.carBehindPhoto) {
|
||||
carImgUrls = [row.carBehindPhoto];
|
||||
}
|
||||
|
||||
console.log('分割结果:', carImgUrls);
|
||||
console.log('分割后长度:', carImgUrls.length);
|
||||
|
||||
return carImgUrls;
|
||||
};
|
||||
|
||||
// 获取结算方式
|
||||
const getSettlementMethod = (row) => {
|
||||
// 根据现有字段判断结算方式
|
||||
// 如果有空车磅重和装车磅重,使用上车重量结算
|
||||
// 如果有落地磅重,使用下车重量结算
|
||||
// 如果有约定单价,使用按照肉价结算
|
||||
|
||||
if (row.emptyWeight && row.entruckWeight) {
|
||||
return '上车重量';
|
||||
} else if (row.landingEntruckWeight) {
|
||||
return '下车重量';
|
||||
} else if (row.firmPrice) {
|
||||
return '按照肉价';
|
||||
}
|
||||
return '--';
|
||||
};
|
||||
|
||||
// 监听rows变化,强制更新表格
|
||||
watch(rows, (newRows) => {
|
||||
console.log('rows数据变化:', newRows);
|
||||
if (newRows && newRows.length > 0) {
|
||||
console.log('第一行数据详情:', newRows[0]);
|
||||
console.log('关键字段:', {
|
||||
statusDesc: newRows[0].statusDesc,
|
||||
registeredJbqCount: newRows[0].registeredJbqCount,
|
||||
earTagCount: newRows[0].earTagCount
|
||||
});
|
||||
}
|
||||
}, { deep: true, immediate: true });
|
||||
|
||||
onMounted(() => {
|
||||
console.log('=== 装车订单页面已加载 ===');
|
||||
|
||||
@@ -254,8 +254,33 @@ const onShowDialog = (orderData) => {
|
||||
|
||||
// 重置表单数据
|
||||
ruleForm.id = orderData?.id || null;
|
||||
ruleForm.buyerId = orderData?.buyerId ? orderData.buyerId.split(',') : [];
|
||||
ruleForm.sellerId = orderData?.sellerId ? orderData.sellerId.split(',') : [];
|
||||
|
||||
// 处理buyerId:支持字符串和数组两种格式
|
||||
if (orderData?.buyerId) {
|
||||
if (Array.isArray(orderData.buyerId)) {
|
||||
ruleForm.buyerId = orderData.buyerId;
|
||||
} else if (typeof orderData.buyerId === 'string' && orderData.buyerId.trim() !== '') {
|
||||
ruleForm.buyerId = orderData.buyerId.split(',').map(id => id.trim()).filter(id => id !== '');
|
||||
} else {
|
||||
ruleForm.buyerId = [];
|
||||
}
|
||||
} else {
|
||||
ruleForm.buyerId = [];
|
||||
}
|
||||
|
||||
// 处理sellerId:支持字符串和数组两种格式
|
||||
if (orderData?.sellerId) {
|
||||
if (Array.isArray(orderData.sellerId)) {
|
||||
ruleForm.sellerId = orderData.sellerId;
|
||||
} else if (typeof orderData.sellerId === 'string' && orderData.sellerId.trim() !== '') {
|
||||
ruleForm.sellerId = orderData.sellerId.split(',').map(id => id.trim()).filter(id => id !== '');
|
||||
} else {
|
||||
ruleForm.sellerId = [];
|
||||
}
|
||||
} else {
|
||||
ruleForm.sellerId = [];
|
||||
}
|
||||
|
||||
ruleForm.settlementType = orderData?.settlementType || 1;
|
||||
|
||||
data.dialogVisible = true;
|
||||
|
||||
48
tradeCattle/add_missing_photo_video_fields.sql
Normal file
48
tradeCattle/add_missing_photo_video_fields.sql
Normal file
@@ -0,0 +1,48 @@
|
||||
-- =============================================
|
||||
-- 数据库迁移脚本:为 delivery 表添加缺失的照片和视频字段
|
||||
-- 用途:存储到地相关的照片和视频
|
||||
-- 创建时间:2025-10-28
|
||||
-- 数据库:MySQL
|
||||
-- =============================================
|
||||
|
||||
-- 添加到地纸质磅单(双章)照片字段
|
||||
ALTER TABLE delivery
|
||||
ADD COLUMN destination_pound_list_img VARCHAR(500) COMMENT '到地纸质磅单(双章)'
|
||||
AFTER driver_id_card_photo;
|
||||
|
||||
-- 添加到地车辆过重磅车头照片字段
|
||||
ALTER TABLE delivery
|
||||
ADD COLUMN destination_vehicle_front_photo VARCHAR(500) COMMENT '到地车辆过重磅车头照片'
|
||||
AFTER destination_pound_list_img;
|
||||
|
||||
-- 添加装牛视频字段
|
||||
ALTER TABLE delivery
|
||||
ADD COLUMN cattle_loading_video VARCHAR(500) COMMENT '装牛视频'
|
||||
AFTER cattle_loading_circle_video;
|
||||
|
||||
-- 添加卸牛视频字段
|
||||
ALTER TABLE delivery
|
||||
ADD COLUMN unload_cattle_video VARCHAR(500) COMMENT '卸牛视频'
|
||||
AFTER cattle_loading_video;
|
||||
|
||||
-- 添加到地过磅视频字段
|
||||
ALTER TABLE delivery
|
||||
ADD COLUMN destination_weight_video VARCHAR(500) COMMENT '到地过磅视频'
|
||||
AFTER unload_cattle_video;
|
||||
|
||||
-- 验证字段是否添加成功
|
||||
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_COMMENT
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'delivery'
|
||||
AND COLUMN_NAME IN (
|
||||
'destination_pound_list_img',
|
||||
'destination_vehicle_front_photo',
|
||||
'cattle_loading_video',
|
||||
'unload_cattle_video',
|
||||
'destination_weight_video'
|
||||
);
|
||||
|
||||
-- 显示完整的表结构
|
||||
DESCRIBE delivery;
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -32,15 +34,15 @@ public class OrderController {
|
||||
*/
|
||||
@SaCheckPermission("order:list")
|
||||
@PostMapping("/list")
|
||||
public AjaxResult list(@RequestBody Map<String, Object> params) {
|
||||
public PageResultResponse<Order> list(@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
logger.info("查询订单列表,参数:{}", params);
|
||||
PageResultResponse<Order> result = orderService.pageQuery(params);
|
||||
logger.info("查询成功,共{}条记录", result.getData().getTotal());
|
||||
return AjaxResult.success(result);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
logger.error("查询订单列表失败:{}", e.getMessage(), e);
|
||||
return AjaxResult.error("查询订单列表失败:" + e.getMessage());
|
||||
return new PageResultResponse<>(0, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.aiotagro.cattletrade.business.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
@@ -13,6 +14,8 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class DeliveryCreateDto {
|
||||
/** 关联订单ID */
|
||||
private Integer orderId;
|
||||
|
||||
/**
|
||||
* 发货方
|
||||
@@ -30,8 +33,6 @@ public class DeliveryCreateDto {
|
||||
* 车牌号
|
||||
*/
|
||||
@NotBlank(message = "车牌号不能为空")
|
||||
@Pattern(regexp = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-Z0-9]{5}[A-Z0-9挂学警港澳]$",
|
||||
message = "车牌号格式不正确")
|
||||
private String plateNumber;
|
||||
|
||||
/**
|
||||
@@ -66,12 +67,14 @@ public class DeliveryCreateDto {
|
||||
* 预计出发时间
|
||||
*/
|
||||
@NotNull(message = "预计出发时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date estimatedDepartureTime;
|
||||
|
||||
/**
|
||||
* 预计到达时间
|
||||
*/
|
||||
@NotNull(message = "预计到达时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date estimatedArrivalTime;
|
||||
|
||||
/**
|
||||
@@ -79,12 +82,20 @@ public class DeliveryCreateDto {
|
||||
*/
|
||||
@NotBlank(message = "起点地址不能为空")
|
||||
private String startLocation;
|
||||
/** 起点经度 */
|
||||
private String startLon;
|
||||
/** 起点纬度 */
|
||||
private String startLat;
|
||||
|
||||
/**
|
||||
* 目的地地址
|
||||
*/
|
||||
@NotBlank(message = "目的地地址不能为空")
|
||||
private String endLocation;
|
||||
/** 目的地经度 */
|
||||
private String endLon;
|
||||
/** 目的地纬度 */
|
||||
private String endLat;
|
||||
|
||||
/**
|
||||
* 牛只数量
|
||||
@@ -110,5 +121,87 @@ public class DeliveryCreateDto {
|
||||
*/
|
||||
@Size(max = 500, message = "备注不能超过500字")
|
||||
private String remark;
|
||||
|
||||
/** 空车过磅重量 */
|
||||
private String emptyWeight;
|
||||
/** 装车过磅重量 */
|
||||
private String entruckWeight;
|
||||
/** 落地过磅重量 */
|
||||
private String landingEntruckWeight;
|
||||
|
||||
/**
|
||||
* 检疫票照片
|
||||
*/
|
||||
private String quarantineTickeyUrl;
|
||||
|
||||
/**
|
||||
* 传纸质磅单(双章)
|
||||
*/
|
||||
private String poundListImg;
|
||||
|
||||
/**
|
||||
* 车辆空磅上磅车头照片
|
||||
*/
|
||||
private String emptyVehicleFrontPhoto;
|
||||
|
||||
/**
|
||||
* 车辆过重磅车头照片
|
||||
*/
|
||||
private String loadedVehicleFrontPhoto;
|
||||
|
||||
/**
|
||||
* 车辆重磅照片
|
||||
*/
|
||||
private String loadedVehicleWeightPhoto;
|
||||
|
||||
/**
|
||||
* 驾驶员手持身份证站车头照片
|
||||
*/
|
||||
private String driverIdCardPhoto;
|
||||
|
||||
/**
|
||||
* 到地纸质磅单(双章)
|
||||
*/
|
||||
private String destinationPoundListImg;
|
||||
|
||||
/**
|
||||
* 到地车辆过重磅车头照片
|
||||
*/
|
||||
private String destinationVehicleFrontPhoto;
|
||||
|
||||
/**
|
||||
* 装车过磅视频
|
||||
*/
|
||||
private String entruckWeightVideo;
|
||||
|
||||
/**
|
||||
* 空车过磅视频
|
||||
*/
|
||||
private String emptyWeightVideo;
|
||||
|
||||
/**
|
||||
* 装牛视频
|
||||
*/
|
||||
private String cattleLoadingVideo;
|
||||
|
||||
/**
|
||||
* 控槽视频
|
||||
*/
|
||||
private String controlSlotVideo;
|
||||
|
||||
/**
|
||||
* 装完牛绕车一圈视频
|
||||
*/
|
||||
private String cattleLoadingCircleVideo;
|
||||
|
||||
/**
|
||||
* 卸牛视频
|
||||
*/
|
||||
private String unloadCattleVideo;
|
||||
|
||||
/**
|
||||
* 到地过磅视频
|
||||
*/
|
||||
private String destinationWeightVideo;
|
||||
}
|
||||
|
||||
|
||||
@@ -318,6 +318,36 @@ public class Delivery implements Serializable {
|
||||
@TableField("driver_id_card_photo")
|
||||
private String driverIdCardPhoto;
|
||||
|
||||
/**
|
||||
* 到地纸质磅单(双章)
|
||||
*/
|
||||
@TableField("destination_pound_list_img")
|
||||
private String destinationPoundListImg;
|
||||
|
||||
/**
|
||||
* 到地车辆过重磅车头照片
|
||||
*/
|
||||
@TableField("destination_vehicle_front_photo")
|
||||
private String destinationVehicleFrontPhoto;
|
||||
|
||||
/**
|
||||
* 装牛视频
|
||||
*/
|
||||
@TableField("cattle_loading_video")
|
||||
private String cattleLoadingVideo;
|
||||
|
||||
/**
|
||||
* 卸牛视频
|
||||
*/
|
||||
@TableField("unload_cattle_video")
|
||||
private String unloadCattleVideo;
|
||||
|
||||
/**
|
||||
* 到地过磅视频
|
||||
*/
|
||||
@TableField("destination_weight_video")
|
||||
private String destinationWeightVideo;
|
||||
|
||||
/**
|
||||
* 主机设备编号
|
||||
*/
|
||||
|
||||
@@ -507,6 +507,11 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
||||
@Transactional
|
||||
@Override
|
||||
public AjaxResult createDelivery(DeliveryCreateDto dto) {
|
||||
// 入参日志
|
||||
System.out.println("[CREATE-DELIVERY] 收到DTO - shipper: " + dto.getShipper() +
|
||||
", buyer: " + dto.getBuyer() +
|
||||
", plateNumber: " + dto.getPlateNumber() +
|
||||
", driverName: " + dto.getDriverName());
|
||||
// 校验时间逻辑
|
||||
if (dto.getEstimatedArrivalTime().before(dto.getEstimatedDepartureTime())) {
|
||||
return AjaxResult.error("预计到达时间必须晚于出发时间");
|
||||
@@ -523,8 +528,42 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
||||
// 创建运送清单
|
||||
Delivery delivery = new Delivery();
|
||||
delivery.setDeliveryNumber(deliveryNumber);
|
||||
delivery.setOrderId(dto.getOrderId());
|
||||
// 基本信息
|
||||
delivery.setLicensePlate(dto.getPlateNumber());
|
||||
delivery.setDriverName(dto.getDriverName());
|
||||
delivery.setDriverMobile(dto.getDriverPhone());
|
||||
// 地址与坐标
|
||||
delivery.setStartLocation(dto.getStartLocation());
|
||||
delivery.setStartLon(dto.getStartLon());
|
||||
delivery.setStartLat(dto.getStartLat());
|
||||
delivery.setEndLocation(dto.getEndLocation());
|
||||
delivery.setEndLon(dto.getEndLon());
|
||||
delivery.setEndLat(dto.getEndLat());
|
||||
// 预计到达
|
||||
delivery.setEstimatedDeliveryTime(dto.getEstimatedArrivalTime());
|
||||
// 过磅重量
|
||||
delivery.setEmptyWeight(dto.getEmptyWeight());
|
||||
delivery.setEntruckWeight(dto.getEntruckWeight());
|
||||
delivery.setLandingEntruckWeight(dto.getLandingEntruckWeight());
|
||||
// 照片
|
||||
delivery.setQuarantineTickeyUrl(dto.getQuarantineTickeyUrl());
|
||||
delivery.setPoundListImg(dto.getPoundListImg());
|
||||
delivery.setEmptyVehicleFrontPhoto(dto.getEmptyVehicleFrontPhoto());
|
||||
delivery.setLoadedVehicleFrontPhoto(dto.getLoadedVehicleFrontPhoto());
|
||||
delivery.setLoadedVehicleWeightPhoto(dto.getLoadedVehicleWeightPhoto());
|
||||
delivery.setDriverIdCardPhoto(dto.getDriverIdCardPhoto());
|
||||
delivery.setDestinationPoundListImg(dto.getDestinationPoundListImg());
|
||||
delivery.setDestinationVehicleFrontPhoto(dto.getDestinationVehicleFrontPhoto());
|
||||
// 视频
|
||||
delivery.setEntruckWeightVideo(dto.getEntruckWeightVideo());
|
||||
delivery.setEmptyWeightVideo(dto.getEmptyWeightVideo());
|
||||
delivery.setEntruckVideo(dto.getCattleLoadingVideo());
|
||||
delivery.setControlSlotVideo(dto.getControlSlotVideo());
|
||||
delivery.setCattleLoadingCircleVideo(dto.getCattleLoadingCircleVideo());
|
||||
delivery.setUnloadCattleVideo(dto.getUnloadCattleVideo());
|
||||
delivery.setDestinationWeightVideo(dto.getDestinationWeightVideo());
|
||||
|
||||
delivery.setStatus(1); // 待装车
|
||||
delivery.setCreatedBy(userId);
|
||||
delivery.setCreateByName(userName);
|
||||
@@ -532,6 +571,10 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
||||
|
||||
// 保存运送清单
|
||||
boolean saved = this.save(delivery);
|
||||
System.out.println("[CREATE-DELIVERY] 入库实体 - deliveryNumber: " + delivery.getDeliveryNumber() +
|
||||
", licensePlate: " + delivery.getLicensePlate() +
|
||||
", driverName: " + delivery.getDriverName() +
|
||||
", status: " + delivery.getStatus());
|
||||
if (!saved) {
|
||||
return AjaxResult.error("创建失败");
|
||||
}
|
||||
@@ -1186,7 +1229,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
|
||||
}
|
||||
|
||||
// 填充装车订单的关联订单信息
|
||||
for适合 (Delivery delivery : resList) {
|
||||
for (Delivery delivery : resList) {
|
||||
if (delivery.getOrderId() != null) {
|
||||
com.aiotagro.cattletrade.business.entity.Order order = orderMapper.selectById(delivery.getOrderId());
|
||||
if (order != null) {
|
||||
|
||||
@@ -54,8 +54,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
Integer pageNum = params.get("pageNum") != null ? (Integer) params.get("pageNum") : 1;
|
||||
Integer pageSize = params.get("pageSize") != null ? (Integer) params.get("pageSize") : 10;
|
||||
Integer settlementType = params.get("settlementType") != null ? (Integer) params.get("settlementType") : null;
|
||||
String buyerName = params.get("buyerName") != null ? (String) params.get("buyerName") : null;
|
||||
String sellerName = params.get("sellerName") != null ? (String) params.get("sellerName") : null;
|
||||
String startTime = params.get("startTime") != null ? (String) params.get("startTime") : null;
|
||||
String endTime = params.get("endTime") != null ? (String) params.get("endTime") : null;
|
||||
|
||||
logger.info("分页查询订单列表,页码:{},每页数量:{}", pageNum, pageSize);
|
||||
logger.info("分页查询订单列表,页码:{},每页数量:{},买方:{},卖方:{},结算方式:{}",
|
||||
pageNum, pageSize, buyerName, sellerName, settlementType);
|
||||
|
||||
// 使用PageHelper进行分页
|
||||
Page<Order> page = PageHelper.startPage(pageNum, pageSize);
|
||||
@@ -63,6 +68,25 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(settlementType != null, Order::getSettlementType, settlementType);
|
||||
|
||||
// 时间范围查询
|
||||
if (startTime != null && !startTime.isEmpty()) {
|
||||
// 如果没有时间部分,添加00:00:00
|
||||
String startTimeStr = startTime;
|
||||
if (startTimeStr.matches("\\d{4}-\\d{2}-\\d{2}")) {
|
||||
startTimeStr = startTimeStr + " 00:00:00";
|
||||
}
|
||||
queryWrapper.ge(Order::getCreateTime, startTimeStr);
|
||||
}
|
||||
if (endTime != null && !endTime.isEmpty()) {
|
||||
// 如果没有时间部分,添加23:59:59
|
||||
String endTimeStr = endTime;
|
||||
if (endTimeStr.matches("\\d{4}-\\d{2}-\\d{2}")) {
|
||||
endTimeStr = endTimeStr + " 23:59:59";
|
||||
}
|
||||
queryWrapper.le(Order::getCreateTime, endTimeStr);
|
||||
}
|
||||
|
||||
queryWrapper.orderByDesc(Order::getCreateTime);
|
||||
|
||||
// 执行查询
|
||||
@@ -71,9 +95,22 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
// 填充关联信息
|
||||
list.forEach(this::fillOrderInfo);
|
||||
|
||||
// 如果提供了买方或卖方名称搜索,进行过滤
|
||||
List<Order> filteredList = list;
|
||||
if (buyerName != null && !buyerName.trim().isEmpty()) {
|
||||
filteredList = filteredList.stream()
|
||||
.filter(order -> order.getBuyerName() != null && order.getBuyerName().contains(buyerName.trim()))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
if (sellerName != null && !sellerName.trim().isEmpty()) {
|
||||
filteredList = filteredList.stream()
|
||||
.filter(order -> order.getSellerName() != null && order.getSellerName().contains(sellerName.trim()))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
// 构建分页结果
|
||||
logger.info("查询到{}条订单记录", list.size());
|
||||
return new PageResultResponse<>(page.getTotal(), list);
|
||||
logger.info("查询到{}条订单记录,过滤后{}条", list.size(), filteredList.size());
|
||||
return new PageResultResponse<>(filteredList.size(), filteredList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,8 +177,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
}
|
||||
|
||||
// 设置更新人和更新时间
|
||||
Integer userId = SecurityUtil.getCurrentUserId();
|
||||
order.setUpdatedBy(userId);
|
||||
try {
|
||||
Integer userId = SecurityUtil.getCurrentUserId();
|
||||
order.setUpdatedBy(userId);
|
||||
} catch (Exception e) {
|
||||
logger.warn("获取当前用户失败,使用订单原有创建人:{}", e.getMessage());
|
||||
// 如果无法获取当前用户,使用原订单的 created_by
|
||||
if (existingOrder.getCreatedBy() != null) {
|
||||
order.setUpdatedBy(existingOrder.getCreatedBy());
|
||||
}
|
||||
}
|
||||
order.setUpdateTime(new Date());
|
||||
|
||||
// 更新数据库
|
||||
|
||||
Reference in New Issue
Block a user