<?phpnamespace App\api\controller; UseThink\controller; Usethink\db; UseThink\Log;/** desc: Warehouse Sweep code Inbound API*/classStorageextendsbase{protected Static $erp; Public function__construct () {Parent::__construct (); $dbhost =config (' erp.dbhost '); $dbuser = config (' erp.dbuser '); Your MSSQL username $dbpass = config (' erp.dbpass '); Your mssql password $dbname = config (' erp.dbname '); Your MSSQL library name try{self:: $erp =odbc_connect ("Driver={sql Server}; server= $dbhost;D atabase= $dbname "," $dbuser "," $dbpass "); }catch (\exception $e) {echo ' ERP database connection error, please check the data connection '; die(); } } /*----------------------------The inbound scan code module starts-------------------------------------*/ /** * List of inbound orders within 5 days * @return \think\response\json * @throws \think\db\exception\datanotfoundexception * @th Rows \think\db\exception\modelnotfoundexception * @throws \think\exception\dbexception*/ Public functionscan_receipt_list () {$timestart= input (' Param.start '); $timeend= input (' param.end '); $day=config (' Erp.getnum '); $search _time_start=$timestart?$timestart:Date("Y-m-d",Strtotime("-$dayDay "));//Date of day $search _time_end=$timeend?$timeend:Date("y-m-d");//the latest date of the day//$map [' insert_time '] = Array (' Between ', [Strtotime ($search _time_start), Strtotime ($search _time_end)]); Read ERP purchase inbound list by date $sql = "Select Ccode from dbo. RDRECORD01 where ddate>= ' $search _time_start ' and ddate<= ' $search _time_end ' "; $exec =odbc_exec (self:: $erp, $sql); $list =[]; while ($row = Odbc_fetch_array ($exec)) {$list []= $row [' Ccode ']; } //$list = db::name (' Test ')->where ($map)->field (' Receipt ')->group (' Receipt ')->select (); if(Count($list)) { $data[' Code '] = 1; $data[' datas '] =$list; $data[' msg '] = ' get success '; }Else{ $data[' code '] = 0; $data[' datas '] = ""; $data[' msg '] = ' recent '.$day.‘ No storage list for the day; } returnJson$data); } /** * Warehouse Tube Scanning inbound orders, List of inbound products * @return \think\response\json * @throws \think\db\exception\datanotfoundexception * @throws \think\db\exception\modelnotfoundexception * @throws \think\exception\dbexception*/ Public functionScan_receipt_info () {$receipt=input ("Param.receipt"); if($receipt! = ") { //$list = db::name (' Test ')->where (' Receipt ', $receipt)->select (); //In accordance with the purchase order number to get inbound orders detailed $sql = "Select Ddate,ccode as receipt,cinvname as p_name,iquantity as p_num,cinvcode as p_code,cbatch as Bat Ch_number,dmadedate as brithday,imassdate as validity,dvdate as expiration from dbo.zpurrkdlist where cCode= ' $receipt ' "; $exec =odbc_exec (self:: $erp, $sql); $list =[]; $i = 0; while ($row = Odbc_fetch_array ($exec)) {$list [$i]= $row; $list [$i] [' P_num ']= (int) $row [' P_num ']; $list [$i] [' P_name ']=iconv (' GBK ', ' utf-8 ', $row [' p_name ']); $i + +; } foreach($list as $key=$val){ $tracking _code=db::name (' products ')->where (' P_code '),$val[' P_code ']) ->value (' Tracking_code '); $count=db::name (' Goodsstockinfo ')->where ([' Delivery_number ' =$val[' Receipt '], ' p_code ' =$val[' P_code ']) -Count(); $needscan=intval($val[' P_num ']) -intval($count); if($count>=$val[' P_num ']){ $list[$key[' Flag ']=1; $list[$key[' Brithday ']=$val[' Brithday ']; $list[$key[' Expiration ']=$val[' Expiration ']; $list[$key[' Tracking_code ']=$tracking _code; $list[$key[' Needscan_num ']=$needscan; }Else{ $list[$key[' Flag ']=0; $list[$key[' Brithday ']=$val[' Brithday ']; $list[$key[' Expiration ']=$val[' Expiration ']; $list[$key[' Tracking_code ']=$tracking _code; $list[$key[' Needscan_num ']=$needscan; } } $data[' Code '] = 1; $data[' datas '] =$list; $data[' msg '] = ' get success '; }Else{ $data[' code '] = 0; $data[' datas '] = ""; $data[' msg '] = ' inbound number cannot be empty '; }//return JSON ($DATA); Print_r($data); }}
PHP access to UF U8 data