Commit e59ca656 by 杨昕

test

parent 7eb5e36c
Pipeline #18777 passed with stages
in 1 minute 12 seconds
......@@ -375,7 +375,7 @@ class MediaController extends Controller
'end_time.date' => '结束时间格式错误',
'end_time.after_or_equal' => '结束时间不能小于开始时间'
]);
return MediaModel::runScreenShotMediaList($request);
return MediaModel::runScreenShotMedia($request);
});
return success($data);
}
......
......@@ -1138,85 +1138,35 @@ class MediaModel extends Eloquent
* @return mixed
* @throws DatabaseException
*/
public static function runScreenShotMediaList($request)
public static function runScreenShotMedia($request)
{
try {
$medias = MediaModel::query()->raw(function ($collection) use ($request) {
$limit = (isset($request->page_size) ? (int)($request->page_size) : Constant::PAGE_NUMBER);
if ($limit > self::$max_page_size) {
$limit = self::$max_page_size;
}
$page = $request->page ?? 1;
$aggregate = [];
$match = [
'status' => "1",
"screen_shot" => null
];
if (isset($request->media_id) && !empty($request->media_id)) {
$match['_id'] = $request->media_id;
}
if (isset($request->start_time) && !empty($request->start_time)) {
$start_time = new UTCDateTime(strtotime($request->start_time) * 1000);
$match['start_time'] = ['$gt' => $start_time];
}
if (isset($request->end_time) && !empty($request->end_time)) {
$end_time = new UTCDateTime(strtotime($request->end_time) * 1000);;
$match['end_time'] = ['$lt' => $end_time];
}
$aggregate[]['$match'] = $match;
$count = MediaModel::where($match)->count();
$skip = ((empty($request->page) ? 1 : $request->page) - 1) * $limit;
$aggregate[]['$skip'] = $skip;
$aggregate[]['$limit'] = $limit;
$tmp_arr = $collection->aggregate($aggregate)->toArray();
$tmp_arr = collect($tmp_arr);
$match = [
'status' => "1",
"screen_shot" => null
];
/**
* 将mongoDate 转化为普通时间
*/
foreach ($tmp_arr as $media) {
$tz = new \DateTimeZone("Asia/Shanghai");
if (is_object($media['start_time'])) {
$start_time = $media['start_time']->toDateTime();
$start_time->setTimezone($tz);
$start_time = $start_time->format("Y-m-d H:i:s");
$media['start_time'] = $start_time;
}
if (isset($request->media_id) && !empty($request->media_id)) {
$match['_id'] = $request->media_id;
}
if (is_object($media['end_time'])) {
$end_time = $media['end_time']->toDateTime();
$end_time->setTimezone($tz);
$media['end_time'] = $end_time->format('Y-m-d H:i:s');
}
if (is_object($media['create_time'])) {
$create_time = $media['create_time']->toDateTime();
$create_time->setTimezone($tz);
$media['create_time'] = $create_time->format('Y-m-d H:i:s');
}
//处理封面图片以及分辨率
self::getScreeShotInfo($media["_id"]);
sleep(1);
}
if (isset($request->start_time) && !empty($request->start_time)) {
$start_time = new UTCDateTime(strtotime($request->start_time) * 1000);
$match['start_time'] = ['$gt' => $start_time];
}
return new LengthAwarePaginator($tmp_arr, $count, $limit, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
if (isset($request->end_time) && !empty($request->end_time)) {
$end_time = new UTCDateTime(strtotime($request->end_time) * 1000);;
$match['end_time'] = ['$lt' => $end_time];
}
});
$media = MediaModel::where($match)->first();
self::getScreeShotInfo($media["_id"]);
sleep(10);
} catch (\Exception $exception) {
throw new DatabaseException($exception->getMessage());
}
return $medias;
return $media;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment