diff --git a/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs b/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs index 0066698..7c43b1b 100644 --- a/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs +++ b/DOAN.Admin.WebApi/Controllers/huate_group/Recipe/RecipeController.cs @@ -111,5 +111,32 @@ namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe } + //TODO 获取公司 + [HttpGet("get_company")] + public IActionResult GetAllCompany() + { + var response = _RecipeService.GetAllCompany(); + return SUCCESS(response); + } + + //TODO 获取车间 + [HttpGet("get_workshop")] + public IActionResult GetWorkShopByCompany(int company_id) + { + var response = _RecipeService.GetWorkShopByCompany(company_id); + return SUCCESS(response); + } + + + //TODO 获取产线和设备 children + [HttpGet("get_line_childen_device")] + public IActionResult GetLineChildenDevice(int workshop_id) + { + var response = _RecipeService.GetLineChildenDevice(workshop_id); + return SUCCESS(response); + } + + + } } \ No newline at end of file diff --git a/DOAN.Model/huate_group/recipe/Dto/ProductLineChildrenDevice.cs b/DOAN.Model/huate_group/recipe/Dto/ProductLineChildrenDevice.cs new file mode 100644 index 0000000..e88aec3 --- /dev/null +++ b/DOAN.Model/huate_group/recipe/Dto/ProductLineChildrenDevice.cs @@ -0,0 +1,29 @@ +using DOAN.Model.Factory_Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.huate_group.recipe.Dto +{ + /// + /// 产线 childern device + /// + public class ProductLineChildrenDevice + { + public int Id { get; set; } + + public int? FkWorkshopId { get; set; } + public string WorkshopName { get; set; } + + public string LineCode { get; set; } + + public string LineName { get; set; } + + public int? Status { get; set; } + + public BaseDeviceAccount[] Children { get; set; } + + } +} diff --git a/DOAN.Model/huate_group/recipe/Dto/RecipeDto.cs b/DOAN.Model/huate_group/recipe/Dto/RecipeDto.cs index c212b71..f970b5e 100644 --- a/DOAN.Model/huate_group/recipe/Dto/RecipeDto.cs +++ b/DOAN.Model/huate_group/recipe/Dto/RecipeDto.cs @@ -5,17 +5,21 @@ namespace DOAN.Model.huate_group.recipe.Dto /// public class RecipeQueryDto : PagerInfo { - public int? FactoryTanantId { get; set; } - public string Workshop { get; set; } - public string Workstation { get; set; } + public int? FkCompanyId { get; set; } - public string Vehiclemodel { get; set; } + public int? FkTanantId { get; set; } - public string Partnumber { get; set; } - public string Paramter { get; set; } + + public int? FkFactoryId { get; set; } + + + public int? FkWorkshopId { get; set; } + + + public int? FkDeviceId { get; set; } } /// @@ -26,13 +30,23 @@ namespace DOAN.Model.huate_group.recipe.Dto [Required(ErrorMessage = "流水号不能为空")] public int Id { get; set; } - public string Localtion { get; set; } + public string CompanyName { get; set; } - public int? FactoryTanantId { get; set; } + public int? FkCompanyId { get; set; } - public string Workshop { get; set; } + public int? FkTanantId { get; set; } - public string Workstation { get; set; } + public string FactoryName { get; set; } + + public int? FkFactoryId { get; set; } + + public string WorkshopName { get; set; } + + public int? FkWorkshopId { get; set; } + + public string DeviceName { get; set; } + + public int? FkDeviceId { get; set; } public string Vehiclemodel { get; set; } diff --git a/DOAN.Model/huate_group/recipe/Recipe.cs b/DOAN.Model/huate_group/recipe/Recipe.cs index ea65fc1..cac9f35 100644 --- a/DOAN.Model/huate_group/recipe/Recipe.cs +++ b/DOAN.Model/huate_group/recipe/Recipe.cs @@ -1,3 +1,4 @@ + namespace DOAN.Model.huate_group.recipe { /// @@ -13,25 +14,58 @@ namespace DOAN.Model.huate_group.recipe public int Id { get; set; } /// - /// 地点 + /// 公司 /// - public string Localtion { get; set; } + [SugarColumn(ColumnName = "company_name")] + public string CompanyName { get; set; } /// - /// 工厂 租户号 + /// 公司id /// - [SugarColumn(ColumnName = "factory_tanant_id")] - public int? FactoryTanantId { get; set; } + [SugarColumn(ColumnName = "fk_company_id")] + public int? FkCompanyId { get; set; } + + /// + /// 租户号 + /// + [SugarColumn(ColumnName = "fk_tanant_id")] + public int? FkTanantId { get; set; } + + /// + /// 工厂名称 + /// + [SugarColumn(ColumnName = "factory_name")] + public string FactoryName { get; set; } + + /// + /// 工厂id + /// + [SugarColumn(ColumnName = "fk_factory_id")] + public int? FkFactoryId { get; set; } /// /// 车间 /// - public string Workshop { get; set; } + [SugarColumn(ColumnName = "workshop_name")] + public string WorkshopName { get; set; } /// - /// 工位 + /// 车间id /// - public string Workstation { get; set; } + [SugarColumn(ColumnName = "fk_workshop_id")] + public int? FkWorkshopId { get; set; } + + /// + /// 设备名称 + /// + [SugarColumn(ColumnName = "device_name")] + public string DeviceName { get; set; } + + /// + /// 设备id + /// + [SugarColumn(ColumnName = "fk_device_id")] + public int? FkDeviceId { get; set; } /// /// 车型 diff --git a/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs b/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs index 1352dac..0f41c99 100644 --- a/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs +++ b/DOAN.Service/huate_group/Recipe/IService/IRecipeService.cs @@ -1,3 +1,4 @@ +using DOAN.Model.Factory_Model; using DOAN.Model.huate_group.recipe; using DOAN.Model.huate_group.recipe.Dto; @@ -18,6 +19,13 @@ namespace DOAN.Service.huate_group.Recipe.IService int UpdateRecipe(Recipee parm); List GetRecipebyLimit(int recipe_id); + List GetAllCompany(); + + + List GetWorkShopByCompany(int company_id); + + List GetLineChildenDevice(int workshop_id); + } } diff --git a/DOAN.Service/huate_group/Recipe/RecipeService.cs b/DOAN.Service/huate_group/Recipe/RecipeService.cs index 4101362..0effd1f 100644 --- a/DOAN.Service/huate_group/Recipe/RecipeService.cs +++ b/DOAN.Service/huate_group/Recipe/RecipeService.cs @@ -5,6 +5,7 @@ using DOAN.Model.huate_group.recipe; using DOAN.Model.huate_group.recipe.Dto; using DOAN.Repository; using Aliyun.OSS; +using DOAN.Model.Factory_Model; namespace DOAN.Service.huate_group.Recipe @@ -69,9 +70,9 @@ namespace DOAN.Service.huate_group.Recipe public List GetRecipebyLimit(int recipe_id) { - return Context.Queryable() - .Where(it=>it.FkRecipeId == recipe_id) - .ToList(); + return Context.Queryable() + .Where(it => it.FkRecipeId == recipe_id) + .ToList(); } /// @@ -82,15 +83,65 @@ namespace DOAN.Service.huate_group.Recipe private static Expressionable QueryExp(RecipeQueryDto parm) { var predicate = Expressionable.Create() - .AndIF(parm.FactoryTanantId>0,it=>it.FactoryTanantId== parm.FactoryTanantId) - .AndIF(parm != null&&!string.IsNullOrEmpty( parm.Workshop),it=>it.Workshop.Contains(parm.Workshop)) - .AndIF(parm != null&&!string.IsNullOrEmpty( parm.Workstation),it=>it.Workstation.Contains(parm.Workstation)) - .AndIF(parm != null&&!string.IsNullOrEmpty( parm.Vehiclemodel),it=>it.Vehiclemodel.Contains(parm.Vehiclemodel)) - .AndIF(parm != null&&!string.IsNullOrEmpty( parm.Partnumber),it=>it.Partnumber.Contains(parm.Partnumber)) - .AndIF(parm != null&&!string.IsNullOrEmpty( parm.Paramter),it=>it.Paramter.Contains(parm.Paramter)) + .AndIF(parm.FkTanantId > 0, it => it.FkTanantId == parm.FkTanantId) + .AndIF(parm.FkFactoryId > 0, it => it.FkFactoryId == parm.FkFactoryId) + .AndIF(parm.FkWorkshopId > 0, it => it.FkWorkshopId == parm.FkWorkshopId) + .AndIF(parm.FkDeviceId > 0, it => it.FkDeviceId == parm.FkDeviceId) + //.AndIF(parm != null && !string.IsNullOrEmpty(parm.Workshop), it => it.WorkshopName.Contains(parm.Workshop)) + //.AndIF(parm != null && !string.IsNullOrEmpty(parm.Workstation), it => it.DeviceName.Contains(parm.Workstation)) + //.AndIF(parm != null && !string.IsNullOrEmpty(parm.Vehiclemodel), it => it.Vehiclemodel.Contains(parm.Vehiclemodel)) + //.AndIF(parm != null && !string.IsNullOrEmpty(parm.Partnumber), it => it.Partnumber.Contains(parm.Partnumber)) + //.AndIF(parm != null && !string.IsNullOrEmpty(parm.Paramter), it => it.Paramter.Contains(parm.Paramter)) ; return predicate; } + + public List GetAllCompany() + { + return Context.Queryable().ToList(); + } + + public List GetWorkShopByCompany(int company_id) + { + return Context.Queryable().Where(it => it.FkCompanyId == company_id).ToList(); + } + + public List GetLineChildenDevice(int workshop_id) + { + List productLineChildrenDevices = new List(); + //获取车间下所有产线 + + List lines = Context.Queryable().Where(it => it.FkWorkshopId == workshop_id).ToList(); + if (lines != null && lines.Count() > 0) + { + foreach (BaseProductionLine line in lines) + { + + ProductLineChildrenDevice LineItem = new ProductLineChildrenDevice(); + + LineItem.Id = line.Id; + LineItem.FkWorkshopId = line.FkWorkshopId; + LineItem.LineCode = line.LineCode; + LineItem.LineName = line.LineName; + LineItem.Status = line.Status; + + + // 获取产线所有设备 + List accounts = Context.Queryable().Where(it => it.FkLineId == line.Id).ToList(); + if (accounts != null && accounts.Count() > 0) + { + LineItem.Children = accounts.ToArray(); + } + productLineChildrenDevices.Add(LineItem); + + + } + + + } + + return productLineChildrenDevices; + } } } \ No newline at end of file diff --git a/DOAN.ServiceCore/SqlSugar/SqlsugarSetup.cs b/DOAN.ServiceCore/SqlSugar/SqlsugarSetup.cs index 7422606..3d54101 100644 --- a/DOAN.ServiceCore/SqlSugar/SqlsugarSetup.cs +++ b/DOAN.ServiceCore/SqlSugar/SqlsugarSetup.cs @@ -149,7 +149,7 @@ namespace DOAN.ServiceCore.SqlSugar log.AfterData = afterPars; } //logger.WithProperty("title", data).Info(pars); - db.GetConnectionScope(0) + db.GetConnectionScope(1) .Insertable(log) .ExecuteReturnSnowflakeId(); } diff --git a/DOAN.Tasks/TaskScheduler/YIDA_dataUpload_Task.cs b/DOAN.Tasks/TaskScheduler/YIDA_dataUpload_Task.cs index 39f0461..9c41e7f 100644 --- a/DOAN.Tasks/TaskScheduler/YIDA_dataUpload_Task.cs +++ b/DOAN.Tasks/TaskScheduler/YIDA_dataUpload_Task.cs @@ -91,7 +91,7 @@ namespace ZR.Tasks.TaskScheduler foreach (T item in device01s) { //1.1 判断设备配置情况 - Recipee options = query.Where(it => it.Workstation == item.Workstation && it.Paramter == item.Paramter).First(); + Recipee options = query.Where(it => it.DeviceName == item.Workstation && it.Paramter == item.Paramter).First(); if (options != null) { //不可上传