forked from erp-dev/erp
feat: batch update for plate order
This commit is contained in:
0
api_v1/management/__init__.py
Normal file
0
api_v1/management/__init__.py
Normal file
0
api_v1/management/commands/__init__.py
Normal file
0
api_v1/management/commands/__init__.py
Normal file
35
api_v1/management/commands/sync_mdy_plate_orders.py
Normal file
35
api_v1/management/commands/sync_mdy_plate_orders.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from api_v1.mdy_plate_order_sync import sync_mdy_plate_orders_to_staging
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = '同步明道云开版数据表到暂存表(可选抓取跨表关联数据)'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--page-size', type=int, default=100)
|
||||
parser.add_argument('--max-pages', type=int, default=None)
|
||||
parser.add_argument('--max-records', type=int, default=None)
|
||||
|
||||
# 默认抓取关联表数据;如需关闭可显式传 --without-related
|
||||
parser.add_argument('--with-related', dest='with_related', action='store_true', default=True)
|
||||
parser.add_argument('--without-related', dest='with_related', action='store_false')
|
||||
|
||||
parser.add_argument('--max-related-per-type', type=int, default=5)
|
||||
parser.add_argument(
|
||||
'--request-interval-seconds',
|
||||
type=float,
|
||||
default=0.02,
|
||||
help='每次明道云请求之间的最小间隔(用于限流,50qps 建议 >= 0.02)',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
payload = sync_mdy_plate_orders_to_staging(
|
||||
page_size=options['page_size'],
|
||||
max_pages=options['max_pages'],
|
||||
max_records=options['max_records'],
|
||||
with_related=options['with_related'],
|
||||
max_related_per_type=options['max_related_per_type'],
|
||||
request_interval_seconds=options['request_interval_seconds'],
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(str(payload)))
|
||||
Reference in New Issue
Block a user