forked from erp-dev/erp
feat: fix setting
This commit is contained in:
@@ -5,6 +5,7 @@ from api_v1.models import (
|
|||||||
DataSync,
|
DataSync,
|
||||||
MDYPlateOrderStaging,
|
MDYPlateOrderStaging,
|
||||||
MDYPlateOrderStagingTiiaUploadFailure,
|
MDYPlateOrderStagingTiiaUploadFailure,
|
||||||
|
PrintingExternalSyncFailure,
|
||||||
ApiAuditLog,
|
ApiAuditLog,
|
||||||
)
|
)
|
||||||
from .tasks import backup_database
|
from .tasks import backup_database
|
||||||
@@ -67,6 +68,39 @@ class MDYPlateOrderStagingTiiaUploadFailureAdmin(admin.ModelAdmin):
|
|||||||
ordering = ['-created_at']
|
ordering = ['-created_at']
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(PrintingExternalSyncFailure)
|
||||||
|
class PrintingExternalSyncFailureAdmin(admin.ModelAdmin):
|
||||||
|
list_display = [
|
||||||
|
'id',
|
||||||
|
'run_date',
|
||||||
|
'external_record_id',
|
||||||
|
'external_order_id',
|
||||||
|
'product_name',
|
||||||
|
'attempts',
|
||||||
|
'last_attempt_at',
|
||||||
|
'created_at',
|
||||||
|
]
|
||||||
|
list_filter = ['run_date', 'created_at']
|
||||||
|
search_fields = ['external_record_id', 'external_order_id', 'product_name', 'error']
|
||||||
|
readonly_fields = [
|
||||||
|
'run_date',
|
||||||
|
'external_record_id',
|
||||||
|
'external_order_id',
|
||||||
|
'product_name',
|
||||||
|
'error',
|
||||||
|
'raw',
|
||||||
|
'attempts',
|
||||||
|
'last_attempt_at',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
]
|
||||||
|
date_hierarchy = 'created_at'
|
||||||
|
ordering = ['-created_at']
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@admin.register(ApiAuditLog)
|
@admin.register(ApiAuditLog)
|
||||||
class ApiAuditLogAdmin(admin.ModelAdmin):
|
class ApiAuditLogAdmin(admin.ModelAdmin):
|
||||||
"""API审计日志管理"""
|
"""API审计日志管理"""
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ TENCENTCLOUD_TIIA_QPS = env.int('TENCENTCLOUD_TIIA_QPS', default=10) # Tencent
|
|||||||
WECOM_WEBHOOK_BASE_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
|
WECOM_WEBHOOK_BASE_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
|
||||||
WECOM_WEBHOOK_KEY = env('WECOM_WEBHOOK_KEY', default='')
|
WECOM_WEBHOOK_KEY = env('WECOM_WEBHOOK_KEY', default='')
|
||||||
SPEAK_ENDPOINT = env('SPEAK_ENDPOINT', default='http://8.148.215.233:9004/speak')
|
SPEAK_ENDPOINT = env('SPEAK_ENDPOINT', default='http://8.148.215.233:9004/speak')
|
||||||
|
PRINTING_ORDER_CREATED_SPEECH_ENABLED = False
|
||||||
|
|
||||||
|
|
||||||
# CORS 配置
|
# CORS 配置
|
||||||
|
|||||||
@@ -326,15 +326,13 @@ def on_printing_order_created(sender, **kwargs):
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("[printing.handlers] 发送 WeCom webhook 失败(已忽略,不影响主流程)")
|
logger.exception("[printing.handlers] 发送 WeCom webhook 失败(已忽略,不影响主流程)")
|
||||||
|
|
||||||
# Just for testing
|
if getattr(settings, "PRINTING_ORDER_CREATED_SPEECH_ENABLED", False):
|
||||||
# ==============================================================
|
|
||||||
try:
|
try:
|
||||||
from flower.utils import play_speech
|
from flower.utils import play_speech
|
||||||
|
|
||||||
play_speech(text=f"生产订单 {order_id} 已创建")
|
play_speech(text=f"生产订单 {order_id} 已创建")
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("[printing.handlers] 发送语音播报失败(已忽略,不影响主流程)")
|
logger.exception("[printing.handlers] 发送语音播报失败(已忽略,不影响主流程)")
|
||||||
# ===================================
|
|
||||||
|
|
||||||
# 在事务提交后再发送,避免事务回滚但通知已发出
|
# 在事务提交后再发送,避免事务回滚但通知已发出
|
||||||
transaction.on_commit(_send_wecom)
|
transaction.on_commit(_send_wecom)
|
||||||
|
|||||||
Reference in New Issue
Block a user