示例#1
0
def prepare(busi_data_type, operation_type, excel_file_name, pdf_file_names, file_number):
    today_dash = datetime.today().strftime('%Y-%m-%d')
    parent_dir, template_path, attachment_path, zip_file, zip_xml_file, utils.CONFIG_PATH_NAME \
        = config(busi_data_type, operation_type)
    utils.set_logging_by_config()

    report = sendReport.EnterpriseSendReport()
    report.busiDataType = busi_data_type
    report.operationType = operation_type
    report.xlsxFileAbsName = os.path.join(parent_dir, template_path + excel_file_name)
    if pdf_file_names is not None and len(pdf_file_names) > 0:
        pdf_file_abs_names = []
        for i in range(len(pdf_file_names)):
            pdf_file_abs_names[i] = os.path.join(parent_dir, template_path + pdf_file_names[i])
        report.pdfFileAbsNames = pdf_file_abs_names
        report.pdfFileNames = pdf_file_names

    service_bl.Excel_2_Json(report)
    service_bl.Save_Data_And_Generate_Zip(report)

    zip_file_name = zip_file.replace('file_number', file_number)
    shutil.copy(os.path.join(parent_dir, '../../../../base-document/' + today_dash + '-zip/' + zip_file_name),
                os.path.join(parent_dir, template_path))

    utils.unzip_file(os.path.join(parent_dir, template_path + zip_file_name),
                     os.path.join(parent_dir, template_path))
示例#2
0
    else:
        logging.error('report type error:{0}'.format(report))

    datas = build_master_agrmt(main_datas, additional_datas, df1[df1['status'] == '0']['element_name'].to_list(),
                               df2[df2['status'] == '0']['element_name'].to_list())
    report.jsonData = datas


def save_data(data):
    url = 'http://{ip}:{port}/sup-agreement/excel/prepare'.format(ip=utils.ip(), port=utils.port())
    params = {
        "params": data
    }
    resp = utils.post(url=url, params=params)


if __name__ == '__main__':
    parent_dir = os.path.dirname(os.path.abspath(__file__))
    config_file = os.path.join(parent_dir, '../client_enterprise/config.yaml')
    utils.CONFIG_PATH_NAME = config_file
    utils.set_logging_by_config()

    report = EnterpriseSendReport()
    report.xlsxFileAbsName = 'D:/test/A1003.xlsx'
    report.isIndividual = True
    parse_excel(report)
    print(json.dumps(report.jsonData))
    # 保存A1003数据
    save_data(report.jsonData)
    pass
示例#3
0
文件: main.ui.py 项目: blshao84/zzbj
def _init_env():
    parent_dir = os.path.dirname(os.path.abspath(__file__))
    config_file = os.path.join(parent_dir, 'config.yaml')
    uts.CONFIG_PATH_NAME = config_file
    uts.set_logging_by_config()
    logging.debug(config_file)