using Microsoft.AspNetCore.Mvc; using WCS.BLL.Services.IService; using WCS.BLL.Services.Service; using WCS.Model.ApiModel.MatInventoryDetail; using WCS.Model; using WCS.Model.ApiModel.StoreInfo; using WCS.BLL.DbModels; using WCS.Model.ApiModel.MatBaseInfo; using WCS.DAL.DbModels; using WCS.DAL.Db; using WCS.Model.ApiModel.Home; using WCS.Model.ApiModel.LocationInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; using WCS.WebApi.Helper; namespace WCS.WebApi.Controllers { /// /// 位置管理的接口 /// [ApiController] [Route("[controller]")] public class LocationInfoController : ControllerBase { public ILocationInfoService _locationInfoService { get; set; } public LocationInfoController(ILocationInfoService locationInfoService) { _locationInfoService = locationInfoService; } #region 位置管理 [Route("getLocationAreas")] [HttpPost(Name = "getLocationAreas")] public async Task getLocationAreas(RequestBase request) { try { //直接获取当前所有货架类型并返回 var locationAreaInfos = DbHelp.db.Queryable() .Select(t => new LocationAreaInfoModel() { Id = t.Id, LocationAreaName = t.LocationAreaName }) .ToList(); return new PageQueryResponse() { Code = 200, Message = "success", Data = new PageQueryResponseData { Lists = locationAreaInfos, Count = locationAreaInfos.Count } }; } catch (Exception ex) { return new PageQueryResponse() { Code = 300, Message = $"查询失败:{ex.Message}", }; } } [Route("getLocationInfos")] [HttpPost(Name = "getLocationInfos")] public async Task GetLocationInfos(GetLocationInfosRequest request) { return await _locationInfoService.GetLocationInfos(request); } [Route("exportLocationInfos")] [HttpPost(Name = "exportLocationInfos")] public async Task ExportLocationInfos(GetLocationInfosRequest request) { var result = await _locationInfoService.ExportLocationInfos(request); var data = result.Data?.Lists; var columns = new[] { new ExportableColumn("序号","RowNumber"), new ExportableColumn("位置区域","LocationArea"), new ExportableColumn("位置编号","LocationCode"), new ExportableColumn("RCS库位编号","RcsStoreCode"), new ExportableColumn("可放置货架类型","AllowShelfTypesNameStr"), new ExportableColumn("启用状态","IsEnableStr"), new ExportableColumn("更新人", "ModifyUser"), new ExportableColumn("更新时间", "ModifyTime"), }; if (data == null) { return NotFound(); } else return ExportExcelHelper.Export("导出数据", columns, data); } [HttpPost("addOrUpdateLocationInfo")] public async Task> addOrUpdateLocationInfo(AddLocaionInfoRequest request) { return await _locationInfoService.addOrUpdateLocationInfo(request); } [HttpPost("deleteLocationInfo")] public async Task> deleteLocationInfo(DeleteInfosRequest request) { return await _locationInfoService.deleteLocationInfo(request); } #endregion } }