diff --git a/httpdocs/import/mpp_import_din.xlsx b/httpdocs/import/mpp_import_din.xlsx
index 0ea33ec..4cb4494 100644
Binary files a/httpdocs/import/mpp_import_din.xlsx and b/httpdocs/import/mpp_import_din.xlsx differ
diff --git a/httpdocs/src/Command/CmdImportBenchmark.php b/httpdocs/src/Command/CmdImportBenchmark.php
index b05edd3..a3621e3 100755
--- a/httpdocs/src/Command/CmdImportBenchmark.php
+++ b/httpdocs/src/Command/CmdImportBenchmark.php
@@ -1,6 +1,8 @@
em->getConnection()->beginTransaction();
- $highestRow = $worksheet->getHighestRow();
- $highestColumn = $worksheet->getHighestColumn();
+ try {
+ $this->em->createQuery('DELETE FROM App\Entity\DinAssetBenchmark')->execute();
+
+ $dinAssetsByDinAndName = [];
+ $dinAssets = $this->em->getRepository(DinAsset::class)->findAll();
+ /** @var DinAsset $dinAsset */
+ foreach ($dinAssets as $dinAsset) {
+ $dinAssetsByDinAndName[$dinAsset->getDinNumber().$dinAsset->getName()] = $dinAsset;
+ }
+
+ $highestRow = $worksheet->getHighestRow();
+ $highestColumn = $worksheet->getHighestColumn();
+
+ $startRow = 2;
+ $startCol = 'A';
+
+ for ($row = $startRow; $row <= $highestRow; $row++) {
+ $rowData = [];
+ for ($col = $startCol; $col <= $highestColumn; $col++) {
+ $cell = $worksheet->getCell($col . $row);
+ $rowData[] = $cell->getValue();
+ }
+ $dinNumber = $rowData[0];
+ $name = $rowData[5];
+ $key = $dinNumber.$name;
+
+ if (!array_key_exists($key, $dinAssetsByDinAndName)) {
+ $output->writeln("No din asset found: ". $key);
+ } else {
+ /** @var DinAsset $dinAsset */
+ $dinAsset = $dinAssetsByDinAndName[$key];
+
+ $dinBenchmark = new DinAssetBenchmark();
+ $dinBenchmark->setDinAsset($dinAsset);
+ $dinBenchmark->setComponent($rowData[7]);
+ $dinBenchmark->setType($rowData[9]);
+ $dinBenchmark->setBandwidth($rowData[11]);
+ $dinBenchmark->setDeviation($rowData[16]);
+ $dinBenchmark->setAverageCosts($rowData[17]);
+ $dinBenchmark->setMinAverageCosts($rowData[18]);
+ $dinBenchmark->setMaxAverageCosts($rowData[19]);
- $startRow = 2;
- $startCol = 'A';
- for ($row = $startRow; $row <= $highestRow; $row++) {
- $rowData = [];
- for ($col = $startCol; $col <= $highestColumn; $col++) {
- $cell = $worksheet->getCell($col . $row);
- $rowData[] = $cell->getValue();
+ $this->em->persist($dinBenchmark);
+ }
}
- $worksheetData[] = $rowData;
+ $this->em->flush();
+ $this->em->getConnection()->commit();
+ } catch (\Exception $e) {
+ $this->em->getConnection()->rollBack();
}
- $a = 0;
return Command::SUCCESS;
}
diff --git a/httpdocs/src/Command/CmdImportDinAssets.php b/httpdocs/src/Command/CmdImportDinAssets.php
index d010b62..56f2d2a 100755
--- a/httpdocs/src/Command/CmdImportDinAssets.php
+++ b/httpdocs/src/Command/CmdImportDinAssets.php
@@ -50,7 +50,6 @@ class CmdImportDinAssets extends Command
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($excelFile);
- /** @var Connection $con */
$this->em->getConnection()->beginTransaction();
try {
@@ -66,7 +65,6 @@ class CmdImportDinAssets extends Command
$isDinWorksheet = $dinNumber >= 100 && $dinNumber < 1000;
if ($isDinWorksheet) {
- $worksheetData = [];
$highestRow = $worksheet->getHighestRow();
$highestColumn = $worksheet->getHighestColumn();
@@ -92,6 +90,9 @@ class CmdImportDinAssets extends Command
$dinAsset = new DinAsset();
$dinAsset->setDinNumber($rowData[0]);
$dinAsset->setName($rowData[1]);
+ $dinAsset->setCycleMonthsMin($rowData[11]);
+ $dinAsset->setCycleMonthsMax($rowData[12]);
+ $dinAsset->setCycleMonthsRecommended($rowData[13]);
$this->em->persist($dinAsset);
$this->em->flush();
$dinAssetsByDinAndName[$key] = $dinAsset;
@@ -108,12 +109,7 @@ class CmdImportDinAssets extends Command
$dinAssetTask->setSpecialist($rowData[8] !== null);
$dinAssetTask->setSkilledPersonnel($rowData[9] !== null);
$dinAssetTask->setNorm($rowData[10]);
- $dinAssetTask->setMinMonths($rowData[11]);
- $dinAssetTask->setMaxMonths($rowData[12]);
- $dinAssetTask->setMonthRecommendedInspection($rowData[13]);
- $dinAssetTask->setMonthRecommendedMaintenance($rowData[14]);
$this->em->persist($dinAssetTask);
- $this->em->flush();
}
}
}
diff --git a/httpdocs/src/Controller/UserController.php b/httpdocs/src/Controller/UserController.php
index 6f6e441..b506120 100644
--- a/httpdocs/src/Controller/UserController.php
+++ b/httpdocs/src/Controller/UserController.php
@@ -10,6 +10,7 @@ namespace App\Controller;
use App\Entity\Catalogue;
use App\Entity\CatalogueDetail;
use App\Entity\DinAsset;
+use App\Entity\DinAssetBenchmark;
use App\Entity\User;
use App\Repository\UserRepository;
use App\Utils\Utils;
@@ -67,9 +68,28 @@ class UserController extends AbstractController
$user = $this->getUser();
$dinAssets = $em->getRepository(DinAsset::class)->findAll();
+ /** @var DinAsset $initialDinAsset */
+ $initialDinAsset = null;
+ $benchmarkValues = [];
+ if (count($dinAssets) > 0) {
+ $initialDinAsset = $dinAssets[0];
+ $benchmarks = $initialDinAsset->getBenchmarks();
+ /** @var DinAssetBenchmark $benchmark */
+ foreach ($benchmarks as $benchmark) {
+ $value = $benchmark->getComponent() ? $benchmark->getComponent() . " | " : "";
+ $value.= $benchmark->getType() ? $benchmark->getType() . " | " : "";
+ $value.= $benchmark->getBandwidth() ? $benchmark->getBandwidth() . " | " : "";
+ if (substr($value, -3) === " | ") {
+ $value = rtrim($value, " | ");
+ }
+ $benchmarkValues[$benchmark->getId()] = $value;
+ }
+ }
return $this->render('pages/risk_analysis.html.twig',
[
+ 'initialDinAsset' => $initialDinAsset,
+ 'benchmarkValues' => $benchmarkValues,
'dinAssets' => $dinAssets,
'riskFailure' => Utils::$riskFailure,
'riskCosts' => Utils::$riskCosts,
diff --git a/httpdocs/src/Entity/DinAsset.php b/httpdocs/src/Entity/DinAsset.php
index bd799b4..667901d 100644
--- a/httpdocs/src/Entity/DinAsset.php
+++ b/httpdocs/src/Entity/DinAsset.php
@@ -27,11 +27,31 @@ class DinAsset
*/
protected $name;
+ /**
+ * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
+ */
+ protected $cycleMonthsMin;
+
+ /**
+ * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
+ */
+ protected $cycleMonthsMax;
+
+ /**
+ * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
+ */
+ protected $cycleMonthsRecommended;
+
/**
* @ORM\OneToMany(targetEntity="DinAssetTask", mappedBy="dinAsset", cascade={"persist", "remove"})
*/
private $tasks;
+ /**
+ * @ORM\OneToMany(targetEntity="DinAssetBenchmark", mappedBy="dinAsset", cascade={"persist", "remove"})
+ */
+ private $benchmarks;
+
/**
* @return mixed
*/
@@ -80,6 +100,54 @@ class DinAsset
$this->name = $name;
}
+ /**
+ * @return mixed
+ */
+ public function getCycleMonthsMin()
+ {
+ return $this->cycleMonthsMin;
+ }
+
+ /**
+ * @param mixed $cycleMonthsMin
+ */
+ public function setCycleMonthsMin($cycleMonthsMin): void
+ {
+ $this->cycleMonthsMin = $cycleMonthsMin;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getCycleMonthsMax()
+ {
+ return $this->cycleMonthsMax;
+ }
+
+ /**
+ * @param mixed $cycleMonthsMax
+ */
+ public function setCycleMonthsMax($cycleMonthsMax): void
+ {
+ $this->cycleMonthsMax = $cycleMonthsMax;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getCycleMonthsRecommended()
+ {
+ return $this->cycleMonthsRecommended;
+ }
+
+ /**
+ * @param mixed $cycleMonthsRecommended
+ */
+ public function setCycleMonthsRecommended($cycleMonthsRecommended): void
+ {
+ $this->cycleMonthsRecommended = $cycleMonthsRecommended;
+ }
+
/**
* @return mixed
*/
@@ -97,10 +165,19 @@ class DinAsset
}
/**
- * @param mixed $task
+ * @return mixed
*/
- public function addTask($task): void
+ public function getBenchmarks()
{
- $this->tasks[] = $task;
+ return $this->benchmarks;
}
+
+ /**
+ * @param mixed $benchmarks
+ */
+ public function setBenchmarks($benchmarks): void
+ {
+ $this->benchmarks = $benchmarks;
+ }
+
}
diff --git a/httpdocs/src/Entity/DinAssetBenchmark.php b/httpdocs/src/Entity/DinAssetBenchmark.php
new file mode 100644
index 0000000..5957422
--- /dev/null
+++ b/httpdocs/src/Entity/DinAssetBenchmark.php
@@ -0,0 +1,198 @@
+id;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getDinAsset()
+ {
+ return $this->dinAsset;
+ }
+
+ /**
+ * @param mixed $dinAsset
+ */
+ public function setDinAsset($dinAsset): void
+ {
+ $this->dinAsset = $dinAsset;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getComponent()
+ {
+ return $this->component;
+ }
+
+ /**
+ * @param mixed $component
+ */
+ public function setComponent($component): void
+ {
+ $this->component = $component;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * @param mixed $type
+ */
+ public function setType($type): void
+ {
+ $this->type = $type;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getBandwidth()
+ {
+ return $this->bandwidth;
+ }
+
+ /**
+ * @param mixed $bandwidth
+ */
+ public function setBandwidth($bandwidth): void
+ {
+ $this->bandwidth = $bandwidth;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getDeviation()
+ {
+ return $this->deviation;
+ }
+
+ /**
+ * @param mixed $deviation
+ */
+ public function setDeviation($deviation): void
+ {
+ $this->deviation = $deviation;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getAverageCosts()
+ {
+ return $this->average_costs;
+ }
+
+ /**
+ * @param mixed $average_costs
+ */
+ public function setAverageCosts($average_costs): void
+ {
+ $this->average_costs = $average_costs;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getMinAverageCosts()
+ {
+ return $this->min_average_costs;
+ }
+
+ /**
+ * @param mixed $min_average_costs
+ */
+ public function setMinAverageCosts($min_average_costs): void
+ {
+ $this->min_average_costs = $min_average_costs;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getMaxAverageCosts()
+ {
+ return $this->max_average_costs;
+ }
+
+ /**
+ * @param mixed $max_average_costs
+ */
+ public function setMaxAverageCosts($max_average_costs): void
+ {
+ $this->max_average_costs = $max_average_costs;
+ }
+
+
+}
diff --git a/httpdocs/src/Entity/DinAssetTask.php b/httpdocs/src/Entity/DinAssetTask.php
index ba5fc82..14190de 100644
--- a/httpdocs/src/Entity/DinAssetTask.php
+++ b/httpdocs/src/Entity/DinAssetTask.php
@@ -72,26 +72,6 @@ class DinAssetTask
*/
protected $norm;
- /**
- * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
- */
- protected $minMonths;
-
- /**
- * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
- */
- protected $maxMonths;
-
- /**
- * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
- */
- protected $monthRecommendedInspection;
-
- /**
- * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
- */
- protected $monthRecommendedMaintenance;
-
/**
* @return mixed
*/
@@ -260,69 +240,4 @@ class DinAssetTask
$this->norm = $norm;
}
- /**
- * @return mixed
- */
- public function getMinMonths()
- {
- return $this->minMonths;
- }
-
- /**
- * @param mixed $minMonths
- */
- public function setMinMonths($minMonths): void
- {
- $this->minMonths = $minMonths;
- }
-
- /**
- * @return mixed
- */
- public function getMaxMonths()
- {
- return $this->maxMonths;
- }
-
- /**
- * @param mixed $maxMonths
- */
- public function setMaxMonths($maxMonths): void
- {
- $this->maxMonths = $maxMonths;
- }
-
- /**
- * @return mixed
- */
- public function getMonthRecommendedInspection()
- {
- return $this->monthRecommendedInspection;
- }
-
- /**
- * @param mixed $monthRecommendedInspection
- */
- public function setMonthRecommendedInspection($monthRecommendedInspection): void
- {
- $this->monthRecommendedInspection = $monthRecommendedInspection;
- }
-
- /**
- * @return mixed
- */
- public function getMonthRecommendedMaintenance()
- {
- return $this->monthRecommendedMaintenance;
- }
-
- /**
- * @param mixed $monthRecommendedMaintenance
- */
- public function setMonthRecommendedMaintenance($monthRecommendedMaintenance): void
- {
- $this->monthRecommendedMaintenance = $monthRecommendedMaintenance;
- }
-
-
}
diff --git a/httpdocs/templates/pages/risk_analysis.html.twig b/httpdocs/templates/pages/risk_analysis.html.twig
index 2dc065b..179f29c 100644
--- a/httpdocs/templates/pages/risk_analysis.html.twig
+++ b/httpdocs/templates/pages/risk_analysis.html.twig
@@ -44,10 +44,19 @@
-
-
-
-
+
+ {% if initialDinAsset is not null %}
+
+ {% else %}
+
+ {% endif %}
+
+
+
+
{% endblock %}