货架管理的导出
This commit is contained in:
@ -20,6 +20,14 @@ namespace WCS.BLL.Services.IService
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PageQueryResponse<ShelfInfo>> GetShelves(GetShelvesRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 导出货架列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PageQueryResponse<ShelfInfo>> ExportShelves(GetShelvesRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 添加、更新、删除货架
|
||||
/// </summary>
|
||||
|
@ -67,6 +67,48 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<ShelfInfo>> ExportShelves(GetShelvesRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<ShelfInfo>()
|
||||
.WhereIF(request.ShelfTypeId != null, t => t.ShelfTypeId == request.ShelfTypeId)
|
||||
.WhereIF(request.IsEnable != null, t => t.IsEnable == request.IsEnable)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.ShelfCode), t => t.ShelfCode.Contains(request.ShelfCode));
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Take(65535)
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
var index = 1;
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = index++;
|
||||
}
|
||||
return new PageQueryResponse<ShelfInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<ShelfInfo>()
|
||||
{
|
||||
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<ShelfInfo>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
|
||||
{
|
||||
try
|
||||
|
@ -7,6 +7,7 @@ using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
@ -30,6 +31,31 @@ namespace WCS.WebApi.Controllers
|
||||
{
|
||||
return await _storeInfoService.GetShelves(request);
|
||||
}
|
||||
[Route("exportShelves")]
|
||||
[HttpPost(Name = "exportShelves")]
|
||||
public async Task<IActionResult> exportShelves(GetShelvesRequest request)
|
||||
{
|
||||
var result = await _storeInfoService.ExportShelves(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("货架类型","ShelfTypeName"),
|
||||
new ExportableColumn("货架编号","ShelfCode"),
|
||||
new ExportableColumn("货架尺寸","ShelfSize"),
|
||||
new ExportableColumn("备注","Remark"),
|
||||
new ExportableColumn("货架当前状态","ShelfStatus"),
|
||||
new ExportableColumn("启用状态","IsEnableStr"),
|
||||
new ExportableColumn("更新人", "ModifyUser"),
|
||||
new ExportableColumn("更新时间", "ModifyTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateShelfInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
|
||||
|
@ -286,7 +286,6 @@ namespace 智慧物流软件系统.ViewModel
|
||||
|
||||
|
||||
public ICommand BtnExportCommand { get => new DelegateCommand(BtnExport); }
|
||||
|
||||
public async void BtnExport()
|
||||
{
|
||||
try
|
||||
|
@ -281,6 +281,43 @@ namespace 智慧物流软件系统.ViewModel
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
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 body = new GetShelvesRequest()
|
||||
{
|
||||
ShelfTypeId = SelectedShelfTypeItem == null ? null : SelectedShelfTypeItem.Id,
|
||||
ShelfCode = ShelfCode,
|
||||
IsEnable = IsEnable,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageSize = PageSize,
|
||||
};
|
||||
await ApiHelp.PostDownloadFileAsync(path, System.Net.Http.HttpMethod.Post, LocalFile.Config.ApiIpHost + "storeInfo/exportShelves", body);
|
||||
Growl.Success("导出成功!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("导出失败:" + ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PageOperation 分页操作
|
||||
|
@ -59,7 +59,7 @@
|
||||
<ComboBoxItem Tag="True">启用</ComboBoxItem>
|
||||
<ComboBoxItem Tag="False">禁用</ComboBoxItem>
|
||||
</ComboBox>
|
||||
|
||||
|
||||
<Button Style="{StaticResource ButtonSuccess}" hc:BorderElement.CornerRadius="15"
|
||||
Grid.Column="9" MinHeight="40" FontSize="18" Content=" 搜索" FontFamily="{StaticResource IconFont}"
|
||||
Command="{Binding BtnSearchCommand}">
|
||||
@ -98,6 +98,12 @@
|
||||
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"
|
||||
@ -195,95 +201,6 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!--<Border Grid.Row="1" Margin="3" Background="AliceBlue" CornerRadius="3" Padding="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.8*"></RowDefinition>
|
||||
<RowDefinition Height="8*"></RowDefinition>
|
||||
<RowDefinition Height="0.7*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnExportCommand}"
|
||||
Content=" 导 出" FontFamily="{StaticResource IconFont}"
|
||||
Style="{StaticResource ButtonWarning}" Background="DarkOrange">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<DataGrid Grid.Row="1"
|
||||
SelectedCellsChanged="DataGrid_SelectedCellsChanged"
|
||||
ItemsSource="{Binding DataGridItemSource}"
|
||||
RowHeight="39"
|
||||
AutoGenerateColumns="False"
|
||||
FontSize="13">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="接口地址" Binding="{Binding RequestUrl}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="设备IP" Binding="{Binding DeviceIp}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="请求参数" Binding="{Binding RequestBody}" MaxWidth="100"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="QueryString" Binding="{Binding QueryString}" MaxWidth="100"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="请求时间" Binding="{Binding RequestTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="返回参数" Binding="{Binding ResponseJson}" MaxWidth="100"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="返回时间" Binding="{Binding ResponseTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="耗时(ms)" Binding="{Binding ExecutionTime}"></DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Border CornerRadius="3" Background="Transparent" VerticalAlignment="Center" >
|
||||
<Grid HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Top" Width="Auto" MinHeight="26">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<TextBlock FontSize="14" Text="共"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding TotalCount ,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="条记录 "></TextBlock>
|
||||
<TextBlock FontSize="14" Text="第"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding CurrentPage,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="/"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding MaxPage,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="页"></TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions >
|
||||
<RowDefinition Height="30"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="0" Name="btnFirst" Content="首页" Foreground="Black" FontSize="14"
|
||||
Command="{Binding BtnFirstPageCommand}"/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="1" Name="btnPrev" Content="上一页" FontSize="14"
|
||||
Command="{Binding BtnPrePageCommand}"/>
|
||||
<TextBox BorderBrush="Transparent" Grid.Column="2" FontSize="14" MinWidth="50" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="IBeam" IsEnabled="False"
|
||||
Text ="{Binding CurrentPage}" TextAlignment="Center"
|
||||
|
||||
/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="3" Name="btnNext" Content="下一页" FontSize="14"
|
||||
Command="{Binding BtnNextPageCommand}"/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="4" Name="btnLast" Content="末页" FontSize="14"
|
||||
Command="{Binding BtnLastPageCommand}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</pi:UserControlBase>
|
||||
|
Reference in New Issue
Block a user