Pārlūkot izejas kodu

worksheet with no benchmark

master
Daniel pirms 2 gadiem
vecāks
revīzija
08b0b918ae
6 mainītis faili ar 70 papildinājumiem un 45 dzēšanām
  1. +1
    -1
      .idea/watcherTasks.xml
  2. +15
    -14
      httpdocs/public/assets/js/mpp-tool.js
  3. +39
    -15
      httpdocs/src/Controller/UserController.php
  4. +7
    -7
      httpdocs/src/Entity/UserWorksheet.php
  5. +1
    -1
      httpdocs/templates/base.html.twig
  6. +7
    -7
      httpdocs/templates/snippets/worksheet-result.html.twig

+ 1
- 1
.idea/watcherTasks.xml Parādīt failu

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="true">
<TaskOptions isEnabled="false">
<option name="arguments" value="$FileName$:$FileNameWithoutExtension$.css" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />


httpdocs/public/assets/js/my-bim-score.js → httpdocs/public/assets/js/mpp-tool.js Parādīt failu

@@ -225,20 +225,21 @@ function onCreateWorksheet() {
e.preventDefault();
let result = window.confirm("Sie nutzen hiermit einen Ihrer Durchgänge.");
if (result) {
// TODO: DANIEL
// $.ajax({
// url: "/create-worksheet",
// method: "post",
// data: $('#form-risk').serializeArray(),
// success: function (data) {
// console.log(data);
// window.location = "/worksheet/" + data;
// },
// error: function (xhr, msg, three) {
// messageBox(false, "Fehler bei der Anfrage.");
// },
// dataType: "json"
// });
$.ajax({
url: "/create-worksheet",
method: "post",
data: {
asset: $('#asset').val()
},
success: function (data) {
console.log(data);
window.location = "/worksheet/" + data;
},
error: function (xhr, msg, three) {
messageBox(false, "Fehler bei der Anfrage.");
},
dataType: "json"
});
}
});
}

+ 39
- 15
httpdocs/src/Controller/UserController.php Parādīt failu

@@ -131,30 +131,54 @@ class UserController extends AbstractController
return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST);
}
$params = $request->request->all();
$benchMark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']);
$calculation = $calculatorService->calculateRisk($benchMark, $params);

$benchmark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']);
/** @var DinAsset $asset */
$asset = $benchmark->getDinAsset();
$asset = $em->getRepository(DinAsset::class)->find($params['asset']);
if ($asset === null) {
return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST);
}
$assetTasks = $asset->getTasks();

$em->getConnection()->beginTransaction();
$failureProbability = null;
$failureDamage = null;
$maintenanceAdvantage = null;
$inspectionAdvantage = null;
$cycle = null;
$bandwidth = null;
$recCycleMaintenance = null;
$recCycleInspection = null;
$costDiffCurRecPercentage = null;
$costDiffCurCycleRecCycle = null;
if (array_key_exists('benchmark', $params)) {
$benchMark = $em->getRepository(DinAssetBenchmark::class)->find($params['benchmark']);
$calculation = $calculatorService->calculateRisk($benchMark, $params);
$failureProbability = Utils::$riskFailure[$params['failure']][0];
$failureDamage = Utils::$riskCosts[$params['costs']][0];
$maintenanceAdvantage = $params['maintenance'];
$inspectionAdvantage = $params['inspection'];
$cycle = $params['cycle'];
$bandwidth = $benchMark->getBandwidth();
$recCycleMaintenance = $calculation['recCycleMaintenance'];
$recCycleInspection = $calculation['recCycleInspection'];
$costDiffCurRecPercentage = $calculation['costDiffCurRecPercentage'];
$costDiffCurCycleRecCycle = $calculation['costDiffCurCycleRecCycle'];
}

$em->getConnection()->beginTransaction();
try {
$worksheet = new UserWorksheet($user);
$worksheet->setDinNumber($asset->getDinNumber());
$worksheet->setDinAssetName($asset->getName());
$worksheet->setFailureProbability(Utils::$riskFailure[$params['failure']][0]);
$worksheet->setFailureDamage(Utils::$riskCosts[$params['costs']][0]);
$worksheet->setMaintenanceAdvantage($params['maintenance']);
$worksheet->setInspectionAdvantage($params['inspection']);
$worksheet->setUserCycleMonths($params['cycle']);
$worksheet->setBandwidth($benchmark->getBandwidth());
$worksheet->setRecMaintenanceCycleMonths($calculation['recCycleMaintenance']);
$worksheet->setRecInspectionCycleMonths($calculation['recCycleInspection']);
$worksheet->setDeviationPercentage($calculation['costDiffCurRecPercentage']);
$worksheet->setDeviationCosts($calculation['costDiffCurCycleRecCycle']);
$worksheet->setFailureProbability($failureProbability);
$worksheet->setFailureDamage($failureDamage);
$worksheet->setMaintenanceAdvantage($maintenanceAdvantage);
$worksheet->setInspectionAdvantage($inspectionAdvantage);
$worksheet->setUserCycleMonths($cycle);
$worksheet->setBandwidth($bandwidth);
$worksheet->setRecMaintenanceCycleMonths($recCycleMaintenance);
$worksheet->setRecInspectionCycleMonths($recCycleInspection);
$worksheet->setDeviationPercentage($costDiffCurRecPercentage);
$worksheet->setDeviationCosts($costDiffCurCycleRecCycle);

$em->persist($worksheet);
$em->flush();


+ 7
- 7
httpdocs/src/Entity/UserWorksheet.php Parādīt failu

@@ -40,12 +40,12 @@ class UserWorksheet
protected $dinAssetName;

/**
* @ORM\Column(type="string", nullable=false)
* @ORM\Column(type="string", nullable=true)
*/
protected $failureProbability;

/**
* @ORM\Column(type="string", nullable=false)
* @ORM\Column(type="string", nullable=true)
*/
protected $failureDamage;

@@ -60,7 +60,7 @@ class UserWorksheet
protected $inspectionAdvantage;

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

@@ -70,22 +70,22 @@ class UserWorksheet
protected $bandwidth;

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

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

/**
* @ORM\Column(type="decimal", precision=10, scale=2))
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
protected $deviationCosts;

/**
* @ORM\Column(type="decimal", precision=10, scale=2))
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
protected $deviationPercentage;



+ 1
- 1
httpdocs/templates/base.html.twig Parādīt failu

@@ -14,7 +14,7 @@
{#{{ encore_entry_script_tags('app') }}#}
<script src="/assets/js/jquery-3.6.0.min.js"></script>
<script src="/assets/js/jquery.serializeObject.js"></script>
<script src="/assets/js/my-bim-score.js"></script>
<script src="/assets/js/mpp-tool.js"></script>
{% endblock %}
</head>
<body>


+ 7
- 7
httpdocs/templates/snippets/worksheet-result.html.twig Parādīt failu

@@ -4,11 +4,11 @@
<table class="mini-table">
<tr>
<td><span>Wie hoch ist die Ausfallwahrscheinlichkeit?</span></td>
<td>{{ worksheet.failureProbability }}</td>
<td>{% if worksheet.failureProbability is not null %}{{ worksheet.failureProbability }}{% else %}-{% endif %}</td>
</tr>
<tr>
<td><span>Wie hoch ist der Schaden bei Ausfall?</span></td>
<td>{{ worksheet.failureDamage }}</td>
<td>{% if worksheet.failureDamage is not null %}{{ worksheet.failureDamage }}{% else %}-{% endif %}</td>
</tr>
</table>

@@ -28,7 +28,7 @@
<table class="mini-table">
<tr>
<td><span>Aktueller Zyklus (in Monaten)</span></td>
<td>{{ worksheet.userCycleMonths }}</td>
<td>{% if worksheet.userCycleMonths is not null %}{{ worksheet.userCycleMonths }}{% else %}-{% endif %}</td>
</tr>
<tr>
<td><span>Größencluster</span></td>
@@ -40,19 +40,19 @@
<table class="mini-table">
<tr>
<td><span>Empfehlung Wartung (in Monaten)</span></td>
<td>{{ worksheet.recMaintenanceCycleMonths }}</td>
<td>{% if worksheet.recMaintenanceCycleMonths is not null %}{{ worksheet.recMaintenanceCycleMonths }}{% else %}-{% endif %}</td>
</tr>
<tr>
<td><span>Empfehlung Inspektion (in Monaten)</span></td>
<td>{{ worksheet.recInspectionCycleMonths }}</td>
<td>{% if worksheet.recInspectionCycleMonths is not null %}{{ worksheet.recInspectionCycleMonths }}{% else %}-{% endif %}</td>
</tr>
<tr>
<td><span>Einsparpotential p.a. (%)</span></td>
<td>{{ worksheet.deviationPercentage * 100 }}%</td>
<td>{% if worksheet.deviationPercentage is not null %}{{ worksheet.deviationPercentage * 100 }}%{% else %}-{% endif %}</td>
</tr>
<tr>
<td><span>Einsparpotential p.a. (€)</span></td>
<td>{{ worksheet.deviationCosts | replace({'.': ','}) }}</td>
<td>{% if worksheet.deviationCosts is not null %}{{ worksheet.deviationCosts | replace({'.': ','}) }}€{% else %}-{% endif %}</td>
</tr>
</table>



Notiek ielāde…
Atcelt
Saglabāt