forked from erp-dev/erp
feat: upload mdy stagging to qiniu beta
This commit is contained in:
@@ -222,6 +222,75 @@ class MDYPlateOrderStagingTiiaUploadFailure(ModelBase):
|
||||
return f'{self.run_date} {self.mdy_rowid}'
|
||||
|
||||
|
||||
class MDYPlateOrderStagingQiniuImageUploadAudit(ModelBase):
|
||||
"""明道云开版暂存"开版图"迁移到七牛的逐图审计记录。"""
|
||||
|
||||
class Status(models.TextChoices):
|
||||
PENDING = 'pending', '待处理'
|
||||
PROCESSING = 'processing', '处理中'
|
||||
SUCCESS = 'success', '成功'
|
||||
FAILED = 'failed', '失败'
|
||||
SKIPPED = 'skipped', '跳过'
|
||||
|
||||
class Source(models.TextChoices):
|
||||
RAW_PLATE_IMAGES = 'raw_plate_images', 'raw.开版图'
|
||||
|
||||
staging = models.ForeignKey(
|
||||
MDYPlateOrderStaging,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='qiniu_image_upload_audits',
|
||||
verbose_name='开版暂存记录',
|
||||
)
|
||||
mdy_rowid = models.CharField(max_length=64, db_index=True, verbose_name='明道云 RowID')
|
||||
source = models.CharField(
|
||||
max_length=50,
|
||||
choices=Source.choices,
|
||||
default=Source.RAW_PLATE_IMAGES,
|
||||
verbose_name='图片来源',
|
||||
)
|
||||
attachment_index = models.PositiveIntegerField(verbose_name='附件序号')
|
||||
source_field = models.CharField(max_length=64, blank=True, verbose_name='原始 URL 字段')
|
||||
original_url = models.URLField(max_length=2048, verbose_name='原始图片 URL')
|
||||
original_host = models.CharField(max_length=255, blank=True, db_index=True, verbose_name='原始图片域名')
|
||||
qiniu_key = models.CharField(max_length=500, blank=True, verbose_name='七牛对象 Key')
|
||||
qiniu_url = models.URLField(max_length=2048, blank=True, verbose_name='七牛图片 URL')
|
||||
status = models.CharField(
|
||||
max_length=20,
|
||||
choices=Status.choices,
|
||||
default=Status.PENDING,
|
||||
db_index=True,
|
||||
verbose_name='上传状态',
|
||||
)
|
||||
attempts = models.PositiveIntegerField(default=0, verbose_name='尝试次数')
|
||||
error = models.TextField(blank=True, verbose_name='错误信息')
|
||||
file_size = models.PositiveBigIntegerField(null=True, blank=True, verbose_name='文件大小')
|
||||
content_type = models.CharField(max_length=100, blank=True, verbose_name='Content-Type')
|
||||
raw_attachment = models.JSONField(default=dict, blank=True, verbose_name='原始附件快照')
|
||||
started_at = models.DateTimeField(null=True, blank=True, verbose_name='开始处理时间')
|
||||
uploaded_at = models.DateTimeField(null=True, blank=True, verbose_name='上传成功时间')
|
||||
last_attempt_at = models.DateTimeField(null=True, blank=True, verbose_name='最后尝试时间')
|
||||
|
||||
class Meta:
|
||||
db_table = 'api_mdy_plate_order_staging_qiniu_image_upload_audit'
|
||||
verbose_name = '开版暂存开版图七牛上传审计'
|
||||
verbose_name_plural = '开版暂存开版图七牛上传审计'
|
||||
ordering = ['-created_at']
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=['staging', 'source', 'attachment_index', 'source_field', 'original_url'],
|
||||
name='uniq_mdy_qiniu_staging_src_idx_url',
|
||||
)
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=['status', 'id'], name='mdy_qiniu_status_id_idx'),
|
||||
models.Index(fields=['original_url'], name='mdy_qiniu_orig_url_idx'),
|
||||
models.Index(fields=['staging', 'source'], name='mdy_qiniu_staging_src_idx'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.mdy_rowid}#{self.attachment_index} {self.status}'
|
||||
|
||||
|
||||
class PrintingExternalSyncFailure(ModelBase):
|
||||
"""
|
||||
外部印染 records 同步失败记录。
|
||||
|
||||
Reference in New Issue
Block a user