fix: decimal存入json字段时使用myjsondecoder

This commit is contained in:
caoqianming 2025-04-09 13:18:42 +08:00
parent c8ce78f50d
commit 3b78c4e993
2 changed files with 5 additions and 4 deletions

View File

@ -4,8 +4,8 @@ from django.utils import timezone
from apps.bi.models import Dataset, DatasetRecord from apps.bi.models import Dataset, DatasetRecord
from apps.bi.services import exec_dataset from apps.bi.services import exec_dataset
import json import json
from apps.utils.tools import MyJSONEncoder
@shared_task() @shared_task()
def exec_dataset_and_store(code: str, query: str = ''): def exec_dataset_and_store(code: str, query: str = ''):
dt = Dataset.objects.get(code=code) dt = Dataset.objects.get(code=code)
@ -16,4 +16,5 @@ def exec_dataset_and_store(code: str, query: str = ''):
if query: if query:
squery = json.loads(query) squery = json.loads(query)
dtr.full_sql, dtr.result = exec_dataset(dt, squery) dtr.full_sql, dtr.result = exec_dataset(dt, squery)
dtr.result = json.loads(json.dumps(dtr.result, cls=MyJSONEncoder))
dtr.save() dtr.save()

View File

@ -7,7 +7,7 @@ from django.utils import timezone
from datetime import datetime from datetime import datetime
from server.conf import BASE_PROJECT_CODE from server.conf import BASE_PROJECT_CODE
import json import json
from django.core.serializers.json import DjangoJSONEncoder from apps.utils.tools import MyJSONEncoder
def get_alldata_with_batch_and_store(batch: str): def get_alldata_with_batch_and_store(batch: str):
""" """
@ -26,7 +26,7 @@ def get_alldata_with_batch_and_store(batch: str):
"last_time": last_time "last_time": last_time
}) })
bobj.last_time = last_time bobj.last_time = last_time
bobj.data = json.loads(json.dumps(data, cls=DjangoJSONEncoder)) bobj.data = json.loads(json.dumps(data, cls=MyJSONEncoder))
bobj.save() bobj.save()
def get_alldata_with_batch_gx(batch: str): def get_alldata_with_batch_gx(batch: str):