liulb@mesnac.com 9 months ago
commit e504baced2

@ -162,15 +162,15 @@ namespace Admin.Core.Socket
/// <param name="client"></param>
private void SetProdStoreClientId(SocketClient client)
{
if (client.IP == "10.10.92.230" || client.IP == "10.10.92.240")
if (client.IP == "10.10.92.230" || client.IP == "10.10.97.42")
{
client.ResetId("A");
}
else if (client.IP == "10.10.92.231" || client.IP == "10.10.92.241")
else if (client.IP == "10.10.92.231" || client.IP == "10.10.97.43")
{
client.ResetId("B");
}
else if(client.IP == "10.10.92.242")
else if(client.IP == "10.10.97.44")
{
client.ResetId("C");
}

@ -237,7 +237,7 @@ namespace Aucma.Core.BoxFoam.Business
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = obj.plc.ReadString("DB400.16.0");
item.MaterialType = foamLine1.plc.ReadString("DB400.16.0").Replace("\n","");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode001 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;
@ -257,7 +257,7 @@ namespace Aucma.Core.BoxFoam.Business
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = obj.plc.ReadString("DB400.28.0");
item.MaterialType = foamLine1.plc.ReadString("DB400.28.0").Replace("\n", "");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode002 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;
@ -277,7 +277,7 @@ namespace Aucma.Core.BoxFoam.Business
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = obj.plc.ReadString("DB400.40.0");
item.MaterialType = foamLine1.plc.ReadString("DB400.40.0").Replace("\n", "");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode003 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;
@ -297,7 +297,7 @@ namespace Aucma.Core.BoxFoam.Business
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = obj.plc.ReadString("DB400.28.0");
item.MaterialType = foamLine1.plc.ReadString("DB400.52.0").Replace("\n", "");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode004 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;
@ -316,7 +316,7 @@ namespace Aucma.Core.BoxFoam.Business
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = obj.plc.ReadString("DB400.52.0");
item.MaterialType = foamLine1.plc.ReadString("DB400.64.0").Replace("\n", "");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode005 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;
@ -331,11 +331,12 @@ namespace Aucma.Core.BoxFoam.Business
case "PB01_006":
item.SpaceStock = obj.plc.ReadInt16("DB200.450");
item.OnRouteAmount = item.SpaceStock - obj.plc.ReadInt16("DB200.98");
item.MaterialType = obj.plc.ReadString("DB400.64.0");
if (foamLine1 != null)
{
if (foamLine1.plc.IsConnected)
{
item.MaterialType = foamLine1.plc.ReadString("DB400.76.0").Replace("\n", "");
if (!string.IsNullOrEmpty(item.MaterialType))
{
var printBarCode006 = _printBarCodeServices.FirstAsync(d => d.MaterialCode == item.MaterialType).Result;

@ -94,7 +94,7 @@
<!--控件模板-->
<ItemsControl.ItemTemplate>
<DataTemplate>
<Control x:Name="ctrl" Width="600" Height="400" VerticalAlignment="Top"></Control>
<Control x:Name="ctrl" Width="600" Height="200" VerticalAlignment="Center"></Control>
<DataTemplate.Triggers>
<!--根据不同类型选择不同模板-->
<DataTrigger Binding="{Binding spaceType}" Value="1">
@ -106,7 +106,7 @@
<Grid Margin="3,3">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="3*"/>
<!--<RowDefinition Height="3*"/>-->
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
@ -133,7 +133,7 @@
<TextBlock Text="在途" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
<TextBlock Text="{Binding onRouteAmount}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding onTheWay}" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="5" BorderBrush="White" BorderThickness="1">
<TextBlock Text="合计" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
@ -147,8 +147,8 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<!--<RowDefinition/>
<RowDefinition/>-->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
@ -160,7 +160,7 @@
<TextBlock Text="型号" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="0" BorderBrush="White" BorderThickness="1">
<TextBlock Text="{Binding materialType}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBlock Text="{Binding materialType}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<!--<Button Command="{Binding DataContext.SubmitCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent" Height="auto">
<TextBlock Text="{Binding materialType}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>-->
@ -209,16 +209,16 @@
</Grid>
</Border>
<Border Grid.Row="2">
<!--<Border Grid.Row="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<!--<ColumnDefinition/>-->
--><!--<ColumnDefinition/>-->
<!--<ColumnDefinition/>
<ColumnDefinition/>-->
<ColumnDefinition/>--><!--
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="White" BorderThickness="1" >
@ -235,7 +235,7 @@
<Border Grid.Column="3" BorderBrush="White" BorderThickness="1">
</Border>
<!--<Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
--><!--<Border Grid.Column="4" BorderBrush="White" BorderThickness="1">
</Border>-->
<!--<Border Grid.Column="5" BorderBrush="White" BorderThickness="1">
@ -245,9 +245,9 @@
</Border>-->
<!--<Border Grid.Column="6" BorderBrush="White" BorderThickness="1">
</Border>-->
</Border>--><!--
</Grid>
</Border>
</Border>-->
</Grid>
</Border>
</ControlTemplate>

@ -234,7 +234,7 @@ namespace Aucma.Core.HwPLc
string returnflag = "";
try
{
OperateResult<string> read = siemensS7Net.ReadString(address, 10);
OperateResult<string> read = siemensS7Net.ReadString(address, 12);
if (read.IsSuccess)
{
returnflag = read.Content;

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>

@ -26,6 +26,17 @@ namespace Aucma.Core.PalletizCX1.Business
{
internal class InStoreBusiness
{
#region 单例实现
private static readonly InStoreBusiness lazy = new InStoreBusiness();
public static InStoreBusiness Instance
{
get
{
return lazy;
}
}
#endregion
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(InStoreBusiness));
private readonly IProductOffLineServices _offlineService;
@ -67,11 +78,13 @@ namespace Aucma.Core.PalletizCX1.Business
#endregion
/// <summary>
/// 记录三个区域上一次扫描条码,条码防抖
/// </summary>
private static Dictionary<string, string> lastCodeKeys = new Dictionary<string, string>();
// private const string BarcodeRef = "6933973114570;1621240AP0098E3D3497";
private PlcModel plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc"));
public InStoreBusiness()
{
@ -79,12 +92,14 @@ namespace Aucma.Core.PalletizCX1.Business
_spaceinfoService = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
_offlineService = App.ServiceProvider.GetService<IProductOffLineServices>();
HandPalletizViewModel.HandSendEvent += InStore;
// string AA = ExtractNumber("FD01_012");
}
public void Init()
{
TouchSocketService.ReceivedClientBufferEvent += ReceivedBuffer;
}
/// <summary>
@ -131,6 +146,26 @@ namespace Aucma.Core.PalletizCX1.Business
{
Task.Run(() =>
{
if (asciiStr.Length == 20)
{
if (lastCodeKeys.TryGetValue(spaceArea, out string lastcode))
{
if (lastcode == asciiStr)
{
//和上次一样不做处理
return;
}
else
{ // 更新值
lastCodeKeys[spaceArea] = lastcode;
}
}
else
{
lastCodeKeys.Add(spaceArea, asciiStr);
}
}
RecordInStore recordInstore = new RecordInStore();
String msg = string.Empty;
try
@ -144,6 +179,7 @@ namespace Aucma.Core.PalletizCX1.Business
{
throw new ArgumentException($"{spaceArea}货道区域为空");
}
if (spaceArea == "C") return;
_offlineService.GetProductInfosBySnCode(asciiStr, out ProductOffline prodInfo);
@ -168,7 +204,7 @@ namespace Aucma.Core.PalletizCX1.Business
bool result = false;
SendInStoreTask(asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range);
#region 添加入库记录
@ -300,7 +336,7 @@ namespace Aucma.Core.PalletizCX1.Business
spaceinfos = spaceinfos.OrderBy(x => x.ObjId).ToList();
MatchSpaceInfoByPlc(ref spaceinfos);
MatchSpaceInfoByPlc(spaceArea, ref spaceinfos);
if (spaceinfos == null || spaceinfos.Count==0)
{
@ -323,13 +359,21 @@ namespace Aucma.Core.PalletizCX1.Business
}
public PlcModel GetPlcByArea(string spaceArea)
{
PlcModel plcCon = null;
plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc"));
return plcCon;
}
/// <summary>
/// 通过PLC匹配获取去除已满的货道
/// </summary>
/// <param name="spaceinfos"></param>
private void MatchSpaceInfoByPlc(ref List<BaseSpaceInfo> spaceinfos)
private void MatchSpaceInfoByPlc(string spaceArea,ref List<BaseSpaceInfo> spaceinfos)
{
PlcModel plcCon = GetPlcByArea(spaceArea);
if (plcCon == null)
{
Task.Delay(1000 * 3).Wait();
@ -396,6 +440,7 @@ namespace Aucma.Core.PalletizCX1.Business
{
int spinFlag = -1;
rangeResult = 0;
PlcModel plcCon = GetPlcByArea(spaceinfo.SpaceArea);
if (plcCon == null)
{
throw new ArgumentException($"成品码:{asciiStr},仓库区域:{spaceinfo.SpaceArea},匹配货道:{spaceinfo.SpaceCode}下发入库任务至PLC逻辑异常:Plc连接为空");
@ -427,11 +472,11 @@ namespace Aucma.Core.PalletizCX1.Business
bool answerFlag = false;
if(spaceinfo.SpaceArea == "A")
{
answerFlag = _plc.ReadBool("B1000");
answerFlag = _plc.ReadBool("B1001");
}
else if(spaceinfo.SpaceArea == "B")
{
answerFlag = _plc.ReadBool("B1001");
answerFlag = _plc.ReadBool("B1002");
}
else if(spaceinfo.SpaceArea =="C")
{
@ -443,29 +488,28 @@ namespace Aucma.Core.PalletizCX1.Business
isFlag = false;
}
Task.Delay(500).Wait();
}
Console.WriteLine("下传PLC开始");
if (spaceinfo.SpaceArea == "A")
{
if (!_plc.WriteInt16("D2", spinFlag.ToString()))
if (!_plc.WriteInt16("D2002", spinFlag.ToString()))
{
throw new ArgumentException($"A区域旋转角度下发至PLC失败");
}
if (!_plc.WriteInt16("D29", spaceCode.ToString()))
if (!_plc.WriteInt16("D9", spaceCode.ToString()))
{
throw new ArgumentException($"A区域货道号下发至PLC失败");
}
_plc.WriteInt16("B1001", "1");//发送完成信号
_plc.WriteInt16("B1201", "1");//发送完成信号
result = true;
}
else if (spaceinfo.SpaceArea == "B")
{
if (!_plc.WriteInt16("D2", spinFlag.ToString()))
if (!_plc.WriteInt16("D1002", spinFlag.ToString()))
{
throw new ArgumentException($"B区域旋转角度下发至PLC失败");
}
@ -474,7 +518,7 @@ namespace Aucma.Core.PalletizCX1.Business
throw new ArgumentException($"B区域货道号下发至PLC失败");
}
_plc.WriteInt16("B1001", "1");//发送完成信号
_plc.WriteInt16("B1102", "1");//发送完成信号
result = true;
}

@ -96,7 +96,7 @@ namespace Aucma.Core.PalletizCX1.ViewModels
/// 分垛信息下传
/// </summary>
[RelayCommand]
public void Save(Window window)
public void Save(Window window)
{
if (Area == null)
{
@ -108,11 +108,12 @@ namespace Aucma.Core.PalletizCX1.ViewModels
MessageBox.Show("请先选择产品型号");
return;
}
HandSendEvent?.Invoke(Area.Content.ToString(), productCode);
MessageBox.Show("手动入库成功");
window.Close();
// 入库
HandSendEvent?.Invoke(Area.Content.ToString(), productCode);
window.Close();
}

@ -19,15 +19,16 @@ namespace Aucma.Core.PalletizCX1.ViewModels
{
internal class IndexControlViewModel : ObservableObject
{
private InStoreBusiness inStoreBusiness;
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
public IndexControlViewModel()
{
new InStoreBusiness().Init();
inStoreBusiness.Init();
SelectTypeViewModel.RefreshPageEvent += Init;
StatisticsPageViewModel.CountInstoreEvent += CountInstore;
this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>();
//this.inStoreBusiness = App.ServiceProvider.GetService<InStoreBusiness>();
//this.inStoreBusiness.Init();
InStoreBusiness.RefreshMsgEvent += RefreshMsg;
InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo;
UpdateInStoreFlagCommand = new RelayCommand<Int32>(obj =>

@ -199,8 +199,9 @@
"EquipName": "InStoreAPlc",
"PlcType": "Melsec",
"Enabled": true,
"IP": "10.10.92.80", //10.10.92.80
"Port": 2014
// "IP": "127.0.0.1",
"IP": "10.10.97.1",
"Port": 2015
},
{
"Id": 2,

@ -61,20 +61,37 @@ namespace Aucma.Core.PalletizCX1.config
public List<PlcConfig> plcAddr = new List<PlcConfig>()
{
new PlcConfig(){spaceCode = 1,spaceArea = "A",address = "X10D3"},
new PlcConfig(){spaceCode = 2,spaceArea = "A",address = "X10D9"},
new PlcConfig(){spaceCode = 3,spaceArea = "A",address = "X10E3"},
new PlcConfig(){spaceCode = 4,spaceArea = "A",address = "X10E9"},
new PlcConfig(){spaceCode = 5,spaceArea = "A",address = "X10F3"},
new PlcConfig(){spaceCode = 6,spaceArea = "A",address = "X10F9"},
new PlcConfig(){spaceCode = 7,spaceArea = "A",address = "X1103"},
new PlcConfig(){spaceCode = 8,spaceArea = "A",address = "X1109"},
new PlcConfig(){spaceCode = 9,spaceArea = "A",address = "X1113"},
new PlcConfig(){spaceCode = 10,spaceArea = "A",address = "X1119"},
new PlcConfig(){spaceCode = 11,spaceArea = "A",address = "X1123"},
new PlcConfig(){spaceCode = 12,spaceArea = "A",address = "X1129"},
new PlcConfig(){spaceCode = 13,spaceArea = "A",address = "X1133"},
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X1139"}
new PlcConfig(){spaceCode = 1,spaceArea = "B",address = "X1077"},
new PlcConfig(){spaceCode = 2,spaceArea = "B",address = "X107D"},
new PlcConfig(){spaceCode = 3,spaceArea = "B",address = "X1083"},
new PlcConfig(){spaceCode = 4,spaceArea = "B",address = "X1089"},
new PlcConfig(){spaceCode = 5,spaceArea = "B",address = "X1093"},
new PlcConfig(){spaceCode = 6,spaceArea = "B",address = "X1099"},
new PlcConfig(){spaceCode = 7,spaceArea = "B",address = "X10A3"},
new PlcConfig(){spaceCode = 8,spaceArea = "B",address = "X10A9"},
new PlcConfig(){spaceCode = 9,spaceArea = "B",address = "X10B3"},
new PlcConfig(){spaceCode = 10,spaceArea = "B",address = "X10B9"},
new PlcConfig(){spaceCode = 11,spaceArea = "B",address = "X10C3"},
new PlcConfig(){spaceCode = 12,spaceArea = "B",address = "X10C9"},
new PlcConfig(){spaceCode = 13,spaceArea = "B",address = "X10D3"},
new PlcConfig(){spaceCode = 14,spaceArea = "B",address = "X10D9"},
new PlcConfig(){spaceCode = 1,spaceArea = "A",address = "X115"},
new PlcConfig(){spaceCode = 2,spaceArea = "A",address = "X11B"},
new PlcConfig(){spaceCode = 3,spaceArea = "A",address = "X123"},
new PlcConfig(){spaceCode = 4,spaceArea = "A",address = "X129"},
new PlcConfig(){spaceCode = 5,spaceArea = "A",address = "X133"},
new PlcConfig(){spaceCode = 6,spaceArea = "A",address = "X139"},
new PlcConfig(){spaceCode = 7,spaceArea = "A",address = "X143"},
new PlcConfig(){spaceCode = 8,spaceArea = "A",address = "X149"},
new PlcConfig(){spaceCode = 9,spaceArea = "A",address = "X153"},
new PlcConfig(){spaceCode = 10,spaceArea = "A",address = "X159"},
new PlcConfig(){spaceCode = 11,spaceArea = "A",address = "X163"},
new PlcConfig(){spaceCode = 12,spaceArea = "A",address = "X169"},
new PlcConfig(){spaceCode = 13,spaceArea = "A",address = "X173"},
new PlcConfig(){spaceCode = 14,spaceArea = "A",address = "X179"}
};

@ -543,7 +543,7 @@ namespace Aucma.Core.ProductOffLine.Business
log.Info(TempOffLineInfo.ProductSNCode + "条码绑定工位未查询到条码绑定记录,请拆掉包装重新绑定");
AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo,3);
speechStr.SpeakAsync("条码未绑定,请回到绑定工位");
// return false;
return false;
}
if (bindingRecord1 != null)

Loading…
Cancel
Save