Merge pull request #28 from a54552239/dev

修复创建任务的时候不能实时更新项目进度的问题
This commit is contained in:
vilson 2022-05-22 11:03:38 +08:00 committed by GitHub
commit 24da8ee696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View File

@ -353,18 +353,6 @@ class Task extends CommonModel
$result = self::update(['done' => $done], ['code' => $taskCode]);
//todo 添加任务动态,编辑权限检测
Db::commit();
$project = Project::where(['code' => $task['project_code']])->field('auto_update_schedule,schedule')->find();
if ($project['auto_update_schedule']) {
$taskCount = \app\common\Model\Task::where(['project_code' => $task['project_code']])->count('code');
if ($taskCount) {
$doneTaskCount = \app\common\Model\Task::where(['project_code' => $task['project_code'], 'done' => 1])->count('code');
$schedule = $doneTaskCount / $taskCount * 100;
$project->schedule = $schedule;
$project->save();
}
}
$projectAutoUpdateSchedule = 1;
} catch (Exception $e) {
Db::rollback();
throw new Exception($e->getMessage());

View File

@ -199,6 +199,21 @@ class Task
$logData['content'] = $content;
}
ProjectLog::create($logData);
$scheduleActions = ['create', 'done', 'redo', 'recycle', 'recovery', 'redoChild', 'doneChild', 'createChild'];
if (in_array($data['type'], $scheduleActions)) {
$project = \app\common\Model\Project::where(['code' => $task['project_code']])->field('auto_update_schedule,schedule')->find();
if ($project['auto_update_schedule']) {
$taskCount = \app\common\Model\Task::where(['project_code' => $task['project_code']])->count('code');
if ($taskCount) {
$doneTaskCount = \app\common\Model\Task::where(['project_code' => $task['project_code'], 'done' => 1])->count('code');
$schedule = $doneTaskCount / $taskCount * 100;
$project->schedule = $schedule;
$project->save();
}
}
}
//工作流事件
if (!$isRobot && !$task['pcode']) {//子任务不触发
$workflowActions = ['create', 'move', 'done', 'redo', 'assign', 'setEndTime', 'pri'];