myzero1/export-big-stream

Export big data through data streams

v1.1.2 2023-12-01 06:43 UTC

This package is not auto-updated.

Last update: 2024-11-01 11:02:04 UTC


README

介绍

Export big data through data streams

软件架构

软件架构说明

安装教程

  1. xxxx
  2. xxxx
  3. xxxx

使用说明

  1. 导出csv

    $pdoCnf=[
        'dsn' => 'mysql:host=localhost;dbname=mydbname',
        'username' => '',
        'password' => '',
    ];

    \myzero1\export_big_stream\Z1export::saveCsv(
        $pdoCnf,
        'SELECT * FROM privilege limit 1000000',
        [
            [
                'label' => 'id',
                'attribute' => 'id',
            ],
            [
                'header' => '订单编号',
                'attribute' => 'updated',
            ],
            [
                'header' => '扣点时间',
                'value' => function ($row) {
                    return $row['created']."created";
                },
            ],
            [
                'label' => '扣点时间',
                'value' => function ($row) {
                    return $row['created']."created";
                },
            ],
        ],
        '测试',
        60*1,
        '科学计数法的处理方式'
    );

  1. 导出zip
    导出zip需要先安装 jdwil/zip-stream
    composer require jdwil/zip-stream=0.1.3
    https://packagist.org/packages/jdwil/zip-stream
    https://github.com/jdwil/zip-stream
    https://github.com/myzero1/zip-stream

    \myzero1\export_big_stream\saveZip::saveCsv(
        $pdoCnf,
        'SELECT * FROM privilege limit 1000000',
        [
            [
                'label' => 'id',
                'attribute' => 'id',
            ],
            [
                'header' => '订单编号',
                'attribute' => 'updated',
            ],
            [
                'header' => '扣点时间',
                'value' => function ($row) {
                    return $row['created']."created";
                },
            ],
            [
                'label' => '扣点时间',
                'value' => function ($row) {
                    return $row['created']."created";
                },
            ],
        ],
        '测试',
        60*1,
        '科学计数法的处理方式'
    );

  1. 使用yii2的ActiveDataProvider导出
    需要在yii2框架中使用

    需要先安装 jeremeamia/superclosure
    composer require jeremeamia/superclosure=2.4.0
    https://packagist.org/packages/jeremeamia/superclosure
    https://github.com/jeremeamia/super_closure

    set app/config/main.php
    return [
        ...
        'modules' => [
            ...
            'export_big_stream' => [
                'class' => 'myzero1\export_big_stream\Module',
            ],
            ...
        ],
        ...
    ];

    \myzero1\export_big_stream\helpers\Helper::createExportForm(
        $dataProvider, 
        $columnsFilter, 
        $name = '用户查询2', 
        $buttonOpts = [
            'class' => 'btn btn-info',
        ],
        $url = ['/export_big_stream/default/export', 'id' => 1], 
        $writerType = 'csv', // zip csv
        $buttonLable = '导出3',
        60*5,
        $confirmMsg = "请问你确认导出数据吗?为空或者不设置都不会弹出提示",
        $tips="这里的信息会写在第二行,为空时不显示,不设置这个参数时使用默认信息。"
    );

  1. remoteArrayDataProvider

    需要在yii2框架中使用

    $remoteArrayDataProvider = \myzero1\export_big_stream\helpers\Helper::remoteArrayDataProvider(
        $url, 
        $adjustedParams,
        $timeout=600,
        $itemsKeys=['data','items'],
        $totalKeys=['data','total'],
        $pageSizeKeys=['data','page_size'],
        $dataProviderKey='',
        $extendDataKeys=['data','total_amount']
    );

    $provider=$remoteArrayDataProvider['dataProvider'];

  1. remoteExport

    $adjustedParams['page'] =  1;
    $adjustedParams['page_size'] =  5;
    $columns=[
        [
            'label' => 'id',
            'attribute' => 'id',
        ],
        [
            'header' => 'id1',
            'value' => function ($row) {
                return $row['id']."_id";
            },
        ],
    ];
    \myzero1\export_big_stream\helpers\Helper::remoteExport(
        $url, 
        $adjustedParams,
        $remoteTimeout=60*1,
        $itemsKeys=['data','items'],
        $pageKey='page',
        $pageSizeKey='page_size',
        $columns,
        $exportName='remote-export',
        $maxExecutionTime=60*5,
        $tips='这里的信息会写在第二行,为空时不显示,不设置这个参数时使用默认信息。'
    );

  1. xxxx

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/