数据多语言
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use app\model\Vehicle;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use app\util\Xunfei;
|
||||
use support\Db;
|
||||
use app\model\Location;
|
||||
|
||||
class TransCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'trans';
|
||||
protected static $defaultDescription = '翻译';
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// $list = Vehicle::all()->toArray();
|
||||
|
||||
// $fields = ['classify', 'brand', 'model', 'status', 'purchase_location', 'procedure_location', 'fbo_destination'];
|
||||
|
||||
// foreach ($list as $key => &$item) {
|
||||
// foreach ($item as $k => &$v) {
|
||||
// if (in_array($k, $fields)) {
|
||||
// $xunfei = new Xunfei();
|
||||
// $rst_dst = $xunfei->fanyi($v, 'cn', 'ar');
|
||||
// if ($rst_dst) {
|
||||
// $list[$key][$k] = $rst_dst["trans_result"]["dst"];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// unset($v);
|
||||
|
||||
// $id = $item['id'];
|
||||
// unset($item['id']);
|
||||
// unset($item['created_at']);
|
||||
// unset($item['updated_at']);
|
||||
// Db::table('vehicles_ar')->where('id', $id)->update($item);
|
||||
|
||||
// $output->write("{$id}: 翻译 - 已处理 \n");
|
||||
// }
|
||||
// unset($item);
|
||||
|
||||
|
||||
|
||||
|
||||
$list = Location::all()->toArray();
|
||||
|
||||
$fields = ['name', 'address', 'area'];
|
||||
|
||||
foreach ($list as $key => &$item) {
|
||||
foreach ($item as $k => &$v) {
|
||||
if (in_array($k, $fields)) {
|
||||
$xunfei = new Xunfei();
|
||||
$rst_dst = $xunfei->fanyi($v, 'cn', 'ru');
|
||||
if ($rst_dst) {
|
||||
$list[$key][$k] = $rst_dst["trans_result"]["dst"];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($v);
|
||||
|
||||
$id = $item['id'];
|
||||
unset($item['id']);
|
||||
unset($item['created_at']);
|
||||
unset($item['updated_at']);
|
||||
Db::table('locations_ru')->where('id', $id)->update($item);
|
||||
|
||||
$output->write("{$id}: 翻译 - 已处理 \n");
|
||||
}
|
||||
unset($item);
|
||||
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,7 @@ class IndexController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
return view('index/location');
|
||||
header('Location: https://dashboard-server.hesuu.com/app/admin');
|
||||
return;
|
||||
return redirect('http://219.157.255.213:25505/app/admin');
|
||||
static $readme;
|
||||
if (!$readme) {
|
||||
$readme = file_get_contents(base_path('README.md'));
|
||||
|
||||
@@ -3,10 +3,20 @@
|
||||
namespace app\controller;
|
||||
|
||||
use app\model\Vehicle;
|
||||
use app\model\VehicleEn;
|
||||
use app\model\VehicleRu;
|
||||
use app\model\VehicleAr;
|
||||
|
||||
use app\model\Location;
|
||||
use app\model\LocationEn;
|
||||
use app\model\LocationRu;
|
||||
use app\model\LocationAr;
|
||||
|
||||
use app\service\OssService;
|
||||
use plugin\admin\app\model\Location;
|
||||
// use plugin\admin\app\model\Location;
|
||||
use util\Util;
|
||||
use support\Request;
|
||||
use support\Cache;
|
||||
|
||||
class VehicleController
|
||||
{
|
||||
@@ -28,26 +38,85 @@ class VehicleController
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$vehicles = Vehicle::with('location')->with('finalLocation')->get();
|
||||
$vehicles->each(function ($vehicle) {
|
||||
|
||||
$lang = $request->post('lang', 'zh');
|
||||
|
||||
switch ($lang) {
|
||||
case 'zh':
|
||||
$vehicles = Vehicle::with('location')->with('finalLocation')->get();
|
||||
$hz = new Location();
|
||||
break;
|
||||
|
||||
case 'en':
|
||||
$vehicles = VehicleEn::with('location')->with('finalLocation')->get();
|
||||
$hz = new LocationEn();
|
||||
break;
|
||||
|
||||
case 'ru':
|
||||
$vehicles = VehicleRu::with('location')->with('finalLocation')->get();
|
||||
$hz = new LocationRu();
|
||||
break;
|
||||
|
||||
case 'ar':
|
||||
$vehicles = VehicleAr::with('location')->with('finalLocation')->get();
|
||||
$hz = new LocationAr();
|
||||
break;
|
||||
}
|
||||
|
||||
// // $vehicles = Vehicle::with('location')->with('finalLocation')->get();
|
||||
// $vehicles->each(function ($vehicle) use ($hz) {
|
||||
// if (isset($vehicle->vin)) {
|
||||
// $vehicle->vin = $this->maskVin($vehicle->vin);
|
||||
// }
|
||||
|
||||
// // $vehicle->status = $this->status[$vehicle->status]??$this->status[0];
|
||||
// // $location = Location::find($vehicle->locations_id);
|
||||
// // $vehicle->location_name = $location ? $location->name : '';
|
||||
// // $final_location = Location::find($vehicle->final_locations_id);
|
||||
// // $vehicle->final_location_name = $final_location ? $final_location->name : '';
|
||||
// $fbo_location = $hz->find($vehicle->fbo_locations_id);
|
||||
// $vehicle->fbo_destination = $fbo_location ? $fbo_location->name : '';
|
||||
|
||||
// if(!str_starts_with($vehicle['img_url'], 'http')){
|
||||
// $ossservice = new OssService();
|
||||
// $img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400);
|
||||
// $vehicle['img_url'] = $img_url;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// =================================== new ===================================== start
|
||||
// 单独处理 locations
|
||||
$fboIds = $vehicles->pluck('fbo_locations_id')->toArray();
|
||||
$fbo = $hz->whereIn('id', array_unique($fboIds))->get()->toArray();
|
||||
$arr = [];
|
||||
foreach ($fbo as $value) {
|
||||
$arr[$value['id']] = $value;
|
||||
}
|
||||
|
||||
// 组装数据
|
||||
foreach ($vehicles as &$vehicle) {
|
||||
if (isset($vehicle->vin)) {
|
||||
$vehicle->vin = $this->maskVin($vehicle->vin);
|
||||
}
|
||||
|
||||
// $vehicle->status = $this->status[$vehicle->status]??$this->status[0];
|
||||
// $location = Location::find($vehicle->locations_id);
|
||||
// $vehicle->location_name = $location ? $location->name : '';
|
||||
// $final_location = Location::find($vehicle->final_locations_id);
|
||||
// $vehicle->final_location_name = $final_location ? $final_location->name : '';
|
||||
$fbo_location = Location::find($vehicle->fbo_locations_id);
|
||||
$vehicle->fbo_destination = $fbo_location ? $fbo_location->name : '';
|
||||
|
||||
$vehicle->fbo_destination = isset($arr[$vehicle->fbo_locations_id]) ? $arr[$vehicle->fbo_locations_id]['name'] : '';
|
||||
|
||||
if(!str_starts_with($vehicle['img_url'], 'http')){
|
||||
$ossservice = new OssService();
|
||||
$img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400);
|
||||
$vehicle['img_url'] = $img_url;
|
||||
$img_url = Cache::get('img_'.$vehicle->id);
|
||||
if ($img_url) {
|
||||
$vehicle['img_url'] = $img_url;
|
||||
} else {
|
||||
$ossservice = new OssService();
|
||||
$img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400);
|
||||
$vehicle['img_url'] = $img_url;
|
||||
Cache::set('img_'.$vehicle->id, $img_url, 86390);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
unset($vehicle);
|
||||
// =================================== new ===================================== end
|
||||
|
||||
$result = ['list' => $vehicles,'count'=>count($vehicles)];
|
||||
return Util::success($result);
|
||||
}
|
||||
@@ -57,7 +126,27 @@ class VehicleController
|
||||
*/
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
$vehicle = Vehicle::with('location')->find($id);
|
||||
$lang = $request->post('lang', 'zh');
|
||||
|
||||
switch ($lang) {
|
||||
case 'zh':
|
||||
$vehicle = Vehicle::with('location')->find($id);
|
||||
break;
|
||||
|
||||
case 'en':
|
||||
$vehicle = VehicleEn::with('location')->find($id);
|
||||
break;
|
||||
|
||||
case 'ru':
|
||||
$vehicle = VehicleRu::with('location')->find($id);
|
||||
break;
|
||||
|
||||
case 'ar':
|
||||
$vehicle = VehicleAr::with('location')->find($id);
|
||||
break;
|
||||
}
|
||||
|
||||
// $vehicle = Vehicle::with('location')->find($id);
|
||||
if (!$vehicle) {
|
||||
return Util::fail($vehicle,'Vehicle not found');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class LocationAr extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'locations_ar';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function vehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleAr::class, 'locations_id', 'id');
|
||||
}
|
||||
/**
|
||||
* 目的地关联
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function finalVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleAr::class, 'final_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FBO vehicles for the location.
|
||||
*/
|
||||
public function fboVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleAr::class, 'fbo_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include locations that have vehicles.
|
||||
*/
|
||||
public function scopeHasVehicles($query)
|
||||
{
|
||||
return $query->whereHas('vehicles_ar');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class LocationEn extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'locations_en';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function vehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleEn::class, 'locations_id', 'id');
|
||||
}
|
||||
/**
|
||||
* 目的地关联
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function finalVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleEn::class, 'final_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FBO vehicles for the location.
|
||||
*/
|
||||
public function fboVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleEn::class, 'fbo_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include locations that have vehicles.
|
||||
*/
|
||||
public function scopeHasVehicles($query)
|
||||
{
|
||||
return $query->whereHas('vehicles_en');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class LocationRu extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'locations_ru';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function vehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleRu::class, 'locations_id', 'id');
|
||||
}
|
||||
/**
|
||||
* 目的地关联
|
||||
* Get the vehicles for the location.
|
||||
*/
|
||||
public function finalVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleRu::class, 'final_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FBO vehicles for the location.
|
||||
*/
|
||||
public function fboVehicles()
|
||||
{
|
||||
return $this->hasMany(VehicleRu::class, 'fbo_locations_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include locations that have vehicles.
|
||||
*/
|
||||
public function scopeHasVehicles($query)
|
||||
{
|
||||
return $query->whereHas('vehicles_ru');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehicleAr extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'vehicles_ar';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(LocationAr::class, 'locations_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function finalLocation()
|
||||
{
|
||||
return $this->belongsTo(LocationAr::class, 'final_locations_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehicleEn extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'vehicles_en';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(LocationEn::class, 'locations_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function finalLocation()
|
||||
{
|
||||
return $this->belongsTo(LocationEn::class, 'final_locations_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
class VehicleRu extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'vehicles_ru';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(LocationRu::class, 'locations_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the location that owns the vehicle.
|
||||
*/
|
||||
public function finalLocation()
|
||||
{
|
||||
return $this->belongsTo(LocationRu::class, 'final_locations_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace app\util;
|
||||
|
||||
|
||||
class Xunfei
|
||||
{
|
||||
|
||||
protected $error = "";
|
||||
|
||||
public function tocurl($url, $header, $content)
|
||||
{
|
||||
$ch = curl_init();
|
||||
if(substr($url,0,5)=='https'){
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
|
||||
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (is_array($header)) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if (!empty($content)) {
|
||||
if (is_array($content)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
|
||||
} else if (is_string($content)) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
||||
}
|
||||
}
|
||||
$response = curl_exec($ch);
|
||||
$error=curl_error($ch);
|
||||
//var_dump($error);
|
||||
if($error){
|
||||
die($error);
|
||||
}
|
||||
$header = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
$data = array('header' => $header,'body' => $response);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function xfyun($text = "中华人民共和国于1949年成立", $from = "cn", $to = "en")
|
||||
{
|
||||
//在控制台-我的应用-机器翻译获取
|
||||
$app_id = "3d46198c";
|
||||
//在控制台-我的应用-机器翻译获取
|
||||
$api_sec = "ZWY2MmUyNjJjYmFkOTFlYTVmYWVhMGYy";
|
||||
//在控制台-我的应用-机器翻译获取
|
||||
$api_key = "b6d805f240176ecaea85130cb5f2bca1";
|
||||
// 机器翻译接口地址
|
||||
$url = "https://ntrans.xfyun.cn/v2/ots";
|
||||
//body组装
|
||||
// $text = "中华人民共和国于1949年成立";//待翻译文本
|
||||
$body = json_encode($this->getBody($app_id, $from, $to, $text));
|
||||
|
||||
// 组装http请求头
|
||||
$date =gmdate('D, d M Y H:i:s') . ' GMT';
|
||||
|
||||
$digestBase64 = "SHA-256=".base64_encode(hash("sha256", $body, true));
|
||||
$builder = sprintf("host: %s
|
||||
date: %s
|
||||
POST /v2/ots HTTP/1.1
|
||||
digest: %s", "ntrans.xfyun.cn", $date, $digestBase64);
|
||||
// echo($builder);
|
||||
$sha = base64_encode(hash_hmac("sha256", $builder, $api_sec, true));
|
||||
|
||||
$authorization = sprintf("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", $api_key,"hmac-sha256",
|
||||
"host date request-line digest", $sha);
|
||||
|
||||
$header = [
|
||||
"Authorization: ".$authorization,
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json,version=1.0',
|
||||
'Host: ntrans.xfyun.cn',
|
||||
'Date: ' .$date,
|
||||
'Digest: '.$digestBase64
|
||||
];
|
||||
$response = $this->tocurl($url, $header, $body);
|
||||
|
||||
// var_dump($response['body']);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public function getBody($app_id, $from, $to, $text)
|
||||
{
|
||||
$common_param = [
|
||||
'app_id' => $app_id
|
||||
];
|
||||
|
||||
$business = [
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
];
|
||||
|
||||
$data = [
|
||||
"text" => base64_encode($text)
|
||||
];
|
||||
|
||||
return $body = [
|
||||
'common' => $common_param,
|
||||
'business' => $business,
|
||||
'data' => $data
|
||||
];
|
||||
}
|
||||
|
||||
// 翻译
|
||||
public function fanyi($text = "", $from = "", $to = "")
|
||||
{
|
||||
try {
|
||||
$res = $this->xfyun($text, $from, $to);
|
||||
$data = json_decode($res["body"], true);
|
||||
if ($data["code"] === 0) {
|
||||
return $data["data"]["result"];
|
||||
} else {
|
||||
$this->error = $data["message"];
|
||||
return false;
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$this->error = $th->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 异常
|
||||
public function error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-2
@@ -30,8 +30,11 @@
|
||||
"webman/admin": "^2.1",
|
||||
"vlucas/phpdotenv": "^5.6",
|
||||
"illuminate/pagination": "^12.10",
|
||||
"shopwwi/webman-filesystem": "2.0",
|
||||
"iidestiny/flysystem-oss": "4"
|
||||
"symfony/filesystem": "^7.2",
|
||||
"shopwwi/webman-filesystem": "^1.1",
|
||||
"shopwwi/filesystem-oss": "^1.0",
|
||||
"webman/console": "^2.1",
|
||||
"webman/cache": "^2.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
||||
Generated
+1152
-784
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of webman.
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
return [
|
||||
'default' => 'file',
|
||||
'stores' => [
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => runtime_path('cache')
|
||||
],
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default'
|
||||
],
|
||||
'array' => [
|
||||
'driver' => 'array'
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -1,4 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
*-------------------------------------------------------------------------p*
|
||||
* 配置文件
|
||||
*-------------------------------------------------------------------------h*
|
||||
* @copyright Copyright (c) 2015-2022 Shopwwi Inc. (http://www.shopwwi.com)
|
||||
*-------------------------------------------------------------------------c*
|
||||
* @license http://www.shopwwi.com s h o p w w i . c o m
|
||||
*-------------------------------------------------------------------------e*
|
||||
* @link http://www.shopwwi.com by 象讯科技 phcent.com
|
||||
*-------------------------------------------------------------------------n*
|
||||
* @since shopwwi象讯·PHP商城系统Pro
|
||||
*-------------------------------------------------------------------------t*
|
||||
*/
|
||||
|
||||
return [
|
||||
'enable' => true,
|
||||
@@ -64,21 +77,16 @@ return [
|
||||
],
|
||||
'oss' => [
|
||||
'driver' => \Shopwwi\WebmanFilesystem\Adapter\AliyunOssAdapterFactory::class,
|
||||
'accessId' => env('OSS_ACCESS_KEY_ID'),
|
||||
'accessSecret' => env('OSS_ACCESS_KEY_SECRET'),
|
||||
'accessKey' => env('OSS_ACCESS_KEY_ID'),
|
||||
'secretKey' => env('OSS_ACCESS_KEY_SECRET'),
|
||||
'bucket' => env('OSS_BUCKET', 'vehicle-album'),
|
||||
'endpoint' => env('OSS_ENDPOINT', 'https://oss-cn-beijing.aliyuncs.com'),
|
||||
'url' => '', // 静态文件访问域名
|
||||
'isCName' => false,
|
||||
'prefix' => '',
|
||||
'timeout' => 60,
|
||||
'connectTimeout' => 10,
|
||||
'securityToken' => null,
|
||||
'proxy' => null,
|
||||
'useSSL' => true,
|
||||
'signatureVersion' => 'v4',
|
||||
'accessId' => getenv('OSS_ACCESS_KEY_ID'),
|
||||
'accessSecret' => getenv('OSS_ACCESS_KEY_SECRET'),
|
||||
'bucket' => getenv('OSS_BUCKET'),
|
||||
'endpoint' => getenv('OSS_ENDPOINT'),
|
||||
'url' => '' // 静态文件访问域名
|
||||
// 'timeout' => 3600,
|
||||
// 'connectTimeout' => 10,
|
||||
// 'isCName' => false,
|
||||
// 'token' => null,
|
||||
// 'proxy' => null,
|
||||
],
|
||||
'qiniu' => [
|
||||
'driver' => \Shopwwi\WebmanFilesystem\Adapter\QiniuAdapterFactory::class,
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
return [
|
||||
'enable' => true,
|
||||
|
||||
'build_dir' => BASE_PATH . DIRECTORY_SEPARATOR . 'build',
|
||||
|
||||
'phar_filename' => 'webman.phar',
|
||||
|
||||
'bin_filename' => 'webman.bin',
|
||||
|
||||
'signature_algorithm'=> Phar::SHA256, //set the signature algorithm for a phar and apply it. The signature algorithm must be one of Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, or Phar::OPENSSL.
|
||||
|
||||
'private_key_file' => '', // The file path for certificate or OpenSSL private key file.
|
||||
|
||||
'exclude_pattern' => '#^(?!.*(composer.json|/.github/|/.idea/|/.git/|/.setting/|/runtime/|/vendor-bin/|/build/|/vendor/webman/admin/))(.*)$#',
|
||||
|
||||
'exclude_files' => [
|
||||
'.env', 'LICENSE', 'composer.json', 'composer.lock', 'start.php', 'webman.phar', 'webman.bin'
|
||||
],
|
||||
|
||||
'custom_ini' => '
|
||||
memory_limit = 256M
|
||||
',
|
||||
];
|
||||
@@ -3,6 +3,12 @@ declare (strict_types = 1);
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\model\LocationAr;
|
||||
use app\model\LocationEn;
|
||||
use app\model\LocationRu;
|
||||
use app\model\VehicleAr;
|
||||
use app\model\VehicleEn;
|
||||
use app\model\VehicleRu;
|
||||
use app\service\OssService;
|
||||
use plugin\admin\app\model\Location;
|
||||
use support\Log;
|
||||
@@ -97,6 +103,8 @@ class VehicleController extends Crud
|
||||
|
||||
// 合并翻译,确保语言文件中的翻译优先
|
||||
$translations = array_merge($required_translations, $translations);
|
||||
|
||||
|
||||
|
||||
return view('vehicle/index', [
|
||||
'lang' => $lang,
|
||||
@@ -285,13 +293,44 @@ class VehicleController extends Crud
|
||||
foreach ($items as &$item) {
|
||||
$location = Location::find($item->locations_id);
|
||||
// $item->status = $this->status[$item->status]??$this->status[0];
|
||||
$item->status = "已到达迪拜仓库";
|
||||
// $item->status = "已到达迪拜仓库";
|
||||
$item->location_name = $location ? $location->name : '';
|
||||
$final_location = Location::find($item->final_locations_id);
|
||||
$item->final_location_name = $final_location ? $final_location->name : '';
|
||||
$fbo_location = Location::find($item->fbo_locations_id);
|
||||
$item->fbo_location_name = $fbo_location ? $fbo_location->name : '';
|
||||
|
||||
$lang = session('lang', 'zh-cn');
|
||||
switch ($lang) {
|
||||
case 'zh-cn':
|
||||
$vehicle = new \app\model\Vehicle();
|
||||
$hz = new \app\model\Location();
|
||||
break;
|
||||
|
||||
case 'en':
|
||||
$vehicle = new \app\model\VehicleEn();
|
||||
$hz = new \app\model\LocationEn();
|
||||
break;
|
||||
|
||||
case 'ru':
|
||||
$vehicle = new \app\model\VehicleRu();
|
||||
$hz = new \app\model\LocationRu();
|
||||
break;
|
||||
case 'ar':
|
||||
$vehicle = new \app\model\VehicleAr();
|
||||
$hz = new \app\model\LocationAr();
|
||||
break;
|
||||
}
|
||||
|
||||
$location = $hz::find($item->locations_id);
|
||||
$item->location_name = $location ? $location->name : '';
|
||||
$car = $vehicle::find($item->id);
|
||||
$item->status = $car ? $car->status : $item->status;
|
||||
$location = $hz::find($item->final_location_id);
|
||||
$item->final_location_name = $location ? $location->name : '';
|
||||
$location = $hz::find($item->fbo_locations_id);
|
||||
$item->fbo_location_name = $location ? $location->name : '';
|
||||
|
||||
if(!str_starts_with($item['img_url'], 'http')){
|
||||
try {
|
||||
$ossservice = new OssService();
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
<!-- 图 标 -->
|
||||
<img class="logo">
|
||||
<!-- 标 题 -->
|
||||
<a href="https://dashboard.hesultd.com/"><span class="title"><?= $translations['system_name'] ?? 'Vehicle Data Platform' ?></span></a>
|
||||
<a href="http://dashboard.hesuu.com:25506/"><span class="title"><?= $translations['system_name'] ?? 'Vehicle Data Platform' ?></span></a>
|
||||
</div>
|
||||
<!-- 菜 单 内 容 -->
|
||||
<div class="layui-side-scroll">
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
<script>
|
||||
// 页面加载时自动跳转
|
||||
window.onload = function() {
|
||||
window.location.href = 'https://dashboard-server.hesultd.com/app/admin';
|
||||
}
|
||||
// window.onload = function() {
|
||||
// window.location.href = 'https://dashboard-server.hesultd.com/app/admin';
|
||||
// }
|
||||
</script>
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Webman\Config;
|
||||
use Webman\Console\Command;
|
||||
use Webman\Console\Util;
|
||||
use support\Container;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
if (!Phar::running()) {
|
||||
chdir(__DIR__);
|
||||
}
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
if (!$appConfigFile = config_path('app.php')) {
|
||||
throw new RuntimeException('Config file not found: app.php');
|
||||
}
|
||||
|
||||
if (class_exists(Dotenv::class) && file_exists(run_path('.env'))) {
|
||||
if (method_exists(Dotenv::class, 'createUnsafeImmutable')) {
|
||||
Dotenv::createUnsafeImmutable(run_path())->load();
|
||||
} else {
|
||||
Dotenv::createMutable(run_path())->load();
|
||||
}
|
||||
}
|
||||
|
||||
$appConfig = require $appConfigFile;
|
||||
if ($timezone = $appConfig['default_timezone'] ?? '') {
|
||||
date_default_timezone_set($timezone);
|
||||
}
|
||||
|
||||
if ($errorReporting = $appConfig['error_reporting'] ?? '') {
|
||||
error_reporting($errorReporting);
|
||||
}
|
||||
|
||||
if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
|
||||
require_once __DIR__ . '/support/bootstrap.php';
|
||||
} else {
|
||||
if (class_exists('Support\App')) {
|
||||
Support\App::loadAllConfig(['route']);
|
||||
} else {
|
||||
Config::reload(config_path(), ['route', 'container']);
|
||||
}
|
||||
}
|
||||
|
||||
$cli = new Command();
|
||||
$cli->setName('webman cli');
|
||||
$cli->installInternalCommands();
|
||||
if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
|
||||
$cli->installCommands($command_path);
|
||||
}
|
||||
|
||||
foreach (config('plugin', []) as $firm => $projects) {
|
||||
if (isset($projects['app'])) {
|
||||
foreach (['', '/app'] as $app) {
|
||||
if ($command_str = Util::guessPath(base_path() . "/plugin/$firm{$app}", 'command')) {
|
||||
$command_path = base_path() . "/plugin/$firm{$app}/$command_str";
|
||||
$cli->installCommands($command_path, "plugin\\$firm" . str_replace('/', '\\', $app) . "\\$command_str");
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($projects as $name => $project) {
|
||||
if (!is_array($project)) {
|
||||
continue;
|
||||
}
|
||||
$project['command'] ??= [];
|
||||
array_walk($project['command'], [$cli, 'createCommandInstance']);
|
||||
}
|
||||
}
|
||||
|
||||
$cli->run();
|
||||
Reference in New Issue
Block a user