From 81e0849186bb9428573b57de7c246a285d97f1d4 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 12 Jan 2024 15:21:27 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=BF=AE=E6=AD=A3=E6=96=B0=E5=8F=91?= =?UTF-8?q?=E6=B3=A1=E6=9C=80=E5=90=8E=E4=B8=80=E6=9E=AA=E5=85=B3=E6=9E=AA?= =?UTF-8?q?=E6=97=B6=E9=97=B40=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IService_New/IProductOffLineServices.cs | 4 +- .../Service_New/ProductOffLineServices.cs | 10 +- .../Business/CollectionFoamMachine.cs | 2 +- .../Business/offLineBusiness.cs | 166 +++++++++--------- .../ViewModels/IndexPageViewModel.cs | 10 +- .../Views/IndexPageView.xaml | 4 +- 6 files changed, 103 insertions(+), 93 deletions(-) diff --git a/Admin.Core.IService/IService_New/IProductOffLineServices.cs b/Admin.Core.IService/IService_New/IProductOffLineServices.cs index 9df9e4f3..4cc77a1a 100644 --- a/Admin.Core.IService/IService_New/IProductOffLineServices.cs +++ b/Admin.Core.IService/IService_New/IProductOffLineServices.cs @@ -15,7 +15,7 @@ namespace Admin.Core.IService /// /// 条码系统获取校验字符串 /// - public Task QueryChecked(string barCode); + public string QueryChecked(string barCode); /// /// 条码系统入库接口 @@ -24,7 +24,7 @@ namespace Admin.Core.IService /// string Order_number 生产订单号(正常订单和返工单要分别传输) /// int Order_type 正常订单为1 返工单为3 /// - public Task SaveBarcodeInfo(string Barcode, string Created_By, string Order_number, int Order_type); + public string SaveBarcodeInfo(string Barcode, string Created_By, string Order_number, int Order_type); } diff --git a/Admin.Core.Service/Service_New/ProductOffLineServices.cs b/Admin.Core.Service/Service_New/ProductOffLineServices.cs index cf9a69dd..f5f814c0 100644 --- a/Admin.Core.Service/Service_New/ProductOffLineServices.cs +++ b/Admin.Core.Service/Service_New/ProductOffLineServices.cs @@ -29,13 +29,13 @@ namespace Admin.Core.Service /// /// 条码系统获取校验字符串 /// - public async Task QueryChecked(string barCode) + public string QueryChecked(string barCode) { try { var _db = baseRepository.Db; string sql = "SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA('"+barCode+ "') as result FROM DUAL"; - var infos = await _db.CopyNew().Ado.SqlQueryAsync(sql); + var infos = _db.CopyNew().Ado.SqlQueryAsync(sql).Result; return infos.FirstOrDefault().result; } catch (Exception ex) @@ -52,19 +52,19 @@ namespace Admin.Core.Service /// string Order_number 生产订单号(正常订单和返工单要分别传输) /// int Order_type 正常订单为1 返工单为3 /// - public async Task SaveBarcodeInfo(string Barcode,string Created_By,string Order_number,int Order_type) + public string SaveBarcodeInfo(string Barcode,string Created_By,string Order_number,int Order_type) { try { // 保存业务 var _db = baseRepository.Db; - var infos = await _db.CopyNew().Ado.SqlQueryAsync($"SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.SAVE_BARCODE_INFO({Barcode},{Created_By},{Order_number},{Order_type})"); + var infos = _db.CopyNew().Ado.SqlQueryAsync($"SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.SAVE_BARCODE_INFO({Barcode},{Created_By},{Order_number},{Order_type})").Result; return infos.FirstOrDefault().result; } catch (Exception ex) { log.Error("条码系统入库异常" + ex); - return null; + return ""; } } diff --git a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs index 15f418e3..625e33a3 100644 --- a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs +++ b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs @@ -103,7 +103,7 @@ namespace Aucma.Core.BoxFoam.Business tempKeys.Add(kvPair.Key, record); } //有变化更新记录所有信息 - if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff)) + if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff) && !kvPair.Value.MixpistOff.Equals("0")) { kvPair.Value.ProductLineCode = "CX_02"; kvPair.Value.StationNumber = "1005"; diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index 339ca73e..5829b6b4 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -3,7 +3,7 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; using Admin.Core.Service; -using Aucma.Core.PLc; +using Aucma.Core.HwPLc; using Aucma.Core.ProductOffLine; using Aucma.Core.ProductOffLine.Models; using log4net; @@ -103,28 +103,30 @@ namespace Aucma.Core.ProductOffLine.Business public async void test() { - - string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481"); - Console.WriteLine(result); - + + // string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481"); + // Console.WriteLine(result); + // string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01"; - //Task.Run(() => - //{ - // Thread.Sleep(5000); - // MaterialBarScanEvent("32160030000000910780", "192.168.1.19"); - // Thread.Sleep(1000); - // MaterialBarScanEvent("33160030000000910780", "192.168.1.20"); - //}); + Task.Run(() => + { + Thread.Sleep(5000); + MaterialBarScanEvent("32160030000000910780", "192.168.1.19"); + // Thread.Sleep(1000); + // MaterialBarScanEvent("33160030000000910780", "192.168.1.20"); + }); } + /// /// 处理条码 /// /// - /// 扫码器方向 - public void MaterialBarScanEvent(string code,string scannerIp)//接收条码数据 + /// 扫码器IP + public void MaterialBarScanEvent(string code,string scannerIp) { - Console.WriteLine(scannerIp); int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器 + log.Info("扫码器ip:" + scannerIp +"编号:["+ScannerNo+ "]扫描到条码:" + code); + string materialType = ""; bool BackResult = false; if (ScannerNo == 1) @@ -233,20 +235,20 @@ namespace Aucma.Core.ProductOffLine.Business { try { - // 1.先质检 + TempOffLineInfo.QualityResult = "成功"; Thread.Sleep(10000); TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1 TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2 - TempOffLineInfo.ProductOrderNo = ""; + log.Info("条码验证开始:" + BarCode); //1.查询条码系统 // string result = await _productOffLineServices.QueryChecked(BarCode); string result = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000003987@BCD-160C,家电下乡@@BCD-160C@test皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01"; - //查询到的数据分割处理,结果中用"@"号分隔,刷新页面显示 - string[] FArrayList = result.Split('@'); + //用"@"号分隔 + string[] FArrayList = result.Split('@'); if (FArrayList[0].ToUpper() == "Y") //查询数据成功 { log.Info(BarCode + "成功返回验证信息:" + result); @@ -313,83 +315,89 @@ namespace Aucma.Core.ProductOffLine.Business TempOffLineInfo.ProductRefreshFlag = true; return false; } - // mes查询订单数据, 异常处理:后期可能根据SN码查箱体码,查订单号并检查更新订单数据 - BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")).Result; - //2.上传条码系统 - if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo)) - { - // string strSave = await _productOffLineServices.SaveBarcodeInfo(BarCode.Trim(), "ILS_SORT", TempOffLineInfo.ProductOrderNo, 1); - string strSave = "Y"; - if (!string.IsNullOrEmpty(strSave)) + + //2.上传条码系统 + if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo)) { - if (strSave == "Y") + // mes查询订单数据, 异常处理:后期可能根据SN码查箱体码,查订单号并检查更新订单数据 + BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")).Result; + + string strSave = _productOffLineServices.SaveBarcodeInfo(BarCode.Trim(), "ILS_SORT", TempOffLineInfo.ProductOrderNo, 1); + // string strSave = "Y"; + if (!string.IsNullOrEmpty(strSave)) { - log.Info(BarCode + "上传条码成功:" + strSave); + if (strSave == "Y") + { - TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码成功"; - //界面刷新 - TempOffLineInfo.ProductRefreshFlag = true; + log.Info(BarCode + "上传条码成功:" + strSave); + TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码成功"; + //界面刷新 + TempOffLineInfo.ProductRefreshFlag = true; if (order != null) - { - TempOffLineInfo.OrderQty = order.OrderAmount; // 订单数量*5 - TempOffLineInfo.ActQty = order.CompleteAmount; // 订单已上传*6 - } - return true; - } - else - { - log.Info(BarCode + "上传条码失败:" + strSave); - TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码失败" + strSave; - //界面刷新 - TempOffLineInfo.ProductRefreshFlag = true; - if (strSave.Contains("条码重复")) - { - // 查询本地数据库是否有数据 - OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == BarCode).Result; - if (offLineInfo != null) { - log.Info(BarCode + "条码重复,本地已存在,放行"); - TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复,本地已存在,放行"; - //界面刷新 - TempOffLineInfo.ProductRefreshFlag = true; - return true; - // chkout:条码重复是否允许放行 - //if (TempOffLineInfo.ChkOut == true) - //{ - // return true; - //} + TempOffLineInfo.OrderQty = order.OrderAmount; // 订单数量*5 + TempOffLineInfo.ActQty = order.CompleteAmount; // 订单已上传*6 } else { - log.Info(BarCode + "条码重复,本地不存在,已插入,放行"); - OffLineInfo info11 = MapperTwo(TempOffLineInfo); - _offLineInfoServices.AddAsync(info11); - return true; - } + + } + return true; } + else + { + log.Info(BarCode + "上传条码失败:" + strSave); + TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码失败" + strSave; + //界面刷新 + TempOffLineInfo.ProductRefreshFlag = true; + if (strSave.Contains("条码重复")) + { + // 查询本地数据库是否有数据 + OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == BarCode).Result; + if (offLineInfo != null) + { + log.Info(BarCode + "条码重复,本地已存在,放行"); + TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复,本地已存在,放行"; + //界面刷新 + TempOffLineInfo.ProductRefreshFlag = true; + return true; + // chkout:条码重复是否允许放行 + //if (TempOffLineInfo.ChkOut == true) + //{ + // return true; + //} + } + else + { + log.Info(BarCode + "条码重复,本地不存在,已插入,放行"); + OffLineInfo info11 = MapperTwo(TempOffLineInfo); + _offLineInfoServices.AddAsync(info11); + return true; + } + } TempOffLineInfo.MsgAlarmFlag = false; return false; - } + } + } + else + { + TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",条码系统保存接口异常"; + TempOffLineInfo.MsgAlarmFlag = true; + //界面刷新 + TempOffLineInfo.ProductRefreshFlag = true; + return false; + } } else { - TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",条码系统保存接口异常"; - TempOffLineInfo.MsgAlarmFlag = true; - //界面刷新 - TempOffLineInfo.ProductRefreshFlag = true; - return false; + TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",生产单号异常"; + TempOffLineInfo.MsgAlarmFlag = true; + //界面刷新 + TempOffLineInfo.ProductRefreshFlag = true; + return false; } } - else - { - TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",生产单号异常"; - TempOffLineInfo.MsgAlarmFlag = true; - //界面刷新 - TempOffLineInfo.ProductRefreshFlag = true; - return false; - } - } catch (Exception ex) { TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message; diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index d0a1c75e..dec35083 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -65,8 +65,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels InitEveryDayMethod(); // 刷新界面信息 RefreshPageListen(); + LoadData(); - } #region 参数定义 @@ -278,13 +278,15 @@ namespace Aucma.Core.ProductOffLine.ViewModels if (OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag == true) { - ModelToPage(OffLineBusiness.TempOffLineInfo1); OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag = false; + ModelToPage(OffLineBusiness.TempOffLineInfo1); + } else if(OffLineBusiness.TempOffLineInfo2.ProductRefreshFlag == true) { - ModelToPage(OffLineBusiness.TempOffLineInfo2); OffLineBusiness.TempOffLineInfo2.ProductRefreshFlag = false; + ModelToPage(OffLineBusiness.TempOffLineInfo2); + } } public void ModelToPage(TempInfo tempInfo) @@ -317,7 +319,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels await App.Current.Dispatcher.BeginInvoke((Action)(() => { - LoadData(); + #region 小时产量统计 List listTime = _baseBomInfoServices.getWorkTime().Result; if (listTime == null) return; diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml index e2a17a5b..8a46850b 100644 --- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml @@ -241,7 +241,7 @@ - + @@ -274,7 +274,7 @@ - +