From 419396f344ac2c8030101f7b9af535f8a6243f5d Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sat, 29 Jun 2024 22:55:46 +0800 Subject: [PATCH] =?UTF-8?q?fix-=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ftp_orders/main.py | 2 +- results/laboratory_form.py | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ftp_orders/main.py b/ftp_orders/main.py index e1a1e3b60d..fd368ec728 100644 --- a/ftp_orders/main.py +++ b/ftp_orders/main.py @@ -416,7 +416,7 @@ def pull_result(self, file: str): iss.save() for res in result: - fraction = Fractions.objects.filter(fsli=res["fsli"]).first() + fraction = Fractions.objects.filter(fsli=res["fsli"], research__hide=False, research__podrazdeleniye__p_type=2).first() if not fraction: continue value = res["value"] diff --git a/results/laboratory_form.py b/results/laboratory_form.py index 5b40b63422..0535f48d1d 100644 --- a/results/laboratory_form.py +++ b/results/laboratory_form.py @@ -17,6 +17,7 @@ from reportlab.lib.styles import getSampleStyleSheet from copy import deepcopy from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY, TA_LEFT +from operator import itemgetter def default_lab_form(fwb, interactive_text_field, pw, direction, styleSheet, directory, show_norm, stl, print_vtype, get_r, result_normal): @@ -575,16 +576,28 @@ def lab_form_1(fwb, interactive_text_field, pw, direction, styleSheet, directory pks.append(iss.pk) data = [] fractions = directory.Fractions.objects.filter(research=iss.research, hide=False, render_type=0).order_by("pk").order_by("sort_weight") + results_iss = Result.objects.filter(issledovaniye=iss).order_by("fraction__sort_weight") # Выборка результатов из базы + + # проверить записанные результаты со справочником из Услуги названия + fractions_set = set([f.fraction for f in results_iss]) + fractions_orders = [[fs.sort_weight, fs] for fs in fractions_set] + sorted_data = sorted(fractions_orders, key=itemgetter(0)) + fractions_tmp = [s[1] for s in sorted_data] + + fraction_compare = [el for el in fractions_tmp if el not in fractions] + if len(fraction_compare) > 0: + fractions = fraction_compare + if iss.api_app: laboratory_analyzer_data.append(iss.api_app.name) - if fractions.count() > 0: - if fractions.count() == 1: + if len(fractions) > 0: + if len(fractions) == 1: tmp = [Paragraph('' + iss.research.title + "", styleSheet["BodyText"])] norm = "none" sign = RANGE_IN - if Result.objects.filter(issledovaniye=iss, fraction=fractions[0]).exists(): - r = Result.objects.filter(issledovaniye=iss, fraction=fractions[0]).order_by("-pk")[0] + if len(fractions) > 0: + r = fractions[0] ref = r.get_ref() if show_norm: norm, sign, ref_res = r.get_is_norm(recalc=True, with_ref=True)