Browse Source

Initial linear curve

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
60b45418a6
  1. 54
      app/Helpers/MasterFunctionsHelper.php
  2. 7
      app/Http/Controllers/HierarchyFtthController.php
  3. 7
      app/Http/Controllers/ProjectController.php
  4. 3
      app/Http/Controllers/VersionGanttController.php
  5. 2
      app/Models/HierarchyFtth.php
  6. 1
      app/Models/VersionGantt.php
  7. 1
      routes/web.php

54
app/Helpers/MasterFunctionsHelper.php

@ -5,6 +5,7 @@ namespace App\Helpers;
use App\Models\Activity;
use App\Models\Project;
use App\Models\VersionGantt;
use App\Models\HierarchyFtth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@ -82,6 +83,59 @@ class MasterFunctionsHelper {
}
}
public function getLinearSCurve($request){
$ftths = HierarchyFtth::where('project_id', $request->project_id)->get();
$ttlProgress = 0;
$ttlPlanning = 0;
foreach ($ftths as $ftth) {
$progress = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('progress');
$planning = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('bobot');
$ttlProgress += $progress;
$ttlPlanning += $planning;
}
$minDate = Project::select('mulai_proyek')->where('id', $request->project_id)->first();
$maxDate = Project::select('akhir_proyek')->where('id', $request->project_id)->first();
$begin = new \DateTime($minDate->mulai_proyek. ' Monday');
$begin->modify('last Monday');
$end = new \DateTime($maxDate->akhir_proyek. ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
$period = new \DatePeriod($begin, $interval, $end);
$dates = iterator_to_array($period);
$count = count($dates);
$avgProgress = $ttlProgress/$count;
$avgPlanning = $ttlPlanning/$count;
$progressData = [];
$planningData = [];
$tempProgress = 0;
$tempPlanning = 0;
foreach($period as $p){
array_push($progressData, $tempProgress);
array_push($planningData, $tempPlanning);
$tempProgress += $avgProgress;
$tempPlanning += $avgPlanning;
}
$dataResponse = array(
"percentagePlan" => $progressData,
"percentageReal" => $planningData,
);
$dataFinal[] = array(
"data"=>$dataResponse,
);
return $dataFinal;
}
public function calculateProgressBasedOnReportMaterial($keyGantt)
{
DB::enableQueryLog();

7
app/Http/Controllers/HierarchyFtthController.php

@ -110,12 +110,15 @@ class HierarchyFtthController extends Controller
if($ftthIds){
foreach ($ftthIds as $ftthId) {
$gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress');
$bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot');
$ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count();
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
if($ftth){
$round = $gantts/$ganttCount;
$round_bobot = $bobot_planning/$ganttCount;
$ftth->progress = round($round, 2);
$ftth->bobot_planning = round($round_bobot, 2);
try {
$ftth->save();
} catch (\Exception $e) {
@ -189,6 +192,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) {
if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
}
}
}
@ -216,6 +220,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) {
if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
}
}
}
@ -228,7 +233,7 @@ class HierarchyFtthController extends Controller
}
public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress')
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value)
->where('m_activity.type_activity', "project")

7
app/Http/Controllers/ProjectController.php

@ -330,6 +330,11 @@ class ProjectController extends Controller
public function getSCurve(Request $request){
$data = MasterFunctionsHelper::getSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public function getLinearSCurve(Request $request){
$data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public function synchronizeReport($gantt_id)
@ -412,7 +417,7 @@ class ProjectController extends Controller
$gantt = MasterFunctionsHelper::getLatestGantt($id);
$result->projectManager = User::where('id', $result->pm_id)->value('name');
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first();
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200);
}
public function getOverdueActivities(Request $request){

3
app/Http/Controllers/VersionGanttController.php

@ -91,7 +91,7 @@ class VersionGanttController extends Controller
}
public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress')
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value)
// ->where('m_activity.type_activity', "project")
@ -100,6 +100,7 @@ class VersionGanttController extends Controller
foreach($progress as $item) {
if($item->persentase_progress){
$item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning;
$item->save();
}
}

2
app/Models/HierarchyFtth.php

@ -12,6 +12,6 @@ class HierarchyFtth extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress'
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning'
];
}

1
app/Models/VersionGantt.php

@ -25,6 +25,7 @@ class VersionGantt extends Model
'committed_cost',
'cost_to_complete',
'progress',
'bobot',
'hierarchy_ftth_id',
'created_at',
'created_by',

1
routes/web.php

@ -66,6 +66,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR');
$router->post('/project/get-s-curve', 'ProjectController@getSCurve');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');

Loading…
Cancel
Save