Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
黄南光
/
auto-restock
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a21ddca9
authored
Nov 06, 2026
by
黄南光
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改react形式
1 parent
f7c609a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
9 deletions
edge/dev/mock_dms.py
edge/edgeclient/actions.py
edge/tests/test_edge.py
edge/dev/mock_dms.py
View file @
a21ddca
...
@@ -24,7 +24,8 @@
...
@@ -24,7 +24,8 @@
"po_max_page":5(采购单列表每页最多返回 5 条;0 = 不限),
"po_max_page":5(采购单列表每页最多返回 5 条;0 = 不限),
"po_no_total":true(采购单列表不返回 total), "po_ignore_page":true(忽略页码,总是第 1 页),
"po_no_total":true(采购单列表不返回 total), "po_ignore_page":true(忽略页码,总是第 1 页),
"bulk_parts":60(造 60 个无上限配件 BULK0001…,测明细翻页),
"bulk_parts":60(造 60 个无上限配件 BULK0001…,测明细翻页),
"fail_submit":true(提交接口报错), "submit_check_fail":true(检查返回重复订货、不允许提交),
"fail_submit":true(提交接口报错), "submit_check_fail":true(检查返回停用件、不允许提交),
"submit_check_repeat":true(检查返回 repeatDetails 重复订货,但仍允许提交),
"submit_drop":true(提交已生效但响应 502,模拟断网),
"submit_drop":true(提交已生效但响应 502,模拟断网),
"create_drop":true(建单已生效但响应 502 网关错误页),
"create_drop":true(建单已生效但响应 502 网关错误页),
"po_page_fail":2(接下来 2 次采购单列表查询返回 502),
"po_page_fail":2(接下来 2 次采购单列表查询返回 502),
...
@@ -205,7 +206,7 @@ def reset():
...
@@ -205,7 +206,7 @@ def reset():
S
.
update
({
"stock"
:
_stock_rows
(),
"orders"
:
orders
,
"details"
:
{
o
[
"id"
]:
_details
(
o
)
for
o
in
orders
},
S
.
update
({
"stock"
:
_stock_rows
(),
"orders"
:
orders
,
"details"
:
{
o
[
"id"
]:
_details
(
o
)
for
o
in
orders
},
"po_max_page"
:
None
,
"valid"
:
set
(),
"codes"
:
set
(),
"po_max_page"
:
None
,
"valid"
:
set
(),
"codes"
:
set
(),
"sso"
:
set
(),
"fail_create"
:
False
,
"hide_warehouse"
:
False
,
"sso_off"
:
False
,
"captcha"
:
False
,
"overlay"
:
""
,
"sso"
:
set
(),
"fail_create"
:
False
,
"hide_warehouse"
:
False
,
"sso_off"
:
False
,
"captcha"
:
False
,
"overlay"
:
""
,
"fail_submit"
:
False
,
"submit_check_fail"
:
False
,
"submit_drop"
:
False
,
"create_drop"
:
False
,
"fail_submit"
:
False
,
"submit_check_fail"
:
False
,
"submit_
check_repeat"
:
False
,
"submit_
drop"
:
False
,
"create_drop"
:
False
,
"po_page_fail"
:
0
,
"po_page_fail"
:
0
,
"auth_base"
:
None
,
"bulk_masters"
:
{},
"auth_base"
:
None
,
"bulk_masters"
:
{},
"po_no_total"
:
False
,
"po_ignore_page"
:
False
,
"po_filter"
:
False
,
"po_filter_error"
:
False
,
"po_no_total"
:
False
,
"po_ignore_page"
:
False
,
"po_filter"
:
False
,
"po_filter_error"
:
False
,
...
@@ -256,7 +257,7 @@ async def mock_set(request: Request):
...
@@ -256,7 +257,7 @@ async def mock_set(request: Request):
if
d
.
get
(
"expire_tokens"
):
if
d
.
get
(
"expire_tokens"
):
S
[
"valid"
]
.
clear
()
S
[
"valid"
]
.
clear
()
for
k
in
(
"fail_create"
,
"hide_warehouse"
,
"sso_off"
,
"po_no_total"
,
"po_ignore_page"
,
"captcha"
,
"po_filter"
,
for
k
in
(
"fail_create"
,
"hide_warehouse"
,
"sso_off"
,
"po_no_total"
,
"po_ignore_page"
,
"captcha"
,
"po_filter"
,
"po_filter_error"
,
"fail_submit"
,
"submit_check_fail"
,
"submit_drop"
,
"create_drop"
):
"po_filter_error"
,
"fail_submit"
,
"submit_check_fail"
,
"submit_
check_repeat"
,
"submit_
drop"
,
"create_drop"
):
if
k
in
d
:
if
k
in
d
:
S
[
k
]
=
bool
(
d
[
k
])
S
[
k
]
=
bool
(
d
[
k
])
if
"po_page_fail"
in
d
:
if
"po_page_fail"
in
d
:
...
@@ -564,12 +565,13 @@ async def po_check(oid: str, request: Request):
...
@@ -564,12 +565,13 @@ async def po_check(oid: str, request: Request):
o
=
_order
(
oid
)
o
=
_order
(
oid
)
if
not
o
:
if
not
o
:
return
_err
(
50000003
,
"单据不存在"
)
return
_err
(
50000003
,
"单据不存在"
)
rep
=
[{
"partNo"
:
d
[
"partNo"
],
"orderNo"
:
"S20261101001"
}
for
d
in
S
[
"details"
]
.
get
(
o
[
"id"
],
[])[:
1
]]
\
first
=
[{
"partNo"
:
d
[
"partNo"
],
"orderNo"
:
"S20261101001"
}
for
d
in
S
[
"details"
]
.
get
(
o
[
"id"
],
[])[:
1
]]
if
S
[
"submit_check_fail"
]
else
[]
bad
=
first
if
S
[
"submit_check_fail"
]
else
[]
# 模拟停用件:不允许提交
return
_ok
({
"accountBalanceFlag"
:
True
,
"inactiveDetails"
:
[],
"inactiveNum"
:
0
,
"limitNum"
:
0
,
rep
=
first
if
S
[
"submit_check_repeat"
]
else
[]
# 模拟别人的单里订过同零件:仍允许提交(见 actions.CHECK_LISTS 备注)
return
_ok
({
"accountBalanceFlag"
:
True
,
"inactiveDetails"
:
bad
,
"inactiveNum"
:
len
(
bad
),
"limitNum"
:
0
,
"limitedDetails"
:
[],
"noAuthPartNoList"
:
None
,
"orderSource"
:
o
[
"orderSource"
],
"packageFlag"
:
False
,
"limitedDetails"
:
[],
"noAuthPartNoList"
:
None
,
"orderSource"
:
o
[
"orderSource"
],
"packageFlag"
:
False
,
"pakckageList"
:
None
,
"repeatDetails"
:
rep
,
"repeatNum"
:
len
(
rep
),
"replaceDetails"
:
[],
"pakckageList"
:
None
,
"repeatDetails"
:
rep
,
"repeatNum"
:
len
(
rep
),
"replaceDetails"
:
[],
"submitFlag"
:
not
rep
,
"version"
:
o
[
"version"
]})
"submitFlag"
:
not
bad
,
"version"
:
o
[
"version"
]})
@app.post
(
P
+
"/bff/parts-po/submit-parts-po/{oid}"
)
@app.post
(
P
+
"/bff/parts-po/submit-parts-po/{oid}"
)
...
...
edge/edgeclient/actions.py
View file @
a21ddca
...
@@ -1054,8 +1054,16 @@ def po_status(cfg, sess, order_id, order_no, since, supplier_code=None, steps=No
...
@@ -1054,8 +1054,16 @@ def po_status(cfg, sess, order_id, order_no, since, supplier_code=None, steps=No
# check-parts-po 只抓到过「完全干净」的成功样本:submitFlag=true、accountBalanceFlag=true、各 *Details 为 []、
# check-parts-po 只抓到过「完全干净」的成功样本:submitFlag=true、accountBalanceFlag=true、各 *Details 为 []、
# *Num 为 0、noAuthPartNoList=null、packageFlag=false。失败时这些字段的含义只能按字段名推断(标「疑似」),
# *Num 为 0、noAuthPartNoList=null、packageFlag=false。失败时这些字段的含义只能按字段名推断(标「疑似」),
# 所以只要和干净样本有任何不同就不提交,原字段名 + 原始内容照搬给人看。
# 所以只要和干净样本有任何不同就不提交,原字段名 + 原始内容照搬给人看。
#
# 【2026-11-06 去掉「疑似重复订货」检查(repeatDetails / repeatNum)】
# 原因:repeatDetails 命中的是 DMS 里「别人」建的单(如 S20261106007,未提交的草稿,同零件同数量),
# 不是我们自己重复建的单;这种重复不属于我们的问题,却会把正常提交一直挡住(报 repeatDetails(疑似重复订货))。
# 所以 check_problems 不再看这两个字段:repeatDetails 非空也照常提交。其余检查项(submitFlag / 余额 / 停用 / 限购 /
# 替代件 / 无权限 / 包装数)保持不变。若以后要恢复,把下面这一行加回 CHECK_LISTS 即可:
# ("repeatDetails", "repeatNum", "疑似重复订货"),
# 注意:提交前核对 _verify_for_submit 仍会确认 DMS 里这张单的明细和云端建单时完全一致,不受影响。
CHECK_LISTS
=
((
"inactiveDetails"
,
"inactiveNum"
,
"疑似停用件"
),
(
"limitedDetails"
,
"limitNum"
,
"疑似限购"
),
CHECK_LISTS
=
((
"inactiveDetails"
,
"inactiveNum"
,
"疑似停用件"
),
(
"limitedDetails"
,
"limitNum"
,
"疑似限购"
),
(
"rep
eatDetails"
,
"repeatNum"
,
"疑似重复订货"
),
(
"rep
laceDetails"
,
None
,
"疑似有替代件"
),
(
"replaceDetails"
,
None
,
"疑似有替代件"
),
(
"noAuthPartNoList"
,
None
,
"疑似无订货权限"
),
(
"pakckageList"
,
None
,
"疑似包装数问题"
))
(
"noAuthPartNoList"
,
None
,
"疑似无订货权限"
),
(
"pakckageList"
,
None
,
"疑似包装数问题"
))
...
...
edge/tests/test_edge.py
View file @
a21ddca
...
@@ -461,10 +461,18 @@ class EdgeTests(unittest.TestCase):
...
@@ -461,10 +461,18 @@ class EdgeTests(unittest.TestCase):
with
self
.
assertRaises
(
actions
.
ActionError
)
as
cm
:
with
self
.
assertRaises
(
actions
.
ActionError
)
as
cm
:
actions
.
submit_po
(
c
,
DmsSession
(
c
),
r
[
"order_id"
],
r
[
"order_no"
],
exp
,
"single"
)
actions
.
submit_po
(
c
,
DmsSession
(
c
),
r
[
"order_id"
],
r
[
"order_no"
],
exp
,
"single"
)
self
.
assertEqual
(
cm
.
exception
.
code
,
"check_failed"
)
self
.
assertEqual
(
cm
.
exception
.
code
,
"check_failed"
)
self
.
assertIn
(
"
repeatDetails(疑似重复订货
)"
,
str
(
cm
.
exception
))
self
.
assertIn
(
"
inactiveDetails(疑似停用件
)"
,
str
(
cm
.
exception
))
self
.
assertIn
(
"submitFlag=false"
,
str
(
cm
.
exception
))
self
.
assertIn
(
"submitFlag=false"
,
str
(
cm
.
exception
))
self
.
assertEqual
(
mock_state
()[
"count"
][
"submit"
],
0
)
self
.
assertEqual
(
mock_state
()[
"count"
][
"submit"
],
0
)
def
test_check_repeat_details_not_blocking
(
self
):
"""repeatDetails 命中的是别人的单(如 S20261106007),不再拦截提交(见 actions.CHECK_LISTS 备注)。"""
c
=
self
.
cfg
()
r
,
exp
=
self
.
_created
(
c
)
mock
(
submit_check_repeat
=
True
)
actions
.
submit_po
(
c
,
DmsSession
(
c
),
r
[
"order_id"
],
r
[
"order_no"
],
exp
,
"single"
)
self
.
assertEqual
(
mock_state
()[
"count"
][
"submit"
],
1
)
def
test_check_problems_clean_sample
(
self
):
def
test_check_problems_clean_sample
(
self
):
clean
=
{
"accountBalanceFlag"
:
True
,
"inactiveDetails"
:
[],
"inactiveNum"
:
0
,
"limitNum"
:
0
,
clean
=
{
"accountBalanceFlag"
:
True
,
"inactiveDetails"
:
[],
"inactiveNum"
:
0
,
"limitNum"
:
0
,
"limitedDetails"
:
[],
"noAuthPartNoList"
:
None
,
"orderSource"
:
"1"
,
"packageFlag"
:
False
,
"limitedDetails"
:
[],
"noAuthPartNoList"
:
None
,
"orderSource"
:
"1"
,
"packageFlag"
:
False
,
...
@@ -475,6 +483,8 @@ class EdgeTests(unittest.TestCase):
...
@@ -475,6 +483,8 @@ class EdgeTests(unittest.TestCase):
actions
.
check_problems
(
dict
(
clean
,
accountBalanceFlag
=
False
))[
0
])
actions
.
check_problems
(
dict
(
clean
,
accountBalanceFlag
=
False
))[
0
])
self
.
assertTrue
(
actions
.
check_problems
(
dict
(
clean
,
noAuthPartNoList
=
[
"019990A115"
])))
self
.
assertTrue
(
actions
.
check_problems
(
dict
(
clean
,
noAuthPartNoList
=
[
"019990A115"
])))
self
.
assertTrue
(
actions
.
check_problems
(
dict
(
clean
,
inactiveNum
=
1
)))
self
.
assertTrue
(
actions
.
check_problems
(
dict
(
clean
,
inactiveNum
=
1
)))
self
.
assertEqual
(
actions
.
check_problems
(
dict
(
clean
,
repeatDetails
=
[{
"applyedOrderNumber"
:
"S20261106007"
}],
repeatNum
=
1
)),
[])
# 重复订货不拦截
def
test_submit_verify_mismatch_refuses
(
self
):
def
test_submit_verify_mismatch_refuses
(
self
):
c
=
self
.
cfg
()
c
=
self
.
cfg
()
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment