保存时验证冠字号为9位
This commit is contained in:
parent
bfd412e726
commit
bc1485663e
|
|
@ -452,6 +452,23 @@ def create_information(
|
|||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""发布资讯"""
|
||||
# 验证并矫正冠字号(J0开头的9位数字)
|
||||
if data.title:
|
||||
import re
|
||||
# 提取冠字号
|
||||
match = re.search(r'J0(\d+)', data.title)
|
||||
if match:
|
||||
num = match.group(1)
|
||||
# 矫正位数
|
||||
if len(num) > 9:
|
||||
# 多位:取前9位
|
||||
num = num[:9]
|
||||
elif len(num) < 9:
|
||||
# 少位:前面补0
|
||||
num = num.zfill(9)
|
||||
# 重新构建title
|
||||
original_num = match.group(0)
|
||||
data.title = data.title.replace(original_num, 'J0' + num, 1)
|
||||
# 生成行情编号:日期 + 5位自然数(从00001开始)
|
||||
deal_no = None
|
||||
if data.info_type == 'deal':
|
||||
|
|
|
|||
Loading…
Reference in New Issue