|
|
|
@ -75,99 +75,12 @@ def report(request): |
|
|
|
last_real_data = AiShow.objects.filter(Q(is_ai_show=False) & |
|
|
|
last_real_data = AiShow.objects.filter(Q(is_ai_show=False) & |
|
|
|
Q(zz_code=zz_code) & |
|
|
|
Q(zz_code=zz_code) & |
|
|
|
Q(show_date=show_date)).order_by('-id').first() |
|
|
|
Q(show_date=show_date)).order_by('-id').first() |
|
|
|
ai_dict = scv_to_obj(last_ai_data.show) |
|
|
|
ai_dict = csv_to_obj(last_ai_data.show) |
|
|
|
real_dict = scv_to_obj(last_real_data.show) |
|
|
|
real_dict = csv_to_obj(last_real_data.show) |
|
|
|
print(ai_dict, real_dict) |
|
|
|
temp_dict = csv_to_obj(last_ai_data.template) |
|
|
|
# 获取影厅数据 |
|
|
|
print(ai_dict, real_dict, temp_dict) |
|
|
|
hall = CinemaHall.objects.filter(cinema_code=zz_code).all() |
|
|
|
output_list_ai_real, output_csv_ai_real = format_show_data(zz_code, show_date, ai_dict, real_dict) |
|
|
|
# 准备数据 |
|
|
|
output_list_ai_temp, output_csv_ai_temp = format_show_data(zz_code, show_date, ai_dict, temp_dict) |
|
|
|
data = dict() |
|
|
|
|
|
|
|
for h in hall: |
|
|
|
|
|
|
|
hall_dict = {'hall_name': h.hall_name, 'hall_id': h.hall_id, 'ai': [], 'real': []} |
|
|
|
|
|
|
|
for ai in ai_dict: |
|
|
|
|
|
|
|
if ai['影厅id'] == str(h.hall_id): |
|
|
|
|
|
|
|
hall_dict['ai'].append({ |
|
|
|
|
|
|
|
'movie_name': ai['影片别名'], |
|
|
|
|
|
|
|
'movie_id': ai['本地影片id'], |
|
|
|
|
|
|
|
'language': ai['语言'], |
|
|
|
|
|
|
|
'show_date': ai['放映日期'], |
|
|
|
|
|
|
|
'start': ai['开始时间'], |
|
|
|
|
|
|
|
'end': ai['结束时间'], |
|
|
|
|
|
|
|
'length': ai['片长'], |
|
|
|
|
|
|
|
'duration': ai['场间'] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
for real in real_dict: |
|
|
|
|
|
|
|
if real['影厅id'] == str(h.hall_id): |
|
|
|
|
|
|
|
hall_dict['real'].append({ |
|
|
|
|
|
|
|
'movie_name': real['影片别名'], |
|
|
|
|
|
|
|
'movie_id': real['本地影片id'], |
|
|
|
|
|
|
|
'language': real['语言'], |
|
|
|
|
|
|
|
'show_date': real['放映日期'], |
|
|
|
|
|
|
|
'start': real['开始时间'], |
|
|
|
|
|
|
|
'end': real['结束时间'], |
|
|
|
|
|
|
|
'length': real['片长'], |
|
|
|
|
|
|
|
'duration': real['场间'] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
data[h.hall_id] = hall_dict |
|
|
|
|
|
|
|
# 格式化输出 |
|
|
|
|
|
|
|
output_list = [] |
|
|
|
|
|
|
|
output_csv = [ |
|
|
|
|
|
|
|
['影厅别名', '影片别名', '语言', '开始时间', '结束时间', '片长', '场间', '', '影厅别名', '影片别名', '语言', |
|
|
|
|
|
|
|
'开始时间', '结束时间', '片长', '场间']] |
|
|
|
|
|
|
|
for v in data.values(): |
|
|
|
|
|
|
|
if len(v['ai']) == 0 and len(v['real']) == 0: |
|
|
|
|
|
|
|
output_list.append([v['hall_name'], show_date, '', '', '', '', '', '', '', '', '', '', '', '', '', '']) |
|
|
|
|
|
|
|
output_csv.append([v['hall_name'], '', '', '', '', '', '', '', v['hall_name'], '', '', '', '', '', '']) |
|
|
|
|
|
|
|
if len(v['ai']) >= len(v['real']): |
|
|
|
|
|
|
|
for i in range(len(v['ai'])): |
|
|
|
|
|
|
|
if i < len(v['real']): |
|
|
|
|
|
|
|
a = v['ai'][i] |
|
|
|
|
|
|
|
r = v['real'][i] |
|
|
|
|
|
|
|
output_list.append( |
|
|
|
|
|
|
|
[v['hall_name'], show_date, a['movie_name'], a['movie_id'], a['language'], a['start'], |
|
|
|
|
|
|
|
a['end'], a['length'], a['duration'], r['movie_name'], r['movie_id'], r['language'], |
|
|
|
|
|
|
|
r['start'], r['end'], r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
output_csv.append( |
|
|
|
|
|
|
|
[v['hall_name'], a['movie_name'], a['language'], a['start'], a['end'], a['length'], |
|
|
|
|
|
|
|
a['duration'], '', v['hall_name'], r['movie_name'], r['language'], r['start'], r['end'], |
|
|
|
|
|
|
|
r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
a = v['ai'][i] |
|
|
|
|
|
|
|
output_list.append( |
|
|
|
|
|
|
|
[v['hall_name'], show_date, a['movie_name'], a['movie_id'], a['language'], a['start'], |
|
|
|
|
|
|
|
a['end'], a['length'], a['duration'], '', '', '', '', '', '', ''] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
output_csv.append( |
|
|
|
|
|
|
|
[v['hall_name'], a['movie_name'], a['language'], a['start'], a['end'], a['length'], |
|
|
|
|
|
|
|
a['duration'], '', '', '', '', '', '', '', ''] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
for i in range(len(v['real'])): |
|
|
|
|
|
|
|
if i < len(v['ai']): |
|
|
|
|
|
|
|
a = v['ai'][i] |
|
|
|
|
|
|
|
r = v['real'][i] |
|
|
|
|
|
|
|
output_list.append( |
|
|
|
|
|
|
|
[v['hall_name'], show_date, a['movie_name'], a['movie_id'], a['language'], a['start'], |
|
|
|
|
|
|
|
a['end'], a['length'], a['duration'], r['movie_name'], r['movie_id'], r['language'], |
|
|
|
|
|
|
|
r['start'], r['end'], r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
output_csv.append( |
|
|
|
|
|
|
|
[v['hall_name'], a['movie_name'], a['language'], a['start'], a['end'], a['length'], |
|
|
|
|
|
|
|
a['duration'], '', v['hall_name'], r['movie_name'], r['language'], r['start'], r['end'], |
|
|
|
|
|
|
|
r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
r = v['real'][i] |
|
|
|
|
|
|
|
output_list.append( |
|
|
|
|
|
|
|
[v['hall_name'], show_date, '', '', '', '', '', '', '', r['movie_name'], r['movie_id'], |
|
|
|
|
|
|
|
r['language'], r['start'], r['end'], r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
output_csv.append( |
|
|
|
|
|
|
|
[v['hall_name'], '', '', '', '', '', '', '', v['hall_name'], r['movie_name'], r['language'], |
|
|
|
|
|
|
|
r['start'], r['end'], r['length'], r['duration']] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
# 返回 |
|
|
|
# 返回 |
|
|
|
result_dict = { |
|
|
|
result_dict = { |
|
|
|
'status': 'success', |
|
|
|
'status': 'success', |
|
|
|
@ -179,8 +92,10 @@ def report(request): |
|
|
|
'ai_sales': last_ai_data.sales, |
|
|
|
'ai_sales': last_ai_data.sales, |
|
|
|
'take_times': last_ai_data.take_times, |
|
|
|
'take_times': last_ai_data.take_times, |
|
|
|
'take_tokens': json.loads(last_ai_data.take_tokens)['total_tokens'], |
|
|
|
'take_tokens': json.loads(last_ai_data.take_tokens)['total_tokens'], |
|
|
|
'csv': list_to_csv(output_csv), |
|
|
|
'csv': list_to_csv(output_csv_ai_real), |
|
|
|
'objects': output_list, |
|
|
|
'real_obj': output_list_ai_real, |
|
|
|
|
|
|
|
'template_obj': output_list_ai_temp, |
|
|
|
|
|
|
|
'template_date':last_ai_data.temp_date, |
|
|
|
'prompt': last_ai_data.prompt, |
|
|
|
'prompt': last_ai_data.prompt, |
|
|
|
'result': last_ai_data.result, |
|
|
|
'result': last_ai_data.result, |
|
|
|
} |
|
|
|
} |
|
|
|
|