@@ -1356,19 +1356,7 @@ _SHOP_DATA_CRAWL_ADMIN_COLUMNS = f"""
|
||||
t.task_no, t.status AS task_status, t.request_json, t.result_json,
|
||||
t.error_message AS task_error, t.created_at, t.updated_at, t.finished_at,
|
||||
{_SHOP_DATA_CRAWL_LATEST_TIME_SQL} AS latest_file_updated_at,
|
||||
u.username,
|
||||
(SELECT j.id FROM biz_task_file_job j
|
||||
WHERE j.module_type = 'SHOP_DATA_CRAWL' AND j.result_id = r.id
|
||||
AND j.job_type = 'ASSEMBLE_RESULT'
|
||||
ORDER BY j.id DESC LIMIT 1) AS file_job_id,
|
||||
(SELECT j.status FROM biz_task_file_job j
|
||||
WHERE j.module_type = 'SHOP_DATA_CRAWL' AND j.result_id = r.id
|
||||
AND j.job_type = 'ASSEMBLE_RESULT'
|
||||
ORDER BY j.id DESC LIMIT 1) AS file_status,
|
||||
(SELECT j.error_message FROM biz_task_file_job j
|
||||
WHERE j.module_type = 'SHOP_DATA_CRAWL' AND j.result_id = r.id
|
||||
AND j.job_type = 'ASSEMBLE_RESULT'
|
||||
ORDER BY j.id DESC LIMIT 1) AS file_error
|
||||
u.username
|
||||
"""
|
||||
|
||||
|
||||
@@ -1599,7 +1587,34 @@ def list_shop_data_crawl_tasks():
|
||||
'ORDER BY ranked.latest_file_updated_at DESC, ranked.result_id DESC',
|
||||
tuple(params + selected_shop_names),
|
||||
)
|
||||
for row in cur.fetchall():
|
||||
all_result_rows = cur.fetchall()
|
||||
|
||||
result_ids = [int(row['result_id']) for row in all_result_rows if row.get('result_id')]
|
||||
file_job_map = {}
|
||||
if result_ids:
|
||||
fj_placeholders = ','.join(['%s'] * len(result_ids))
|
||||
cur.execute(
|
||||
'SELECT fj.result_id, fj.id AS file_job_id, fj.status AS file_status, '
|
||||
'fj.error_message AS file_error '
|
||||
'FROM biz_task_file_job fj '
|
||||
f'INNER JOIN (SELECT result_id, MAX(id) AS max_id '
|
||||
f'FROM biz_task_file_job '
|
||||
f"WHERE module_type = 'SHOP_DATA_CRAWL' AND job_type = 'ASSEMBLE_RESULT' "
|
||||
f'AND result_id IN (' + fj_placeholders + ') '
|
||||
f'GROUP BY result_id) latest '
|
||||
'ON fj.id = latest.max_id',
|
||||
tuple(result_ids),
|
||||
)
|
||||
for fj_row in cur.fetchall():
|
||||
file_job_map[int(fj_row['result_id'])] = fj_row
|
||||
|
||||
for row in all_result_rows:
|
||||
rid = int(row.get('result_id') or 0)
|
||||
fj = file_job_map.get(rid)
|
||||
if fj:
|
||||
row['file_job_id'] = fj.get('file_job_id')
|
||||
row['file_status'] = fj.get('file_status')
|
||||
row['file_error'] = fj.get('file_error')
|
||||
shop_key = _shop_data_crawl_shop_key(row.get('shop_name'))
|
||||
result_rows_by_shop.setdefault(shop_key, []).append(row)
|
||||
finally:
|
||||
@@ -2997,7 +3012,7 @@ def export_dedupe_total_data():
|
||||
params=params,
|
||||
headers={'X-Internal-Token': _resolve_internal_token()},
|
||||
stream=True,
|
||||
timeout=60,
|
||||
timeout=(10, 1800),
|
||||
)
|
||||
except requests.RequestException:
|
||||
return jsonify({'success': False, 'error': 'backend-java 服务不可用'}), 502
|
||||
@@ -3362,6 +3377,7 @@ def _format_shop_manage_item(item):
|
||||
'group_name': item.get('groupName') or '',
|
||||
'shop_name': item.get('shopName') or '',
|
||||
'mall_name': item.get('mallName') or '',
|
||||
'zn_username': item.get('znUsername') or '',
|
||||
'account': item.get('account') or '',
|
||||
'password': item.get('passwordMasked') or '',
|
||||
'created_at': (item.get('createdAt') or '').replace('T', ' ')[:16],
|
||||
@@ -3493,7 +3509,11 @@ def get_shop_manage_credential(item_id):
|
||||
credential = credential_result.get('data') or {}
|
||||
if str(credential.get('id')) != str(item_id):
|
||||
return jsonify({'success': False, 'error': '店铺凭据不匹配'}), 409
|
||||
response = jsonify({'success': True, 'password': credential.get('password') or ''})
|
||||
response = jsonify({
|
||||
'success': True,
|
||||
'zn_username': credential.get('znUsername') or '',
|
||||
'password': credential.get('password') or '',
|
||||
})
|
||||
response.headers['Cache-Control'] = 'no-store'
|
||||
return response
|
||||
|
||||
@@ -3509,6 +3529,7 @@ def create_shop_manage():
|
||||
'groupId': data.get('group_id'),
|
||||
'shopName': (data.get('shop_name') or '').strip(),
|
||||
'mallName': (data.get('mall_name') or '').strip(),
|
||||
'znUsername': (data.get('zn_username') or '').strip(),
|
||||
'account': (data.get('account') or '').strip(),
|
||||
'password': (data.get('password') or '').strip(),
|
||||
'createdById': current_row.get('id') if current_row else None,
|
||||
@@ -3534,6 +3555,7 @@ def create_shop_manage():
|
||||
'group_name': item.get('groupName') or '',
|
||||
'shop_name': item.get('shopName') or '',
|
||||
'mall_name': item.get('mallName') or '',
|
||||
'zn_username': item.get('znUsername') or '',
|
||||
'account': item.get('account') or '',
|
||||
'password': item.get('password') or '',
|
||||
'created_at': (item.get('createdAt') or '').replace('T', ' ')[:16],
|
||||
@@ -3556,6 +3578,8 @@ def update_shop_manage(item_id):
|
||||
'account': (data.get('account') or '').strip(),
|
||||
'password': (data.get('password') or '').strip(),
|
||||
}
|
||||
if 'zn_username' in data:
|
||||
payload['znUsername'] = (data.get('zn_username') or '').strip()
|
||||
result, error_response, status = _proxy_backend_java(
|
||||
'PUT',
|
||||
f'/api/admin/shop-manages/{item_id}',
|
||||
@@ -3576,6 +3600,7 @@ def update_shop_manage(item_id):
|
||||
'group_name': item.get('groupName') or '',
|
||||
'shop_name': item.get('shopName') or '',
|
||||
'mall_name': item.get('mallName') or '',
|
||||
'zn_username': item.get('znUsername') or '',
|
||||
'account': item.get('account') or '',
|
||||
'password': item.get('password') or '',
|
||||
'created_at': (item.get('createdAt') or '').replace('T', ' ')[:16],
|
||||
|
||||
Reference in New Issue
Block a user