display();
    }
    public function helloAction()
    {
        //\App\Jobs\SendEmail::dispatch('abc', ['fvzone@qq.com'], '您的验证码是0123', 'fsdafsd哈哈哈');
        //\App\Jobs\SendSms::dispatch(['15182223008'], '您的验证码是01234');
        $menus = DB::table('menu')->get();
        foreach($menus as $menu) {
            $url = str_replace('.', '/', $menu['url']);
            DB::table('menu')->where('id', $menu['id'])->update([
                'url' => $url,
            ]);
        }
        //\App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
        exit;
        
        /*
        $dbParams = array(
            'dbname' => 'gdoooa_demo',
            'user' => 'root',
            'password' => 'root',
            'host' => 'localhost:3307',
            'driver' => 'pdo_mysql',
            'charset' => 'utf8mb4',
            'default_table_options' => [
                'charset' => 'utf8mb4',
                'collate' => 'utf8mb4_unicode_ci',
            ]
        );
        $paths = array(base_path(). "/abc");
        $isDevMode = false;
        $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
        $em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
        $platform = $em->getConnection()->getDatabasePlatform();
        $platform->registerDoctrineTypeMapping('enum', 'string');
        $metadata = $em->getClassMetadata('App\\Share');
        //$cmf = $em->getMetadataFactory();
        //$class = $cmf->getMetadataFor('Share');
        print_r($metadata);
        */
        $abc['indexes'] = [
            'idx_object_id' => [
                'columns' => ['source_id'],
            ],
        ];
        $abc['columns'] = [
            'id' => [
            'name' => '', 
            'type' => '', 
            'default' => '', 
            'notnull' => '', 
            'length' => '', 
            'unsigned' => '', 
            'autoincrement' => '', 
            'comment' => '',
        ], 'name' => [
            'name' => '', 
            'type' => '', 
            'default' => '', 
            'notnull' => '', 
            'length' => '', 
            'unsigned' => '', 
            'autoincrement' => '',
            'comment' => '',
        ]];
        file_put_contents(base_path().'/abc.json', json_encode($abc, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
        /*
        $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
        $sm = $conn->getSchemaManager();
        $columns = $sm->listTableColumns('role');
        foreach ($columns as $column) {
            $column->
            echo $column->getName() . ': ' . $column->getType() . "\n";
        }
        print_r($columns);
        */
        exit;
        $abc = \Gdoo\Produce\Services\ProduceService::getPlanDetail('2020-08-01', '2020-08-04', 0, 0, 0);
        // $abc = \Gdoo\Stock\Service\StockService::reportOrderStockInOut(139, 0, '', '', '2020-08-01', '2020-09-21', 1, 1, 0);
        print_r($abc);
        exit;
        /*
        $rows = DB::table('model_permission')->get();
        foreach($rows as $row) {
            $data = json_decode($row['data'], true);
            print_r($data);
            foreach($data as $k => $rr) {
                // _product
                print_r($k);
                echo "\n";
            }
        }
        exit;
        */
        /*
        $users = DB::table('user')
        ->where('group_id', 2)
        ->get(['id','status', 'name', 'username']);
        foreach($users as $user) {
            DB::table('customer')->where('user_id', $user['id'])->update([
                'status' => $user['status'], 
                'name' => $user['name'],
                'code' => $user['username'],
            ]);
        }
        echo 'demo';
        exit;
        */
        $gets['stock_allocation']['out_warehouse_id'] = 111;
        if($gets['stock_allocation']['out_warehouse_id'] <> 140 and $gets['stock_allocation']['out_warehouse_id'] <> 139 and $gets['stock_allocation']['out_warehouse_id'] <> 20005 and $gets['stock_allocation']['out_warehouse_id'] <> 20048) {
            echo '1111111111111';
        }
        if($gets['stock_allocation']['out_warehouse_id'] == 140 or $gets['stock_allocation']['out_warehouse_id'] == 139 or $gets['stock_allocation']['out_warehouse_id'] == 20005 or $gets['stock_allocation']['out_warehouse_id'] == 20048) {
            echo '22222222222222';
            exit;
        }
        exit;
        /*
        $customers = DB::table('tbb_customer')
        ->get(['tbb_customer.*']);
        
        $users = [];
        foreach($customers as $customer) {
            $users[] = [
                'id' => $customer['CustID'],
                'code' => $customer['cCusCode'],
                'name' => $customer['cCusName'],
                'tel' => $customer['cCusPhone'],
                'fax' => $customer['cCusFax'],
                'address' => $customer['cCusAddress'],
                'head_phone' => $customer['cCusLPersonPhone'],
                'head_name' => $customer['cCusLPerson'],
                'email' => $customer['cCusEmail'],
                
                // 直营 3
                'type_id' => (int)($customer['bZykh2'] == 1 ? 3 : 1),
                // 是否调拨
                'is_allocate' => (int)$customer['bZykh'],
                // 一般纳税人
                'general_taxpayer' => (int)$customer['Sfybnsr'],
                'status' => (int)$customer['Status'],
                'warehouse_address' => $customer['CustWhAddress'],
                'warehouse_tel' => $customer['TelPhone'],
                'warehouse_contact' => $customer['CustWhPerson'],
                'warehouse_phone' => $customer['CustWhPhone'],
                'warehouse_size' => $customer['CustWhSqure'],
            ];
        }
        */
        /*
        $pwd = bcrypt('123456');
        foreach($users as $user) {
            DB::table('user')->insert([
                'id' => $user['id'],
                'username' => $user['code'],
                'name' => $user['name'],
                'email' => $user['email'],
                'phone' => $user['head_phone'],
                'status' => $user['status'], 
                'group_id' => 2,
                'role_id' => 2,
                'password' => $pwd,
            ]);
            DB::table('customer')->insert($user);
        }
        exit;
        $ufcustomer = DB::table('ufcustomer')->get()->toArray();
        $ccodes = [];
        foreach($ufcustomer as $_ufcustomer) {
            $ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
        }
        foreach($ccodes as $cid => $_codes) {
            foreach($_codes as $i => $_code) {
            }
        }
        */
        //100189
        $ufcustomer = DB::table('ufcustomer')->get()->toArray();
        $ccodes = [];
        foreach($ufcustomer as $_ufcustomer) {
            $ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
        }
        $users = DB::table('user')->where('group_id', 2)->get()->keyBy('username')->toArray();
        foreach($ccodes as $cid => $_codes) {
            foreach($_codes as $i => $_code) {
            }
        }
        /*
        set_time_limit(0);
        $rows = file_get_contents(public_path('r.json'));
        $rows = json_decode($rows, true);
        foreach($rows as $row) {
            $id1 = DB::table('region')->insertGetId(['name' => $row['name'], 'code' => $row['code'], 'layer' => 1]);
            foreach($row['cityList'] as $city) {
                $id2 = DB::table('region')->insertGetId(['layer' => 2, 'parent_id' => $id1, 'name' => $city['name'], 'code' => $city['code']]);
                foreach($city['areaList'] as $area) {
                    DB::table('region')->insertGetId(['layer' => 3, 'parent_id' => $id2, 'name' => $area['name'], 'code' => $area['code']]);
                }
            }
        }
        echo 111;
        */
        exit;
        /*
        \App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
        exit;
        DB::enableQueryLog();
        $user = DB::table('user as u')->orderBy('id', 'desc')->orderBy('username', 'asc')->first();
        print_r(DB::getQueryLog());
        */
        /*
        $units = option('product.unit')->pluck('id', 'name');
        $rows = DB::table('product')->get();
        foreach($rows as $row) {
            $unit = strtolower($row['unit']);
            if (isset($units[$unit])) {
                $row['unit_id'] = $units[$unit];
                DB::table('product')->where('id', $row['id'])->update($row);
            } else {
                echo $unit."\n";
            }
        }
        */
        exit;
        /*
        $t1 = microtime(true);
        $stocks = DB::table('stock_yonyou_data')
        ->groupBy('code')
        ->selectRaw('sum(quantity_set - quantity_get) as quantity,code')
        ->pluck('quantity', 'code');
        $abc = 0;
        foreach ($stocks as $stock) {
            $abc += $stock;
        }
        echo $abc."
";
        $t2 = microtime(true);
        echo '耗时'.($t2 - $t1).'秒';
        ``
        exit;
        */
        //$abc = \Yunpian::send('15182223008', '您的验证码是5967');
        //print_r($abc);
        //exit;
        /*
        $agentid = 1000035;
        $url = 'http://www.shenghuafood.com/article/article/view?id=1336&agentid='.$agentid;
        //$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww42727b1e44abc7fa&redirect_uri='.$u.'&response_type=code&scope=snsapi_privateinfo&agentid='.$agentid.'&state='.$agentid.'#wechat_redirect';
        $msg = array(
            'touser'  => 'qy01bbfb5d6f30ae009bc0e5b8fb',
            'toparty' => '',
            'msgtype' => 'news',
            'agentid' => $agentid,
            'news' => array(
                "articles"=> array(
                    0 => array(
                        "title"       => "有新的公告提醒",
                        "description" => "[公告】关于西安大军区的调整公告",
                        "url"         => $url,
                        "picurl"      => ""
                ))
            )
            'text'    => array(
                "content"=>"各部门及同事:\n".
                "为更好的服务好再来大厦,满足大厦入驻员工的班车需求,现对部分班车路线及时刻做相应调整,自2016年9月20日零时生效。详情点击\nhttp://banche.hoolilai.com"
            )
        );
                
        $api = new \App\Wechat\Work\App($agentid);
        
        var_dump($api->sendMsgToUser($msg));
        */
        $xml = simplexml_load_file('tpl.xml');
        /*
        $attributes = $xml->record->attributes();
        foreach ($attributes as $k => $v) {
            print_r($k.'---'.$v);
        }
        */
        $form = $xml->xpath("record[@type='form']/form")[0];
        foreach ($form as $key => $node) {
            if ($key == 'group') {
                $fields = [];
                foreach ($node as $k => $field) {
                    if ($k == 'field') {
                        $attr = $field->attributes();
                        $col  = $attr['col'] - 2;
                        $abc[] = '';
                        $abc[] = '