using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using NPOI.SS.Formula.Functions; using SqlSugar; using WCS.BLL; using WCS.BLL.DbModels; using WCS.BLL.HardWare; using WCS.BLL.Manager; using WCS.BLL.Services.IService; using WCS.BLL.Services.Service; using WCS.DAL.Db; using WCS.DAL.DbModels; using WCS.Model; using WCS.Model.ApiModel.AGV; using WCS.Model.ApiModel.Home; using WCS.Model.ApiModel.StoreInfo; using Mode = WCS.BLL.HardWare.Mode; namespace WCS.WebApi.Controllers { /// /// 主页面的接口 /// [ApiController] [Route("[controller]")] public class AgvTaskController : ControllerBase { public AgvTaskController() { } /// /// agv任务回调 /// /// /// [Route("getAGVTasks")] [HttpPost(Name = "getAGVTasks")] public async Task> getAGVTasks(GetAGVTasksRequest request) { try { var recordsQueryable = DbHelp.db.Queryable() .WhereIF(string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode)) .WhereIF(string.IsNullOrEmpty(request.CreateUser), t => t.CreateUser.Contains(request.CreateUser)) .WhereIF(string.IsNullOrEmpty(request.StartLocationCode), t => t.StartLocationCode.Contains(request.StartLocationCode)) .WhereIF(string.IsNullOrEmpty(request.EndLocationCode), t => t.StartLocationCode.Contains(request.EndLocationCode)) .WhereIF(request.TaskStatus !=null, t => t.TaskStatus == request.TaskStatus); var totalCount = await recordsQueryable.CountAsync(); var records = await recordsQueryable .Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize) .ToListAsync(); //生成序号 for (int i = 0; i < records.Count; i++) { records[i].RowNumber = (request.PageNumber - 1) * request.PageSize + i + 1; } return new PageQueryResponse() { Code = 200, Message = $"success", Data = new PageQueryResponseData() { TotalCount = totalCount, MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize), Count = records.Count, Lists = records.ToList() } }; } catch (Exception ex) { return new PageQueryResponse() { Code = 300, Message = $"操作失败:{ex.Message}", }; } } } }