|
|
@@ -1611,15 +1611,16 @@ class DeepSeekService
|
|
|
logDB('deepseek', 'info', '解析内容', $script_arr);
|
|
|
|
|
|
if (!$script_arr['episodes']) {
|
|
|
- yield [
|
|
|
- 'type' => 'error',
|
|
|
- 'script' => $script_arr,
|
|
|
- 'msg' => '未生成剧本相关信息',
|
|
|
- 'answer' => $fullContent,
|
|
|
- 'reasoning' => $fullReasoningContent,
|
|
|
- 'usage' => $usage
|
|
|
- ];
|
|
|
- return ;
|
|
|
+ Utils::throwError('20003:未生成剧本相关信息');
|
|
|
+ // yield [
|
|
|
+ // 'type' => 'done',
|
|
|
+ // 'script' => $script_arr,
|
|
|
+ // 'msg' => '未生成剧本相关信息',
|
|
|
+ // 'answer' => $fullContent,
|
|
|
+ // 'reasoning' => $fullReasoningContent,
|
|
|
+ // 'usage' => $usage
|
|
|
+ // ];
|
|
|
+ // return ;
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
@@ -1702,6 +1703,7 @@ class DeepSeekService
|
|
|
// 检查是否存在重叠的剧集序号范围
|
|
|
$exists_groups = DB::table('mp_script_episode_group')
|
|
|
->where('script_id', $script_id)
|
|
|
+ ->where('group_id', '<>', $group_id)
|
|
|
->where('is_deleted', 0)
|
|
|
->where(function($query) use ($start_episode_sequence, $end_episode_sequence) {
|
|
|
// 检查新范围是否与现有范围重叠
|
|
|
@@ -1881,16 +1883,16 @@ class DeepSeekService
|
|
|
|
|
|
logDB('deepseek', 'info', '解析内容', $script_arr);
|
|
|
|
|
|
- if (!$script_arr['episodes']) {
|
|
|
- yield [
|
|
|
- 'type' => 'error',
|
|
|
- 'script' => $script_arr,
|
|
|
- 'msg' => '未生成剧本相关信息',
|
|
|
- 'answer' => $fullContent,
|
|
|
- 'reasoning' => $fullReasoningContent,
|
|
|
- 'usage' => $usage
|
|
|
- ];
|
|
|
- return;
|
|
|
+ if (!$script_arr['roles']) {
|
|
|
+ Utils::throwError('20003:未生成剧本相关信息');
|
|
|
+ // yield [
|
|
|
+ // 'type' => 'done',
|
|
|
+ // 'script' => $script_arr,
|
|
|
+ // 'msg' => '未生成剧本相关信息',
|
|
|
+ // 'answer' => $fullContent,
|
|
|
+ // 'reasoning' => $fullReasoningContent,
|
|
|
+ // 'usage' => $usage
|
|
|
+ // ];
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
@@ -2194,30 +2196,26 @@ class DeepSeekService
|
|
|
$group_id = getProp($data, 'group_id');
|
|
|
|
|
|
$script = DB::table('mp_scripts')->where('id', $script_id)->where('is_deleted', 0)
|
|
|
- ->selectRaw('id as script_id, script_name, intro, highlights, roles, role_relationship, core_contradiction, art_style, scenes, status, start_episode_sequence, end_episode_sequence, episode_num, remark, created_at')->first();
|
|
|
+ ->selectRaw('id as script_id, script_name, episode_num, remark, created_at')->first();
|
|
|
if (!$script) Utils::throwError('20003:该剧本不存在!');
|
|
|
$script = (array)$script;
|
|
|
- $script['roles'] = json_decode($script['roles']);
|
|
|
- $script['scenes'] = json_decode($script['scenes']);
|
|
|
- $start = 1;
|
|
|
- $end = DB::table('mp_script_episodes')->where('script_id', $script_id)->count('id');
|
|
|
|
|
|
// 获取分集组信息
|
|
|
if ($group_id) {
|
|
|
- $group = DB::table('mp_script_episode_group')->where('script_id', $script_id)->where('id', $group_id)
|
|
|
- ->select('start_episode_number', 'end_episode_number')->first();
|
|
|
- if (!$group) Utils::throwError('20003:分集不存在');
|
|
|
-
|
|
|
- $start = getProp($group, 'start_episode_number');
|
|
|
- $end = getProp($group, 'end_episode_number');
|
|
|
+ $groups = DB::table('mp_script_episode_group')->where('script_id', $script_id)->where('id', $group_id)->where('is_deleted', 0)->whereNotNull('episode_content')
|
|
|
+ ->selectRaw('intro, highlights, roles, role_relationship, core_contradiction, art_style, scenes, status, start_episode_number, end_episode_number, episode_content')
|
|
|
+ ->get()->map(function($value) {
|
|
|
+ return (array)$value;
|
|
|
+ })->toArray();
|
|
|
+ }else {
|
|
|
+ $groups = DB::table('mp_script_episode_group')->where('script_id', $script_id)->where('is_deleted', 0)->whereNotNull('episode_content')
|
|
|
+ ->selectRaw('intro, highlights, roles, role_relationship, core_contradiction, art_style, scenes, status, start_episode_number, end_episode_number, episode_content')
|
|
|
+ ->orderBy('start_episode_number')->orderBy('id')->get()->map(function($value) {
|
|
|
+ return (array)$value;
|
|
|
+ })->toArray();
|
|
|
}
|
|
|
-
|
|
|
- // 获取分集信息
|
|
|
- $episode_list = DB::table('mp_script_episodes')->where('script_id', $script_id)->whereBetween('episode_number', [$start, $end])
|
|
|
- ->select('episode_number', 'episode_name', 'episode_content')->orderBy('episode_number')->get()->map(function ($value) {
|
|
|
- return (array)$value;
|
|
|
- })->toArray();
|
|
|
- $script['episodes'] = $episode_list;
|
|
|
+ if (!$groups) Utils::throwError('20003:分集不存在');
|
|
|
+ $script['group'] = $groups;
|
|
|
|
|
|
$export_type = getProp($data, 'export_type', 'txt');
|
|
|
|
|
|
@@ -2545,55 +2543,60 @@ class DeepSeekService
|
|
|
*/
|
|
|
private function buildScriptContent($script) {
|
|
|
$content = '';
|
|
|
-
|
|
|
- // 剧本基本信息
|
|
|
- if (!empty($script['intro'])) {
|
|
|
- $content .= "###故事梗概\n" . $script['intro'] . "\n\n";
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($script['highlights'])) {
|
|
|
- $content .= "###剧本亮点\n" . $script['highlights'] . "\n\n";
|
|
|
- }
|
|
|
+ $groups = $script['group'];
|
|
|
+ $groups = (array)$groups;
|
|
|
|
|
|
- if (!empty($script['role_relationship'])) {
|
|
|
- $content .= "###人物关系\n" . $script['role_relationship'] . "\n\n";
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($script['core_contradiction'])) {
|
|
|
- $content .= "###核心矛盾\n" . $script['core_contradiction'] . "\n\n";
|
|
|
- }
|
|
|
+ foreach ($groups as $group) {
|
|
|
+ // 剧本基本信息
|
|
|
+ if (!empty($group['intro'])) {
|
|
|
+ $content .= "###故事梗概\n" . $group['intro'] . "\n\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($group['highlights'])) {
|
|
|
+ $content .= "###剧本亮点\n" . $group['highlights'] . "\n\n";
|
|
|
+ }
|
|
|
|
|
|
- if (!empty($script['roles']) && is_array($script['roles'])) {
|
|
|
- $content .= "###主体列表\n";
|
|
|
- foreach ($script['roles'] as $role) {
|
|
|
- $content .= getProp($role, 'role') . ":" . getProp($role, 'description') . "\n";
|
|
|
+ if (!empty($group['role_relationship'])) {
|
|
|
+ $content .= "###人物关系\n" . $group['role_relationship'] . "\n\n";
|
|
|
}
|
|
|
- $content .= "\n\n";
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($script['art_style'])) {
|
|
|
- $content .= "###美术风格\n" . $script['art_style'] . "\n\n";
|
|
|
- }
|
|
|
-
|
|
|
- // 场景信息
|
|
|
- if (!empty($script['scenes']) && is_array($script['scenes'])) {
|
|
|
- $content .= "###场景列表\n";
|
|
|
- foreach ($script['scenes'] as $scene) {
|
|
|
- $content .= getProp($scene, 'scene') . ":" . getProp($scene, 'description') . "\n";
|
|
|
+
|
|
|
+ if (!empty($group['core_contradiction'])) {
|
|
|
+ $content .= "###核心矛盾\n" . $group['core_contradiction'] . "\n\n";
|
|
|
}
|
|
|
- $content .= "\n\n";
|
|
|
- }
|
|
|
-
|
|
|
- // 分集内容
|
|
|
- if (!empty($script['episodes']) && is_array($script['episodes'])) {
|
|
|
- $content .= "###分集剧本\n";
|
|
|
- foreach ($script['episodes'] as $episode) {
|
|
|
- // $content .= "##分集" . $episode['episode_number'] . "\n分集名";
|
|
|
- // if (!empty($episode['episode_name'])) {
|
|
|
- // $content .= ":" . $episode['episode_name'];
|
|
|
+
|
|
|
+ if (!empty($group['roles']) && is_array($group['roles'])) {
|
|
|
+ $content .= "###主体列表\n";
|
|
|
+ foreach ($group['roles'] as $role) {
|
|
|
+ $content .= getProp($role, 'role') . ":" . getProp($role, 'description') . "\n";
|
|
|
+ }
|
|
|
+ $content .= "\n\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($group['art_style'])) {
|
|
|
+ $content .= "###美术风格\n" . $group['art_style'] . "\n\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 场景信息
|
|
|
+ if (!empty($group['scenes']) && is_array($group['scenes'])) {
|
|
|
+ $content .= "###场景列表\n";
|
|
|
+ foreach ($group['scenes'] as $scene) {
|
|
|
+ $content .= getProp($scene, 'scene') . ":" . getProp($scene, 'description') . "\n";
|
|
|
+ }
|
|
|
+ $content .= "\n\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分集内容
|
|
|
+ if (!empty($group['episode_content'])) {
|
|
|
+ $content .= "###分集剧本\n";
|
|
|
+ $content .= $group['episode_content'];
|
|
|
+ // foreach ($script['episodes'] as $episode) {
|
|
|
+ // // $content .= "##分集" . $episode['episode_number'] . "\n分集名";
|
|
|
+ // // if (!empty($episode['episode_name'])) {
|
|
|
+ // // $content .= ":" . $episode['episode_name'];
|
|
|
+ // // }
|
|
|
+ // // $content .= "\n";
|
|
|
+ // $content .= $episode['episode_content'] . "\n\n";
|
|
|
// }
|
|
|
- // $content .= "\n";
|
|
|
- $content .= $episode['episode_content'] . "\n\n";
|
|
|
}
|
|
|
}
|
|
|
|