Daniel 2 лет назад
Родитель
Сommit
15905d91cd
1 измененных файлов: 22 добавлений и 12 удалений
  1. +22
    -12
      httpdocs/src/Controller/UserController.php

+ 22
- 12
httpdocs/src/Controller/UserController.php Просмотреть файл

@@ -124,15 +124,10 @@ class UserController extends AbstractController
{ {
$params = $request->request->all(); $params = $request->request->all();
$benchmark = $this->getDoctrine()->getRepository(DinAssetBenchmark::class)->find($params['benchmark']); $benchmark = $this->getDoctrine()->getRepository(DinAssetBenchmark::class)->find($params['benchmark']);
/** @var DinAsset $asset */
$asset = $benchmark->getDinAsset(); $asset = $benchmark->getDinAsset();
$userCycle = $params['cycle']; $userCycle = $params['cycle'];


$cycleDeviation = 1 - ($userCycle / ($asset->getCycleMonthsRecMaintenance()));
$costsCurrentPerYear = (12 / $userCycle) * $benchmark->getAverageCosts();
$costsRecPerYear = (12 / $asset->getCycleMonthsRecMaintenance()) * $benchmark->getAverageCosts();
$costsDiffPerYear = $costsRecPerYear - $costsCurrentPerYear;
$costsDiff5Years = $costsDiffPerYear * 5;

$pointsFailure = Utils::$riskFailure[$params['failure']][1]; $pointsFailure = Utils::$riskFailure[$params['failure']][1];
$pointsCosts = Utils::$riskCosts[$params['costs']][1]; $pointsCosts = Utils::$riskCosts[$params['costs']][1];
if ($params['costs'] === Utils::PERSON_DAMAGE_INDEX) { if ($params['costs'] === Utils::PERSON_DAMAGE_INDEX) {
@@ -140,16 +135,31 @@ class UserController extends AbstractController
} }
$riskPoints = $pointsFailure + $pointsCosts; $riskPoints = $pointsFailure + $pointsCosts;
$riskFactor = Utils::$riskPoints[$riskPoints]['factor']; $riskFactor = Utils::$riskPoints[$riskPoints]['factor'];
$recCycle = (int) ($asset->getCycleMonthsMax() * $riskFactor);


$recCycleMaintenance = $asset->getCycleMonthsMax();
if ( ((int)$params['maintenance']) === 1 && ((int)$params['check']) === 1 ) {
$recCycleMaintenance = (int) ($asset->getCycleMonthsMax() * $riskFactor);
if ($recCycleMaintenance < $asset->getCycleMonthsMin()) {
$recCycleMaintenance = $asset->getCycleMonthsMin();
}
}
$costsCurrentPerYear = (12 / $userCycle) * $benchmark->getAverageCosts(); $costsCurrentPerYear = (12 / $userCycle) * $benchmark->getAverageCosts();
$costsRecPerYear = (12 / $recCycle) * $benchmark->getAverageCosts();

$costsRecPerYear = (12 / $recCycleMaintenance) * $benchmark->getAverageCosts();


$recCycleInspection = $asset->getCycleMonthsMax();
if ( ((int)$params['inspection']) === 1 ) {
$recCycleInspection = (int) ($asset->getCycleMonthsMax() * $riskFactor);
if ($recCycleInspection < $asset->getCycleMonthsMin()) {
$recCycleInspection = $asset->getCycleMonthsMin();
}
}
$costDiffCurCycleRecCycle = $costsCurrentPerYear - $costsRecPerYear;
$costDiffCurRecPercentage = 1 - ($userCycle / $recCycleMaintenance);


$res = [];
$res['cycleRecMaintenance'] = $asset->getCycleMonthsRecMaintenance();
$res['cycleRecInspection'] = $asset->getCycleMonthsRecInspection();
$res['recCycleMaintenance'] = $recCycleMaintenance;
$res['recCycleInspection'] = $recCycleInspection;
$res['costDiffCurCycleRecCycle'] = $costDiffCurCycleRecCycle;
$res['costDiffCurRecPercentage'] = $costDiffCurRecPercentage;
return $this->json($res); return $this->json($res);
} }




Загрузка…
Отмена
Сохранить