forked from erp-dev/erp
feat: added mdy stagging upload to tiia, and change outgoing_date to datetime type
This commit is contained in:
@@ -105,6 +105,58 @@
|
||||
|
||||
---
|
||||
|
||||
## 四点五、MDY 开版暂存(MDYPlateOrderStaging)图片上传到图库(CreateImage)
|
||||
|
||||
### 4.5.1 目标数据源与字段(明道云暂存)
|
||||
|
||||
数据源:
|
||||
|
||||
- 模型:`api_v1.models.MDYPlateOrderStaging`
|
||||
- 图片字段:`raw["62d52f4b8d2972284492dd27"]`(明道云开版主表字段“开版图”,Attachment)
|
||||
|
||||
单个附件项的 URL 取值策略(当前约定):
|
||||
|
||||
- **优先**:`original_file_full_path`(你确认的主用字段)
|
||||
- **候补**:`DownloadUrl`
|
||||
- 不再使用:`preview_url`(通常带 token/过期参数,不适合作为长期回显 URL)
|
||||
|
||||
### 4.5.2 Service(上传单条暂存记录)
|
||||
|
||||
位置:`api_v1/mdy_plate_order_staging_tiia_upload.py`
|
||||
|
||||
- `upload_mdy_plate_order_staging_plate_images_to_tencent_tiia(staging, rate_limiter=None, dry_run=False)`
|
||||
- `EntityId`:使用 `staging.mdy_rowid`
|
||||
- 每张图调用:`api_v1.utils.tencentcloud_tiia.upload_image_url_to_tencent_tiia(image_url, entity_id, custom_content=image_url)`
|
||||
- 限流:`SimpleRateLimiter(qps=settings.TENCENTCLOUD_TIIA_QPS)`(默认 10)
|
||||
- 单张失败不影响其它图片,返回 `successes/failures` 明细
|
||||
|
||||
### 4.5.3 定时任务(Celery Beat)
|
||||
|
||||
位置:`api_v1/tasks.py`
|
||||
|
||||
- task:`upload_mdy_plate_order_staging_images_to_tencent_tiia(batch_size=200, dry_run=False)`
|
||||
- **游标**:`api_v1.models.DataSync`(`table_name=mdy_plate_order_staging_tiia_upload`),用 `last_rowid` 存储 staging 表自增 `id`
|
||||
- **失败落库**:`api_v1.models.MDYPlateOrderStagingTiiaUploadFailure`(同日同 rowid 去重,attempts 累加)
|
||||
|
||||
Beat 配置位置:`flower/settings.py`
|
||||
|
||||
- `CELERY_BEAT_SCHEDULE['daily_mdy_plate_order_staging_tiia_image_upload']`
|
||||
- 默认:**03:20** 运行
|
||||
- kwargs 默认值:
|
||||
- `batch_size=500`
|
||||
- `dry_run=False`
|
||||
|
||||
手动触发(示例):
|
||||
|
||||
- `uv run python manage.py shell -c "from api_v1.tasks import upload_mdy_plate_order_staging_images_to_tencent_tiia; r=upload_mdy_plate_order_staging_images_to_tencent_tiia.delay(batch_size=50, dry_run=True); print(r.id)"`
|
||||
|
||||
### 4.5.4 迁移与 Admin
|
||||
|
||||
- 迁移:`api_v1/migrations/0010_mdy_plate_order_staging_tiia_upload_failure.py`
|
||||
- Admin:`api_v1/admin.py` 已注册 `MDYPlateOrderStagingTiiaUploadFailure`
|
||||
|
||||
---
|
||||
|
||||
## 五、手动跑批(推荐:management command)
|
||||
|
||||
位置:`printing/management/commands/tiia_upload_plate_order_images.py`
|
||||
|
||||
Reference in New Issue
Block a user