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); }