Compare commits

..

No commits in common. 'ab366b6622da3d632952eeb33654c0c779931248' and '068526bc3f0a82e3d5b09f4fbcdaeb84b0623491' have entirely different histories.

  1. 26
      app/Console/Commands/ActualProgressProject.php

26
app/Console/Commands/ActualProgressProject.php

@ -3,11 +3,9 @@
namespace App\Console\Commands;
use App\Helpers\MasterFunctionsHelper;
use App\Models\HierarchyFtth;
use App\Models\Project;
use App\Models\VersionGantt;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class ActualProgressProject extends Command
{
@ -42,7 +40,7 @@ class ActualProgressProject extends Command
*/
public function handle()
{
$projects = Project::leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
$projects = Project::join('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.is_multiLocation')
->get();
@ -54,16 +52,9 @@ class ActualProgressProject extends Command
->where('m_version_gantt.proyek_id', $project->id)
->get();
foreach ($versionGantt as $key => $gantt) {
$hierarchy = HierarchyFtth::where('id',$gantt->hierarchy_ftth_id)->count();
// Perhitungan jika project memiliki gantt tetapi tidak ada hierarchy (Kasus perpindahan tipe project dari single location ke multi location)
if($hierarchy == 0){
$progress[$key] = 0;
} else {
$progress[$key] = $gantt->progress;
}
$progress[$key] = $gantt->progress;
}
$actualProgress = round(array_sum($progress) / count($versionGantt), 2);
$progress = array(); // unset/kosongkan array progress untuk project selanjutnya
} else {
// untuk project single location
$gantt = MasterFunctionsHelper::getLatestGantt($project->id);
@ -74,15 +65,12 @@ class ActualProgressProject extends Command
'gantt_id' => $lastGantt,
'periode' => 'week'
];
// kondisi jika tidak ada gantt_id
if (empty($arr['gantt_id'])) {
$actualProgress = 0;
} else {
$project->scurve = MasterFunctionsHelper::getSCurve(collect($arr));
$actualArray = $project->scurve[0]['data']['percentageReal'];
$actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0;
}
$project->scurve = MasterFunctionsHelper::getSCurve(collect($arr));
$actualArray = $project->scurve[0]['data']['percentageReal'];
$actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0;
}
Project::where('id', $project->id)->update(['persentase_progress' => $actualProgress]);
}
}

Loading…
Cancel
Save