<?php
namespace App\Containers\ServiceSection\DataScienceContainer\Entities;
use ApiPlatform\Metadata\ApiResource;
// use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
// use ApiPlatform\Metadata\Patch;
// use ApiPlatform\Metadata\Put;
// use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
// use Symfony\Component\Serializer\Annotation\MaxDepth;
use Symfony\Component\Serializer\Annotation\Context;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use App\Ship\ApiPlatform\Filter\SimpleSearchFilter;
use App\Containers\ServiceSection\DataScienceContainer\Data\Repositories\DataOperationalResultsRepository;
#[ApiResource(
routePrefix: '/data',
normalizationContext: [
'groups' => 'read',
'enable_max_depth' => true
],
operations: [
new Get(
uriTemplate: '/data_operational_results/{id}', requirements: ['id' => '\d+']
),
new GetCollection(
uriTemplate: '/data_operational_results'
)
],
shortName: 'Service_DataScience',
security: "is_granted('ROLE_ADMIN')"
)]
#[ApiFilter(SearchFilter::class, properties: [
'id' => 'exact',
'name' => 'partial'
])]
#[ApiFilter(NumericFilter::class, properties: ['id'])]
#[ApiFilter(RangeFilter::class, properties: ['id'])]
#[ApiFilter(DateFilter::class, properties: ['dateStart', 'dateEnd', 'createdAt', 'updatedAt'])]
#[ApiFilter(BooleanFilter::class, properties: ['isHide'])]
#[ApiFilter(OrderFilter::class)]
#[ApiFilter(filterClass: SimpleSearchFilter::class, properties: ['name'])]
#[ORM\Entity(repositoryClass: DataOperationalResultsRepository::class)]
#[ORM\Table(name: '`service_data_science_operational_results`')]
class DataOperationalResultsEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
#[Groups(['read'])]
private ?int $id = null;
// Название
#[ORM\Column(type: Types::STRING, length: 50, nullable: false)]
#[Groups(['read'])]
private string $name;
// Дата начала периода
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: false)]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
)]
#[Groups(['read'])]
private \DateTimeInterface $dateStart;
// Дата окончания периода
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: false)]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s'],
denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
)]
#[Groups(['read'])]
private \DateTimeInterface $dateEnd;
// Действующие договора
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private ?int $currentContractsCount = 0;
// Оплачено грн по действующим договорам
#[ORM\Column(type: Types::FLOAT, scale: 4, options: ['default' => 0.0000])]
#[Groups(['read'])]
private ?float $currentContractsPaymentUAH = 0.0000;
// Оплачено км по действующим договорам
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private ?int $currentContractsPaymentMileage = 0;
// Активные договора
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private ?int $activeContractsCount = 0;
// Оплачено грн по активным договорам
#[ORM\Column(type: Types::FLOAT, scale: 4, options: ['default' => 0.0000])]
#[Groups(['read'])]
private ?float $activeContractsPaymentUAH = 0.0000;
// Оплачено км по активным договорам
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private ?int $activeContractsPaymentMileage = 0;
#[ORM\Column(type: Types::BOOLEAN)]
#[Groups(['read'])]
private ?bool $isHide = false;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
)]
#[Groups(['read'])]
protected $createdAt;
#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i:s']
)]
#[Groups(['read'])]
protected $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function setName(?string $name): ?self
{
$this->name = $name;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setDateStart(?\DateTimeImmutable $date): ?self
{
$this->dateStart = $date;
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateEnd(?\DateTimeImmutable $date): ?self
{
$this->dateEnd = $date;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function getCurrentContractsCount(): ?int
{
return $this->currentContractsCount;
}
public function setCurrentContractsCount(?int $value): ?self
{
$this->currentContractsCount = $value;
return $this;
}
public function getCurrentContractsPaymentUAH(): ?float
{
return $this->currentContractsPaymentUAH;
}
public function setCurrentContractsPaymentUAH(?float $value): ?self
{
$this->currentContractsPaymentUAH = ($value ? round($value, 4) : null);
return $this;
}
public function getCurrentContractsPaymentMileage(): ?int
{
return $this->currentContractsPaymentMileage;
}
public function setCurrentContractsPaymentMileage(?int $value): ?self
{
$this->currentContractsPaymentMileage = $value;
return $this;
}
public function getActiveContractsCount(): ?int
{
return $this->activeContractsCount;
}
public function setActiveContractsCount(?int $value): ?self
{
$this->activeContractsCount = $value;
return $this;
}
public function getActiveContractsPaymentUAH(): ?float
{
return $this->activeContractsPaymentUAH;
}
public function setActiveContractsPaymentUAH(?float $value): ?self
{
$this->activeContractsPaymentUAH = ($value ? round($value, 4) : null);
return $this;
}
public function getActiveContractsPaymentMileage(): ?int
{
return $this->activeContractsPaymentMileage;
}
public function setActiveContractsPaymentMileage(?int $value): ?self
{
$this->activeContractsPaymentMileage = $value;
return $this;
}
public function getIsHide(): ?bool
{
return $this->isHide;
}
public function setIsHide(?bool $value): ?self
{
$this->isHide = $value;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
}