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'] ?? ""; } $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]['site'] = $data['site'] ?? ""; } $url = config("j_rfid.scanScreenCompleted"); $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 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]; } }