add-按型号统计界面添加型号编码

master
liuwf 5 months ago
parent 9b1eecf2b2
commit 9017d80757

@ -104,6 +104,10 @@ namespace SlnMesnac.Business
/// <param name="ip"></param>
public async void BarCodeHandler(string materialCodeStr, string ip)
{
#region 复位报警灯
// 声光电报警复位
gunHelper.SendData("OK");
#endregion
Console.WriteLine("相机流程开始:");
// 传入照片
byte[] ImageData = null;
@ -125,6 +129,12 @@ namespace SlnMesnac.Business
//2.根据箱体码查询型号根据型号判断是否需要校验LOGO
ProductModel mode = logoConfigService.GetMaterialTypeByBarCode(materialCodeStr);
if(mode == null)
{
// 根据成品码查询不到型号
Warning($"根据成品码{materialCodeStr}查询不到型号,检查网络!");
return;
}
LogoConfig logoConfig = logoConfigService.GetByMaterialType(mode.MaterialCode);
// 海康校验结果
bool hikFlag = false;
@ -141,13 +151,13 @@ namespace SlnMesnac.Business
{
//校验成功放行
RefreshMessageEvent?.Invoke("Logo识别成功,下发放行");
RefreshMessageEvent?.Invoke("LOGO+PCI识别成功,下发放行");
logger.LogInformation($"箱体码:{materialCodeStr}Logo识别成功下发放行");
}
else
{
//校验失败禁止放行
WarningAndStop($"Logo识别失败,禁止放行");
WarningAndStop($"LOGO+PCI识别失败,禁止放行");
}
}
else
@ -155,7 +165,7 @@ namespace SlnMesnac.Business
// 不需要校验
hikFlag = true;
RefreshMessageEvent?.Invoke("Logo无需识别,下发放行");
RefreshMessageEvent?.Invoke("LOGO+PCI无需识别,下发放行");
logger.LogInformation($"箱体码:{materialCodeStr}Logo无需识别下发放行");
}
@ -222,7 +232,7 @@ namespace SlnMesnac.Business
return true;
}
// 检查是否超过两秒
if (stopwatch.ElapsedMilliseconds > 2500)
if (stopwatch.ElapsedMilliseconds > 3000)
{
return false;
}
@ -387,6 +397,14 @@ namespace SlnMesnac.Business
RefreshMessageEvent?.Invoke(message, true);
Stop();
}
public void Warning(string message)
{
logger.LogError(message);
RefreshMessageEvent?.Invoke(message, true);
}
#endregion

@ -75,7 +75,12 @@ FROM
{
string sql = $"SELECT a.BAR_CODE, b.ORDER_NO, b.MATERIAL_CODE,b.MATERIAL_NAME,b.ORDER_QTY FROM IMOS_TM_PRINT_INFO a LEFT JOIN IMOS_PR_ORDER b ON a.ORDER_NUMBER = lpad( b.ORDER_NO, '12', '0' ) WHERE a.BAR_CODE = '{barCode}'";
// 查询MES所有型号
model = _rep.Context.SqlQueryable<ProductModel>(sql).First();
var list = _rep.Context.SqlQueryable<ProductModel>(sql);
if(list==null || list.Count() == 0)
{
return null;
}
model = list.First();
}
catch (Exception ex)
{

@ -17,7 +17,7 @@ namespace SlnMesnac.WPF.ConvertTo
{
if (value is int IsSuccess)
{
return IsSuccess == 1 ? "成功" : "失败";
return IsSuccess == 1 ? "OK" : "NG";
}
return string.Empty; // or handle unexpected value
}

@ -73,6 +73,7 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
@ -102,7 +103,7 @@
</Ellipse>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="能耗相机" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
<TextBlock Text="视觉相机" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
@ -167,6 +168,36 @@
</StackPanel>
</Grid>
</StackPanel>
<StackPanel Grid.Column="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Ellipse Width="30" Height="30">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding DataBaseStatus}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger>
<DataTrigger Binding="{Binding DataBaseStatus}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding DataBaseStatus}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="数据库" FontSize="15" Foreground="#FFFFFF" Margin="2,0,10,0"/>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</StackPanel>

@ -9,6 +9,7 @@ namespace SlnMesnac.WPF.Models
public class ModelCount
{
public int No { get; set; }
public string MaterialType { get; set; }
public string ProductName { get; set; }
public int Amount { get; set; }
}

@ -20,6 +20,7 @@ using System.Collections.ObjectModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -78,7 +79,7 @@ namespace SlnMesnac.WPF.ViewModel
/// <exception cref="NotImplementedException"></exception>
private void Reset()
{
Message = "";
logoBusiness.Pass();
}
@ -150,7 +151,10 @@ namespace SlnMesnac.WPF.ViewModel
RefreshResultColor(isSuccess);
RefreshDataGrid();
if (!isSuccess)
{
ImageData = null;
}
}
/// <summary>

@ -88,6 +88,16 @@ namespace SlnMesnac.WPF.ViewModel
}
#region 参数定义
/// <summary>
/// 数据库状态
/// </summary>
private int _DataBaseStatus = 1;
public int DataBaseStatus
{
get { return _DataBaseStatus; }
set { _DataBaseStatus = value; RaisePropertyChanged(nameof(DataBaseStatus)); }
}
/// <summary>
/// PLC设备状态
/// </summary>

@ -58,14 +58,18 @@ namespace SlnMesnac.WPF.ViewModel
{
var ModelList = list.GroupBy(x => x.MaterialName).
Select(x => new { ProductModel = x.Key, Amount = x.Count() }).ToList();
Select(x => new {
ProductModel = x.Key,
MaterialType = x.FirstOrDefault().MaterialType,
Amount = x.Count()
}).ToList();
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
ModelDataGrid.Clear();
int index = 1;
foreach (var item in ModelList)
{
ModelDataGrid.Add(new ModelCount() { No = index++, ProductName = item.ProductModel, Amount = item.Amount });
ModelDataGrid.Add(new ModelCount() { No = index++, MaterialType = item.MaterialType,ProductName = item.ProductModel, Amount = item.Amount });
}
}));

@ -117,7 +117,7 @@
<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 Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" >
<TextBlock Text="产品型号" FontSize="18" 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="18" Text="{Binding ProductModel,Mode=TwoWay}" BorderBrush="White" Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
<Button Content="复 位" Command="{Binding ResetCommand}"
Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="#FF1CC57B" Width="130" Height="50" Margin="50 0 0 0"/>
@ -150,7 +150,7 @@
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,1,5" >
<Grid>
<TextBlock Text="识别信息" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Text="视觉识别信息" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 80 0">
<TextBlock Text="识别结果" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" />
<!--<TextBlock Text="{Binding ResultTxt,Mode=TwoWay}" FontSize="20" FontWeight="Bold" Foreground="{Binding ResultColor}" VerticalAlignment="Center" Margin="0 0 40 0" />-->
@ -173,8 +173,8 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Visibility="{Binding OKIsVis}" Grid.Row="0" Text="OK" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
<TextBlock Visibility="{Binding NGIsVis}" Grid.Row="1" Text="NG" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="OrangeRed"></TextBlock>
<TextBlock Visibility="{Binding OKIsVis}" Grid.Row="0" Text="OK" FontSize="100" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
<TextBlock Visibility="{Binding NGIsVis}" Grid.Row="1" Text="NG" FontSize="100" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="OrangeRed"></TextBlock>
</Grid >
</Grid>
</Border>

@ -182,6 +182,7 @@
<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 ProductName}" Header="产品型号" Width="3*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />
<DataGridTextColumn Binding="{Binding Amount}" Header="数量" Width="*" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}" />

Loading…
Cancel
Save