diff --git a/ZR.Admin.WebApi/Controllers/mes/mm/MmAgvLocationController.cs b/ZR.Admin.WebApi/Controllers/mes/mm/MmAgvLocationController.cs index 46cb061d..e497c8e1 100644 --- a/ZR.Admin.WebApi/Controllers/mes/mm/MmAgvLocationController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/mm/MmAgvLocationController.cs @@ -49,7 +49,7 @@ namespace ZR.Admin.WebApi.Controllers public IActionResult GetMmAgvLocation(int Id) { var response = _MmAgvLocationService.GetInfo(Id); - + var info = response.Adapt(); return SUCCESS(info); } @@ -102,8 +102,33 @@ namespace ZR.Admin.WebApi.Controllers return ToResponse(response); } + /// + /// 区域信息 + /// + /// + [HttpGet("listAreaOptions")] + public IActionResult ListAreaOptions() + { + var response = _MmAgvLocationService.ListAreaOptions(); + + return SUCCESS(response); + } + [HttpGet("update_status")] + public IActionResult Updatestatus(int index, int status) + { + if (status == 0) + { + status = 1; + }else if (status == 1) + { + status = 0; + } + + var response = _MmAgvLocationService.Updatestatus(index, status); + return SUCCESS(response); + } } } \ No newline at end of file diff --git a/ZR.Model/MES/mm/Dto/MmAgvLocationDto.cs b/ZR.Model/MES/mm/Dto/MmAgvLocationDto.cs index 365a8910..b79e89df 100644 --- a/ZR.Model/MES/mm/Dto/MmAgvLocationDto.cs +++ b/ZR.Model/MES/mm/Dto/MmAgvLocationDto.cs @@ -7,6 +7,8 @@ namespace ZR.Model.Dto /// public class MmAgvLocationQueryDto : PagerInfo { + + public int areaCode { get; set; } } /// diff --git a/ZR.Service/mes/mm/IService/IMmAgvLocationService.cs b/ZR.Service/mes/mm/IService/IMmAgvLocationService.cs index bf7ef14d..bea7c7f2 100644 --- a/ZR.Service/mes/mm/IService/IMmAgvLocationService.cs +++ b/ZR.Service/mes/mm/IService/IMmAgvLocationService.cs @@ -20,5 +20,9 @@ namespace ZR.Service.mes.mm.IService int UpdateMmAgvLocation(MmAgvLocation parm); + List<(int,string)> ListAreaOptions(); + + int Updatestatus(int index, int status); + } } diff --git a/ZR.Service/mes/mm/MmAgvLocationService.cs b/ZR.Service/mes/mm/MmAgvLocationService.cs index bcfaa660..7811fd85 100644 --- a/ZR.Service/mes/mm/MmAgvLocationService.cs +++ b/ZR.Service/mes/mm/MmAgvLocationService.cs @@ -26,7 +26,8 @@ namespace ZR.Service.Business /// public PagedInfo GetList(MmAgvLocationQueryDto parm) { - var predicate = Expressionable.Create(); + var predicate = Expressionable.Create() + .AndIF(parm.areaCode!=0,it=>it.AreaCode==parm.areaCode); var response = Queryable() .Where(predicate.ToExpression()) @@ -83,5 +84,41 @@ namespace ZR.Service.Business return Update(model, true); } + + /// + /// 获取地域选择 + /// + /// + public List<(int, string)> ListAreaOptions() + { + // 使用 LINQ 查询获取结果 + var queryResult = Context.Queryable() + .GroupBy(it => it.AreaCode) + .Select(it => new + { + item1 = it.AreaCode, // 使用 Key 获取分组的键值 + item2 = SqlFunc.AggregateMax(it.Area), // 聚合 Area 字段的最大值 + }) + .ToList(); + + // 将匿名对象转换为 List<(int, string)> + List<(int, string)> lists = queryResult + .Select(item => ((int)item.item1, item.item2)) + .ToList(); + + + + return lists; + } + /// + /// 更改状态 + /// + /// + /// + /// + public int Updatestatus(int index, int status) + { + return Context.Updateable().Where(it=>it.Id==index).SetColumns(it=>it.Status==status).ExecuteCommand(); + } } } \ No newline at end of file