src/Entity/Building/Building.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Building;
  3. use App\Entity\Client\Client;
  4. use App\Entity\Event\Event;
  5. use App\Entity\Extension\BlameableTrait;
  6. use App\Entity\Extension\DisabledReasonTrait;
  7. use App\Entity\Extension\DisabledTrait;
  8. use App\Entity\Extension\HistoricalInterface;
  9. use App\Entity\Extension\ItemsWithHistoryTrait;
  10. use App\Entity\Extension\TimestampableTrait;
  11. use App\Entity\File;
  12. use App\Entity\Gauge\Gauge;
  13. use App\Entity\Role;
  14. use App\Repository\Building\BuildingRepository;
  15. use App\Entity\User;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\ORM\Mapping as ORM;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. /**
  21. * @ORM\Entity(repositoryClass=BuildingRepository::class)
  22. * @ORM\Table(name="buildings")
  23. */
  24. class Building
  25. {
  26. public const TYPE_BUILDING = 1;
  27. public const TYPE_PUBLIC_LIGHTNING = 2;
  28. public const TYPE_OTHER = 3;
  29. use BlameableTrait;
  30. use TimestampableTrait;
  31. use ItemsWithHistoryTrait;
  32. use DisabledTrait;
  33. use DisabledReasonTrait;
  34. /**
  35. * @var null|int
  36. * @ORM\Id()
  37. * @ORM\GeneratedValue()
  38. * @ORM\Column(type="integer")
  39. */
  40. private ?int $id = null;
  41. /**
  42. * @var Client
  43. * @ORM\ManyToOne(targetEntity="App\Entity\Client\Client", inversedBy="buildings")
  44. * @ORM\JoinColumn(name="client_id", referencedColumnName="id", nullable=false)
  45. */
  46. private Client $client;
  47. /**
  48. * @var Collection|User[]
  49. * @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="buildings")
  50. */
  51. protected $users;
  52. /**
  53. * @var Collection|File[]
  54. *
  55. * @ORM\ManyToMany(targetEntity="App\Entity\File", mappedBy="buildings", cascade={"persist"})
  56. */
  57. private $files;
  58. /**
  59. * @var File|null
  60. * @ORM\ManyToOne(targetEntity="App\Entity\File", inversedBy="buildingPhotos")
  61. * @ORM\JoinColumn(nullable=true)
  62. */
  63. private ?File $photo = null;
  64. /**
  65. * @var int
  66. * @ORM\Column(type="smallint")
  67. *
  68. * @Assert\NotBlank
  69. * @Assert\Type(type="int")
  70. */
  71. private int $type;
  72. /**
  73. * @var Sector
  74. * @ORM\ManyToOne(targetEntity="App\Entity\Building\Sector", inversedBy="buildings")
  75. * @ORM\JoinColumn(name="sector_id", referencedColumnName="id", nullable=false)
  76. * @Assert\NotBlank
  77. */
  78. private Sector $sector;
  79. /**
  80. * @var string
  81. * @ORM\Column(type="string")
  82. *
  83. * @Assert\NotBlank
  84. * @Assert\Type(type="string")
  85. */
  86. private string $name;
  87. /**
  88. * @var string|null
  89. * @ORM\Column(type="string", nullable=true)
  90. * @Assert\Type(type="string")
  91. */
  92. private ?string $ico;
  93. /**
  94. * @var string|null
  95. * @ORM\Column(type="string", nullable=true)
  96. * @Assert\Type(type="string")
  97. */
  98. private ?string $owner;
  99. /**
  100. * GID - Global Identification for Prague region
  101. * @var string|null
  102. * @ORM\Column(type="string", nullable=true)
  103. */
  104. private ?string $gid = null;
  105. /**
  106. * @var string|null
  107. * @ORM\Column(type="string", nullable=true)
  108. * @Assert\Type(type="string")
  109. */
  110. private ?string $delegatedManagerIco;
  111. /**
  112. * @var string|null
  113. * @ORM\Column(type="string", nullable=true)
  114. * @Assert\Type(type="string")
  115. */
  116. private ?string $delegatedManager;
  117. /**
  118. * @var string|null
  119. * @ORM\Column(type="string", nullable=true)
  120. * @Assert\Type(type="string")
  121. */
  122. private ?string $managerIco;
  123. /**
  124. * @var string|null
  125. * @ORM\Column(type="string", nullable=true)
  126. * @Assert\Type(type="string")
  127. */
  128. private ?string $manager;
  129. /**
  130. * @var int|null
  131. * @ORM\Column(type="integer", nullable=true)
  132. * @Assert\Type(type="integer")
  133. * @Assert\GreaterThan(0)
  134. */
  135. private ?int $builtYear;
  136. /**
  137. * @var string|null
  138. * @ORM\Column(type="text", nullable=true)
  139. * @Assert\Type(type="string")
  140. */
  141. private ?string $description;
  142. /**
  143. * @var string|null
  144. * @ORM\Column(type="string", nullable=true)
  145. * @Assert\Type(type="string")
  146. */
  147. private ?string $street = null;
  148. /**
  149. * @var string|null
  150. * @ORM\Column(type="string", nullable=true)
  151. * @Assert\Type(type="string")
  152. */
  153. private ?string $houseNumber = null;
  154. /**
  155. * @var string|null
  156. * @ORM\Column(type="string", nullable=true)
  157. * @Assert\Type(type="string")
  158. */
  159. private ?string $referenceNumber = null;
  160. /**
  161. * @var int|null
  162. * @ORM\Column(type="integer", nullable=true)
  163. * @Assert\Type(type="integer")
  164. * @Assert\Length(
  165. * min = 5,
  166. * max = 5
  167. * )
  168. */
  169. private ?int $zip = null;
  170. /**
  171. * @var string|null
  172. * @ORM\Column(type="string", nullable=true)
  173. * @Assert\Type(type="string")
  174. */
  175. private ?string $city = null;
  176. /**
  177. * @var BuildingProperties
  178. * @ORM\OneToOne(targetEntity="App\Entity\Building\BuildingProperties", mappedBy="building", cascade={"all"})
  179. */
  180. private BuildingProperties $properties; // @phpstan-ignore-line
  181. /**
  182. * @var BuildingEnergyManagement
  183. * @ORM\OneToOne(targetEntity="App\Entity\Building\BuildingEnergyManagement", mappedBy="building", cascade={"all"})
  184. */
  185. private BuildingEnergyManagement $energyManagement; // @phpstan-ignore-line
  186. /**
  187. * @var Collection|BuildingUsersQuantity[]
  188. * @ORM\OneToMany(targetEntity="App\Entity\Building\BuildingUsersQuantity", mappedBy="building", cascade={"all"})
  189. */
  190. private $buildingUsersQuantity;
  191. /**
  192. * @var Collection|BuildingHeatedArea[]
  193. * @ORM\OneToMany(targetEntity="App\Entity\Building\BuildingHeatedArea", mappedBy="building", cascade={"all"})
  194. */
  195. private $buildingHeatedArea;
  196. /**
  197. * @var Collection|BuildingUsableArea[]
  198. * @ORM\OneToMany(targetEntity="App\Entity\Building\BuildingUsableArea", mappedBy="building", cascade={"all"})
  199. */
  200. private $buildingUsableArea;
  201. /**
  202. * @var Collection|BuiltUpArea[]
  203. * @ORM\OneToMany(targetEntity="App\Entity\Building\BuiltUpArea", mappedBy="building", cascade={"all"})
  204. */
  205. private $builtUpArea;
  206. /**
  207. * @var Collection|BuildingTemperature[]
  208. * @ORM\OneToMany(targetEntity="App\Entity\Building\BuildingTemperature", mappedBy="building", cascade={"all"})
  209. */
  210. private $temperature;
  211. /**
  212. * @var Collection|PublicLightPoints[]
  213. * @ORM\OneToMany(targetEntity="App\Entity\Building\PublicLightPoints", mappedBy="building", cascade={"all"})
  214. */
  215. private $publicLightPoints;
  216. /**
  217. * @var Collection|PublicLightPointsFVE[]
  218. * @ORM\OneToMany(targetEntity="App\Entity\Building\PublicLightPointsFVE", mappedBy="building", cascade={"all"})
  219. */
  220. private $publicLightPointsFVE;
  221. /**
  222. * @var Collection|Gauge[]
  223. * @ORM\OneToMany(targetEntity="App\Entity\Gauge\Gauge", mappedBy="building")
  224. */
  225. private $gauges;
  226. /**
  227. * @var Collection|CalculatedConsumption[]
  228. * @ORM\OneToMany(targetEntity="App\Entity\Building\CalculatedConsumption", mappedBy="building", cascade={"all"})
  229. */
  230. private $calculatedConsumption;
  231. /**
  232. * @var Collection|Event[]
  233. *
  234. * @ORM\ManyToMany(targetEntity="App\Entity\Event\Event", mappedBy="buildings", cascade={"persist"})
  235. */
  236. private $events;
  237. /**
  238. * @var float|null
  239. * @ORM\Column(type="float", nullable=true)
  240. */
  241. private ?float $mapLat = null;
  242. /**
  243. * @var float|null
  244. * @ORM\Column(type="float", nullable=true)
  245. */
  246. private ?float $mapLng = null;
  247. /**
  248. * @var float|null
  249. * @ORM\Column(type="float", nullable=true)
  250. */
  251. private ?float $mapLatCustom = null;
  252. /**
  253. * @var float|null
  254. * @ORM\Column(type="float", nullable=true)
  255. */
  256. private ?float $mapLngCustom = null;
  257. /**
  258. * @var string|null
  259. * @ORM\Column(type="string", nullable=true)
  260. */
  261. private ?string $mapyCzUrl = null;
  262. /**
  263. * @var bool
  264. * @ORM\Column(type="boolean", options={"default": true})
  265. */
  266. private bool $showOnMap = true;
  267. /**
  268. * Building constructor.
  269. */
  270. public function __construct()
  271. {
  272. $this->type = self::TYPE_BUILDING;
  273. $this->properties = new BuildingProperties($this);
  274. $this->energyManagement = new BuildingEnergyManagement($this);
  275. $this->users = new ArrayCollection();
  276. $this->buildingUsersQuantity = new ArrayCollection();
  277. $this->buildingHeatedArea = new ArrayCollection();
  278. $this->buildingUsableArea = new ArrayCollection();
  279. $this->builtUpArea = new ArrayCollection();
  280. $this->temperature = new ArrayCollection();
  281. $this->publicLightPoints = new ArrayCollection();
  282. $this->publicLightPointsFVE = new ArrayCollection();
  283. $this->files = new ArrayCollection();
  284. $this->gauges = new ArrayCollection();
  285. $this->calculatedConsumption = new ArrayCollection();
  286. $this->showOnMap = true;
  287. }
  288. public function __toString(): string
  289. {
  290. return $this->getName();
  291. }
  292. /**
  293. * @param BuildingUsersQuantity $newItem
  294. * @return $this
  295. */
  296. public function addBuildingUsersQuantity(BuildingUsersQuantity $newItem): Building
  297. {
  298. $newItem->setBuilding($this);
  299. $this->buildingUsersQuantity->add($newItem);
  300. return $this;
  301. }
  302. /**
  303. * @param bool $fullVersion
  304. * @return string
  305. */
  306. public function getAddress($fullVersion = false) : string
  307. {
  308. $address = '';
  309. if ($this->getStreet() !== null) {
  310. $address .= $this->getStreet();
  311. }
  312. if ($this->getHouseNumber() !== null) {
  313. $address .= ' '.$this->getHouseNumber();
  314. }
  315. if ($this->getReferenceNumber() !== null) {
  316. $address .= '/'.$this->getReferenceNumber();
  317. }
  318. if ($fullVersion) {
  319. if ($this->getZip() !== null) {
  320. $address .= ', '.$this->getZip();
  321. }
  322. if ($this->getCity() !== null) {
  323. $address .= ' '.$this->getCity();
  324. }
  325. }
  326. return $address;
  327. }
  328. /**
  329. * @param File $file
  330. * @return $this
  331. */
  332. public function addFile(File $file): self
  333. {
  334. if (!$this->files->contains($file)) {
  335. $this->files[] = $file;
  336. $file->addBuilding($this);
  337. }
  338. return $this;
  339. }
  340. /**
  341. * @param File $file
  342. * @return $this
  343. */
  344. public function removeFile(File $file): self
  345. {
  346. if ($this->files->contains($file)) {
  347. $this->files->removeElement($file);
  348. $file->removeBuilding($this);
  349. }
  350. return $this;
  351. }
  352. /**
  353. * @return int|null
  354. */
  355. public function getId(): ?int
  356. {
  357. return $this->id;
  358. }
  359. /**
  360. * @param int|null $id
  361. * @return Building
  362. */
  363. public function setId(?int $id): Building
  364. {
  365. $this->id = $id;
  366. return $this;
  367. }
  368. /**
  369. * @return Client
  370. */
  371. public function getClient(): Client
  372. {
  373. return $this->client;
  374. }
  375. /**
  376. * @param Client $client
  377. * @return Building
  378. */
  379. public function setClient(Client $client): Building
  380. {
  381. $this->client = $client;
  382. return $this;
  383. }
  384. /**
  385. * @return User[]|Collection
  386. */
  387. public function getUsers()
  388. {
  389. return $this->users;
  390. }
  391. /**
  392. * @param User[]|Collection $users
  393. * @return Building
  394. */
  395. public function setUsers($users)
  396. {
  397. $this->users = $users;
  398. return $this;
  399. }
  400. /**
  401. * @return File[]|Collection
  402. */
  403. public function getFiles()
  404. {
  405. return $this->files;
  406. }
  407. /**
  408. * @param File[]|Collection $files
  409. * @return Building
  410. */
  411. public function setFiles($files)
  412. {
  413. $this->files = $files;
  414. return $this;
  415. }
  416. /**
  417. * @return File|null
  418. */
  419. public function getPhoto(): ?File
  420. {
  421. return $this->photo;
  422. }
  423. /**
  424. * @param File|null $photo
  425. * @return Building
  426. */
  427. public function setPhoto(?File $photo): Building
  428. {
  429. $this->photo = $photo;
  430. if ($photo !== null) {
  431. $photo->addBuilding($this);
  432. }
  433. return $this;
  434. }
  435. /**
  436. * @return int
  437. */
  438. public function getType(): int
  439. {
  440. return $this->type;
  441. }
  442. /**
  443. * @param int $type
  444. * @return Building
  445. */
  446. public function setType(int $type): Building
  447. {
  448. $this->type = $type;
  449. return $this;
  450. }
  451. /**
  452. * @return Sector
  453. */
  454. public function getSector(): Sector
  455. {
  456. return $this->sector;
  457. }
  458. /**
  459. * @param Sector $sector
  460. * @return Building
  461. */
  462. public function setSector(Sector $sector): Building
  463. {
  464. $this->sector = $sector;
  465. return $this;
  466. }
  467. /**
  468. * @return string
  469. */
  470. public function getName(): string
  471. {
  472. return $this->name;
  473. }
  474. /**
  475. * @param string $name
  476. * @return Building
  477. */
  478. public function setName(string $name): Building
  479. {
  480. $this->name = $name;
  481. return $this;
  482. }
  483. /**
  484. * @return string|null
  485. */
  486. public function getIco(): ?string
  487. {
  488. return $this->ico;
  489. }
  490. /**
  491. * @param string|null $ico
  492. * @return Building
  493. */
  494. public function setIco(?string $ico): Building
  495. {
  496. $this->ico = $ico;
  497. return $this;
  498. }
  499. public function getGid(): ?string
  500. {
  501. return $this->gid;
  502. }
  503. public function setGid(?string $gid): Building
  504. {
  505. $this->gid = $gid;
  506. return $this;
  507. }
  508. /**
  509. * @return string|null
  510. */
  511. public function getOwner(): ?string
  512. {
  513. return $this->owner;
  514. }
  515. /**
  516. * @param string|null $owner
  517. * @return Building
  518. */
  519. public function setOwner(?string $owner): Building
  520. {
  521. $this->owner = $owner;
  522. return $this;
  523. }
  524. /**
  525. * @return string|null
  526. */
  527. public function getManagerIco(): ?string
  528. {
  529. return $this->managerIco;
  530. }
  531. /**
  532. * @param string|null $managerIco
  533. * @return Building
  534. */
  535. public function setManagerIco(?string $managerIco): Building
  536. {
  537. $this->managerIco = $managerIco;
  538. return $this;
  539. }
  540. /**
  541. * @return string|null
  542. */
  543. public function getManager(): ?string
  544. {
  545. return $this->manager;
  546. }
  547. /**
  548. * @param string|null $manager
  549. * @return Building
  550. */
  551. public function setManager(?string $manager): Building
  552. {
  553. $this->manager = $manager;
  554. return $this;
  555. }
  556. /**
  557. * @return int|null
  558. */
  559. public function getBuiltYear(): ?int
  560. {
  561. return $this->builtYear;
  562. }
  563. /**
  564. * @param int|null $builtYear
  565. * @return Building
  566. */
  567. public function setBuiltYear(?int $builtYear): Building
  568. {
  569. $this->builtYear = $builtYear;
  570. return $this;
  571. }
  572. /**
  573. * @return string|null
  574. */
  575. public function getDescription(): ?string
  576. {
  577. return $this->description;
  578. }
  579. /**
  580. * @param string|null $description
  581. * @return Building
  582. */
  583. public function setDescription(?string $description): Building
  584. {
  585. $this->description = $description;
  586. return $this;
  587. }
  588. /**
  589. * @return string|null
  590. */
  591. public function getStreet(): ?string
  592. {
  593. return $this->street;
  594. }
  595. /**
  596. * @param string|null $street
  597. * @return Building
  598. */
  599. public function setStreet(?string $street): Building
  600. {
  601. $this->street = $street;
  602. return $this;
  603. }
  604. /**
  605. * @return string|null
  606. */
  607. public function getHouseNumber(): ?string
  608. {
  609. return $this->houseNumber;
  610. }
  611. /**
  612. * @param string|null $houseNumber
  613. * @return Building
  614. */
  615. public function setHouseNumber(?string $houseNumber): Building
  616. {
  617. $this->houseNumber = $houseNumber;
  618. return $this;
  619. }
  620. /**
  621. * @return string|null
  622. */
  623. public function getReferenceNumber(): ?string
  624. {
  625. return $this->referenceNumber;
  626. }
  627. /**
  628. * @param string|null $referenceNumber
  629. * @return Building
  630. */
  631. public function setReferenceNumber(?string $referenceNumber): Building
  632. {
  633. $this->referenceNumber = $referenceNumber;
  634. return $this;
  635. }
  636. /**
  637. * @return int|null
  638. */
  639. public function getZip(): ?int
  640. {
  641. return $this->zip;
  642. }
  643. /**
  644. * @param int|null $zip
  645. * @return Building
  646. */
  647. public function setZip(?int $zip): Building
  648. {
  649. $this->zip = $zip;
  650. return $this;
  651. }
  652. /**
  653. * @return string|null
  654. */
  655. public function getCity(): ?string
  656. {
  657. return $this->city;
  658. }
  659. /**
  660. * @param string|null $city
  661. * @return Building
  662. */
  663. public function setCity(?string $city): Building
  664. {
  665. $this->city = $city;
  666. return $this;
  667. }
  668. /**
  669. * @return BuildingProperties
  670. */
  671. public function getProperties(): BuildingProperties
  672. {
  673. return $this->properties;
  674. }
  675. /**
  676. * @param BuildingProperties $properties
  677. * @return Building
  678. */
  679. public function setProperties(BuildingProperties $properties): Building
  680. {
  681. $this->properties = $properties;
  682. return $this;
  683. }
  684. /**
  685. * @return BuildingEnergyManagement
  686. */
  687. public function getEnergyManagement(): BuildingEnergyManagement
  688. {
  689. return $this->energyManagement;
  690. }
  691. /**
  692. * @param BuildingEnergyManagement $energyManagement
  693. * @return Building
  694. */
  695. public function setEnergyManagement(BuildingEnergyManagement $energyManagement): Building
  696. {
  697. $this->energyManagement = $energyManagement;
  698. return $this;
  699. }
  700. /**
  701. * @return BuildingUsersQuantity[]|Collection
  702. */
  703. public function getBuildingUsersQuantity()
  704. {
  705. return $this->buildingUsersQuantity;
  706. }
  707. /**
  708. * @param BuildingUsersQuantity[]|Collection $buildingUsersQuantity
  709. * @return Building
  710. */
  711. public function setBuildingUsersQuantity($buildingUsersQuantity)
  712. {
  713. $this->buildingUsersQuantity = $buildingUsersQuantity;
  714. return $this;
  715. }
  716. /**
  717. * @return BuildingHeatedArea[]|Collection
  718. */
  719. public function getBuildingHeatedArea()
  720. {
  721. return $this->buildingHeatedArea;
  722. }
  723. /**
  724. * @param BuildingHeatedArea[]|Collection $buildingHeatedArea
  725. * @return Building
  726. */
  727. public function setBuildingHeatedArea($buildingHeatedArea)
  728. {
  729. $this->buildingHeatedArea = $buildingHeatedArea;
  730. return $this;
  731. }
  732. /**
  733. * @param BuildingHeatedArea $newItem
  734. * @return $this
  735. */
  736. public function addBuildingHeatedArea(BuildingHeatedArea $newItem): Building
  737. {
  738. $newItem->setBuilding($this);
  739. $this->buildingHeatedArea->add($newItem);
  740. return $this;
  741. }
  742. /**
  743. * @return BuildingUsableArea[]|Collection
  744. */
  745. public function getBuildingUsableArea()
  746. {
  747. return $this->buildingUsableArea;
  748. }
  749. /**
  750. * @param BuildingUsableArea[]|Collection $buildingUsableArea
  751. * @return Building
  752. */
  753. public function setBuildingUsableArea($buildingUsableArea)
  754. {
  755. $this->buildingUsableArea = $buildingUsableArea;
  756. return $this;
  757. }
  758. /**
  759. * @param BuildingUsableArea $newItem
  760. * @return $this
  761. */
  762. public function addBuildingUsableArea(BuildingUsableArea $newItem): Building
  763. {
  764. $newItem->setBuilding($this);
  765. $this->buildingUsableArea->add($newItem);
  766. return $this;
  767. }
  768. /**
  769. * @return BuiltUpArea[]|Collection
  770. */
  771. public function getBuiltUpArea()
  772. {
  773. return $this->builtUpArea;
  774. }
  775. /**
  776. * @param BuiltUpArea[]|Collection $builtUpArea
  777. * @return Building
  778. */
  779. public function setBuiltUpArea($builtUpArea)
  780. {
  781. $this->builtUpArea = $builtUpArea;
  782. return $this;
  783. }
  784. /**
  785. * @param BuiltUpArea $newItem
  786. * @return $this
  787. */
  788. public function addBuiltUpArea(BuiltUpArea $newItem): Building
  789. {
  790. $newItem->setBuilding($this);
  791. $this->builtUpArea->add($newItem);
  792. return $this;
  793. }
  794. /**
  795. * @return BuildingTemperature[]|Collection
  796. */
  797. public function getTemperature()
  798. {
  799. return $this->temperature;
  800. }
  801. /**
  802. * @param BuildingTemperature[]|Collection $temperature
  803. * @return Building
  804. */
  805. public function setTemperature($temperature)
  806. {
  807. $this->temperature = $temperature;
  808. return $this;
  809. }
  810. /**
  811. * @param BuildingTemperature $newItem
  812. * @return $this
  813. */
  814. public function addTemperature(BuildingTemperature $newItem): Building
  815. {
  816. $newItem->setBuilding($this);
  817. $this->temperature->add($newItem);
  818. return $this;
  819. }
  820. /**
  821. * @return PublicLightPoints[]|Collection
  822. */
  823. public function getPublicLightPoints()
  824. {
  825. return $this->publicLightPoints;
  826. }
  827. /**
  828. * @param PublicLightPoints[]|Collection $publicLightPoints
  829. * @return Building
  830. */
  831. public function setPublicLightPoints($publicLightPoints)
  832. {
  833. $this->publicLightPoints = $publicLightPoints;
  834. return $this;
  835. }
  836. /**
  837. * @param PublicLightPoints $newItem
  838. * @return $this
  839. */
  840. public function addPublicLightPoints(PublicLightPoints $newItem): Building
  841. {
  842. $newItem->setBuilding($this);
  843. $this->publicLightPoints->add($newItem);
  844. return $this;
  845. }
  846. /**
  847. * @return PublicLightPointsFVE[]|Collection
  848. */
  849. public function getPublicLightPointsFVE()
  850. {
  851. return $this->publicLightPointsFVE;
  852. }
  853. /**
  854. * @param PublicLightPointsFVE[]|Collection $publicLightPointsFVE
  855. * @return Building
  856. */
  857. public function setPublicLightPointsFVE($publicLightPointsFVE)
  858. {
  859. $this->publicLightPointsFVE = $publicLightPointsFVE;
  860. return $this;
  861. }
  862. /**
  863. * @param PublicLightPointsFVE $newItem
  864. * @return $this
  865. */
  866. public function addPublicLightPointsFVE(PublicLightPointsFVE $newItem): Building
  867. {
  868. $newItem->setBuilding($this);
  869. $this->publicLightPointsFVE->add($newItem);
  870. return $this;
  871. }
  872. /**
  873. * @return Gauge[]|Collection
  874. */
  875. public function getGauges()
  876. {
  877. return $this->gauges;
  878. }
  879. /**
  880. * @param Gauge[]|Collection $gauges
  881. * @return Building
  882. */
  883. public function setGauges($gauges)
  884. {
  885. $this->gauges = $gauges;
  886. return $this;
  887. }
  888. /**
  889. * @return CalculatedConsumption[]|Collection
  890. */
  891. public function getCalculatedConsumption()
  892. {
  893. return $this->calculatedConsumption;
  894. }
  895. /**
  896. * @param CalculatedConsumption[]|Collection $calculatedConsumption
  897. * @return Building
  898. */
  899. public function setCalculatedConsumption($calculatedConsumption)
  900. {
  901. $this->calculatedConsumption = $calculatedConsumption;
  902. return $this;
  903. }
  904. /**
  905. * @param CalculatedConsumption $calculatedConsumption
  906. * @return Building
  907. */
  908. public function addCalculatedConsumption(CalculatedConsumption $calculatedConsumption)
  909. {
  910. $calculatedConsumption->setBuilding($this);
  911. if ($calculatedConsumption->getMonthValues()->count() === 0) {
  912. // add month values by ratios
  913. $calculatedConsumption->addMonthValuesByRatios();
  914. }
  915. $this->calculatedConsumption->add($calculatedConsumption);
  916. return $this;
  917. }
  918. /**
  919. * @param int $usage
  920. * @param \DateTime|null $date
  921. * @return HistoricalInterface|CalculatedConsumption|mixed|null
  922. */
  923. public function getCurrentCalculatedConsumption(int $usage, ?\DateTime $date = null)
  924. {
  925. if ($date === null) {
  926. $date = new \DateTime();
  927. }
  928. $current = null;
  929. foreach ($this->getCalculatedConsumption() as $item) {
  930. if ($item->getValidFrom() <= $date
  931. && $usage === $item->getUsage()
  932. && (
  933. !$current instanceof CalculatedConsumption
  934. || $item->getValidFrom() > $current->getValidFrom()
  935. )
  936. ) {
  937. $current = $item;
  938. }
  939. }
  940. return $current;
  941. }
  942. /**
  943. * @return Event[]|Collection
  944. */
  945. public function getEvents()
  946. {
  947. return $this->events;
  948. }
  949. /**
  950. * @param Event[]|Collection $events
  951. * @return Building
  952. */
  953. public function setEvents($events)
  954. {
  955. $this->events = $events;
  956. return $this;
  957. }
  958. /**
  959. * @return string|null
  960. */
  961. public function getDelegatedManagerIco(): ?string
  962. {
  963. return $this->delegatedManagerIco;
  964. }
  965. /**
  966. * @param string|null $delegatedManagerIco
  967. * @return Building
  968. */
  969. public function setDelegatedManagerIco(?string $delegatedManagerIco): Building
  970. {
  971. $this->delegatedManagerIco = $delegatedManagerIco;
  972. return $this;
  973. }
  974. /**
  975. * @return string|null
  976. */
  977. public function getDelegatedManager(): ?string
  978. {
  979. return $this->delegatedManager;
  980. }
  981. /**
  982. * @param string|null $delegatedManager
  983. * @return Building
  984. */
  985. public function setDelegatedManager(?string $delegatedManager): Building
  986. {
  987. $this->delegatedManager = $delegatedManager;
  988. return $this;
  989. }
  990. /**
  991. * Uživatel Pracovník u daného objektu
  992. * @return User|null
  993. */
  994. public function getResponsibleUser(): ?User
  995. {
  996. foreach ($this->getUsers() as $user) {
  997. if ($user->getRole()->getName() === Role::WORKER) {
  998. return $user;
  999. }
  1000. }
  1001. return null;
  1002. }
  1003. /**
  1004. * @return float|null
  1005. */
  1006. public function getMapLat(): ?float
  1007. {
  1008. return $this->mapLat;
  1009. }
  1010. /**
  1011. * @param float|null $mapLat
  1012. * @return $this
  1013. */
  1014. public function setMapLat(?float $mapLat): self
  1015. {
  1016. $this->mapLat = $mapLat;
  1017. return $this;
  1018. }
  1019. /**
  1020. * @return float|null
  1021. */
  1022. public function getMapLng(): ?float
  1023. {
  1024. return $this->mapLng;
  1025. }
  1026. /**
  1027. * @param float|null $mapLng
  1028. * @return $this
  1029. */
  1030. public function setMapLng(?float $mapLng): self
  1031. {
  1032. $this->mapLng = $mapLng;
  1033. return $this;
  1034. }
  1035. /**
  1036. * @return float|null
  1037. */
  1038. public function getMapLatCustom(): ?float
  1039. {
  1040. return $this->mapLatCustom;
  1041. }
  1042. /**
  1043. * @param float|null $mapLatCustom
  1044. * @return $this
  1045. */
  1046. public function setMapLatCustom(?float $mapLatCustom): self
  1047. {
  1048. $this->mapLatCustom = $mapLatCustom;
  1049. return $this;
  1050. }
  1051. /**
  1052. * @return float|null
  1053. */
  1054. public function getMapLngCustom(): ?float
  1055. {
  1056. return $this->mapLngCustom;
  1057. }
  1058. /**
  1059. * @param float|null $mapLngCustom
  1060. * @return $this
  1061. */
  1062. public function setMapLngCustom(?float $mapLngCustom): self
  1063. {
  1064. $this->mapLngCustom = $mapLngCustom;
  1065. return $this;
  1066. }
  1067. public function getMapLatEffective(): ?float
  1068. {
  1069. if ($this->hasCustomMapCoordinates()) {
  1070. return $this->mapLatCustom;
  1071. }
  1072. return $this->mapLat;
  1073. }
  1074. public function getMapLngEffective(): ?float
  1075. {
  1076. if ($this->hasCustomMapCoordinates()) {
  1077. return $this->mapLngCustom;
  1078. }
  1079. return $this->mapLng;
  1080. }
  1081. private function hasCustomMapCoordinates(): bool
  1082. {
  1083. return $this->mapLatCustom !== null && $this->mapLngCustom !== null;
  1084. }
  1085. /**
  1086. * @return string|null
  1087. */
  1088. public function getMapyCzUrl(): ?string
  1089. {
  1090. return $this->mapyCzUrl;
  1091. }
  1092. /**
  1093. * @param string|null $mapyCzUrl
  1094. * @return $this
  1095. */
  1096. public function setMapyCzUrl(?string $mapyCzUrl): self
  1097. {
  1098. $this->mapyCzUrl = $mapyCzUrl;
  1099. return $this;
  1100. }
  1101. /**
  1102. * @return bool
  1103. */
  1104. public function isShowOnMap(): bool
  1105. {
  1106. return $this->showOnMap;
  1107. }
  1108. /**
  1109. * @param bool $showOnMap
  1110. * @return $this
  1111. */
  1112. public function setShowOnMap(bool $showOnMap): self
  1113. {
  1114. $this->showOnMap = $showOnMap;
  1115. return $this;
  1116. }
  1117. }