diff --git a/Admin.Core.Service/Service_New/ProductOffLineServices.cs b/Admin.Core.Service/Service_New/ProductOffLineServices.cs index 8ef43b6b..86a8edf7 100644 --- a/Admin.Core.Service/Service_New/ProductOffLineServices.cs +++ b/Admin.Core.Service/Service_New/ProductOffLineServices.cs @@ -101,7 +101,8 @@ namespace Admin.Core.Service { if (string.IsNullOrEmpty(snCode)) { - throw new ArgumentException($"根据SN条码获取已下线成品信息异常:SN码为空"); + log.Error($"{snCode}根据SN条码获取已下线成品信息异常:SN码为空"); + throw new ArgumentException($"{snCode}根据SN条码获取已下线成品信息异常:SN码为空"); } try @@ -118,7 +119,8 @@ namespace Admin.Core.Service } catch (Exception e) { - throw new InvalidOperationException($"根据SN条码获取已下线成品信息异常:{e.Message}"); + log.Error($"{snCode}根据SN条码获取已下线成品信息异常:{e.Message}"); + throw new InvalidOperationException($"{snCode}根据SN条码获取已下线成品信息异常:{e.Message}"); } } diff --git a/Aucma.Core.PalletizCX1/Business/InstoreBusiness.cs b/Aucma.Core.PalletizCX1/Business/InstoreBusiness.cs index 81ee6406..c52d64b0 100644 --- a/Aucma.Core.PalletizCX1/Business/InstoreBusiness.cs +++ b/Aucma.Core.PalletizCX1/Business/InstoreBusiness.cs @@ -35,7 +35,7 @@ namespace Aucma.Core.PalletizCX1.Business private readonly AppConfig _appConfig; private AppConfig appConfig = new AppConfig(); - + public string storeCode = Appsettings.app("StoreInfo", "PalletizStoreCodeA"); // 过点数据表,物料完成记录MaterialCompletion private readonly IMaterialCompletionServices? _iMaterialCompletionServices = App.ServiceProvider.GetService(); @@ -137,12 +137,12 @@ namespace Aucma.Core.PalletizCX1.Business { if (string.IsNullOrEmpty(asciiStr)) { - throw new ArgumentException($"条码信息为空"); + throw new ArgumentException($"{spaceArea}条码信息为空"); } if (string.IsNullOrEmpty(spaceArea)) { - throw new ArgumentException($"货道区域为空"); + throw new ArgumentException($"{spaceArea}货道区域为空"); } _offlineService.GetProductInfosBySnCode(asciiStr, out ProductOffline prodInfo); @@ -151,7 +151,8 @@ namespace Aucma.Core.PalletizCX1.Business if (prodInfo == null) { - throw new ArgumentException($"根据成品码获取成品信息为空"); + log.Error($"区域:{spaceArea}根据成品码获取成品信息为空"); + throw new ArgumentException($"区域:{spaceArea}根据成品码获取成品信息为空"); } RefreshProductInfoEvent?.Invoke(asciiStr, prodInfo.ProductModel, prodInfo.ProductOrderNo); @@ -160,7 +161,7 @@ namespace Aucma.Core.PalletizCX1.Business out BaseSpaceInfo spaceinfo); if (!getSpaceResult) { - msg = $"{prodInfo.ProductName}未找到货道,请检查该型号是否有货道或者货道已满"; + msg = $"区域:{spaceArea}:{prodInfo.ProductName}未找到货道,请检查该型号是否有货道或者货道已满"; RefreshMsgEvent?.Invoke(msg); return; } @@ -198,14 +199,14 @@ namespace Aucma.Core.PalletizCX1.Business if (!result) { - msg = msg + "放行失败"; + msg = msg + $"区域:{spaceArea}放行失败"; RefreshMsgEvent?.Invoke(msg); - throw new ArgumentException($"入库任务下发至PLC失败,等待plc响应超时"); + throw new ArgumentException($"区域{spaceArea}: 入库任务下发至PLC失败,等待plc响应超时"); } else { - msg = msg + "放行成功"; + msg = msg + $"区域{spaceArea}放行成功"; RefreshMsgEvent?.Invoke(msg); List spaceinfos = new List(); if (laseSpaceinfo != null) @@ -291,7 +292,7 @@ namespace Aucma.Core.PalletizCX1.Business if (spaceinfos == null || spaceinfos.Count==0) { - log.Info($"通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); + log.Info($"区域{spaceArea},{prodInfo.ProductSncode}通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); laseSpaceinfo = null; spaceinfo = null; return false; @@ -303,7 +304,7 @@ namespace Aucma.Core.PalletizCX1.Business if (spaceinfos == null || spaceinfos.Count==0) { - log.Info($"通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); + log.Info($"区域{spaceArea},{prodInfo.ProductSncode}通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); laseSpaceinfo = null; spaceinfo = null; return false; @@ -313,7 +314,7 @@ namespace Aucma.Core.PalletizCX1.Business if (spaceinfo == null || spaceinfos.Count==0) { - log.Info($"通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); + log.Info($"区域{spaceArea},{prodInfo.ProductSncode}通过物料型号获取货道信息异常:根据成品信息获取货道信息为空"); laseSpaceinfo = null; spaceinfo = null; return false; @@ -397,7 +398,7 @@ namespace Aucma.Core.PalletizCX1.Business rangeResult = 0; if (plcCon == null) { - throw new ArgumentException($"下发入库任务至PLC逻辑异常:Plc连接为空"); + throw new ArgumentException($"成品码:{asciiStr},仓库区域:{spaceinfo.SpaceArea},匹配货道:{spaceinfo.SpaceCode}下发入库任务至PLC逻辑异常:Plc连接为空"); } var _plc = plcCon.plc; @@ -423,26 +424,38 @@ namespace Aucma.Core.PalletizCX1.Business result = false; return; } - bool answerFlag = _plc.ReadBool("B1000"); - + bool answerFlag = false; + if(spaceinfo.SpaceArea == "A") + { + answerFlag = _plc.ReadBool("B1000"); + } + else if(spaceinfo.SpaceArea == "B") + { + answerFlag = _plc.ReadBool("B1001"); + } + else if(spaceinfo.SpaceArea =="C") + { + answerFlag = _plc.ReadBool("B1000"); + } + if (answerFlag) { isFlag = false; } - Task.Delay(500).Wait(); + Task.Delay(500).Wait(); } if (spaceinfo.SpaceArea == "A") { if (!_plc.WriteInt16("D2", spinFlag.ToString())) { - throw new ArgumentException($"旋转角度下发至PLC失败"); + throw new ArgumentException($"A区域旋转角度下发至PLC失败"); } if (!_plc.WriteInt16("D29", spaceCode.ToString())) { - throw new ArgumentException($"货道号下发至PLC失败"); + throw new ArgumentException($"A区域货道号下发至PLC失败"); } _plc.WriteInt16("B1001", "1");//发送完成信号 @@ -452,7 +465,33 @@ namespace Aucma.Core.PalletizCX1.Business else if (spaceinfo.SpaceArea == "B") { - result = false; + if (!_plc.WriteInt16("D2", spinFlag.ToString())) + { + throw new ArgumentException($"B区域旋转角度下发至PLC失败"); + } + if (!_plc.WriteInt16("D29", spaceCode.ToString())) + { + throw new ArgumentException($"B区域货道号下发至PLC失败"); + } + + _plc.WriteInt16("B1001", "1");//发送完成信号 + + result = true; + } + else if (spaceinfo.SpaceArea == "C") + { + if (!_plc.WriteInt16("D2", spinFlag.ToString())) + { + throw new ArgumentException($"C区域旋转角度下发至PLC失败"); + } + if (!_plc.WriteInt16("D29", spaceCode.ToString())) + { + throw new ArgumentException($"C区域货道号下发至PLC失败"); + } + + _plc.WriteInt16("B1001", "1");//发送完成信号 + + result = true; } } diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index f8a338a6..28f0528e 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -153,12 +153,12 @@ namespace Aucma.Core.ProductOffLine.Business if (LinerScannerIp == ip) { Console.WriteLine($"内侧扫码器ip: {ip} 未扫描到条码"); - speechStr.SpeakAsync("东侧扫码失败"); + speechStr.SpeakAsync("西侧扫码失败"); } else if(ShellScannerIp == ip) { Console.WriteLine($"外侧扫码器ip: {ip} 未扫描到条码"); - speechStr.SpeakAsync("西侧扫码失败"); + speechStr.SpeakAsync("东侧扫码失败"); } } diff --git a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs index 59680730..49d96460 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs @@ -178,12 +178,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels { DateTime EndTime = Convert.ToDateTime(result.EndTime); - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_02" && x.ProductScanTime <= EndTime.AddDays(1)).Result; } else if (string.IsNullOrEmpty(result.EndTime)) { DateTime BeginTime = Convert.ToDateTime(result.BeginTime); - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_02" && x.ProductScanTime >= BeginTime).Result; } else { @@ -194,7 +194,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels MessageBox.Show("结束时间要大于开始时间!"); return; } - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_02" && x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; } } if (list != null) diff --git a/Aucma.Core.ProductOffLineCX1/Business/GunBusiness.cs b/Aucma.Core.ProductOffLineCX1/Business/GunBusiness.cs index dbca3008..80fb9774 100644 --- a/Aucma.Core.ProductOffLineCX1/Business/GunBusiness.cs +++ b/Aucma.Core.ProductOffLineCX1/Business/GunBusiness.cs @@ -62,13 +62,14 @@ namespace Aucma.Core.ProductOffLineCX1.Business { try { - string port = System.IO.Ports.SerialPort.GetPortNames().FirstOrDefault(); + // string port = System.IO.Ports.SerialPort.GetPortNames().FirstOrDefault(); + // string port = appConfig. //实例化串行端口 - + //端口名 注:因为使用的是USB转RS232 所以去设备管理器中查看一下虚拟com口的名字 - serialPort.PortName = port;// portName; + serialPort.PortName = appConfig.Port;// portName; //波特率 霍尼威尔扫码枪115200,普通9600 - serialPort.BaudRate = int.Parse(appConfig.BaudRate); ; + serialPort.BaudRate = int.Parse(appConfig.BaudRate); //奇偶校验 serialPort.Parity = Parity.None; //停止位 diff --git a/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs index 4a7885c1..05941f34 100644 --- a/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLineCX1/Business/offLineBusiness.cs @@ -157,12 +157,12 @@ namespace Aucma.Core.ProductOffLineCX1.Business if (LinerScannerIp == ip) { Console.WriteLine($"内侧扫码器ip: {ip} 未扫描到条码"); - speechStr.SpeakAsync("东侧扫码失败"); + speechStr.SpeakAsync("西侧扫码失败"); } else if (ShellScannerIp == ip) { Console.WriteLine($"外侧扫码器ip: {ip} 未扫描到条码"); - speechStr.SpeakAsync("西侧扫码失败"); + speechStr.SpeakAsync("东侧扫码失败"); } } diff --git a/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs b/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs index 602053fc..b2384c33 100644 --- a/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs +++ b/Aucma.Core.ProductOffLineCX1/Config/AppConfig.cs @@ -71,6 +71,15 @@ namespace Aucma.Core.ProductOffLineCX1.Config set { iniHelper.IniWriteValue("system", "BaudRate", value); } } + /// + /// 扫码枪串口 + /// + public string Port + { + get { return iniHelper.IniReadValue("system", "Port"); } + set { iniHelper.IniWriteValue("system", "Port", value); } + } + /// /// 手动放行按钮密码 /// diff --git a/Aucma.Core.ProductOffLineCX1/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.ProductOffLineCX1/ViewModels/StatisticsPageViewModel.cs index 2d2a3212..38c5b2b0 100644 --- a/Aucma.Core.ProductOffLineCX1/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.ProductOffLineCX1/ViewModels/StatisticsPageViewModel.cs @@ -178,12 +178,12 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels { DateTime EndTime = Convert.ToDateTime(result.EndTime); - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime <= EndTime.AddDays(1)).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_01"&& x.ProductScanTime <= EndTime.AddDays(1)).Result; } else if (string.IsNullOrEmpty(result.EndTime)) { DateTime BeginTime = Convert.ToDateTime(result.BeginTime); - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_01" && x.ProductScanTime >= BeginTime).Result; } else { @@ -194,7 +194,7 @@ namespace Aucma.Core.ProductOffLineCX1.ViewModels MessageBox.Show("结束时间要大于开始时间!"); return; } - list = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; + list = _offLineInfoServices.QueryAsync(x => x.ProductLineCode == "CX_01" && x.ProductScanTime >= BeginTime && x.ProductScanTime <= EndTime.AddDays(1)).Result; } } if (list != null)