增加打印信息

main
rogersun 2 weeks ago
parent 7cfed22716
commit bab13b1dec
  1. 62
      ai/utils/show_process.py
  2. 6
      ai/views.py

@ -21,35 +21,35 @@ def show_main_process():
show_ai = ShowAI(cinema, show_date) show_ai = ShowAI(cinema, show_date)
prompt = show_ai.general_prompt() prompt = show_ai.general_prompt()
start = datetime.datetime.now() start = datetime.datetime.now()
# result, message, tokens = show_ai.get_show_result_ai() result, message, tokens = show_ai.get_show_result_ai()
# end = datetime.datetime.now() end = datetime.datetime.now()
# print('prompt:', prompt) print('prompt:', prompt)
# print('result:', result) print('result:', result)
# print('message:', message) print('message:', message)
# print('tokens:', tokens) print('tokens:', tokens)
# # 获取排片数据 # 获取排片数据
# _show = next((s for s in result.split('------') if s.startswith('\n影厅别名,影厅id')), '') _show = next((s for s in result.split('------') if s.startswith('\n影厅别名,影厅id')), '')
# _show = _show.strip() _show = _show.strip()
# print('_show:', _show) print('_show:', _show)
# # 获取销售额 # 获取销售额
# _sales = next((s for s in result.split('\n') if re.search('预估销售数据', s)), '') _sales = next((s for s in result.split('\n') if re.search('预估销售数据', s)), '')
# _sales = str(re.findall(r'\d+\.?\d*', _sales)[0]) _sales = str(re.findall(r'\d+\.?\d*', _sales)[0])
# print('_sales:', _sales) print('_sales:', _sales)
# # 处理返回结果 # 处理返回结果
# try: try:
# AiShow.objects.create( AiShow.objects.create(
# cinema=cinema.name, cinema=cinema.name,
# zz_code=cinema.zz_code, zz_code=cinema.zz_code,
# show_date=show_date, show_date=show_date,
# is_ai_show=True, is_ai_show=True,
# show=_show, show=_show,
# sales=_sales, sales=_sales,
# prompt=prompt, prompt=prompt,
# result=result, result=result,
# message=message, message=message,
# take_times=int((end - start).seconds), take_times=int((end - start).seconds),
# take_tokens=tokens take_tokens=tokens
# ) )
# except Exception as e: except Exception as e:
# print(e) print(e)
return True return True

@ -34,10 +34,14 @@ def get_cinema_show_result(request):
end = datetime.datetime.strftime( end = datetime.datetime.strftime(
datetime.datetime.strptime(show_date, '%Y-%m-%d') + datetime.timedelta(hours=29, minutes=59, seconds=59), datetime.datetime.strptime(show_date, '%Y-%m-%d') + datetime.timedelta(hours=29, minutes=59, seconds=59),
'%Y-%m-%d %H:%M:%S') '%Y-%m-%d %H:%M:%S')
show = ''
income = ''
if cinema: if cinema:
print(cinema)
data = GetData(json.loads(cinema.db_config)) data = GetData(json.loads(cinema.db_config))
show = data.get_show_data(start, end) show = data.get_show_data(start, end)
income = data.get_total_income(start, end) income = data.get_total_income(start, end)
print(show, income)
try: try:
AiShow.objects.create( AiShow.objects.create(
cinema=cinema.name, cinema=cinema.name,
@ -57,6 +61,8 @@ def get_cinema_show_result(request):
result_dict = { result_dict = {
'status': 'success', 'status': 'success',
'message': '生成成功', 'message': '生成成功',
'show': show,
'income': income,
} }
return JsonResponse(result_dict, json_dumps_params={'ensure_ascii': False}) return JsonResponse(result_dict, json_dumps_params={'ensure_ascii': False})

Loading…
Cancel
Save