去掉事务
This commit is contained in:
parent
f04e013498
commit
a6cc1c50dc
@ -71,32 +71,30 @@ class FlowPoolMonthSync extends Command
|
|||||||
$array = array_merge($array, $items);
|
$array = array_merge($array, $items);
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::transaction(function () use ($array) {
|
$this->line('插入数据,条数 #:' . count($array));
|
||||||
$this->line('插入数据,条数 #:' . count($array));
|
|
||||||
|
|
||||||
foreach (array_groupBy($array, 'month') as $month => $group) {
|
foreach (array_groupBy($array, 'month') as $month => $group) {
|
||||||
$news = [];
|
$news = [];
|
||||||
|
|
||||||
$group = array_groupBy($group, 'sim');
|
$group = array_groupBy($group, 'sim');
|
||||||
|
|
||||||
foreach ($group as $sim => $item) {
|
foreach ($group as $sim => $item) {
|
||||||
if (count($item) > 1) {
|
if (count($item) > 1) {
|
||||||
$temp = $item[0];
|
$temp = $item[0];
|
||||||
$temp['mebibyte'] = array_sum(array_pluck($item, 'mebibyte'));
|
$temp['mebibyte'] = array_sum(array_pluck($item, 'mebibyte'));
|
||||||
$group[$sim] = [$temp];
|
$group[$sim] = [$temp];
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$news = array_merge($news, array_collapse($group));
|
|
||||||
|
|
||||||
$table = FlowPoolService::checkTable($month);
|
|
||||||
|
|
||||||
foreach (array_chunk($news, 1000) as $values) {
|
|
||||||
echo '.';
|
|
||||||
app(FlowPoolMonth::class)->setTable($table)->upsert($values, ['sim', 'month']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
$news = array_merge($news, array_collapse($group));
|
||||||
|
|
||||||
|
$table = FlowPoolService::checkTable($month);
|
||||||
|
|
||||||
|
foreach (array_chunk($news, 1000) as $values) {
|
||||||
|
echo '.';
|
||||||
|
app(FlowPoolMonth::class)->setTable($table)->upsert($values, ['sim', 'month']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->line($this->description . ' End');
|
$this->line($this->description . ' End');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user