| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458 | <?phpnamespace App\Service;use Illuminate\Support\Facades\Log;class JRFIDServerService extends Service{    public function loginRule($data){        if(empty($data['name'])) return [false, '请输入账号!'];        if(empty($data['password'])) return [false, '请输入密码!'];        list($status, $msg) = $this->getToken($data);        if(! $status) return [false, $msg];        return [true, ['data' => $msg]];    }    public function getToken($data){        $account = $data['name'];        $password = $data['password'];        $url = config("j_rfid.login");        $post = [            "name" => $account,            "password" => $password,            "rememberMe" => true        ];        $header = ['Content-Type:application/json'];        list($status, $result) = $this->post_helper($url,$post, $header);        if(! $status) return [$status, $result];        //登录失败        if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];        return [true, $result];    }    public function getSite($data){        $url = config("j_rfid.site");        list($status,$result) = $this->get_helper($url);        if(! $status) return [$status, $result];        if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];        return [true, $result];    }    public function getSite2($data,$param){        $url = config("j_rfid.site2");        $header = ["Authorization: {$param['token']}"];        list($status,$result) = $this->get_helper($url,$header);        if(! $status) return [$status, $result];        if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];        return [true, $result];    }    public function getFlowByProduce($data,$param){        if(empty($data['produce_no'])) return [false, '订单号不能为空'];        if(empty($data['site'])) return [false, '站点不能为空'];        $url = config("j_rfid.get_flow_by_produce");        $post = [            'produce_no' => $data['produce_no'],            'site' => $data['site'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        return [true, $result['data']];    }    public function getProduceByContract($data,$param){        if(empty($data['contract_no'])) return [false, '合同不能为空'];        if(empty($data['site'])) return [false, '站点不能为空'];        $url = config("j_rfid.get_produce_by_contract");        $post = [            'contract_no' => $data['contract_no'],            'site' => $data['site'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        return [true, $result['data']];    }    public function getPrintData($data){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, '打印数据类型不能为空'];        $size = $data['size'] ?? 9;        $number = $data['number'] ?? 1;        $rsaService = new RsaEncryptionService();        $dataToEncrypt = [            'id' => $data['id'],            'type' => $data['type'],            'size' => $size,            'number' => $number,        ];        $this->recKSort($dataToEncrypt);        //加密        $encryptedData = $rsaService->encrypt2($dataToEncrypt);////        $return2 = $rsaService->decrypt2($return);//dd($return,$return2);//        $aa = $rsaService->aesDecrypt($aes);//        dd($aes,$aa);////        list($status, $encryptedData) = $rsaService->encrypt($dataToEncrypt);//        if(! $status) return [false, $encryptedData];        $url = config("j_rfid.get_print_data");        Log::channel('apiLog')->info('工装云POST:源数据', ["api" => $url , "param" => $dataToEncrypt]);        $post = [            'body' => $encryptedData,        ];        list($status,$result) = $this->post_helper($url,$post,['Content-Type:application/json']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['furn_pro_flow_dt_a'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function getPrintData2($data){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, '打印数据类型不能为空'];        $size = $data['size'] ?? 9;        $number = $data['number'] ?? 1;        $rsaService = new RsaEncryptionService();        $dataToEncrypt = [            'id' => $data['id'],            'type' => $data['type'],            'size' => $size,            'number' => $number,        ];        $this->recKSort($dataToEncrypt);        //加密        $encryptedData = $rsaService->encrypt2($dataToEncrypt);        $url = config("j_rfid.get_sep_order_dt_data");        Log::channel('apiLog')->info('工装云POST:源数据', ["api" => $url , "param" => $dataToEncrypt]);        $post = [            'body' => $encryptedData,        ];        list($status,$result) = $this->post_helper($url,$post,['Content-Type:application/json']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['furn_sep_order_dt_prod'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    // 关联数组排序,递归    public function recKSort(&$arr)    {        $kstring = true;        foreach ($arr as $k => &$v) {            if (!is_string($k)) {                $kstring = false;            }            if (is_array($v)) {                $this->recKSort($v);            }        }        if ($kstring) {            ksort($arr);        }    }    public function getTeam($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.get_team");        $post['rules'] = [            [                'field' => 'site',                'option' => 'LIKE_ANYWHERE',                'values' => [$data['site']]            ],            [                'field' => 'is_used',                'option' => 'IN',                'values' => ['1']            ]        ];        if(isset($data['department_code'])) {            $post['rules'] = array_merge($post['rules'], [[                'field' => 'department_code',                'option' => 'IN',                'values' => [$data['department_code']]            ]]);        }        $post['size'] = $data['size'] ?? 6;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function getDepart($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.get_depart");        $post['rules'] = [            [                'field' => 'is_used',                'option' => 'IN',                'values' => ['1']            ]        ];        $post['size'] = $data['size'] ?? 6;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function getProcedureClass($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.get_procedure_class");        $post['rules'] = [            [                'field' => 'is_used',                'option' => 'IN',                'values' => ['1']            ]        ];        $post['size'] = $data['size'] ?? 6;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function furnProduceScheduleList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.furn_produce_schedule_list");        $sorts = [];        if(empty($data['sorts'])) {            //默认            $sorts = [                [                    "property" => "exe_produce_order_a.order_date",                    "direction" => "DESC",                    "sortOrderNumber" => 2                ]            ];        }        $post = [            "direction" => $data['direction'] ?? "DESC", //排序            "property" =>  $data['direction'] ?? "id", // 排序            "sorts" => $sorts        ];        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        $post['rules'] = $data['rules'] ?? [];        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function completionOrders($data,$param){        if(empty($data['screenDataList'])) return [false, '完工数据不能为空'];        if(empty($data['site'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '完工数据不能为空'];            $data['screenDataList'][$key]['completed_teams_group'] = $data['completed_teams_group'] ?? "";            $data['screenDataList'][$key]['completed_teams_group_show'] = $data['completed_teams_group_show'] ?? "";            $data['screenDataList'][$key]['completed_date'] = $utc_date;            $data['screenDataList'][$key]['completed_date_lt'] = $date;            $data['screenDataList'][$key]['procedure_code'] = $data['procedure_code'] ?? [];            $data['screenDataList'][$key]['site'] = $data['site'] ?? "";            $data['screenDataList'][$key]['data_type'] = "manual";            $data['screenDataList'][$key]['data_type_show'] = "手工新建";        }        $url = config("j_rfid.completion_orders");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post, $param['header']);        if(! $status) return [$status, $result];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function scanScreenCompleted($data,$param){        if(empty($data['screenDataList'])) return [false, '完工数据不能为空'];        if(empty($data['site'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '完工数据不能为空'];            $data['screenDataList'][$key]['completed_teams_group'] = $data['completed_teams_group'] ?? "";            $data['screenDataList'][$key]['completed_teams_group_show'] = $data['completed_teams_group_show'] ?? "";            $data['screenDataList'][$key]['completed_date'] = $utc_date;            $data['screenDataList'][$key]['completed_date_lt'] = $date;            $data['screenDataList'][$key]['data_type'] = "manual";            $data['screenDataList'][$key]['data_type_show'] = "手工新建";            $data['screenDataList'][$key]['site'] = $data['site'] ?? "";        }        $url = config("j_rfid.scanScreenCompleted");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post, $param['header'], 300);        if(! $status) return [$status, $result];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function qualityOrders($data,$param){        if(empty($data['screenDataList'])) return [false, '质检数据不能为空'];        if(empty($data['site'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '质检数据不能为空'];            $data['screenDataList'][$key]['qualified_teams_group'] = $data['qualified_teams_group'] ?? "";            $data['screenDataList'][$key]['qualified_teams_group_show'] = $data['qualified_teams_group_show'] ?? "";            $data['screenDataList'][$key]['qualified_date'] = $utc_date;            $data['screenDataList'][$key]['qualified_date_lt'] = $date;            $data['screenDataList'][$key]['procedure_code'] = $data['procedure_code'] ?? [];            $data['screenDataList'][$key]['site'] = $data['site'] ?? "";        }        $url = config("j_rfid.quality_orders");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post, $param['header']);        if(! $status) return [$status, $result];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function screenPrint($data){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $rsaService = new RsaEncryptionService();        $dataToEncrypt = [            'id' => $data['id'],            'type' => $data['type']        ];        $this->recKSort($dataToEncrypt);        //加密        $encryptedData = $rsaService->encrypt2($dataToEncrypt);//        list($status, $encryptedData) = $rsaService->encrypt($dataToEncrypt);//        if(! $status) return [false, $encryptedData];        $url = config("j_rfid.screen_print");        Log::channel('apiLog')->info('工装云POST:源数据', ["api" => $url , "param" => $dataToEncrypt]);        $post = [            'body' => $encryptedData,        ];        list($status,$result) = $this->post_helper($url,$post,['Content-Type:application/json']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        return [true, ''];    }    public function screenPrintSepData($data){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $rsaService = new RsaEncryptionService();        $dataToEncrypt = [            'id' => $data['id'],            'type' => $data['type']        ];        $this->recKSort($dataToEncrypt);        //加密        $encryptedData = $rsaService->encrypt2($dataToEncrypt);        $url = config("j_rfid.screen_print_sep_data");        Log::channel('apiLog')->info('工装云POST:源数据', ["api" => $url , "param" => $dataToEncrypt]);        $post = [            'body' => $encryptedData,        ];        list($status,$result) = $this->post_helper($url,$post,['Content-Type:application/json']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        return [true, ''];    }    public function getE8AndUTC(){        $eastEightTimeZone = new \DateTimeZone('Asia/Shanghai'); // 东八区时区        $utcTimeZone = new \DateTimeZone('UTC'); // UTC时区        // 假设的东八区时间,没有毫秒部分        $dateTimeString = date("Y-m-d H:i:s");        $milliseconds = '000'; // 假设的毫秒值        // 创建DateTime对象并设置时区为东八区        $dateTime = new \DateTime($dateTimeString, $eastEightTimeZone);        // 将DateTime对象转换为UTC时区        $dateTime->setTimezone($utcTimeZone);        // 格式化DateTime对象为ISO 8601格式,并添加毫秒部分        $formattedDate = $dateTime->format('Y-m-d\TH:i:s') . '.' . str_pad($milliseconds, 3, '0', STR_PAD_LEFT) . 'Z';        return [$dateTimeString,$formattedDate];    }    public function getContractDrawRoom($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $post['site'] = $data['site'];        $post['type'] = $data['type'];        $url = config("j_rfid.get_contract_draw_room");        if(isset($data['contract_no'])) $post['contract_no'] = $data['contract_no'];        if(isset($data['room_no'])) $post['room_no'] = $data['room_no'];        if(isset($data['drawing_no'])) $post['drawing_no'] = $data['drawing_no'];        if(isset($data['procedure_calss'])) $post['procedure_calss'] = $data['procedure_calss'];        $post['size'] = $data['size'] ?? 10;        $post['number'] = $data['number'] ?? 1;        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function screenGetProFlow($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['contract_no'])) return [false, '合同不能为空'];        if(empty($data['drawing_no'])) return [false, '图号不能为空'];        if(empty($data['room_no'])) return [false, '房间号不能为空'];        $url = config("j_rfid.screen_get_pro_flow");        $post = [            'site' => $data['site'],            'contract_no' => $data['contract_no'],            'drawing_no' => $data['drawing_no'],            'room_no' => $data['room_no'],        ];        $post['size'] = $data['size'] ?? 10;        $post['number'] = $data['number'] ?? 1;        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function getDispatchContractDrawRoom($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $post['site'] = $data['site'];        $post['type'] = $data['type'];        $url = config("j_rfid.get_dispatch_contract_draw_room");        if(isset($data['contract_no'])) $post['contract_no'] = $data['contract_no'];        if(isset($data['room_no'])) $post['room_no'] = $data['room_no'];        if(isset($data['drawing_no'])) $post['drawing_no'] = $data['drawing_no'];        if(isset($data['procedure_calss'])) $post['procedure_calss'] = $data['procedure_calss'];        $post['size'] = $data['size'] ?? 10;        $post['number'] = $data['number'] ?? 1;        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function screenSend($data,$param){        if(empty($data['screenDataList'])) return [false, '收发货数据不能为空'];        if(empty($data['site']) || empty($data['site_show'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '收发货数据不能为空'];            $data['screenDataList'][$key]['delivery_teams_group'] = $data['delivery_teams_group'];            $data['screenDataList'][$key]['delivery_teams_group_show'] = $data['delivery_teams_group_show'];            $data['screenDataList'][$key]['delivery_date'] = $utc_date;            $data['screenDataList'][$key]['delivery_date_lt'] = $date;            $data['screenDataList'][$key]['site'] = $data['site'];            $data['screenDataList'][$key]['site_show'] = $data['site_show'];        }        $url = config("j_rfid.screen_send");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function screenReceipt($data,$param){        if(empty($data['screenDataList'])) return [false, '发货数据不能为空'];        if(empty($data['site']) || empty($data['site_show'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '发货数据不能为空'];//            $data['screenDataList'][$key]['delivery_teams_group'] = $data['delivery_teams_group'];//            $data['screenDataList'][$key]['delivery_teams_group_show'] = $data['delivery_teams_group_show'];            $data['screenDataList'][$key]['receipt_date'] = $utc_date;            $data['screenDataList'][$key]['receipt_date_lt'] = $date;            $data['screenDataList'][$key]['site'] = $data['site'];            $data['screenDataList'][$key]['site_show'] = $data['site_show'];        }        $url = config("j_rfid.screenReceipt");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function screenPackage($data,$param){        if(empty($data['screenDataList'])) return [false, '包装数据不能为空'];        if(empty($data['site']) || empty($data['site_show'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '包装数据不能为空'];            $data['screenDataList'][$key]['package_teams_group'] = $data['package_teams_group'];            $data['screenDataList'][$key]['package_teams_group_show'] = $data['package_teams_group_show'];            $data['screenDataList'][$key]['package_date'] = $utc_date;            $data['screenDataList'][$key]['package_date_lt'] = $date;            $data['screenDataList'][$key]['site'] = $data['site'];            $data['screenDataList'][$key]['site_show'] = $data['site_show'];        }        $url = config("j_rfid.screen_package");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ['box_no' => $result['data'] ?? [], 'package_date' => $date]];    }    public function screenGetPackageData($data,$param){        if(empty($data['site'])) return [false, '站点信息不能为空'];        if(empty($data['contract_no'])) return [false, '合同不能为空'];//        if(empty($data['drawing_no'])) return [false, '图号不能为空'];//        if(empty($data['room_no'])) return [false, '房间号不能为空'];        $size = $data['size'] ?? 10;        $number = $data['number'] ?? 1;        $url = config("j_rfid.screen_get_package_data");        $post = [            'site' => $data['site'],            'contract_no' => $data['contract_no'],            'drawing_no' => $data['drawing_no'] ?? "",            'room_no' => $data['room_no'] ?? "",            'size' => $size,            'number' => $number,        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function screenGetProDtData($data,$param){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];//        if(empty($data['contract_no'])) return [false, '合同不能为空'];//        if(empty($data['drawing_no'])) return [false, '图号不能为空'];        $url = config("j_rfid.screenGetProDtData");        $post = [            'id' => $data['id'],            'type' => $data['type'],            'contract_no' => $data['contract_no'] ?? null,            'drawing_no' => $data['drawing_no'] ?? null,        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['furn_pro_flow_dt_a'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function screenGetPackageAssem($data,$param){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        if(empty($data['site'])) return [false, '站点不能为空'];        $url = config("j_rfid.screenGetPackageAssem");        $post = [            'id' => $data['id'],            'type' => $data['type'],            'site' => $data['site'],            'contract_no' => $data['contract_no'] ?? ""        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['assembly_list'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        foreach ($result['assembly_list'] as $key => $value){            foreach ($value['package_assembly_list'] as $kk => $vv){                $result['assembly_list'][$key]['package_assembly_list'][$kk]['package_date'] = $this->changeDateToDateMin($vv['package_date']);            }        }        return [true, $result['assembly_list']];    }    public function screenGetPackageAssemData($data,$param){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['contract_no'])) return [false, '合同不能为空'];        $url = config("j_rfid.screenGetPackageAssemData");        $post = [            'id' => $data['id'],            'type' => $data['type'],            'site' => $data['site'],            'contract_no' => $data['contract_no'] ?? ""        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['assembly_list'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        foreach ($result['assembly_list'] as $key => $value){            foreach ($value['package_assembly_list'] as $kk => $vv){                $result['assembly_list'][$key]['package_assembly_list'][$kk]['package_date'] = $this->changeDateToDateMin($vv['package_date']);            }        }        return [true, $result['assembly_list']];    }    public function screenGetDispatchDtData($data,$param){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $url = config("j_rfid.screen_get_dispatch_dt_data");        $post = [            'id' => $data['id'],            'type' => $data['type'],            'contract_no' => $data['contract_no'] ?? null,            'drawing_no' => $data['drawing_no'] ?? null,            'procedure' => $data['procedure'] ?? null,        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['furn_dispatch_product_dt'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function furnSeparateOrderDtAssemList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['id'])) return [false, '芯片|组件数据不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.furn_separate_order_dt_assem_list");        $post['rules'] = [            [                'field' => 'id',                'option' => 'IN',                'values' => $data['id']            ],        ];        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function screenPackageBySepAssem($data,$param){        if(empty($data['screenDataList'])) return [false, '包装数据不能为空'];        if(empty($data['site']) || empty($data['site_show'])) return [false, '站点信息不能为空'];        list($date,$utc_date) = $this->getE8AndUTC();        foreach ($data['screenDataList'] as $key => $value){            if(empty($value['id']) || ! isset($value['type'])) return [false, '包装数据不能为空'];            $data['screenDataList'][$key]['package_teams_group'] = $data['package_teams_group'];            $data['screenDataList'][$key]['package_teams_group_show'] = $data['package_teams_group_show'];            $data['screenDataList'][$key]['package_date'] = $utc_date;            $data['screenDataList'][$key]['package_date_lt'] = $date;            $data['screenDataList'][$key]['site'] = $data['site'];            $data['screenDataList'][$key]['site_show'] = $data['site_show'];        }        $url = config("j_rfid.screen_package_by_sep_assem");        $post = [            'screenDataList' => $data['screenDataList'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ['box_no' => $result['data'] ?? [], 'package_date' => $date]];    }    public function sendAndReceiptList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.sendAndReceiptList");        if(! empty($data['contract_no']) || ! empty($data['no']) || ! empty($data['drawing_no'])) {            $rules = [];            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'contract_no',                    'option' => 'IN',                    'values' => $data['contract_no']                ];            }            if(! empty($data['no'])) {                $rules[] = [                    'field' => 'no',                    'option' => 'LIKE_ANYWHERE',                    'values' => $data['no']                ];            }            if(! empty($data['drawing_no'])) {                $rules[] = [                    'field' => 'drawing_no',                    'option' => 'IN',                    'values' => $data['drawing_no']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function sendOrderDtAssemList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.sendOrderDtAssemList");        if(! empty($data['send_id']) || ! empty($data['sep_dt_assem_id']) || ! empty($data['contract_no'])) {            $rules = [];            if(! empty($data['send_id'])) {                $rules[] = [                    'field' => 'furn_send_prod_dt.send_id',                    'option' => 'IN',                    'values' => $data['send_id']                ];            }            if(! empty($data['sep_dt_assem_id'])) {                $rules[] = [                    'field' => 'sep_dt_assem_id',                    'option' => 'IN',                    'values' => $data['sep_dt_assem_id']                ];            }            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'furn_send_prod_dt.contract_no',                    'option' => 'NOT_IN',                    'values' => $data['contract_no']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function packageList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.packageList");        if(! empty($data['drawing_no']) || ! empty($data['contract_no'])) {            $rules = [];            if(! empty($data['drawing_no'])) {                $rules[] = [                    'field' => 'drawing_no',                    'option' => 'IN',                    'values' => $data['drawing_no']                ];            }            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'contract_no',                    'option' => 'IN',                    'values' => $data['contract_no']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function screenAutoCreateDispatch($data,$param){        if(empty($data['type'])) return [false, '类型不能为空'];        if(empty($data['id'])) return [false, 'ID不能为空'];        if(empty($data['contract_no'])) return [false, '合同号不能为空'];        if(empty($data['drawing_no'])) return [false, '图号不能为空'];        if(empty($data['procedure'])) return [false, '工序不能为空'];        foreach ($data['procedure'] as $value){            if(empty($value)) return [false, '工序不能为空'];        }        $post = [            'type' => $data['type'],            'id' => $data['id'],            'contract_no' => $data['contract_no'],            'drawing_no' => $data['drawing_no'],            'procedure' => $data['procedure'],        ];        $url = config("j_rfid.screenAutoCreateDispatch");        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, ''];    }    public function screenGetSepData($data,$param){        if(empty($data['id'])) return [false, '数据ID不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $url = config("j_rfid.screenGetSepData");        $post = [            'id' => $data['id'],            'type' => $data['type'],        ];        list($status,$result) = $this->post_helper($url,$post,$param['header']);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['furn_sep_order_dt_assem_list'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function furnSeparateOrderCompList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.furnSeparateOrderCompList");        if(! empty($data['drawing_no']) || ! empty($data['contract_no']) || ! empty($data['region']) || ! empty($data['room_no']) || ! empty($data['assembly_name']) || ! empty($data['component'])) {            $rules = [];            if(! empty($data['drawing_no'])) {                $rules[] = [                    'field' => 'exe_sep_order_a.drawing_no',                    'option' => 'IN',                    'values' => $data['drawing_no']                ];            }            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'exe_sep_order_a.contract_no',                    'option' => 'IN',                    'values' => $data['contract_no']                ];            }            if(! empty($data['region'])) {                $rules[] = [                    'field' => 'exe_sep_order_a.region',                    'option' => 'IN',                    'values' => $data['region']                ];            }            if(! empty($data['room_no'])) {                $rules[] = [                    'field' => 'exe_sep_order_dtl_b.room',                    'option' => 'IN',                    'values' => $data['room_no']                ];            }            if(! empty($data['assembly_name'])) {                $rules[] = [                    'field' => 'exe_sep_order_dtl_b.assembly_name',                    'option' => 'IN',                    'values' => $data['assembly_name']                ];            }            if(! empty($data['component'])) {                $rules[] = [                    'field' => 'component',                    'option' => 'IN',                    'values' => $data['component']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function furnSeparateOrderDtCompList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.furnSeparateOrderDtCompList");        if(! empty($data['drawing_no']) || ! empty($data['contract_no']) || ! empty($data['region']) || ! empty($data['room_no']) || ! empty($data['assembly_name']) || ! empty($data['component'])) {            $rules = [];            if(! empty($data['drawing_no'])) {                $rules[] = [                    'field' => 'furn_sep_order_dt_prod.drawing_no',                    'option' => 'IN',                    'values' => $data['drawing_no']                ];            }            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'furn_sep_order_dt_prod.contact_no',                    'option' => 'IN',                    'values' => $data['contract_no']                ];            }            if(! empty($data['region'])) {                $rules[] = [                    'field' => 'furn_sep_order_dt_prod.region',                    'option' => 'IN',                    'values' => $data['region']                ];            }            if(! empty($data['room_no'])) {                $rules[] = [                    'field' => 'furn_sep_order_dt_assem.room_no',                    'option' => 'IN',                    'values' => $data['room_no']                ];            }            if(! empty($data['assembly_name'])) {                $rules[] = [                    'field' => 'furn_sep_order_dt_assem.assembly_name',                    'option' => 'IN',                    'values' => $data['assembly_name']                ];            }            if(! empty($data['component'])) {                $rules[] = [                    'field' => 'component',                    'option' => 'IN',                    'values' => $data['component']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function getWorkshopData($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.getWorkshopData");        if(! empty($data['drawing_no'])) $post['drawing_no'] = $data['drawing_no'];        if(! empty($data['contract_no'])) $post['contract_no'] = $data['contract_no'];        if(! empty($data['region'])) $post['region'] = $data['region'];        if(! empty($data['room_no'])) $post['room_no'] = $data['room_no'];        if(! empty($data['assembly_name'])) $post['assembly_name'] = $data['assembly_name'];        if(! empty($data['component'])) $post['component'] = $data['component'];        $post['type'] = $data['type'];        $post['site'] = $data['site'];        $post['size'] = $data['size'] ?? 10;        $post['number'] = $data['number'] ?? 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function screenGetSendData($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        if(empty($data['type'])) return [false, 'TYPE不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.screenGetSendData");        if(! empty($data['drawing_no'])) $post['drawing_no'] = $data['drawing_no'];        if(! empty($data['contract_no'])) $post['contract_no'] = $data['contract_no'];        if(! empty($data['region'])) $post['region'] = $data['region'];        if(! empty($data['room_no'])) $post['room_no'] = $data['room_no'];        if(! empty($data['assembly_name'])) $post['assembly_name'] = $data['assembly_name'];        if(! empty($data['component'])) $post['component'] = $data['component'];        if(! empty($data['send_no'])) $post['send_no'] = $data['send_no'];        $post['type'] = $data['type'];        $post['site'] = $data['site'];        $post['size'] = $data['size'] ?? 10;        $post['number'] = $data['number'] ?? 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['message']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['success'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result['data']];    }    public function furnSendOrderDtCompList($data,$param){        if(empty($data['site'])) return [false, '站点不能为空'];        $header = array_merge($param['header'], ['site:'. $data['site']]);        $url = config("j_rfid.furnSendOrderDtCompList");        if(! empty($data['drawing_no']) || ! empty($data['contract_no']) || ! empty($data['region']) || ! empty($data['room_no']) || ! empty($data['assembly_name']) || ! empty($data['component'])) {            $rules = [];            if(! empty($data['drawing_no'])) {                $rules[] = [                    'field' => 'furn_send_assem_dt.drawing_no',                    'option' => 'IN',                    'values' => $data['drawing_no']                ];            }            if(! empty($data['contract_no'])) {                $rules[] = [                    'field' => 'furn_send_prod_dt.contact_no',                    'option' => 'IN',                    'values' => $data['contract_no']                ];            }            if(! empty($data['region'])) {                $rules[] = [                    'field' => 'furn_send_assem_dt.region',                    'option' => 'IN',                    'values' => $data['region']                ];            }            if(! empty($data['room_no'])) {                $rules[] = [                    'field' => 'furn_send_assem_dt.room_no',                    'option' => 'IN',                    'values' => $data['room_no']                ];            }            if(! empty($data['assembly_name'])) {                $rules[] = [                    'field' => 'furn_send_assem_dt.assembly_name',                    'option' => 'IN',                    'values' => $data['assembly_name']                ];            }            if(! empty($data['component'])) {                $rules[] = [                    'field' => 'component',                    'option' => 'IN',                    'values' => $data['component']                ];            }            $post['rules'] = $rules;        }        $post['size'] = $data['size'] ?? 10;        $post['number'] = ($data['number'] ?? 1) - 1;        list($status,$result) = $this->post_helper($url,$post,$header);        if(! $status) return [$status, $result];        if(! empty($result['status']) && $result['status'] == 'error') return [false, $result['msg']];        if(! empty($result['type']) && $result['type'] == 'errorVm') return [false, $result['message']];        if(! isset($result['content'])) {            $error = $result[0]['message'] ?? "操作失败,请刷新页面";            return [false, $error];        }        return [true, $result];    }    public function post_helper($url, $data, $header = [], $timeout = 20){        Log::channel('apiLog')->info('工装云POST', ["api" => $url , "param" => $data ,"header" => $header]);        $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, json_encode($data));        $r = curl_exec($ch);        if ($r === false) {            // 获取错误号            $errorNumber = curl_errno($ch);            // 获取错误信息            $errorMessage = curl_error($ch);            $message = "cURL Error #{$errorNumber}: {$errorMessage}";            Log::channel('apiLog')->info('工装云POST结果', ["message" => $message]);            return [false, $message];        }        curl_close($ch);        $return = json_decode($r, true);        Log::channel('apiLog')->info('工装云POST结果', ["message" => $return]);        if(! empty($return['message']) && $return['message'] == 'error.unAuthorized') return [0, '登录凭证已失效或者不正确'];        return [true, $return];    }    public function get_helper($url,$header=[],$timeout = 20){        $ch = curl_init();        curl_setopt_array($ch, array(            CURLOPT_URL => $url,            CURLOPT_RETURNTRANSFER => true,            CURLOPT_ENCODING => '',            CURLOPT_MAXREDIRS => 10,            CURLOPT_TIMEOUT => $timeout,            CURLOPT_FOLLOWLOCATION => true,            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,            CURLOPT_CUSTOMREQUEST => 'GET',            CURLOPT_SSL_VERIFYPEER => false,            CURLOPT_HTTPHEADER => $header,        ));        $r = curl_exec($ch);        if ($r === false) {            // 获取错误号            $errorNumber = curl_errno($ch);            // 获取错误信息            $errorMessage = curl_error($ch);            $message = "cURL Error #{$errorNumber}: {$errorMessage}";            Log::channel('apiLog')->info('工装云GET', ["message" => $message]);            return [false, $message];        }        curl_close($ch);        $return = json_decode($r, true);        Log::channel('apiLog')->info('工装云GET', ["message" => $return]);        if(! empty($return['message']) && $return['message'] == 'error.unAuthorized') return [0, '登录凭证已失效或者不正常'];        return [true, $return];    }}
 |