我已经帮你写好了这个加工厂,将该加工厂代码新增到方案的事件 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()
{
// $log = new LogStorage('891db136-0a45-3b88-8495-3d93ebe5989d','5dfd64b5-cc20-357f-b1f5-80ad0967dbbf');
// $log->insertOne(['text'=> '测试19', 'params'=> $this->params]);
if(!isset($this->params[1]['Model'])){
return;
}
foreach ($this->params[1]['Model'] as &$value) {
if(!isset($value['FRefundBillSrcEntity'])){
continue;
}
foreach ($value['FRefundBillSrcEntity'] as &$details) {
if(!isset($details['FRefundBillSrcEntity_Link'])){
return;
}
$glbyj = $details['FRefundBillSrcEntity_Link'][0]['FRefundBillSrcEntity_Link_FSBillId'];
$str = explode(':',$glbyj,-1);
if($str==[]){
unset($details['FRefundBillSrcEntity_Link']);
continue;
}
// $log->insertOne(['text'=> '测试37', 'params'=> $str]);
$where = ['content.FBillNo' => ['$eq' =>$str[0]]];
$dataStorage = new DataStorage('891db136-0a45-3b88-8495-3d93ebe5989d','7ea1534f-4416-3092-ae1b-58b63cb41b81');
$query = $dataStorage->find($where);
// $log->insertOne(['text'=> '测试40', 'params'=> $query]);
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']);
}
}
}
}
}