src/Domain/Whater/Model/DistributionNetwork.php line 24

Open in your IDE?
  1. <?php
  2. namespace Whater\Domain\Whater\Model;
  3. use BornFree\TacticianDomainEvent\Recorder\ContainsRecordedEvents;
  4. use BornFree\TacticianDomainEvent\Recorder\EventRecorderCapabilities;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Location\Coordinate;
  8. use Location\Ellipsoid;
  9. use Location\Polygon as LocationPolygon;
  10. use LongitudeOne\Spatial\PHP\Types\Geometry\Polygon;
  11. use Ramsey\Uuid\Uuid;
  12. use Whater\Domain\Common\Exception\InvalidUUIDException;
  13. use Whater\Domain\Whater\Event\DistributionNetworkPolygonWasUpdate;
  14. use Whater\Domain\Whater\Exception\InvalidDistributionNetworkParentException;
  15. use Whater\Domain\Zones\Model\Country;
  16. /**
  17. * Class DistributionNetwork
  18. *
  19. * @package Whater\Domain\Whater\Model
  20. */
  21. class DistributionNetwork implements ContainsRecordedEvents
  22. {
  23. use EventRecorderCapabilities;
  24. const DN_STATUS_SUITABLE = 'DN_STATUS_SUITABLE';
  25. const DN_STATUS_NOT_SUITABLE = 'DN_STATUS_NOT_SUITABLE';
  26. const DN_STATUS_WITH_RESTRICTIONS = 'DN_STATUS_WITH_RESTRICTIONS';
  27. const DN_STATUS_UNKNOWN = 'DN_STATUS_UNKNOWN';
  28. const DN_TYPE_EXTERNAL = 'DN_TYPE_EXTERNAL';
  29. const DN_TYPE_INTERNAL = 'DN_TYPE_INTERNAL';
  30. const DN_TYPE_INTERMEDIATE = 'DN_TYPE_INTERMEDIATE';
  31. /**
  32. * @var string
  33. */
  34. private $uuid;
  35. /**
  36. * @var string
  37. */
  38. private $slug;
  39. /**
  40. * @var string
  41. */
  42. private $name;
  43. /**
  44. * @var string
  45. */
  46. private $details;
  47. /**
  48. * @var string
  49. */
  50. private $whaterStatus;
  51. /**
  52. * @var string
  53. */
  54. private $whaterStatusByGovernment;
  55. /**
  56. * @var \DateTime
  57. */
  58. private $whaterStatusByGovernmentUpdatedAt;
  59. /**
  60. * @var string
  61. */
  62. private $whaterStatusByOperator;
  63. /**
  64. * @var \DateTime
  65. */
  66. private $whaterStatusByOperatorUpdatedAt;
  67. /**
  68. * @var string
  69. */
  70. private $whaterStatusByUbication;
  71. /**
  72. * @var \DateTime
  73. */
  74. private $whaterStatusByUbicationUpdatedAt;
  75. /**
  76. * @var \DateTime
  77. */
  78. private $createdAt;
  79. /**
  80. * @var \DateTime
  81. */
  82. private $updatedAt;
  83. /**
  84. * @var \DateTime
  85. */
  86. private $lastAnalitycsUpdateAt;
  87. /**
  88. * @var \DateTime
  89. */
  90. private $lastSinacConnectionAt;
  91. /**
  92. * @var Collection
  93. */
  94. private $towns;
  95. /**
  96. * @var Country
  97. */
  98. private $country;
  99. /**
  100. * @var Collection
  101. */
  102. private $whaterPoints;
  103. /**
  104. * @var WhaterOrganization
  105. */
  106. private $responsableOrganizationGovernment;
  107. /**
  108. * @var WhaterOrganization
  109. */
  110. private $responsableOrganizationOperator;
  111. /**
  112. * @var WhaterOrganization
  113. */
  114. private $responsableOrganizationCorporative;
  115. /**
  116. * @var WhaterOrganization
  117. */
  118. private $responsableOrganizationUbication;
  119. /**
  120. * @var float
  121. */
  122. private $centerLatitude;
  123. /**
  124. * @var float
  125. */
  126. private $centerLongitude;
  127. /**
  128. * @var string
  129. */
  130. private $type;
  131. /**
  132. * @var Collection
  133. */
  134. private $analyticals;
  135. /**
  136. * @var Collection
  137. */
  138. private $ubications;
  139. /**
  140. * @var Collection
  141. */
  142. private $townLocations;
  143. /**
  144. * @var Collection
  145. */
  146. private $establishments;
  147. /**
  148. * @var Collection
  149. */
  150. private $valorations;
  151. /**
  152. * @var array
  153. */
  154. private $totalColor;
  155. /**
  156. * @var array
  157. */
  158. private $totalTaste;
  159. /**
  160. * @var array
  161. */
  162. private $totalSmell;
  163. /**
  164. * @var array
  165. */
  166. private $totalTurbidity;
  167. /**
  168. * @var array
  169. */
  170. private $totalGeneral;
  171. /**
  172. * @var DistributionNetwork
  173. */
  174. private $parent;
  175. /**
  176. * @var Collection
  177. */
  178. private $children;
  179. /**
  180. * @var int
  181. */
  182. private $sinacConnectionErrors;
  183. /**
  184. * @var string
  185. */
  186. private $sinacId;
  187. /**
  188. * @var Polygon
  189. */
  190. private $geometryPolygon;
  191. /**
  192. * @var float
  193. */
  194. private $geometryAreaInHa;
  195. /**
  196. * @var bool
  197. */
  198. private $notifyWhaterStatusChange;
  199. /**
  200. * @var Collection
  201. */
  202. private $ownershipRequests;
  203. /**
  204. * @var Collection
  205. */
  206. private $articles;
  207. /**
  208. * @var \DateTime
  209. */
  210. private $lastProfessionalValorationAt;
  211. /**
  212. * @var int
  213. */
  214. private $countProfessionalGeneral;
  215. /**
  216. * @var float
  217. */
  218. private $averageProfessionalGeneral;
  219. /**
  220. * @var \DateTime
  221. */
  222. private $lastUserValorationAt;
  223. /**
  224. * @var int
  225. */
  226. private $countUserGeneral;
  227. /**
  228. * @var float
  229. */
  230. private $averageUserGeneral;
  231. /**
  232. * @var Collection
  233. */
  234. private $whaterWidgetLogs;
  235. /**
  236. * @param string $distributionNetworkId
  237. * @param string $isoCode
  238. * @param string $name
  239. */
  240. public function __construct(
  241. Country $country,
  242. string $distributionNetworkId = null,
  243. string $name,
  244. string $type = DistributionNetwork::DN_TYPE_EXTERNAL,
  245. string $details = null,
  246. string $slug = null,
  247. string $sinacId = null,
  248. DistributionNetwork $parent = null
  249. ) {
  250. try {
  251. $this->uuid = Uuid::fromString($distributionNetworkId ?: Uuid::uuid4())->toString();
  252. } catch (\InvalidArgumentException $e) {
  253. throw new InvalidUUIDException();
  254. }
  255. $this->country = $country;
  256. $this->name = $name;
  257. $this->type = $type;
  258. $this->details = $details;
  259. $this->slug = $slug;
  260. $this->whaterPoints = new ArrayCollection();
  261. $this->towns = new ArrayCollection();
  262. $this->sinacId = $sinacId;
  263. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  264. $this->centerLongitude = round($country->longitude(), 8);
  265. $this->centerLatitude = round($country->latitude(), 8);
  266. $this->geometryPolygon = new Polygon([[
  267. [$this->centerLongitude + 0.005, $this->centerLatitude + 0.005],
  268. [$this->centerLongitude + 0.005, $this->centerLatitude - 0.005],
  269. [$this->centerLongitude - 0.005, $this->centerLatitude - 0.005],
  270. [$this->centerLongitude - 0.005, $this->centerLatitude + 0.005],
  271. [$this->centerLongitude + 0.005, $this->centerLatitude + 0.005]
  272. ]]);
  273. $this->countUserGeneral = 0;
  274. $this->countProfessionalGeneral = 0;
  275. $this->averageProfessionalGeneral = null;
  276. $this->averageUserGeneral = null;
  277. $this->geometryAreaInHa = 100;
  278. $this->createdAt = new \DateTime();
  279. $this->updatedAt = new \DateTime();
  280. $this->analyticals = new ArrayCollection();
  281. $this->children = new ArrayCollection();
  282. $this->ubications = new ArrayCollection();
  283. $this->townLocations = new ArrayCollection();
  284. $this->establishments = new ArrayCollection();
  285. $this->valorations = new ArrayCollection();
  286. $this->articles = new ArrayCollection();
  287. $this->whaterWidgetLogs = new ArrayCollection();
  288. $this->parent = $parent;
  289. $this->sinacConnectionErrors = 0;
  290. $this->notifyWhaterStatusChange = false;
  291. $this->ownershipRequests = new ArrayCollection();
  292. if ($type == DistributionNetwork::DN_TYPE_INTERMEDIATE) {
  293. if ($this->parent == null) {
  294. throw new InvalidDistributionNetworkParentException();
  295. } else if ($this->parent()->type != DistributionNetwork::DN_TYPE_EXTERNAL) {
  296. throw new InvalidDistributionNetworkParentException();
  297. }
  298. } else if ($type == DistributionNetwork::DN_TYPE_INTERNAL) {
  299. if ($this->parent == null) {
  300. throw new InvalidDistributionNetworkParentException();
  301. } else if ($this->parent()->type != DistributionNetwork::DN_TYPE_INTERMEDIATE) {
  302. throw new InvalidDistributionNetworkParentException();
  303. }
  304. }
  305. }
  306. public function editDistributionNetwork(
  307. Country $country,
  308. string $name,
  309. string $slug,
  310. string $details = null,
  311. string $sinacId = null
  312. ) {
  313. $this->country = $country;
  314. $this->name = $name;
  315. $this->slug = $slug;
  316. $this->details = $details;
  317. $this->sinacId = $sinacId;
  318. $this->updatedAt = new \DateTime();
  319. return $this;
  320. }
  321. public function editPolygon(
  322. Polygon $geometryPolygon
  323. ) {
  324. $this->geometryPolygon = $geometryPolygon;
  325. $this->record(new DistributionNetworkPolygonWasUpdate($this));
  326. }
  327. public function editCenterAndArea(
  328. float $centerLatitude = null,
  329. float $centerLongitude = null,
  330. float $geometryAreaInHa = null
  331. ) {
  332. if ($centerLatitude != null) {
  333. $this->centerLatitude = $centerLatitude;
  334. }
  335. if ($centerLongitude != null) {
  336. $this->centerLongitude = $centerLongitude;
  337. }
  338. if ($geometryAreaInHa != null) {
  339. $this->geometryAreaInHa = $geometryAreaInHa;
  340. }
  341. }
  342. public function updateAnalitycsUpdateTime(\DateTime $lastAnalitycsUpdateAt = null)
  343. {
  344. if ($lastAnalitycsUpdateAt != null) {
  345. $this->lastAnalitycsUpdateAt = $lastAnalitycsUpdateAt;
  346. } else if (count($this->analyticals()) == 0) {
  347. $this->lastAnalitycsUpdateAt = new \DateTime();
  348. } else {
  349. $arrAnalyticals = $this->analyticals()->toArray();
  350. usort($arrAnalyticals, function ($a1, $a2) {
  351. return $a1->analyzedAt() < $a2->analyzedAt();
  352. });
  353. $this->lastAnalitycsUpdateAt = $arrAnalyticals[0]->analyzedAt();
  354. }
  355. }
  356. public function updateWhaterStatus(string $whaterStatus = null)
  357. {
  358. $oldWhaterStatus = $this->whaterStatus;
  359. if ($whaterStatus != null) {
  360. switch ($whaterStatus) {
  361. case DistributionNetwork::DN_STATUS_SUITABLE:
  362. case Analytical::ANALYTICAL_SUITABLE:
  363. $this->whaterStatus = DistributionNetwork::DN_STATUS_SUITABLE;
  364. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_SUITABLE) {
  365. $this->notifyWhaterStatusChange = true;
  366. } else {
  367. $this->notifyWhaterStatusChange = false;
  368. }
  369. break;
  370. case DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  371. case Analytical::ANALYTICAL_NOT_SUITABLE:
  372. $this->whaterStatus = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  373. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_NOT_SUITABLE) {
  374. $this->notifyWhaterStatusChange = true;
  375. } else {
  376. $this->notifyWhaterStatusChange = false;
  377. }
  378. break;
  379. case DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS:
  380. $this->whaterStatus = DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS;
  381. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS) {
  382. $this->notifyWhaterStatusChange = true;
  383. } else {
  384. $this->notifyWhaterStatusChange = false;
  385. }
  386. break;
  387. case DistributionNetwork::DN_STATUS_UNKNOWN;
  388. case Analytical::ANALYTICAL_UNKNOWN:
  389. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  390. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  391. $this->notifyWhaterStatusChange = true;
  392. } else {
  393. $this->notifyWhaterStatusChange = false;
  394. }
  395. break;
  396. default:
  397. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  398. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  399. $this->notifyWhaterStatusChange = true;
  400. } else {
  401. $this->notifyWhaterStatusChange = false;
  402. }
  403. }
  404. } else {
  405. $arrAnalyticals = $this->analyticals()->toArray();
  406. usort($arrAnalyticals, function ($a1, $a2) {
  407. return $a1->analyzedAt() < $a2->analyzedAt();
  408. });
  409. if (count($arrAnalyticals) > 0) {
  410. $lastAnaytical = $arrAnalyticals[0];
  411. switch ($lastAnaytical->result()) {
  412. case Analytical::ANALYTICAL_NOT_SUITABLE:
  413. $this->whaterStatus = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  414. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_NOT_SUITABLE) {
  415. $this->notifyWhaterStatusChange = true;
  416. } else {
  417. $this->notifyWhaterStatusChange = false;
  418. }
  419. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  420. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  421. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  422. }
  423. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  424. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  425. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  426. }
  427. if ($this->whaterStatusByUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->whaterStatusByUbication)) {
  428. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  429. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  430. }
  431. break;
  432. case Analytical::ANALYTICAL_SUITABLE:
  433. $this->whaterStatus = DistributionNetwork::DN_STATUS_SUITABLE;
  434. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_SUITABLE) {
  435. $this->notifyWhaterStatusChange = true;
  436. } else {
  437. $this->notifyWhaterStatusChange = false;
  438. }
  439. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  440. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_SUITABLE;
  441. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  442. }
  443. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  444. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_SUITABLE;
  445. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  446. }
  447. if ($this->responsableOrganizationUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationUbication)) {
  448. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_SUITABLE;
  449. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  450. }
  451. break;
  452. case Analytical::ANALYTICAL_UNKNOWN:
  453. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  454. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  455. $this->notifyWhaterStatusChange = true;
  456. } else {
  457. $this->notifyWhaterStatusChange = false;
  458. }
  459. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  460. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_UNKNOWN;
  461. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  462. }
  463. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  464. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_UNKNOWN;
  465. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  466. }
  467. if ($this->responsableOrganizationUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationUbication)) {
  468. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_UNKNOWN;
  469. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  470. }
  471. break;
  472. default:
  473. break;
  474. }
  475. if ($lastAnaytical->analyzedAt() > $this->lastAnalitycsUpdateAt) {
  476. $this->lastAnalitycsUpdateAt = $lastAnaytical->analyzedAt();
  477. }
  478. } else {
  479. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  480. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  481. $this->notifyWhaterStatusChange = true;
  482. } else {
  483. $this->notifyWhaterStatusChange = false;
  484. }
  485. }
  486. }
  487. // update all whaterpoint status
  488. $this->updateWhaterPointsStatus();
  489. }
  490. public function updateWhaterPointsStatus()
  491. {
  492. foreach ($this->whaterPoints() as $whaterPoint) {
  493. $whaterPoint->updateWhaterStatus();
  494. }
  495. }
  496. public function updateSinacConnectionErrors(
  497. int $sinacConnectionErrors,
  498. \DateTime $lastSinacConnectionAt
  499. ) {
  500. $this->sinacConnectionErrors = $sinacConnectionErrors;
  501. $this->lastSinacConnectionAt = $lastSinacConnectionAt;
  502. }
  503. /**
  504. * @return string
  505. */
  506. public function id(): string
  507. {
  508. return $this->uuid;
  509. }
  510. /**
  511. * @return string
  512. */
  513. public function name(): string
  514. {
  515. return $this->name;
  516. }
  517. /**
  518. * @return string
  519. */
  520. public function details(): ?string
  521. {
  522. return $this->details;
  523. }
  524. /**
  525. * @return string
  526. */
  527. public function slug(): string
  528. {
  529. return $this->slug;
  530. }
  531. /**
  532. * @return string
  533. */
  534. public function whaterStatus(): string
  535. {
  536. return $this->whaterStatus;
  537. }
  538. /**
  539. * @return string
  540. */
  541. public function whaterStatusByGovernment(): ?string
  542. {
  543. return $this->whaterStatusByGovernment;
  544. }
  545. /**
  546. * @return \DateTime
  547. */
  548. public function whaterStatusByGovernmentUpdatedAt(): ?\DateTime
  549. {
  550. return $this->whaterStatusByGovernmentUpdatedAt;
  551. }
  552. /**
  553. * @return string
  554. */
  555. public function whaterStatusByOperator(): ?string
  556. {
  557. return $this->whaterStatusByOperator;
  558. }
  559. /**
  560. * @return \DateTime
  561. */
  562. public function whaterStatusByOperatorUpdatedAt(): ?\DateTime
  563. {
  564. return $this->whaterStatusByOperatorUpdatedAt;
  565. }
  566. /**
  567. * @return string
  568. */
  569. public function whaterStatusByUbication(): ?string
  570. {
  571. return $this->whaterStatusByUbication;
  572. }
  573. /**
  574. * @return \DateTime
  575. */
  576. public function whaterStatusByUbicationUpdatedAt(): ?\DateTime
  577. {
  578. return $this->whaterStatusByUbicationUpdatedAt;
  579. }
  580. /**
  581. * @return Collection
  582. */
  583. public function whaterPoints(): Collection
  584. {
  585. return $this->whaterPoints;
  586. }
  587. /**
  588. * @return Collection
  589. */
  590. public function towns(): Collection
  591. {
  592. return $this->towns;
  593. }
  594. /**
  595. * @return Country
  596. */
  597. public function country(): Country
  598. {
  599. return $this->country;
  600. }
  601. /**
  602. * @return Collection
  603. */
  604. public function ownershipRequests(): Collection
  605. {
  606. return $this->ownershipRequests;
  607. }
  608. public function lastAnalytical(): ?Analytical
  609. {
  610. $lastAnalytical = null;
  611. $arrAnalyticals = $this->analyticals()->toArray();
  612. usort($arrAnalyticals, function ($a1, $a2) {
  613. return $a1->analyzedAt() < $a2->analyzedAt();
  614. });
  615. if (count($arrAnalyticals) > 0) {
  616. $lastAnalytical = $arrAnalyticals[0];
  617. }
  618. return $lastAnalytical;
  619. }
  620. public function updateResponsables(
  621. WhaterOrganization $responsableOrganizationGovernment = null,
  622. WhaterOrganization $responsableOrganizationOperator = null,
  623. WhaterOrganization $responsableOrganizationCorporative = null,
  624. WhaterOrganization $responsableOrganizationUbication = null
  625. ) {
  626. $this->responsableOrganizationGovernment = $responsableOrganizationGovernment;
  627. $this->responsableOrganizationOperator = $responsableOrganizationOperator;
  628. $this->responsableOrganizationCorporative = $responsableOrganizationCorporative;
  629. $this->responsableOrganizationUbication = $responsableOrganizationUbication;
  630. $this->updatedAt = new \DateTime();
  631. }
  632. public function updateResponsableOrganizationOperator(
  633. WhaterOrganization $responsableOrganizationOperator = null,
  634. ) {
  635. $this->responsableOrganizationOperator = $responsableOrganizationOperator;
  636. $this->updatedAt = new \DateTime();
  637. }
  638. public function updateValorations()
  639. {
  640. $sumUserColor = array(
  641. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  642. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  643. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  644. );
  645. $sumUserTaste = array(
  646. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  647. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  648. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  649. );
  650. $sumUserSmell = array(
  651. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  652. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  653. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  654. );
  655. $sumUserTurbidity = array(
  656. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  657. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  658. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  659. );
  660. $sumUserGeneral = array(
  661. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  662. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  663. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  664. );
  665. $countUserColor = 0;
  666. $countUserTaste = 0;
  667. $countUserSmell = 0;
  668. $countUserTurbidity = 0;
  669. $countUserGeneral = 0;
  670. $sumProfessionalColor = array(
  671. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  672. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  673. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  674. );
  675. $sumProfessionalTaste = array(
  676. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  677. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  678. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  679. );
  680. $sumProfessionalSmell = array(
  681. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  682. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  683. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  684. );
  685. $sumProfessionalTurbidity = array(
  686. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  687. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  688. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  689. );
  690. $sumProfessionalGeneral = array(
  691. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  692. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  693. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  694. );
  695. $countProfessionalColor = 0;
  696. $countProfessionalTaste = 0;
  697. $countProfessionalSmell = 0;
  698. $countProfessionalTurbidity = 0;
  699. $countProfessionalGeneral = 0;
  700. foreach ($this->valorations() as $valoration) {
  701. if ($valoration->isProfessionalValoration()) {
  702. if (
  703. $this->lastProfessionalValorationAt == null ||
  704. $this->lastProfessionalValorationAt < $valoration->createdAt()
  705. ) {
  706. $this->lastProfessionalValorationAt = $valoration->createdAt();
  707. }
  708. if ($valoration->colorValoration() != null) {
  709. switch ($valoration->colorValoration()) {
  710. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  711. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  712. break;
  713. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  714. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  715. break;
  716. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  717. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  718. break;
  719. default:
  720. break;
  721. }
  722. $countProfessionalColor++;
  723. }
  724. if ($valoration->tasteValoration() != null) {
  725. switch ($valoration->tasteValoration()) {
  726. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  727. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  728. break;
  729. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  730. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  731. break;
  732. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  733. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  734. break;
  735. default:
  736. break;
  737. }
  738. $countProfessionalTaste++;
  739. }
  740. if ($valoration->smellValoration() != null) {
  741. switch ($valoration->smellValoration()) {
  742. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  743. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  744. break;
  745. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  746. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  747. break;
  748. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  749. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  750. break;
  751. default:
  752. break;
  753. }
  754. $countProfessionalSmell++;
  755. }
  756. if ($valoration->turbidityValoration() != null) {
  757. switch ($valoration->turbidityValoration()) {
  758. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  759. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  760. break;
  761. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  762. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  763. break;
  764. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  765. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  766. break;
  767. default:
  768. break;
  769. }
  770. $countProfessionalTurbidity++;
  771. }
  772. if ($valoration->generalValoration() != null) {
  773. switch ($valoration->generalValoration()) {
  774. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  775. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  776. break;
  777. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  778. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  779. break;
  780. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  781. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  782. break;
  783. default:
  784. break;
  785. }
  786. $countProfessionalGeneral++;
  787. }
  788. } else {
  789. if (
  790. $this->lastUserValorationAt == null ||
  791. $this->lastUserValorationAt < $valoration->createdAt()
  792. ) {
  793. $this->lastUserValorationAt = $valoration->createdAt();
  794. }
  795. if ($valoration->colorValoration() != null) {
  796. switch ($valoration->colorValoration()) {
  797. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  798. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  799. break;
  800. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  801. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  802. break;
  803. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  804. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  805. break;
  806. default:
  807. break;
  808. }
  809. $countUserColor++;
  810. }
  811. if ($valoration->tasteValoration() != null) {
  812. switch ($valoration->tasteValoration()) {
  813. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  814. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  815. break;
  816. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  817. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  818. break;
  819. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  820. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  821. break;
  822. default:
  823. break;
  824. }
  825. $countUserTaste++;
  826. }
  827. if ($valoration->smellValoration() != null) {
  828. switch ($valoration->smellValoration()) {
  829. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  830. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  831. break;
  832. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  833. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  834. break;
  835. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  836. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  837. break;
  838. default:
  839. break;
  840. }
  841. $countUserSmell++;
  842. }
  843. if ($valoration->turbidityValoration() != null) {
  844. switch ($valoration->turbidityValoration()) {
  845. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  846. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  847. break;
  848. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  849. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  850. break;
  851. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  852. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  853. break;
  854. default:
  855. break;
  856. }
  857. $countUserTurbidity++;
  858. }
  859. if ($valoration->generalValoration() != null) {
  860. switch ($valoration->generalValoration()) {
  861. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  862. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  863. break;
  864. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  865. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  866. break;
  867. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  868. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  869. break;
  870. default:
  871. break;
  872. }
  873. $countUserGeneral++;
  874. }
  875. }
  876. }
  877. // count valoration
  878. $this->countProfessionalGeneral = $countProfessionalGeneral;
  879. $this->countUserGeneral = $countUserGeneral;
  880. // calculate average valoration for color, taste, smell and turbidity
  881. if ($countProfessionalColor + $countUserColor > 0) {
  882. foreach ($sumUserColor as $key => $value) {
  883. $this->totalColor[$key] = $sumUserColor[$key] + $sumProfessionalColor[$key];
  884. }
  885. } else {
  886. $this->totalColor = array(
  887. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  888. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  889. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  890. );
  891. }
  892. if ($countProfessionalTaste + $countUserTaste > 0) {
  893. foreach ($sumUserTaste as $key => $value) {
  894. $this->totalTaste[$key] = $sumUserTaste[$key] + $sumProfessionalTaste[$key];
  895. }
  896. } else {
  897. $this->totalTaste = array(
  898. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  899. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  900. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  901. );
  902. }
  903. if ($countProfessionalSmell + $countUserSmell > 0) {
  904. foreach ($sumUserSmell as $key => $value) {
  905. $this->totalSmell[$key] = $sumUserSmell[$key] + $sumProfessionalSmell[$key];
  906. }
  907. } else {
  908. $this->totalSmell = array(
  909. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  910. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  911. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  912. );
  913. }
  914. if ($countProfessionalTurbidity + $countUserTurbidity > 0) {
  915. foreach ($sumUserTurbidity as $key => $value) {
  916. $this->totalTurbidity[$key] = $sumUserTurbidity[$key] + $sumProfessionalTurbidity[$key];
  917. }
  918. } else {
  919. $this->totalTurbidity = array(
  920. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  921. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  922. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  923. );
  924. }
  925. if ($countProfessionalGeneral + $countUserGeneral > 0) {
  926. foreach ($sumUserGeneral as $key => $value) {
  927. $this->totalGeneral[$key] = $sumUserGeneral[$key] + $sumProfessionalGeneral[$key];
  928. }
  929. } else {
  930. $this->totalGeneral = array(
  931. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  932. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  933. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  934. );
  935. }
  936. // calculate average valoration for users and professionals
  937. if ($this->countProfessionalGeneral > 0) {
  938. $averageProfessionalGeneral =
  939. (($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION] * 10) +
  940. ($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION] * 5) +
  941. ($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION] * 0)) / $this->countProfessionalGeneral;
  942. $this->averageProfessionalGeneral = round($averageProfessionalGeneral, 2);
  943. } else {
  944. $this->averageProfessionalGeneral = null;
  945. }
  946. if ($this->countUserGeneral > 0) {
  947. $averageUserGeneral =
  948. (($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION] * 10) +
  949. ($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION] * 5) +
  950. ($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION] * 0)) / $this->countUserGeneral;
  951. $this->averageUserGeneral = round($averageUserGeneral, 2);
  952. } else {
  953. $this->averageUserGeneral = null;
  954. }
  955. }
  956. /**
  957. * @return string
  958. */
  959. public function sinacId(): ?string
  960. {
  961. return $this->sinacId;
  962. }
  963. /**
  964. * @return \DateTime
  965. */
  966. public function createdAt(): \DateTime
  967. {
  968. return $this->createdAt;
  969. }
  970. /**
  971. * @return \DateTime
  972. */
  973. public function updatedAt(): \DateTime
  974. {
  975. return $this->updatedAt;
  976. }
  977. /**
  978. * @return \DateTime
  979. */
  980. public function lastAnalitycsUpdateAt(): ?\DateTime
  981. {
  982. return $this->lastAnalitycsUpdateAt;
  983. }
  984. /**
  985. * @return float
  986. */
  987. public function centerLatitude(): float
  988. {
  989. if ($this->centerLatitude == null) {
  990. return 0;
  991. }
  992. return $this->centerLatitude;
  993. }
  994. /**
  995. * @return float
  996. */
  997. public function centerLongitude(): float
  998. {
  999. if ($this->centerLongitude == null) {
  1000. return 0;
  1001. }
  1002. return $this->centerLongitude;
  1003. }
  1004. /**
  1005. * @return Polygon
  1006. */
  1007. public function geometryPolygon(): ?Polygon
  1008. {
  1009. return $this->geometryPolygon;
  1010. }
  1011. /**
  1012. * @return LocationPolygon
  1013. */
  1014. public function locationPolygon(): ?LocationPolygon
  1015. {
  1016. if ($this->geometryPolygon() != null) {
  1017. $pol = new LocationPolygon();
  1018. $points = $this->geometryPolygon()->toArray();
  1019. foreach ($points[0] as $point) {
  1020. $lat = $point[1];
  1021. $long = $point[0];
  1022. $pol->addPoint(new Coordinate($lat, $long, Ellipsoid::createDefault()));
  1023. }
  1024. return $pol;
  1025. }
  1026. return null;
  1027. }
  1028. public function getGeoJsonPolygon(): ?string
  1029. {
  1030. if ($this->geometryPolygon() != null) {
  1031. $geoJsonCoordinates = [];
  1032. // Recorre los anillos (exterior + huecos si existen)
  1033. foreach ($this->geometryPolygon()->getRings() as $ring) {
  1034. $ringCoordinates = [];
  1035. // Recorre los puntos del anillo
  1036. foreach ($ring->getPoints() as $point) {
  1037. $ringCoordinates[] = [$point->getLongitude(), $point->getLatitude()];
  1038. }
  1039. // Cierra el anillo si no está cerrado
  1040. if ($ringCoordinates[0] !== $ringCoordinates[count($ringCoordinates) - 1]) {
  1041. $ringCoordinates[] = $ringCoordinates[0];
  1042. }
  1043. // Añade el anillo a las coordenadas del GeoJSON
  1044. $geoJsonCoordinates[] = $ringCoordinates;
  1045. }
  1046. // Construye el GeoJSON
  1047. $geoJson = [
  1048. "type" => "Polygon",
  1049. "coordinates" => $geoJsonCoordinates
  1050. ];
  1051. return json_encode($geoJson, JSON_PRETTY_PRINT);
  1052. }
  1053. return null;
  1054. }
  1055. /**
  1056. * @return float
  1057. */
  1058. public function geometryAreaInHa(): ?float
  1059. {
  1060. return $this->geometryAreaInHa;
  1061. }
  1062. /**
  1063. * @return Collection
  1064. */
  1065. public function analyticals(): Collection
  1066. {
  1067. return $this->analyticals;
  1068. }
  1069. /**
  1070. * @return string
  1071. */
  1072. public function type(): string
  1073. {
  1074. return $this->type;
  1075. }
  1076. /**
  1077. * @return Collection
  1078. */
  1079. public function ubications(): Collection
  1080. {
  1081. return $this->ubications;
  1082. }
  1083. /**
  1084. * @return Collection
  1085. */
  1086. public function townLocations(): Collection
  1087. {
  1088. return $this->townLocations;
  1089. }
  1090. /**
  1091. * @return bool
  1092. */
  1093. public function equals(DistributionNetwork $distributionNetwork)
  1094. {
  1095. return $this->id() === $distributionNetwork->id();
  1096. }
  1097. /**
  1098. * @return Collection
  1099. */
  1100. public function establishments(): Collection
  1101. {
  1102. return $this->establishments;
  1103. }
  1104. /**
  1105. * @return Collection
  1106. */
  1107. public function valorations(): Collection
  1108. {
  1109. return $this->valorations;
  1110. }
  1111. /**
  1112. * @return Collection
  1113. */
  1114. public function children(): Collection
  1115. {
  1116. return $this->children;
  1117. }
  1118. /**
  1119. * @return null|DistributionNetwork
  1120. */
  1121. public function parent(): ?DistributionNetwork
  1122. {
  1123. return $this->parent;
  1124. }
  1125. /**
  1126. * @return int
  1127. */
  1128. public function sinacConnectionErrors(): int
  1129. {
  1130. return $this->sinacConnectionErrors;
  1131. }
  1132. /**
  1133. * @return \DateTime
  1134. */
  1135. public function lastSinacConnectionAt(): ?\DateTime
  1136. {
  1137. return $this->lastSinacConnectionAt;
  1138. }
  1139. /**
  1140. * @return WhaterOrganization
  1141. */
  1142. public function responsableOrganizationGovernment(): ?WhaterOrganization
  1143. {
  1144. return $this->responsableOrganizationGovernment;
  1145. }
  1146. /**
  1147. * @return WhaterOrganization
  1148. */
  1149. public function responsableOrganizationOperator(): ?WhaterOrganization
  1150. {
  1151. return $this->responsableOrganizationOperator;
  1152. }
  1153. /**
  1154. * @return WhaterOrganization
  1155. */
  1156. public function responsableOrganizationCorporative(): ?WhaterOrganization
  1157. {
  1158. return $this->responsableOrganizationCorporative;
  1159. }
  1160. /**
  1161. * @return WhaterOrganization
  1162. */
  1163. public function responsableOrganizationUbication(): ?WhaterOrganization
  1164. {
  1165. return $this->responsableOrganizationUbication;
  1166. }
  1167. /**
  1168. * @return bool
  1169. */
  1170. public function notifyWhaterStatusChange(): bool
  1171. {
  1172. return $this->notifyWhaterStatusChange;
  1173. }
  1174. /**
  1175. * @return Collection
  1176. */
  1177. public function articles(): Collection
  1178. {
  1179. return $this->articles;
  1180. }
  1181. /**
  1182. * @return Collection
  1183. */
  1184. public function whaterWidgetLogs(): Collection
  1185. {
  1186. return $this->whaterWidgetLogs;
  1187. }
  1188. /**
  1189. * @return array
  1190. */
  1191. public function totalColor(): ?array
  1192. {
  1193. return $this->totalColor;
  1194. }
  1195. /**
  1196. * @return array
  1197. */
  1198. public function totalTaste(): ?array
  1199. {
  1200. return $this->totalTaste;
  1201. }
  1202. /**
  1203. * @return array
  1204. */
  1205. public function totalSmell(): ?array
  1206. {
  1207. return $this->totalSmell;
  1208. }
  1209. /**
  1210. * @return array
  1211. */
  1212. public function totalTurbidity(): ?array
  1213. {
  1214. return $this->totalTurbidity;
  1215. }
  1216. /**
  1217. * @return array
  1218. */
  1219. public function totalGeneral(): ?array
  1220. {
  1221. return $this->totalGeneral;
  1222. }
  1223. /**
  1224. * @return \DateTime
  1225. */
  1226. public function lastProfessionalValorationAt(): ?\DateTime
  1227. {
  1228. return $this->lastProfessionalValorationAt;
  1229. }
  1230. /**
  1231. * @return int
  1232. */
  1233. public function countProfessionalGeneral(): int
  1234. {
  1235. return $this->countProfessionalGeneral;
  1236. }
  1237. /**
  1238. * @return float
  1239. */
  1240. public function averageProfessionalGeneral(): ?float
  1241. {
  1242. return $this->averageProfessionalGeneral;
  1243. }
  1244. /**
  1245. * @return \DateTime
  1246. */
  1247. public function lastUserValorationAt(): ?\DateTime
  1248. {
  1249. return $this->lastUserValorationAt;
  1250. }
  1251. /**
  1252. * @return int
  1253. */
  1254. public function countUserGeneral(): int
  1255. {
  1256. return $this->countUserGeneral;
  1257. }
  1258. /**
  1259. * @return float
  1260. */
  1261. public function averageUserGeneral(): ?float
  1262. {
  1263. return $this->averageUserGeneral;
  1264. }
  1265. }