Daniel 2 лет назад
Родитель
Сommit
a1a92e6a09
9 измененных файлов: 113 добавлений и 31 удалений
  1. Двоичные данные
      httpdocs/import/mpp_import_benchmark.xlsx
  2. Двоичные данные
      httpdocs/import/~$mpp_import_benchmark.xlsx
  3. Двоичные данные
      httpdocs/import/~$mpp_import_din.xlsx
  4. +22
    -3
      httpdocs/public/assets/js/my-bim-score.js
  5. +2
    -1
      httpdocs/src/Command/CmdImportDinAssets.php
  6. +37
    -2
      httpdocs/src/Controller/UserController.php
  7. +33
    -6
      httpdocs/src/Entity/DinAsset.php
  8. +14
    -11
      httpdocs/src/Utils/Utils.php
  9. +5
    -8
      httpdocs/templates/pages/risk_analysis.html.twig

Двоичные данные
httpdocs/import/mpp_import_benchmark.xlsx Просмотреть файл


Двоичные данные
httpdocs/import/~$mpp_import_benchmark.xlsx Просмотреть файл


Двоичные данные
httpdocs/import/~$mpp_import_din.xlsx Просмотреть файл


+ 22
- 3
httpdocs/public/assets/js/my-bim-score.js Просмотреть файл

@@ -3,6 +3,7 @@ $(document).ready(function() {
listing(); listing();
catalogue(); catalogue();
onChangeDinAsset(); onChangeDinAsset();
onFormSubmit();
}); });


// Message Box for alerts // Message Box for alerts
@@ -124,9 +125,9 @@ function onChangeDinAsset() {
$("#cycle").attr({ $("#cycle").attr({
"min" : data.cycleMin, "min" : data.cycleMin,
"max" : data.cycleMax "max" : data.cycleMax
}).val(data.cycleRecommended);
}).val('');


$('#bandwidth')
$('#benchmark')
.find('option') .find('option')
.remove() .remove()
.end() .end()
@@ -134,7 +135,7 @@ function onChangeDinAsset() {


for (let i in data.benchmarkValues) { for (let i in data.benchmarkValues) {
noBenchmarkData = true; noBenchmarkData = true;
$('#bandwidth').append('<option value="' + i + '">' + data.benchmarkValues[i] + '</option>');
$('#benchmark').append('<option value="' + i + '">' + data.benchmarkValues[i] + '</option>');
} }


if (Object.keys(data.benchmarkValues).length < 1) { if (Object.keys(data.benchmarkValues).length < 1) {
@@ -151,6 +152,24 @@ function onChangeDinAsset() {
}); });
} }


function onFormSubmit() {
$("#submit").on("click", function(e) {
console.log($('#form-risk').serializeArray());
$.ajax({
url: "/calculate-risk",
method: "post",
data: $('#form-risk').serializeArray(),
success: function (data) {
console.log(data);
},
error: function (xhr, msg, three) {
messageBox(false, "Fehler bei der Anfrage.");
},
dataType: "json"
});
});
}

let savedCatalogueAnswer, let savedCatalogueAnswer,
savedCatalogueNote; savedCatalogueNote;
$(document).ready(function() { $(document).ready(function() {


+ 2
- 1
httpdocs/src/Command/CmdImportDinAssets.php Просмотреть файл

@@ -92,7 +92,8 @@ class CmdImportDinAssets extends Command
$dinAsset->setName($rowData[1]); $dinAsset->setName($rowData[1]);
$dinAsset->setCycleMonthsMin($rowData[11]); $dinAsset->setCycleMonthsMin($rowData[11]);
$dinAsset->setCycleMonthsMax($rowData[12]); $dinAsset->setCycleMonthsMax($rowData[12]);
$dinAsset->setCycleMonthsRecommended($rowData[13]);
$dinAsset->setCycleMonthsRecInspection($rowData[13]);
$dinAsset->setCycleMonthsRecMaintenance($rowData[14]);
$this->em->persist($dinAsset); $this->em->persist($dinAsset);
$this->em->flush(); $this->em->flush();
$dinAssetsByDinAndName[$key] = $dinAsset; $dinAssetsByDinAndName[$key] = $dinAsset;


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

@@ -96,7 +96,6 @@ class UserController extends AbstractController
); );
} }



/** /**
* @Route("/get-benchmark-data", name="get_benchmark_data") * @Route("/get-benchmark-data", name="get_benchmark_data")
*/ */
@@ -111,13 +110,49 @@ class UserController extends AbstractController
} }


$res = []; $res = [];
$res['cycleRecommended'] = $dinAsset->getCycleMonthsRecommended();
$res['cycleRecommended'] = $dinAsset->getCycleMonthsRecInspection();
$res['cycleMin'] = $dinAsset->getCycleMonthsMin(); $res['cycleMin'] = $dinAsset->getCycleMonthsMin();
$res['cycleMax'] = $dinAsset->getCycleMonthsMax(); $res['cycleMax'] = $dinAsset->getCycleMonthsMax();
$res['benchmarkValues'] = $dinAsset->getBenchMarkSelectValues(); $res['benchmarkValues'] = $dinAsset->getBenchMarkSelectValues();
return $this->json($res); return $this->json($res);
} }


/**
* @Route("/calculate-risk", name="calculate_risk")
*/
public function calculateRisk(Request $request)
{
$params = $request->request->all();
$benchmark = $this->getDoctrine()->getRepository(DinAssetBenchmark::class)->find($params['benchmark']);
$asset = $benchmark->getDinAsset();
$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];
$pointsCosts = Utils::$riskCosts[$params['costs']][1];
if ($params['costs'] === Utils::PERSON_DAMAGE_INDEX) {
$pointsCosts = Utils::PERSON_DAMAGE_BASE - $pointsFailure;
}
$riskPoints = $pointsFailure + $pointsCosts;
$riskFactor = Utils::$riskPoints[$riskPoints]['factor'];
$recCycle = (int) ($asset->getCycleMonthsMax() * $riskFactor);

$costsCurrentPerYear = (12 / $userCycle) * $benchmark->getAverageCosts();
$costsRecPerYear = (12 / $recCycle) * $benchmark->getAverageCosts();



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

/** /**
* @Route("/download", name="download") * @Route("/download", name="download")
* *


+ 33
- 6
httpdocs/src/Entity/DinAsset.php Просмотреть файл

@@ -40,7 +40,12 @@ class DinAsset
/** /**
* @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true}) * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
*/ */
protected $cycleMonthsRecommended;
protected $cycleMonthsRecInspection;

/**
* @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
*/
protected $cycleMonthsRecMaintenance;


/** /**
* @ORM\OneToMany(targetEntity="DinAssetTask", mappedBy="dinAsset", cascade={"persist", "remove"}) * @ORM\OneToMany(targetEntity="DinAssetTask", mappedBy="dinAsset", cascade={"persist", "remove"})
@@ -135,17 +140,39 @@ class DinAsset
/** /**
* @return mixed * @return mixed
*/ */
public function getCycleMonthsRecommended()
public function getCycleMonthsRecInspection()
{ {
return $this->cycleMonthsRecommended;
return $this->cycleMonthsRecInspection;
} }


/** /**
* @param mixed $cycleMonthsRecommended
* @param mixed $cycleMonthsRecInspection
*/ */
public function setCycleMonthsRecommended($cycleMonthsRecommended): void
public function setCycleMonthsRecInspection($cycleMonthsRecInspection): void
{ {
$this->cycleMonthsRecommended = $cycleMonthsRecommended;
if ($cycleMonthsRecInspection <= 0) {
throw new \Exception('invalid value');
}
$this->cycleMonthsRecInspection = $cycleMonthsRecInspection;
}

/**
* @return mixed
*/
public function getCycleMonthsRecMaintenance()
{
return $this->cycleMonthsRecMaintenance;
}

/**
* @param mixed $cycleMonthsRecMaintenance
*/
public function setCycleMonthsRecMaintenance($cycleMonthsRecMaintenance): void
{
if ($cycleMonthsRecMaintenance <= 0) {
throw new \Exception('invalid value');
}
$this->cycleMonthsRecMaintenance = $cycleMonthsRecMaintenance;
} }


/** /**


+ 14
- 11
httpdocs/src/Utils/Utils.php Просмотреть файл

@@ -10,8 +10,10 @@ class Utils
const PASSWORD_MIN_LENGTH = 5; const PASSWORD_MIN_LENGTH = 5;
const PASSWORD_MAX_LENGTH = 50; const PASSWORD_MAX_LENGTH = 50;


const PERSON_DAMAGE_BASE = 40;
const PERSON_DAMAGE_INDEX = 4;

public static $riskFailure = [ public static $riskFailure = [
['-', 0],
['sehr niedrig', 5], ['sehr niedrig', 5],
['niedrig', 10], ['niedrig', 10],
['mittel', 15], ['mittel', 15],
@@ -19,23 +21,24 @@ class Utils
]; ];


public static $riskCosts = [ public static $riskCosts = [
['-', 0],
['0 - 5.000 €', 5], ['0 - 5.000 €', 5],
['5.001 - 50.000 €', 10], ['5.001 - 50.000 €', 10],
['mittel', 15],
['hoch', 20]
['50.001 - 250.000 €', 15],
['> 1 Mio €', 20],
['Personenschaden', 0]
]; ];


public static $riskPoints = [ public static $riskPoints = [
['factor' => 0, 'cycle' => 6, 'points' => 10],
['factor' => 0.17, 'cycle' => 6, 'points' => 15],
['factor' => 0.33, 'cycle' => 6, 'points' => 20],
['factor' => 0.5, 'cycle' => 6, 'points' => 25],
['factor' => 0.67, 'cycle' => 6, 'points' => 30],
['factor' => 0.83, 'cycle' => 6, 'points' => 35],
['factor' => 1, 'cycle' => 6, 'points' => 40],
10 => ['factor' => 1, 'cycle' => 6],
15 => ['factor' => 0.83, 'cycle' => 8],
20 => ['factor' => 0.67, 'cycle' => 16],
25 => ['factor' => 0.5, 'cycle' => 24],
30 => ['factor' => 0.33, 'cycle' => 32],
35 => ['factor' => 0.17, 'cycle' => 40],
40 => ['factor' => 0, 'cycle' => 48]
]; ];



/** /**
* Checks email format * Checks email format
* @param $email * @param $email


+ 5
- 8
httpdocs/templates/pages/risk_analysis.html.twig Просмотреть файл

@@ -5,7 +5,7 @@
{% block body %} {% block body %}
<h1>MPP-Tool</h1> <h1>MPP-Tool</h1>
<p id="instruction">Bitte füllen sie alle Felder aus, um eine Risikoanalyse zu erstellen.</p> <p id="instruction">Bitte füllen sie alle Felder aus, um eine Risikoanalyse zu erstellen.</p>
<form method="post" class="form form--catalogue">
<form method="post" id="form-risk" class="form form--catalogue">
<label for="asset">Bitte wählen sie eine Anlage.</label> <label for="asset">Bitte wählen sie eine Anlage.</label>
<select name="asset" id="asset"> <select name="asset" id="asset">
{% for asset in dinAssets %} {% for asset in dinAssets %}
@@ -29,35 +29,32 @@
<h2>Optimierungsckeck</h2> <h2>Optimierungsckeck</h2>
<label for="maintenance">Wird durch die Wartung der Abnutzungsvorrat positiv beeinflusst?</label> <label for="maintenance">Wird durch die Wartung der Abnutzungsvorrat positiv beeinflusst?</label>
<select name="maintenance" id="maintenance"> <select name="maintenance" id="maintenance">
<option value="-">-</option>
<option value="0">Nein</option> <option value="0">Nein</option>
<option value="1">Ja</option> <option value="1">Ja</option>
</select> </select>
<label for="inspection">Kann durch eine Inspektion der Zustand der Anlage erkannt werden?</label> <label for="inspection">Kann durch eine Inspektion der Zustand der Anlage erkannt werden?</label>
<select name="inspection" id="inspection"> <select name="inspection" id="inspection">
<option value="-">-</option>
<option value="0">Nein</option> <option value="0">Nein</option>
<option value="1">Ja</option> <option value="1">Ja</option>
</select> </select>
<label for="check">Genügt eine einfache Sichtkontrolle im Rahmen des regelmäßigen Rundgangs?</label> <label for="check">Genügt eine einfache Sichtkontrolle im Rahmen des regelmäßigen Rundgangs?</label>
<select name="check" id="check"> <select name="check" id="check">
<option value="-">-</option>
<option value="0">Nein</option> <option value="0">Nein</option>
<option value="1">Ja</option> <option value="1">Ja</option>
</select> </select>
<label for="cycle">Aktueller Zyklus (in Monaten)</label> <label for="cycle">Aktueller Zyklus (in Monaten)</label>
{% if initialDinAsset is not null %} {% if initialDinAsset is not null %}
<input name="cycle" type="number" id="cycle" value="{{ initialDinAsset.cycleMonthsRecommended }}" min="{{ initialDinAsset.cycleMonthsMin }}" max ="{{ initialDinAsset.cycleMonthsMax }}">
<input name="cycle" type="number" id="cycle" value="" min="{{ initialDinAsset.cycleMonthsMin }}" max ="{{ initialDinAsset.cycleMonthsMax }}">
{% else %} {% else %}
<input name="cycle" type="number" id="cycle" disabled> <input name="cycle" type="number" id="cycle" disabled>
{% endif %} {% endif %}


<label for="bandwidth">Bandbreite Anlage</label>
<select name="bandwidth" id="bandwidth">
<label for="benchmark">Bandbreite Anlage</label>
<select name="benchmark" id="benchmark">
{% for key, benchmarkValue in benchmarkValues %} {% for key, benchmarkValue in benchmarkValues %}
<option value="{{ key }}">{{ benchmarkValue }}</option> <option value="{{ key }}">{{ benchmarkValue }}</option>
{% endfor %} {% endfor %}
</select> </select>
<span class="btn" id="submit">Berechnen</span>
</form> </form>
{% endblock %} {% endblock %}

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