数据集成平台的数据处理解决方案

  • 轻易云集成顾问-曹天民

轻易云数据集成平台数据加工厂实现方案

以下代码展示了如何在轻易云数据集成平台中实现一个高效的数据加工处理逻辑。该加工厂代码需要添加到方案的AfterTargetGenerate事件中,用于处理退款单据与源单据的关联关系。

<?php
use Domain\Datahub\Instance\Storage\LogStorage;
use Domain\Datahub\Instance\Storage\DataStorage;

class AfterTargetGenerate
{
    protected $params = [];
    protected $adapter;
    protected $ids = [];

    public function __construct(&$params, $ids)
    {
        $this->params = &$params;
        $this->ids = $ids;
    }

    public function run()
    {
        // 检查参数中是否存在Model数据
        if(!isset($this->params[1]['Model'])){
            return;
        }

        // 遍历处理每个Model数据
        foreach ($this->params[1]['Model'] as &$value) {
            if(!isset($value['FRefundBillSrcEntity'])){
                continue;
            }

            // 处理退款单据与源单据的关联关系
            foreach ($value['FRefundBillSrcEntity'] as &$details) {
                if(!isset($details['FRefundBillSrcEntity_Link'])){
                    return;
                }

                // 解析源单据ID
                $glbyj = $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'];
                $str = explode(':',$glbyj,-1);

                if($str==[]){
                    unset($details['FRefundBillSrcEntity_Link']);
                    continue;
                }

                // 通过轻易云数据存储服务查询源单据信息
                $where = ['content.FBillNo' => ['$eq' =>$str[0]]];
                $dataStorage = new DataStorage('891db136-0a45-3b88-8495-3d93ebe5989d','7ea1534f-4416-3092-ae1b-58b63cb41b81');
                $query = $dataStorage->find($where);

                // 更新关联关系
                if($query){
                    $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'] = $query[0]['content']['FID'];
                    $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSId'] = $query[0]['content']['FEntity_FEntryID'];
                }else{
                    $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'] = '';
                    $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSId'] = '';
                }

                // 清理无效的关联关系
                if($details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'] == '' || 
                   $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'] === null || 
                   $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSId'] == '' || 
                   $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSId'] === null)
                {
                    unset($details['FRefundBillSrcEntity_Link']);
                }
            }
        }
    }
}

该代码展示了轻易云数据集成平台的强大数据处理能力:

  1. 通过DataStorage服务实现高效数据查询
  2. 支持复杂的数据关联关系处理
  3. 提供完善的数据校验和清理机制
  4. 采用面向对象的设计模式,便于维护和扩展

轻易云数据集成平台的这种加工厂模式,可以显著提升企业数据处理效率,降低开发成本,是数字化转型的理想选择。

更多系统对接方案