Commit 2f5b6b2f authored by hj's avatar hj

更新提交

parent 848cbaad
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace App\Http\Controllers\V1\Chemicals; namespace App\Http\Controllers\V1\Chemicals;
use App\Services\Api\ChemicalsMsdsService;
use App\Services\Api\RhawnOrdersService; use App\Services\Api\RhawnOrdersService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Jiannei\Response\Laravel\Support\Facades\Response; use Jiannei\Response\Laravel\Support\Facades\Response;
...@@ -30,15 +31,16 @@ class MsdsController extends Controller ...@@ -30,15 +31,16 @@ class MsdsController extends Controller
{ {
use Helpers; use Helpers;
public function __construct(RhawnOrdersService $rhawnOrdersService) public function __construct(ChemicalsMsdsService $chemicalsMsdsService)
{ {
$this->rhawnOrdersService= $rhawnOrdersService; $this->chemicalsMsdsService= $chemicalsMsdsService;
$this->controllerType = 'rhawn';
} }
public function getMsds(Request $request) public function getMsds(Request $request)
{ {
$this->chemicalsMsdsService->getMsds('270912-72-6');
$customerCode = $request->get('customer_code'); $customerCode = $request->get('customer_code');
$companyCode = $request->get('company_code'); $companyCode = $request->get('company_code');
......
<?php
namespace App\Repositories\Contracts;
use Prettus\Repository\Contracts\RepositoryInterface;
interface FileManageRepository extends RepositoryInterface
{
}
<?php
namespace App\Repositories\Criteria;
use Illuminate\Database\Eloquent\Builder;
use App\Repositories\Criteria\Criteria;
class BaseCriteria extends Criteria
{
protected function condition(Builder $query): void
{
if ($this->request->has('created_at')) {
$createdAt = $this->request->offsetGet('created_at');
if(!empty($createdAt)){
list($start,$end) = explode(',',$createdAt);
if(!preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i',$start)){
$start = $start. ' 00:00:00';
}
if(!preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i',$end)){
$end = $end. ' 23:59:59';
}
if(!empty($start) && !empty($end)){
$query->whereRaw('created_at >= "'.$start.'" and created_at < "'.$end.'"');
}
}
}
if ($this->request->has('createdAt')) {
$createdAt = $this->request->offsetGet('createdAt');
if(!empty($createdAt)){
list($start,$end) = explode(',',$createdAt);
if(!preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i',$start)){
$start = $start. ' 00:00:00';
}
if(!preg_match('/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\ [0-9]{2}\:[0-9]{2}\:[0-9]{2}/i',$end)){
$end = $end. ' 23:59:59';
}
if(!empty($start) && !empty($end)){
$query->whereRaw('created_at >= "'.$start.'" and created_at < "'.$end.'"');
}
}
}
}
}
<?php
namespace App\Repositories\Eloquent;
use App\Repositories\Contracts\FileManageRepository;
use App\Repositories\Models\FileManage;
use Prettus\Validator\Contracts\ValidatorInterface;
use App\Repositories\BaseRepository;
class FileManageRepositoryEloquent extends BaseRepository implements FileManageRepository
{
/**
* 定义validator的检索规则
* @var \string[][]
*/
public $rules = [
ValidatorInterface::RULE_CREATE => [
'uniqueid' => 'required|string',
'name' => 'required|string',
'type' => 'required|string',
'extension' => 'required|string',
'path' => 'required|string',
'mime_type' => 'required|string',
'byte_size' => 'required',
],
];
/**
* Specify Model class name.
*
* @return string
*/
public function model()
{
return FileManage::class;
}
public function saveUplodFiles($fileImage)
{
$saveParams = $fileImage;
if($file = $this->getFileByUniqueId($saveParams['uniqueid'])){
$saveParams['updated_at'] = date('Y-m-d H:i:s',time());
$file = $file->update($saveParams);
}else{
$saveParams['type'] = (isset($saveParams['type']) && !empty($saveParams['type'])) ? $saveParams['type'] : 'image';
$saveParams['created_at'] = date('Y-m-d H:i:s',time());
$file = $this->create($saveParams);
}
return $file;
}
public function getFileByUniqueId($id)
{
$file = $this->findWhere(['uniqueid' => $id]);
return $file->first();
}
}
<?php
/**
* Created by Reliese Model.
*/
namespace App\Repositories\Models;
use Carbon\Carbon;
/**
* Class FileManage
*
* @property int $id
* @property string $uniqueid
* @property string $name
* @property string $extension
* @property string $type
* @property string $path
* @property string $mime_type
* @property int $byte_size
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string $model_name
* @property string $model_data_id
*
* @package App\Repositories\Models
*/
class FileManage extends Model
{
protected $table = 'file_manage';
protected $casts = [
'byte_size' => 'int'
];
protected $fillable = [
'uniqueid',
'name',
'extension',
'type',
'path',
'mime_type',
'byte_size',
'model_name',
'model_data_id',
'created_by'
];
}
<?php
namespace App\Services\Api;
use App\Services\FileService;
use Illuminate\Support\Facades\Storage;
class ChemicalsMsdsService
{
public function __construct()
{
}
public function getMsds($cas)
{
$findResult = shell_exec('find '.env('MSDS_FILE_DIR').' -iname \''.$cas.'\' -print');
if(is_null($findResult)){
return null;
}
$msds_html = file_get_contents(env('MSDS_FILE_DIR').'/'.$cas.'/'.$cas.'_sds_cn.html');
dd($msds_html);
dd(Storage::exists(env('MSDS_FILE_DIR')));
if(Storage::exists(env('MSDS_FILE_DIR').'/'.$cas)){
dd(123);
}
$fileService = app(FileService::class);
dd($fileService->getFileFolderPath());
}
}
This diff is collapsed.
<?php
namespace App\Services\Traits;
use App\Exceptions\ServerRunTimeException;
use App\Repositories\Criteria\BaseCriteria;
use App\Services\AuthService as adminAuth;
use App\Services\Traits\DataEntriesService;
use App\Services\YyBao\Auth\AuthService as frontAuth;
use App\Services\YyBao\CustomersService;
use App\Services\YyBao\ImportExportTasksService;
use Illuminate\Support\Facades\DB;
trait BaseService
{
protected $repository;
protected $guard;
public function setRepository($repository)
{
$this->repository = $repository;
}
public function getRepository()
{
return $this->repository;
}
public function setGuard($guardName)
{
$this->guard = $guardName;
}
public function getGuard()
{
return $this->guard;
}
public function moneyFromat($money, $fromat = true)
{
$money = bcdiv($money, 100 ,2);
if($fromat){
return is_numeric($money) ? sprintf("%.2f", substr(sprintf("%.3f", $money), 0, -1)) : '';
}
return $money;
}
public function getList($requestParams, BaseCriteria $pushCriteria)
{
$this->getRepository()->pushCriteria($pushCriteria);
if(empty($requestParams['page_size']) || $requestParams['page_size'] == 0){
$requestParams['page_size'] = 10;
}
return $this->getRepository()->listPageByPaginate($requestParams['page_size']);
}
public function collectionToArray($collection, $model = null)
{
return $this->getRepository()->transformData(
collect($collection)->map(function($collect){
return !is_array($collect) ? $collect->toArray() : $collect;
}), $model
);
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFileManageTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('file_manage', function (Blueprint $table) {
$table->id();
$table->longText('uniqueid')->comment('uniqueid')->nullable(false);
$table->string('name')->comment('文件名称')->nullable(false);
$table->string('extension')->comment('扩展名')->nullable(false);
$table->string('type')->comment('图片类型')->nullable(false)->default('image');
$table->text('path')->nullable(false)->comment('保存路径');
$table->string('mime_type')->nullable(false)->comment('mime类型');
$table->integer('byte_size')->nullable(false)->comment('文件大小');
$table->string('model_name')->nullable()->comment('模型名称');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('file_manage');
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment