From c08b220d173ad5507c837af62b5c7f3ba1e7a4da Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 22 Jul 2026 16:29:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BF?= =?UTF-8?q?=E6=96=B0=E5=A2=9Evalidate=E6=8E=A5=E5=8F=A3,=E4=BE=9B=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E7=94=BB=E5=B8=83=E5=AE=9E=E6=97=B6=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?DAG=E7=BB=93=E6=9E=84(=E4=B8=8D=E5=AD=98=E7=9B=98,=E8=BF=94?= =?UTF-8?q?=E5=9B=9Evalid/error)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- apps/mtm/views.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/mtm/views.py b/apps/mtm/views.py index 5f3d4788..9bb00e4c 100644 --- a/apps/mtm/views.py +++ b/apps/mtm/views.py @@ -362,13 +362,29 @@ class RoutePackViewSet(CustomModelViewSet): @action(methods=['get'], detail=True, perms_map={'get': '*'}) def final_materials(self, request, *args, **kwargs): """获取最终产品 - + 获取最终产品""" ins:RoutePack = self.get_object() matIds = ins.get_final_material_ids() qs = Material.objects.filter(id__in=matIds) res = [{"id": x.id, "name": str(x)} for x in qs] return Response(res) + + @action(methods=['get'], detail=True, perms_map={'get': '*'}) + def validate(self, request, *args, **kwargs): + """校验工艺图是否合法(不存盘) + + 供拖拽画布实时校验DAG结构,返回 {valid, error},不修改gjson + """ + ins:RoutePack = self.get_object() + try: + ins.validate_and_return_gjson() + return Response({"valid": True, "error": ""}) + except ParseError as e: + detail = e.detail + if isinstance(detail, (list, tuple)): + detail = detail[0] if detail else "" + return Response({"valid": False, "error": str(detail)}) class RouteViewSet(CustomModelViewSet): queryset = Route.objects.all() serializer_class = RouteSerializer