From 5a8db9cfade64e83aadd043e6174bde0a3e9d45c Mon Sep 17 00:00:00 2001 From: vilson <545522390@qq.com> Date: Sun, 22 May 2022 11:02:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D=E8=83=BD=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/Model/Task.php | 12 ------------ application/project/behavior/Task.php | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/application/common/Model/Task.php b/application/common/Model/Task.php index cb90c9f..aca9c09 100644 --- a/application/common/Model/Task.php +++ b/application/common/Model/Task.php @@ -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()); diff --git a/application/project/behavior/Task.php b/application/project/behavior/Task.php index 5a82552..67e9a56 100644 --- a/application/project/behavior/Task.php +++ b/application/project/behavior/Task.php @@ -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'];