ShuanghongS 2 weken geleden
bovenliggende
commit
5f74e71d94
3 gewijzigde bestanden met toevoegingen van 12 en 24 verwijderingen
  1. 1 0
      include.ini.php
  2. 4 3
      service/ocean_order.class.php
  3. 7 21
      utils/dms_edoc.class.php

+ 1 - 0
include.ini.php

@@ -45,6 +45,7 @@ include_once ADODB_PATH . 'adodb.inc.php';
 include_once ONLINE_ROOT . 'libs' . DS . 'config.ini.php';
 include_once ONLINE_ROOT . 'utils' . DS . 'utils.class.php';
 include_once ONLINE_ROOT . 'utils' . DS . 'common.class.php';
+include_once ONLINE_ROOT . 'utils' . DS . 'dms_edoc.class.php';
 include_once ONLINE_ROOT . 'libs' . DS . 'phpXLSWriter' . DS . "xlsxwriter.class.php";
 
 

+ 4 - 3
service/ocean_order.class.php

@@ -66,6 +66,7 @@ class ocean_order {
          * export ocean order to excel
         */
         if ($operate == "excel") {
+            //dms_edoc::getEdocFile('ABCNA1008776',["PDF","WORD","WO"]);
             $this->_ocean_excel();
         }
 
@@ -933,7 +934,7 @@ class ocean_order {
                 $textSearch_arr = array($textSearch_arr);
             }
             $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
-            
+
             //$sqlWhere .= " and (ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking),lower(tracking_no)],''))";
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(ARRAY[lower(booking_no::text), lower(h_bol::text), lower(m_bol), lower(carrier_booking), lower(quote_no), lower(tracking_no)]||string_to_array(lower(ctnrs),','), ''::text))
                 or lower(kln_ocean.po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
@@ -1031,8 +1032,8 @@ class ocean_order {
                 string_agg(distinct incoterms, '<$>') as incoterm_str,
                 string_agg(distinct service, '<$>') as service_str 
             from public.kln_ocean 
-                left join public.kln_ocean_extend oe 
-                    on oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text ". $sqlWhere_befrom_filterTag;
+                LEFT JOIN LATERAL ( SELECT import_po_no
+                    FROM public.kln_ocean_extend oe WHERE oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text) oe ON true ". $sqlWhere_befrom_filterTag;
             error_log("online_ocean_search_All_Status: ".$sql);
 
             //$sql_all_status_data = common::excuteObjectSql($sql);

+ 7 - 21
utils/dms_edoc.class.php

@@ -5,14 +5,11 @@ if (!defined('IN_ONLINE')) {
 }
 
 /**
- * Description of utilsclass
+ * Description of dms_edoc
  *
  * @author Administrator
  */
-class utils {
-    private static $cachedToken = null;
-    private static $tokenExpiryTime = 0;
-
+class dms_edoc {
     /**
      * 获取文件
     */
@@ -30,25 +27,21 @@ class utils {
             $grant_type = 'client_credentials';
             $client_id = 'online';
             $client_secret = 'ouuRZ8QbIrcqKZi0NBJLt7PUEiRr5uXd';
-            $accessToken = utils::getAccessToken($accessTokenUrl,$grant_type,$client_id,$client_secret);
+            $accessToken = dms_edoc::getAccessToken($accessTokenUrl,$grant_type,$client_id,$client_secret);
             if ($accessToken === null) {
                 throw new Exception("Failed to obtain access token");
             }
 
             $New_Dms_Url = 'http://dms.kln.com/edoc/documents/fileList'; 
-            $result = utils::CURLClient($New_Dms_Url,$accessToken,$data);
+            $result = dms_edoc::CURLClient($New_Dms_Url,$accessToken,$data);
         } catch (Exception $e) {
-            error_log("Error in downloadFiles: " . $e->getMessage());
+            error_log("Error getEdocFile: " . $e->getMessage());
         }
         return $result;
         
     }
 
     public static function getAccessToken($accessTokenUrl,$grant_type,$client_id,$client_secret){
-        if (self::$cachedToken !== null && time() * 1000 < self::$tokenExpiryTime) {
-            return self::$cachedToken;
-        }
-
         $postData = http_build_query([
             'grant_type' => $grant_type,
             'client_id' => $client_id,
@@ -83,15 +76,9 @@ class utils {
         if ($httpCode === 200) {
             $jsonResponse = json_decode($response, true);
             if (isset($jsonResponse['access_token'])) {
-                self::$cachedToken = $jsonResponse['access_token'];
-                //计算过期时间,但是换算成毫秒*1000
-                $expiresIn = isset($jsonResponse['expires_in']) ? $jsonResponse['expires_in'] * 1000 : 0;
-                self::$tokenExpiryTime = (time() * 1000) + $expiresIn - 300000;
-                return self::$cachedToken;
+                return $jsonResponse['access_token'];
             } 
         } 
-        self::$cachedToken = null;
-        self::$tokenExpiryTime = 0;
         return null;
     }
 
@@ -137,12 +124,11 @@ class utils {
             $result = json_decode($response, true);
             if ($httpCode == 200 && isset($result['data'])) {
                 return json_encode($result['data'], JSON_UNESCAPED_UNICODE);
-            }else{
-                return null;
             }
         } catch (Exception $e) {
             error_log($e->getMessage());
         }
+        return null;
     }
 
 }