From 2e35df01c757fb797d275a7b93452702cd31a5fe Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 8 Apr 2025 18:05:58 +0800 Subject: [PATCH] 1 --- .../OnlyPrintProductLabelController.cs | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/linesider_screen_bankend/linesider_screen_bankend/Controller/OnlyPrintProductLabelController.cs b/linesider_screen_bankend/linesider_screen_bankend/Controller/OnlyPrintProductLabelController.cs index 5ff43da..336876c 100644 --- a/linesider_screen_bankend/linesider_screen_bankend/Controller/OnlyPrintProductLabelController.cs +++ b/linesider_screen_bankend/linesider_screen_bankend/Controller/OnlyPrintProductLabelController.cs @@ -61,7 +61,7 @@ namespace linesider_screen_bankend.Controller // 使用 using 语句确保资源正确释放 using (var bartender = new BartenderPrintHelper()) { - + var variables = new Dictionary { { "partnumber", workorderInfo.Specification }, @@ -88,10 +88,16 @@ namespace linesider_screen_bankend.Controller } - + // 返回成功响应 await this.HttpContext.SendApiSuccessAsync(null); } + else + { + + // 返回成功响应 + await this.HttpContext.SendApiFailAsync(500, "工单不在数据库"); + } } catch (Exception ex) @@ -144,11 +150,16 @@ namespace linesider_screen_bankend.Controller .Where(x => x.Workorder == workorder) .First(); - + if (workorderInfo == null) + { + // 返回成功响应 + await this.HttpContext.SendApiFailAsync(500, "工单不在数据库"); + return; + } // 使用 using 语句确保资源正确释放 using (var bartender = new BartenderPrintHelper()) { - + var variables = new Dictionary { { "partnumber", workorderInfo.Specification }, @@ -175,7 +186,7 @@ namespace linesider_screen_bankend.Controller } - + // 返回成功响应 await this.HttpContext.SendApiSuccessAsync(null); } @@ -206,10 +217,16 @@ namespace linesider_screen_bankend.Controller ProWorkorder workorderInfo = SqlSugarHelper.Db.Queryable() .Where(x => x.Workorder == workorder) .First(); + if (workorderInfo == null) + { + // 返回成功响应 + await this.HttpContext.SendApiFailAsync(500, "工单不在数据库"); + return; + } // 使用 using 语句确保资源正确释放 using (var bartender = new BartenderPrintHelper()) { - + var variables = new Dictionary { { "partnumber", workorderInfo.Specification }, @@ -236,7 +253,7 @@ namespace linesider_screen_bankend.Controller } - + // 返回成功响应 await this.HttpContext.SendApiSuccessAsync(null); }