feat: 批次统计分析中关于decimal的处理

This commit is contained in:
caoqianming 2025-07-17 10:26:17 +08:00
parent c0d504ecfe
commit 1bc9cd2c60
3 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,8 @@ from apps.mtm.models import Mgroup
import decimal import decimal
from django.db.models import Sum from django.db.models import Sum
from apps.wpm.services_2 import get_f_l_date from apps.wpm.services_2 import get_f_l_date
import json
from apps.utils.tools import MyJSONEncoder
myLogger = logging.getLogger("log") myLogger = logging.getLogger("log")
def main(batch: str, mgroup_obj:Mgroup=None): def main(batch: str, mgroup_obj:Mgroup=None):
@ -93,7 +95,7 @@ def main(batch: str, mgroup_obj:Mgroup=None):
else: else:
old_data = {} old_data = {}
old_data.update(data) old_data.update(data)
batchst.data = old_data batchst.data = json.loads(json.dumps(old_data, cls=MyJSONEncoder))
if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time): if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time):
batchst.first_time = res["first_time"] batchst.first_time = res["first_time"]
if batchst.last_time is None or (res["last_time"] and res["last_time"] > batchst.last_time): if batchst.last_time is None or (res["last_time"] and res["last_time"] > batchst.last_time):

View File

@ -7,6 +7,8 @@ import decimal
from django.db.models import Sum from django.db.models import Sum
from datetime import datetime from datetime import datetime
from apps.wpm.services_2 import get_f_l_date from apps.wpm.services_2 import get_f_l_date
import json
from apps.utils.tools import MyJSONEncoder
myLogger = logging.getLogger("log") myLogger = logging.getLogger("log")
def main(batch: str, mgroup_obj): def main(batch: str, mgroup_obj):
@ -137,7 +139,7 @@ def main(batch: str, mgroup_obj):
res = get_f_l_date(data) res = get_f_l_date(data)
batchst.data = data batchst.data = json.loads(json.dumps(data, cls=MyJSONEncoder))
if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time): if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time):
batchst.first_time = res["first_time"] batchst.first_time = res["first_time"]
if batchst.last_time is None or (res["last_time"] and res["last_time"] > batchst.last_time): if batchst.last_time is None or (res["last_time"] and res["last_time"] > batchst.last_time):

View File

@ -7,6 +7,8 @@ from apps.system.models import Dept
from apps.inm.models import MIOItem from apps.inm.models import MIOItem
from apps.qm.models import FtestWork from apps.qm.models import FtestWork
from apps.wpm.services_2 import get_f_l_date from apps.wpm.services_2 import get_f_l_date
import json
from apps.utils.tools import MyJSONEncoder
myLogger = logging.getLogger("log") myLogger = logging.getLogger("log")
def main(batch: str, mgroup_obj): def main(batch: str, mgroup_obj):
@ -463,7 +465,7 @@ def main(batch: str, mgroup_obj):
res = get_f_l_date(data) res = get_f_l_date(data)
batchst.data = data batchst.data = json.loads(json.dumps(data, cls=MyJSONEncoder))
batchst.material_start = material_start batchst.material_start = material_start
if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time): if batchst.first_time is None or (res["first_time"] and res["first_time"] < batchst.first_time):
batchst.first_time = res["first_time"] batchst.first_time = res["first_time"]