add-分垛库调试、测温采集服务添加事务控制

main
liuwf 6 months ago
parent cf01d9af57
commit 51251bbe03

@ -423,7 +423,7 @@ namespace Aucma.Core.Palletiz.Business
RefreshMsgEvent?.Invoke(msg);
return;
}
msg = $"成品码:{asciiStr},仓库区域:{spaceinfo.SpaceArea},匹配货道:{spaceinfo.SpaceCode};旋转:{(spinFlag == 3 ? "0°" : "180°")};下发plc放行信号";
msg = $"成品码:{asciiStr},仓库区域:{spaceinfo.SpaceArea},匹配货道:{spaceinfo.SpaceCode};旋转:{IntToRange(spinFlag)};下发plc放行信号";
RefreshMsgEvent?.Invoke(msg);
DateTime startTime = DateTime.Now;
while (isFlag)
@ -532,6 +532,21 @@ namespace Aucma.Core.Palletiz.Business
return result;
}
public int IntToRange(int range)
{
int result = 0;
switch (range)
{
case 3: result = 0; break;
case 1: result = 90; break;
case 4: result = 180; break;
case 2: result = 270; break;
}
return result;
}
/// <summary>
/// 提取货道号
/// </summary>

@ -123,6 +123,7 @@ namespace Aucma.Core.Palletiz.ViewModels
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
bool flag1 = true;// MvCodeHelper.ConnectionStatus(ip1);
Scanner1State(flag1);
Scanner2State(flag1);
}
#endregion
@ -419,13 +420,13 @@ namespace Aucma.Core.Palletiz.ViewModels
{
if (type)
{
Scanner1UIStatusWb = "扫码器1连接成功";
Scanner1UIStatusWb = "A区域扫码器";
Scanner1UIColor = "Green";
Scanner1UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner1UIStatusWb = "扫码器1状态异常";
Scanner1UIStatusWb = "A区域扫码器";
Scanner1UIColor = "Red";
Scanner1UIIcon = "Assets/Images/Red.png";
}
@ -433,6 +434,67 @@ namespace Aucma.Core.Palletiz.ViewModels
}
#endregion
#region 扫码器2状态
/// <summary>
/// UI 展示状态-文字
/// </summary>
public string _scanner2UIStatusWb;
public string Scanner2UIStatusWb
{
//get { return plcUIStatusWb; }
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
get => _scanner2UIStatusWb;
set => SetProperty(ref _scanner2UIStatusWb, value);
}
/// <summary>
/// UI 展示状态-颜色
/// </summary>
public string _scanner2UIColor;
public string Scanner2UIColor
{
//get { return plcUIColor; }
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
get => _scanner2UIColor;
set => SetProperty(ref _scanner2UIColor, value);
}
/// <summary>
/// UI 展示状态-图标
/// </summary>
public string _scanner2UIIcon;
public string Scanner2UIIcon
{
//get { return plcUIIcon; }
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
get => _scanner2UIIcon;
set => SetProperty(ref _scanner2UIIcon, value);
}
/// <summary>
/// 扫码器1连接状态-true:连接成功false:失败
/// </summary>
/// <param name="type"></param>
public void Scanner2State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
Scanner1UIStatusWb = "B区域扫码器";
Scanner1UIColor = "Green";
Scanner1UIIcon = "Assets/Images/Green.png";
}
else
{
Scanner1UIStatusWb = "B区域扫码器";
Scanner1UIColor = "Red";
Scanner1UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 刷新时间
public string _currentDateTime;

@ -261,7 +261,7 @@
<ContentControl x:Name="ctrl" Height="{Binding ActualHeight, ElementName=areaB_outerBorder}" Margin="5,5">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Width" Value="55" />
<Setter Property="Width" Value="65" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
@ -274,7 +274,7 @@
<TextBlock Text="{Binding SpaceCode, StringFormat='B{0}'}" Foreground="White" FontSize="18" FontWeight="Bold" />
</StackPanel>
<WrapPanel Width="35" Height="{Binding ActualHeight, ElementName=areaB_outerBorder}" Orientation="Vertical">
<WrapPanel Width="45" Height="{Binding ActualHeight, ElementName=areaB_outerBorder}" Orientation="Vertical">
<!--<TextBlock Text="BC/BD-100T" Foreground="White" FontSize="18" FontWeight="Bold" Width="50" Height="200" Background="Red"/>-->
<TextBlock Text="{Binding typeNameA}" Width="25" Foreground="White" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Left" TextWrapping="Wrap">
</TextBlock>

@ -87,6 +87,13 @@
</Border>
<TextBlock x:Name="Scanner1" Text="{Binding Scanner1UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner1UIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="Scanner2Status" ImageSource="{Binding Scanner2IIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="Scanner2" Text="{Binding Scanner2UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Scanner2UIColor}" FontSize="15" Margin="10,0"/>
</StackPanel>
</Grid>
</Border>

@ -71,6 +71,11 @@ namespace Aucma.Core.PalletizCX1.Business
public delegate void RefreshMsg(string msg);
public static event RefreshMsg? RefreshMsgEvent;
/// <summary>
/// 提示信息刷新
/// </summary>
public delegate void RefreshAreaMsg(string area,string msg);
public static event RefreshAreaMsg? RefreshAreaMsgEvent;
/// <summary>
///入库时DataGrid添加一条DataGrid记录
@ -146,6 +151,7 @@ namespace Aucma.Core.PalletizCX1.Business
/// <param name="asciiStr">20位是正常扫码传输的条码,手动入库传的是人工选择的成品型号</param>
private void InStore(string spaceArea, string asciiStr)
{
RefreshAreaMsgEvent?.Invoke(spaceArea, "");
#region 未登录禁止入库
if (string.IsNullOrEmpty(appConfig.TeamName))
{
@ -204,7 +210,7 @@ namespace Aucma.Core.PalletizCX1.Business
}
RefreshProductInfoEvent?.Invoke(asciiStr, prodInfo.ProductModel, prodInfo.ProductOrderNo);
RefreshAreaMsgEvent?.Invoke(spaceArea, prodInfo.ProductModel);
bool getSpaceResult = GetSpaceInfoByMaterialType(spaceArea, prodInfo, out BaseSpaceInfo laseSpaceinfo,
out BaseSpaceInfo spaceinfo);
if (!getSpaceResult)
@ -271,7 +277,7 @@ namespace Aucma.Core.PalletizCX1.Business
}
_ = _recordInstoreServices.AddAsync(recordInstore).Result;
RefreshAreaMsgEvent?.Invoke(spaceArea, "");
}
catch (Exception e)

@ -30,6 +30,7 @@ namespace Aucma.Core.PalletizCX1.ViewModels
//this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>();
//this.inStoreBusiness.Init();
InStoreBusiness.RefreshMsgEvent += RefreshMsg;
InStoreBusiness.RefreshAreaMsgEvent += RefreshAreaMsg;
InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo;
UpdateInStoreFlagCommand = new RelayCommand<Int32>(obj =>
{
@ -97,6 +98,31 @@ namespace Aucma.Core.PalletizCX1.ViewModels
set => SetProperty(ref msg, value);
}
#region 提示上次库满时型号
public string msgA = string.Empty;
public string MsgA
{
get { return this.msgA; }
set => SetProperty(ref msgA, value);
}
public string msgB = string.Empty;
public string MsgB
{
get { return this.msgB; }
set => SetProperty(ref msgB, value);
}
public string msgC = string.Empty;
public string MsgC
{
get { return this.msgC; }
set => SetProperty(ref msgC, value);
}
#endregion
public string inStoreAmount = "入库数量:";
public string InStoreAmount
{
@ -171,6 +197,24 @@ namespace Aucma.Core.PalletizCX1.ViewModels
{
Msg = msg;
}
/// <summary>
/// 刷新界面提示信息
/// </summary>
/// <param name="msg"></param>
public void RefreshAreaMsg(string Area, string msg)
{
if (Area == "A"){
MsgA = msg;
}else if (Area == "B")
{
MsgB = msg;
}else if (Area == "C")
{
MsgC = msg;
}
}
/// <summary>
/// 刷新界面扫码信息
/// </summary>

@ -151,12 +151,20 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" Margin="30 0 0 0" Orientation="Horizontal">
<TextBlock Text="C区域" Foreground="White" FontSize="30" />
<TextBlock Text="{Binding MsgC,Mode=TwoWay}" Foreground="White" FontSize="30" Margin="60,0,0,0"/>
</StackPanel>
<TextBlock Grid.Column="0" Text="C区域" Foreground="White" FontSize="30" VerticalAlignment="Center" Margin="30 0 0 0"/>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="30 0 0 0" Orientation="Horizontal">
<TextBlock Text="B区域" Foreground="White" FontSize="30" />
<TextBlock Text="{Binding MsgB,Mode=TwoWay}" Foreground="White" FontSize="30" Margin="60,0,0,0"/>
</StackPanel>
<TextBlock Grid.Column="1" Text="B区域" Foreground="White" FontSize="30" VerticalAlignment="Center" Margin="30 0 0 0"/>
<TextBlock Grid.Column="2" Text="A区域" Foreground="White" FontSize="30" VerticalAlignment="Center" Margin="30 0 0 0"/>
<StackPanel Grid.Column="2" VerticalAlignment="Center" Margin="30 0 0 0" Orientation="Horizontal">
<TextBlock Text="A区域" Foreground="White" FontSize="30" />
<TextBlock Text="{Binding MsgA,Mode=TwoWay}" Foreground="White" FontSize="30" Margin="60,0,0,0"/>
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="3" BorderBrush="#1157b9" BorderThickness="0" Margin="0,5,0,5">

@ -4,6 +4,7 @@ using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using log4net;
using Serilog;
using SqlSugar;
using StackExchange.Profiling.Internal;
using System.Collections.Generic;
using System.Timers;
@ -24,15 +25,15 @@ namespace Aucma.Core.TemperatureTask
private readonly IMaterialCompletionServices _materialCompletionServices;
private readonly IPrintBarCodeServices _printBarCodeServices;
private readonly IReportQualityInspectionServices _reportQualityInspectionServices;
private ISqlSugarClient sqlSugarClient;
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
bool flag = true;
public AucamTemperatureMeasurementService(ITemperatureHistoryServices temperatureHistoryServices,
ITestedCodeMESServices codeMESServices, IMaterialCompletionServices materialCompletionServices,
IPrintBarCodeServices printBarCodeServices, IReportQualityInspectionServices reportQualityInspectionServices)
IPrintBarCodeServices printBarCodeServices, IReportQualityInspectionServices reportQualityInspectionServices, ISqlSugarClient _sqlSugarClient)
{
_codeMESServices = codeMESServices;
sqlSugarClient = _sqlSugarClient;
_codeMESServices = codeMESServices;
_temperatureHistoryServices = temperatureHistoryServices;
_materialCompletionServices = materialCompletionServices;
_printBarCodeServices = printBarCodeServices;
@ -52,16 +53,18 @@ namespace Aucma.Core.TemperatureTask
/// 采集任务处理
/// </summary>
/// <returns></returns>
private async void Run(object? sender, ElapsedEventArgs e)
private void Run(object? sender, ElapsedEventArgs e)
{
try
{
if (flag)
{
try
{
flag = false;
sqlSugarClient.AsTenant().BeginTran();
var historyList = _codeMESServices.QueryAsync(d => d.IsSync == 0).Result;
if (historyList == null || historyList.Count == 0) return;
Console.WriteLine($"【{DateTime.Now}】开始读取测温数据");
@ -114,13 +117,19 @@ namespace Aucma.Core.TemperatureTask
}
}
Console.WriteLine($"【{DateTime.Now}】测温数据同步成功!数量:{query.Count}");
sqlSugarClient.AsTenant().CommitTran();
}
catch (Exception ex)
{
sqlSugarClient.AsTenant().RollbackTran();
Console.WriteLine($"【{DateTime.Now}】 {ex.Message}");
logHelper.Error(ex.Message);
}
finally { flag = true; }
finally {
flag = true;
}
}
}
catch (Exception ex)

Loading…
Cancel
Save