示例#1
0
def iter_(begin, years=9):
    workdays = set()
    holidays = {}
    for year, anpai, ab in fetch('select * from jqb where year>=?',
                                 [begin[:4]]):
        for a in anpai.splitlines():
            s = Pattern == a
            d = s.groupdict()
            holidays.update(
                zip(parsedate(d.get('fj'), year), cycle([d['name']])))
            sb = d.get('sb')
            if sb:
                workdays.update(parsedate(sb, year))
    year = begin[:4]
    obj = fetchone('select * from jqb where year=?', [begin[:4]])
    if not obj:
        print('起始年份无对应的假期表,请先下载')
        exit(1)
    ab = obj[2]
    if not ab:
        ab = input(f'请输入 {year} 年 1 月 1 日的 AB 户标志:')
        ab = ab.upper()
        if ab not in 'AB':
            print('AB户标志输入不正确!')
            exit(2)

        with connect():
            execute('update jqb set ab=? where year=?', [ab, year])
    data = []
    begin = datetime(f'{year}-1-1')
    for d in begin.iter(begin.add(years=years)):
        memo = holidays.get(d) or WEEKDAY.get(d.isoweekday())
        if not memo:
            flag, sx, memo = '0', '0', ''
        elif memo.startswith('星期') and d in workdays:
            flag, sx, memo = '0', '0', '调休上班'
        else:
            flag, sx = '1', '2'
        ab_ = ab if flag == '1' else "A" if ab == 'B' else "B"
        if d.month == 1 and d.day == 1:
            if fetchone('select ab from jqb where year =?', [d.year]):
                with connect():
                    execute('update jqb set ab=? where year=?', [ab, d.year])
        data.append((d % '%Y%m%d', flag, sx, memo, ab, ab_))
        ab = ab_
    return data
示例#2
0
def show(year):
    year = year or str(now().year)
    sql = 'select * from jqb where year=?'
    obj = fetchone(sql, [year])
    if obj:
        print(f'年份: {obj[0]}')
        if obj[2]:
            print(f'初始AB户标志:{obj[2]}')
        print(obj[1])
示例#3
0
def test_jym(jym):
    '检查交易码是否已被使用'
    row = fetchone(
        'select  jym,jymc,"生产参数" from jym where jym =? '
        'union select jym,jymc,"科技菜单" from jycd where jym =? ', [jym, jym])
    if row:
        print(f'交易码 {jym} 已在 {row[2]} 使用\n交易名称为:{row[1]}')
    else:
        print(f'交易码 {jym} 未被使用')
示例#4
0
def query_jyz(jyz):
    "查询交易组"
    row = fetchone('select * from jyz where jyz=?', [jyz])
    if row:
        print(f'交易组  :{row[0]}\n交易组名:{row[1]}\n')
        for r in fetch(
                'select b.code,b.name from jyzgw a '
                'left join jygw b on a.gw=b.id where a.jyz=?', [jyz]):
            print(*r, sep='\t')
示例#5
0
def show_kemu(sql, arg=None):
    data = fetchone(sql, arg)
    if data:
        print('%s\t%s\n%s' % (data))
        return True
示例#6
0
def query_jym(jym):
    "查询单个交易码"
    row = fetchone(f'{QUERYJYM} where a.jym=?', [jym])
    if row:
        data = zip([x['header'] for x in HEASER], convert_row(row))
        tprint(data, format_spec={0: '20'})
示例#7
0
def get_param_ver(name):
    return fetchone('select period,time from param_period where name =?',
                    [name])