using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using WIDESEA_Core; using WIDESEA_Core.BaseController; using WIDESEA_Core.Enums; using WIDESEA_DTO.Basic; using WIDESEA_IBasicRepository; using WIDESEA_IBasicService; using WIDESEA_ISystemRepository; using WIDESEA_Model.Models; namespace WIDESEA_WMSServer.Controllers.Basic { /// /// 货位 /// [Route("api/LocationInfoRow")] [ApiController] public class LocationInfoRowController : ApiBaseController { private readonly ILocationInfoRepository _repository; private readonly IAreaInfoRepository _areaInfoRepository; private readonly ILocationInfoRepository _locationInfoRepository; public LocationInfoRowController(ILocationInfoService service, ILocationInfoRepository repository, IAreaInfoRepository areaInfoRepository, ILocationInfoRepository locationInfoRepository) : base(service) { _repository = repository; _areaInfoRepository = areaInfoRepository; _locationInfoRepository = locationInfoRepository; } /// /// 获取库区权限 /// /// [HttpGet, HttpPost, Route("GetArea"), AllowAnonymous] public object GetArea() { List list = new List(); List? locations = _locationInfoRepository.QueryData(); List areaInfos = _areaInfoRepository.QueryData(x => locations.Select(x => x.AreaId).ToList().Contains(x.Id)); foreach (var areaInfo in areaInfos) { var Rows = locations.Where(x => x.AreaId == areaInfo.Id).GroupBy(x => x.Row).Select(x => x.Key).OrderBy(x => x).ToList(); var obj = new { house_name = areaInfo.AreaName, shelf_code = areaInfo.Id, tunnel = Rows }; list.Add(obj); } return list; } /// /// 获取货位信息 /// /// /// [HttpPost, Route("GetLocationStatu"), AllowAnonymous] public object GetLocationStatu([FromBody] LocationArea area) { List layers = new List(); var data = _locationInfoRepository.QueryData(x => x.AreaId == area.shelf_code && x.Row == area.tunnel); foreach (var layer in data.GroupBy(t => t.Layer)) { var rows = new List(); var data_rows = layer.GroupBy(t => t.Row); foreach (var data_row in data_rows) { var cols = new List(); foreach (var data_col in data_row) { cols.Add(new LocationCol() { //列 row = data_col.Row, layer = data_col.Layer, index = data_col.Column, locationCode = data_col.LocationCode, location_state = data_col.LocationStatus, location_lock = data_col.EnableStatus, remark = data_col.Remark }); } cols = cols.OrderBy(t => t.index).ToList(); rows.Add(new LocationRow() { //行 index = data_row.Key, cols = cols }); } rows = rows.OrderBy(t => t.index).ToList(); layers.Add(new LocationLayer() { //层 index = layer.Key, rows = rows }); } layers = layers.OrderBy(t => t.index).ToList(); return layers; } } }