|
@@ -34,6 +34,9 @@ class OutputPresenter:
|
|
|
PAYABLE_FILTER_TOOLS = frozenset(('list_payable_cost_filter_options',))
|
|
PAYABLE_FILTER_TOOLS = frozenset(('list_payable_cost_filter_options',))
|
|
|
PAYABLE_EXPORT_TOOLS = frozenset(('export_payable_cost_list',))
|
|
PAYABLE_EXPORT_TOOLS = frozenset(('export_payable_cost_list',))
|
|
|
DESTINATION_TRAILER_TOOLS = frozenset(('query_destination_trailer_list',))
|
|
DESTINATION_TRAILER_TOOLS = frozenset(('query_destination_trailer_list',))
|
|
|
|
|
+ ORDER_ABNORMAL_TOOLS = frozenset(('query_order_abnormal_list',))
|
|
|
|
|
+ RECEIVE_VOLUME_TOOLS = frozenset(('query_receive_volume_list',))
|
|
|
|
|
+ CONTAINER_TIMELINESS_TOOLS = frozenset(('query_container_timeliness_list',))
|
|
|
DETAIL_TOOLS = frozenset(('query_outbound_detail',))
|
|
DETAIL_TOOLS = frozenset(('query_outbound_detail',))
|
|
|
ORDER_DETAIL_TOOLS = frozenset(('query_order_detail',))
|
|
ORDER_DETAIL_TOOLS = frozenset(('query_order_detail',))
|
|
|
OPTION_TOOLS = frozenset((
|
|
OPTION_TOOLS = frozenset((
|
|
@@ -42,12 +45,15 @@ class OutputPresenter:
|
|
|
'list_pending_outbound_export_filter_options',
|
|
'list_pending_outbound_export_filter_options',
|
|
|
'list_customer_filter_options',
|
|
'list_customer_filter_options',
|
|
|
'list_destination_trailer_filter_options',
|
|
'list_destination_trailer_filter_options',
|
|
|
|
|
+ 'list_order_abnormal_filter_options',
|
|
|
|
|
+ 'list_receive_volume_filter_options',
|
|
|
))
|
|
))
|
|
|
EXPORT_TOOLS = frozenset((
|
|
EXPORT_TOOLS = frozenset((
|
|
|
'export_pending_outbound_orders',
|
|
'export_pending_outbound_orders',
|
|
|
'export_out_of_province_port_data',
|
|
'export_out_of_province_port_data',
|
|
|
'export_receivable_cost_list',
|
|
'export_receivable_cost_list',
|
|
|
'export_pallet_data',
|
|
'export_pallet_data',
|
|
|
|
|
+ 'export_container_timeliness_report',
|
|
|
))
|
|
))
|
|
|
TASK_TOOLS = frozenset(('query_export_task',))
|
|
TASK_TOOLS = frozenset(('query_export_task',))
|
|
|
SAFE_TOOLS = (
|
|
SAFE_TOOLS = (
|
|
@@ -56,6 +62,9 @@ class OutputPresenter:
|
|
|
| RECEIVABLE_LIST_TOOLS | RECEIVABLE_FILTER_TOOLS
|
|
| RECEIVABLE_LIST_TOOLS | RECEIVABLE_FILTER_TOOLS
|
|
|
| PAYABLE_COST_TOOLS | PAYABLE_FILTER_TOOLS | PAYABLE_EXPORT_TOOLS
|
|
| PAYABLE_COST_TOOLS | PAYABLE_FILTER_TOOLS | PAYABLE_EXPORT_TOOLS
|
|
|
| DESTINATION_TRAILER_TOOLS
|
|
| DESTINATION_TRAILER_TOOLS
|
|
|
|
|
+ | ORDER_ABNORMAL_TOOLS
|
|
|
|
|
+ | RECEIVE_VOLUME_TOOLS
|
|
|
|
|
+ | CONTAINER_TIMELINESS_TOOLS
|
|
|
| OPTION_TOOLS | EXPORT_TOOLS | TASK_TOOLS
|
|
| OPTION_TOOLS | EXPORT_TOOLS | TASK_TOOLS
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -547,6 +556,56 @@ class OutputPresenter:
|
|
|
DESTINATION_TRAILER_PROGRESS_STAGES = frozenset((
|
|
DESTINATION_TRAILER_PROGRESS_STAGES = frozenset((
|
|
|
'待安排拖车', '待提柜', '待还柜(海)', '已还柜(海)', '已提货(空)',
|
|
'待安排拖车', '待提柜', '待还柜(海)', '已还柜(海)', '已提货(空)',
|
|
|
))
|
|
))
|
|
|
|
|
+ ORDER_ABNORMAL_COLUMNS = (
|
|
|
|
|
+ ('order_number', '订单号'), ('customer_name', '客户'),
|
|
|
|
|
+ ('product_name', '物流产品'), ('abnormal_status', '问题件状态'),
|
|
|
|
|
+ ('abnormal_type', '问题件类型'), ('abnormal_desc', '问题件描述'),
|
|
|
|
|
+ ('outbound_status', '排舱单状态'), ('inbound_date', '入库时间'),
|
|
|
|
|
+ ('marker_name', '标记人'),
|
|
|
|
|
+ )
|
|
|
|
|
+ ORDER_ABNORMAL_STATUSES = frozenset((
|
|
|
|
|
+ '待处理', '放行待审核', '包裹放行', '退件待审核', '退件驳回', '已退件',
|
|
|
|
|
+ ))
|
|
|
|
|
+ RECEIVE_VOLUME_COLUMNS = (
|
|
|
|
|
+ ('order_number', '订单号'), ('customer_name', '客户名称'),
|
|
|
|
|
+ ('packing_type', '货物类型'), ('inbound_volume', '入库体积'),
|
|
|
|
|
+ ('inbound_date', '入库时间'), ('sales_name', '商务经理'),
|
|
|
|
|
+ ('merchandiser_name', '客户经理'), ('department_name', '事业部'),
|
|
|
|
|
+ ('product_name', '物流产品'),
|
|
|
|
|
+ )
|
|
|
|
|
+ CONTAINER_TIMELINESS_COLUMNS = (
|
|
|
|
|
+ ('ship_company', '船公司'), ('bl_number', '提单号'),
|
|
|
|
|
+ ('container_code', '柜号'), ('container_type', '柜型'),
|
|
|
|
|
+ ('is_direct_send_name', '是否直送'), ('shipping_method', '运输方式'),
|
|
|
|
|
+ ('route', '航线'), ('vessel_name', '航名航次'),
|
|
|
|
|
+ ('wharf_name', '到港码头'), ('providers_name', '拖车行'),
|
|
|
|
|
+ ('dt_status_name', '柜子状态'), ('warehouse_name', '交货仓库'),
|
|
|
|
|
+ ('order_total', '件数'), ('total_volume', '体积'),
|
|
|
|
|
+ ('total_weight', '重量'), ('loading_name', '起运港'),
|
|
|
|
|
+ ('destination_name', '目的港'), ('delivery_address', '派送地址'),
|
|
|
|
|
+ ('has_throw_off_name', '甩柜'), ('throw_off_time', '甩柜时间'),
|
|
|
|
|
+ ('ed_check_name', '报关查验'), ('ed_check_time', '报关查验时间'),
|
|
|
|
|
+ ('qg_check_name', '清关查验'), ('check_time', '清关查验时间'),
|
|
|
|
|
+ ('in_inspection_site', '进查验场时间'),
|
|
|
|
|
+ ('out_inspection_site', '出查验场时间'),
|
|
|
|
|
+ ('is_close_area_name', '封闭区'), ('start_close_area', '进封闭区时间'),
|
|
|
|
|
+ ('end_close_area', '出封闭区时间'), ('outbound_date', '出库时间'),
|
|
|
|
|
+ ('export_release_time', '出口报关放行时间'),
|
|
|
|
|
+ ('etd', '干线预计出发时间'), ('eta', '干线预计到达时间'),
|
|
|
|
|
+ ('gxyjsx', '干线预计时效'), ('departure_time', '干线实际出发时间'),
|
|
|
|
|
+ ('arrival_time', '干线实际到达时间'), ('gxsjsx', '干线实际时效'),
|
|
|
|
|
+ ('hcsx', '航程时效'), ('start_clearance_time', '开始清关时间'),
|
|
|
|
|
+ ('import_release_time', '海外清关放行时间'),
|
|
|
|
|
+ ('wharf_wait_time', '码头等待时间'), ('pickup_time', '码头提柜时间'),
|
|
|
|
|
+ ('second_pickup_time', '二次提柜时间'), ('tgsx', '提柜时效'),
|
|
|
|
|
+ ('max_appointment_delivery_time', 'APPT时间'),
|
|
|
|
|
+ ('delivery_end_time', '卡车实际派送时间'),
|
|
|
|
|
+ ('oversea_warehouse_name', '海外仓库名称'),
|
|
|
|
|
+ ('inbound_date', '到仓时间'), ('inbound_time', '海外仓入库时间'),
|
|
|
|
|
+ ('container_return_date', '还空柜时间'), ('hksx', '还空时效'),
|
|
|
|
|
+ ('amazon_wait_time', '亚马逊等待时间'),
|
|
|
|
|
+ ('inner_remark', '内部备注'), ('financial_remark', '财务备注'),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
OUTBOUND_DETAIL_SUMMARY = {
|
|
OUTBOUND_DETAIL_SUMMARY = {
|
|
|
'bl_number': '提单号',
|
|
'bl_number': '提单号',
|
|
@@ -709,6 +768,20 @@ class OutputPresenter:
|
|
|
'inbound_time_start': '海外仓入库时间开始',
|
|
'inbound_time_start': '海外仓入库时间开始',
|
|
|
'inbound_time_end': '海外仓入库时间结束',
|
|
'inbound_time_end': '海外仓入库时间结束',
|
|
|
},
|
|
},
|
|
|
|
|
+ 'query_container_timeliness_list': {
|
|
|
|
|
+ 'container_codes': '柜号',
|
|
|
|
|
+ 'bl_numbers': '提单号',
|
|
|
|
|
+ 'departure_time_start': '干线实际出发时间开始',
|
|
|
|
|
+ 'departure_time_end': '干线实际出发时间结束',
|
|
|
|
|
+ 'page': '页码',
|
|
|
|
|
+ 'limit': '每页数量',
|
|
|
|
|
+ },
|
|
|
|
|
+ 'export_container_timeliness_report': {
|
|
|
|
|
+ 'container_codes': '柜号',
|
|
|
|
|
+ 'bl_numbers': '提单号',
|
|
|
|
|
+ 'departure_time_start': '干线实际出发时间开始',
|
|
|
|
|
+ 'departure_time_end': '干线实际出发时间结束',
|
|
|
|
|
+ },
|
|
|
'export_receivable_cost_list': {
|
|
'export_receivable_cost_list': {
|
|
|
'reference_numbers': '参考号',
|
|
'reference_numbers': '参考号',
|
|
|
'tracking_numbers': '跟踪号',
|
|
'tracking_numbers': '跟踪号',
|
|
@@ -823,6 +896,18 @@ class OutputPresenter:
|
|
|
return self._present_destination_trailer_list(
|
|
return self._present_destination_trailer_list(
|
|
|
data, tool_result.get('meta'), meta
|
|
data, tool_result.get('meta'), meta
|
|
|
)
|
|
)
|
|
|
|
|
+ if tool_name in self.ORDER_ABNORMAL_TOOLS:
|
|
|
|
|
+ return self._present_order_abnormal_list(
|
|
|
|
|
+ data, tool_result.get('meta'), meta
|
|
|
|
|
+ )
|
|
|
|
|
+ if tool_name in self.RECEIVE_VOLUME_TOOLS:
|
|
|
|
|
+ return self._present_receive_volume_list(
|
|
|
|
|
+ data, tool_result.get('meta'), meta
|
|
|
|
|
+ )
|
|
|
|
|
+ if tool_name in self.CONTAINER_TIMELINESS_TOOLS:
|
|
|
|
|
+ return self._present_container_timeliness_list(
|
|
|
|
|
+ data, tool_result.get('meta'), meta
|
|
|
|
|
+ )
|
|
|
if tool_name in self.TABLE_TOOLS:
|
|
if tool_name in self.TABLE_TOOLS:
|
|
|
return self._present_table(
|
|
return self._present_table(
|
|
|
tool_name,
|
|
tool_name,
|
|
@@ -1645,6 +1730,134 @@ class OutputPresenter:
|
|
|
}
|
|
}
|
|
|
return self._success_result(content, self._render_table(content), meta)
|
|
return self._success_result(content, self._render_table(content), meta)
|
|
|
|
|
|
|
|
|
|
+ def _present_order_abnormal_list(self, data, raw_meta, meta):
|
|
|
|
|
+ if set(data) != {'abnormal_status', 'columns', 'records'}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ abnormal_status = data.get('abnormal_status')
|
|
|
|
|
+ if abnormal_status not in self.ORDER_ABNORMAL_STATUSES:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ expected = list(self.ORDER_ABNORMAL_COLUMNS)
|
|
|
|
|
+ pagination = self._customer_pagination(raw_meta)
|
|
|
|
|
+ columns = data.get('columns')
|
|
|
|
|
+ records = data.get('records')
|
|
|
|
|
+ if (
|
|
|
|
|
+ not isinstance(columns, list)
|
|
|
|
|
+ or not isinstance(records, list)
|
|
|
|
|
+ or len(columns) != len(expected)
|
|
|
|
|
+ or pagination is None
|
|
|
|
|
+ ):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ for column, (key, name) in zip(columns, expected):
|
|
|
|
|
+ if column != {'key': key, 'name': name}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ rows = []
|
|
|
|
|
+ expected_keys = [key for key, _ in expected]
|
|
|
|
|
+ for record in records:
|
|
|
|
|
+ if not isinstance(record, dict) or set(record) != set(expected_keys):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row = []
|
|
|
|
|
+ for key in expected_keys:
|
|
|
|
|
+ value = record[key]
|
|
|
|
|
+ if not isinstance(value, str):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row.append(value)
|
|
|
|
|
+ rows.append(row)
|
|
|
|
|
+ headers = [{'label': name} for _, name in expected]
|
|
|
|
|
+ content = {
|
|
|
|
|
+ 'abnormal_status': abnormal_status,
|
|
|
|
|
+ 'headers': headers,
|
|
|
|
|
+ 'rows': rows,
|
|
|
|
|
+ 'pagination': pagination,
|
|
|
|
|
+ }
|
|
|
|
|
+ return self._success_result(content, self._render_table(content), meta)
|
|
|
|
|
+
|
|
|
|
|
+ def _present_receive_volume_list(self, data, raw_meta, meta):
|
|
|
|
|
+ if set(data) != {'columns', 'records'}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ expected = list(self.RECEIVE_VOLUME_COLUMNS)
|
|
|
|
|
+ pagination = self._customer_pagination(raw_meta)
|
|
|
|
|
+ columns = data.get('columns')
|
|
|
|
|
+ records = data.get('records')
|
|
|
|
|
+ if (
|
|
|
|
|
+ not isinstance(columns, list)
|
|
|
|
|
+ or not isinstance(records, list)
|
|
|
|
|
+ or len(columns) != len(expected)
|
|
|
|
|
+ or pagination is None
|
|
|
|
|
+ ):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ for column, (key, name) in zip(columns, expected):
|
|
|
|
|
+ if column != {'key': key, 'name': name}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ rows = []
|
|
|
|
|
+ expected_keys = [key for key, _ in expected]
|
|
|
|
|
+ for record in records:
|
|
|
|
|
+ if not isinstance(record, dict) or set(record) != set(expected_keys):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row = []
|
|
|
|
|
+ for key in expected_keys:
|
|
|
|
|
+ value = record[key]
|
|
|
|
|
+ if key == 'inbound_volume':
|
|
|
|
|
+ if not self._valid_volume_cell(value):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row.append(value)
|
|
|
|
|
+ continue
|
|
|
|
|
+ if not isinstance(value, str):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row.append(value)
|
|
|
|
|
+ rows.append(row)
|
|
|
|
|
+ headers = [{'label': name} for _, name in expected]
|
|
|
|
|
+ content = {
|
|
|
|
|
+ 'headers': headers,
|
|
|
|
|
+ 'rows': rows,
|
|
|
|
|
+ 'pagination': pagination,
|
|
|
|
|
+ }
|
|
|
|
|
+ return self._success_result(content, self._render_table(content), meta)
|
|
|
|
|
+
|
|
|
|
|
+ def _present_container_timeliness_list(self, data, raw_meta, meta):
|
|
|
|
|
+ if set(data) != {'columns', 'records'}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ expected = list(self.CONTAINER_TIMELINESS_COLUMNS)
|
|
|
|
|
+ pagination = self._customer_pagination(raw_meta)
|
|
|
|
|
+ columns = data.get('columns')
|
|
|
|
|
+ records = data.get('records')
|
|
|
|
|
+ if (
|
|
|
|
|
+ not isinstance(columns, list)
|
|
|
|
|
+ or not isinstance(records, list)
|
|
|
|
|
+ or len(columns) != len(expected)
|
|
|
|
|
+ or pagination is None
|
|
|
|
|
+ ):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ for column, (key, name) in zip(columns, expected):
|
|
|
|
|
+ if column != {'key': key, 'name': name}:
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ rows = []
|
|
|
|
|
+ expected_keys = [key for key, _ in expected]
|
|
|
|
|
+ for record in records:
|
|
|
|
|
+ if not isinstance(record, dict) or set(record) != set(expected_keys):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row = []
|
|
|
|
|
+ for key in expected_keys:
|
|
|
|
|
+ value = record[key]
|
|
|
|
|
+ if not isinstance(value, str):
|
|
|
|
|
+ return self._format_error(meta)
|
|
|
|
|
+ row.append(value)
|
|
|
|
|
+ rows.append(row)
|
|
|
|
|
+ headers = [{'label': name} for _, name in expected]
|
|
|
|
|
+ content = {
|
|
|
|
|
+ 'headers': headers,
|
|
|
|
|
+ 'rows': rows,
|
|
|
|
|
+ 'pagination': pagination,
|
|
|
|
|
+ }
|
|
|
|
|
+ return self._success_result(content, self._render_table(content), meta)
|
|
|
|
|
+
|
|
|
|
|
+ @staticmethod
|
|
|
|
|
+ def _valid_volume_cell(value):
|
|
|
|
|
+ return (
|
|
|
|
|
+ not isinstance(value, bool)
|
|
|
|
|
+ and isinstance(value, (int, float))
|
|
|
|
|
+ and math.isfinite(float(value))
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
@staticmethod
|
|
@staticmethod
|
|
|
def _valid_amount_cell(value):
|
|
def _valid_amount_cell(value):
|
|
|
if not isinstance(value, dict) or set(value) != {'amount', 'currency'}:
|
|
if not isinstance(value, dict) or set(value) != {'amount', 'currency'}:
|