Implementation make s3 amazon on upload and download.
This commit is contained in:
parent
67df6e859a
commit
6d2693ec5f
@ -25,13 +25,7 @@ class InfoSectorialController extends Controller
|
|||||||
$data['name'] = Str::of($file->getClientOriginalName())->explode('.')->offsetGet(0);
|
$data['name'] = Str::of($file->getClientOriginalName())->explode('.')->offsetGet(0);
|
||||||
$data['uid'] = Str::of($file->hashName())->explode('.')->offsetGet(0);
|
$data['uid'] = Str::of($file->hashName())->explode('.')->offsetGet(0);
|
||||||
$extension = $file->getClientOriginalExtension();
|
$extension = $file->getClientOriginalExtension();
|
||||||
$path = $file->store('pdf','s3');
|
$data['path'] = $file->storeAs('pdf', $data['uid'].".{$extension}", 's3');
|
||||||
|
|
||||||
dd($path);
|
|
||||||
// $path = Storage::disk('s3')->put('pdf', $data['uid'].".{$extension}");
|
|
||||||
// $path = Storage::disk('s3')->url($path);
|
|
||||||
dd($path);
|
|
||||||
//$data['uid'].".{$extension}"
|
|
||||||
|
|
||||||
return InfoSectorial::query()->create($data);
|
return InfoSectorial::query()->create($data);
|
||||||
|
|
||||||
@ -43,16 +37,16 @@ class InfoSectorialController extends Controller
|
|||||||
|
|
||||||
$data = InfoSectorial::query()->where('created_at', '=', $created_at)->first();
|
$data = InfoSectorial::query()->where('created_at', '=', $created_at)->first();
|
||||||
|
|
||||||
if (Storage::disk('public')->exists($data->path))
|
if (!Storage::disk('s3')->exists($data->path))
|
||||||
{
|
{
|
||||||
$path = Storage::disk('public')->path(($data->path));
|
return $this->errorResponse( false, '', 500);
|
||||||
|
|
||||||
$heders = [
|
|
||||||
'Content-Type' => mime_content_type($path)
|
|
||||||
];
|
|
||||||
|
|
||||||
return response()->download($path, $data->name, $heders);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'attachment; filename="'. basename($data->path) .'"',
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->make(Storage::disk('s3')->get($data->path), 200, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,20 @@ class DadosTeRepository extends AbstractRepository implements DadosTeContractInt
|
|||||||
'dados_te.preco_nf',
|
'dados_te.preco_nf',
|
||||||
'dados_te.nf_c_icms'
|
'dados_te.nf_c_icms'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->execute($fields, $params)->get();
|
return $this->execute($fields, $params)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function filterRow($params, $field = 'mes'): array
|
||||||
|
{
|
||||||
|
$arr['filters'] = collect($params['filters'])
|
||||||
|
->map(function ($value, $key) use ($field) {
|
||||||
|
if ($value['field'] === $field) {
|
||||||
|
Arr::set( $value, "field", "TO_CHAR(TO_DATE(dados_te.{$value['field']}, 'YYMM'), 'MM/YYYY')");
|
||||||
|
$value['row'] = true;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
})->all();
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,5 +6,9 @@ use App\Repositories\ContractInterface;
|
|||||||
|
|
||||||
interface Med5minContractInterface extends ContractInterface
|
interface Med5minContractInterface extends ContractInterface
|
||||||
{
|
{
|
||||||
|
public function discretized5min($params);
|
||||||
|
public function discretized15min($params);
|
||||||
|
public function discretizedOneHour($params);
|
||||||
|
public function discretizedOneDay($params);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@ namespace App\Repositories\Med5min;
|
|||||||
use App\Models\Med5min;
|
use App\Models\Med5min;
|
||||||
use App\Repositories\AbstractRepository;
|
use App\Repositories\AbstractRepository;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
class Med5minRepository extends AbstractRepository implements Med5minContractInterface
|
class Med5minRepository extends AbstractRepository implements Med5minContractInterface
|
||||||
@ -28,4 +29,66 @@ class Med5minRepository extends AbstractRepository implements Med5minContractInt
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function discretized5min($params)
|
||||||
|
{
|
||||||
|
$fields =
|
||||||
|
[
|
||||||
|
'med_5min.ponto',
|
||||||
|
'med_5min.dia_num',
|
||||||
|
DB::raw("(med_5min.minuto/60) AS hora"),
|
||||||
|
DB::raw("MOD(med_5min.minuto,60) AS minut"),
|
||||||
|
DB::raw("SUM(med_5min.ativa_consumo) AS consumo"),
|
||||||
|
DB::raw("UM(med_5min.reativa_consumo+med_5min.reativa_geracao) AS reativa")
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->execute($fields, $params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discretized15min($params)
|
||||||
|
{
|
||||||
|
$fields =
|
||||||
|
[
|
||||||
|
'med_5min.ponto',
|
||||||
|
'med_5min.dia_num',
|
||||||
|
DB::raw("(med_5min.minuto/60) AS hora"),
|
||||||
|
DB::raw("MOD(med_5min.minuto,60) AS minut"),
|
||||||
|
DB::raw("SUM(med_5min.ativa_consumo) AS consumo"),
|
||||||
|
DB::raw("UM(med_5min.reativa_consumo+med_5min.reativa_geracao) AS reativa")
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->execute($fields, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discretizedOneHour($params)
|
||||||
|
{
|
||||||
|
$fields =
|
||||||
|
[
|
||||||
|
'med_5min.ponto',
|
||||||
|
'med_5min.dia_num',
|
||||||
|
DB::raw("(med_5min.minuto/60) AS hora"),
|
||||||
|
DB::raw("MOD(med_5min.minuto,60) AS minut"),
|
||||||
|
DB::raw("SUM(med_5min.ativa_consumo) AS consumo"),
|
||||||
|
DB::raw("UM(med_5min.reativa_consumo+med_5min.reativa_geracao) AS reativa")
|
||||||
|
];;
|
||||||
|
|
||||||
|
return $this->execute($fields, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discretizedOneDay($params)
|
||||||
|
{
|
||||||
|
$fields =
|
||||||
|
[
|
||||||
|
'med_5min.ponto',
|
||||||
|
'med_5min.dia_num',
|
||||||
|
DB::raw("(med_5min.minuto/60) AS hora"),
|
||||||
|
DB::raw("MOD(med_5min.minuto,60) AS minut"),
|
||||||
|
DB::raw("SUM(med_5min.ativa_consumo) AS consumo"),
|
||||||
|
DB::raw("UM(med_5min.reativa_consumo+med_5min.reativa_geracao) AS reativa")
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->execute($fields, $params);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,7 @@ trait FiltersQuery
|
|||||||
|
|
||||||
$obj = new $className;
|
$obj = new $className;
|
||||||
|
|
||||||
if (!isset($jsonData) && method_exists($obj, 'jsonToObject'))
|
if (!isset($jsonData) && method_exists($obj, 'jsonToObject')) {
|
||||||
{
|
|
||||||
throw new Exception("Request inválido");
|
throw new Exception("Request inválido");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user