change-优化历史记录查询速度,去除查询照片列

add- 界面统计添加通过率字段
master
liuwf 5 months ago
parent 3d6a2c0436
commit fe8c547ab5

@ -22,8 +22,13 @@ namespace SlnMesnac.Repository.service.Impl
public async Task<List<LogoIdentify>> GetAllRecordAsync() public async Task<List<LogoIdentify>> GetAllRecordAsync()
{ {
//List<LogoIdentify> list = null;
//list = await _rep.GetListAsync(x => x.RecordTime >= DateTime.Now.AddDays(-3));
//return list;
List<LogoIdentify> list = null; List<LogoIdentify> list = null;
list = await _rep.GetListAsync(); list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-3) });
return list; return list;
} }
@ -39,17 +44,21 @@ namespace SlnMesnac.Repository.service.Impl
{ {
List<LogoIdentify> list = null; List<LogoIdentify> list = null;
if(time1 == null && time2 == null){ if(time1 == null && time2 == null){
list = _rep.GetList(); list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-1) });
}else if (time1 == null) }
else if (time1 == null)
{ {
list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList(); list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME <= @RecordTime ", new { RecordTime = DateTime.Parse(time2) });
// list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList();
}else if (time2 == null) }else if (time2 == null)
{ {
list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList(); list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Parse(time1) });
// list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList();
} }
else else
{ {
list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList(); list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime1 AND RECORD_TIME <= @RecordTime2 ", new { RecordTime1 = DateTime.Parse(time1), RecordTime2 = DateTime.Parse(time2) });
// list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList();
} }
return list; return list;

@ -34,9 +34,10 @@
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right"> <StackPanel Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right">
<Grid>
<TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/> <TextBlock Grid.Column="0" Text="{Binding Date}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
</Grid> <TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -11,6 +11,11 @@ namespace SlnMesnac.WPF.Models
public int No { get; set; } public int No { get; set; }
public string MaterialType { get; set; } public string MaterialType { get; set; }
public string ProductName { get; set; } public string ProductName { get; set; }
public int Amount { get; set; } //总数量
public int TotalAmount { get; set; }
//合格通过数
public int PassAmount { get; set; }
//合格通过率
public string PassRate { get; set; }
} }
} }

@ -7,6 +7,14 @@
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Converter\**" /> <Compile Remove="Converter\**" />
<Compile Remove="Page\**" /> <Compile Remove="Page\**" />

@ -121,12 +121,17 @@ namespace SlnMesnac.WPF.ViewModel
public async void RefreshDataGrid() public async void RefreshDataGrid()
{ {
try
{
await Task.Run(async() =>
{
List<LogoIdentify> list = await logoIdentifyService.GetAllRecordAsync(); List<LogoIdentify> list = await logoIdentifyService.GetAllRecordAsync();
if (list == null || list.Count == 0) return; if (list == null || list.Count == 0) return;
LogoIdentifyDataGrid.Clear();
await App.Current.Dispatcher.BeginInvoke((Action)(() => await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
LogoIdentifyDataGrid.Clear();
LogoIdentifyDataGrid.Clear(); LogoIdentifyDataGrid.Clear();
list = list.OrderByDescending(x => x.RecordTime).ToList(); list = list.OrderByDescending(x => x.RecordTime).ToList();
foreach (LogoIdentify verify in list) foreach (LogoIdentify verify in list)
@ -134,6 +139,12 @@ namespace SlnMesnac.WPF.ViewModel
LogoIdentifyDataGrid.Add(verify); LogoIdentifyDataGrid.Add(verify);
} }
})); }));
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
} }

@ -84,6 +84,7 @@ namespace SlnMesnac.WPF.ViewModel
} }
private void Timer_Tick(object sender, EventArgs e) private void Timer_Tick(object sender, EventArgs e)
{ {
Date = DateTime.Now.ToString("yyyy年MM月dd日");
Time = DateTime.Now.ToString("HH:mm:ss"); Time = DateTime.Now.ToString("HH:mm:ss");
} }
@ -138,6 +139,16 @@ namespace SlnMesnac.WPF.ViewModel
} }
} }
private string _Date;
public string Date
{
get { return _Date; }
set
{
_Date = value;
RaisePropertyChanged(nameof(Date));
}
}
public System.Windows.Controls.UserControl _content; public System.Windows.Controls.UserControl _content;

@ -61,7 +61,8 @@ namespace SlnMesnac.WPF.ViewModel
Select(x => new { Select(x => new {
ProductModel = x.Key, ProductModel = x.Key,
MaterialType = x.FirstOrDefault().MaterialType, MaterialType = x.FirstOrDefault().MaterialType,
Amount = x.Count() Amount = x.Count(),
PassAmount = x.Where(s=> s.Result == 1).Count(),
}).ToList(); }).ToList();
App.Current.Dispatcher.BeginInvoke((Action)(() => App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
@ -69,7 +70,7 @@ namespace SlnMesnac.WPF.ViewModel
int index = 1; int index = 1;
foreach (var item in ModelList) foreach (var item in ModelList)
{ {
ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, Amount = item.Amount }); ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, TotalAmount = item.Amount ,PassAmount = item.PassAmount ,PassRate = ((double)item.PassAmount / item.Amount).ToString("P2") });
} }
})); }));

@ -112,7 +112,7 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" > <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" >
<TextBlock Text="产品码" FontSize="20" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 30 0"/> <TextBlock Text="产品码" FontSize="20" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 30 0"/>
<TextBox FontSize="20" Text="{Binding BoxCode,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 10 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" /> <TextBox FontSize="20" Text="{Binding BoxCode,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 10 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
<TextBox FontSize="20" Text="{Binding BoxTime,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBox FontSize="20" Text="{Binding BoxTime,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel> </StackPanel>
@ -216,7 +216,7 @@
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding ProductCode}" Header="箱体码" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/> <DataGridTextColumn Binding="{Binding ProductCode}" Header="产品条码" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding MaterialType}" Header="产品型号" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding MaterialType}" Header="产品型号" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding MaterialName}" Header="产品名称" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding MaterialName}" Header="产品名称" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding isChecked, Converter={StaticResource IsCheckedConverter}}" Header="是否检测" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding isChecked, Converter={StaticResource IsCheckedConverter}}" Header="是否检测" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />

@ -182,9 +182,11 @@
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding No}" Header="序号" Width="0.3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding No}" Header="序号" Width="0.3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding MaterialType}" Header="产品编码" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding MaterialType}" Header="产品编码" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding ProductName}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding ProductName}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding Amount}" Header="数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" /> <DataGridTextColumn Binding="{Binding PassAmount}" Header="通过数" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding TotalAmount}" Header="总数量" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding PassRate}" Header="通过率" Width="1.2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

Loading…
Cancel
Save