Last active
January 13, 2022 13:04
-
-
Save dmop/b740d0a4d253d05f8df2ef467f70ac68 to your computer and use it in GitHub Desktop.
Revisions
-
dmop revised this gist
Jan 13, 2022 . 1 changed file with 28 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ from datetime import datetime from typing import List from players.models import LoggiUser from proto.integration.api.label.v1.label_pb2 import LABEL_RESPONSE_TYPE_URL from logging import getLogger @@ -11,15 +13,11 @@ logger = getLogger(__name__) def create_new_redispatch( package_id: int, posting_card_number: str, distribution_center_id: int ) -> GetOrCreateRedispatchLabelResponse: client = RedispatchClient() @@ -38,16 +36,16 @@ def get_or_create_redispatch_label( confirmed_by = LoggiUser.objects.get(id=created_by_id) pkg.make_sure_is_confirmed(confirmed_at=datetime.now(), whom=confirmed_by.full_name, distribution_center_id=distribution_center_id) client.save_redispatch( redispatch_response=response.redispatch, package=pkg, is_emergency=False, distribution_center_id=distribution_center_id, created_by_id=created_by_id, application_name="xd_app" ) with in_read_only_database(): @@ -56,17 +54,21 @@ def get_or_create_redispatch_label( pkg.update_status(task) def force_create_new_redispatches( package_ids: List[int], posting_card_number: str, distribution_center_id: int ): pkgs_processed = 0 for pkg_id in package_ids: print(f"--------------------------------") print(f"iniciando -> {pkg_id}") create_new_redispatch(pkg_id, posting_card_number, distribution_center_id) pkgs_processed += 1 print(f"processado {pkgs_processed} -> {pkg_id}") print(f"--------------------------------") for pkg_id in package_ids: pkg = get_package_by_id(pkg_id) print(f'curl {pkg.redispatches.last().label_url} -o {pkg_id}.pdf') -
dmop revised this gist
Jan 13, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,10 @@ logger = getLogger(__name__) package_ids = [] posting_card_number = "000000000" is_emergency = False application_name = "xd_app" distribution_center_id = 1 def get_or_create_redispatch_label( -
dmop renamed this gist
Jan 13, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dmop renamed this gist
Jan 13, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dmop created this gist
Jan 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ from datetime import datetime from players.models import LoggiUser from proto.integration.api.label.v1.label_pb2 import LABEL_RESPONSE_TYPE_URL from logging import getLogger from base.db.router import in_eventual_consistence_database, in_read_only_database from proto.loggi_web.v1.api_pb2 import GetOrCreateRedispatchLabelResponse from wms.redispatch.redispatch_client import RedispatchClient from wms.redispatch.repository import ( get_package_by_id ) logger = getLogger(__name__) package_ids = [] posting_card_number = "0074837273" is_emergency = False application_name = "xd_app" distribution_center_id = 1029 def get_or_create_redispatch_label( package_id: int ) -> GetOrCreateRedispatchLabelResponse: client = RedispatchClient() pkg = get_package_by_id(package_id) created_by_id = pkg.redispatches.last().created_by_id response, label_error = client.get_or_create_redispatch_label( package=pkg, distribution_center_id=distribution_center_id, posting_card_number=posting_card_number, force_create=True, response_type=LABEL_RESPONSE_TYPE_URL, ) with in_eventual_consistence_database(): confirmed_by = LoggiUser.objects.get(id=created_by_id) pkg.make_sure_is_confirmed(confirmed_at=datetime.now(), whom=confirmed_by.full_name, distribution_center_id=distribution_center_id) client.save_redispatch( redispatch_response=response.redispatch, package=pkg, is_emergency=is_emergency, distribution_center_id=distribution_center_id, created_by_id=created_by_id, application_name=application_name ) with in_read_only_database(): task = pkg.tasks.latest('created') pkg.update_status(task) pkgs_processed = 0 for pkg_id in package_ids: print(f"--------------------------------") print(f"iniciando -> {pkg_id}") get_or_create_redispatch_label(pkg_id) pkgs_processed += 1 print(f"processado {pkgs_processed} -> {pkg_id}") print(f"--------------------------------") for pkg_id in package_ids: pkg = get_package_by_id(pkg_id) print(f'curl {pkg.redispatches.last().label_url} -o {pkg_id}.pdf')