|
|
@@ -2665,6 +2665,56 @@ class common {
|
|
|
$reference = utils::replacementsFixed($total,$reference,array("Download_Complete"));
|
|
|
}
|
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Show shipments delayed in the last 30 days."){
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
+ }
|
|
|
+ $sqlArr = explode(";", $sql);
|
|
|
+ $sqlCount = $sqlArr[0];
|
|
|
+ //拼接用户权限
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
+ $sqlCount = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlCount);
|
|
|
+ error_log("countSql:".$sqlCount);
|
|
|
+ $count = common::excuteOneSql($sqlCount);
|
|
|
+ //替换总数
|
|
|
+ $total = array("total" =>$count);
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,array("total"));
|
|
|
+
|
|
|
+ $sqlDetail = $sqlArr[1];
|
|
|
+ //拼接用户权限
|
|
|
+ $sqlDetail = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlDetail);
|
|
|
+ error_log("detail:".$sqlDetail);
|
|
|
+ $data = common::excuteListSql($sqlDetail);
|
|
|
+
|
|
|
+ $refer_data =array();
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
+ $temp['log_type'] = $d['log_type'];
|
|
|
+ $temp['planned_time'] = common::dealDateTime($d['event_old_date'],$d['event_old_time'],'',"m/d/Y");
|
|
|
+ $temp['actual_time'] = common::dealDateTime($d['event_date'],$d['event_time'],'',"m/d/Y");
|
|
|
+ $temp['duration'] = $d['duration'] <= 0 ? '< 1 Days' : $d['duration'].' Days';
|
|
|
+
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
+ $httpUrl = SERVER_Vue_PAHT."tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
+ $temp['action'] = '<a href="'.$httpUrl.'" target="_blank">Details</a> <a href="'.SERVER_Vue_PAHT.'SystemSettings" target="_blank">Notify</a>';
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ $reference = utils::replacementsFixedMultilineForFixed($refer_data,$reference,$fixedChat['table_format_tr']);
|
|
|
+
|
|
|
+ $total = array("Download_Complete" =>"");
|
|
|
+ if ($count > 10){
|
|
|
+ $httpUrl = SERVER_PAHT."main_new_version.php?action=robot_chat&operate=download&faq=". common::deCode($fixedChat["fixed_faq"]);
|
|
|
+ $download_complete = '- Due to page limitations, only the first 10 records are currently displayed. If you need the complete data, please click the <a href="'.$httpUrl.'" target="_blank">Download Complete</a> button.';
|
|
|
+ $total = array("Download_Complete" =>$download_complete);
|
|
|
+ }
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,array("Download_Complete"));
|
|
|
+ }
|
|
|
+
|
|
|
if($fixedChat["fixed_faq"] == "List shipments with milestone updates in the last 7 days."){
|
|
|
$reference = $fixedChat["answer_style"];
|
|
|
$sql = $fixedChat["fixed_sql"];
|
|
|
@@ -3108,6 +3158,20 @@ class common {
|
|
|
$columns[] = array("display_name" => "Cargo Type","database_column_name"=>"cargo_type");
|
|
|
}
|
|
|
|
|
|
+ if($faq == "Show shipments delayed in the last 30 days."){
|
|
|
+ // | HBL/HAWB No. | Origin | Destination | Latest Milestone | ETA | Cargo Type | Actions |
|
|
|
+ // |--------------|------------------|------------------|------------------|-----------|---------------|------------------|
|
|
|
+ // | {{h_bol}} | {{place_of_receipt_exp}} | {{place_of_delivery_exp}} | {{description}} | {{eta}} | {{cargo_type}} | {{action}} |
|
|
|
+ $columns = array();
|
|
|
+ $columns[] = array("display_name" => "HBL/HAWB No.","database_column_name"=>"h_bol");
|
|
|
+ $columns[] = array("display_name" => "Origin","database_column_name"=>"place_of_receipt_exp");
|
|
|
+ $columns[] = array("display_name" => "Destination","database_column_name"=>"place_of_delivery_exp");
|
|
|
+ $columns[] = array("display_name" => "Delayed Type","database_column_name"=>"log_type");
|
|
|
+ $columns[] = array("display_name" => "Planned Date","database_column_name"=>"planned_time");
|
|
|
+ $columns[] = array("display_name" => "Actual/Revised Date","database_column_name"=>"actual_time");
|
|
|
+ $columns[] = array("display_name" => "Delay Duration","database_column_name"=>"duration");
|
|
|
+ }
|
|
|
+
|
|
|
if($faq == "List shipments with milestone updates in the last 7 days."){
|
|
|
// | HBL/HAWB No. | Latest Milestone | Time | Location | Actions |
|
|
|
// |--------------|----------------------------|------------------------------|---------------------------|------------------|
|
|
|
@@ -3172,5 +3236,94 @@ class common {
|
|
|
}
|
|
|
return $columns;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理数据问题
|
|
|
+ */
|
|
|
+ public static function dealDataWithFaq($faq,$data){
|
|
|
+ $refer_data = array();
|
|
|
+ //返回格式相同的放到一起处理
|
|
|
+ if($faq == "Shipments arriving in the next 7 days."){
|
|
|
+ $refer_data = $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "Show shipments delayed in the last 30 days."){
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
+ $temp['log_type'] = $d['log_type'];
|
|
|
+ $temp['planned_time'] = common::dealDateTime($d['event_old_date'],$d['event_old_time'],'',"m/d/Y");
|
|
|
+ $temp['actual_time'] = common::dealDateTime($d['event_date'],$d['event_time'],'',"m/d/Y");
|
|
|
+ $temp['duration'] = $d['duration'] <= 0 ? '< 1 Days' : $d['duration'].' Days';
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "List shipments with milestone updates in the last 7 days."){
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['description'] = $d['description'];
|
|
|
+ $temp['update_date'] = common::dealDateTime($d['update_date'],"",$d['timezone'],"m/d/Y H:i:s");
|
|
|
+ $temp['locations'] = $d['locations'];
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "What is the current status of my active shipments?"){
|
|
|
+ foreach($data as $key => $val){
|
|
|
+ $temp = array();
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
+ $temp['description'] = $d['description'];
|
|
|
+ $temp['time'] = common::dealDateTime($d['act_date'],$d['act_time'],$d['timezone'],"m/d/Y");
|
|
|
+ $temp['locations'] = $d['locations'];
|
|
|
+ $temp['cargo_type'] = $d['cargo_type'];
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "List shipments with container status updates in the last 7 days."){
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['container_no'] = $d['container_no'];
|
|
|
+ $temp['description'] = $d['description'];
|
|
|
+ $temp['time'] = common::dealDateTime($d['eventdate'],$d['eventtime'],$d['timezone'],"m/d/Y");
|
|
|
+ $temp['uncity'] = $d['uncity'];
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "Today's shipments summary."){
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['transport_mode'] = $d['transport_mode'];
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
+ $temp['action_type'] = $d['action_type'];
|
|
|
+ $temp['time'] = common::dealDateTime($d['act_date'],$d['act_time'],$d['timezone'],"m/d/Y");
|
|
|
+ $temp['locations'] = $d['locations'];
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($faq == "Sort my active shipments by earliest arrival date."){
|
|
|
+ foreach($data as $key =>$d){
|
|
|
+ $temp = array();
|
|
|
+ $temp['eta'] = $d['eta'];
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
+ $temp['transport_mode'] = $d['transport_mode'];
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
+ $temp['day_to_arr'] = $d['day_to_arr'];
|
|
|
+ $refer_data[] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $refer_data;
|
|
|
+ }
|
|
|
}
|
|
|
?>
|