# 共执行了922天:因为缺了 20171010 的文件; 2016-10-19 有多的两个补数文件
        # 1、20190110 191    2019-1-9    2018-7-3
        # 3、20180703 265    2018-7-2    2017-10-11
        # 2、20171010 466    2017-10-9   2016-7-1

        # 其他文件没有多 delta 1天
        # 1、20190110 191    2019-1-10    2018-7-4 但实际看见的文件是到 2018-7-3 日
        # 再给保理7、8号两个流水增加1天文件2018-7-2,运行   7 20180703 1
        # 上面都是 205个文件
        # 再风险 4、6、9,  运行 4 20180702 190
        # 再流水 3、5、7,8  运行 3 20180702 190

        date2 = start_date - datetime.timedelta(days=delta)
        day_str2 = date2.strftime("%Y%m%d")

        the_conf.find_row(date2.strftime("%Y-%m-%d"))
        run_remove_files(the_conf)

        run_remove_hive(the_conf)

        run_sftp_file(the_conf)

        g_zip_path = the_conf.get_zip_path()
        if len(g_zip_path) > 0:
            run_unzip_file(the_conf)

        run_conv_file_local_to_hdfs(the_conf)
        run_hive(the_conf)

        run_remove_files(the_conf)
Exemplo n.º 2
0
    if m_project_id == 1:
        return_info = subprocess.run("/app/code/posflow_loader/ftpcmd.sh", shell=True)
        print(return_info.returncode)

    f_delta = the_conf.get_file_date_delta()
    # start_date_str = StrTool.get_the_date_str(start_date_str, - int(f_delta))

    del_range = 30  # 删除旧数据的时间范围,天
    keep_range = 7  # 保留最近旧数据的时间范围,天

    for i in range(0, del_range):
        delta = m_days + keep_range + del_range - 1 - i
        date2 = start_date - datetime.timedelta(days=delta)
        m_day_str3 = date2.strftime("%Y-%m-%d")
        the_conf.find_row(m_day_str3)
        run_remove_files(the_conf)

    for i in range(0, m_days):
        delta = m_days - i - 1
        date2 = start_date - datetime.timedelta(days=delta)
        date3 = start_date - datetime.timedelta(days=(delta + keep_range))

        the_conf.find_row(date3.strftime("%Y-%m-%d"))
        run_remove_files(the_conf)

        the_conf.find_row(date2.strftime("%Y-%m-%d"))
        run_remove_files(the_conf)

        run_remove_hive(the_conf)