diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index 22e23d3a..9adf1940 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -4,6 +4,16 @@ using log4net; using LiveCharts.Wpf; using LiveCharts; using System.Collections.Generic; +using Aucma.Core.Scanner; +using Microsoft.Extensions.Hosting; +using NPOI.SS.Formula.Functions; +using Oracle.ManagedDataAccess.Client; +using System.Windows.Forms; +using System.Threading; +using static Aucma.Core.Scanner.MvCodeHelper; +using Admin.Core.Common; +using System.Linq; +using static Npgsql.Replication.PgOutput.Messages.RelationMessage; /* * 成品分舵入库首页信息 @@ -17,12 +27,12 @@ namespace Aucma.Core.ProductOffLine.ViewModels public IndexPageViewModel() { - StationName = "成品分垛入库"; - MaterialName = "SC-AUCMA-农夫山泉,SC 门体"; - OrderNo = "8512365486"; - BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss"); - - InitEveryDayMethod(); + MvCodeHelper.ReceiveCodeEvent += ReceiveCode; + // test(); + //List listdatabase = Appsettings.app("DBS") + // .Where(i => i.Enabled).ToList(); + InitEveryDayMethod(); + } #region 扫描信息 @@ -80,13 +90,41 @@ namespace Aucma.Core.ProductOffLine.ViewModels #endregion + private void LoadProduct() + { + ChartValues achievement = new ChartValues(); + ProductionHourList = new List(); + App.Current.Dispatcher.BeginInvoke((Action)(() => + { + Achievement.Clear(); + for (int i = 0; i < 5; i++) + { + ProductionHourList.Add(i.ToString()); + achievement.Add(1 + i * 10); + } + + var column = new ColumnSeries(); + column.DataLabels = true; + column.Title = "泡后库"; + column.Values = achievement; + + Achievement.Add(column); + ModelStatistics.Add(column); + })); + } + private void InitEveryDayMethod() { + StationName = "成品下线扫描"; + MaterialName = "SC-AUCMA-农夫山泉,SC 门体"; + OrderNo = "8512365486"; + BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss"); ChartValues achievement = new ChartValues(); Random random = new Random(); for (int i = 0; i < 5; i++) { achievement.Add(random.Next(60, 100)); + } var column = new ColumnSeries(); @@ -117,7 +155,6 @@ namespace Aucma.Core.ProductOffLine.ViewModels column2.Title = "产量"; column2.Values = achievement2; - Achievement.Add(column2); } @@ -161,5 +198,64 @@ namespace Aucma.Core.ProductOffLine.ViewModels set { productionHourList = value; } } #endregion + + /// + /// 扫描的条码处理 + /// + /// + /// 扫码器方向,1左边分A库,2右边分B库 + private void ReceiveCode(string code,int direction) + { + //1.扫描的SN条码去条码系统查询 + string result = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000000807@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01"; + + //2.查询到的数据分割处理,结果中用"@"号分隔,刷新页面显示并存到scada数据库(表待建) + string[] resultArray = result.Split('@'); + // 输出结果 + foreach (string item in resultArray) + { + Thread.Sleep(2000); + MessageBox.Show(item); + } + + //3.调条码系统保存接口入库 + + //4.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) + + //5.分垛A,B库逻辑(先左边读到的条码分A库,右边读到的B库==>预留分库逻辑) + + //6.下发plc信号 + + } + + + // 测试连接 + void test() + { + string connectionString = "Data Source=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.50)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;"; + // string connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_scada;Password=aucma;"; + // string functionQuery = "SELECT COUNT(*) from CODE_BINDING"; + string sql = "SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA('16160030000000910779') FROM DUAL"; + using (OracleConnection connection = new OracleConnection(connectionString)) + { + connection.Open(); + + using (OracleCommand command = new OracleCommand(sql, connection)) + { + // 执行函数并获取结果 + string result = command.ExecuteScalar().ToString(); + + // 在结果中用"@"号分隔 + string[] resultArray = result.Split('@'); + + // 输出结果 + foreach (string item in resultArray) + { + Thread.Sleep(2000); + MessageBox.Show(item); + } + } + } + } } } diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml index 9c741bd5..f9fdfdf8 100644 --- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml @@ -56,7 +56,7 @@ - + @@ -146,6 +146,7 @@ + diff --git a/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml b/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml index bd75bafe..c7ce5779 100644 --- a/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/StatisticsPageView.xaml @@ -37,7 +37,7 @@