mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
feat: 支持AI分析工作报告
This commit is contained in:
parent
7ca0bc5960
commit
2d5ce87605
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Exceptions\ApiException;
|
use App\Exceptions\ApiException;
|
||||||
|
use App\Module\Base;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Carbon\Traits\Creator;
|
use Carbon\Traits\Creator;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@ -95,6 +96,24 @@ class Report extends AbstractModel
|
|||||||
return $this->appendattrs['receives'];
|
return $this->appendattrs['receives'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取汇报内容
|
||||||
|
* @param $id
|
||||||
|
* @return self|null
|
||||||
|
*/
|
||||||
|
public static function idOrCodeToContent($id)
|
||||||
|
{
|
||||||
|
if (Base::isNumber($id)) {
|
||||||
|
return self::find($id);
|
||||||
|
} elseif ($id) {
|
||||||
|
$reportLink = ReportLink::whereCode($id)->first();
|
||||||
|
if ($reportLink) {
|
||||||
|
return self::find($reportLink->rid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单条记录
|
* 获取单条记录
|
||||||
* @param $id
|
* @param $id
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace App\Tasks;
|
|||||||
use App\Models\FileContent;
|
use App\Models\FileContent;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectTask;
|
use App\Models\ProjectTask;
|
||||||
|
use App\Models\Report;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserBot;
|
use App\Models\UserBot;
|
||||||
use App\Models\UserDepartment;
|
use App\Models\UserDepartment;
|
||||||
@ -606,22 +607,37 @@ class BotReceiveMsgTask extends AbstractTask
|
|||||||
$original = str_replace($match[0][$index], "'{$taskName}' (see below for task_content tag)", $original);
|
$original = str_replace($match[0][$index], "'{$taskName}' (see below for task_content tag)", $original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (preg_match_all("/<a class=\"mention file\" href=\"([^\"']+?)\"[^>]*?>(.*?)<\/a>/", $original, $match)) {
|
if (preg_match_all("/<a class=\"mention ([^'\"]*)\" href=\"([^\"']+?)\"[^>]*?>[~%]([^>]*)<\/a>/", $original, $match)) {
|
||||||
$filePaths = $match[1];
|
$urlPaths = $match[2];
|
||||||
foreach ($filePaths as $index => $filePath) {
|
foreach ($urlPaths as $index => $urlPath) {
|
||||||
if (preg_match("/single\/file\/(.*?)$/", $filePath, $fileMatch)) {
|
$pathTag = null;
|
||||||
$fileName = addslashes($match[2][$index]);
|
$pathName = null;
|
||||||
$fileContent = "文件状态:不存在或已删除";
|
$pathContent = null;
|
||||||
|
if (preg_match("/single\/file\/(.*?)$/", $urlPath, $fileMatch)) {
|
||||||
|
$pathTag = "file_content";
|
||||||
|
$pathName = addslashes($match[3][$index]);
|
||||||
|
$pathContent = "文件状态:不存在或已删除";
|
||||||
$fileInfo = FileContent::idOrCodeToContent($fileMatch[1]);
|
$fileInfo = FileContent::idOrCodeToContent($fileMatch[1]);
|
||||||
if ($fileInfo && isset($fileInfo->content['url'])) {
|
if ($fileInfo && isset($fileInfo->content['url'])) {
|
||||||
$filePath = public_path($fileInfo->content['url']);
|
$urlPath = public_path($fileInfo->content['url']);
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($urlPath)) {
|
||||||
$fileName .= " (ID:{$fileInfo->id})";
|
$pathName .= " (ID:{$fileInfo->id})";
|
||||||
$fileContent = TextExtractor::getFileContent($filePath);
|
$pathContent = TextExtractor::getFileContent($urlPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$aiContents[] = "<file_content path=\"{$fileName}\">\n{$fileContent}\n</file_content>";
|
} elseif (preg_match("/single\/report\/detail\/(.*?)$/", $urlPath, $reportMatch)) {
|
||||||
$original = str_replace($match[0][$index], "'{$fileName}' (see below for file_content tag)", $original);
|
$pathTag = "report_content";
|
||||||
|
$pathName = addslashes($match[3][$index]);
|
||||||
|
$pathContent = "报告状态:不存在或已删除";
|
||||||
|
$reportInfo = Report::idOrCodeToContent($reportMatch[1]);
|
||||||
|
if ($reportInfo) {
|
||||||
|
$pathName .= " (ID:{$reportInfo->id})";
|
||||||
|
$pathContent = $reportInfo->content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($pathTag) {
|
||||||
|
$aiContents[] = "<{$pathTag} path=\"{$pathName}\">\n{$pathContent}\n</{$pathTag}>";
|
||||||
|
$original = str_replace($match[0][$index], "'{$pathName}' (see below for {$pathTag} tag)", $original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user