diff --git a/apps/mtm/services.py b/apps/mtm/services.py index 65b4370c..9c4a4783 100644 --- a/apps/mtm/services.py +++ b/apps/mtm/services.py @@ -124,7 +124,9 @@ def mgroup_run_change(mgroup: Mgroup, new_run: bool, last_timex: datetime): last_stlog.save() cal_exp_duration_sec(last_stlog.id) # 触发时间分配 elif last_stlog.end_time and new_run is False and last_timex > last_stlog.end_time: # 从开到停 - StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex)) + last_stlog2 = StLog.objects.filter(mgroup=mgroup, is_shutdown=True).order_by("-start_time").first() + if not last_stlog2: + StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex)) elif new_run is False: StLog.objects.create(title="停机", is_shutdown=True, mgroup=mgroup, end_time=None, start_time=last_timex, sflog=get_sflog(mgroup, last_timex)) mgroup.is_running = False diff --git a/apps/qm/views.py b/apps/qm/views.py index a8405f22..c4427212 100644 --- a/apps/qm/views.py +++ b/apps/qm/views.py @@ -30,13 +30,12 @@ class NotOkOptionView(APIView): res2 = {i.value: i.label for i in NotOkOption} return Response({"res_list": res1, "res_dict": res2}) -class TestItemViewSet(ListModelMixin, CustomGenericViewSet): +class TestItemViewSet(CustomModelViewSet): """ list:质检项目 质检项目 """ - perms_map = {'get': '*'} queryset = TestItem.objects.all() serializer_class = TestItemSerializer filterset_class = TestItemFilter