This commit is contained in:
2026-01-28 16:18:10 +03:30
parent df6f21f74b
commit 06594f13d2
3 changed files with 275 additions and 3 deletions

View File

@@ -5243,6 +5243,27 @@ def delete_kill_req_cron():
market_poultry_request_remain_quantity(kill_request.poultry_request)
def delete_kill_req_manual(request):
current_time = datetime.datetime.now()
kill_requests = KillRequest.objects.filter(Q(market_final_accept=True, market_code_status=True,
input_market_code__isnull=True) | Q(market_final_accept=False),
trash=False,
market=True,
market_state='pending',
market_expire_date_time__lt=current_time
).select_related('poultry_request')
for kill_request in kill_requests:
kill_request.trash = True
kill_request.market_state_message = {
"fullname": "سیستمی",
"mobile": "سیستمی",
"date": str(datetime.datetime.now())
}
kill_request.market_state = 'deleted'
kill_request.save()
market_poultry_request_remain_quantity(kill_request.poultry_request)
return HttpResponse('ok')
def delete_steward_allocation_cron():
current_time = datetime.datetime.now().date()
# allow=AllowRegisterCodeForStewardAllocation.objects.filter(trash=False,active=True).first()
@@ -9336,4 +9357,200 @@ def poultry_science_for_bazresi(request):
)
serializer = PoultryScienceReportSerializer(query, many=True)
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.data, status=status.HTTP_200_OK)
def archive_kill_house_remain_limitation_weight_manual(request):
production_date = (datetime.datetime.now() - datetime.timedelta(days=3)).date()
archive_date = (datetime.datetime.now() - datetime.timedelta(days=3))
kill_houses = KillHouse.objects.filter(trash=False, out_province=False)
for kill_house in kill_houses:
kill_house_requests = KillHouseRequest.objects.filter(input_warehouse=kill_house,
province_request__poultry_request__free_sale_in_province=False,
kill_request__recive_date__date=production_date,
ware_house_confirmation=True, trash=False,
calculate_status=True, warehouse=True)
kill_house_allocations = StewardAllocation.objects.filter(
kill_house=kill_house, trash=False, calculate_status=True, warehouse=True, system_registration_code=True,
receiver_state__in=('pending', 'accepted'), production_date__date=production_date, quota='governmental')
kill_house_free_sale_bars = KillHouseFreeSaleBarInformation.objects.filter(kill_house=kill_house,
quota='governmental',
production_date__date=production_date,
trash=False,
calculate_status=True,
warehouse=True)
segmentations = PosSegmentation.objects.filter(kill_house=kill_house, production_date__date=production_date,
trash=False, warehouse=True,
quota='governmental')
kill_house_requests_weight = kill_house_requests.aggregate(total=Sum('ware_house_accepted_real_weight'))[
'total'] or 0
kill_house_allocations_weight = \
kill_house_allocations.aggregate(total=Sum('real_weight_of_carcasses'))['total'] or 0
kill_house_free_sale_bars_weight = kill_house_free_sale_bars.aggregate(total=Sum('real_weight_of_carcasses'))[
'total'] or 0
segmentation_weight = \
segmentations.aggregate(total=Sum('weight'))[
'total'] or 0
archives = WarehouseArchive.objects.filter(kill_house=kill_house, date__date=production_date,
quota='governmental',
trash=False)
archives_governmental_weight = \
archives.aggregate(total=Sum('weight'))[
'total'] or 0
total_input = kill_house_requests_weight
total_output = kill_house_allocations_weight + kill_house_free_sale_bars_weight + segmentation_weight + archives_governmental_weight
total_remain = total_input - total_output
if total_remain > 0:
if kill_house.ware_house_remaining_weight_archive_percent > 0:
percent_limitation_weight = total_input * (kill_house.ware_house_remaining_weight_archive_percent / 100)
if percent_limitation_weight >= total_remain:
archive = WarehouseArchive(
kill_house=kill_house,
date=archive_date,
quota='governmental',
weight=total_remain,
registerer='سیستم',
registerer_mobile='سیستم',
registerer_role='سیستم',
description='مانده کمتر از استاندارد تعیین شده',
)
archive.save()
kill_house_archive_warehousing(archive.kill_house)
return HttpResponse('ok')
def delete_steward_allocation_manual(request):
current_time = datetime.datetime.now().date()
# allow=AllowRegisterCodeForStewardAllocation.objects.filter(trash=False,active=True).first()
# if allow:
steward_allocation = StewardAllocation.objects.filter(trash=False,
date__date=current_time,
receiver_state='pending',
active_expire_date_time=True,
logged_registration_code__isnull=True,
kill_house__isnull=False,
return_trash=False).order_by('id')
for allocation in steward_allocation:
product = allocation.product
seller_type = allocation.seller_type
to_cold_house = allocation.to_cold_house
other_cold_house = allocation.other_cold_house if allocation.other_cold_house else None
allocation.trash = True
allocation.save()
if seller_type == 'KillHouse':
kill_house_allocations_product_warehousing(product)
if to_cold_house and to_cold_house.kill_house == product.kill_house:
kill_house_cold_house_allocations(to_cold_house)
elif seller_type == 'ColdHouse':
cold_house_warehousing(to_cold_house)
if other_cold_house:
cold_house_warehousing(other_cold_house)
else:
guild_steward_allocations_product_warehousing(product)
return HttpResponse('ok')
def delete_sale_bar_manual(request):
steward_sale_bar = StewardFreeSaleBarInformation.objects.filter(trash=False, logged_registration_code__isnull=True,
system_registration_code=True,
active_expire_date_time=True,
registration_code__isnull=False)
for free_sale_bar in steward_sale_bar:
free_sale_bar.trash = True
free_sale_bar.save()
guild_steward_free_sale_product_warehousing(free_sale_bar.product)
kill_house_sale_bar = KillHouseFreeSaleBarInformation.objects.filter(trash=False,
logged_registration_code__isnull=True,
system_registration_code=True,
active_expire_date_time=True,
registration_code__isnull=False)
for free_sale_bar_kill_house in kill_house_sale_bar:
product = free_sale_bar_kill_house.product
free_sale_bar_kill_house.trash = True
free_sale_bar_kill_house.save()
kill_house_free_sale_product_warehousing(product)
def send_credit_sahandsms_sms_manual(request):
filters = {}
if base_url_for_sms_report == 'ha':
filters['username'] = 'hamedan'
elif base_url_for_sms_report == 'ku':
filters['username'] = 'kurdistan'
elif base_url_for_sms_report == 'ma':
filters['username__in'] = ['markazi', 'senfmarkazi']
managements = ManagementSendSms.objects.filter(**filters) \
.values('username') \
.annotate(min_id=Min('id')) \
.values_list('min_id', flat=True)
managements = ManagementSendSms.objects.filter(id__in=managements)
for management in managements:
r = requests.get(
f"http://webservice.sahandsms.com/newsmswebservice.asmx/GetUserCredit?username={management.username}"
f"&password={management.password}")
url = f'https://eitaayar.ir/api/{token}/sendMessage'
date = datetime.datetime.now().date()
if base_url_for_sms_report == 'ma':
province = 'مرکزی'
elif base_url_for_sms_report == 'ha':
province = 'همدان'
elif base_url_for_sms_report == 'ku':
province = 'کردستان'
elif base_url_for_sms_report == 'bu':
province = 'بوشهر'
else:
province = 'تست'
date_shamsi = shamsi_date(date).replace('-', '_')
base_message = '🗓📢❗ سامانه رصدیار، زنجیره تامین،تولید و توزیع مرغ گوشتی📢❗\n'
base_message += f' #گزارش_مانده_حساب_پنل_پیامکی #{date_shamsi}\n'
base_message += f' #استان_{province}\n\n'
base_message += f'\n'
messages = []
current_message = base_message
root = ET.fromstring(r.content)
credit_amount = int(root.text)
amount = "{:,}".format(credit_amount)
new_message_part = "🔸 نام کاربری پنل : {0} \n".format(management.username)
new_message_part += "🔸 مانده حساب پنل : {0} ریال \n".format(amount)
# new_message_part = "🔸 نام کاربری پنل {0}: {1} ریال \n".format(management.username, amount)
if credit_amount < 1000000:
new_message_part += "‼توجه: لطفا برای شارژ پنل پیامکی خود اقدام فرمایید‼"
new_message_part += '\n\n'
if len(current_message) + len(new_message_part) > 4000:
messages.append(current_message)
current_message = base_message
current_message += new_message_part
if current_message and current_message != base_message:
messages.append(current_message)
for message in messages:
data = {
'chat_id': chat_id_mali,
'text': message,
}
response = requests.post(url, data=data, verify=False)
return HttpResponse('ok')