#feature: update log format
This commit is contained in:
@@ -170,7 +170,7 @@ class JiraService
|
||||
$endOfWeek = $now->copy()->subWeek()->endOfWeek();
|
||||
|
||||
$workLogs = $this->getWorkLogs($username, $startOfWeek, $endOfWeek);
|
||||
$organizedTasks = $this->organizeTasksForReport($workLogs);
|
||||
$organizedTasks = $this->organizeTasksForReport($workLogs, $username);
|
||||
|
||||
$nextWeekTasks = $this->getNextWeekTasks($username);
|
||||
|
||||
@@ -307,11 +307,14 @@ class JiraService
|
||||
'created',
|
||||
'fixVersions',
|
||||
'labels',
|
||||
'customfield_10004', // Sprint字段
|
||||
'customfield_10900', // Bug发现阶段
|
||||
'customfield_12700', // Bug错误类型
|
||||
'customfield_10115', // Bug修复描述
|
||||
'customfield_14305', // 需求类型
|
||||
'assignee', // 经办人
|
||||
'customfield_10004', // Sprint字段
|
||||
'customfield_10900', // Bug发现阶段
|
||||
'customfield_11000', // 开发人
|
||||
'customfield_11301', // 实际修复人
|
||||
'customfield_12700', // Bug错误类型
|
||||
'customfield_10115', // Bug修复描述
|
||||
'customfield_14305', // 需求类型
|
||||
]);
|
||||
|
||||
if (!empty($issues->issues)) {
|
||||
@@ -369,6 +372,11 @@ class JiraService
|
||||
// 提取需求类型
|
||||
$requirementType = $this->extractRequirementType($issue);
|
||||
|
||||
// 提取经办人、开发人、实际修复人
|
||||
$assignee = $this->extractAssignee($issue);
|
||||
$developer = $this->extractDeveloper($issue);
|
||||
$actualFixer = $this->extractActualFixer($issue);
|
||||
|
||||
$workLogs->push([
|
||||
'id' => $worklog->id ?? '',
|
||||
'project' => $issue->fields->project->name ?? '',
|
||||
@@ -385,6 +393,9 @@ class JiraService
|
||||
'bug_type' => $bugType,
|
||||
'bug_description' => $bugDescription,
|
||||
'requirement_type' => $requirementType,
|
||||
'assignee' => $assignee,
|
||||
'developer' => $developer,
|
||||
'actual_fixer' => $actualFixer,
|
||||
'date' => $worklogDate->format('Y-m-d'),
|
||||
'time' => $worklogDate->format('H:i'),
|
||||
'hours' => round(($worklog->timeSpentSeconds ?? 0) / 3600, 2),
|
||||
@@ -593,6 +604,60 @@ class JiraService
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取经办人
|
||||
*/
|
||||
private function extractAssignee($issue): ?string
|
||||
{
|
||||
// 从assignee字段获取经办人
|
||||
if (isset($issue->fields->assignee)) {
|
||||
$assignee = $issue->fields->assignee;
|
||||
|
||||
// 处理对象类型
|
||||
if (is_object($assignee)) {
|
||||
return $assignee->name ?? $assignee->key ?? null;
|
||||
} elseif (is_string($assignee)) {
|
||||
return $assignee;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取开发人
|
||||
*/
|
||||
private function extractDeveloper($issue): ?string
|
||||
{
|
||||
// 从customfield_11000获取开发人
|
||||
if (isset($issue->fields->customFields['customfield_11000'])) {
|
||||
$developer = $issue->fields->customFields['customfield_11000'];
|
||||
|
||||
if (is_string($developer) && !empty($developer)) {
|
||||
return $developer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取实际修复人
|
||||
*/
|
||||
private function extractActualFixer($issue): ?string
|
||||
{
|
||||
// 从customfield_11301获取实际修复人
|
||||
if (isset($issue->fields->customFields['customfield_11301'])) {
|
||||
$fixer = $issue->fields->customFields['customfield_11301'];
|
||||
|
||||
if (is_string($fixer) && !empty($fixer)) {
|
||||
return $fixer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理摘要中的图片链接
|
||||
*/
|
||||
@@ -610,29 +675,27 @@ class JiraService
|
||||
*/
|
||||
private function isTaskCompleted(string $status): bool
|
||||
{
|
||||
// 只有已完成或已取消才打勾
|
||||
$completedStatuses = [
|
||||
'已完成',
|
||||
'完成',
|
||||
'Done',
|
||||
'Closed',
|
||||
'Resolved',
|
||||
];
|
||||
$cancelledStatuses = [
|
||||
'已取消',
|
||||
'取消',
|
||||
'Cancelled',
|
||||
'Canceled',
|
||||
// 定义"进行中"的状态列表
|
||||
// 如果状态不在这个列表中,则认为任务已完成
|
||||
$inProgressStatuses = [
|
||||
'需求已确认',
|
||||
'开发中',
|
||||
'需求调研中',
|
||||
'需求已调研',
|
||||
'需求已评审',
|
||||
'需求已排期',
|
||||
'待提测',
|
||||
'需求设计中',
|
||||
];
|
||||
|
||||
return in_array($status, $completedStatuses, true)
|
||||
|| in_array($status, $cancelledStatuses, true);
|
||||
// 如果状态不在"进行中"列表中,则标记为已完成
|
||||
return !in_array($status, $inProgressStatuses, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织任务数据用于周报生成
|
||||
*/
|
||||
private function organizeTasksForReport(Collection $workLogs): Collection
|
||||
private function organizeTasksForReport(Collection $workLogs, string $username): Collection
|
||||
{
|
||||
$organized = collect([
|
||||
'sprints' => collect(),
|
||||
@@ -671,6 +734,21 @@ class JiraService
|
||||
$isSubtask = in_array($issueType, ['Sub-task', 'sub-task', '子任务']);
|
||||
|
||||
if ($isBug && $workLog['bug_stage']) {
|
||||
// Bug过滤逻辑:必须经办人、实际修复人或开发人是当前用户
|
||||
$assignee = $workLog['assignee'] ?? null;
|
||||
$developer = $workLog['developer'] ?? null;
|
||||
$actualFixer = $workLog['actual_fixer'] ?? null;
|
||||
|
||||
// 检查是否有任一字段匹配当前用户
|
||||
$isUserRelated = ($assignee === $username)
|
||||
|| ($developer === $username)
|
||||
|| ($actualFixer === $username);
|
||||
|
||||
// 如果不是当前用户相关的Bug,跳过
|
||||
if (!$isUserRelated) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Bug按发现阶段分类
|
||||
$stage = $workLog['bug_stage'];
|
||||
if (!$organized['bugs']->has($stage)) {
|
||||
|
||||
Reference in New Issue
Block a user