using Microsoft.AspNetCore.Mvc; using WCS.BLL.Services.IService; using WCS.BLL.Services.Service; using WCS.Model; using WCS.Model.ApiModel.StoreInfo; using WCS.BLL.DbModels; using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatDetailCurrentInfo; using WCS.DAL.DbModels; using WCS.WebApi.Helper; namespace WCS.WebApi.Controllers { /// /// 当前库存存量的数据 当前库存数据 /// [ApiController] [Route("[controller]")] public class MatDetailCurrenInfoController : ControllerBase { public IMatDetailCurrentInfoService _matDetailCurrentInfoService { get; set; } public MatDetailCurrenInfoController(IMatDetailCurrentInfoService matDetailCurrentInfoService) { _matDetailCurrentInfoService = matDetailCurrentInfoService; } #region 库存数据管理 [Route("getMatDetailCurrentInfos")] [HttpPost(Name = "getMatDetailCurrentInfos")] public async Task GetMatDetailCurrentInfos(GetMatDetailCurrentInfosRequest request) { return await _matDetailCurrentInfoService.GetMatDetailCurrentInfos(request); } [Route("exportMatDetailCurrentInfos")] [HttpPost(Name = "exportMatDetailCurrentInfos")] public async Task ExportMatDetailCurrentInfos(GetMatDetailCurrentInfosRequest request) { var result = await _matDetailCurrentInfoService.ExportMatDetailCurrentInfos(request); var data = result.Data?.Lists; var columns = new[] { new ExportableColumn("序号","RowNumber"), new ExportableColumn("货架类型","ShelfType"), new ExportableColumn("货架编码","ShelfCode"), new ExportableColumn("位置区域","LocationArea"), new ExportableColumn("位置编号","LocationCode"), new ExportableColumn("物料编码","MatCode"), new ExportableColumn("物料名称","MatName"), new ExportableColumn("物料规格","MatSpec"), new ExportableColumn("数量", "MatQty"), new ExportableColumn("更新人", "ModifyUser"), new ExportableColumn("更新时间", "ModifyTime"), }; if (data == null) { return NotFound(); } else return ExportExcelHelper.Export("导出数据", columns, data); } [HttpPost("updateMatDetailCurrentInfo")] public async Task> updateMatDetailCurrentInfo(AddLocaionInfoRequest request) { return await _matDetailCurrentInfoService.updateMatDetailCurrentInfo(request); } [HttpPost("updateMatDetailCurrentInfoById")] public async Task> updateMatDetailCurrentInfoById(UpdateMatDetailCurrentInfoByIdRequest request) { var transRequest = new AddLocaionInfoRequest() { UserName = request.UserName, DeviceType = request.DeviceType, LocationInfo = new MatDetailCurrentInfo() { Id = request.MatDetailCurrentInfoId, MatQty = request.MatQty, } }; return await _matDetailCurrentInfoService.updateMatDetailCurrentInfo(transRequest); } [HttpPost("deleteMatDetailCurrentInfo")] public async Task> deleteMatDetailCurrentInfo(DeleteInfosRequest request) { //校验 if (request.needDeleteIds == null || request.needDeleteIds.Count == 0) { return new ResponseCommon() { Code = 201, Message = "操作失败:参数校验失败(ID)." }; } return await _matDetailCurrentInfoService.deleteMatDetailCurrentInfo(request); } #endregion } }