check_erp_push.py
3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- coding: utf-8 -*-
import pymssql
# 数据库连接
conn = pymssql.connect(
server='192.168.1.91,1433',
database='wms4_global',
user='sa',
password='HHrobot123.'
)
cursor = conn.cursor()
print("=" * 80)
print("一、查询入库单(receipt_header)问题单据")
print("=" * 80)
# 入库单问题单据:头尾状态不是"回传",且已完成出入库但未推送ERP
# 需要排除:调拨入库(type='transfer')、倒扣料入库(type='deduction')
# 状态值需要确认:先看数据字典
print("\n【1. 查看入库单类型分布】")
cursor.execute("""
SELECT type, COUNT(*) as cnt
FROM receipt_header
GROUP BY type
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
print("\n【2. 查看入库单头状态分布】")
cursor.execute("""
SELECT first_status, COUNT(*) as cnt
FROM receipt_header
GROUP BY first_status
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
print("\n【3. 查看入库单尾状态分布】")
cursor.execute("""
SELECT last_status, COUNT(*) as cnt
FROM receipt_header
GROUP BY last_status
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
# 查看组盘头表
print("\n【4. 查看组盘相关表】")
cursor.execute("""
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE '%group%' OR TABLE_NAME LIKE '%container%'
""")
for row in cursor.fetchall():
print(f" {row[0]}")
print("\n【5. 查看入库单关联组盘情况】")
cursor.execute("""
SELECT COUNT(*)
FROM receipt_header rh
INNER JOIN receipt_container_header rch ON rh.id = rch.receipt_id
""")
print(f" 入库单关联组盘数量: {cursor.fetchone()[0]}")
print("\n" + "=" * 80)
print("二、查询出库单(shipment_header)问题单据")
print("=" * 80)
print("\n【1. 查看出库单类型分布】")
cursor.execute("""
SELECT type, COUNT(*) as cnt
FROM shipment_header
GROUP BY type
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
print("\n【2. 查看出库单头状态分布】")
cursor.execute("""
SELECT first_status, COUNT(*) as cnt
FROM shipment_header
GROUP BY first_status
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
print("\n【3. 查看出库单尾状态分布】")
cursor.execute("""
SELECT last_status, COUNT(*) as cnt
FROM shipment_header
GROUP BY last_status
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
# 重点:查询组盘头表
print("\n【6. 查看组盘头表结构】")
cursor.execute("""
SELECT COLUMN_NAME, DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'receipt_container_header'
""")
print(" receipt_container_header 表字段:")
for row in cursor.fetchall():
print(f" {row[0]} ({row[1]})")
print("\n【7. 查看组盘头表状态分布】")
cursor.execute("""
SELECT status, COUNT(*) as cnt
FROM receipt_container_header
GROUP BY status
ORDER BY cnt DESC
""")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}条")
conn.close()
print("\n查询完成!")