update excel

This commit is contained in:
2026-01-27 12:53:09 +03:30
parent 5085e375af
commit 3b4ef2c1e1

View File

@@ -2631,7 +2631,6 @@ def all_products_transport_excel(request):
) )
transports = transports.iterator(chunk_size=2000) transports = transports.iterator(chunk_size=2000)
# serializer = AllProductsTransportCustomSerializer(transports.order_by('-date', '-create_date'), many=True).data
excel_options = [ excel_options = [
'ردیف', 'ردیف',
@@ -2679,19 +2678,7 @@ def all_products_transport_excel(request):
if product_type and product_type != 'undefined': if product_type and product_type != 'undefined':
excel_description(worksheet, 'A1', f'محصول {product_type}', row2='C1') excel_description(worksheet, 'A1', f'محصول {product_type}', row2='C1')
# header_list2 = [
# 'تعداد کشتارگاه ها',
# 'تعداد بار',
# 'حجم بار',
# 'تعداد بار داخل استان',
# 'حجم بار داخل استان',
# 'درصد بار داخل استان',
# 'تعداد بار خارج استان',
# 'حجم بار خارج استان',
# 'درصد بار خارج استان',
#
# ]
# create_header(worksheet, header_list2, 5, 2, height=20.8, border_style='thin')
create_header_freez(worksheet, excel_options, 1, 6, 7, 20) create_header_freez(worksheet, excel_options, 1, 6, 7, 20)
l = 5 l = 5
m = 1 m = 1
@@ -2703,81 +2690,32 @@ def all_products_transport_excel(request):
list1 = [ list1 = [
m, m,
row[0], # tracking row[0],
row[1], # product row[1],
row[2] or '-', # items row[2] or '-',
quantity, quantity,
row[4], # unit row[4],
str(shamsi_date(convert_str_to_date(row[5]), in_value=True)) if row[5] else '-', str(shamsi_date(convert_str_to_date(row[5]), in_value=True)) if row[5] else '-',
row[6], # destination row[6],
row[7], # jihadi_destination row[7],
row[8], # destination_province row[8],
row[9], # destination_city row[9],
row[10], # origin row[10],
row[11], # jihadi_origin row[11],
row[12], # origin_province row[12],
row[13], # origin_city row[13],
"داخل استان" if row[12] == row[8] else "خارج استان", "داخل استان" if row[12] == row[8] else "خارج استان",
row[14] or '-', # destination_prev row[14] or '-',
row[15] or '-', # destination_changed row[15] or '-',
row[16], # car_tracking_code row[16],
str(shamsi_date(convert_str_to_date(row[17]), in_value=True)) if row[17] else '-', str(shamsi_date(convert_str_to_date(row[17]), in_value=True)) if row[17] else '-',
row[18] or '-', # unloading row[18] or '-',
] ]
m += 1 m += 1
l += 1 l += 1
create_value(worksheet, list1, l + 1, 1) create_value(worksheet, list1, l + 1, 1)
# total_quantity = sum(
# item['quantity'] for item in serializer)
# aggregation1_bars = all_bars.aggregate(
# total=Sum('GoodAmount'),
# input_total=Sum('GoodAmount', filter=Q(Out=False)),
# output_total=Sum('GoodAmount', filter=Q(Out=True)),
# input_count=Count('id', filter=Q(Out=False)),
# output_count=Count('id', filter=Q(Out=True)),
# total_count=Count('id')
# )
#
# aggregation1_all_products = all_products_transport.aggregate(
# total=Sum('quantity'),
# input_total=Sum('quantity', filter=Q(out=False)),
# output_total=Sum('quantity', filter=Q(out=True)),
# input_count=Count('id', filter=Q(out=False)),
# output_count=Count('id', filter=Q(out=True)),
# total_count=Count('id')
# )
#
# total_count = (aggregation1_bars['total_count'] or 0) + (aggregation1_all_products['total_count'] or 0)
# total_bars_quantity = (aggregation1_bars['total'] or 0) + (aggregation1_all_products['total'] or 0)
# total_input_bars_quantity = (aggregation1_bars['input_total'] or 0) + (
# aggregation1_all_products['input_total'] or 0)
# total_output_bars_quantity = (aggregation1_bars['output_total'] or 0) + (
# aggregation1_all_products['output_total'] or 0)
# input_bars_count = (aggregation1_bars['input_count'] or 0) + (aggregation1_all_products['input_count'] or 0)
# output_bars_count = (aggregation1_bars['output_count'] or 0) + (aggregation1_all_products['output_count'] or 0)
#
# if total_count > 0:
# total_input_bars_percent = round((input_bars_count / total_count) * 100, 1)
# total_output_bars_percent = round((output_bars_count / total_count) * 100, 1)
# else:
# total_input_bars_percent = 0
# total_output_bars_percent = 0
# value_header_list2 = [
# kill_houses.count(),
# total_count,
# total_bars_quantity,
# input_bars_count,
# total_input_bars_quantity,
# total_input_bars_percent,
# output_bars_count,
# total_output_bars_quantity,
# total_output_bars_percent,
#
# ]
#
# create_value(worksheet, value_header_list2, 3, 5, border_style='thin')
list2 = [ list2 = [
'مجموع==>', 'مجموع==>',
@@ -2801,14 +2739,7 @@ def all_products_transport_excel(request):
'', '',
'', '',
'', '',
# total_count,
# total_bars_quantity,
# input_bars_count,
# total_input_bars_quantity,
# total_input_bars_percent,
# output_bars_count,
# total_output_bars_quantity,
# total_output_bars_percent,
] ]
create_value(worksheet, list2, l + 3, 1, color='green') create_value(worksheet, list2, l + 3, 1, color='green')