diff --git a/app/Console/Commands/CalculateProgressGantt.php b/app/Console/Commands/CalculateProgressGantt.php index 6db1d41..3e9f81c 100644 --- a/app/Console/Commands/CalculateProgressGantt.php +++ b/app/Console/Commands/CalculateProgressGantt.php @@ -19,13 +19,10 @@ class CalculateProgressGantt extends Command $hierarchy = HierarchyFtth::findOrFail($hierarchy_id); $project = Project::find($hierarchy->project_id); - $project->calculation_status = true; - $project->save(); - $data = MasterFunctionsHelper::CalculateSCurve(null, $hierarchy_id); - $project->scurve = json_encode($data); - $project->calculation_status = true; - $project->save(); + $hierarchy->bobot_planning = end($data[0]['data']['percentagePlan']); + $hierarchy->progress = end($data[0]['data']['percentageReal']); + $hierarchy->save(); } } diff --git a/app/Http/Controllers/HierarchyFtthController.php b/app/Http/Controllers/HierarchyFtthController.php index c880d6e..bcf27ad 100644 --- a/app/Http/Controllers/HierarchyFtthController.php +++ b/app/Http/Controllers/HierarchyFtthController.php @@ -189,7 +189,6 @@ class HierarchyFtthController extends Controller $finalData = []; foreach($data as $objRow){ $objRow->key = rand(1, 1000); - $this->countProgress(intval($objRow->id)); if (VersionGantt::where('hierarchy_ftth_id', $objRow->id)->exists()) { $dataGantt = VersionGantt::where('hierarchy_ftth_id', $objRow->id)->get(); $progress = $this->ganttProgress('hierarchy_ftth_id', $objRow->id); @@ -210,7 +209,13 @@ class HierarchyFtthController extends Controller return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200); } - + public function countProgressTree($hierarchy_id) + { + Artisan::call('calculate:progressgantt', [ + 'hierarchy_id' => $hierarchy_id + ]); + return response()->json(['status'=>'success','code'=>200], 200); + } private function getChildren($project_id, $parent_id) { $finalData = []; diff --git a/routes/web.php b/routes/web.php index 14e1d08..f82f295 100644 --- a/routes/web.php +++ b/routes/web.php @@ -491,6 +491,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update'); $router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy'); $router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject'); + $router->get('/hierarchy-ftths/count-tree/{hierarchy_id}', 'HierarchyFtthController@countProgressTree'); $router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt'); $router->post('/map-monitoring/search', 'MapMonitoringController@search');