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

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

@ -21,9 +21,14 @@ namespace SlnMesnac.Repository.service.Impl
}
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 = 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;
}
@ -39,17 +44,21 @@ namespace SlnMesnac.Repository.service.Impl
{
List<LogoIdentify> list = null;
if(time1 == null && time2 == null){
list = _rep.GetList();
}else if (time1 == null)
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)
{
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)
{
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
{
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;

@ -34,9 +34,10 @@
</StackPanel>
<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"/>
</Grid>
<TextBlock Grid.Column="0" Text="{Binding Date}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" Text="{Binding Time}" FontSize="25" Foreground="White" FontWeight="Bold" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>

@ -11,6 +11,11 @@ namespace SlnMesnac.WPF.Models
public int No { get; set; }
public string MaterialType { 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>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Converter\**" />
<Compile Remove="Page\**" />

@ -120,21 +120,32 @@ namespace SlnMesnac.WPF.ViewModel
public async void RefreshDataGrid()
{
List<LogoIdentify> list = await logoIdentifyService.GetAllRecordAsync();
if (list == null || list.Count == 0) return;
LogoIdentifyDataGrid.Clear();
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
try
{
await Task.Run(async() =>
{
LogoIdentifyDataGrid.Clear();
list = list.OrderByDescending(x=>x.RecordTime).ToList();
foreach (LogoIdentify verify in list)
List<LogoIdentify> list = await logoIdentifyService.GetAllRecordAsync();
if (list == null || list.Count == 0) return;
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
LogoIdentifyDataGrid.Add(verify);
}
}));
LogoIdentifyDataGrid.Clear();
LogoIdentifyDataGrid.Clear();
list = list.OrderByDescending(x => x.RecordTime).ToList();
foreach (LogoIdentify verify in list)
{
LogoIdentifyDataGrid.Add(verify);
}
}));
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
#region 界面刷新

@ -84,6 +84,7 @@ namespace SlnMesnac.WPF.ViewModel
}
private void Timer_Tick(object sender, EventArgs e)
{
Date = DateTime.Now.ToString("yyyy年MM月dd日");
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;

@ -61,7 +61,8 @@ namespace SlnMesnac.WPF.ViewModel
Select(x => new {
ProductModel = x.Key,
MaterialType = x.FirstOrDefault().MaterialType,
Amount = x.Count()
Amount = x.Count(),
PassAmount = x.Where(s=> s.Result == 1).Count(),
}).ToList();
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
@ -69,7 +70,7 @@ namespace SlnMesnac.WPF.ViewModel
int index = 1;
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/>
</Grid.RowDefinitions>
<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 BoxTime,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel>
@ -216,7 +216,7 @@
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</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 MaterialName}" Header="产品名称" Width="2*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding isChecked, Converter={StaticResource IsCheckedConverter}}" Header="是否检测" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />

@ -182,10 +182,12 @@
<DataGrid.Columns>
<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 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>
</UniformGrid>

Loading…
Cancel
Save