微信公众号内容生成调整
This commit is contained in:
@@ -158,6 +158,56 @@ LUA;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 多问题按条件拆分成两个队列新增日志记录
|
||||||
|
public function recordQuestionProcessingStart($key, $totalQuestions)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$redis = $this->connect();
|
||||||
|
$redis->hMSet($key, [
|
||||||
|
'status' => 'processing',
|
||||||
|
'total' => $totalQuestions,
|
||||||
|
'completed' => 0,
|
||||||
|
'start_time' => time(),
|
||||||
|
'queue_1_completed' => 0,
|
||||||
|
'queue_2_completed' => 0
|
||||||
|
]);
|
||||||
|
$redis->expire($key, 10800); // 6小时过期
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 多问题按条件拆分成两个队列更新日志记录
|
||||||
|
public function updateQuestionProcessingProgress($key, $sKeyName)
|
||||||
|
{
|
||||||
|
$redis = $this->connect();
|
||||||
|
// 获取总数
|
||||||
|
$total = $redis->hGet($key, 'total');
|
||||||
|
if (!$total) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(!empty($sKeyName)){
|
||||||
|
$redis->hIncrBy($key, $sKeyName, 1);
|
||||||
|
}
|
||||||
|
//获取每个队列完成数量
|
||||||
|
$queue_1_completed = $redis->hGet($key, 'queue_1_completed');
|
||||||
|
$queue_2_completed = $redis->hGet($key, 'queue_2_completed');
|
||||||
|
$completed = $queue_1_completed + $queue_2_completed;
|
||||||
|
if($completed > $total){
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
// 计算进度
|
||||||
|
$iProgress = round(($completed / $total) * 100, 2);
|
||||||
|
// 事务更新多个字段
|
||||||
|
$redis->hSet($key, 'completed', $completed);
|
||||||
|
$redis->hSet($key, 'progress', $iProgress);
|
||||||
|
if ($iProgress >= 100) {
|
||||||
|
$redis->hSet($key, 'status', 'completed');
|
||||||
|
$redis->hSet($key, 'end_time', time());
|
||||||
|
}
|
||||||
|
return $iProgress;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 更新处理进度
|
// 更新处理进度
|
||||||
public function updateProcessingProgress($key, $completed)
|
public function updateProcessingProgress($key, $completed)
|
||||||
@@ -166,7 +216,7 @@ LUA;
|
|||||||
// 获取总数
|
// 获取总数
|
||||||
$total = $redis->hGet($key, 'total');
|
$total = $redis->hGet($key, 'total');
|
||||||
if (!$total) {
|
if (!$total) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算进度
|
// 计算进度
|
||||||
|
|||||||
Reference in New Issue
Block a user