diff --git a/WcsMain/ApiServe/Controllers/Dto/WcsDto/Convey/QueryConveyTaskWithPageRequest.cs b/WcsMain/ApiServe/Controllers/Dto/WcsDto/Convey/QueryConveyTaskWithPageRequest.cs new file mode 100644 index 0000000..46d5c31 --- /dev/null +++ b/WcsMain/ApiServe/Controllers/Dto/WcsDto/Convey/QueryConveyTaskWithPageRequest.cs @@ -0,0 +1,54 @@ +using System.Text.Json.Serialization; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.ElTag; + +namespace WcsMain.ApiServe.Controllers.Dto.WcsDto.Convey; + +public class QueryConveyTaskWithPageRequest +{ + /// + /// 查询的字符串 + /// + [JsonPropertyName("searchStr")] + public string? SearchStr { get; set; } + + /// + /// 任务类型 + /// + [JsonPropertyName("conveyTaskType")] + public List? TaskType { get; set; } + + /// + /// 任务状态 + /// + [JsonPropertyName("conveyTaskStatus")] + public List? TaskStatus { get; set; } + + /// + /// 查询时间范围 + /// + [JsonPropertyName("timeRange")] + public List? TimeRange { get; set; } + + /// + /// 分页信息 + /// + [JsonPropertyName("page")] + public ConveyTaskPage? Page { get; set; } +} + + +public class ConveyTaskPage +{ + /// + /// 每页大小 + /// + [JsonPropertyName("pageSize")] + public int PageSize { get; set; } + + /// + /// 当前页数 + /// + [JsonPropertyName("pageIndex")] + public int PageIndex { get; set; } + +} \ No newline at end of file diff --git a/WcsMain/ApiServe/Controllers/WcsController/ConveyTaskController.cs b/WcsMain/ApiServe/Controllers/WcsController/ConveyTaskController.cs index f9dc2a4..667cc8d 100644 --- a/WcsMain/ApiServe/Controllers/WcsController/ConveyTaskController.cs +++ b/WcsMain/ApiServe/Controllers/WcsController/ConveyTaskController.cs @@ -2,7 +2,9 @@ using Microsoft.AspNetCore.Mvc; using WcsMain.ApiServe.ControllerFilter.ExceptionFilter; using WcsMain.ApiServe.Controllers.Dto; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.Convey; using WcsMain.ApiServe.Factory; +using WcsMain.ApiServe.Service.WcsService; using WcsMain.DataBase.TableEntity; namespace WcsMain.ApiServe.Controllers.WcsController; @@ -12,21 +14,16 @@ namespace WcsMain.ApiServe.Controllers.WcsController; [Route("api/wcs/conveyTask")] [ApiController] [WcsExceptionFilter] -public class ConveyTaskController : ControllerBase +public class ConveyTaskController(ConveyService conveyService) : ControllerBase { + private readonly ConveyService _conveyService = conveyService; + /// /// 分页查询箱式线任务 /// /// [HttpPost("queryConveyTaskWithPage")] - public WcsApiResponse> QueryConveyTaskWithPage() - { - // TODO - return WcsApiResponseFactory.Fail>(); - - - - } + public WcsApiResponse> QueryConveyTaskWithPage([FromBody] QueryConveyTaskWithPageRequest request) => _conveyService.QueryConveyTaskWithPage(request); diff --git a/WcsMain/ApiServe/Service/WcsService/ConveyService.cs b/WcsMain/ApiServe/Service/WcsService/ConveyService.cs new file mode 100644 index 0000000..bac3cd8 --- /dev/null +++ b/WcsMain/ApiServe/Service/WcsService/ConveyService.cs @@ -0,0 +1,32 @@ +using WcsMain.ApiServe.Controllers.Dto; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.Convey; +using WcsMain.ApiServe.Factory; +using WcsMain.DataBase.Dao; +using WcsMain.DataBase.TableEntity; +using WcsMain.WcsAttribute.AutoFacAttribute; + +namespace WcsMain.ApiServe.Service.WcsService; + +[Service] +public class ConveyService(AppConveyTaskDao conveyTaskDao) +{ + private readonly AppConveyTaskDao _conveyTaskDao = conveyTaskDao; + + /// + /// 分页查询箱式线任务 + /// + /// + /// + public WcsApiResponse> QueryConveyTaskWithPage(QueryConveyTaskWithPageRequest request) + { + (List? conveyTasks, int totalRows) = _conveyTaskDao.QueryConveyTaskWithPage(request); + if (conveyTasks == default) + { + return WcsApiResponseFactory.DataBaseErr>(); + } + return WcsApiResponseFactory.Success(totalRows, conveyTasks); + } + + + +} diff --git a/WcsMain/DataBase/Dao/AppConveyTaskDao.cs b/WcsMain/DataBase/Dao/AppConveyTaskDao.cs index 4ec72c2..806bc73 100644 --- a/WcsMain/DataBase/Dao/AppConveyTaskDao.cs +++ b/WcsMain/DataBase/Dao/AppConveyTaskDao.cs @@ -1,4 +1,6 @@ using System.Threading.Tasks; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.Convey; +using WcsMain.ApiServe.Controllers.Dto.WcsDto.ElTag; using WcsMain.Common; using WcsMain.DataBase.TableEntity; using WcsMain.WcsAttribute.AutoFacAttribute; @@ -87,15 +89,54 @@ public class AppConveyTaskDao _ = ex; return 0; } - - - - } - + /// + /// 分页查询箱式线任务表 + /// + /// + /// + public (List? conveyTasks, int totalRows) QueryConveyTaskWithPage(QueryConveyTaskWithPageRequest request) + { + try + { + int totalRows = 0; + var sqlFuc = CommonTool.DbServe.Queryable() + .WhereIF(!string.IsNullOrEmpty(request.SearchStr), + w => w.TaskId!.Contains(request.SearchStr!) + || w.TaskGroup!.Contains(request.SearchStr!) + || w.Location!.Contains(request.SearchStr!) + || w.ArriveLocation!.Contains(request.SearchStr!) + || w.VehicleNo!.Contains(request.SearchStr!) + || w.Remark!.Contains(request.SearchStr!)); + if (request.TaskType != default) + { + List taskTaskType = []; + request.TaskType.ForEach(item => taskTaskType.Add(item)); + sqlFuc.Where(w => taskTaskType.Contains(w.TaskType)); + } + if (request.TaskStatus != default) + { + List taskStatus = []; + request.TaskStatus.ForEach(item => taskStatus.Add(item)); + sqlFuc.Where(w => taskStatus.Contains(w.TaskStatus)); + } + if (request.TimeRange is { Count: 2 }) // 时间范围 + { + sqlFuc.Where(w => w.CreateTime > request.TimeRange[0] && w.CreateTime < request.TimeRange[1]); + } + sqlFuc.OrderByDescending(o => new { o.CreateTime }); + var queryResult = sqlFuc.ToPageList(request.Page!.PageIndex, request.Page!.PageSize, ref totalRows); + return (queryResult, totalRows); + } + catch (Exception ex) + { + _ = ex; + return default; + } + } diff --git a/WcsMain/DataBase/TableEntity/AppConveyTask.cs b/WcsMain/DataBase/TableEntity/AppConveyTask.cs index 4582824..1a36dfc 100644 --- a/WcsMain/DataBase/TableEntity/AppConveyTask.cs +++ b/WcsMain/DataBase/TableEntity/AppConveyTask.cs @@ -1,4 +1,5 @@ using SqlSugar; +using System.Text.Json.Serialization; namespace WcsMain.DataBase.TableEntity; @@ -12,36 +13,42 @@ public class AppConveyTask /// 任务号 /// [SugarColumn(ColumnName = "task_id", IsPrimaryKey = true)] + [JsonPropertyName("taskId")] public string? TaskId { get; set; } /// /// 任务组 /// [SugarColumn(ColumnName = "task_group")] + [JsonPropertyName("taskGroup")] public string? TaskGroup { get; set; } /// /// 载具号 /// [SugarColumn(ColumnName = "vehicle_no")] + [JsonPropertyName("vehicleNo")] public string? VehicleNo { get; set; } /// /// 任务类型 /// [SugarColumn(ColumnName = "task_type")] + [JsonPropertyName("taskType")] public int? TaskType { get; set; } /// /// 任务状态 /// [SugarColumn(ColumnName = "task_status")] + [JsonPropertyName("taskStatus")] public int? TaskStatus { get; set; } /// /// 点位 /// [SugarColumn(ColumnName = "location")] + [JsonPropertyName("location")] public string? Location { get; set; } @@ -49,36 +56,42 @@ public class AppConveyTask /// 实际到达的点位 /// [SugarColumn(ColumnName = "arrive_location")] + [JsonPropertyName("arriveLocation")] public string? ArriveLocation { get; set; } /// /// 创建人 /// [SugarColumn(ColumnName = "create_person")] + [JsonPropertyName("createPerson")] public string? CreatePerson { get; set; } /// /// 创建时间 /// [SugarColumn(ColumnName = "create_time")] + [JsonPropertyName("createTime")] public DateTime? CreateTime { get; set; } /// /// 移栽时间 /// [SugarColumn(ColumnName = "move_time")] + [JsonPropertyName("moveTime")] public DateTime? MoveTime { get; set; } /// /// 完成时间 /// [SugarColumn(ColumnName = "complete_time")] + [JsonPropertyName("completeTime")] public DateTime? CompleteTime { get; set; } /// /// 备注信息 /// [SugarColumn(ColumnName = "remark")] + [JsonPropertyName("remark")] public string? Remark { get; set; } diff --git a/WcsMain/Enum/Convey/ConveyTaskTypeEnum.cs b/WcsMain/Enum/Convey/ConveyTaskTypeEnum.cs new file mode 100644 index 0000000..5614ef9 --- /dev/null +++ b/WcsMain/Enum/Convey/ConveyTaskTypeEnum.cs @@ -0,0 +1,14 @@ +namespace WcsMain.Enum.Convey; + +/// +/// 箱式线任务类型 +/// +public enum ConveyTaskTypeEnum +{ + pick = 1, // 拣选 + replenish = 2, // 补货 + deliver = 3, // 发货 + check = 4, // 复核 + + +}