库存盘点的导出
This commit is contained in:
@ -41,6 +41,8 @@ namespace WCS.BLL.Services.IService
|
||||
|
||||
public Task<PageQueryResponse<MatDetailStocktakingInfoModel>> getStocktakingInfos(GetStocktakingInfosRequest request);
|
||||
|
||||
public Task<PageQueryResponse<MatDetailStocktakingInfoModel>> exportStocktakingInfos(GetStocktakingInfosRequest request);
|
||||
|
||||
public Task<PageQueryResponse<MatDetailCurrentInfoModel>> getStocktakingInfosByShelfCode(GetStocktakingInfosByShelfCodeRequest request);
|
||||
|
||||
public Task<ResponseCommon<object>> updateStocktakingInfo(UpdateStocktakingInfoRequest request);
|
||||
|
@ -1171,6 +1171,78 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<MatDetailStocktakingInfoModel>> exportStocktakingInfos(GetStocktakingInfosRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<MatDetailStocktakingInfo>()
|
||||
.LeftJoin<ShelfInfo>((mci, si) => mci.ShlefId == si.Id)
|
||||
.LeftJoin<LocationInfo>((mci, si, li) => (si.TransStatus == TransStatusEnum.静止 && si.CurrentLocationId == li.Id)
|
||||
|| (si.TransStatus == TransStatusEnum.运输中 && si.DestinationLocationId == li.Id))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), (mci, si, li) => mci.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), (mci, si, li) => mci.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StocktakingUser), (mci, si, li) => mci.StocktakingUser.Contains(request.StocktakingUser))
|
||||
.WhereIF(request.StocktakingStatus != null, (mci, si, li) => mci.StocktakingStatus == request.StocktakingStatus)
|
||||
.Select((mci, si, li) => new MatDetailStocktakingInfoModel()
|
||||
{
|
||||
Id = mci.Id,
|
||||
MatDetailCurrentId = mci.MatDetailCurrentId,
|
||||
|
||||
ShlefId = mci.ShlefId,
|
||||
ShelfCode = mci.ShelfCode,
|
||||
ShelfType = si.ShelfTypeName,
|
||||
ShelfArea = li.LocationArea,
|
||||
|
||||
MatCode = mci.MatCode,
|
||||
MatName = mci.MatName,
|
||||
MatSpec = mci.MatSpec,
|
||||
MatQty = mci.MatQty,
|
||||
StocktakingQty = mci.StocktakingQty,
|
||||
MatSupplier = mci.MatSupplier,
|
||||
MatCustomer = mci.MatCustomer,
|
||||
|
||||
StocktakingUser = mci.StocktakingUser,
|
||||
StocktakingTime = mci.StocktakingTime,
|
||||
StocktakingStatus = mci.StocktakingStatus,
|
||||
});
|
||||
|
||||
//分页
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.OrderByDescending(mci => mci.Id)
|
||||
.Take(65535)
|
||||
.ToListAsync();
|
||||
|
||||
//生成序号
|
||||
var index = 1;
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = index++;
|
||||
}
|
||||
|
||||
return new PageQueryResponse<MatDetailStocktakingInfoModel>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<MatDetailStocktakingInfoModel>()
|
||||
{
|
||||
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<MatDetailStocktakingInfoModel>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<MatDetailCurrentInfoModel>> getStocktakingInfosByShelfCode(GetStocktakingInfosByShelfCodeRequest request)
|
||||
{
|
||||
try
|
||||
|
@ -4,6 +4,8 @@ using WCS.BLL.Services.Service;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
@ -81,6 +83,34 @@ namespace WCS.WebApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Route("exportStocktakingInfos")]
|
||||
[HttpPost(Name = "exportStocktakingInfos")]
|
||||
public async Task<IActionResult> exportStocktakingInfos(GetStocktakingInfosRequest request)
|
||||
{
|
||||
var result = await _stockTakingService.exportStocktakingInfos(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("物料名称","MatName"),
|
||||
new ExportableColumn("物料规格","MatSpec"),
|
||||
new ExportableColumn("货架编号","ShelfCode"),
|
||||
new ExportableColumn("货架区域","ShelfArea"),
|
||||
new ExportableColumn("原数量","MatQty"),
|
||||
new ExportableColumn("盘点数量","StocktakingQty"),
|
||||
new ExportableColumn("盘点人", "StocktakingUser"),
|
||||
new ExportableColumn("盘点时间", "StocktakingTime"),
|
||||
new ExportableColumn("盘点状态", "StocktakingStatus"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
}
|
||||
|
||||
[Route("getStocktakingInfosByShelfCode")]
|
||||
[HttpPost(Name = "getStocktakingInfosByShelfCode")]
|
||||
public async Task<ResponseCommon> getStocktakingInfosByShelfCode(GetStocktakingInfosByShelfCodeRequest request)
|
||||
|
@ -12,6 +12,7 @@ using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using System.Collections.ObjectModel;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
|
||||
namespace 智慧物流软件系统.ViewModel
|
||||
{
|
||||
@ -131,6 +132,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
{
|
||||
BtnSearch(true);
|
||||
}
|
||||
|
||||
public void BtnSearch(bool IsPageReset = true)
|
||||
{
|
||||
if (CurrentPage == 0 || IsPageReset)
|
||||
@ -175,9 +177,8 @@ namespace 智慧物流软件系统.ViewModel
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料删除操作
|
||||
/// 盘点提交操作
|
||||
/// </summary>
|
||||
public ICommand BtnCommitCommand { get => new DelegateCommand(BtnCommit); }
|
||||
public async void BtnCommit()
|
||||
@ -218,6 +219,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料修改操作
|
||||
/// </summary>
|
||||
@ -265,7 +267,7 @@ namespace 智慧物流软件系统.ViewModel
|
||||
public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); }
|
||||
public async void BtnDelete()
|
||||
{
|
||||
Growl.Ask($"是否删除所有勾选得数据]!", isConfirmed =>
|
||||
Growl.Ask($"是否删除所有勾选的数据?", isConfirmed =>
|
||||
{
|
||||
if (isConfirmed)
|
||||
{
|
||||
@ -301,6 +303,49 @@ namespace 智慧物流软件系统.ViewModel
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出功能
|
||||
/// </summary>
|
||||
public ICommand BtnExportCommand { get => new DelegateCommand(BtnExport); }
|
||||
public async void BtnExport()
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 选择文件保存路径
|
||||
Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
|
||||
sfd.Title = "选择文件保存路径";
|
||||
sfd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
|
||||
sfd.FileName = "库存盘点" + DateTime.Now.ToString("yyyyMMddhhmmss");
|
||||
sfd.OverwritePrompt = true;
|
||||
if (sfd.ShowDialog() != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string path = sfd.FileName;
|
||||
#endregion
|
||||
var isSelected = Enum.TryParse<StocktakingStatusEnum>(SelectedStocktakingStatus, out StocktakingStatusEnum status);
|
||||
var body = new GetStocktakingInfosRequest()
|
||||
{
|
||||
MatCode = MatCode,
|
||||
MatName = MatName,
|
||||
StocktakingUser = StocktakingUser,
|
||||
StocktakingStatus = isSelected ? status : null,
|
||||
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageSize = PageSize,
|
||||
|
||||
};
|
||||
await ApiHelp.PostDownloadFileAsync(path, System.Net.Http.HttpMethod.Post, LocalFile.Config.ApiIpHost + "PDAStocktaking/exportStocktakingInfos", body);
|
||||
Growl.Success("导出成功!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("导出失败:" + ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PageOperation 分页操作
|
||||
|
@ -137,6 +137,13 @@
|
||||
Foreground="WhiteSmoke"
|
||||
Command="{Binding BtnDeleteCommand}"
|
||||
Style="{StaticResource ButtonDanger}"></Button>
|
||||
|
||||
<Button MinHeight="40" FontSize="18" Margin="5"
|
||||
Content="导 出" FontFamily="{StaticResource IconFont}"
|
||||
Command="{Binding BtnExportCommand}"
|
||||
Foreground="WhiteSmoke"
|
||||
Background="DarkOrange">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<DataGrid Grid.Row="1"
|
||||
SelectionChanged="DataGrid_SelectionChanged"
|
||||
|
Reference in New Issue
Block a user