xyc
2026-08-14 1f4a6cc6045f47861c3e8d49a782afc3e11e3843
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
# -*- coding: utf-8 -*-
import io
 
base = r'C:\Users\jcxiong\Documents\Codex\MyProject\trafficAudit'
 
sql_path = base + r'\docs\init.sql'
with io.open(sql_path, encoding='utf-8') as f:
    sql = f.read()
 
pairs = [
    ("""    -- 规上
    above_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规上周转量',""",
     """    -- 规上
    above_scale_freight DECIMAL(15,2) DEFAULT 0 COMMENT '规上货运量',
    above_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规上周转量',"""),
    ("""    -- 规下
    below_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规下周转量',""",
     """    -- 规下
    below_scale_freight DECIMAL(15,2) DEFAULT 0 COMMENT '规下货运量',
    below_scale_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '规下周转量',"""),
    ("""    -- 合计
    total_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '运输量(规上+规下)',""",
     """    -- 合计
    total_freight DECIMAL(15,2) DEFAULT 0 COMMENT '运输量合计-货运量',
    total_turnover DECIMAL(15,2) DEFAULT 0 COMMENT '运输量合计-周转量',"""),
]
for old, new in pairs:
    assert old in sql, 'anchor missing: ' + old[:40]
    sql = sql.replace(old, new)
with io.open(sql_path, 'w', encoding='utf-8', newline='') as f:
    f.write(sql)
print('init.sql updated')
 
md_path = base + r'\docs\database.md'
with io.open(md_path, encoding='utf-8') as f:
    md = f.read()
pairs_md = [
    ('| above_scale_turnover | decimal(15,2) | 规上周转量 |',
     '| above_scale_freight | decimal(15,2) | 规上货运量 |\n| above_scale_turnover | decimal(15,2) | 规上周转量 |'),
    ('| below_scale_turnover | decimal(15,2) | 规下周转量 |',
     '| below_scale_freight | decimal(15,2) | 规下货运量 |\n| below_scale_turnover | decimal(15,2) | 规下周转量 |'),
    ("| total_turnover | decimal(15,2) | 运输量(规上+规下) |",
     '| total_freight | decimal(15,2) | 运输量合计-货运量 |\n| total_turnover | decimal(15,2) | 运输量合计-周转量 |'),
]
for old, new in pairs_md:
    assert old in md, 'md anchor missing: ' + old[:40]
    md = md.replace(old, new)
with io.open(md_path, 'w', encoding='utf-8', newline='') as f:
    f.write(md)
print('database.md updated')