浏览代码

first commit

cqpCow 1 年之前
父节点
当前提交
009d5e28ba
共有 38 个文件被更改,包括 433 次插入4390 次删除
  1. 0 36
      app/Console/SwooleServer.php
  2. 0 55
      app/Exceptions/Handler.php
  3. 0 83
      app/Exports/CommonExport.php
  4. 0 30
      app/Exports/MyExport.php
  5. 0 446
      app/Http/Controllers/Api/DwyController.php
  6. 0 347
      app/Http/Controllers/Api/EmployeeController.php
  7. 0 67
      app/Http/Controllers/Api/InOutOptionController.php
  8. 0 30
      app/Http/Controllers/Api/LoginController.php
  9. 0 516
      app/Http/Controllers/Api/ScreenController.php
  10. 0 87
      app/Http/Controllers/Api/SysMenuController.php
  11. 0 226
      app/Jobs/DesktopDeviceJob.php
  12. 0 624
      app/Jobs/DoorDeviceJob.php
  13. 0 60
      app/Jobs/LabelDealJob.php
  14. 0 177
      app/Jobs/ManDeviceJob.php
  15. 0 139
      app/Jobs/ProcessDataJob.php
  16. 0 106
      app/Jobs/SendDataJob.php
  17. 0 14
      app/Model/BigKingDevice.php
  18. 0 14
      app/Model/BigKingTbj.php
  19. 0 19
      app/Model/Depart.php
  20. 0 14
      app/Model/DeviceData.php
  21. 0 14
      app/Model/DeviceSite.php
  22. 0 36
      app/Model/Employee.php
  23. 0 19
      app/Model/EmployeeDepartPermission.php
  24. 0 14
      app/Model/EmployeeManagerDepart.php
  25. 0 19
      app/Model/EmployeeMenuPermission.php
  26. 0 14
      app/Model/EmployeeRole.php
  27. 0 19
      app/Model/EmployeeTeamPermission.php
  28. 0 19
      app/Model/Role.php
  29. 0 19
      app/Model/SysMenu.php
  30. 0 260
      app/Service/ClearDataService.php
  31. 0 39
      app/Service/DwyService.php
  32. 0 469
      app/Service/EmployeeService.php
  33. 0 123
      app/Service/InOutOptionService.php
  34. 423 0
      app/Service/JRFIDServerService.php
  35. 0 78
      app/Service/LabelDealService.php
  36. 0 94
      app/Service/SysMenuService.php
  37. 10 0
      config/j_rfid.php
  38. 0 64
      routes/api.php

+ 0 - 36
app/Console/SwooleServer.php

@@ -1,36 +0,0 @@
-<?php
-use Swoole\Server;
-
-$server = new Server('http://cloud_device.qingyaokeji.com/', 9501, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
-
-$server->set([
-    'worker_num'      => 1, //工作进程数
-    'task_worker_num' => 5, //任务工作进程数
-    'log_file' => '/www/server/file.log', //日志文件目录
-//    'task_use_object' => true, //用于设置是否使用面向对象风格的 Task 回调格式。
-    'max_connection' => 3, //最大连接数
-//    'upload_tmp_dir' => '/path/to/tmp/dir',  //上传文件的临时存储路径
-//    'daemonize' => true, //守护进程
-]);
-
-//注册一个回调函数,当有客户端连接到服务器时触发。回调函数内的代码会在客户端连接时执行。
-$server->on('connect', function ($server, $fd) {
-    echo "Client {$fd} connected.\n";
-});
-
-//注册一个回调函数,当服务器从已连接的客户端接收数据时触发。回调函数内的代码会在接收到客户端发送的数据时执行
-$server->on('receive', function ($server, $fd, $from_id, $data) {
-    echo "Received data from client {$fd}: {$data}\n";
-    $server->send($fd, "Server received: {$data}");
-});
-
-//注册一个回调函数,当服务器与客户端断开连接时触发。回调函数内的代码会在客户端断开连接时执行。
-$server->on('close', function ($server, $fd) {
-    echo "Client {$fd} closed.\n";
-});
-
-$server->on('Task', function ($task) {
-    // 处理任务回调逻辑
-    echo "Client222222222222";
-});
-$server->start();

+ 0 - 55
app/Exceptions/Handler.php

@@ -1,55 +0,0 @@
-<?php
-
-namespace App\Exceptions;
-
-use Exception;
-use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
-
-class Handler extends ExceptionHandler
-{
-    /**
-     * A list of the exception types that are not reported.
-     *
-     * @var array
-     */
-    protected $dontReport = [
-        //
-    ];
-
-    /**
-     * A list of the inputs that are never flashed for validation exceptions.
-     *
-     * @var array
-     */
-    protected $dontFlash = [
-        'password',
-        'password_confirmation',
-    ];
-
-    /**
-     * Report or log an exception.
-     *
-     * @param  \Exception  $exception
-     * @return void
-     *
-     * @throws \Exception
-     */
-    public function report(Exception $exception)
-    {
-        parent::report($exception);
-    }
-
-    /**
-     * Render an exception into an HTTP response.
-     *
-     * @param  \Illuminate\Http\Request  $request
-     * @param  \Exception  $exception
-     * @return \Symfony\Component\HttpFoundation\Response
-     *
-     * @throws \Exception
-     */
-    public function render($request, Exception $exception)
-    {
-        return parent::render($request, $exception);
-    }
-}

+ 0 - 83
app/Exports/CommonExport.php

@@ -1,83 +0,0 @@
-<?php
-
-namespace App\Exports;
-
-
-use Illuminate\Support\Collection;
-use Illuminate\Support\Facades\Redis;
-use Maatwebsite\Excel\Concerns\FromCollection;
-
-use Maatwebsite\Excel\Concerns\WithEvents;     // 自动注册事件监听器
-use Maatwebsite\Excel\Concerns\WithStrictNullComparison;    // 导出 0 原样显示,不为 null
-use Maatwebsite\Excel\Events\AfterSheet;
-
-
-
-
-class CommonExport implements FromCollection, WithEvents, WithStrictNullComparison
-{
-
-    public $data;
-
-    /**
-     * @return \Illuminate\Support\Collection
-     */
-    public function __construct($data)
-    {
-        $this->data = $data;
-    }
-
-    public function registerEvents(): array
-    {
-        //这边处理数据格式
-
-        //关于表单的合并
-        $params = $this->data['params'];
-
-        $style = [
-            AfterSheet::class => function (AfterSheet $event) use($params) {
-                $count = count($this->data['data']);
-
-                //设置区域单元格水平居中
-                $event->sheet->getDelegate()->getStyle('A1:'.'BZ'.($count+1))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
-
-
-                //合并相关
-                $merge = $params['merge'];
-                $event->sheet->getDelegate()->setMergeCells($merge);
-            },
-        ];
-
-        return $style;
-
-    }
-
-
-    //数组转集合
-    public function collection()
-    {
-        return new Collection($this->createData());
-    }
-    //业务代码
-    public function createData()
-    {
-        $data = $this->export();
-        return $data;
-
-    }
-
-    private function export(){
-//        var_dump($this->data);die;
-        $data = $this->data['data'];
-        $list = [];
-        foreach ($data as $v){
-            $list[] = $v;
-        }
-        return $list;
-    }
-
-
-
-
-
-}

+ 0 - 30
app/Exports/MyExport.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Exports;
-
-use Maatwebsite\Excel\Facades\Excel;
-
-
-
-
-class MyExport {
-
-    public $base1_path = '/app';
-    public $base2_path = '/excel';
-
-    public function commonExport($data,$path = ''){
-
-        $param = $data;
-        $export = new CommonExport($param);
-        $date = date('Ymd');
-        $path = $date.'/'.$path;
-        Excel::store($export, $path);
-        return ['file'=>$this->base2_path.'/'.$path];
-    }
-
-
-    public function excelDownload($file){
-        return response()->file(storage_path().$this->base1_path.$this->base2_path.'/'.$file);
-    }
-
-}

+ 0 - 446
app/Http/Controllers/Api/DwyController.php

@@ -1,446 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Model\BigKingTbj;
-use App\Service\EmployeeService;
-use App\Service\SysMenuService;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Redis;
-use Illuminate\Support\Str;
-
-class DwyController extends BaseController
-{
-
-
-    public function advertisement()
-    {
-
-        return ['status' => 200, 'data' => [
-            'video' => ['https://clouddevice.qingyaokeji.com/1.mp4',
-                'https://clouddevice.qingyaokeji.com/2.mp4'],
-            'img' => [
-                'https://clouddevice.qingyaokeji.com/3.jpeg',
-                'https://clouddevice.qingyaokeji.com/3.jpeg',
-            ],
-            'limit_time' => 10
-        ]];
-    }
-
-    public function openCommand(Request $request)
-    {
-        $data = $request->all();
-        file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
-        $device_id = $data['device_code'];
-        $box_code = $data['box_code'];
-        $key = $data['type'];
-        if ($key === 'UP') {
-            $num = Redis::get($device_id . 'status_num');
-            if (empty($num)) $num = 0;
-            $num++;
-
-            if ($num === 1) {
-                Redis::set($device_id . 'status_num', $num);
-                Redis::expire($device_id . 'status_num', 300);
-
-                Redis::set($device_id . 'status', 201);
-                Redis::expire($device_id . 'status', 300);
-
-                Redis::set($device_id, json_encode([$box_code]));
-                Redis::expire($device_id, 300);
-            } else {
-
-                $old = Redis::get($device_id);
-                if (empty($old)) $old = [];
-                else $old = json_decode($old, true);
-                $data = array_merge($old, [$box_code]);
-                Redis::set($device_id, json_encode($data));
-                Redis::expire($device_id, 300);
-
-                Redis::del($device_id . 'status');
-                Redis::del($device_id . 'status_num');
-            }
-
-        } else {
-            Redis::set($device_id, json_encode([$box_code]));
-            Redis::expire($device_id, 300);
-        }
-
-        return ['status' => 200];
-
-
-    }
-
-    public function openDoor(Request $request)
-    {
-        $data = $request->all();
-        file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
-        $data = $data['device_code'];
-        $code = Redis::get($data);
-        Redis::del($data);
-//        return ['data'=>['CK00001','CK00018'],'status'=>200];
-        if (empty($code)) return ['data' => [], 'status' => 201];
-
-        $status = Redis::get($data . 'status');
-        if (empty($status)) $status = 200;
-        return ['data' => json_decode($code, true), 'status' => $status];
-    }
-
-
-    public function getOpenCommand(Request $request)
-    {
-
-        $data = $request->all();
-        file_put_contents('dwy1.txt', json_encode($data) . PHP_EOL, 8);
-        $device_id = $data['device_code'];
-        $box_code = $data['box_code'];
-        $key = $device_id . '_' . $box_code;
-        $return = 201;
-        $status = Redis::get($key);
-        if ($status) {
-            $return = 200;
-            Redis::del($key);
-        }
-
-        return ['status' => $return];
-    }
-
-    public function boxList(Request $request)
-    {
-        $param = $request->all();
-        $token = $param['token'];
-        $device_code = $param['device_code'];
-
-        //商标仓列表
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/device/device/diy/device_code';
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' . $token,
-        ];
-        $box_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
-        $box_data = json_decode($box_data, true);
-        if (isset($box_data['status']) && $box_data['status'] === 'success') {
-            //库存查询
-            $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
-            $stock_data = $this->post_helper($url, '{"device_code":"' . $device_code . '"}', $header);
-            $stock_data = json_decode($stock_data, true);
-            if ($stock_data) {
-                $list = [];
-                $material_list = [];
-                foreach ($box_data['data'] as $v) {
-                    $list[$v['box_code']] = [
-                        'material_code' => $v['material_code'],
-                        'material_code_show' => $v['material_code_show'],
-                        'box_code' => $v['box_code'],
-                        'box_code_show' => $v['box_code_show'],
-                        'min_stock_qty' => $v['min_stock_qty'] ?? 0,
-                        'safe_stock_qty' => $v['safe_stock_qty'] ?? 0,
-                        'status' => 1, //0设备仓中没有对应库存,1有对应库存,2对应商标仓中还有数量不允许上标
-                        'qty' => 0,
-                    ];
-                    $material_list[$v['material_code']][] = $v['box_code'];
-                }
-
-                $return = [];
-                foreach ($stock_data as $v) {
-                    if (isset($material_list[$v['material_code']]) && $v['box_code'] == 'CK00001' && $v['qty'] > 0) {
-                        foreach ($material_list[$v['material_code']] as $vv) {
-                            $list[$vv]['status'] = 1;
-                        }
-                    }
-                    if (isset($list[$v['box_code']]) && $v['qty'] > 0) {
-                        $list[$v['box_code']]['qty'] = $v['qty'];
-                    }
-                }
-                foreach ($list as $v) {
-                    if ($v['qty'] > 0) {
-                        $v['status'] = 2;
-                    }
-                    $return[] = $v;
-                }
-                return ['status' => 'success', 'data' => $return];
-            }
-
-        }
-
-        return $box_data;
-
-
-    }
-
-
-    public function setLb(Request $request)
-    {
-
-        $param = $request->all();
-        file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
-//        $param = [
-//            'token'=>'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNzM2OTUyNTA3NTI5NTQzNzMiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfQVJSRVNULFJPTEVfQURNSU4iLCJ0b2tlbklkIjoiOTUwIiwiZXhwIjoxNzA3OTcxMTcxfQ.2VQ9Wqmk4rvKAcTsQPw59llBbeXjalKDGIZA4kesnuOJ0POmPVOVlRLbTtUDxl0XiFdPDUrKzuEFl2DXSgQdJg',
-//            'list'=>[
-//                [
-//                    'title'=>'优选A7家具板ENF小标',
-//                    'num'=>'20',
-//                ],[
-//                    'title'=>'植萃除醛圆标',
-//                    'num'=>'10',
-//                ],
-//            ],
-//        ];
-        $token = $param['token'];
-        $list = $param['list'];
-        $mac = $param['mac'];
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' . $token,
-        ];
-        $data = $this->post_helper($url, '{"device_code":"'.$mac.'"}', $header);
-        $data = json_decode($data, true);
-
-        usort($data, function ($a,$b){
-            return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
-        });
-        foreach ($data as $k => &$v) {
-
-            if (!isset($v['product_list'])) $v['product_list'] = [];
-            if (!isset($v['box_code_show']) || $v['box_code_show'] == '设备仓') {
-                unset($data[$k]);
-                continue;
-            }
-//            $v['use_qty'] = $v['qty'];
-//            if($v['box_code'] === 'CK00008'){
-//                $v['use_qty'] = 150;
-//                $v['qty'] = 150;
-////                $v['qty'] = 200;
-//                $v['in_stock_qty'] = 0;
-//            }
-
-            if ($v['qty'] <= 0) {
-                unset($data[$k]);
-                continue;
-            }
-            $v['use_qty'] = $v['qty'];
-            if (!isset($v['send_qty'])) $v['send_qty'] = 0;
-            foreach ($list as $kk => $vv) {
-
-
-                if ($vv['num'] == 0) continue;
-                if ($v['material_code_show'] === $vv['title']) {
-                    $v['restore_qty'] = isset($vv['restock_qty']) && $vv['restock_qty'] > 0 ? $vv['restock_qty'] : 0;
-                    if (($v['qty'] - $v['send_qty']) > $vv['num']) {
-                        $list[$kk]['num'] -= $vv['num'];
-                        $v['send_qty'] += $vv['num'];
-                        $p_total = $vv['num'];
-                    } else {
-                        $list[$kk]['num'] -= ($v['qty'] - $v['send_qty']);
-                        $p_total = $vv['num'] - ($v['qty'] - $v['send_qty']);
-                        $v['send_qty'] += ($v['qty'] - $v['send_qty']);
-                    }
-
-
-                    //把产品相关参数进行封装
-                    ////产品编号
-                    //"product_code": "",
-                    ////产品名称
-                    //"product_code_show": "",
-                    ////工艺
-                    //"process_title": "",
-                    ////花色
-                    //"color": "",
-                    ////工艺2
-                    //"process_title_two": "",
-                    ////花色2
-                    //"color_two": "",
-                    $key_arr = [
-                        'product_code' => $vv['product_code'] ?? '',
-                        'product_code_show' => $vv['product_code_show'] ?? '',
-                        'order_item_id' => $vv['order_item_id'] ?? '',
-                        'order_item_id_show' => $vv['order_item_id_show'] ?? '',
-                        'process_title' => $vv['process_title'] ?? '',
-                        'color' => $vv['color'] ?? '',
-                        'process_title_two' => $vv['process_title_two'] ?? '',
-                        'color_two' => $vv['color_two'] ?? '',
-                        'send_qty' => $p_total,
-                        'fake_qty' => $p_total,
-//                        'send_qty' => 0,
-                        'restock_qty' => $vv['restock_qty'] ?? 0,
-                    ];
-                    $v['product_list'][] = $key_arr;
-                }
-
-
-
-            }
-        }
-
-        usort($data, function ($a,$b){
-            return str_replace('CK','',$a['box_code']) - str_replace('CK','',$b['box_code']);
-        });
-        return ['status' => 200, 'data' => $data];
-    }
-
-    public function zjlb(Request $request)
-    {
-
-        $param = $request->all();
-        file_put_contents('dwy1.txt', json_encode($param) . PHP_EOL, 8);
-//        $param = [
-//            'token'=>'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNzM2OTUyNTA3NTI5NTQzNzMiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfQVJSRVNULFJPTEVfQURNSU4iLCJ0b2tlbklkIjoiOTUwIiwiZXhwIjoxNzA3OTcxMTcxfQ.2VQ9Wqmk4rvKAcTsQPw59llBbeXjalKDGIZA4kesnuOJ0POmPVOVlRLbTtUDxl0XiFdPDUrKzuEFl2DXSgQdJg',
-//            'list'=>[
-//                [
-//                    'title'=>'优选A7家具板ENF小标',
-//                    'num'=>'20',
-//                ],[
-//                    'title'=>'植萃除醛圆标',
-//                    'num'=>'10',
-//                ],
-//            ],
-//        ];
-//        dd(json_encode($param));
-//        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/box_inventory';
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/box_inventory_dtl_qr/page';
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' . $request->header('Authorization'),
-        ];
-        $param = '{"direction":"DESC","property":"id","fromClientType":"pc","number":0,"sorts":[],"rules":[{"field":"box_inventory.device_code","option":"LIKE_ANYWHERE","values":["'.$param['device_code'].'"]}],"size":15,"specialConditions":[],"workflowSearchBean":{},"dynamicFormCode":"box_inventory","developmentSystemId":null,"debugFlag":true}';
-        $data = $this->post_helper($url, $param, $header);
-//        $data = $this->post_helper($url, json_encode($param), $header);
-        $data = json_decode($data, true);
-        $data = $data['content'] ?? [];
-        foreach ($data as $k => &$v) {
-            $v['material_code_show'] = $v['box_inventory']['material_code_show'];
-            $v['qty'] = $v['roll_qty'];
-            $v['use_qty'] = 0;
-        }
-        sort($data);
-        return json_encode($data);
-    }
-
-    public function boxOut(Request $request)
-    {
-
-
-        $param = $request->all();
-        file_put_contents('dwy.txt', json_encode($param) . PHP_EOL, 8);
-        //商标绑定
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/1';
-//        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind';
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' . $request->header('Authorization'),
-        ];
-        $lead_bind = $param['lead_bind'];
-        $this->post_helper($url, json_encode($lead_bind), $header);
-
-        //商标出库
-//        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/11';
-        $lead_bind = $param['lead_out'];
-        $this->post_helper($url, json_encode($lead_bind), $header);
-        return ['status'=>200,'msg'=>'success'];
-    }
-
-    public function post_helper($url, $data, $header)
-    {
-        $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);
-        file_put_contents('33.txt',$r.PHP_EOL,8);
-        return $r;
-
-    }
-
-    public function setTbData(Request $request){
-        $data = $request->all();
-        if(empty($data['id']) && empty($data['data'])) return [201, ''];
-
-        BigKingTbj::updateOrCreate(
-            ['id' => $data['id']], //查询条件
-            [
-                "id" => $data['id'],
-                "data" => json_encode($data['data'])
-            ]  //添加或者修改的数据
-        );
-
-        return [200, ''];
-    }
-
-    public function getTbData(Request $request){
-        $data = $request->all();
-        if(empty($data['id'])) return [201, ''];
-
-        $result = BigKingTbj::where('id',$data['id'])->first();
-        if(empty($result)) return [200,'data' => []];
-        $result = $result->toArray();
-
-        return [200, 'data' => json_decode($result['data'],true)];
-    }
-    public function setBoxTrademark(Request $request){
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_sale_order/brand_sale_order/diy/find_roll_qr_code_list';
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' .'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9JTk5FUl9VU0VSLFJPTEVfQlJBTkRfU1VQUExJRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9VU0VfQlJBTkRfU1VQUExJRVIsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2MzM1NTJ9.CC69s4dpUdd9UqQlpeK5UF3DwY5Zenn-YHv8Iy1ai0cCXgere7r7jskWU9ARmKotys2tCGYRlO-Idtxdwdsefg',
-        ];
-        $data  = [
-            'roll_qr_code_list' => [
-                '171368443563212'
-            ]
-        ];
-        $a = $this->post_helper($url, json_encode($data), $header);
-        var_dump($a);die;
-        $a = json_decode($a,true);
-        $detail = [];
-        foreach ($a['data'] as $v){
-            $code = $v['brand_qr_code'];
-            $detail[] = $code;
-        }
-        file_put_contents('1.txt',json_encode($detail));
-        var_dump($a);die;
-    }
-
-
-    public function getBoxTrademark(Request $request){
-        $data = $request->all();
-        if(empty($data['box_nos']) && empty($data['mac'])) return ['status' => 201,'data' => []];
-
-        $box_nos = $data['box_nos'];
-        $dv = $data['mac'];
-        $detail = [];
-
-        //测试写入文件
-//        foreach ($box_nos as $v) {
-//            $filePath = storage_path( "app/box_trade/"."{$dv}_{$v}.txt");
-//            if (! file_exists(storage_path('box_trade'))) Storage::makeDirectory('box_trade');
-//            file_put_contents($filePath,json_encode(['a' => '测试','b'=>'测试2']));
-//        }
-
-        //读取文件
-        foreach ($box_nos as $v) {
-            //            $filePath = public_path($file_path . "{$dv}_{$v}.txt");
-            $filePath = storage_path("app/box_trade/"."{$dv}_{$v}.txt");
-            if(file_exists($filePath)){
-                if (($content = file_get_contents($filePath)) === false) continue;
-                $decodedContent = json_decode($content, true);
-                if (json_last_error() !== JSON_ERROR_NONE) continue;
-                $detail[] = [
-                    'detail'=>$decodedContent,
-                    'code'=>$v,
-                ];
-            }
-        }
-
-        return ['status' => 200, 'data' => $detail];
-    }
-
-
-}

+ 0 - 347
app/Http/Controllers/Api/EmployeeController.php

@@ -1,347 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\EmployeeService;
-use App\Service\SysMenuService;
-use Illuminate\Http\Request;
-
-
-class EmployeeController extends BaseController
-{
-
-
-
-
-
-    public function employeeEdit(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->employeeEdit($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function employeeAdd(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->userData->toArray();
-        list($status,$data) = $service->employeeAdd($request->all(),$user);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function employeeDel(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function employeeList(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-    public function roleEdit(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->roleEdit($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function roleAdd(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->roleAdd($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function roleDel(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->roleDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function roleList(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->roleList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-    public function departEdit(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->departEdit($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function departAdd(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->departAdd($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function departDel(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->departDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function departList(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->departList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function teamEdit(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->teamEdit($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function teamAdd(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->teamAdd($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function teamDel(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->teamDel($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function teamList(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->teamList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function employeeDepart(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeDepart($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-    public function employeeTeam(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeTeam($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-    public function employeeRole(Request $request)
-    {
-
-
-        $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeRole($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-
-}

+ 0 - 67
app/Http/Controllers/Api/InOutOptionController.php

@@ -1,67 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use App\Service\InOutOptionService;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Redis;
-
-class InOutOptionController extends BaseController
-{
-    public function setOrderNumber(Request $request){
-        $service = new InOutOptionService();
-        list($status,$data) = $service->setOrderNumber($request->all());
-
-        echo 'ok';die;
-    }
-
-    public function getOrderNumber(Request $request){
-        $service = new InOutOptionService();
-        list($status,$data) = $service->getOrderNumber($request->all(),$request->header('Site'));
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function setFhMessage(Request $request){
-        $service = new InOutOptionService();
-        $service->setFhMessage($request->all(),$request->header('Site'));
-
-        echo 'ok';
-    }
-
-    public function inout(){
-        $i = 'inout_key_state';
-        $s = Redis::get($i);
-        if($s){
-            $key = 'inout_key';
-            $a = Redis::get($key);
-            if(empty($a)){
-                $a = 1;
-            } else{
-                if($a == 1) $a = 2;
-                else $a = 1;
-            }
-            Redis::set($key,$a);
-
-            if($a == 1) $type = '出库';
-            else $type = '入库';
-
-            $detail = [
-                'project'=>'南京福猴建材有限公司',
-                'type'=>$type,
-                'num'=>'2',
-                'order_no'=>'PG2023101900818',
-                '时间'=>date('Y-m-d H:i:s'),
-            ];
-            Redis::del($i);
-            return $this->json_return(200,'',$detail);
-        }
-
-        return $this->json_return(200,'',[]);
-
-    }
-}

+ 0 - 30
app/Http/Controllers/Api/LoginController.php

@@ -9,14 +9,6 @@ use Illuminate\Support\Facades\Log;
 //登录
 class LoginController extends BaseController
 {
-    const MOBILE = '[mobile]';// 手机端
-    const PERSONAL_COMPUTER = '[personalComputer]';// 电脑端
-
-    public static $port = [
-        self::MOBILE => '',
-        self::PERSONAL_COMPUTER => '',
-    ];
-
     public function login(Request $request){
         $data = $request->only("account","password");
 
@@ -25,28 +17,6 @@ class LoginController extends BaseController
         list($bool, $return) = $result;
         if(! $bool) return $this->json_return(201,'',$return);
 
-        //日志
-        $res = Log::channel('login')->info("登录成功", $return);
-
-        //生成token
-        $jwtToken = TokenService::getToken($return['id']);
-        $jwtToken = self::PERSONAL_COMPUTER . $jwtToken;
-
-        return $this->json_return(200,'', ['token' => $jwtToken, 'emp_name'=>$return['name']]);
-    }
-
-    public function loginMobile(Request $request){
-        $data = $request->only("account","password");
-
-        //登录
-        $result = (new EmployeeService())->loginRule($data);
-        list($bool, $return) = $result;
-        if(! $bool) return $this->json_return(201,'',$return);
-
-        //生成token
-        $jwtToken = TokenService::getToken($return['id']);
-        $jwtToken = self::MOBILE . $jwtToken;
-
         return $this->json_return(200,'', ['token' => $jwtToken]);
     }
 }

+ 0 - 516
app/Http/Controllers/Api/ScreenController.php

@@ -1,516 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Model\DeviceData;
-use App\Model\DeviceSite;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Redis;
-
-
-class ScreenController extends BaseController
-{
-
-    public function oee(){
-
-        $models = [];
-        $site = 1;
-        $list = DeviceSite::where('site',$site)->where('title','压板上升')->groupBy('device_name')->pluck('device_name')->toArray();
-        foreach ($list as  $v){
-            $models[$v] = [
-                "machine_day_num"=> 0,
-                "machine_month_num"=> 0,
-                "machine_week_num"=> 0,
-                "break_day_num"=> 0,
-                "break_month_num"=> 0,
-                "break_week_num"=> 0,
-                "start_time"=> '',
-                "rate"=> 0
-            ];
-        }
-        $device_point_key = DeviceSite::where('site',$site)->select(
-            '*'
-        )->get()->toArray();
-        //失败次数
-        $err_key = [];
-        foreach ($device_point_key as $v){
-            if($v['title'] == '急停') $err_key[] = $v['key'];
-        }
-        list($day_key,$week_key,$month_key) = $this->initCount($err_key);
-        //当天最早开始时间
-        $dayStart = strtotime(date('Y-m-d')); //
-        $start_time = DeviceData::groupBy('device_name')->where('crt_time','>=',$dayStart)->select(DB::raw('min(crt_time) as crt_time'),'device_name')->get()->toArray();
-        $start_key = [];
-        foreach ($start_time as $v){
-            $v['device_name'] = str_replace('广西大王椰','',$v['device_name']);
-            $start_key[$v['device_name']] = $v['crt_time'];
-        }
-        //运行次数
-        $run_key = [];
-        foreach ($device_point_key as $v){
-            if($v['title'] == '压板上升') $run_key[] = $v['key'];
-        }
-        list($run_day_key,$run_week_key,$run_month_key) = $this->initCount($run_key);
-        //当天的开始与结束时间戳
-
-        foreach ($models as $k=>$v){
-            $a = rand(0,5)+(rand(0,100)/100);
-            $models[$k]['break_day_num'] = $day_key[$k]??0;
-            $models[$k]['title'] = str_replace('广西大王椰','',$k);
-            $models[$k]['break_month_num'] = $month_key[$k]??0;
-            $models[$k]['break_week_num'] = $week_key[$k]??0;
-            $models[$k]['start_time'] = $start_key[$k]??0;
-            $models[$k]['machine_day_num'] = $run_day_key[$k]??0;
-            $models[$k]['machine_month_num'] = $run_week_key[$k]??0;
-            $models[$k]['machine_week_num'] = $run_month_key[$k]??0;
-
-
-            //工作次数
-            $process_num  = $run_day_key[$k] ?? 0;
-            //故障次数
-            $fault_tmp = $day_key[$k] ?? 0;
-            //工作时间
-            $process_time_tmp = $this->calTimeReturnMin($run_day_key[$k]??0);
-            //故障时间
-            $fault_time_tmp = $this->calTimeReturnMin($day_key[$k]??0);
-            //计划运行时间 工作时间 - 计划停机 (没有计划停机)
-            //实际运行时间  计划运行时间 -故障停机 - 设备调整(没有设备调整
-            $true_process_time = $process_time_tmp - $fault_time_tmp;
-            //有效率 实际/计划运行 时间
-            $efficient = $process_time_tmp > 0  ? number_format($true_process_time / $process_time_tmp,2) : 0;
-            //表现性 加工数量/实际运行时间
-            $expressive = $true_process_time > 0 ? number_format($process_num / $true_process_time,2) : 0;
-            //质量指数 加工数量- 废品数量 / 加工数量
-            $quality_index = $process_num > 0 ? number_format(($process_num - $fault_tmp) / $process_num,2) : 0;
-            //OEE
-
-            $oee = number_format($efficient * $expressive * $quality_index,2);
-            if($oee >  $a ) $oee -= $a;
-            $models[$k]['rate'] = sprintf('%.2f',$oee);
-        }
-        sort($models);
-        return $this->json_return(200,'',$models);
-    }
-
-    public function initCount($key){
-
-        $lastMonthStart = strtotime(date('Y-m-01', strtotime('-1 month'))); // 上个月的第一天
-        $lastMonthEnd = strtotime(date('Y-m-t', strtotime('-1 month')))+86400; // 上个月的最后一天
-        $lastWeekStart = strtotime(date('Y-m-d', strtotime('-1 week last Monday'))); // 上周的周一
-        $lastWeekEnd = strtotime(date('Y-m-d', strtotime('-1 week next Sunday'))); // 上周的周日
-        $dayStart = strtotime(date('Y-m-d')); //
-        $dayEnd = $dayStart+86400; // 上周的周日
-        $month = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$lastMonthStart)->where('crt_time','<',$lastMonthEnd)->select(DB::raw('count(1) as c'),'device_name')->get()->toArray();
-//        var_dump($month);die;
-        $month_key = [];
-        foreach ($month as $v){
-            $v['device_name'] = str_replace('广西大王椰','',$v['device_name']);
-            $month_key[$v['device_name']] = $v['c'];
-        }
-        $week = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$lastWeekStart)->where('crt_time','<',$lastWeekEnd)->select(DB::raw('count(1) as c'),'device_name')->get()->toArray();
-        $wee_key = [];
-        foreach ($week as $v){
-            $v['device_name'] = str_replace('广西大王椰','',$v['device_name']);
-            $wee_key[$v['device_name']] = $v['c'];
-        }
-        $day = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$dayStart)->where('crt_time','<',$dayEnd)->select(DB::raw('count(1) as c'),'device_name')->get()->toArray();
-        $day_key = [];
-        foreach ($day as $v){
-            $v['device_name'] = str_replace('广西大王椰','',$v['device_name']);
-            $day_key[$v['device_name']] = $v['c'];
-        }
-        return [$day_key,$wee_key,$month_key];
-    }
-
-    public function wyOee(){
-        $models = [];
-        $site = 1;
-        $list = DeviceSite::where('site',$site)->wherein('title',['主缸压力','压力','温度'])->groupBy('device_name')->pluck('device_name')->toArray();
-        foreach ($list as  $v){
-            $models[$v] = [
-                "y_day_num"=> 0,
-                "y_month_num"=> 0,
-                "y_week_num"=> 0,
-                "w_day_num"=> 0,
-                "w_month_num"=> 0,
-                "w_week_num"=> 0,
-                "start_time"=> '',
-                "rate_y"=> 0,
-                "rate_w"=> 0,
-            ];
-        }
-        $device_point_key = DeviceSite::where('site',$site)->select(
-            '*'
-        )->get()->toArray();
-        //失败次数
-        $err_key = [];
-        foreach ($device_point_key as $v){
-            if($v['title'] == '主缸压力'||$v['title'] == '压力') $err_key[] = $v['key'];
-        }
-        list($day_key,$week_key,$month_key) = $this->wyiInitCount($err_key);
-        //运行次数
-        $run_key = [];
-        foreach ($device_point_key as $v){
-            if($v['title'] == '温度') $run_key[] = $v['key'];
-        }
-        list($run_day_key,$run_week_key,$run_month_key) = $this->wyiInitCount($run_key);
-
-        //当天最早开始时间
-        $dayStart = strtotime(date('Y-m-d')); //
-        $start_time = DeviceData::groupBy('device_name')->where('crt_time','>=',$dayStart)->select(DB::raw('min(crt_time) as crt_time'),'device_name')->get()->toArray();
-        $y_time = DeviceData::groupBy('device_name')->orderBy('id','desc')->where('crt_time','>=',$dayStart)->wherein('dev_eui',$err_key)->select('happening_data','device_name')->get()->toArray();
-        $w_time = DeviceData::groupBy('device_name')->orderBy('id','desc')->where('crt_time','>=',$dayStart)->wherein('dev_eui',$run_key)->select('happening_data','device_name')->get()->toArray();
-        $start_key = [];
-        $now_w_key = [];
-        $now_y_key = [];
-        foreach ($start_time as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $start_key[$v['device_name']] = $v['crt_time'];
-        }
-        foreach ($y_time as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $now_y_key[$v['device_name']] = $v['happening_data'];
-        }
-        foreach ($w_time as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $now_w_key[$v['device_name']] = $v['happening_data'];
-        }
-        //当天的开始与结束时间戳
-        foreach ($models as $k=>$v){
-            $models[$k]['y_day_num'] = $day_key[$k]??0;
-            $models[$k]['title'] = str_replace('广西大王椰','',$k);
-            $models[$k]['y_month_num'] = $month_key[$k]??0;
-            $models[$k]['y_week_num'] = $week_key[$k]??0;
-            $models[$k]['start_time'] = $start_key[$k]??0;
-            $models[$k]['w_day_num'] = $run_day_key[$k]??0;
-            $models[$k]['w_month_num'] = $run_week_key[$k]??0;
-            $models[$k]['w_week_num'] = $run_month_key[$k]??0;
-
-
-            $models[$k]['rate_w'] = isset($now_w_key[$k]) ?sprintf('%.2f',$now_w_key[$k]):0;
-            $models[$k]['rate_y'] =  isset($now_y_key[$k]) ? sprintf('%.2f',$now_y_key[$k]):0;
-            if( $models[$k]['rate_y']>10) $models[$k]['rate_y'] =  sprintf('%.2f',($models[$k]['rate_y']/100));
-        }
-        sort($models);
-        return $this->json_return(200,'',$models);
-    }
-
-    public function wyiInitCount($key){
-
-        $lastMonthStart = strtotime(date('Y-m-01', strtotime('-1 month'))); // 上个月的第一天
-        $lastMonthEnd = strtotime(date('Y-m-t', strtotime('-1 month')))+86400; // 上个月的最后一天
-        $lastWeekStart = strtotime(date('Y-m-d', strtotime('-1 week last Monday'))); // 上周的周一
-        $lastWeekEnd = strtotime(date('Y-m-d', strtotime('-1 week next Sunday'))); // 上周的周日
-        $dayStart = strtotime(date('Y-m-d')); //
-        $dayEnd = $dayStart+86400; // 上周的周日
-        $month = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$lastMonthStart)->where('crt_time','<',$lastMonthEnd)->select(DB::raw('sum(happening_data) as s'),DB::raw('count(1) as c'),'device_name')->get()->toArray();
-        $month_key = [];
-        foreach ($month as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $month_key[$v['device_name']] = sprintf('%.2f',($v['s']/$v['c']));
-        }
-//        var_dump($key);
-//        var_dump($lastWeekStart);
-//        var_dump($lastMonthEnd);
-        $week = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$lastWeekStart)->where('crt_time','<',$lastWeekEnd)->select(DB::raw('sum(happening_data) as s'),DB::raw('count(1) as c'),'device_name')->get()->toArray();
-        $wee_key = [];
-        foreach ($week as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $wee_key[$v['device_name']] = sprintf('%.2f',($v['s']/$v['c']));
-        }
-        $day = DeviceData::wherein('dev_eui',$key)->groupBy('device_name')->where('crt_time','>=',$dayStart)->where('crt_time','<',$dayEnd)->select(DB::raw('sum(happening_data) as s'),DB::raw('count(1) as c'),'device_name')->get()->toArray();
-        $day_key = [];
-        foreach ($day as $v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $day_key[$v['device_name']] = sprintf('%.2f',($v['s']/$v['c']));
-        }
-        return [$day_key,$wee_key,$month_key];
-    }
-
-
-    /**
-     * 用于计算时间
-     * @param $minute
-     * @return string
-     */
-    public function calTimeReturnMin($minute){
-        return number_format($minute * 1.5 / 60,2);
-    }
-
-    //温度明细、折线
-    public function wd(Request $request){
-
-        //明细
-        $request = $request->all();
-//        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->wherein('title',['温度'])->groupBy('key')->pluck('key')->toArray();
-        $max_time = DeviceData::wherein('dev_eui',$key)->max('crt_time');
-        $start = $max_time-1800;
-        $list = DeviceData::wherein('dev_eui',$key)->where('crt_time','>=',$start)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
-//        $list = $list['data'];
-//        $start = strtotime($list[0]['c']);
-        $list_key = [];
-        $device_key = [];
-        foreach ($list as $k=>$v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            if(!in_array($v['device_name'],$device_key))$device_key[] = $v['device_name'];
-            $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[]
-            $list[$k] = $v;
-        }
-//        die('ss');
-        $time_list = [];
-        $data_key = [];
-        for ($i=$start;$i<$max_time;$i= $i+60){
-            $time_key = date('Y-m-d H:i',$i);
-            $time_list[] = $time_key;
-            foreach ($device_key as $v){
-                if(isset($list_key[$v][$time_key])) $data_key[$v][] = $list_key[$v][$time_key];
-                else $data_key[$v][] = 0;
-            }
-        }
-        $return = [];
-        $return[0][] =  '设备名称';
-        foreach ($time_list as $v){
-            $return[0][] = $v;
-        }
-        $n = 0;
-        foreach ($data_key as $k=>$v){
-            $n++;
-            $return[$n][] = $k;
-            foreach ($v as $vv){
-                if($vv < 0) $vv = -$vv;
-                $return[$n][] = $vv;
-            }
-        }
-//        var_dump($time_list);
-//        var_dump($data_key);die;
-        //折线
-//        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select('crt_time','device_name','happening_data')->get()->toArray();
-        return $this->json_return(200,'',['return'=>$return,'list'=>$list]);
-    }
-    //压力明细、折线
-    public function yl(Request $request){
-
-        //明细
-        $request = $request->all();
-        $start = isset($request['start_time']) ? $request['start_time'] : time()-8000;
-//        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->wherein('title',['主缸压力','压力'])->groupBy('key')->pluck('key')->toArray();
-        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
-        if(empty($list)) {
-            $time = DeviceData::max('crt_time');
-            $s_time = $time-8000;
-            $list = DeviceData::where('crt_time','>=',$s_time)->wherein('dev_eui',$key)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H:%i') as c"),'device_name','happening_data')->get()->toArray();
-        }
-
-        $list_key = [];
-        $device_key = [];
-        foreach ($list as $k=>$v){
-            if($v['happening_data'] > 10) $v['happening_data'] = sprintf('%.2f',$v['happening_data']/1000);
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            if(!in_array($v['device_name'],$device_key))$device_key[] = $v['device_name'];
-            $list_key[$v['device_name']][$v['c']] = sprintf('%.2f',$v['happening_data']*1);
-//            $list_key[]
-            $list[$k] = $v;
-        }
-//        die('ss');
-        $time_list = [];
-        $data_key = [];
-        $count = time();
-        if(! empty($time)) {
-            $start = $s_time;
-            $count = $time;
-        }
-        for ($i=$start;$i<$count;$i= $i+60){
-            $time_key = date('Y-m-d H:i',$i);
-            $time_list[] = $time_key;
-            foreach ($device_key as $v){
-                if(isset($list_key[$v][$time_key])) $data_key[$v][] = $list_key[$v][$time_key];
-                else $data_key[$v][] = 0;
-            }
-        }
-        $return = [];
-        $return[0][] =  '设备名称';
-        foreach ($time_list as $v){
-            $return[0][] = $v;
-        }
-        $n = 0;
-        foreach ($data_key as $k=>$v){
-            $n++;
-            $return[$n][] = $k;
-            foreach ($v as $vv){
-                $return[$n][] = $vv;
-            }
-        }
-//        var_dump($time_list);
-//        var_dump($data_key);die;
-        //折线
-//        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select('crt_time','device_name','happening_data')->get()->toArray();
-        return $this->json_return(200,'',['return'=>$return,'list'=>$list]);
-    }
-
-    //故障明细、折线
-    public function gz(Request $request){
-
-        //明细
-        $request = $request->all();
-//        $start = isset($request['start_time']) ? $request['start_time'] : time()-864000;
-//        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->wherein('title',['急停'])->groupBy('key')->pluck('key')->toArray();
-        $list = DeviceData::wherein('dev_eui',$key)->where('happening_data',1)->select('crt_time','device_name','happening_data');
-//        $list = $this->limi
-        $list = $list->paginate(50, '*', 'page', 1)->toArray();
-        $list = $list['data'];
-        foreach ($list as &$v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $v['crt_time'] = date('Y-m-d H:i:s',$v['crt_time']);
-        }
-        //折线
-//        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select('crt_time','device_name','happening_data')->get()->toArray();
-        return $this->json_return(200,'',$list);
-    }
-
-    public function gzEchart(){
-
-        $start = time()-86400*150;
-        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->wherein('title',['急停'])->groupBy('key')->pluck('key')->toArray();
-        $list = DeviceData::wherein('dev_eui',$key)->where('happening_data',1)->select(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H') as c") ,DB::raw("count(id) as s"),'device_name','happening_data')->groupBy('dev_eui')->groupBy(DB::raw("DATE_FORMAT(FROM_UNIXTIME(crt_time), '%Y-%m-%d %H')"));
-        $list = $list->where('crt_time','>=',$start);
-        $list = $list->paginate(50, '', 'page', 1)->toArray();
-        $list = $list['data'];
-        $list_key = [];
-        $device_key = [];
-        $time_list = [];
-        foreach ($list as $k=>$v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            if(!in_array($v['device_name'],$device_key))$device_key[] = $v['device_name'];
-            $list_key[$v['device_name']][$v['c']] = $v['s'];
-//            $list_key[]
-            $list[$k] = $v;
-            if(!in_array($v['c'],$time_list))$time_list[] = $v['c'];
-        }
-//        die('ss');
-       sort($time_list);
-        $return = [];
-       foreach ($time_list as $v){
-           foreach ($list_key as $k=>$vv){
-              if(!isset($return[$k]))  $return[$k] = [];
-              if(isset($vv[$v])) $return[$k][] =  $vv[$v];
-              else  $return[$k][] = 0;
-           }
-//           $return[] = $detail;
-       }
-       $detail = [];
-       foreach ($return as $k=>$v){
-           $detail[] = [
-               'title' => $k,
-               'list' => $v,
-           ];
-       }
-//       var_dump($return);die;
-        return $this->json_return(200,'',['return'=>$detail,'x'=>$time_list]);
-    }
-
-    //机器云明细,机器云折线
-    public function deviceAll(Request $request){
-
-        //明细
-        $request = $request->all();
-//        $start = isset($request['start_time']) ? $request['start_time'] : time()-200;
-//        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->groupBy('key')->pluck('title','key')->toArray();
-        $key_list = [];
-        foreach ($key as $k=>$v){
-            $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();
-        $list = $list['data'];
-        foreach ($list as &$v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-            $v['crt_time'] = date('Y-m-d H:i:s',$v['crt_time']);
-            $v['title'] = $key[$v['dev_eui']];
-        }
-        //折线
-//        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select('crt_time','device_name','happening_data')->get()->toArray();
-        return $this->json_return(200,'',$list);
-    }
-
-    //机器云明细,机器云折线
-    public function deviceChart(Request $request){
-
-        //明细
-        $request = $request->all();
-        $start = isset($request['start_time']) ? $request['start_time'] : time()-100000;
-//        $end = isset($request['start_time']) ? $request['start_time'] : time();
-        $key = DeviceSite::where('site',1)->wherein('title',['温度'])->groupBy('key')->pluck('key')->toArray();
-        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
-        if(empty($list)){
-            $time = DeviceData::max('crt_time');
-            $s_time = $time-100000;
-            $list = DeviceData::where('crt_time','>=',$s_time)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
-        }
-        foreach ($list as &$v){
-            $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
-        }
-        //折线
-//        $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select('crt_time','device_name','happening_data')->get()->toArray();
-        return $this->json_return(200,'',$list);
-    }
-
-    public function inout(){
-        $i = 'inout_key_state';
-        $s = Redis::get($i);
-        if($s){
-            $key = 'inout_key';
-            $a = Redis::get($key);
-            if(empty($a)){
-                $a = 1;
-            } else{
-                if($a == 1) $a = 2;
-                else $a = 1;
-            }
-            Redis::set($key,$a);
-
-            if($a == 1) $type = '出库';
-            else $type = '入库';
-
-            $detail = [
-                'project'=>'南京福猴建材有限公司',
-                'type'=>$type,
-                'num'=>'2',
-                'order_no'=>'PG2023101900818',
-                '时间'=>date('Y-m-d H:i:s'),
-            ];
-            Redis::del($i);
-            return $this->json_return(200,'',$detail);
-        }
-
-        return $this->json_return(200,'',[]);
-
-    }
-
-    public function upInout(){
-        $i = 'inout_key_state';
-        $s = Redis::set($i,1);
-    }
-
-    public function t(){
-        $a = bin2hex('PG2023103000182');
-        echo             '00'.$a;
-    }
-//
-//    public function endDb($db,$start_time){
-//
-//        $end_time = $start_time-86400;
-//        $start_time =
-//        $db = $db->where('crt_time','>=',$start_time)->
-//        return $db;
-//    }
-
-}

+ 0 - 87
app/Http/Controllers/Api/SysMenuController.php

@@ -1,87 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-
-use App\Service\SysMenuService;
-use Illuminate\Http\Request;
-
-
-class SysMenuController extends BaseController
-{
-
-
-
-
-
-    public function add(Request $request)
-    {
-
-
-        $service = new SysMenuService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->add($request->all(),$request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function edit(Request $request)
-    {
-
-
-        $service = new SysMenuService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->edit($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function del(Request $request)
-    {
-
-
-        $service = new SysMenuService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->del($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-    public function menuList(Request $request)
-    {
-
-
-        $service = new SysMenuService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->menuList($request->all());
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-
-    }
-
-
-
-
-}

+ 0 - 226
app/Jobs/DesktopDeviceJob.php

@@ -1,226 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Service\ClearDataService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Illuminate\Support\Facades\Redis;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class DesktopDeviceJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $url;
-
-    /**
-     * Create a new job instance
-     *
-     * @return void
-     */
-    public function __construct($data)
-    {
-        $this->data = $data;
-        $this->url = config('ip.zs');
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        try{
-            $first = ltrim($this->data[0],'0');//取第一个值
-            $order_num = hex2bin($first); //十六进制字符串转回 原来字符串
-            file_put_contents('record_complete.txt',date("Y-m-d H:i:s",time())."原数据:$first" . "解析后:" . $order_num . PHP_EOL,8);
-            if(! $order_num) return;
-
-            // 使用Redis Facade设置键名为order_number的值,当键名不存在时才设置成功
-            if (Redis::setnx($order_num, $order_num)) {
-                Redis::expire($order_num, 120);
-
-                $dispatchList = $this->getDispatchList($order_num);
-                if(empty($dispatchList) || empty($dispatchList['content'])) return;
-                $this->completionOrders($dispatchList,$first);
-
-                file_put_contents('send_record.txt',date('Y-m-d H:i:s').$order_num . PHP_EOL,8);
-            }
-
-            //输出信息 测试
-            $this->echoMessage(new ConsoleOutput());
-        }catch (\Exception $exception){
-            file_put_contents('record_error.txt',date("Y-m-d H:i:s",time()).json_encode($this->data) . PHP_EOL.$exception->getMessage().PHP_EOL,8);
-        }
-    }
-
-    public function getDispatchList($data){
-        if(empty($data)) return [];
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        $url = $this->url . 'jbl/api/module-data/dispatch_orders/page';
-        $post = [
-            'direction' => 'DESC',
-            'property' => 'id',
-            'fromClientType' => 'pc',
-            'number' => 0,
-            'sorts' => [],
-            'rules' => [['field' =>'dispatch_orders.dispatch_no','option' => 'LIKE_ANYWHERE', 'values' => [$data]]],
-            "size"=> 15,
-            "specialConditions" => [],
-            "workflowSearchBean" => [],
-            "dynamicFormCode" => "dispatch_orders",
-            "dynamicFormTable" => null,
-            "ignoreField" => true,
-            "developmentSystemId" => null,
-            "debugFlag" => true,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json",'Site:91451322MA5P9JNKXA'];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_get_dispatch.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
-
-        return json_decode($response,true);
-    }
-
-    public function completionOrders($data,$tag){
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        //组织数据
-        $total = 0;
-        $completion_orders_dtl = [];
-        $first = $data['content'][0]['dispatch_orders'];
-        foreach ($data['content'] as $value){
-            $total += $value['dispatch_num'];
-            $completion_orders_dtl[] = [
-                "item_num" => $value['item_num'],
-                "product_no" => $value['product_no'],
-                "in_product_tile" => $value['in_product_tile'],
-                "in_process_title" => $value['in_process_title'],
-                "in_color" => $value['in_color'],
-                "in_process_title_two" => $value['in_process_title_two'],
-                "in_color_two" => $value['in_color_two'],
-                "product_size" => $value['product_size'],
-                "product_unit" => $value['product_unit'],
-                "product_unit_title" => $value['product_unit_title'],
-                "finished_num" => $value['dispatch_num'],
-                "dispatch_num" => $value['dispatch_num'],
-                "production_num" => $value['production_num'],
-                "production_no" => $value['production_no'],
-                "production_item_no" => $value['production_item_no'],
-                "dispatch_order_no" => $first['dispatch_no'],
-//                "dispatch_item_no" => $value['dispatch_item_no'],
-                "order_no" => $value['order_no'],
-                "order_item_no" => $value['order_item_no'],
-                "customer_no" => $value['customer_no'],
-                "customer_name" => $value['customer_name'],
-                "dealer_no" => $value['dealer_no'],
-                "dealer_name" => $value['dealer_name'],
-                "product_title" => $value['product_title'],
-                "process_title" => $value['process_title'],
-                "color" => $value['color'],
-                "process_title_two" => $value['process_title_two'],
-                "color_two" => $value['color_two'],
-                "color_code_two" => $value['color_code_two'],
-//                "dispatch_item_id" => $value['dispatch_item_id'],
-                "process_code_two" => $value['process_code_two'],
-                "color_code" => $value['color_code'],
-                "order_item_id" => $value['order_item_id'],
-                "production_item_id" => $value['production_item_id'],
-                "process_code" => $value['process_code'],
-                "process_router_id" => $value['process_router_id'],
-                "craft_type_dk" => $value['craft_type_dk'],
-                "craft_type_dk_show" => $value['craft_type_dk_show'],
-                "mat_type" => $value['mat_type'],
-                "site" =>  null,
-//                "not_finished_num" => $value['not_finished_num'],
-//                "lineId" => $value['lineId'],
-//                "mainKey" => $value['mainKey']
-            ];
-        }
-
-        $completion_orders = [
-            "completion_order_no" => null,
-            "completion_time" => gmdate("Y-m-d\TH:i:s.000\Z"),
-            "process_id" => $first['process_id'],
-            "team_id" => $first['team_id'],
-            "equipment_id" => $first['equipment_id'],
-            "employee_id" => $first['employee_id'],
-            "remark" => $first['remark'],
-            "site" => null,
-            "created_by" => null,
-            "created_date" => null,
-            "last_modified_by" => null,
-            "last_modified_date" => null,
-            "process_id_show" => $first['process_id_show'],
-            "team_id_show" => $first['team_id_show'],
-            "equipment_id_show" => $first['equipment_id_show'],
-            "employee_id_show" => $first['employee_id_show'],
-            "tag" => $tag,
-            "completion_type" => 'COMPLETION_AFTER_QUALITY',
-            "completion_type_show" => '完工扫码',
-            "finished_num_total" => $total,
-        ];
-        $post = [
-            "bizTypeEk" => "LOWCODE",
-            "bizId" => -1,
-            "data" => [
-                "completion_orders_dtl" => $completion_orders_dtl,
-                "completion_orders" => $completion_orders,
-            ],
-            "dynamicFormId" => "474201923419320320",
-            "showModelId" => "474382714828959744"
-        ];
-        //组织数据------
-        $url = $this->url . 'jbl/api/module-data/completion_orders/completion_orders';
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json",'Site:91451322MA5P9JNKXA'];
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_get_dispatch.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
-    }
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln($this->data);
-    }
-}

+ 0 - 624
app/Jobs/DoorDeviceJob.php

@@ -1,624 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Service\ClearDataService;
-use App\Service\InOutOptionService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Illuminate\Support\Facades\Redis;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class DoorDeviceJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $type;
-    protected $site;
-    protected $device_id;
-
-    /**
-     * Create a new job instance
-     *
-     * @return void
-     */
-    public function __construct($data,$type,$site,$device_id)
-    {
-        $this->data = $data;
-        $this->type = $type;
-        $this->site = $site ?? '91451322MA5P9JNKXA';
-        $this->device_id = $device_id;
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        try{
-            $epc = $this->data;
-            $type = $this->type;//1 入库 2 出库
-            $order_number = [];
-            foreach ($epc as $value){
-                $str = @hex2bin($value);
-                $str = ltrim($str, "\x00");// 代0字符串
-                $str = str_replace(chr(26), '', $str); //过滤CRTL-Z字符
-                if(! empty($str) && substr($str, 0, 2) === "BZ"){
-                    if(! in_array($str, $order_number)) $order_number[] = $str; // 十六进制字符串转回原来字符串
-                }
-            }
-            file_put_contents('record_door_data.txt',date("Y-m-d H:i:s",time())."原数据:".json_encode($epc) . "解析后:" . json_encode($order_number) .PHP_EOL.'start'.PHP_EOL,8);
-            if(empty($order_number)) return;
-
-            $this->zs($type,$order_number);
-
-            //输出信息 测试
-            $this->echoMessage(new ConsoleOutput());
-        }catch (\Exception $exception){
-            file_put_contents('record_door_error.txt',date("Y-m-d H:i:s",time()).json_encode($this->data) . PHP_EOL.$exception->getMessage()."line" . $exception->getLine().PHP_EOL,8);
-        }
-    }
-
-    //测试--------------------------------------
-    public function getDeviceStateCs($data){
-        if(empty($data)) return [];
-        list($status,$token) = ClearDataService::getTokenCs();
-        if(! $status) return [];
-
-        $site = $this->site;
-        $url = "http://121.36.142.167:7774/jbl/api/module-data/device/device/diy/machine_code_list";
-        $post = [
-            'machine_code_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getDoorState'.PHP_EOL,8);
-        $result = json_decode($response,true);
-        if(empty($result)) return false;
-        $first = $result[0];
-        return $first['status'];
-    }
-
-    public function productionReceiptCs($data){
-        list($status,$token) = ClearDataService::getTokenCs();
-        if(! $status) return;
-
-        $site = $this->site;
-        $url = "http://121.36.142.167:7774/jbl/api/module-data/box_orders/box_orders/diy/production_receipt";
-        $post = [
-            'defective_order_no_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'in_opt'.PHP_EOL,8);
-
-        $return = json_decode($response,true);
-        if(! empty($return['data'])){
-            $expire_time = 10;
-            $key = $this->device_id . InOutOptionService::OrderKeyQueueIn;
-            Redis::set($key, json_encode($return['data']));
-            Redis::expire($key, $expire_time);
-        }
-    }
-
-    public function getDispatchListCs($data){
-        if(empty($data)) return [];
-        list($status,$token) = ClearDataService::getTokenCs();
-        if(! $status) return [];
-
-        $site = $this->site;
-        $url = "http://121.36.142.167:7774/jbl/api/module-data/box_orders/box_orders/diy/defective_order_no_list";
-        $post = [
-            'defective_order_no_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
-
-        return json_decode($response,true);
-    }
-
-    public function completionOrdersCs($data,$type){
-        list($status,$token) = ClearDataService::getTokenCs();
-        if(! $status) return;
-
-        $site = $this->site;
-        $device_id = $this->device_id;
-        //组织数据
-        $main_dtl = $orderNo = [];
-        if($type == 1){
-            $opt = InOutOptionService::OrderKeyQueueIn;
-            $url = 'http://121.36.142.167:7774/jbl/api/module-data/production_receipt/production_receipt';
-            $dynamicFormId = "473758926009479168";
-            $showModelId = "473761325902147584";
-            foreach ($data as $value){
-                if(empty($value['box_orders']['delivery_status'])){
-                    $main_dtl[] = [
-                        "product_code"=> $value['brand_code'],
-                        "product_title"=> $value['product_title'],
-                        "product_size"=> $value['product_size'],
-                        "color"=> $value['color'],
-                        "color_two"=> $value['color_two'],
-                        "product_unit_title"=> $value['product_unit_title'],
-                        "product_unit"=> $value['product_unit'],
-                        "color_code"=> $value['color_code'],
-                        "color_code_two"=> $value['color_code_two'],
-                        "in_num"=> $value['box_num'],
-                    ];
-                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
-                }
-            }
-            $datas = [
-                'production_receipt' => [
-                    'production_receipt_no' => null,
-                    'in_out_type' => 'RK007',
-                    'box_title' => 'WH05001',
-                    'in_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
-                    'status' => "NOT_APPROVED",
-                ],
-                'production_receipt_dtl' => $main_dtl
-            ];
-        }else{
-            $opt = InOutOptionService::OrderKeyQueueOut;
-            $url = 'http://121.36.142.167:7774/jbl/api/module-data/picking_out/picking_out';
-            $dynamicFormId = "473763313217908736";
-            $showModelId = "473771977253269504";
-            $item = 0;
-            $site_b = $site_b_show = "";
-            foreach ($data as $value){
-                if(empty($value['box_orders']['delivery_status'])){
-                    $item = $item + 1;
-                    if(empty($site_b)) $site_b = $value['site'];
-                    if(empty($site_b_show)) $site_b_show = $value['site_show'];
-                    $main_dtl[] = [
-                        "product_code"=> $value['brand_code'],
-                        "product_title"=> $value['product_title'],
-                        "product_size"=> $value['product_size'],
-                        "color"=> $value['color'],
-                        "color_two"=> $value['color_two'],
-                        "product_unit_title"=> $value['product_unit_title'],
-                        "product_unit"=> $value['product_unit'],
-                        "color_code"=> $value['color_code'],
-                        "color_code_two"=> $value['color_code_two'],
-                        "in_num"=> $value['box_num'],
-                        "bus_type" => "BOX",
-                        "bus_type_show" => "包装明细",
-                        "bus_id" => $value['box_orders']['id'],
-                        "bus_no" => $value['box_orders']['defective_order_no'],
-                        "item_num" => $item,
-                        "bus_item_no" => $value['item_num'],
-                        "bus_item_id" => $value['id'],
-                        "order_no" => $value['order_no'],
-                        "customer_no" => $value['customer_no'],
-                        "customer_name" => $value['customer_name'],
-                        "dealer_no" => $value['dealer_no'],
-                        "dealer_name" => $value['dealer_name'],
-                        "site" => $value['site'],
-                        "site_show" => $value['site_show'],
-                    ];
-                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
-                }
-            }
-            $datas = [
-                'picking_out' => [
-                    'picking_out_no' => null,
-                    'in_out_type' => 'CK010',
-                    'box_title' => 'WH05001',
-                    'out_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
-                    'status' => "NOT_APPROVED",
-                    'in_out_type_show' => "通道门成品出库",
-                    'box_title_show' => "成品仓",
-                    "site" => $site_b,
-                    "site_show" => $site_b_show
-                ],
-                'picking_out_product' => $main_dtl
-            ];
-        }
-
-        if(! empty($main_dtl)){
-            //有产品
-            $post = [
-                "bizTypeEk" => "LOWCODE",
-                "bizId" => -1,
-                "data" => $datas,
-                "dynamicFormId" => $dynamicFormId,
-                "showModelId" => $showModelId
-            ];
-        }
-        //组织数据------
-        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . json_encode($post) .PHP_EOL.'post'.PHP_EOL,8);
-
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        $result = json_decode($response,true);
-        if(! empty($result['createdDate'])) {
-            $expire_time = 10;
-            $key = $device_id . $opt;
-            Redis::set($key, json_encode($orderNo));
-            Redis::expire($key, $expire_time);
-        }
-
-        file_put_contents('record_door_result_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
-    }
-
-    public function cs($type,$order_number){
-        //获取是否开启通道门
-        $bool = $this->getDeviceStateCs([$this->device_id]);
-        if(! $bool) {
-            file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'door_not_open'.PHP_EOL,8);
-            return;
-        }
-
-        if($type == 1){
-            //入库
-            $this->productionReceiptCs($order_number);
-        }else{
-            //出库
-            //获取包装单产品
-            $dispatchList = $this->getDispatchListCs($order_number);
-            if(empty($dispatchList) || empty($dispatchList['data'])) {
-                file_put_contents('record_door_result_cs.txt',date("Y-m-d H:i:s",time()).'getlist_end'.PHP_EOL,8);
-                return;
-            }
-            $this->completionOrdersCs($dispatchList['data'],$type);
-        }
-    }
-    //测试--------------------------------------
-
-
-    //正式--------------------------------------
-    public function getDeviceState($data){
-        if(empty($data)) return [];
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return [];
-
-        $site = $this->site;
-        $url = "http://122.112.250.253:7774/jbl/api/module-data/device/device/diy/machine_code_list";
-        $post = [
-            'machine_code_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getDoorState'.PHP_EOL,8);
-        $result = json_decode($response,true);
-        if(empty($result)) return false;
-        $first = $result[0];
-        return $first['status'];
-    }
-
-    public function productionReceipt($data){
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        $site = $this->site;
-        $url = "http://122.112.250.253:7774/jbl/api/module-data/box_orders/box_orders/diy/production_receipt";
-        $post = [
-            'defective_order_no_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'in_opt'.PHP_EOL,8);
-
-        $return = json_decode($response,true);
-        if(! empty($return['data'])){
-            $expire_time = 10;
-            $key = $this->device_id . InOutOptionService::OrderKeyQueueIn;
-            Redis::set($key, json_encode($return['data']));
-            Redis::expire($key, $expire_time);
-        }
-    }
-
-    public function getDispatchList($data){
-        if(empty($data)) return [];
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return [];
-
-        $site = $this->site;
-        $url = "http://122.112.250.253:7774/jbl/api/module-data/box_orders/box_orders/diy/defective_order_no_list";
-        $post = [
-            'defective_order_no_list' => $data,
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-        $json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',json_encode($post));
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => $json,
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'getlist'.PHP_EOL,8);
-
-        return json_decode($response,true);
-    }
-
-    public function completionOrders($data,$type){
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        $site = $this->site;
-        $device_id = $this->device_id;
-        //组织数据
-        $main_dtl = $orderNo = [];
-        if($type == 1){
-            $opt = InOutOptionService::OrderKeyQueueIn;
-            $url = 'http://122.112.250.253:7774/jbl/api/module-data/production_receipt/production_receipt';
-            $dynamicFormId = "473758926009479168";
-            $showModelId = "473761325902147584";
-            foreach ($data as $value){
-                if(empty($value['box_orders']['delivery_status'])){
-                    $main_dtl[] = [
-                        "product_code"=> $value['brand_code'],
-                        "product_title"=> $value['product_title'],
-                        "product_size"=> $value['product_size'],
-                        "color"=> $value['color'],
-                        "color_two"=> $value['color_two'],
-                        "product_unit_title"=> $value['product_unit_title'],
-                        "product_unit"=> $value['product_unit'],
-                        "color_code"=> $value['color_code'],
-                        "color_code_two"=> $value['color_code_two'],
-                        "in_num"=> $value['box_num'],
-                    ];
-                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
-                }
-            }
-            $datas = [
-                'production_receipt' => [
-                    'production_receipt_no' => null,
-                    'in_out_type' => 'RK007',
-                    'box_title' => 'WH05001',
-                    'in_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
-                    'status' => "NOT_APPROVED",
-                ],
-                'production_receipt_dtl' => $main_dtl
-            ];
-        }else{
-            $opt = InOutOptionService::OrderKeyQueueOut;
-            $url = 'http://122.112.250.253:7774/jbl/api/module-data/picking_out/picking_out';
-            $dynamicFormId = "473763313217908736";
-            $showModelId = "473771977253269504";
-            $item = 0;
-            $site_b = $site_b_show = "";
-            foreach ($data as $value){
-                if(empty($value['box_orders']['delivery_status'])){
-                    $item = $item + 1;
-                    if(empty($site_b)) $site_b = $value['site'];
-                    if(empty($site_b_show)) $site_b_show = $value['site_show'];
-                    $main_dtl[] = [
-                        "product_code"=> $value['brand_code'],
-                        "product_title"=> $value['product_title'],
-                        "product_size"=> $value['product_size'],
-                        "color"=> $value['color'],
-                        "color_two"=> $value['color_two'],
-                        "product_unit_title"=> $value['product_unit_title'],
-                        "product_unit"=> $value['product_unit'],
-                        "color_code"=> $value['color_code'],
-                        "color_code_two"=> $value['color_code_two'],
-                        "in_num"=> $value['box_num'],
-                        "bus_type" => "BOX",
-                        "bus_type_show" => "包装明细",
-                        "bus_id" => $value['box_orders']['id'],
-                        "bus_no" => $value['box_orders']['defective_order_no'],
-                        "item_num" => $item,
-                        "bus_item_no" => $value['item_num'],
-                        "bus_item_id" => $value['id'],
-                        "order_no" => $value['order_no'],
-                        "customer_no" => $value['customer_no'],
-                        "customer_name" => $value['customer_name'],
-                        "dealer_no" => $value['dealer_no'],
-                        "dealer_name" => $value['dealer_name'],
-                        "site" => $value['site'],
-                        "site_show" => $value['site_show'],
-                    ];
-                    if(! in_array($value['box_orders']['defective_order_no'], $orderNo)) $orderNo[] = $value['box_orders']['defective_order_no'];
-                }
-            }
-            $datas = [
-                'picking_out' => [
-                    'picking_out_no' => null,
-                    'in_out_type' => 'CK010',
-                    'box_title' => 'WH05001',
-                    'out_time' => gmdate("Y-m-d\TH:i:s.000\Z"),
-                    'status' => "NOT_APPROVED",
-                    'in_out_type_show' => "通道门成品出库",
-                    'box_title_show' => "成品仓",
-                    "site" => $site_b,
-                    "site_show" => $site_b_show
-                ],
-                'picking_out_product' => $main_dtl
-            ];
-        }
-
-        if(! empty($main_dtl)){
-            //有产品
-            $post = [
-                "bizTypeEk" => "LOWCODE",
-                "bizId" => -1,
-                "data" => $datas,
-                "dynamicFormId" => $dynamicFormId,
-                "showModelId" => $showModelId
-            ];
-        }else{
-            file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . "no_products" .PHP_EOL.'post'.PHP_EOL,8);
-            return;
-        }
-
-        //组织数据------
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . json_encode($post) .PHP_EOL.'post'.PHP_EOL,8);
-
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json","Site:{$site}"];
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        $result = json_decode($response,true);
-        if(! empty($result['createdDate'])) {
-            $expire_time = 10;
-            $key = $device_id . $opt;
-            Redis::set($key, json_encode($orderNo));
-            Redis::expire($key, $expire_time);
-        }
-
-        file_put_contents('record_door_result.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.'create'.PHP_EOL,8);
-    }
-
-    public function zs($type,$order_number){
-        //获取是否开启通道门
-        $bool = $this->getDeviceState([$this->device_id]);
-        if(! $bool) {
-            file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'door_not_open'.PHP_EOL,8);
-            return;
-        }
-
-        if($type == 1){
-            //入库
-            $this->productionReceipt($order_number);
-        }else{
-            //出库
-            //获取包装单产品
-            $dispatchList = $this->getDispatchList($order_number);
-            if(empty($dispatchList) || empty($dispatchList['data'])) {
-                file_put_contents('record_door_result.txt',date("Y-m-d H:i:s",time()).'getlist_end'.PHP_EOL,8);
-                return;
-            }
-            $this->completionOrders($dispatchList['data'],$type);
-        }
-    }
-    //正式--------------------------------------
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln($this->data);
-    }
-}

+ 0 - 60
app/Jobs/LabelDealJob.php

@@ -1,60 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Service\DwyService;
-use App\Service\LabelDealService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class LabelDealJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $header;
-    protected $id;
-
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct($data,$header,$id)
-    {
-        $this->data = $data;
-        $this->header = $header;
-        $this->id = $id;
-    }
-
-    public function handle()
-    {
-        try {
-            $data = $this->data;
-            $dv = $data['key'];
-            $return = $box_list = [];
-            //处理数据
-            LabelDealService::getInstance()->clearData($data,$return,$box_list);
-            file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "清洗数据:" . json_encode($return) . PHP_EOL,8);
-
-            //调用外部方法
-            list($lead_bind,$lead_out) = DwyService::getInstance()->setBoxData($this->header,$dv,$return,$box_list,$data);
-
-            //调用保存接口
-            LabelDealService::getInstance()->boxOut($lead_bind,$lead_out,$this->header,$this->id);
-        }catch (\Throwable $exception){
-            file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "队列捕获:" . $exception->getLine() . "|" . $exception->getMessage(). "|"  . $exception->getCode(). PHP_EOL,8);
-            $this->delete();
-        }
-    }
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln($this->data);
-    }
-}

+ 0 - 177
app/Jobs/ManDeviceJob.php

@@ -1,177 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Model\BigKingDevice;
-use App\Model\DeviceData;
-use App\Service\ClearDataService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class ManDeviceJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $url;
-
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct($data)
-    {
-        $this->data = $data;
-        $this->url = config('ip.zs');
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        //                {"data":{"position":{"lngGcj":118.56216535926838,"lngBd":118.56858403462685,"lngWgs":118.557395,"latGcj":28.684134864745076,"locationType":"CELL","time":1695365429,"latWgs":28.687429,"deviceId":"01401422100800000103","cusdeviceNos":["0000130876000007"],"latBd":28.690489277743108},"deviceId":"01401422100800000103","deviceName":"1\u53f7\u70ed\u538b\u673a"},"type":"position"}
-        try{
-            if(empty($this->data['data'])) return;
-
-            $device = BigKingDevice::select('data')->get()->toArray();
-            $device = array_column($device,'data');
-
-            $deviceId = $this->data['data']['deviceId'];
-            $deviceName = $this->data['data']['deviceName'];
-            $ip = self::getIP();
-            $data_type = 3;
-            if($this->data['type'] == "dataPoint"){
-                $insert = [];
-                foreach ($this->data['data']['dataPoints'] as $value){
-                    $dev_eui = $deviceId . $value['dataPointId'];
-
-                    if(! in_array($dev_eui,$device)) continue;
-
-                    //发送给大王椰
-                    $this->sendToDevice(['dev_eui' => $dev_eui, 'value' => $value['value']]);
-
-                    $insert[] = [
-//                        'data' => json_encode($value),
-                        'happening_data' => $value['value'],
-                        'dev_eui' => $dev_eui,
-                        'device_name' => $deviceName,
-                        'source_ip' => $ip,
-                        'data_type' => $data_type,
-                        'crt_time' => time()
-                    ];
-                }
-                DeviceData::insert($insert);
-            }elseif ($this->data['type'] == "position"){
-                $dev_eui = $deviceId;
-                if(in_array($dev_eui,$device)) {
-                    $insert[] = [
-//                        'data' => json_encode($this->data['data']['position']),
-                        'happening_data' => '',
-                        'dev_eui' => $deviceId,
-                        'device_name' => $deviceName,
-                        'source_ip' => $ip,
-                        'data_type' => $data_type,
-                        'crt_time' => time()
-                    ];
-                    DeviceData::insert($insert);
-                }
-            }
-
-//            if(is_array($this->data) || is_object($this->data)){
-//                $data = json_encode($this->data);
-//            }else {
-//                $data = $this->data;
-//            }
-//            file_put_contents('send_man.txt',date('Y-m-d H:i:s').PHP_EOL . $data . PHP_EOL,8);
-        }catch (\Exception $exception){
-            file_put_contents('send_man_error.txt',date("Y-m-d H:i:s").json_encode($this->data).PHP_EOL.$exception->getMessage().$exception->getLine().$exception->getFile().PHP_EOL,8);
-        }
-    }
-
-    public function sendToDevice($data){
-        date_default_timezone_set("PRC");
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        $url = $this->url . "api/module-data/device_machine_record/device_machine_record";
-        $post = [
-            'bizId' => -1,
-            'bizTypeEk' => 'LOWCODE',
-            'data' => [
-                'device_machine_record' => [
-                    'machine_code' => $data['dev_eui'],
-                    'param_value' => $data['value'],
-                    'record_time' => $this->getNowDay()
-                ]
-            ],
-            'dynamicFormId' => '477743923368955904',
-            'showModelId' => '477745421456904192'
-        ];
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json"];
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        $res = json_decode($response,true);
-        if(isset($res['code'])){//报错了
-            file_put_contents('record_man_error.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.json_encode($post),8);
-        }
-    }
-
-    public static function getIP(){
-        if (getenv('HTTP_CLIENT_IP')) {
-            $ip = getenv('HTTP_CLIENT_IP');
-        }
-        elseif (getenv('HTTP_X_REAL_IP')) {
-            $ip = getenv('HTTP_X_REAL_IP');
-        } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
-            $ip = getenv('HTTP_X_FORWARDED_FOR');
-            $ips = explode(',', $ip);
-            $ip = $ips[0];
-        } elseif (getenv('REMOTE_ADDR')) {
-            $ip = getenv('REMOTE_ADDR');
-        } else {
-            $ip = '0.0.0.0';
-        }
-        return $ip;
-    }
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln($this->data);
-    }
-
-    function getNowDay(){
-        // 获取当前时间
-        $currentDateTime = new \DateTime();
-
-// 设置时区为 PRC
-        $currentDateTime->setTimezone(new \DateTimeZone('UTC'));
-
-// 格式化时间为 "2023-09-21T16:00:00.000Z" 的格式
-        $formattedDateTime = $currentDateTime->format('Y-m-d\TH:i:s.000\Z');
-
-        return $formattedDateTime;
-    }
-}

+ 0 - 139
app/Jobs/ProcessDataJob.php

@@ -1,139 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use App\Service\ClearDataService;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class ProcessDataJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $url;
-
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct($data)
-    {
-        $this->data = $data;
-        $this->url = config('ip.zs');
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        //标记
-        file_put_contents('record.txt',json_encode($this->data) . PHP_EOL,8);
-
-        //保存数据到自己服务器
-        ClearDataService::saveData($this->data);
-
-        //处理数据
-        $return = ClearDataService::clearData($this->data);
-
-        $this->sendToDevice($return);
-
-        //传递数据给下一个队列
-        file_put_contents('record2.txt',json_encode($return) . PHP_EOL,8);
-
-        //输出信息
-        $this->echoMessage(new ConsoleOutput());
-    }
-
-    public function sendToDevice($data){
-        date_default_timezone_set("PRC");
-        list($status,$token) = ClearDataService::getToken();
-        if(! $status) return;
-
-        $url = $this->url . "api/module-data/device_machine_record/device_machine_record";
-        $header = ["Authorization: Bearer {$token}","Content-Type:application/json"];
-        if(! empty($data['multiple'])){
-            foreach ($data['multiple'] as $key => $value){
-                $post = [
-                    'bizId' => -1,
-                    'bizTypeEk' => 'LOWCODE',
-                    'data' => [
-                        'device_machine_record' => [
-                            'machine_code' => $key,
-                            'param_value' => $value,
-                            'record_time' => $this->getNowDay()
-                        ]
-                    ],
-                    'dynamicFormId' => '477743923368955904',
-                    'showModelId' => '477745421456904192'
-                ];
-                $this->sendData($url,$post,$header);
-            }
-        } else{
-            $post = [
-                'bizId' => -1,
-                'bizTypeEk' => 'LOWCODE',
-                'data' => [
-                    'device_machine_record' => [
-                        'machine_code' => $data['dev_eui'],
-                        'param_value' => $data['value'],
-                        'record_time' => $this->getNowDay()
-                    ]
-                ],
-                'dynamicFormId' => '477743923368955904',
-                'showModelId' => '477745421456904192'
-            ];
-            $this->sendData($url,$post,$header);
-        }
-    }
-
-    public function sendData($url, $post, $header){
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        $res = json_decode($response,true);
-        if(isset($res['code'])){//报错了
-            file_put_contents('record_chuangan_error.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL.json_encode($post),8);
-        }
-    }
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln(json_encode($this->data));
-    }
-
-    function getNowDay(){
-        // 获取当前时间
-        $currentDateTime = new \DateTime();
-
-// 设置时区为 PRC
-        $currentDateTime->setTimezone(new \DateTimeZone('UTC'));
-
-// 格式化时间为 "2023-09-21T16:00:00.000Z" 的格式
-        $formattedDateTime = $currentDateTime->format('Y-m-d\TH:i:s.000\Z');
-
-        return $formattedDateTime;
-    }
-}

+ 0 - 106
app/Jobs/SendDataJob.php

@@ -1,106 +0,0 @@
-<?php
-
-namespace App\Jobs;
-
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-class SendDataJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    protected $data;
-    protected $url;
-
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct($data)
-    {
-        $this->data = $data;
-        $this->url = config('ip.zs');
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        //暂时不用
-        file_put_contents('record2.txt',json_encode($this->data) . PHP_EOL,8);
-        if(isset($data['is_clear_data'])){
-            $this->sendToDevice($this->data);
-        }
-
-        //输出信息 测试
-        $this->echoMessage(new ConsoleOutput());
-    }
-
-    private function sendRequest($url,$data){
-        $data = json_encode($data);
-        $header[] = "Content-Type:application/json";
-        $ch=curl_init($url);
-        curl_setopt($ch,CURLOPT_POST,1);
-        curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
-        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
-        curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
-        $response=curl_exec($ch);
-        $response=json_decode($response,true);
-
-        if(curl_errno($ch) ){
-            sc(curl_error($ch));
-        }
-        return $response;
-    }
-
-    public function sendToDevice($data){
-        $url = $this->url . "api/module-data/device_machine_record/device_machine_record";
-        $post = [
-            'bizId' => -1,
-            'bizTypeEk' => 'LOWCODE',
-            'data' => [
-                'device_machine_record' => [
-                    'machine_code' => $data['dev_eui'],
-                    'param_value' => $data['value']
-                ]
-            ],
-            'dynamicFormId' => '477743923368955904',
-            'showModelId' => '477745421456904192'
-        ];
-        $header = ['Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOLFJPTEVfSU5URVJGQUNFIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0Njc0MTE0fQ.L3Di3K_cpF0rWSgvzbcLufLm8bkCxd3Y-xudfKzSm4F-qdpDr0hYWWQP5K5BYTNuZnu4tWpGmSW2KRHU0pjt-A','Content-Type:application/json'];
-
-        $curl = curl_init();
-        curl_setopt_array($curl, array(
-            CURLOPT_URL => $url,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_ENCODING => '',
-            CURLOPT_MAXREDIRS => 10,
-            CURLOPT_TIMEOUT => 0,
-            CURLOPT_FOLLOWLOCATION => true,
-            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-            CURLOPT_CUSTOMREQUEST => 'POST',
-            CURLOPT_POSTFIELDS => json_encode($post),
-            CURLOPT_HTTPHEADER => $header,
-        ));
-        $response = curl_exec($curl);
-        curl_close($curl);
-
-        file_put_contents('record2.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL,8);
-    }
-
-    protected function echoMessage(OutputInterface $output)
-    {
-        $output->writeln($this->data);
-    }
-}

+ 0 - 14
app/Model/BigKingDevice.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class BigKingDevice extends Model
-{
-    protected $table = "big_king_device"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/BigKingTbj.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class BigKingTbj extends Model
-{
-    protected $table = "big_king_tbj"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-    protected $guarded = [];
-}

+ 0 - 19
app/Model/Depart.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 部门管理
- * Class Unit
- * @package App\Models
- */
-class Depart extends Model
-{
-    protected $table = "depart"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const RULE_DEPART = "ALL";
-}

+ 0 - 14
app/Model/DeviceData.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class DeviceData extends Model
-{
-    protected $table = "device_data"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/DeviceSite.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class DeviceSite extends Model
-{
-    protected $table = "device_site"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 36
app/Model/Employee.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class Employee extends Model
-{
-    protected $table = "employee"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-    const USE = 1;
-    const NOT_USE = 2;
-    const IS_ADMIN = 1;
-    const IS_NOT_ADMIN = 0;
-    const SPECIAL_ADMIN = 1;
-    const IS_TECHNICAL = [
-        0 => '否',
-        1 => '是'
-    ];
-
-    //人员状态
-    const STATUS_ONE = 1;
-    const STATUS_TWO = 2;
-
-    const STATUS = [
-        1 => '正常',
-        2 => '停用'
-    ];
-}

+ 0 - 19
app/Model/EmployeeDepartPermission.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class EmployeeDepartPermission extends Model
-{
-    protected $table = "employee_depart_permission"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/EmployeeManagerDepart.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class EmployeeManagerDepart extends Model
-{
-    protected $table = "employee_manager_depart"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/EmployeeMenuPermission.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class EmployeeMenuPermission extends Model
-{
-    protected $table = "employee_menu_permission"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 14
app/Model/EmployeeRole.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-class EmployeeRole extends Model
-{
-    protected $table = "employee_role"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/EmployeeTeamPermission.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class EmployeeTeamPermission extends Model
-{
-    protected $table = "employee_team_permission"; //指定表
-    const CREATED_AT = null;
-    const UPDATED_AT = null;
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/Role.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 角色管理
- * Class Unit
- * @package App\Models
- */
-class Role extends Model
-{
-    protected $table = "role"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 19
app/Model/SysMenu.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Model;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 菜单管理
- * Class Unit
- * @package App\Models
- */
-class SysMenu extends Model
-{
-    protected $table = "sys_menu"; //指定表
-    const CREATED_AT = 'crt_time';
-    const UPDATED_AT = 'upd_time';
-    protected $dateFormat = 'U';
-
-}

+ 0 - 260
app/Service/ClearDataService.php

@@ -1,260 +0,0 @@
-<?php
-
-namespace App\Service;
-
-
-use App\Model\DeviceData;
-use Illuminate\Support\Facades\Redis;
-
-class ClearDataService extends Service
-{
-    /*
-     * 压力传感器数据
-     * [    "obj" => array:10 [
-            "applicationID" => "2"  // 应用ID
-            "applicationName" => "cloud2"  // 应用名称
-            "data" => "A3sAAA=="
-            "devEUI" => "24e124126c481114" // 设备EUI
-            "deviceName" => "设备二" // 设备名称
-            "fCnt" => 6  // 帧计数
-            "fPort" => 85 // 应用端口
-            "rxInfo" => array:1 [
-              0 => array:8 [
-                "altitude" => 0 // 网关海拔
-                "latitude" => 0 // 网关经度
-                "longitude" => 0 // 网关纬度
-                "loRaSNR" => 13.2 // 信噪比
-                "mac" => "24e124fffef7887c" // 网关ID
-                "name" => "Local Gateway" // 网关名称
-                "rssi" => -24    // 信号强度 (dBm)
-                "time" => "2023-08-03T05:47:47.337673Z"
-              ]
-            ]
-            "time" => "2023-08-03T05:47:47.337673Z"
-            "txInfo" => array:4 [ // 节点信息
-              "adr" => true  // 设备ADR状态
-              "codeRate" => "4/5" // 编码率
-              "dataRate" => array:3 [
-                "bandwidth" => 125  // 带宽
-                "modulation" => "LORA" // LORA调制
-                "spreadFactor" => 7  // 扩频因子
-              ]
-              "frequency" => 473300000 // 使用频率
-            ]
-          ]
-       "pressure" => 0
-     ]
-     *
-     *温度传感器数据
-     *
-     *  ["obj" => array:10 [
-        "applicationID" => "1"
-        "applicationName" => "cloud"
-        "data" => "A2cAAQ=="
-        "devEUI" => "24e124126d054217"
-        "deviceName" => "设备一"
-        "fCnt" => 983
-        "fPort" => 85
-        "rxInfo" => array:1 [
-          0 => array:8 [
-            "altitude" => 0
-            "latitude" => 0
-            "loRaSNR" => 13.5
-            "longitude" => 0
-            "mac" => "24e124fffef7887c"
-            "name" => "Local Gateway"
-            "rssi" => -31
-            "time" => "2023-08-02T09:50:44.880803Z"
-          ]
-        ]
-        "time" => "2023-08-02T09:50:44.880803Z"
-        "txInfo" => array:4 [
-          "adr" => true
-          "codeRate" => "4/5"
-          "dataRate" => array:3 [
-            "bandwidth" => 125
-            "modulation" => "LORA"
-            "spreadFactor" => 7
-          ]
-          "frequency" => 471900000
-        ]
-      ]
-    "temperature" => 25.6
-    ]
-     *
-     * */
-
-    public static function saveData($data){
-        try{
-            $time = time();
-            $dev_eui = $data['obj']['devEUI'];
-            $device_name = $data['obj']['deviceName'];
-            $source_ip = self::getIP();
-            //保存数据
-            if(isset($data['temperature']) && isset($data['humidity'])){
-                $insert[] = [
-                    'dev_eui' => $dev_eui . '1',
-                    'device_name' => $device_name,
-                    'source_ip' => $source_ip,
-                    'data_type' => 4,
-                    'happening_data' => $data['temperature'],
-                    'crt_time' => $time,
-                ];
-                $insert[] = [
-                    'dev_eui' => $dev_eui . '2',
-                    'device_name' => $device_name,
-                    'source_ip' => $source_ip,
-                    'data_type' => 4,
-                    'happening_data' => $data['humidity'],
-                    'crt_time' => $time,
-                ];
-                DeviceData::insert($insert);
-            }else{
-                $model = new DeviceData();
-//            $model->data = json_encode($data);//源数据
-                $model->dev_eui = $dev_eui;
-                $model->device_name = $device_name;
-                $model->source_ip = $source_ip;
-                if(isset($data['temperature'])){
-                    $model->data_type = 1;
-                    $model->happening_data = $data['temperature'];
-                }elseif (isset($data['pressure'])){
-                    $model->data_type = 2;
-                    $model->happening_data = $data['pressure'];
-                }
-                $model->save();
-            }
-        }catch (\Exception $exception){
-            file_put_contents('record_errors.txt',json_encode($data) . PHP_EOL . $exception->getFile().$exception->getLine().$exception->getCode(),8);
-        }
-    }
-
-    public static function clearData($data){
-        $return['is_clear_data'] = 1;
-        $return['dev_eui'] = $data['obj']['devEUI'] ?? '';
-        if(isset($data['temperature']) && isset($data['humidity'])){
-            $return['multiple'] = [
-                $return['dev_eui'] . '1' => $data['temperature'],
-                $return['dev_eui'] . '2' => $data['humidity'],
-            ];
-        }elseif(isset($data['temperature'])){
-            $return['value'] = $data['temperature'];
-        }elseif (isset($data['pressure'])){
-            $return['value'] = round($data['pressure'] / 1000,2);
-        }else{
-            $return['value'] = 0;
-        }
-
-        return $return;
-    }
-
-    public static function getUrl($data){
-        //根据业务将数据发送到对应的地址
-        // 温度传感器数据包含temperature 字段  压力传感器包含pressure 字段
-
-        $url = 'http://fyy_api.qingyaokeji.com/api/testData';
-        $url = '';
-        return $url;
-    }
-
-    public static function getIP(){
-        if (getenv('HTTP_CLIENT_IP')) {
-            $ip = getenv('HTTP_CLIENT_IP');
-        }
-        elseif (getenv('HTTP_X_REAL_IP')) {
-            $ip = getenv('HTTP_X_REAL_IP');
-        } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
-            $ip = getenv('HTTP_X_FORWARDED_FOR');
-            $ips = explode(',', $ip);
-            $ip = $ips[0];
-        } elseif (getenv('REMOTE_ADDR')) {
-            $ip = getenv('REMOTE_ADDR');
-        } else {
-            $ip = '0.0.0.0';
-        }
-        return $ip;
-    }
-
-    //"status": "error",
-    //        "userType": null,
-    //        "userDto": null,
-    //        "token": null,
-    //        "errorMessage": "用户名或密码不正确",
-    //        "brushFaceFlag": false,
-    //        "brushFaceValidationResult": null
-    public static function getToken(){
-        $token_key = 'big_king_login_token';
-        $token = Redis::get($token_key);
-        if(! $token){
-            $url = config('ip.zs');
-            $post = array("name" => "admin","password"=>"admin","rememberMe"=>true);
-            $header = ['Content-Type:application/json'];
-            $curl = curl_init();
-            curl_setopt_array($curl, array(
-                CURLOPT_URL => $url . 'jbl/api/mes/login',
-                CURLOPT_RETURNTRANSFER => true,
-                CURLOPT_ENCODING => '',
-                CURLOPT_MAXREDIRS => 10,
-                CURLOPT_TIMEOUT => 0,
-                CURLOPT_FOLLOWLOCATION => true,
-                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-                CURLOPT_CUSTOMREQUEST => 'POST',
-                CURLOPT_POSTFIELDS => json_encode($post),
-                CURLOPT_HTTPHEADER =>  $header,
-            ));
-            $response = curl_exec($curl);
-            curl_close($curl);
-            $result = json_decode($response,true);
-            if(empty($result['token'])) {
-                file_put_contents('big_king_token_error.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL,8);
-                return [false,''];
-            }else{
-                $token = $result['token'];
-                $expire_time = 1728000; //20天
-                Redis::set($token_key,$token);
-                Redis::expire($token_key, $expire_time);
-                return [true,$token];
-            }
-        }
-
-        return [true,$token];
-    }
-
-    public static function getTokenCs(){
-        $token_key = 'big_king_login_token_cs';
-        $token = Redis::get($token_key);
-        if(! $token){
-            $url = config('ip.cs');
-            $post = array("name" => "admin","password"=>"admin","rememberMe"=>true);
-            $header = ['Content-Type:application/json'];
-            $curl = curl_init();
-            curl_setopt_array($curl, array(
-                CURLOPT_URL => $url . 'jbl/api/mes/login',
-                CURLOPT_RETURNTRANSFER => true,
-                CURLOPT_ENCODING => '',
-                CURLOPT_MAXREDIRS => 10,
-                CURLOPT_TIMEOUT => 0,
-                CURLOPT_FOLLOWLOCATION => true,
-                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
-                CURLOPT_CUSTOMREQUEST => 'POST',
-                CURLOPT_POSTFIELDS => json_encode($post),
-                CURLOPT_HTTPHEADER =>  $header,
-            ));
-            $response = curl_exec($curl);
-            curl_close($curl);
-            $result = json_decode($response,true);
-            if(empty($result['token'])) {
-                file_put_contents('big_king_token_error_cs.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL,8);
-                return [false,''];
-            }else{
-                $token = $result['token'];
-                $expire_time = 1728000; //20天
-                Redis::set($token_key,$token);
-                Redis::expire($token_key, $expire_time);
-                return [true,$token];
-            }
-        }
-
-        return [true,$token];
-    }
-}

文件差异内容过多而无法显示
+ 0 - 39
app/Service/DwyService.php


+ 0 - 469
app/Service/EmployeeService.php

@@ -1,469 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Model\Depart;
-use App\Model\Employee;
-use App\Model\EmployeeDepartPermission;
-use App\Model\EmployeeManagerDepart;
-use App\Model\EmployeeMenuPermission;
-use App\Model\EmployeeRole;
-use App\Model\EmployeeTeamPermission;
-use App\Model\Role;
-use App\Model\SysMenu;
-use App\Model\Team;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Hash;
-
-/**
- * 人员相关
- * @package App\Models
- */
-class EmployeeService extends Service
-{
-    public function employeeEdit($data,$user){
-        list($status,$msg) = $this->employeeRule($data,false);
-        if(!$status) return [$status,$msg];
-
-        $model = new Employee();
-        $model = $model->where('id',$data['id'])->first();
-        $model->id_card = $data['id_card']??'';
-        $model->number = $data['number'] ;
-        $model->mobile = $data['mobile'];
-        $model->emp_name = $data['emp_name'];
-        $model->is_admin = $data['is_admin'];
-        if($model->is_admin == 1){
-            $model->account = $data['account'];
-            if($data['password'] !== '********'){
-                $model->password   = Hash::make($data['password']);
-            }
-        }
-        $model->save();
-        return [true,'保存成功!'];
-    }
-
-    public function employeeAdd($data,$user){
-        list($status,$msg) = $this->employeeRule($data);
-        if(!$status) return [$status,$msg];
-
-        $model = new Employee();
-        $model->id_card = $data['id_card']??'';
-        $model->number = $data['number'] ;
-        $model->mobile = $data['mobile'];
-        $model->emp_name = $data['emp_name'];
-        $model->state = 1;
-        $model->crt_id = $user['id'];
-        $model->is_admin = $data['is_admin'];
-        if($model->is_admin == 1){
-            $model->account = $data['account'];
-            $model->password   = Hash::make($data['password']);
-        }
-        $model->save();
-
-        return [true,'保存成功!'];
-    }
-
-    public function employeeDel($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-
-        Employee::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,'删除成功'];
-    }
-
-    public function employeeList($data){
-        $list = Employee::where('del_time',0)->select('id_card','emp_name','mobile','crt_time','account','is_admin','upd_time','id')->orderBy('id','desc');
-
-        $list = $this->limit($list,'',$data);
-
-        return [200,$list];
-    }
-
-    public function employeeRule($data,$is_add = true){
-        if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
-        if($this->isEmpty($data,'mobile')) return [false,'手机号不存在!'];
-        if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
-        if(! $is_add){
-            if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
-            $bool = Employee::where('number',$data['number'])
-                ->where('id','<>',$data['id'])
-                ->where('del_time',0)->exists();
-            $bool_account = Employee::where('account',$data['account'])
-                ->where('id','<>',$data['id'])
-                ->where('del_time',0)->exists();
-        }else{
-            $bool = Employee::where('number',$data['number'])
-                ->where('del_time',0)->exists();
-            $bool_account = Employee::where('account',$data['account'])
-                ->where('del_time',0)->exists();
-        }
-        if($bool) return [false,'工号已存在!'];
-        if($bool_account) return [false,'账号已存在!'];
-
-        return [true,''];
-    }
-
-    public function roleEdit($data){
-        list($status,$msg) = $this->roleRule($data);
-        if(!$status) return [$status,$msg];
-        $first = Role::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new Role();
-        $model = $model->where('id',$data['id'])->first();
-
-        $model->title = $data['title'];
-        $model->save();
-        return [true,'保存成功!'];
-
-    }
-
-    public function roleAdd($data,$user){
-
-
-//        if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
-        list($status,$msg) = $this->roleRule($data);
-        if(!$status) return [$status,$msg];
-        $first = SysMenu::where('title',$data['title'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new Role();
-
-        $model->title = $data['title'] ;
-
-        $model->save();
-
-        return [true,'保存成功!'];
-
-    }
-
-    public function roleDel($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-
-        Role::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,'删除成功'];
-    }
-
-    public function roleList($data){
-        $list = Role::where('del_time',0)->select('title','title','crt_time','id','upd_time')->orderBy('id','desc');
-
-        $list = $this->limit($list,'',$data);
-
-        return [200,$list];
-    }
-
-    public function roleRule($data){
-        if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
-
-        return [true,''];
-    }
-
-    public function departEdit($data){
-        list($status,$msg) = $this->departRule($data);
-        if(!$status) return [$status,$msg];
-        $first = Depart::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new Depart();
-        $model = $model->where('id',$data['id'])->first();
-
-        $model->title = $data['title'];
-        $model->code = $data['code']??'';
-        $model->save();
-        return [true,'保存成功!'];
-
-    }
-
-    public function departAdd($data,$user){
-
-
-//        if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
-        list($status,$msg) = $this->departRule($data);
-        if(!$status) return [$status,$msg];
-        $first = Depart::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new Depart();
-
-        $model->title = $data['title'] ;
-        $model->code = $data['code'] ?? '' ;
-
-        $model->save();
-
-        return [true,'保存成功!'];
-
-    }
-
-    public function departDel($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-
-        Depart::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,'删除成功'];
-    }
-
-    public function departList($data){
-        $list = Depart::where('del_time',0)->select('title','crt_time','id','upd_time','code')->orderBy('id','desc');
-
-        $list = $this->limit($list,'',$data);
-
-        return [200,$list];
-    }
-
-    public function departRule($data){
-        if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
-
-        return [true,''];
-    }
-
-
-    public function teamEdit($data){
-        list($status,$msg) = $this->teamRule($data,false);
-        if(!$status) return [$status,$msg];
-
-        $model = new Team();
-        $model = $model->where('id',$data['id'])->first();
-        $model->title = $data['title'];
-        $model->code = $data['code'];
-        $model->save();
-
-        return [true,'保存成功!'];
-    }
-
-    public function teamAdd($data,$user){
-        list($status,$msg) = $this->teamRule($data);
-        if(!$status) return [$status,$msg];
-
-        $model = new Team();
-        $model->title = $data['title'] ;
-        $model->code = $data['code'];
-        $model->save();
-
-        return [true,'保存成功!'];
-    }
-
-    public function teamDel($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-
-        Team::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,'删除成功'];
-    }
-
-    public function teamList($data){
-        $list = Team::where('del_time',0)->select('title','id','crt_time','upd_time','code')->orderBy('id','desc');
-
-        $list = $this->limit($list,'',$data);
-
-        return [200,$list];
-    }
-
-    public function teamRule($data,$is_add = true){
-        if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
-        if($this->isEmpty($data,'code')) return [false,'编码不存在'];
-
-        $model = Team::where('title',$data['title'])
-            ->where('code',$data['code'])
-            ->where('del_time',0);
-        if(! $is_add){
-            if($this->isEmpty($data,'id')) return [false,'ID不能为空'];
-            $model->where('id','<>',$data['id']);
-        }
-        $bool = $model->exists();
-        if($bool) return [false,'名称和编码已存在!'];
-
-        return [true,''];
-    }
-
-    public function employeeRole($data){
-        $role_ids = [];
-        $employee_ids = [];
-        foreach ($data as $v){
-            if(isset($v['role_id'])){
-                if(!in_array($v['role_id'],$role_ids)){
-                    $role_ids[] = $v['role_id'];
-                }
-            }
-
-            if(isset($v['employee_id'])){
-                if(!in_array($v['employee_id'],$employee_ids)){
-                    $employee_ids[] = $v['employee_id'];
-                }
-            }
-        }
-
-        EmployeeMenuPermission::wherein('role_id',$role_ids)->delete();
-        EmployeeMenuPermission::wherein('employee_id',$employee_ids)->delete();
-
-
-        EmployeeMenuPermission::insert($data);
-
-        return [200,'保存成功!'];
-
-    }
-
-    public function employeeDepart($data){
-        if($this->isEmpty($data,'insert')) return [false,'数据不能为空!'];
-
-        DB::beginTransaction();
-        try {
-            if($data['type'] == 1){
-                EmployeeDepartPermission::whereIn('depart_id',$data['insert']['depart_id'])->delete();
-            }else{
-                EmployeeDepartPermission::whereIn('employee_id',$data['insert']['employee_id'])->delete();
-            }
-
-            $insert = [];
-            foreach ($data['insert']['depart_id'] as $t){
-                foreach ($data['insert']['employee_id'] as $e){
-                    $insert[] = [
-                        'depart_id' => $t,
-                        'employee_id' => $e
-                    ];
-                }
-            }
-            EmployeeDepartPermission::insert($insert);
-
-            DB::commit();
-        }catch (\Throwable $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,'保存成功!'];
-    }
-
-    public function employeeTeam($data){
-        if($this->isEmpty($data,'insert')) return [false,'数据不能为空!'];
-
-        DB::beginTransaction();
-        try {
-            if($data['type'] == 1){
-                EmployeeTeamPermission::whereIn('team_id',$data['insert']['team_id'])->delete();
-            }else{
-                EmployeeTeamPermission::whereIn('employee_id',$data['insert']['employee_id'])->delete();
-            }
-
-            $insert = [];
-            foreach ($data['insert']['team_id'] as $t){
-                foreach ($data['insert']['employee_id'] as $e){
-                    $insert[] = [
-                        'team_id' => $t,
-                        'employee_id' => $e
-                    ];
-                }
-            }
-            EmployeeTeamPermission::insert($insert);
-
-            DB::commit();
-        }catch (\Throwable $exception){
-            DB::rollBack();
-            return [false,$exception->getMessage()];
-        }
-
-        return [true,'保存成功!'];
-    }
-
-    public function loginRule($data){
-        if($this->isEmpty($data,'account')) return [false,'账号不能为空!'];
-        if($this->isEmpty($data,'password')) return [false,'密码不存在!'];
-
-        $res = Employee::where('del_time',0)
-            ->where('account', $data['account'])
-            ->get()->toArray();
-
-        if(empty($res)) return [false,'账号不存在或已被删除!'];
-
-        $res = reset($res);
-        if(! Hash::check($data['password'], $res['password'])) return [false,'密码错误!'];
-        if($res['is_admin'] != Employee::IS_ADMIN) return [false,'该账号不能登录!'];
-        if($res['state'] == Employee::NOT_USE) return [false,'账号停用!'];
-
-        return [true, ['id'=>$res['id'], 'name'=>$res['emp_name'], 'account' => $res['account']]];
-    }
-
-    public static function checkUser($userId){
-        $res = Employee::where('id', $userId)
-            ->where('del_time',0)
-            ->where('is_admin',Employee::IS_ADMIN)
-            ->where('state',Employee::USE)->get()->first();
-        if(empty($res)) return [false, '该账号无法登录,请联系管理员!'];
-
-        return [true, $res];
-    }
-
-    //获取登录账号的角色
-    public static function getPersonRole($employee_id){
-        if(empty($employee_id)) return [];
-        $role = EmployeeRole::where('del_time',0)
-            ->where('employee_id',$employee_id)
-            ->select('role_id')
-            ->get()->toArray();
-
-        //组织
-        $role_id = array_column($role,'role_id');
-        asort($role_id);
-        $role_id = array_values($role_id);
-
-        return $role_id;
-    }
-
-    //获取登录账号的权限部门
-    public static function getPersonDepart($employee_id){
-        if(empty($employee_id)) return [];
-
-        //admin账号
-        if($employee_id == Employee::SPECIAL_ADMIN) return [Depart::RULE_DEPART];
-
-        //操作人员直接绑定部门
-        $employee_manager_depart = EmployeeManagerDepart::where('del_time',0)
-            ->where('employee_id',$employee_id)
-            ->select('depart_id')
-            ->get()->toArray();
-
-        //操作人员绑定角色
-        $employee_role = EmployeeRole::from('employee_role as a')
-            ->leftJoin('role_depart as b','b.role_id','a.role_id')
-            ->select('b.depart_id','b.role_id')
-            ->where('a.del_time',0)
-            ->where('b.del_time',0)
-            ->where('a.employee_id',$employee_id)
-            ->get()->toArray();
-
-        return array_filter(array_merge_recursive(array_column($employee_manager_depart,'depart_id'),array_column($employee_role,'depart_id')));
-    }
-
-    //人员直接绑定部门
-    public function employeeManagerDepart($data,$user){
-        if($user['id'] != Employee::SPECIAL_ADMIN) return [false,'非ADMIN账号不能操作'];
-
-        if($this->isEmpty($data,'employee_id')) return [false,'请选择操作人员'];
-        if($this->isEmpty($data,'depart_id')) return [false,'请选择部门'];
-
-        EmployeeManagerDepart::where('employee_id',$data['employee_id'])->update([
-            'del_time' => time()
-        ]);
-
-        $insert = [];
-        foreach ($data['depart_id'] as $value){
-            $insert[] = [
-                'employee_id' => $data['employee_id'],
-                'depart_id' => $value,
-                'crt_time' => time(),
-                'upd_time' => time(),
-            ];
-        }
-        EmployeeManagerDepart::insert($insert);
-
-        return [true,''];
-    }
-}

+ 0 - 123
app/Service/InOutOptionService.php

@@ -1,123 +0,0 @@
-<?php
-
-namespace App\Service;
-
-use App\Jobs\DoorDeviceJob;
-use Illuminate\Support\Facades\Redis;
-
-class InOutOptionService extends Service
-{
-    const OrderKeyQueueIn = 'InOrderNumber';
-    const OrderKeyQueueOut = 'OutOrderNumber';
-    const OrderKeyQueueInOut = 'InOutOrderNumber';
-    const Key = 'FHCK';
-
-    //通道门传来的数据  正常出入库 直接生成单据 (放入队列生成)
-    //发货出库数据 出库以后存到缓存 前端自取  发货出库会有可能这次不发了 所以也有入回来
-    public function setOrderNumber($data){
-        if(! empty($data['data']['tagList'])){
-            $in = $out = [];
-            $device_id = $data['data']['id'] ?? 0; //设备id
-            $site = $data['data']['devMark'] ?? ""; //站点
-            foreach ($data['data']['tagList'] as $value){
-                if($value['direction'] == '1'){
-                    //(判断到有发货出库的入库标识 存入缓存)
-                    if(Redis::exists($device_id . self::Key)){
-                        Redis::lpush($device_id . self::Key . self::OrderKeyQueueInOut, json_encode($value));
-                    }else{
-                        //入库 直接生成入库单
-                        if(! in_array($value['epc'],$in)) $in[] = $value['epc'];
-                    }
-                }elseif ($value['direction'] == '2'){
-                    //(判断到有发货出库的出库标识 存入缓存)
-                    if(Redis::exists($device_id . self::Key)){
-                        Redis::lpush($device_id . self::Key . self::OrderKeyQueueInOut, json_encode($value));
-                    }else{
-                        //出库 直接生成出库单
-                        if(! in_array($value['epc'],$out)) $out[] = $value['epc'];
-                    }
-                }
-            }
-            if(! empty($in)) dispatch(new DoorDeviceJob($in,1,$site,$device_id))->onQueue('door_device');
-            if(! empty($out)) dispatch(new DoorDeviceJob($out,2,$site,$device_id))->onQueue('door_device');
-        }
-    }
-
-    //获取单号 包括成功的出入库数据(生成单据成功 返回成功的包装单号)  和   发货出库(包装单号)
-    public function getOrderNumber($data,$site){
-        //获取某个站点的数据
-        $tmp = [];
-        $result = [];
-
-        //发货出库
-        $key = $data['device_id'] . self::Key . self::OrderKeyQueueInOut;
-        if(Redis::exists($key)) {
-            //发货
-            while ($item = Redis::lpop($key)) {
-                $order = json_decode($item, true);
-                $order_it = $order['epc'] . $order['direction'];
-                if(! in_array($order_it, $tmp)){
-                    $str = @hex2bin($order['epc']);
-                    $str = ltrim($str, "\x00");
-                    $str = str_replace(chr(26), '', $str); //过滤CRTL-Z字符
-                    if(! empty($str) && substr($str, 0, 2) === "BZ"){
-                        $order['epc'] = $str;
-                        $order['site'] = $site;
-                        $result[] = $order;
-                    }
-                }
-            }
-
-            return [true, $result];
-        }
-
-        //入库
-        $key = $data['device_id'] . self::OrderKeyQueueIn;
-        $res = Redis::get($key);
-        if(! empty($res)){
-            $return  = json_decode($res,true);
-            foreach ($return as $value){
-                $str = str_replace(chr(26), '', $value); //过滤CRTL-Z字符
-                $result[] = [
-                    'epc' => $str,
-                    'direction' => '1',
-                ];
-            }
-            Redis::del($key);
-            return [true, $result];
-        }
-
-        //发货
-        $key = $data['device_id'] . self::OrderKeyQueueOut;
-        $res = Redis::get($key);
-        if(! empty($res)){
-            $return  = json_decode($res,true);
-            foreach ($return as $value){
-                $result[] = [
-                    'epc' => $value,
-                    'direction' => '2',
-                ];
-            }
-            Redis::del($key);
-            return [true, $result];
-        }
-
-        return [true, $result];
-    }
-
-    //设置通道门是 正常出入库 还是  发货出库
-    public function setFhMessage($data,$site){
-        $key = $data['device_id'] . self::Key;
-        if(empty($data['fh'])){
-            //通道门处在出入库屏 删除通道门在发货出库屏下的标识(如果存在)
-            if(Redis::exists($key)) Redis::del($key);
-        }else{
-            //通道门处在发货出库屏 设置55秒过期  前端50秒请求一次 更新标识时间
-            if (Redis::setnx($key, 1)) {
-                Redis::expire($key, 55); //多少秒后过期
-            }else{
-                Redis::expire($key, 55); //多少秒后过期
-            }
-        }
-    }
-}

+ 423 - 0
app/Service/JRFIDServerService.php

@@ -0,0 +1,423 @@
+<?php
+
+namespace App\Service;
+
+use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Redis;
+
+class JRFIDServerService extends Service
+{
+    public static function getToken(){
+        $token_key = config("j_rfid.LoginRedisTopic");
+        $token = Redis::get($token_key);
+        if(! $token){
+            $url = config('ip.zs');
+            $post = array("name" => "admin","password"=>"admin","rememberMe"=>true);
+            $header = ['Content-Type:application/json'];
+            $curl = curl_init();
+            curl_setopt_array($curl, array(
+                CURLOPT_URL => $url . 'jbl/api/mes/login',
+                CURLOPT_RETURNTRANSFER => true,
+                CURLOPT_ENCODING => '',
+                CURLOPT_MAXREDIRS => 10,
+                CURLOPT_TIMEOUT => 0,
+                CURLOPT_FOLLOWLOCATION => true,
+                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+                CURLOPT_CUSTOMREQUEST => 'POST',
+                CURLOPT_POSTFIELDS => json_encode($post),
+                CURLOPT_HTTPHEADER =>  $header,
+            ));
+            $response = curl_exec($curl);
+            curl_close($curl);
+            $result = json_decode($response,true);
+            if(empty($result['token'])) {
+                file_put_contents('big_king_token_error.txt',date('Y-m-d H:i:s'). PHP_EOL . $response .PHP_EOL,8);
+                return [false,''];
+            }else{
+                $token = $result['token'];
+                $expire_time = 1728000; //20天
+                Redis::set($token_key,$token);
+                Redis::expire($token_key, $expire_time);
+                return [true,$token];
+            }
+        }
+
+        return [true,$token];
+    }
+
+    //销售订单(合同)保存
+    public function U8SaleOrderSave($data,$cmaker = ""){
+        if(! is_array($data)) $data = [$data];
+        $id = $data;
+
+        //映射ip是否通畅
+        $bool = $this->isDomainAvailable($this->u8['domain']);
+        if(! $bool) {
+            $msg = 'U8程序外部域名不可达';
+            $this->finalSettle($id, U8Job::two, $msg);
+            return;
+        }
+
+        //获取数据
+        $result = $this->getSaleOrderData($id);
+        if(empty($result)) {
+            $msg = "同步数据获取失败";
+            $this->finalSettle($id, U8Job::two, $msg);
+            return;
+        }
+
+        //u8接口参数组织
+        $post = $this->post_common;
+        $post['entity'] = "U8SaleOrderSave";
+
+        $time = date("Y-m-d");
+        $time1 = date("Y-m-d H:i:s");
+        foreach ($result as $value){
+            $bodys = [];
+
+//            $cdefine31 = "";
+//            if(! empty($value['cstname']) && $value['cstname'] == "线下销售") $cdefine31 = $value['cstname'];
+            foreach ($value['product'] as $son){
+                //子表数据
+                $bodys[] = [
+                    "cinvcode"=>$son['code'], //存货编码
+                    "iquantity"=>$son['number'], //数量
+                    "inum"=>$son['number'], //件数
+                    "itaxrate"=>$son['itaxrate'], //税率
+                    "iunitprice"=>$son['iunitprice'],//原币单价
+                    "itaxunitprice"=>$son['itaxunitprice'], // 原币含税单价
+                    "isum"=>$son['isum'], //原币价税合计
+                    "imoney"=>$son['imoney'], //原币无税金额
+                    "itax"=>$son['itax'],//原币税额
+                    "cbmemo"=>$son['mark'], //表体备注
+//                    "iappids"=>"", //子表id
+//                    "cinvcode"=>$son['code'], //存货编码
+//                    "iquantity"=>$son['number'], //数量
+//                    "inum"=>$son['number'], //件数
+//                    "ipertaxrate"=>$son['ipertaxrate'], //税率
+//                    "iunitprice"=>$son['iunitprice'], //原币单价
+//                    "itaxprice"=>$son['itaxprice'], //原币含税单价
+//                    "isum"=>$son['isum'], //原币价税合计
+//                    "imoney"=>$son['imoney'], //原币无税金额
+//                    "itax"=>$son['itax'],//原币税额
+//                    "cbmemo"=>$son['mark'], //表体备注
+                    "cdefine22"=>$son['cdefine22'], //手机号码
+                    "cdefine23"=>"",
+                    "cdefine24"=>"",
+                    "cdefine25"=>$son['cdefine25'], //平台类型
+                    "cdefine26"=>"",
+                    "cdefine27"=>"",
+                    "cdefine28"=>$son['cdefine28'], //平台单号
+                    "cdefine29"=>$son['cdefine29'], //分社施工
+                    "cdefine30"=>$son['cdefine30'], //业务员
+                    "cdefine31"=>$son['cdefine31'], //客户名称
+                    "cdefine32"=>$son['cdefine32'], //直播销售
+                    "cdefine33"=>"",
+                    "cdefine34"=>"",
+                    "cdefine35"=>"",
+                    "cdefine36"=>"",
+                    "cdefine37"=>"",
+                    "cfree1"=>"",
+                    "cfree2"=>"",
+                    "cfree3"=>"",
+                    "cfree4"=>"",
+                    "cfree5"=>"",
+                    "cfree6"=>"",
+                    "cfree7"=>"",
+                    "cfree8"=>"",
+                    "cfree9"=>"",
+                    "cfree10"=>""
+                ];
+            }
+
+            //最终数据
+            $post['data'] = [
+                "csocode"=>'',
+                "ddate"=> $time,
+                "cmaker"=>$cmaker ?? 'admin',
+                "dcreatesystime"=>$time1,
+                "cstcode"=>"",
+                "cbustype" => $value['cbustype'], //业务类型
+                "cstname"=>$value['cstname'], //销售类型
+                "ccuscode"=>"",
+                "ccusabbname"=>$value['ccusabbname'], //客户简称
+                "cdepcode"=>"",
+                "cdepname"=>"", // 部门名称 $value['cdepname']
+                "cpersoncode"=>"", //业务员编码 暂时不要
+                "jobnumber"=>$value['jobnumber'],//业务员工号
+                "itaxrate"=>"0",
+                "cmemo"=>$value['mark'],//"T9销售订单:". $value['order_number']
+                "cdefine1"=>"",
+                "cdefine2"=>"",
+                "cdefine3"=>"",
+                "cdefine4"=>"",
+                "cdefine5"=>"",
+                "cdefine6"=>"",
+                "cdefine7"=>"",
+                "cdefine8"=>"",
+                "cdefine9"=>"",
+                "cdefine10"=>"",
+                "cdefine11"=>"",
+                "cdefine12"=>"",
+                "cdefine13"=>"",
+                "cdefine14"=>"",
+                "cdefine15"=>"",
+                "cdefine16"=>"",
+                "bodys"=>$bodys
+            ];
+
+            file_put_contents('record_purchase.txt',"请求参数:" . json_encode($post) . PHP_EOL,8);
+            $return = $this->post_helper($this->u8_api,json_encode($post), ['Content-Type:application/json']);
+            file_put_contents('record_purchase.txt',"返回结果:" . json_encode($return). PHP_EOL,8);
+
+            //剔除数据
+            $id = array_diff($id, [$value['id']]);
+
+            if(empty($return)) {
+                $msg = '异常错误,请确认请求接口地址或地址不可达';
+                $this->finalSettle($value['id'],U8Job::two, $msg);
+            }else{
+                if( ! empty($return['flag'])){
+                    $this->finalSettle($value['id'],U8Job::two);
+                }else{
+                    $this->finalSettle($value['id'], U8Job::two, $return['msg']);
+                }
+            }
+        }
+
+        if(! empty($id)){
+            $msg = "未找到同步数据";
+            $this->finalSettle($id,U8Job::two, $msg);
+        }
+    }
+
+    //最终处理
+    public function finalSettle($data,$data_type, $msg = ''){
+        if(! is_array($data)) $data = [$data];
+        $time = time();
+        $insert = [];
+
+        U8Job::where('del_time',0)
+            ->where('data_type',$data_type)
+            ->whereIn('data',$data)
+            ->update(['del_time' => $time]);
+        foreach ($data as $value){
+            if(empty($msg)){
+                $insert[] = [
+                    'data' => $value,
+                    'data_type' => $data_type,
+                    'crt_time' => $time,
+                    'state' => U8Job::success,
+                ];
+            }else{
+                $insert[] = [
+                    'data' => $value,
+                    'data_type' => $data_type,
+                    'crt_time' => $time,
+                    'state' => U8Job::failed,
+                    'msg' => $msg
+                ];
+            }
+        }
+
+        U8Job::insert($insert);
+    }
+
+    public function getPurchaseData($id){
+        $main = PurchaseOrder::whereIn('id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        if(empty($main)) return [];
+        $supplier = Supplier::whereIn('id',array_unique(array_column($main,'supplier')))
+            ->pluck('title','id')
+            ->toArray();
+//        $depart = Depart::whereIn('id',array_unique(array_column($main,'depart_id')))
+//            ->pluck('title','id')
+//            ->toArray();
+        $emp = Employee::whereIn('id',array_unique(array_column($main,'purchase_id')))
+            ->pluck('number','id')
+            ->toArray();
+        $code_map = BasicType::whereIn('id',array_unique(array_column($main,'purchase_type')))
+            ->pluck('title','id')
+            ->toArray();
+
+        $sub = PurchaseOrderInfo::whereIn('purchase_order_id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        $product = Product::whereIn('id',array_unique(array_column($sub,'product_id')))
+            ->get()->toArray();
+        $product_map = array_column($product,null,'id');
+
+        $sub_map = [];
+        foreach ($sub as $value){
+            $product_tmp = $product_map[$value['product_id']] ?? [];
+            $value['code'] = $product_tmp['code'];
+
+            //计算金额
+            if($value['rate'] > 0){
+//                    ipertaxrate 税率
+//                    iunitprice 原币单价
+//                    itaxprice 原币含税单价
+//                    isum 原币价税合计
+//                    imoney 原币无税金额
+//                    itax 原币税额
+                $value['ipertaxrate'] = $value['rate'];
+                $rate = round($value['rate'] / 100,2);
+                $value['iunitprice'] = round($value['price'] / (1 + $rate),2);
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = round($value['price'] * $value['number'],2);
+                $value['imoney'] = round($value['iunitprice'] * $value['number'],2);
+                $value['itax'] = round($value['isum'] - $value['imoney'],2);
+            }else{
+                $value['ipertaxrate'] = 0;
+                $value['iunitprice'] = $value['price'];
+                $value['itaxprice'] = $value['price'];
+                $value['isum'] = $value['price'] * $value['number'];
+                $value['imoney'] = $value['isum'];
+                $value['itax'] = 0;
+            }
+
+            $sub_map[$value['purchase_order_id']][] = $value;
+        }
+        foreach ($main as $key => $value){
+            $main[$key]['cptname'] = $code_map[$value['purchase_type']] ?? "";
+            $main[$key]['cvenname'] = $supplier[$value['supplier']] ?? "";
+//            $main[$key]['cdepname'] = $depart[$value['depart_id']] ?? "";
+//            $main[$key]['cpersoncode'] = $emp[$value['purchase_id']] ?? "";
+            $main[$key]['jobnumber'] = $emp[$value['purchase_id']] ?? "";
+            $main[$key]['product'] = $sub_map[$value['id']] ?? [];
+        }
+
+        return $main;
+    }
+
+    public function getSaleOrderData($id){
+        $main = SalesOrder::whereIn('id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        if(empty($main)) return [];
+        $main_map = array_column($main,null,'id');
+        $sub = SalesOrderProductInfo::whereIn('sales_order_id',$id)
+            ->where('del_time',0)
+            ->get()->toArray();
+        $product = Product::whereIn('id',array_unique(array_column($sub,'product_id')))
+            ->get()->toArray();
+        $product_map = array_column($product,null,'id');
+        $code_id = array_filter(array_unique(array_merge_recursive(array_column($main,'sale_type'),array_column($main,'plat_type'),array_column($main,'install_position'),array_column($main,'customer_short_name'))));
+        $code_map = BasicType::whereIn('id',$code_id)
+            ->pluck('title','id')
+            ->toArray();
+        $customer_map = Customer::whereIn('id',array_unique(array_column($main,'customer_id')))
+            ->pluck('title','id')
+            ->toArray();
+//        $depart = Depart::where('parent_id',0)
+//            ->pluck('title','id')
+//            ->toArray();
+        $empList = Employee::whereIn('id',array_unique(array_column($main,'crt_id')))
+            ->select('number','id','emp_name')
+            ->get()
+            ->toArray();
+        $emp = array_column($empList,'number','id');
+        $emp2 = array_column($empList,'emp_name','id');
+//        $see = SeeRange::where('del_time',0)
+//            ->whereIn('data_id',array_column($main,'id'))
+//            ->where('data_type',SeeRange::type_seven)
+//            ->where('type',SeeRange::data_three)
+//            ->pluck('param_id','data_id')->toArray();//指派的分社
+
+        $sub_map = [];
+        foreach ($sub as $value){
+            $product_tmp = $product_map[$value['product_id']] ?? [];
+            $main_tmp = $main_map[$value['sales_order_id']] ?? [];
+            $position = $code_map[$main_tmp['install_position']] ?? "";
+
+            if($main_tmp['model_type'] == SalesOrder::Model_type_four){
+                //线上订单
+                $cdefine28 = $main_tmp['plat_order'] ?? "";
+            }else{
+                $cdefine28 = $main_tmp['order_number'] ?? "";
+            }
+//            "itaxrate"=>$son['itaxrate'], //税率
+//            "iunitprice"=>$son['iunitprice'],//原币单价
+//            "itaxunitprice"=>$son['itaxunitprice'], // 原币含税单价
+//            "isum"=>$son['isum'], //原币价税合计
+//            "imoney"=>$son['imoney'], //原币无税金额
+//            "itax"=>$son['itax'],//原币税额
+            //计算金额
+            //比如这4个产品合同金额是300.11,那么价税合计就是300.11,
+            //含税单价就是300.11/4,目前加了税率的没有计算规则。税率不进入计算
+
+            $value['itaxrate'] = 0;//税率
+            $value['iunitprice'] = $value['price'];
+            $value['itaxunitprice'] = $value['price'];
+            $value['isum'] = $value['final_amount']; //原币价税合计
+            $value['imoney'] = $value['isum']; //原币无税金额
+            $value['itax'] = 0;
+
+//            if($value['rate'] > 0){
+//                $value['itaxrate'] = $value['rate'];
+//                $rate = round($value['rate'] / 100,2);
+//                $value['iunitprice'] = round($value['final_amount'] / (1 + $rate),2);
+//                $value['itaxunitprice'] = $value['final_amount'];
+//                $value['isum'] = round($value['final_amount'] * $value['number'],2);
+//                $value['imoney'] = round($value['iunitprice'] * $value['number'],2);
+//                $value['itax'] = round($value['isum'] - $value['imoney'],2);
+//            }else{
+//                $value['itaxrate'] = 0;
+//                $value['iunitprice'] = $value['final_amount'];
+//                $value['itaxunitprice'] = $value['final_amount'];
+//                $value['isum'] = $value['final_amount'] * $value['number'];
+//                $value['imoney'] = $value['isum'];
+//                $value['itax'] = 0;
+//            }
+            $value['cdefine25'] = $code_map[$main_tmp['plat_type']] ?? ""; //平台类型
+            $value['cdefine28'] = $cdefine28; //平台单号
+//            $top_depart_id = $see[$value['sales_order_id']] ?? 0;
+            $value['cdefine29'] = $position ?? "";//安装地点
+            $value['cdefine32'] = "";//直播销售 暂时没有
+            $value['cdefine31'] = $customer_map[$main_tmp['customer_id']] ?? "";//客户名称
+            $value['cdefine22'] = $main_tmp['customer_contact'] ?? "";//手机号码
+//            $value['cdefine31'] = "";//客户名称(线上的时候就是空  线下的话就是表头的客户简称)
+//            $value['cdefine22'] = "";//手机号码 暂时没有
+            $value['cdefine30'] = $emp2[$main_tmp['crt_id']] ?? "";//业务员
+            $value['code'] = $product_tmp['code'];//存货编码
+
+            $sub_map[$value['sales_order_id']][] = $value;
+        }
+        foreach ($main as $key => $value){
+            $customer_short_name = $code_map[$value['customer_short_name']] ?? "";
+//            if($plat_type == "营销部"){
+//                $ccusabbname = "营销部客户";
+//            }else{
+//                $ccusabbname = $customer_map[$value['customer_id']] ?? "";
+//            }
+            $main[$key]['cbustype'] = "普通销售"; //业务类型(本身就是中文)
+            $main[$key]['cstname'] = SalesOrder::$model_type_title[$value['model_type']] ?? ""; //销售类型
+            $main[$key]['ccusabbname'] = $customer_short_name;//客户简称
+//            $main[$key]['cdepname'] = $depart[$value['top_depart_id']] ?? "";//部门名称
+//            $main[$key]['cpersoncode'] = $emp[$value['crt_id']] ?? "";//业务员
+            $main[$key]['jobnumber'] = $emp[$value['crt_id']] ?? "";
+            $main[$key]['product'] = $sub_map[$value['id']] ?? [];
+        }
+
+        return $main;
+    }
+
+    public function post_helper($url, $data, $header = [], $timeout = 20){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_ENCODING, '');
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        $r = curl_exec($ch);
+        curl_close($ch);
+        return json_decode($r, true);
+    }
+}

+ 0 - 78
app/Service/LabelDealService.php

@@ -1,78 +0,0 @@
-<?php
-
-namespace App\Service;
-
-
-use App\Model\BigKingCbj;
-
-class LabelDealService extends Service
-{
-    protected static $instance;
-
-    public static function getInstance(): self
-    {
-        if (self::$instance == null) self::$instance = new LabelDealService();
-        return self::$instance;
-    }
-
-    public function clearData($data,&$return,&$box_list){
-        if( empty($data['lead_out']) || empty($data['lead_out']['brand_out_stock_list'])) return;
-
-        foreach ($data['lead_out']['brand_out_stock_list'] as $value){
-            $box_list[] = $value['send_box_code'];
-            foreach ($value['brand_out_stock_dtl'] as $tmp){
-                if(! isset($return[$value['send_box_code']])){
-                    $return[$value['send_box_code']] = [
-                        'fake_qty' => 0,
-                        'detail' => [],
-                    ];
-                }
-                $return[$value['send_box_code']]['fake_qty'] += $tmp['fake_qty'];
-                $return[$value['send_box_code']]['detail'] = array_merge($return[$value['send_box_code']]['detail'], explode(',',$tmp['brand_qr_code_list']));
-            }
-        }
-    }
-
-    public function boxOut($lead_bind,$lead_out,$token,$id)
-    {
-        //商标出库
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind_out_stock';
-//        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/11';
-        $return_out = $this->post_helper($url, json_encode($lead_out), $token);
-        file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "出库:" . $return_out. PHP_EOL,8);
-        $return_out = json_decode($return_out, true);
-
-        sleep(3);
-
-        //商标绑定
-//        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/1';
-        $url = 'https://tm.dwycloud.com/jbl/api/module-data/brand_in_stock/brand_in_stock/diy/lead_bind';
-        $return_bind = $this->post_helper($url, json_encode($lead_bind), $token);
-        file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "绑定:" . $return_bind. PHP_EOL,8);
-        $return_bind = json_decode($return_bind, true);
-
-        if(isset($return_bind['status']) && $return_bind['status'] == 'success' && isset($return_out['status']) && $return_out['status'] == 'success') BigKingCbj::where('id',$id)->update(['is_successful' => 1]);
-    }
-
-    public function post_helper($url, $data, $auth)
-    {
-        file_put_contents('msg_result.txt',date('Y-m-d H:i:s') . "请求参数:" . $data . PHP_EOL,8);
-        $header = [
-            'Content-Type:application/json',
-            'Authorization: ' . $auth,
-        ];
-        $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;
-
-    }
-}

+ 0 - 94
app/Service/SysMenuService.php

@@ -1,94 +0,0 @@
-<?php
-
-namespace App\Service;
-
-
-use App\Model\SysMenu;
-
-/**
- * 菜单相关
- * @package App\Models
- */
-class SysMenuService extends Service
-{
-
-    public function edit($data){
-        list($status,$msg) = $this->menuRule($data);
-        if(!$status) return [$status,$msg];
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-        $id = $data['id'];
-        $first = SysMenu::where('title',$data['title'])->where('id','<>',$id)->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = SysMenu::where('id',$id)->first();
-        $model->title = $data['title'];
-        $model->icon = $data['icon'] ??  '';
-        $model->uri = $data['uri'];
-        $model->parent_id = $data['parent_id'];
-        $model->sort = $data['sort'] ?? 0;
-        $model->save();
-
-        return [true,'保存成功!'];
-
-    }
-
-    public function add($data,$user){
-
-
-//        if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
-        list($status,$msg) = $this->menuRule($data);
-        if(!$status) return [$status,$msg];
-        $first = SysMenu::where('title',$data['title'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new SysMenu();
-
-        $model->title = $data['title'];
-        $model->icon = $data['icon'] ??  '';
-        $model->uri = $data['uri'];
-        $model->parent_id = $data['parent_id'];
-        $model->sort = $data['sort'] ?? 0;
-//        $model->crt_id = $user->id;
-        $model->crt_id = 1;
-        $model->save();
-
-        return [true,'保存成功!'];
-
-    }
-
-    public function del($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
-
-        SysMenu::where('id',$data['id'])->update([
-            'del_time'=>time()
-        ]);
-
-        return [true,'删除成功'];
-    }
-
-    public function menuList($data){
-        if(isset($data['type'])) $type = $data['type'];
-        else $type = '1';
-        if($type === '1'){
-            $return  = SysMenu::where('del_time',0)->select('title','icon','uri','parent_id','sort','crt_time','id')->orderBy('sort','desc')->get()->toArray();
-        }else{
-            $list = SysMenu::where('del_time',0)->where('state',1)->select('title','icon','uri','parent_id','sort','crt_time','id')->orderBy('sort','desc')->get()->toArray();
-            $return = $this->makeTree(0,$list);
-            $return = $this->set_sort_circle($return);
-        }
-
-
-        return [200,$return];
-    }
-
-    public function menuRule($data){
-        if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
-//        if($this->isEmpty($data,'icon')) return [201,'d不存在!'];
-//        if($this->isEmpty($data,'uri')) return [false,'路由不存在!'];
-        if($this->isEmpty($data,'parent_id')) return [false,'父级不存在!'];
-
-        return [true,''];
-    }
-
-
-}

+ 10 - 0
config/j_rfid.php

@@ -0,0 +1,10 @@
+<?php
+//状态码
+return [
+    //登录标识
+    'LoginRedisTopic' => 'JRFIDLOGIN',
+    //登录
+    'login' => 'https://gzy.qingyaokeji.com/jbl/api/mes/login',
+    //站点获取
+    'site' => 'https://gzy.qingyaokeji.com/jbl/api/site/all/ignore-action?_allow_anonymous=true',
+];

+ 0 - 64
routes/api.php

@@ -17,71 +17,7 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
     return $request->user();
 });
 
-//用于出标机开关门的redis
-Route::any('openCommand', 'Api\DwyController@openCommand');
-Route::any('getOpenCommand', 'Api\DwyController@getOpenCommand');
-Route::any('openDoor', 'Api\DwyController@openDoor');
-Route::any('setLb', 'Api\DwyController@setLb');
-Route::any('boxList', 'Api\DwyController@boxList');
-Route::any('ttttt', 'Api\TestController@deviceCallback');
-//Route::any('boxOut', 'Api\DwyController@boxOut');
-
-//贴标机
-Route::any('setTbData', 'Api\DwyController@setTbData');
-Route::any('getTbData', 'Api\DwyController@getTbData');
-
 Route::any('login', 'Api\LoginController@login');
-Route::any('job', 'Api\JobController@processDataJobAdd');
-Route::any('job_device', 'Api\JobController@processDataJobAddDevice');
-Route::any('man_device', 'Api\JobController@processDataJobAddDeviceMan');
-//通道门传输的数据保存单号
-Route::any('setOrderNumber', 'Api\InOutOptionController@setOrderNumber');
-//获取单号
-Route::any('getOrderNumber', 'Api\InOutOptionController@getOrderNumber');
-//设置发货出库标识
-Route::any('setFhMessage', 'Api\InOutOptionController@setFhMessage');
-Route::any('del', 'Api\JobController@delKey');
-Route::any('oee', 'Api\ScreenController@oee');
-Route::any('wyOee', 'Api\ScreenController@wyOee');
-Route::any('wd', 'Api\ScreenController@wd');
-Route::any('yl', 'Api\ScreenController@yl');
-Route::any('gz', 'Api\ScreenController@gz');
-Route::any('deviceAll', 'Api\ScreenController@deviceAll');
-Route::any('deviceChart', 'Api\ScreenController@deviceChart');
-Route::any('inout', 'Api\ScreenController@inout');
-Route::any('upInout', 'Api\ScreenController@upInout');
-Route::any('gzEchart', 'Api\ScreenController@gzEchart');
-Route::any('t', 'Api\ScreenController@t');
-Route::any('deviceCallback', 'Api\TestController@deviceCallback');
-Route::any('advertisement', 'Api\DwyController@advertisement');
-Route::any('zjlb', 'Api\DwyController@zjlb');
-Route::any('tttt', 'Api\DwyController@tttt');
-Route::any('getBoxTrademark', 'Api\DwyController@getBoxTrademark');
-Route::any('aaaa', 'Api\DwyController@setBoxTrademark');
-Route::any('boxOut', 'Api\JobController@labelDeal');
 
 Route::group(['middleware'=> []],function ($route){
-    $route->any('menuAdd', 'Api\SysMenuController@add');
-    $route->any('menuEdit', 'Api\SysMenuController@edit');
-    $route->any('menuDel', 'Api\SysMenuController@del');
-    $route->any('menuList', 'Api\SysMenuController@menuList');
-
-    $route->any('employeeAdd', 'Api\EmployeeController@employeeAdd');
-    $route->any('employeeEdit', 'Api\EmployeeController@employeeEdit');
-    $route->any('employeeDel', 'Api\EmployeeController@employeeDel');
-    $route->any('employeeList', 'Api\EmployeeController@employeeList');
-
-    $route->any('departAdd', 'Api\EmployeeController@departAdd');
-    $route->any('departEdit', 'Api\EmployeeController@departEdit');
-    $route->any('departDel', 'Api\EmployeeController@departDel');
-    $route->any('departList', 'Api\EmployeeController@departList');
-
-    $route->any('roleAdd', 'Api\EmployeeController@roleAdd');
-    $route->any('roleEdit', 'Api\EmployeeController@roleEdit');
-    $route->any('roleDel', 'Api\EmployeeController@roleDel');
-    $route->any('roleList', 'Api\EmployeeController@roleList');
-
-    $route->any('employeeDepart', 'Api\EmployeeController@employeeDepart');
-    $route->any('employeeTeam', 'Api\EmployeeController@employeeTeam');
-    $route->any('employeeRole', 'Api\EmployeeController@employeeRole');
 });

部分文件因为文件数量过多而无法显示