diff --git a/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs b/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs index ae06507..423f7ea 100644 --- a/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs +++ b/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs @@ -3,6 +3,7 @@ using DOAN.Admin.WebApi.Filters; using DOAN.Service.huate_group.Recipe.IService; using DOAN.Model.huate_group.recipe; using DOAN.Model.huate_group.recipe.Dto; +using System.ComponentModel; //创建时间:2024-08-21 namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe @@ -125,6 +126,11 @@ namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe [HttpGet("get_workshop")] public IActionResult GetWorkShopByCompany(int company_id) { + if (company_id <= 0) + { + throw new Exception("参数异常,请检查常数"); + + } var response = _RecipeService.GetWorkShopByCompany(company_id); return SUCCESS(response); } @@ -134,10 +140,28 @@ namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe [HttpGet("get_line_childen_device")] public IActionResult GetLineChildenDevice(int workshop_id) { + if (workshop_id <= 0) + { + throw new Exception("参数异常,请检查常数"); + + } var response = _RecipeService.GetLineChildenDevice(workshop_id); return SUCCESS(response); } + //TODO 选中配方 + [HttpGet("selected")] + public IActionResult SelectedRecipe(int recipe_id) + { + if (recipe_id <= 0) + { + throw new Exception("参数异常,请检查常数"); + + } + var response = _RecipeService.SelectedRecipe(recipe_id); + return SUCCESS(response); + } + } diff --git a/DOAN.Model/Factory_Model/BaseDeviceAccountExtensions.cs b/DOAN.Model/Factory_Model/BaseDeviceAccountExtensions.cs new file mode 100644 index 0000000..d3f45b1 --- /dev/null +++ b/DOAN.Model/Factory_Model/BaseDeviceAccountExtensions.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.Factory_Model +{ + public static class BaseDeviceAccountExtensions + { + + } +} diff --git a/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs b/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs index 0f41c99..5e98bdb 100644 --- a/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs +++ b/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs @@ -26,6 +26,6 @@ namespace DOAN.Service.huate_group.Recipe.IService List GetLineChildenDevice(int workshop_id); - + int SelectedRecipe(int recipe_id); } } diff --git a/DOAN.Service/huate_group/Recipe/RecipeService.cs b/DOAN.Service/huate_group/Recipe/RecipeService.cs index 14fa98c..b73c8b0 100644 --- a/DOAN.Service/huate_group/Recipe/RecipeService.cs +++ b/DOAN.Service/huate_group/Recipe/RecipeService.cs @@ -54,7 +54,7 @@ namespace DOAN.Service.huate_group.Recipe /// public Recipee AddRecipe(Recipee model) { - model.IsSelected = false; + // 根据设备id 填充 company workshop line BaseDeviceAccount account = Context.Queryable().Where(x => x.Id == model.FkDeviceId).First(); model.DeviceName = account.DeviceName; @@ -174,5 +174,23 @@ namespace DOAN.Service.huate_group.Recipe return productLineChildrenDevices; } + + public int SelectedRecipe(int recipe_id) + { + int result = 0; + UseTran2(() => + { + Recipee recipee = Context.Queryable().Where(it => it.Id == recipe_id).First(); + if (recipee != null) + { + Context.Updateable().Where(it => it.FkDeviceId == recipee.FkDeviceId).SetColumns(it => it.IsSelected == false).ExecuteCommand(); + result = Context.Updateable().Where(it => it.Id == recipee.Id).SetColumns(it => it.IsSelected == true).ExecuteCommand(); + + } + + }); + + return result; + } } } \ No newline at end of file