Merge branch 'master' of https://gitlab.com/kluppsoftware/smart-energia-api
This commit is contained in:
commit
1ca66fc72d
@ -39,7 +39,7 @@ abstract class AbstractRepository
|
|||||||
{
|
{
|
||||||
$model = app()->make($this->model);
|
$model = app()->make($this->model);
|
||||||
|
|
||||||
if (!$model instanceof Model) {
|
if (!($model instanceof Model)) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"Class {$this->model} must be an instance of Illuminate\\Database\\Eloquent\\Model"
|
"Class {$this->model} must be an instance of Illuminate\\Database\\Eloquent\\Model"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,7 +7,6 @@ namespace App\Repositories\Med5min;
|
|||||||
use App\Helpers\Helpers;
|
use App\Helpers\Helpers;
|
||||||
use App\Models\Med5min;
|
use App\Models\Med5min;
|
||||||
use App\Repositories\AbstractRepository;
|
use App\Repositories\AbstractRepository;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
@ -217,7 +216,7 @@ class Med5minRepository extends AbstractRepository implements Med5minContractInt
|
|||||||
->orderBy(DB::raw("dia_num_month, med_5min.ponto"))
|
->orderBy(DB::raw("dia_num_month, med_5min.ponto"))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach($result as $row) {
|
foreach ($result as $row) {
|
||||||
$row['dia_num'] = $row['dia_num_month'];
|
$row['dia_num'] = $row['dia_num_month'];
|
||||||
unset($row['dia_num_month']);
|
unset($row['dia_num_month']);
|
||||||
}
|
}
|
||||||
@ -245,42 +244,37 @@ class Med5minRepository extends AbstractRepository implements Med5minContractInt
|
|||||||
|
|
||||||
$field =
|
$field =
|
||||||
[
|
[
|
||||||
// DB::raw("(SUM(med_5min.ativa_consumo)/SQRT(((SUM(med_5min.ativa_consumo)^2) + (SUM(med_5min.reativa_consumo+med_5min.reativa_geracao)^2)))) as FP"),
|
|
||||||
DB::raw("
|
DB::raw("
|
||||||
(
|
(
|
||||||
SUM(med_5min.ativa_consumo)
|
SUM(med_5min.ativa_consumo)
|
||||||
/
|
/
|
||||||
SQRT(
|
CASE WHEN SQRT(SUM(med_5min.reativa_consumo+med_5min.reativa_geracao)^2) <> 0
|
||||||
SUM(med_5min.ativa_consumo)^2
|
THEN SQRT(SUM(med_5min.reativa_consumo+med_5min.reativa_geracao)^2)
|
||||||
+
|
ELSE NULL
|
||||||
SUM(med_5min.reativa_consumo+med_5min.reativa_geracao)^2
|
END
|
||||||
)
|
|
||||||
) as FP"),
|
) as FP"),
|
||||||
DB::raw("0.92 as F_ref")
|
DB::raw("0.92 as F_ref")
|
||||||
];
|
];
|
||||||
|
|
||||||
return $collection->merge($field);
|
return $collection->merge($field);
|
||||||
|
}, function ($collection, $value) use ($period) {
|
||||||
}, function ($collection, $value) use($period) {
|
|
||||||
|
|
||||||
$multiplyBy = 1;
|
$multiplyBy = 1;
|
||||||
if($period === 5) {
|
if ($period === 5) {
|
||||||
$multiplyBy = 12;
|
$multiplyBy = 12;
|
||||||
}else if($period === 15) {
|
} else if ($period === 15) {
|
||||||
$multiplyBy = 4;
|
$multiplyBy = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
$field =
|
$field =
|
||||||
[
|
[
|
||||||
DB::raw("(CASE WHEN (((med_5min.minuto-5)/60) >= 18 AND ((med_5min.minuto-5)/60) < 21 AND extract( dow from date '1899-12-30' + cast (med_5min.dia_num as integer)) BETWEEN 1 AND 5) THEN dados_cadastrais.demanda_p ELSE dados_cadastrais.demanda_fp END)*1.05 as dem_tolerancia"),
|
DB::raw("(CASE WHEN (((med_5min.minuto-5)/60) >= 18 AND ((med_5min.minuto-5)/60) < 21 AND extract( dow from date '1899-12-30' + cast (med_5min.dia_num as integer)) BETWEEN 1 AND 5) THEN dados_cadastrais.demanda_p ELSE dados_cadastrais.demanda_fp END)*1.05 as dem_tolerancia"),
|
||||||
DB::raw("SUM(med_5min.ativa_consumo)*".$multiplyBy." AS dem_reg"),
|
DB::raw("SUM(med_5min.ativa_consumo)*" . $multiplyBy . " AS dem_reg"),
|
||||||
DB::raw("(CASE WHEN (((med_5min.minuto-5)/60) >= 18 AND ((med_5min.minuto-5)/60) <= 21 AND extract( dow from date '1899-12-30' + cast (med_5min.dia_num as integer)) BETWEEN 1 AND 5) THEN dados_cadastrais.demanda_p ELSE dados_cadastrais.demanda_fp END) as dem_cont")
|
DB::raw("(CASE WHEN (((med_5min.minuto-5)/60) >= 18 AND ((med_5min.minuto-5)/60) <= 21 AND extract( dow from date '1899-12-30' + cast (med_5min.dia_num as integer)) BETWEEN 1 AND 5) THEN dados_cadastrais.demanda_p ELSE dados_cadastrais.demanda_fp END) as dem_cont")
|
||||||
];
|
];
|
||||||
|
|
||||||
return $collection->merge($field);
|
return $collection->merge($field);
|
||||||
|
|
||||||
})->all();
|
})->all();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function groupField($typeField, $type = null): array
|
public function groupField($typeField, $type = null): array
|
||||||
@ -295,7 +289,7 @@ class Med5minRepository extends AbstractRepository implements Med5minContractInt
|
|||||||
array_splice($fields, 3);
|
array_splice($fields, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($type === '1_mes') {
|
if ($type === '1_mes') {
|
||||||
$fields = ["med_5min.ponto", "dia_num_month", "day_formatted"];
|
$fields = ["med_5min.ponto", "dia_num_month", "day_formatted"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +300,4 @@ class Med5minRepository extends AbstractRepository implements Med5minContractInt
|
|||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,10 @@
|
|||||||
"name": "laravel/laravel",
|
"name": "laravel/laravel",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "The Laravel Framework.",
|
"description": "The Laravel Framework.",
|
||||||
"keywords": ["framework", "laravel"],
|
"keywords": [
|
||||||
|
"framework",
|
||||||
|
"laravel"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
@ -52,7 +55,24 @@
|
|||||||
],
|
],
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
"@php artisan key:generate --ansi"
|
"@php artisan key:generate --ansi"
|
||||||
]
|
],
|
||||||
|
"cached": [
|
||||||
|
"@php artisan optimize --ansi",
|
||||||
|
"@php artisan view:clear --ansi",
|
||||||
|
"@php artisan view:cache --ansi",
|
||||||
|
"@php artisan route:clear --ansi",
|
||||||
|
"@php artisan event:cache --ansi"
|
||||||
|
],
|
||||||
|
"clear-cached": [
|
||||||
|
"@php artisan optimize:clear",
|
||||||
|
"@php artisan cache:clear --ansi",
|
||||||
|
"@php artisan view:clear --ansi",
|
||||||
|
"@php artisan route:clear --ansi",
|
||||||
|
"@php artisan event:clear --ansi",
|
||||||
|
"@php artisan config:clear --ansi",
|
||||||
|
"@php artisan schedule:clear-cache --ansi"
|
||||||
|
],
|
||||||
|
"dev": "@php artisan serve --host=0.0.0.0 --port=8080 --ansi"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user