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. * @param string $distributionNetworkId
  233. * @param string $isoCode
  234. * @param string $name
  235. */
  236. public function __construct(
  237. Country $country,
  238. string $distributionNetworkId = null,
  239. string $name,
  240. string $type = DistributionNetwork::DN_TYPE_EXTERNAL,
  241. string $details = null,
  242. string $slug = null,
  243. string $sinacId = null,
  244. DistributionNetwork $parent = null
  245. ) {
  246. try {
  247. $this->uuid = Uuid::fromString($distributionNetworkId ?: Uuid::uuid4())->toString();
  248. } catch (\InvalidArgumentException $e) {
  249. throw new InvalidUUIDException();
  250. }
  251. $this->country = $country;
  252. $this->name = $name;
  253. $this->type = $type;
  254. $this->details = $details;
  255. $this->slug = $slug;
  256. $this->whaterPoints = new ArrayCollection();
  257. $this->towns = new ArrayCollection();
  258. $this->sinacId = $sinacId;
  259. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  260. $this->centerLongitude = round($country->longitude(), 8);
  261. $this->centerLatitude = round($country->latitude(), 8);
  262. $this->geometryPolygon = new Polygon([[
  263. [$this->centerLongitude + 0.005, $this->centerLatitude + 0.005],
  264. [$this->centerLongitude + 0.005, $this->centerLatitude - 0.005],
  265. [$this->centerLongitude - 0.005, $this->centerLatitude - 0.005],
  266. [$this->centerLongitude - 0.005, $this->centerLatitude + 0.005],
  267. [$this->centerLongitude + 0.005, $this->centerLatitude + 0.005]
  268. ]]);
  269. $this->countUserGeneral = 0;
  270. $this->countProfessionalGeneral = 0;
  271. $this->averageProfessionalGeneral = null;
  272. $this->averageUserGeneral = null;
  273. $this->geometryAreaInHa = 100;
  274. $this->createdAt = new \DateTime();
  275. $this->updatedAt = new \DateTime();
  276. $this->analyticals = new ArrayCollection();
  277. $this->children = new ArrayCollection();
  278. $this->ubications = new ArrayCollection();
  279. $this->townLocations = new ArrayCollection();
  280. $this->establishments = new ArrayCollection();
  281. $this->valorations = new ArrayCollection();
  282. $this->articles = new ArrayCollection();
  283. $this->parent = $parent;
  284. $this->sinacConnectionErrors = 0;
  285. $this->notifyWhaterStatusChange = false;
  286. $this->ownershipRequests = new ArrayCollection();
  287. if ($type == DistributionNetwork::DN_TYPE_INTERMEDIATE) {
  288. if ($this->parent == null) {
  289. throw new InvalidDistributionNetworkParentException();
  290. } else if ($this->parent()->type != DistributionNetwork::DN_TYPE_EXTERNAL) {
  291. throw new InvalidDistributionNetworkParentException();
  292. }
  293. } else if ($type == DistributionNetwork::DN_TYPE_INTERNAL) {
  294. if ($this->parent == null) {
  295. throw new InvalidDistributionNetworkParentException();
  296. } else if ($this->parent()->type != DistributionNetwork::DN_TYPE_INTERMEDIATE) {
  297. throw new InvalidDistributionNetworkParentException();
  298. }
  299. }
  300. }
  301. public function editDistributionNetwork(
  302. Country $country,
  303. string $name,
  304. string $slug,
  305. string $details = null,
  306. string $sinacId = null
  307. ) {
  308. $this->country = $country;
  309. $this->name = $name;
  310. $this->slug = $slug;
  311. $this->details = $details;
  312. $this->sinacId = $sinacId;
  313. $this->updatedAt = new \DateTime();
  314. return $this;
  315. }
  316. public function editPolygon(
  317. Polygon $geometryPolygon
  318. ) {
  319. $this->geometryPolygon = $geometryPolygon;
  320. $this->record(new DistributionNetworkPolygonWasUpdate($this));
  321. }
  322. public function editCenterAndArea(
  323. float $centerLatitude = null,
  324. float $centerLongitude = null,
  325. float $geometryAreaInHa = null
  326. ) {
  327. if ($centerLatitude != null) {
  328. $this->centerLatitude = $centerLatitude;
  329. }
  330. if ($centerLongitude != null) {
  331. $this->centerLongitude = $centerLongitude;
  332. }
  333. if ($geometryAreaInHa != null) {
  334. $this->geometryAreaInHa = $geometryAreaInHa;
  335. }
  336. }
  337. public function updateAnalitycsUpdateTime(\DateTime $lastAnalitycsUpdateAt = null)
  338. {
  339. if ($lastAnalitycsUpdateAt != null) {
  340. $this->lastAnalitycsUpdateAt = $lastAnalitycsUpdateAt;
  341. } else if (count($this->analyticals()) == 0) {
  342. $this->lastAnalitycsUpdateAt = new \DateTime();
  343. } else {
  344. $arrAnalyticals = $this->analyticals()->toArray();
  345. usort($arrAnalyticals, function ($a1, $a2) {
  346. return $a1->analyzedAt() < $a2->analyzedAt();
  347. });
  348. $this->lastAnalitycsUpdateAt = $arrAnalyticals[0]->analyzedAt();
  349. }
  350. }
  351. public function updateWhaterStatus(string $whaterStatus = null)
  352. {
  353. $oldWhaterStatus = $this->whaterStatus;
  354. if ($whaterStatus != null) {
  355. switch ($whaterStatus) {
  356. case DistributionNetwork::DN_STATUS_SUITABLE:
  357. case Analytical::ANALYTICAL_SUITABLE:
  358. $this->whaterStatus = DistributionNetwork::DN_STATUS_SUITABLE;
  359. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_SUITABLE) {
  360. $this->notifyWhaterStatusChange = true;
  361. } else {
  362. $this->notifyWhaterStatusChange = false;
  363. }
  364. break;
  365. case DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  366. case Analytical::ANALYTICAL_NOT_SUITABLE:
  367. $this->whaterStatus = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  368. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_NOT_SUITABLE) {
  369. $this->notifyWhaterStatusChange = true;
  370. } else {
  371. $this->notifyWhaterStatusChange = false;
  372. }
  373. break;
  374. case DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS:
  375. $this->whaterStatus = DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS;
  376. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_WITH_RESTRICTIONS) {
  377. $this->notifyWhaterStatusChange = true;
  378. } else {
  379. $this->notifyWhaterStatusChange = false;
  380. }
  381. break;
  382. case DistributionNetwork::DN_STATUS_UNKNOWN;
  383. case Analytical::ANALYTICAL_UNKNOWN:
  384. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  385. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  386. $this->notifyWhaterStatusChange = true;
  387. } else {
  388. $this->notifyWhaterStatusChange = false;
  389. }
  390. break;
  391. default:
  392. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  393. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  394. $this->notifyWhaterStatusChange = true;
  395. } else {
  396. $this->notifyWhaterStatusChange = false;
  397. }
  398. }
  399. } else {
  400. $arrAnalyticals = $this->analyticals()->toArray();
  401. usort($arrAnalyticals, function ($a1, $a2) {
  402. return $a1->analyzedAt() < $a2->analyzedAt();
  403. });
  404. if (count($arrAnalyticals) > 0) {
  405. $lastAnaytical = $arrAnalyticals[0];
  406. switch ($lastAnaytical->result()) {
  407. case Analytical::ANALYTICAL_NOT_SUITABLE:
  408. $this->whaterStatus = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  409. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_NOT_SUITABLE) {
  410. $this->notifyWhaterStatusChange = true;
  411. } else {
  412. $this->notifyWhaterStatusChange = false;
  413. }
  414. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  415. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  416. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  417. }
  418. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  419. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  420. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  421. }
  422. if ($this->whaterStatusByUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->whaterStatusByUbication)) {
  423. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_NOT_SUITABLE;
  424. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  425. }
  426. break;
  427. case Analytical::ANALYTICAL_SUITABLE:
  428. $this->whaterStatus = DistributionNetwork::DN_STATUS_SUITABLE;
  429. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_SUITABLE) {
  430. $this->notifyWhaterStatusChange = true;
  431. } else {
  432. $this->notifyWhaterStatusChange = false;
  433. }
  434. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  435. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_SUITABLE;
  436. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  437. }
  438. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  439. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_SUITABLE;
  440. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  441. }
  442. if ($this->responsableOrganizationUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationUbication)) {
  443. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_SUITABLE;
  444. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  445. }
  446. break;
  447. case Analytical::ANALYTICAL_UNKNOWN:
  448. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  449. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  450. $this->notifyWhaterStatusChange = true;
  451. } else {
  452. $this->notifyWhaterStatusChange = false;
  453. }
  454. if ($this->responsableOrganizationGovernment != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationGovernment)) {
  455. $this->whaterStatusByGovernment = DistributionNetwork::DN_STATUS_UNKNOWN;
  456. $this->whaterStatusByGovernmentUpdatedAt = $lastAnaytical->analyzedAt();
  457. }
  458. if ($this->responsableOrganizationOperator != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationOperator)) {
  459. $this->whaterStatusByOperator = DistributionNetwork::DN_STATUS_UNKNOWN;
  460. $this->whaterStatusByOperatorUpdatedAt = $lastAnaytical->analyzedAt();
  461. }
  462. if ($this->responsableOrganizationUbication != null && $lastAnaytical->responsable() != null && $lastAnaytical->responsable()->equals($this->responsableOrganizationUbication)) {
  463. $this->whaterStatusByUbication = DistributionNetwork::DN_STATUS_UNKNOWN;
  464. $this->whaterStatusByUbicationUpdatedAt = $lastAnaytical->analyzedAt();
  465. }
  466. break;
  467. default:
  468. break;
  469. }
  470. if ($lastAnaytical->analyzedAt() > $this->lastAnalitycsUpdateAt) {
  471. $this->lastAnalitycsUpdateAt = $lastAnaytical->analyzedAt();
  472. }
  473. } else {
  474. $this->whaterStatus = DistributionNetwork::DN_STATUS_UNKNOWN;
  475. if ($oldWhaterStatus != DistributionNetwork::DN_STATUS_UNKNOWN) {
  476. $this->notifyWhaterStatusChange = true;
  477. } else {
  478. $this->notifyWhaterStatusChange = false;
  479. }
  480. }
  481. }
  482. // update all whaterpoint status
  483. $this->updateWhaterPointsStatus();
  484. }
  485. public function updateWhaterPointsStatus()
  486. {
  487. foreach ($this->whaterPoints() as $whaterPoint) {
  488. $whaterPoint->updateWhaterStatus();
  489. }
  490. }
  491. public function updateSinacConnectionErrors(
  492. int $sinacConnectionErrors,
  493. \DateTime $lastSinacConnectionAt
  494. ) {
  495. $this->sinacConnectionErrors = $sinacConnectionErrors;
  496. $this->lastSinacConnectionAt = $lastSinacConnectionAt;
  497. }
  498. /**
  499. * @return string
  500. */
  501. public function id(): string
  502. {
  503. return $this->uuid;
  504. }
  505. /**
  506. * @return string
  507. */
  508. public function name(): string
  509. {
  510. return $this->name;
  511. }
  512. /**
  513. * @return string
  514. */
  515. public function details(): ?string
  516. {
  517. return $this->details;
  518. }
  519. /**
  520. * @return string
  521. */
  522. public function slug(): string
  523. {
  524. return $this->slug;
  525. }
  526. /**
  527. * @return string
  528. */
  529. public function whaterStatus(): string
  530. {
  531. return $this->whaterStatus;
  532. }
  533. /**
  534. * @return string
  535. */
  536. public function whaterStatusByGovernment(): ?string
  537. {
  538. return $this->whaterStatusByGovernment;
  539. }
  540. /**
  541. * @return \DateTime
  542. */
  543. public function whaterStatusByGovernmentUpdatedAt(): ?\DateTime
  544. {
  545. return $this->whaterStatusByGovernmentUpdatedAt;
  546. }
  547. /**
  548. * @return string
  549. */
  550. public function whaterStatusByOperator(): ?string
  551. {
  552. return $this->whaterStatusByOperator;
  553. }
  554. /**
  555. * @return \DateTime
  556. */
  557. public function whaterStatusByOperatorUpdatedAt(): ?\DateTime
  558. {
  559. return $this->whaterStatusByOperatorUpdatedAt;
  560. }
  561. /**
  562. * @return string
  563. */
  564. public function whaterStatusByUbication(): ?string
  565. {
  566. return $this->whaterStatusByUbication;
  567. }
  568. /**
  569. * @return \DateTime
  570. */
  571. public function whaterStatusByUbicationUpdatedAt(): ?\DateTime
  572. {
  573. return $this->whaterStatusByUbicationUpdatedAt;
  574. }
  575. /**
  576. * @return Collection
  577. */
  578. public function whaterPoints(): Collection
  579. {
  580. return $this->whaterPoints;
  581. }
  582. /**
  583. * @return Collection
  584. */
  585. public function towns(): Collection
  586. {
  587. return $this->towns;
  588. }
  589. /**
  590. * @return Country
  591. */
  592. public function country(): Country
  593. {
  594. return $this->country;
  595. }
  596. /**
  597. * @return Collection
  598. */
  599. public function ownershipRequests(): Collection
  600. {
  601. return $this->ownershipRequests;
  602. }
  603. public function lastAnalytical(): ?Analytical
  604. {
  605. $lastAnalytical = null;
  606. $arrAnalyticals = $this->analyticals()->toArray();
  607. usort($arrAnalyticals, function ($a1, $a2) {
  608. return $a1->analyzedAt() < $a2->analyzedAt();
  609. });
  610. if (count($arrAnalyticals) > 0) {
  611. $lastAnalytical = $arrAnalyticals[0];
  612. }
  613. return $lastAnalytical;
  614. }
  615. public function updateResponsables(
  616. WhaterOrganization $responsableOrganizationGovernment = null,
  617. WhaterOrganization $responsableOrganizationOperator = null,
  618. WhaterOrganization $responsableOrganizationCorporative = null,
  619. WhaterOrganization $responsableOrganizationUbication = null
  620. ) {
  621. $this->responsableOrganizationGovernment = $responsableOrganizationGovernment;
  622. $this->responsableOrganizationOperator = $responsableOrganizationOperator;
  623. $this->responsableOrganizationCorporative = $responsableOrganizationCorporative;
  624. $this->responsableOrganizationUbication = $responsableOrganizationUbication;
  625. $this->updatedAt = new \DateTime();
  626. }
  627. public function updateResponsableOrganizationOperator(
  628. WhaterOrganization $responsableOrganizationOperator = null,
  629. ) {
  630. $this->responsableOrganizationOperator = $responsableOrganizationOperator;
  631. $this->updatedAt = new \DateTime();
  632. }
  633. public function updateValorations()
  634. {
  635. $sumUserColor = array(
  636. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  637. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  638. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  639. );
  640. $sumUserTaste = 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. $sumUserSmell = 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. $sumUserTurbidity = 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. $sumUserGeneral = 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. $countUserColor = 0;
  661. $countUserTaste = 0;
  662. $countUserSmell = 0;
  663. $countUserTurbidity = 0;
  664. $countUserGeneral = 0;
  665. $sumProfessionalColor = array(
  666. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  667. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  668. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  669. );
  670. $sumProfessionalTaste = 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. $sumProfessionalSmell = 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. $sumProfessionalTurbidity = 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. $sumProfessionalGeneral = 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. $countProfessionalColor = 0;
  691. $countProfessionalTaste = 0;
  692. $countProfessionalSmell = 0;
  693. $countProfessionalTurbidity = 0;
  694. $countProfessionalGeneral = 0;
  695. foreach ($this->valorations() as $valoration) {
  696. if ($valoration->isProfessionalValoration()) {
  697. if (
  698. $this->lastProfessionalValorationAt == null ||
  699. $this->lastProfessionalValorationAt < $valoration->createdAt()
  700. ) {
  701. $this->lastProfessionalValorationAt = $valoration->createdAt();
  702. }
  703. if ($valoration->colorValoration() != null) {
  704. switch ($valoration->colorValoration()) {
  705. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  706. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  707. break;
  708. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  709. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  710. break;
  711. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  712. $sumProfessionalColor[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  713. break;
  714. default:
  715. break;
  716. }
  717. $countProfessionalColor++;
  718. }
  719. if ($valoration->tasteValoration() != null) {
  720. switch ($valoration->tasteValoration()) {
  721. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  722. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  723. break;
  724. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  725. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  726. break;
  727. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  728. $sumProfessionalTaste[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  729. break;
  730. default:
  731. break;
  732. }
  733. $countProfessionalTaste++;
  734. }
  735. if ($valoration->smellValoration() != null) {
  736. switch ($valoration->smellValoration()) {
  737. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  738. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  739. break;
  740. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  741. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  742. break;
  743. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  744. $sumProfessionalSmell[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  745. break;
  746. default:
  747. break;
  748. }
  749. $countProfessionalSmell++;
  750. }
  751. if ($valoration->turbidityValoration() != null) {
  752. switch ($valoration->turbidityValoration()) {
  753. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  754. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  755. break;
  756. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  757. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  758. break;
  759. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  760. $sumProfessionalTurbidity[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  761. break;
  762. default:
  763. break;
  764. }
  765. $countProfessionalTurbidity++;
  766. }
  767. if ($valoration->generalValoration() != null) {
  768. switch ($valoration->generalValoration()) {
  769. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  770. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  771. break;
  772. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  773. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  774. break;
  775. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  776. $sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  777. break;
  778. default:
  779. break;
  780. }
  781. $countProfessionalGeneral++;
  782. }
  783. } else {
  784. if (
  785. $this->lastUserValorationAt == null ||
  786. $this->lastUserValorationAt < $valoration->createdAt()
  787. ) {
  788. $this->lastUserValorationAt = $valoration->createdAt();
  789. }
  790. if ($valoration->colorValoration() != null) {
  791. switch ($valoration->colorValoration()) {
  792. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  793. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  794. break;
  795. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  796. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  797. break;
  798. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  799. $sumUserColor[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  800. break;
  801. default:
  802. break;
  803. }
  804. $countUserColor++;
  805. }
  806. if ($valoration->tasteValoration() != null) {
  807. switch ($valoration->tasteValoration()) {
  808. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  809. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  810. break;
  811. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  812. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  813. break;
  814. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  815. $sumUserTaste[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  816. break;
  817. default:
  818. break;
  819. }
  820. $countUserTaste++;
  821. }
  822. if ($valoration->smellValoration() != null) {
  823. switch ($valoration->smellValoration()) {
  824. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  825. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  826. break;
  827. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  828. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  829. break;
  830. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  831. $sumUserSmell[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  832. break;
  833. default:
  834. break;
  835. }
  836. $countUserSmell++;
  837. }
  838. if ($valoration->turbidityValoration() != null) {
  839. switch ($valoration->turbidityValoration()) {
  840. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  841. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  842. break;
  843. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  844. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  845. break;
  846. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  847. $sumUserTurbidity[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  848. break;
  849. default:
  850. break;
  851. }
  852. $countUserTurbidity++;
  853. }
  854. if ($valoration->generalValoration() != null) {
  855. switch ($valoration->generalValoration()) {
  856. case DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION:
  857. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION]++;
  858. break;
  859. case DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION:
  860. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION]++;
  861. break;
  862. case DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION:
  863. $sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION]++;
  864. break;
  865. default:
  866. break;
  867. }
  868. $countUserGeneral++;
  869. }
  870. }
  871. }
  872. // count valoration
  873. $this->countProfessionalGeneral = $countProfessionalGeneral;
  874. $this->countUserGeneral = $countUserGeneral;
  875. // calculate average valoration for color, taste, smell and turbidity
  876. if ($countProfessionalColor + $countUserColor > 0) {
  877. foreach ($sumUserColor as $key => $value) {
  878. $this->totalColor[$key] = $sumUserColor[$key] + $sumProfessionalColor[$key];
  879. }
  880. } else {
  881. $this->totalColor = array(
  882. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  883. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  884. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  885. );
  886. }
  887. if ($countProfessionalTaste + $countUserTaste > 0) {
  888. foreach ($sumUserTaste as $key => $value) {
  889. $this->totalTaste[$key] = $sumUserTaste[$key] + $sumProfessionalTaste[$key];
  890. }
  891. } else {
  892. $this->totalTaste = array(
  893. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  894. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  895. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  896. );
  897. }
  898. if ($countProfessionalSmell + $countUserSmell > 0) {
  899. foreach ($sumUserSmell as $key => $value) {
  900. $this->totalSmell[$key] = $sumUserSmell[$key] + $sumProfessionalSmell[$key];
  901. }
  902. } else {
  903. $this->totalSmell = array(
  904. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  905. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  906. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  907. );
  908. }
  909. if ($countProfessionalTurbidity + $countUserTurbidity > 0) {
  910. foreach ($sumUserTurbidity as $key => $value) {
  911. $this->totalTurbidity[$key] = $sumUserTurbidity[$key] + $sumProfessionalTurbidity[$key];
  912. }
  913. } else {
  914. $this->totalTurbidity = array(
  915. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  916. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  917. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  918. );
  919. }
  920. if ($countProfessionalGeneral + $countUserGeneral > 0) {
  921. foreach ($sumUserGeneral as $key => $value) {
  922. $this->totalGeneral[$key] = $sumUserGeneral[$key] + $sumProfessionalGeneral[$key];
  923. }
  924. } else {
  925. $this->totalGeneral = array(
  926. DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION => 0,
  927. DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION => 0,
  928. DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION => 0
  929. );
  930. }
  931. // calculate average valoration for users and professionals
  932. if ($this->countProfessionalGeneral > 0) {
  933. $averageProfessionalGeneral =
  934. (($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION] * 10) +
  935. ($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION] * 5) +
  936. ($sumProfessionalGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION] * 0)) / $this->countProfessionalGeneral;
  937. $this->averageProfessionalGeneral = round($averageProfessionalGeneral, 2);
  938. } else {
  939. $this->averageProfessionalGeneral = null;
  940. }
  941. if ($this->countUserGeneral > 0) {
  942. $averageUserGeneral =
  943. (($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_ACCEPTABLE_VALORATION] * 10) +
  944. ($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NEEDS_IMPROVEMENT_VALORATION] * 5) +
  945. ($sumUserGeneral[DistributionNetworkValoration::DN_QUALITY_NOT_ACCEPTABLE_VALORATION] * 0)) / $this->countUserGeneral;
  946. $this->averageUserGeneral = round($averageUserGeneral, 2);
  947. } else {
  948. $this->averageUserGeneral = null;
  949. }
  950. }
  951. /**
  952. * @return string
  953. */
  954. public function sinacId(): ?string
  955. {
  956. return $this->sinacId;
  957. }
  958. /**
  959. * @return \DateTime
  960. */
  961. public function createdAt(): \DateTime
  962. {
  963. return $this->createdAt;
  964. }
  965. /**
  966. * @return \DateTime
  967. */
  968. public function updatedAt(): \DateTime
  969. {
  970. return $this->updatedAt;
  971. }
  972. /**
  973. * @return \DateTime
  974. */
  975. public function lastAnalitycsUpdateAt(): ?\DateTime
  976. {
  977. return $this->lastAnalitycsUpdateAt;
  978. }
  979. /**
  980. * @return float
  981. */
  982. public function centerLatitude(): float
  983. {
  984. if ($this->centerLatitude == null) {
  985. return 0;
  986. }
  987. return $this->centerLatitude;
  988. }
  989. /**
  990. * @return float
  991. */
  992. public function centerLongitude(): float
  993. {
  994. if ($this->centerLongitude == null) {
  995. return 0;
  996. }
  997. return $this->centerLongitude;
  998. }
  999. /**
  1000. * @return Polygon
  1001. */
  1002. public function geometryPolygon(): ?Polygon
  1003. {
  1004. return $this->geometryPolygon;
  1005. }
  1006. /**
  1007. * @return LocationPolygon
  1008. */
  1009. public function locationPolygon(): ?LocationPolygon
  1010. {
  1011. if ($this->geometryPolygon() != null) {
  1012. $pol = new LocationPolygon();
  1013. $points = $this->geometryPolygon()->toArray();
  1014. foreach ($points[0] as $point) {
  1015. $lat = $point[1];
  1016. $long = $point[0];
  1017. $pol->addPoint(new Coordinate($lat, $long, Ellipsoid::createDefault()));
  1018. }
  1019. return $pol;
  1020. }
  1021. return null;
  1022. }
  1023. public function getGeoJsonPolygon(): ?string
  1024. {
  1025. if ($this->geometryPolygon() != null) {
  1026. $geoJsonCoordinates = [];
  1027. // Recorre los anillos (exterior + huecos si existen)
  1028. foreach ($this->geometryPolygon()->getRings() as $ring) {
  1029. $ringCoordinates = [];
  1030. // Recorre los puntos del anillo
  1031. foreach ($ring->getPoints() as $point) {
  1032. $ringCoordinates[] = [$point->getLongitude(), $point->getLatitude()];
  1033. }
  1034. // Cierra el anillo si no está cerrado
  1035. if ($ringCoordinates[0] !== $ringCoordinates[count($ringCoordinates) - 1]) {
  1036. $ringCoordinates[] = $ringCoordinates[0];
  1037. }
  1038. // Añade el anillo a las coordenadas del GeoJSON
  1039. $geoJsonCoordinates[] = $ringCoordinates;
  1040. }
  1041. // Construye el GeoJSON
  1042. $geoJson = [
  1043. "type" => "Polygon",
  1044. "coordinates" => $geoJsonCoordinates
  1045. ];
  1046. return json_encode($geoJson, JSON_PRETTY_PRINT);
  1047. }
  1048. return null;
  1049. }
  1050. /**
  1051. * @return float
  1052. */
  1053. public function geometryAreaInHa(): ?float
  1054. {
  1055. return $this->geometryAreaInHa;
  1056. }
  1057. /**
  1058. * @return Collection
  1059. */
  1060. public function analyticals(): Collection
  1061. {
  1062. return $this->analyticals;
  1063. }
  1064. /**
  1065. * @return string
  1066. */
  1067. public function type(): string
  1068. {
  1069. return $this->type;
  1070. }
  1071. /**
  1072. * @return Collection
  1073. */
  1074. public function ubications(): Collection
  1075. {
  1076. return $this->ubications;
  1077. }
  1078. /**
  1079. * @return Collection
  1080. */
  1081. public function townLocations(): Collection
  1082. {
  1083. return $this->townLocations;
  1084. }
  1085. /**
  1086. * @return bool
  1087. */
  1088. public function equals(DistributionNetwork $distributionNetwork)
  1089. {
  1090. return $this->id() === $distributionNetwork->id();
  1091. }
  1092. /**
  1093. * @return Collection
  1094. */
  1095. public function establishments(): Collection
  1096. {
  1097. return $this->establishments;
  1098. }
  1099. /**
  1100. * @return Collection
  1101. */
  1102. public function valorations(): Collection
  1103. {
  1104. return $this->valorations;
  1105. }
  1106. /**
  1107. * @return Collection
  1108. */
  1109. public function children(): Collection
  1110. {
  1111. return $this->children;
  1112. }
  1113. /**
  1114. * @return null|DistributionNetwork
  1115. */
  1116. public function parent(): ?DistributionNetwork
  1117. {
  1118. return $this->parent;
  1119. }
  1120. /**
  1121. * @return int
  1122. */
  1123. public function sinacConnectionErrors(): int
  1124. {
  1125. return $this->sinacConnectionErrors;
  1126. }
  1127. /**
  1128. * @return \DateTime
  1129. */
  1130. public function lastSinacConnectionAt(): ?\DateTime
  1131. {
  1132. return $this->lastSinacConnectionAt;
  1133. }
  1134. /**
  1135. * @return WhaterOrganization
  1136. */
  1137. public function responsableOrganizationGovernment(): ?WhaterOrganization
  1138. {
  1139. return $this->responsableOrganizationGovernment;
  1140. }
  1141. /**
  1142. * @return WhaterOrganization
  1143. */
  1144. public function responsableOrganizationOperator(): ?WhaterOrganization
  1145. {
  1146. return $this->responsableOrganizationOperator;
  1147. }
  1148. /**
  1149. * @return WhaterOrganization
  1150. */
  1151. public function responsableOrganizationCorporative(): ?WhaterOrganization
  1152. {
  1153. return $this->responsableOrganizationCorporative;
  1154. }
  1155. /**
  1156. * @return WhaterOrganization
  1157. */
  1158. public function responsableOrganizationUbication(): ?WhaterOrganization
  1159. {
  1160. return $this->responsableOrganizationUbication;
  1161. }
  1162. /**
  1163. * @return bool
  1164. */
  1165. public function notifyWhaterStatusChange(): bool
  1166. {
  1167. return $this->notifyWhaterStatusChange;
  1168. }
  1169. /**
  1170. * @return Collection
  1171. */
  1172. public function articles(): Collection
  1173. {
  1174. return $this->articles;
  1175. }
  1176. /**
  1177. * @return array
  1178. */
  1179. public function totalColor(): ?array
  1180. {
  1181. return $this->totalColor;
  1182. }
  1183. /**
  1184. * @return array
  1185. */
  1186. public function totalTaste(): ?array
  1187. {
  1188. return $this->totalTaste;
  1189. }
  1190. /**
  1191. * @return array
  1192. */
  1193. public function totalSmell(): ?array
  1194. {
  1195. return $this->totalSmell;
  1196. }
  1197. /**
  1198. * @return array
  1199. */
  1200. public function totalTurbidity(): ?array
  1201. {
  1202. return $this->totalTurbidity;
  1203. }
  1204. /**
  1205. * @return array
  1206. */
  1207. public function totalGeneral(): ?array
  1208. {
  1209. return $this->totalGeneral;
  1210. }
  1211. /**
  1212. * @return \DateTime
  1213. */
  1214. public function lastProfessionalValorationAt(): ?\DateTime
  1215. {
  1216. return $this->lastProfessionalValorationAt;
  1217. }
  1218. /**
  1219. * @return int
  1220. */
  1221. public function countProfessionalGeneral(): int
  1222. {
  1223. return $this->countProfessionalGeneral;
  1224. }
  1225. /**
  1226. * @return float
  1227. */
  1228. public function averageProfessionalGeneral(): ?float
  1229. {
  1230. return $this->averageProfessionalGeneral;
  1231. }
  1232. /**
  1233. * @return \DateTime
  1234. */
  1235. public function lastUserValorationAt(): ?\DateTime
  1236. {
  1237. return $this->lastUserValorationAt;
  1238. }
  1239. /**
  1240. * @return int
  1241. */
  1242. public function countUserGeneral(): int
  1243. {
  1244. return $this->countUserGeneral;
  1245. }
  1246. /**
  1247. * @return float
  1248. */
  1249. public function averageUserGeneral(): ?float
  1250. {
  1251. return $this->averageUserGeneral;
  1252. }
  1253. }