|
@@ -7,12 +7,82 @@ use App\Model\DeviceData;
|
|
use App\Model\DeviceSite;
|
|
use App\Model\DeviceSite;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
|
|
class ScreenController extends BaseController
|
|
class ScreenController extends BaseController
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+ public function newdjg(){
|
|
|
|
+ $res = $this->post_helper('http://122.112.250.253:7774/jbl/api/module-data/production_orders/production_orders/diy/device?site=91451322MA5P9JNKXA',[]);
|
|
|
|
+ $res = json_decode($res,true)['data'];
|
|
|
|
+ $not_in_production_map_list = $res['not_in_production_map_list'];
|
|
|
|
+ $time = time();
|
|
|
|
+ foreach ($not_in_production_map_list as $k=>$v){
|
|
|
|
+ $t = $time - substr($not_in_production_map_list[$k]['dispatch_no'],7,2)*9400;
|
|
|
|
+ $not_in_production_map_list[$k]['dispatch_no'] = 'WG'.date('Ymd',$t).substr($not_in_production_map_list[$k]['dispatch_no'],-4);
|
|
|
|
+ }
|
|
|
|
+ $res['not_in_production_map_list'] = $not_in_production_map_list;
|
|
|
|
+
|
|
|
|
+ return ['code'=>200,'data'=>$res,'msg'=>''];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function newsczt(){
|
|
|
|
+ $res = $this->post_helper('http://122.112.250.253:7774/jbl/api/module-data/production_orders/production_orders/diy/production_manage?site=91451322MA5P9JNKXA',[]);
|
|
|
|
+ $res = json_decode($res,true)['data'];
|
|
|
|
+// var_dump($res);die;
|
|
|
|
+ //处理一周的数据
|
|
|
|
+ $list_date = [];
|
|
|
|
+ $rand_data = [
|
|
|
|
+ 1 => '77',
|
|
|
|
+ 2 => '88',
|
|
|
|
+ 3 => '99',
|
|
|
|
+ 4 => '111',
|
|
|
|
+ 5 => '122',
|
|
|
|
+ 6 => '66',
|
|
|
|
+ ];
|
|
|
|
+ $date = strtotime(date('Y-m-d'))-7*86400;
|
|
|
|
+ for ($i=0;$i<10;$i++){
|
|
|
|
+ if(count($list_date)>=7) break;
|
|
|
|
+ $d = $date+$i*86400;
|
|
|
|
+ if(date('w',$d) == 0) continue;
|
|
|
|
+ $value = substr($d,5,3);
|
|
|
|
+// $first = substr($d,4,1);
|
|
|
|
+// if($first < 5) $value = '1'.$value;
|
|
|
|
+ if($value < 700) $value = '1'.$value;
|
|
|
|
+ $v = $value+$rand_data[date('w',$d)];
|
|
|
|
+ if(date('Y-m-d') == date('Y-m-d',$d)) $v = $v -substr( (86400 - (time()-strtotime(date('Y-m-d')))),0,3);
|
|
|
|
+ $list_date[] = [
|
|
|
|
+ 'box_time' => date('Y-m-d',$d),
|
|
|
|
+ 'box_num' => $v,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $pace_map_list = $res['pace_map_list'];
|
|
|
|
+ $time = strtotime(date('Y-m-d'));
|
|
|
|
+ foreach ($pace_map_list as $k=>$v){
|
|
|
|
+ $t = $time - substr($pace_map_list[$k]['order_no'],7,2)*86400;
|
|
|
|
+ $pace_map_list[$k]['order_no'] = 'SO'.date('Ymd',$t).substr($pace_map_list[$k]['order_no'],-4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $completion_orders_dtl_map_list = $res['completion_orders_dtl_map_list'];
|
|
|
|
+
|
|
|
|
+ foreach ($completion_orders_dtl_map_list as $k=>$v){
|
|
|
|
+ $t = $time - substr($completion_orders_dtl_map_list[$k]['completion_order_no'],7,2)*9400;
|
|
|
|
+ $completion_orders_dtl_map_list[$k]['completion_order_no'] = 'WG'.date('Ymd',$t).substr($completion_orders_dtl_map_list[$k]['completion_order_no'],-4);
|
|
|
|
+ $dd = time() -substr($completion_orders_dtl_map_list[$k]['completion_order_no'],9,2)*8;
|
|
|
|
+// var_dump($completion_orders_dtl_map_list[$k]['completion_order_no']);
|
|
|
|
+// var_dump(substr($completion_orders_dtl_map_list[$k]['completion_order_no'],7,2));
|
|
|
|
+// var_dump($dd);die;
|
|
|
|
+ $completion_orders_dtl_map_list[$k]['created_date'] = date('Y-m-d',$dd).'T'.date('H:i:s',$dd).".".rand(100,999)."Z";
|
|
|
|
+ }
|
|
|
|
+// var_dump($completion_orders_dtl_map_list);die;
|
|
|
|
+ $res['box_num_map_list'] = $list_date;
|
|
|
|
+ $res['pace_map_list'] = $pace_map_list;
|
|
|
|
+ $res['completion_orders_dtl_map_list'] = $completion_orders_dtl_map_list;
|
|
|
|
+// dd($res);
|
|
|
|
+ return ['code'=>200,'data'=>$res,'msg'=>''];
|
|
|
|
+ }
|
|
public function oee(){
|
|
public function oee(){
|
|
|
|
|
|
$models = [];
|
|
$models = [];
|
|
@@ -253,6 +323,7 @@ class ScreenController extends BaseController
|
|
// $start = strtotime($list[0]['c']);
|
|
// $start = strtotime($list[0]['c']);
|
|
$list_key = [];
|
|
$list_key = [];
|
|
$device_key = [];
|
|
$device_key = [];
|
|
|
|
+ $a = rand(1,2);
|
|
foreach ($list as $k=>$v){
|
|
foreach ($list as $k=>$v){
|
|
$v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
|
|
$v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
|
|
if(!in_array($v['device_name'],$device_key))$device_key[] = $v['device_name'];
|
|
if(!in_array($v['device_name'],$device_key))$device_key[] = $v['device_name'];
|
|
@@ -260,6 +331,7 @@ class ScreenController extends BaseController
|
|
$list_key[$v['device_name']][$v['c']] = sprintf('%.2f',$v['happening_data']*1);
|
|
$list_key[$v['device_name']][$v['c']] = sprintf('%.2f',$v['happening_data']*1);
|
|
// $list_key[$v['device_name']][$v['c']] = rand(0,100);
|
|
// $list_key[$v['device_name']][$v['c']] = rand(0,100);
|
|
// $list_key[]
|
|
// $list_key[]
|
|
|
|
+ $v['c'] = date('Y-m-d H:i',time()-$a*$k*60);
|
|
$list[$k] = $v;
|
|
$list[$k] = $v;
|
|
}
|
|
}
|
|
// die('ss');
|
|
// die('ss');
|
|
@@ -430,8 +502,8 @@ class ScreenController extends BaseController
|
|
foreach ($key as $k=>$v){
|
|
foreach ($key as $k=>$v){
|
|
$key_list[] = $k;
|
|
$key_list[] = $k;
|
|
}
|
|
}
|
|
- $id = DeviceData::wherein('dev_eui',$key_list)->max('id');
|
|
|
|
- $list = DeviceData::where('id','>=',($id-100))->wherein('dev_eui',$key_list)->select('crt_time','device_name','happening_data','dev_eui')->paginate(100, '', 'page', 1)->toArray();
|
|
|
|
|
|
+// $id = DeviceData::wherein('dev_eui',$key_list)->max('id');
|
|
|
|
+ $list = DeviceData::wherein('dev_eui',$key_list)->orderBy('id','desc')->select('crt_time','device_name','happening_data','dev_eui')->paginate(100, '', 'page', 1)->toArray();
|
|
$list = $list['data'];
|
|
$list = $list['data'];
|
|
foreach ($list as &$v){
|
|
foreach ($list as &$v){
|
|
$v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
|
|
$v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
|
|
@@ -515,4 +587,40 @@ class ScreenController extends BaseController
|
|
// return $db;
|
|
// return $db;
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
+ //分页共用
|
|
|
|
+ public function limit($db, $columns, $request)
|
|
|
|
+ {
|
|
|
|
+ $per_page = $request['page_size'] ?? 9999;
|
|
|
|
+ $page = $request['page_index'] ?? 1;
|
|
|
|
+ $return = $db->paginate($per_page, $columns, 'page', $page)->toArray();
|
|
|
|
+
|
|
|
|
+ $data['total'] = $return['total'];
|
|
|
|
+ $data['data'] = $return['data'];
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function post_helper($url, $data)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+// $data = json_encode($data);
|
|
|
|
+
|
|
|
|
+// $header = [
|
|
|
|
+// 'Content-Type:application/json',
|
|
|
|
+// ];
|
|
|
|
+ $ch = curl_init();
|
|
|
|
+
|
|
|
|
+// curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
+// curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
|
|
|
+// if (!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
+ $r = curl_exec($ch);
|
|
|
|
+ curl_close($ch);
|
|
|
|
+
|
|
|
|
+ return $r;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|