Daniel пре 2 година
родитељ
комит
a1a92e6a09
9 измењених фајлова са 113 додато и 31 уклоњено
  1. BIN
      httpdocs/import/mpp_import_benchmark.xlsx
  2. BIN
      httpdocs/import/~$mpp_import_benchmark.xlsx
  3. BIN
      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

BIN
httpdocs/import/mpp_import_benchmark.xlsx Прегледај датотеку


BIN
httpdocs/import/~$mpp_import_benchmark.xlsx Прегледај датотеку


BIN
httpdocs/import/~$mpp_import_din.xlsx Прегледај датотеку


+ 22
- 3
httpdocs/public/assets/js/my-bim-score.js Прегледај датотеку

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

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

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

for (let i in data.benchmarkValues) {
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) {
@@ -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,
savedCatalogueNote;
$(document).ready(function() {


+ 2
- 1
httpdocs/src/Command/CmdImportDinAssets.php Прегледај датотеку

@@ -92,7 +92,8 @@ class CmdImportDinAssets extends Command
$dinAsset->setName($rowData[1]);
$dinAsset->setCycleMonthsMin($rowData[11]);
$dinAsset->setCycleMonthsMax($rowData[12]);
$dinAsset->setCycleMonthsRecommended($rowData[13]);
$dinAsset->setCycleMonthsRecInspection($rowData[13]);
$dinAsset->setCycleMonthsRecMaintenance($rowData[14]);
$this->em->persist($dinAsset);
$this->em->flush();
$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")
*/
@@ -111,13 +110,49 @@ class UserController extends AbstractController
}

$res = [];
$res['cycleRecommended'] = $dinAsset->getCycleMonthsRecommended();
$res['cycleRecommended'] = $dinAsset->getCycleMonthsRecInspection();
$res['cycleMin'] = $dinAsset->getCycleMonthsMin();
$res['cycleMax'] = $dinAsset->getCycleMonthsMax();
$res['benchmarkValues'] = $dinAsset->getBenchMarkSelectValues();
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")
*


+ 33
- 6
httpdocs/src/Entity/DinAsset.php Прегледај датотеку

@@ -40,7 +40,12 @@ class DinAsset
/**
* @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"})
@@ -135,17 +140,39 @@ class DinAsset
/**
* @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_MAX_LENGTH = 50;

const PERSON_DAMAGE_BASE = 40;
const PERSON_DAMAGE_INDEX = 4;

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

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

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
* @param $email


+ 5
- 8
httpdocs/templates/pages/risk_analysis.html.twig Прегледај датотеку

@@ -5,7 +5,7 @@
{% block body %}
<h1>MPP-Tool</h1>
<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>
<select name="asset" id="asset">
{% for asset in dinAssets %}
@@ -29,35 +29,32 @@
<h2>Optimierungsckeck</h2>
<label for="maintenance">Wird durch die Wartung der Abnutzungsvorrat positiv beeinflusst?</label>
<select name="maintenance" id="maintenance">
<option value="-">-</option>
<option value="0">Nein</option>
<option value="1">Ja</option>
</select>
<label for="inspection">Kann durch eine Inspektion der Zustand der Anlage erkannt werden?</label>
<select name="inspection" id="inspection">
<option value="-">-</option>
<option value="0">Nein</option>
<option value="1">Ja</option>
</select>
<label for="check">Genügt eine einfache Sichtkontrolle im Rahmen des regelmäßigen Rundgangs?</label>
<select name="check" id="check">
<option value="-">-</option>
<option value="0">Nein</option>
<option value="1">Ja</option>
</select>
<label for="cycle">Aktueller Zyklus (in Monaten)</label>
{% 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 %}
<input name="cycle" type="number" id="cycle" disabled>
{% 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 %}
<option value="{{ key }}">{{ benchmarkValue }}</option>
{% endfor %}
</select>
<span class="btn" id="submit">Berechnen</span>
</form>
{% endblock %}

Loading…
Откажи
Сачувај