From 8538964ef3a1a79e9a9bc655bb6d2f3d8a56c86a Mon Sep 17 00:00:00 2001
From: liuwf <wenfaliu@163.com>
Date: Wed, 6 Mar 2024 19:04:58 +0800
Subject: [PATCH] =?UTF-8?q?change-=E6=88=90=E5=93=81=E4=B8=8B=E7=BA=BF?=
 =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=AE=8C=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Admin.Core.Model/Model_New/OffLineInfo.cs     |  10 +
 .../Aucma.Core.ProductOffLine.csproj          |   2 +-
 .../Business/MvCodeHelper.cs                  | 113 ++++-
 .../Business/offLineBusiness.cs               | 325 +++++++-----
 Aucma.Core.ProductOffLine/Config/AppConfig.cs |  57 +++
 Aucma.Core.ProductOffLine/Startup.cs          |   6 +-
 .../ViewModels/IndexPageViewModel.cs          | 465 +++++++++---------
 .../ViewModels/LoginViewModel.cs              | 118 +++++
 .../ViewModels/MainWindowViewModel.cs         |  51 +-
 .../ViewModels/QualityItemViewModel.cs        |   2 +-
 .../Views/ChooseDirectionWindow.xaml          |  19 +
 .../Views/ChooseDirectionWindow.xaml.cs       |  77 +++
 .../Views/IndexPageView.xaml                  |  19 +-
 .../Views/IndexPageView.xaml.cs               |   8 +-
 Aucma.Core.ProductOffLine/Views/Login.xaml    |  58 +++
 Aucma.Core.ProductOffLine/Views/Login.xaml.cs |  29 ++
 .../Views/MainWindow.xaml                     |  14 +-
 .../Views/MainWindow.xaml.cs                  |   6 +
 Aucma.Core.ProductOffLine/appsettings.json    |  16 +-
 19 files changed, 994 insertions(+), 401 deletions(-)
 create mode 100644 Aucma.Core.ProductOffLine/Config/AppConfig.cs
 create mode 100644 Aucma.Core.ProductOffLine/ViewModels/LoginViewModel.cs
 create mode 100644 Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml
 create mode 100644 Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml.cs
 create mode 100644 Aucma.Core.ProductOffLine/Views/Login.xaml
 create mode 100644 Aucma.Core.ProductOffLine/Views/Login.xaml.cs

diff --git a/Admin.Core.Model/Model_New/OffLineInfo.cs b/Admin.Core.Model/Model_New/OffLineInfo.cs
index b78140fc..7b56f500 100644
--- a/Admin.Core.Model/Model_New/OffLineInfo.cs
+++ b/Admin.Core.Model/Model_New/OffLineInfo.cs
@@ -62,5 +62,15 @@ namespace Admin.Core.Model
         /// </summary>
         [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")]
         public string ProductLineCode { get; set; } //扫描时间
+        /// <summary>
+        /// 上传条码系统保存接口返回信息
+        /// </summary>
+        [SugarColumn(ColumnName = "SAVE_RETURN_INFO")]
+        public string SaveRetuenInfo { get; set; }
+        /// <summary>
+        /// 当前登录班组(一线白班,一线夜班,二线白班,二线夜班)
+        /// </summary>
+        [SugarColumn(ColumnName = "LOGIN_TEAM")]
+        public string LoginTeam { get; set; }
     }
 }
diff --git a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
index 48bc648f..244070ed 100644
--- a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
+++ b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj
@@ -36,7 +36,7 @@
 
   <ItemGroup>
     <Content Include="appsettings.json">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
       <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
     </Content>
diff --git a/Aucma.Core.ProductOffLine/Business/MvCodeHelper.cs b/Aucma.Core.ProductOffLine/Business/MvCodeHelper.cs
index 2f7bd499..b87e5eef 100644
--- a/Aucma.Core.ProductOffLine/Business/MvCodeHelper.cs
+++ b/Aucma.Core.ProductOffLine/Business/MvCodeHelper.cs
@@ -2,12 +2,14 @@
 using Aucma.Core.Scanner;
 using log4net;
 using MvCodeReaderSDKNet;
+using NPOI.SS.Formula.Functions;
 using StackExchange.Profiling;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.InteropServices;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using UAParser;
 
@@ -99,6 +101,8 @@ namespace Aucma.Core.ProductOffLine.Business
                     }
                     else
                     {
+                        // 更新存活时间
+                        LinerLiveTime = DateTime.Now;
                         Console.WriteLine(DateTime.Now + ":外侧扫码器==>条码:" + strCode.Trim().TrimEnd('\0') + "长度不为20,当做No Read 处理");
                         log.Info(DateTime.Now + ":外侧扫码器==>条码:" + strCode.Trim().TrimEnd('\0') + "长度不为20,当做No Read 处理");
                     }
@@ -153,6 +157,8 @@ namespace Aucma.Core.ProductOffLine.Business
                     }
                     else
                     {
+                        // 更新存活时间
+                        LinerLiveTime = DateTime.Now;
                         Console.WriteLine(DateTime.Now + "内侧扫码器==>条码:" + strCode.Trim().TrimEnd('\0') + "长度不为20,当做No Read 处理");
                         log.Info(DateTime.Now + "内侧扫码器==>条码:" + strCode.Trim().TrimEnd('\0') + "长度不为20,当做No Read 处理");
                     }
@@ -173,7 +179,7 @@ namespace Aucma.Core.ProductOffLine.Business
 
         public static void Shell()
         {
-
+            ShellLiveTime = DateTime.Now;
             MvCodeReader.cbOutputEx2delegate ImageCallback;
 
             MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2 stFrameInfo = new MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2();
@@ -187,12 +193,23 @@ namespace Aucma.Core.ProductOffLine.Business
                 nRet = MvCodeReader.MV_CODEREADER_EnumDevices_NET(ref stDevList, MvCodeReader.MV_CODEREADER_GIGE_DEVICE);
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
                 {
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
+
+                    RefreshStateEvent?.Invoke("内侧", false);
+                    Thread.Sleep(1000 * 10);
                     Console.WriteLine("Enum device failed:{0:x8}", nRet);
                     break;
                 }
                 Console.WriteLine("Enum device count : " + Convert.ToString(stDevList.nDeviceNum));
                 if (0 == stDevList.nDeviceNum)
                 {
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
+                   
+                    RefreshStateEvent?.Invoke("内侧", false);
+                    Thread.Sleep(1000 * 10);
+                    
                     break;
                 }
 
@@ -217,10 +234,17 @@ namespace Aucma.Core.ProductOffLine.Business
                         {
                             nDevIndex = i;
                             Console.WriteLine("device IP :" + ipStr);
+                           
                         }
                     }
                 }
-                if (nDevIndex < 0) return;
+                if (nDevIndex < 0) {
+                    Console.WriteLine("未找到外侧扫码器");
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
+                    Thread.Sleep(1000 * 30);
+                    break;
+                }
                 stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[nDevIndex], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
 
                 // ch:创建设备 | en:Create device
@@ -228,6 +252,8 @@ namespace Aucma.Core.ProductOffLine.Business
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
                 {
                     Console.WriteLine("Create device failed:{0:x8}", nRet);
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
                     break;
                 }
 
@@ -250,6 +276,8 @@ namespace Aucma.Core.ProductOffLine.Business
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
                 {
                     Console.WriteLine("Register image callback failed!");
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
                     break;
                 }
 
@@ -258,6 +286,8 @@ namespace Aucma.Core.ProductOffLine.Business
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
                 {
                     Console.WriteLine("Start grabbing failed:{0:x8}", nRet);
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
                     break;
                 }
                 
@@ -265,8 +295,23 @@ namespace Aucma.Core.ProductOffLine.Business
                 ShellDevice = device;
                 Console.WriteLine("Press enter to exit");
                 Console.WriteLine(DateTime.Now.ToString());
-                Console.ReadLine();
-
+                while (true)
+                {
+                    Thread.Sleep(1000*60);
+                    DateTime dateTime = DateTime.Now;
+                    TimeSpan timeSpan = dateTime.Subtract(ShellLiveTime);
+                    if (timeSpan.TotalMinutes >= 10)
+                    {
+                        Console.WriteLine("外侧扫码器超时");
+                        //CloseShell();
+                        //Shell();
+                        break;
+                    }
+                   
+                }
+                // Console.ReadLine();
+                // 刷新扫码器状态
+                RefreshStateEvent?.Invoke("外侧", false);
                 // ch:停止抓图 | en:Stop grabbing
                 nRet = device.MV_CODEREADER_StopGrabbing_NET();
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
@@ -291,16 +336,16 @@ namespace Aucma.Core.ProductOffLine.Business
                     break;
                 }
             } while (false);
-
-            if (MvCodeReader.MV_CODEREADER_OK != nRet)
-            {
-                // ch:销毁设备 | en:Destroy device
-                nRet = device.MV_CODEREADER_DestroyHandle_NET();
-                if (MvCodeReader.MV_CODEREADER_OK != nRet)
-                {
-                    Console.WriteLine("Destroy device failed:{0:x8}", nRet);
-                }
-            }
+            Shell();
+            //if (MvCodeReader.MV_CODEREADER_OK != nRet)
+            //{
+            //    // ch:销毁设备 | en:Destroy device
+            //    nRet = device.MV_CODEREADER_DestroyHandle_NET();
+            //    if (MvCodeReader.MV_CODEREADER_OK != nRet)
+            //    {
+            //        Console.WriteLine("Destroy device failed:{0:x8}", nRet);
+            //    }
+            //}
 
         }
 
@@ -308,7 +353,7 @@ namespace Aucma.Core.ProductOffLine.Business
 
         public static void Liner()
         {
-
+            LinerLiveTime = DateTime.Now;
             MvCodeReader.cbOutputEx2delegate ImageCallback;
 
             MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2 stFrameInfo = new MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2();
@@ -322,12 +367,22 @@ namespace Aucma.Core.ProductOffLine.Business
                 nRet = MvCodeReader.MV_CODEREADER_EnumDevices_NET(ref stDevList, MvCodeReader.MV_CODEREADER_GIGE_DEVICE);
                 if (MvCodeReader.MV_CODEREADER_OK != nRet)
                 {
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
+
+                    RefreshStateEvent?.Invoke("内侧", false);
+                    Thread.Sleep(1000 * 10);
                     Console.WriteLine("Enum device failed:{0:x8}", nRet);
                     break;
                 }
                 Console.WriteLine("Enum device count : " + Convert.ToString(stDevList.nDeviceNum));
                 if (0 == stDevList.nDeviceNum)
                 {
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("外侧", false);
+
+                    RefreshStateEvent?.Invoke("内侧", false);
+                    Thread.Sleep(1000 * 10);
                     break;
                 }
 
@@ -355,7 +410,15 @@ namespace Aucma.Core.ProductOffLine.Business
                         }
                     }
                 }
-                if (nDevIndex < 0) return;
+                if (nDevIndex < 0)
+                {
+                    Console.WriteLine("未找到内侧扫码器");
+                    // 刷新扫码器状态
+                    RefreshStateEvent?.Invoke("内侧", false);
+                    Thread.Sleep(1000 * 30);
+                    break;
+                }
+
                 stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[nDevIndex], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
 
                 // ch:创建设备 | en:Create device
@@ -399,7 +462,21 @@ namespace Aucma.Core.ProductOffLine.Business
 
                 Console.WriteLine("Press enter to exit");
                 Console.WriteLine(DateTime.Now.ToString());
-                Console.ReadLine();
+                while (true)
+                {
+                    Thread.Sleep(1000*60);
+                    DateTime dateTime = DateTime.Now;
+                    TimeSpan timeSpan = dateTime.Subtract(LinerLiveTime);
+                    if (timeSpan.TotalMinutes >= 10)
+                    {
+                        Console.WriteLine("内侧扫码器超时");
+                        //CloseShell();
+                        //Shell();
+                        break;
+                    }
+
+                }
+                //Console.ReadLine();
 
                 // ch:停止抓图 | en:Stop grabbing
                 nRet = device.MV_CODEREADER_StopGrabbing_NET();
@@ -424,6 +501,7 @@ namespace Aucma.Core.ProductOffLine.Business
                     Console.WriteLine("Destroy device failed:{0:x8}", nRet);
                     break;
                 }
+
             } while (false);
 
             if (MvCodeReader.MV_CODEREADER_OK != nRet)
@@ -435,6 +513,7 @@ namespace Aucma.Core.ProductOffLine.Business
                     Console.WriteLine("Destroy device failed:{0:x8}", nRet);
                 }
             }
+            Liner();
 
         }
 
diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
index c2f7ab18..a6c3b68a 100644
--- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
+++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
@@ -1,11 +1,14 @@
 using Admin.Core.Common;
+using Admin.Core.Common.Config;
 using Admin.Core.IService;
 using Admin.Core.Model;
 using Admin.Core.Model.Model_New;
 using Admin.Core.Service;
 using Aucma.Core.HwPLc;
 using Aucma.Core.ProductOffLine;
+using Aucma.Core.ProductOffLine.Config;
 using Aucma.Core.ProductOffLine.Models;
+using Aucma.Core.ProductOffLine.Views;
 using Aucma.Core.Scanner;
 using log4net;
 using Microsoft.Extensions.DependencyInjection;
@@ -23,6 +26,7 @@ using System.Collections.Generic;
 using System.Data;
 using System.Linq;
 using System.Reflection;
+using System.Reflection.Metadata.Ecma335;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
@@ -62,6 +66,7 @@ namespace Aucma.Core.ProductOffLine.Business
         #endregion
 
         #region 接口引用
+        private AppConfig appConfig = AppConfig.Instance;
 
         private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
 
@@ -104,7 +109,8 @@ namespace Aucma.Core.ProductOffLine.Business
        public OffLineBusiness()
         {
             MvCodeHelper.RefreshMaterialCodeStrEvent += MaterialBarScan;
-           // test();
+            ChooseDirectionWindow.SendPlcPassEvent += DownLoadPassFlag;
+           test();
         }
         #region 变量定义
         /// <summary>
@@ -116,11 +122,11 @@ namespace Aucma.Core.ProductOffLine.Business
 
         public  void test()
         {
-           //  private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
-        // string result =  _productOffLineServices.QueryChecked("1520870000099E2V0004");
-      //  string result =  _productOffLineServices.QueryChecked("1530080CD0098E1V1714");
-        //    Console.WriteLine(result);
-        //    string strSave = _productOffLineServices.SaveBarcodeInfo("1520870000099E2V0004", "ILS_SORT", result.Replace("0000",""), 1);
+            //  private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness));
+            // string result =  _productOffLineServices.QueryChecked("1520870000099E2V0004");
+            //  string result =  _productOffLineServices.QueryChecked("1530080CD0098E1V1714");
+            //    Console.WriteLine(result);
+            //    string strSave = _productOffLineServices.SaveBarcodeInfo("1520870000099E2V0004", "ILS_SORT", result.Replace("0000",""), 1);
             //   LogHelper.Info("成品码:1520870000099E2V0004"+strSave);
             //   string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
             Task.Run(() =>
@@ -128,14 +134,23 @@ namespace Aucma.Core.ProductOffLine.Business
                 //while (true)
                 //{
                 Thread.Sleep(5000);
-                Random random = new Random();
-                MaterialBarScan("32160030000000912" + random.Next(100, 999), "10.10.92.141");
-                Thread.Sleep(3000);
-                Random random1 = new Random();
-                MaterialBarScan("99160030000000912" + random1.Next(100, 999), "10.10.92.141");
-                Thread.Sleep(3000);
-                Random random2 = new Random();
-                MaterialBarScan("44160030000000912" + random2.Next(100, 999), "10.10.92.141");
+              // string aa =  appConfig.BarCodeAccount;
+              //  string bb = appConfig.ProductlineCode;
+              //  appConfig.BarCodeAccount = "123";
+                //TempOffLineInfo1.QualityResult = "失败";
+                //TempOffLineInfo1.ProductSNCode = "323222444"; //产品SN条码*1
+                //TempOffLineInfo1.ProductScanTime = System.DateTime.Now; // 扫码时间*2
+                //TempOffLineInfo1.MsgInfo = "条码质检失败:";
+                //RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo1);
+                //  Random random = new Random();
+                //  MaterialBarScan("32160030000000912" + random.Next(100, 999), "10.10.92.141");
+
+                //Thread.Sleep(3000);
+                //Random random1 = new Random();
+                //MaterialBarScan("99160030000000912" + random1.Next(100, 999), "10.10.92.141");
+                //Thread.Sleep(3000);
+                //Random random2 = new Random();
+                //MaterialBarScan("44160030000000912" + random2.Next(100, 999), "10.10.92.141");
                 //  }
 
                 //  Thread.Sleep(1000);
@@ -173,16 +188,26 @@ namespace Aucma.Core.ProductOffLine.Business
                     if (!BackResult)
                     {
                         log.Info("条码:" + TempOffLineInfo1.ProductSNCode + "对接条码系统处理失败,禁止放行,流程结束");
+
                         return;
                     }
                    // TempOffLineInfo1.ProductRefreshFlag = true;
                     // 2.更新mes数据库
                     BackResult = updateMesData(TempOffLineInfo1);
-                    BackResult = true;  // 测试
+                   
+                    //  BackResult = true;  // 测试
                     // 3.plc放行
                     if (BackResult)
                     {
-                        
+                        try
+                        {
+                            //刷新统计图表
+                            RefreshChartsEvent?.Invoke();
+                        }
+                        catch (Exception ex)
+                        {
+                            log.Error("刷新统计图表出错:" + ex.Message.ToString());
+                        }
                         bool plcResult = SendAndWaitSignal(ScannerNo, materialType);
                         //if (plcResult)
                         //{
@@ -199,15 +224,7 @@ namespace Aucma.Core.ProductOffLine.Business
                         //    TempOffLineInfo1.ProductRefreshFlag = true;
                         //}
                         log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
-                        try
-                        {
-                            //刷新统计图表
-                            RefreshChartsEvent?.Invoke();
-                        }
-                        catch(Exception ex)
-                        {
-                            log.Error("刷新统计图表出错:"+ex.Message.ToString());
-                        }
+                        
                     }
                     else
                     {
@@ -232,11 +249,20 @@ namespace Aucma.Core.ProductOffLine.Business
                 //    TempOffLineInfo2.ProductRefreshFlag = true;
                     // 2.更新mes数据库
                     BackResult = updateMesData(TempOffLineInfo2);
-                    BackResult = true;
+                  
+                    //BackResult = true;
                     // 3.plc放行
                     if (BackResult)
                     {
-                      
+                        try
+                        {
+                            //刷新统计图表
+                            RefreshChartsEvent?.Invoke();
+                        }
+                        catch (Exception ex)
+                        {
+                            log.Error("刷新统计图表出错:" + ex.Message.ToString());
+                        }
 
                         bool plcResult = SendAndWaitSignal(ScannerNo, materialType);
                         //if (plcResult)
@@ -254,14 +280,7 @@ namespace Aucma.Core.ProductOffLine.Business
                         //    TempOffLineInfo2.ProductRefreshFlag = true;
                         //}
                         log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo2.ProductOrderNo, TempOffLineInfo2.OrderQty));
-                        try
-                        {
-                            //刷新统计图表
-                            RefreshChartsEvent?.Invoke();
-                        }catch(Exception ex)
-                        {
-                            log.Error("刷新页面异常"+ex.Message.ToString());
-                        }
+                      
                     
                     
                     }
@@ -327,49 +346,76 @@ namespace Aucma.Core.ProductOffLine.Business
                 
                 // 产线
                 info11.ProductLineCode = "CX_02";
+                info11.SaveRetuenInfo = TempOffLineInfo.MsgInfo;
+                info11.LoginTeam = appConfig.LoginTeam;
                 // 查询本地数据库是否有数据
                 OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
                 if(offLineInfo == null)
                 {
-                    _offLineInfoServices.AddAsync(info11);
-                }
-               
-                // 修改订单表
-                ////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO)   注意:查询的字段可能需要修改,确保数据一致
-
-                ////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
-                BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo).Result;
-
-                order.CompleteAmount++;
-                if (order.CompleteAmount == order.OrderAmount)
-                {
-                    order.CompleteDate = DateTime.Now;
-                }
-                order.UpdatedTime = DateTime.Now;
-                 _baseOrderInfoServices.UpdateAsync(order);
-
+                    info11.ProductOrderNo = "0000" + info11.ProductOrderNo;
+                   int flag = _offLineInfoServices.AddAsync(info11).Result;
+                    if (flag < 0)
+                    {
+                        TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "插入下线记录失败";
+                        TempOffLineInfo.MsgAlarmFlag = true;
+                        //界面刷新
+                        RefreshScanMateriaCodeEvent(TempOffLineInfo);
+                        return false;
+                    }
 
-                #region 暂时不启用,因为还没打箱体码,查不到数据,更新过点数据
-                //PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode).Result;
-                //if (print != null)
-                //{
-                //    MaterialCompletion completion = new MaterialCompletion();
-                //    completion.OrderCode = print.OrderCode;
-                //    completion.MaterialBarcode = bindingRecord1.BoxCode;
-                //    completion.MaterialCode = print.MaterialCode;
-                //    completion.MaterialName = print.MaterialName;
-                //    completion.StationName = "1009";
-                //    completion.CompleteDate = DateTime.Now;
-                //    completion.ProductLineCode = "CX_02";
-                //    completion.isDownLine = 1;
-                //    _ = _iMaterialCompletionServices.AddAsync(completion).Result;
+                    // 不重复上传的条码才更新mes订单完成数
+                    // 修改订单表
+                    ////6.更新mes 数据库完成数量和时间(BASE_ORDERINFO)   注意:查询的字段可能需要修改,确保数据一致
 
-                //}
+                    ////6.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
+                    BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo).Result;
+                    if (order == null)
+                    {
+                        TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "查询mes订单失败";
+                        TempOffLineInfo.MsgAlarmFlag = true;
+                        //界面刷新
+                        RefreshScanMateriaCodeEvent(TempOffLineInfo);
+                        return false;
 
-                #endregion
+                    }
+                    order.CompleteAmount++;
+                    if (order.CompleteAmount == order.OrderAmount)
+                    {
+                        order.CompleteDate = DateTime.Now;
+                    }
+                    order.UpdatedTime = DateTime.Now;
+                    bool uploadOrder = _baseOrderInfoServices.UpdateAsync(order).Result;
+                    if(!uploadOrder)
+                    {
+                        TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "更新mes订单完成数失败";
+                        TempOffLineInfo.MsgAlarmFlag = true;
+                        //界面刷新
+                        RefreshScanMateriaCodeEvent(TempOffLineInfo);
+                        return false;
+                    }
 
+                    #region 暂时不启用,因为还没打箱体码,查不到数据,更新过点数据
+                    //PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode).Result;
+                    //if (print != null)
+                    //{
+                    //    MaterialCompletion completion = new MaterialCompletion();
+                    //    completion.OrderCode = print.OrderCode;
+                    //    completion.MaterialBarcode = bindingRecord1.BoxCode;
+                    //    completion.MaterialCode = print.MaterialCode;
+                    //    completion.MaterialName = print.MaterialName;
+                    //    completion.StationName = "1009";
+                    //    completion.CompleteDate = DateTime.Now;
+                    //    completion.ProductLineCode = "CX_02";
+                    //    completion.isDownLine = 1;
+                    //    _ = _iMaterialCompletionServices.AddAsync(completion).Result;
+
+                    //}
 
+                    #endregion
+ 
+                }
                 return true;
+
             }
             catch (Exception)
             {
@@ -396,6 +442,7 @@ namespace Aucma.Core.ProductOffLine.Business
               TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
               TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
               TempOffLineInfo.MsgInfo = "条码质检失败:";
+
               foreach(ReportQualityInsPection item in qualityList)
                {
                   TempOffLineInfo.MsgInfo += item.QualityDefectName;
@@ -526,10 +573,33 @@ namespace Aucma.Core.ProductOffLine.Business
         {
             try
             {
+                int orderType = 1; // ZP03为在库返工订单,传参数3,默认正常订单1
+                // 先查订单
                 if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo))
                 {
+                    // mes查询订单数据,
+                    BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")).Result;
+                    if (order != null)
+                    {
+                        if (order.OrderType == "ZP03")
+                        {
+                            orderType = 3;
+                        }
+                        TempOffLineInfo.OrderQty = order.OrderAmount; // 订单数量*5
+                        TempOffLineInfo.ActQty = order.CompleteAmount;  // 订单已上传*6
+                    }
+                    else
+                    {
+                        TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",MES未查询到订单数据";
+                        TempOffLineInfo.MsgAlarmFlag = true;
+                        //界面刷新
+                        // TempOffLineInfo.ProductRefreshFlag = true;
+                        RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
+                        return false;
+                    }
+
                     // 条码系统保存接口
-                    string strSave = _productOffLineServices.SaveBarcodeInfo(TempOffLineInfo.ProductSNCode, "6945", TempOffLineInfo.ProductOrderNo, 1);
+                    string strSave = _productOffLineServices.SaveBarcodeInfo(TempOffLineInfo.ProductSNCode, appConfig.BarCodeAccount, TempOffLineInfo.ProductOrderNo, orderType);
                     //    string strSave = "Y";
                     if (!string.IsNullOrEmpty(strSave))
                     {
@@ -538,23 +608,7 @@ namespace Aucma.Core.ProductOffLine.Business
                             log.Info(TempOffLineInfo.ProductSNCode + "上传条码成功:" + strSave);
                             TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码成功";
 
-                            // mes查询订单数据, 异常处理:后期可能根据SN码查箱体码,查订单号并检查更新订单数据
-                            BaseOrderInfo order = _baseOrderInfoServices.FirstAsync(x => x.OrderCode == TempOffLineInfo.ProductOrderNo.Replace("0000", "")).Result;
-                            if (order != null)
-                            {
-                                TempOffLineInfo.OrderQty = order.OrderAmount; // 订单数量*5
-                                TempOffLineInfo.ActQty = order.CompleteAmount;  // 订单已上传*6
-                            }
-                            else
-                            {
-                                TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",MES查询订单数据异常";
-                                TempOffLineInfo.MsgAlarmFlag = true;
-                                //界面刷新
-                                // TempOffLineInfo.ProductRefreshFlag = true;
-                                RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
-                                // return false;
-                            }
-
+                         
                             //界面刷新
                             //  TempOffLineInfo.ProductRefreshFlag = true;
                             RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
@@ -568,31 +622,7 @@ namespace Aucma.Core.ProductOffLine.Business
 
                             if (strSave.Contains("条码重复"))
                             {
-                                // 查询本地数据库是否有数据
-                                OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
-                                if (offLineInfo != null)
-                                {
-                                    log.Info(TempOffLineInfo.ProductSNCode + "条码重复,本地已存在,放行");
-                                    TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复,本地已存在,放行";
-                                    //界面刷新
-                                    //   TempOffLineInfo.ProductRefreshFlag = true;
-                                    RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
-                                    return true;
-                                    //  chkout:条码重复是否允许放行
-                                    //if (TempOffLineInfo.ChkOut == true)
-                                    //{
-                                    //    return true;
-                                    //}
-                                }
-                                else
-                                {
-                                    log.Info(TempOffLineInfo.ProductSNCode + "条码重复,本地不存在,已插入,可以放行");
-                                    OffLineInfo info11 = MapperTwo(TempOffLineInfo);
-                                    // 产线
-                                    info11.ProductLineCode = "CX_02";
-                                    _offLineInfoServices.AddAsync(info11);
-                                    return true;
-                                }
+                                return CodeRepeatProcess(TempOffLineInfo);
                             }
                             TempOffLineInfo.MsgAlarmFlag = true;
                             //界面刷新
@@ -628,12 +658,73 @@ namespace Aucma.Core.ProductOffLine.Business
                 return false;
             }
         }
-    #region plc交互
-    /// <summary>
-    /// 下发plc放行信号,传进来扫码器编号,分垛方向A或者B,返回plc反馈结果
-    /// </summary>
-    /// <param name="materialType"></param>
-    private bool DownLoadPassFlag(int scannerNo,string strDirection)
+
+        /// <summary>
+        /// 条码系统上传重复逻辑20240305经aucma负责人商讨确定
+        /// 如果条码重复,比对mes系统记录,在五分钟以内重复,视为短时间内员工重复推箱子或用扫码枪扫描,可以放行
+        /// 超过五分钟,报警并显示已存在记录时间提示员工,
+        /// 员工判断如果是一码多用,搬下来换新条码重新扫描;如果是同一箱子因为吃饭或停班重复扫描,那么点击屏幕按钮进行放行
+        /// </summary>
+        /// <returns></returns>
+        public bool CodeRepeatProcess(TempInfo TempOffLineInfo)
+        {
+            try
+            {
+                // 查询本地数据库是否有数据
+                OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
+
+                if (offLineInfo != null)
+                {
+                    if (offLineInfo.ProductScanTime >= DateTime.Now.AddMinutes(-5)) // 五分钟以内
+                    {
+                        log.Info(TempOffLineInfo.ProductSNCode + "五分钟内重复上传条码系统,本地已存在,放行");
+                        TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "五分钟内重复上传条码系统,放行";
+                        //界面刷新
+                        //   TempOffLineInfo.ProductRefreshFlag = true;
+                        RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
+                        return true;
+                    }
+                    else
+                    {
+                        log.Info(TempOffLineInfo.ProductSNCode + "条码重复,并且距离上次上传超过五分钟,报警并显示已存在记录时间提示员工操作处理");
+                        TempOffLineInfo.MsgAlarmFlag = true;
+                       
+                        TempOffLineInfo.MsgInfo = "条码重复,上传间隔超过五分钟禁止放行,人工处理,上传时间:" + offLineInfo.ProductScanTime;
+                        //界面刷新
+                        //   TempOffLineInfo.ProductRefreshFlag = true;
+                        RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo);
+                        return false;
+                    }
+                }
+                else
+                {
+                    log.Info(TempOffLineInfo.ProductSNCode + "条码重复,本地不存在,已插入,放行");
+                    OffLineInfo info11 = MapperTwo(TempOffLineInfo);
+                    // 产线
+                    info11.ProductLineCode = "CX_02";
+                    info11.ProductOrderNo = "0000" + info11.ProductOrderNo;
+                    info11.SaveRetuenInfo = TempOffLineInfo.MsgInfo;
+                    info11.LoginTeam = appConfig.LoginTeam;
+                    _offLineInfoServices.AddAsync(info11);
+                    return true;
+                }
+            }
+            catch (Exception ex)
+            {
+                
+                log.Error("CodeRepeatProcess()异常" + ex.Message.ToString());
+                return false;
+            }
+            
+        }
+        #region plc交互
+        /// <summary>
+        /// 下发plc放行信号,传进来扫码器编号,分垛方向A或者B,返回plc反馈结果
+        /// scannerNo == 1内侧,scannerNo == 2外侧
+        /// strDirection "A" ? 1 : 2;入库方向A,B
+        /// </summary>
+        /// <param name="materialType"></param>
+        private bool DownLoadPassFlag(int scannerNo,string strDirection)
     {
         // 入库方向A,B
         int direction = strDirection == "A" ? 1 : 2;
diff --git a/Aucma.Core.ProductOffLine/Config/AppConfig.cs b/Aucma.Core.ProductOffLine/Config/AppConfig.cs
new file mode 100644
index 00000000..7ee93185
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/Config/AppConfig.cs
@@ -0,0 +1,57 @@
+using Admin.Core.Common.Config;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.ProductOffLine.Config
+{
+    public sealed class AppConfig
+    {
+        private static IniHelper iniHelper = new IniHelper(System.Environment.CurrentDirectory + "/config/App.InI");
+
+
+        private static readonly Lazy<AppConfig> lazy = new Lazy<AppConfig>(() => new AppConfig());
+        public static AppConfig Instance
+        {
+            get
+            {
+                return lazy.Value;
+            }
+        }
+
+
+        public AppConfig()
+        {
+          
+        }
+        /// <summary>
+        /// 条码系统账号
+        /// </summary>
+        public string BarCodeAccount
+        {
+            get { return iniHelper.IniReadValue("system", "BarCodeAccount"); }
+            set { iniHelper.IniWriteValue("system", "BarCodeAccount", value); }
+        }
+
+        /// <summary>
+        /// 产线编号
+        /// </summary>
+        public string ProductlineCode
+        {
+            get { return iniHelper.IniReadValue("system", "ProductlineCode"); }
+            set { iniHelper.IniWriteValue("system", "ProductlineCode", value); }
+        }
+
+        /// <summary>
+        /// 当前登录班组
+        /// </summary>
+        public string LoginTeam
+        {
+            get { return iniHelper.IniReadValue("system", "LoginTeam"); }
+            set { iniHelper.IniWriteValue("system", "LoginTeam", value); }
+        }
+
+    }
+}
diff --git a/Aucma.Core.ProductOffLine/Startup.cs b/Aucma.Core.ProductOffLine/Startup.cs
index fc64ab2b..29719ee5 100644
--- a/Aucma.Core.ProductOffLine/Startup.cs
+++ b/Aucma.Core.ProductOffLine/Startup.cs
@@ -66,7 +66,7 @@ namespace Aucma.Core.ProductOffLine
             services.AddScannerSetup();
 
             //�������
-             services.AddJobSetup();
+          //   services.AddJobSetup();
 
             //PLC
             services.AddPlcSetup();
@@ -91,7 +91,7 @@ namespace Aucma.Core.ProductOffLine
         /// </summary>
         /// <param name="app"></param>
         /// <param name="env"></param>
-        public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter)
+        public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService)//, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter
         {
             // ʹ�þ�̬�ļ�
             app.UseStaticFiles();
@@ -99,7 +99,7 @@ namespace Aucma.Core.ProductOffLine
             //app.UseAuthorization();
 
             // ����QuartzNetJob���ȷ���
-            app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
+         //   app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
             //����ɨ�����
             app.UseScannerMildd(scannerService);
             //PLC
diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
index 89443f65..b586e4bb 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
@@ -37,6 +37,8 @@ using Aucma.Core.ProductOffLine.Models;
 using System.Globalization;
 using Admin.Core.Model.ViewModels;
 using ChartsByTime = Admin.Core.Model.ViewModels.ChartsByTime;
+using LiveCharts.Defaults;
+using System.Windows.Documents;
 
 
 /*
@@ -52,7 +54,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         // 成品下线操作mes数据
         private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
 
-      //  System.Timers.Timer timer = new System.Timers.Timer(500);//界面刷新定时器
+        //  System.Timers.Timer timer = new System.Timers.Timer(500);//界面刷新定时器
         private readonly IBaseBomInfoServices? _baseBomInfoServices;
         private OffLineBusiness offLineBusiness = OffLineBusiness.Instance;
         private static double aaa = 100.0;
@@ -61,22 +63,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         {
             OffLineBusiness.RefreshScanMateriaCodeEvent += ModelToPage;
             OffLineBusiness.RefreshChartsEvent += RefreshCharts;
-            OffLineQty = "235";
+            MainWindowViewModel.RefreshFirstPageChartsEvent += RefreshCharts;
             _offLineInfoServices = App.ServiceProvider.GetService<IOffLineInfoServices>();
             _baseBomInfoServices = App.ServiceProvider.GetService<IBaseBomInfoServices>();
-            InitEveryDayMethod();
-            // 刷新界面扫码信息
-          //  RefreshPageListen();
-            LoadData();
-            //Task.Run(() =>
-            //{
-            //    Thread.Sleep(5000);
-            //    InitEveryDayMethod();
-            //   // Thread.Sleep(5000);
-            //  //  InitEveryDayMethod();
-            //});
-
-         //   offLineBusiness.test();
+
+            RefreshCharts();
+
+
+          
 
         }
         /// <summary>
@@ -84,10 +78,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         /// </summary>
         public void RefreshCharts()
         {
-            InitEveryDayMethod();
-            AddDataGrid();
+            
+            List<OffLineInfo> list = LoadData();
+           // Console.WriteLine("刷新台数:"+list.Count);
+            InitEveryDayMethod(list);
+
         }
-      
+       
 
         #region 参数定义
 
@@ -204,7 +201,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
                 OnPropertyChanged(nameof(MsgColor));
             }
         }
-       
+
         #endregion
 
 
@@ -255,7 +252,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         /// <summary>
         /// 日产量柱状图X轴日期
         /// </summary>
-        private List<string> productionHourList;
+        private List<string> productionHourList = new List<string>();
 
         public List<string> ProductionHourList
         {
@@ -293,40 +290,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
 
 
         #region 界面刷新定时器
-        //public void RefreshPageListen()
-        //{
-        //    timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshPage);
-        //    timer.AutoReset = true;
-        //    timer.Enabled = true;
-        //    timer.Start();
-
-        //}
-        /// <summary>
-        /// 定时检测两个扫码实体是否需要刷新
-        /// </summary>
-        /// <param name="source"></param>
-        /// <param name="e"></param>
-        //public void RefreshPage(object source, System.Timers.ElapsedEventArgs e)
-        //{
-            
-
-        //    if (OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag == true)
-        //    {
-        //        OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag = false;
-        //        ModelToPage(OffLineBusiness.TempOffLineInfo1);
 
-        //        LoadData();
-              
-                  
-                
-        //    }
-        //    else if(OffLineBusiness.TempOffLineInfo2.ProductRefreshFlag == true)
-        //    {
-        //        OffLineBusiness.TempOffLineInfo2.ProductRefreshFlag = false;
-        //        ModelToPage(OffLineBusiness.TempOffLineInfo2);
-              
-        //    }
-        //}
         public void ModelToPage(TempInfo tempInfo)
         {
             App.Current.Dispatcher.Invoke(() =>
@@ -338,7 +302,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
                 OrderQty = tempInfo.OrderQty.ToString();
                 ActQty = tempInfo.ActQty.ToString();
                 MsgInfo = tempInfo.MsgInfo;
-                if (tempInfo.MsgAlarmFlag==null || tempInfo.MsgAlarmFlag==false)
+                if (tempInfo.MsgAlarmFlag == null || tempInfo.MsgAlarmFlag == false)
                 {
                     MsgColor = Brushes.White;
                 }
@@ -352,159 +316,190 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         #endregion
 
 
-        private async void InitEveryDayMethod()
+
+        private async void InitEveryDayMethod(List<OffLineInfo> list)
         {
 
-            await App.Current.Dispatcher.BeginInvoke((Action)(() =>
-              {
-                  Achievement.Clear();
-                  ProductionHourList = new List<string>();
-                 // OffLineQty = "232";
-                  for (int i = 8; i <= 19; i++)
-                  {
-                      ProductionHourList.Add(i + ":00");
-                  }
-                  //ChartValues<int> achievement2 = new ChartValues<int>();
-                  //achievement2.Add(74);
-                  //achievement2.Add(77);
-                  //achievement2.Add(75);
-                  //achievement2.Add(6);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //achievement2.Add(0);
-                  //var column2 = new ColumnSeries();
-                  //column2.DataLabels = true;
-                  //column2.Title = "产量";
-                  //column2.Values = achievement2;
-                  //column2.Foreground = Brushes.White;
-                  //Achievement.Add(column2);
-
-                  //MaterialNameList.Add("BCD-162CST,炫金色,A");
-                  //MaterialNameList.Add("BCD-212CHG,炫金色,A");
-                  //MaterialNameList.Add("BCD-211CGN,星际灰,A");
-                  //MaterialNameList.Add("BC/BD-310NF,银河灰,A");
-                  //MaterialNameList.Add("BC/BD-232WD,银河灰,A");
-                  //MaterialNameList.Add("BC/BD-145NF,炫金色,ZS,A");
-                  //ChartValues<int> achievement = new ChartValues<int>();
-                  //achievement.Add(41);
-                  //achievement.Add(37);
-                  //achievement.Add(37);
-                  //achievement.Add(47);
-                  //achievement.Add(39);
-                  //achievement.Add(19);
-                  //var column = new ColumnSeries();
-                  //column.DataLabels = true;
-                  //column.Title = "型号";
-                  //column.Values = achievement;
-                  //column.Foreground = Brushes.White;
-
-                  //ModelStatistics.Add(column);
-                  #region 小时产量统计
-                  List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
-                  if (listTime == null) return;
-                  //  var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime)
-                  // List<dynamic> hourAmount = _offLineInfoServices.QueryCharts1("CX_01");
-
-                  List<Admin.Core.Model.ViewModels.ChartsByTime> list = _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime).Result;
-                  
-                  if (list == null) return;
-                  List<ChartsByTimeAmount> hourList1 = new List<ChartsByTimeAmount>();
-                  // 当班下线数量
-                  int sum = 0;
-                  foreach (ChartsByTime item in list)
-                  {
-                      DateTime date = DateTime.ParseExact(item.date + ":00:00", "yyyy-MM-dd/HH:mm:ss", CultureInfo.InvariantCulture);
-                      ChartsByTimeAmount hour = new ChartsByTimeAmount();
-                      hour.ProductCode = item.productLineCode;
-                      hour.ProductDate = date;
-                      hour.ProductAmount = item.Amount;
-                      sum += item.Amount;
-                      hourList1.Add(hour);
-                  }
-                  // 当班下线数量页面赋值
-                  OffLineQty = sum.ToString();
-                  if (hourList1 == null) return;
-
-
-                  var hourList = hourList1.Where(x => x.ProductCode.Equals("CX_02") && x.ProductDate >= listTime[0].startTime && x.ProductDate <= listTime[11].startTime);
-
-                  List<string> xList = new List<string>();
-                  ChartValues<int> achievement2 = new ChartValues<int>();
-                  foreach (var item in hourList)
-                  {
-                      xList.Add(item.ProductDate.Hour.ToString() + ":00");
-                      achievement2.Add(item.ProductAmount);
-                  }
-
-                  var column2 = new ColumnSeries();
-                  column2.DataLabels = true;
-                  column2.Title = "产量";
-                  column2.Values = achievement2;
-                  column2.Foreground = Brushes.White;
-
-                  //  Achievement.Clear();
-                  //Achievement.Add(column2);
-                  if (Achievement.Count > 0)
-                  {
-                      for (int i = 0; i < hourList.Count(); i++)
-                      {
-                          Achievement.FirstOrDefault().Values[i] = hourList.ElementAt(i).ProductAmount;
-                      }
-                  }
-                  else
-                  {
-                      Achievement.Clear();
-                      Achievement.Add(column2);
-                  }
-
-                  ProductionHourList = xList;
-                  #endregion
-
-
-                  #region 型号统计
-                  List<string> nameList = new List<string>();
-                  ChartValues<int> achievement = new ChartValues<int>();
-                  var column = new ColumnSeries();
-
-                  List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
-                  var modelList = offList.GroupBy(x => x.ProductModel);
-
-                  foreach (var item in modelList)
-                  {
-                      achievement.Add(item.Count());
-                      nameList.Add(item.Key);
-                  }
-                  column.DataLabels = true;
-                  column.Title = "型号";
-                  column.Values = achievement;
-                  column.Foreground = Brushes.White;
-
-                  // x轴
-                  MaterialNameList = null;
-                  MaterialNameList = nameList;
-                  // y轴
-                  if (ModelStatistics.Count > 0)
-                  {
-                      for (int i = 0; i < modelList.Count(); i++)
-                      {
-                          Achievement.FirstOrDefault().Values[i] = modelList.ElementAt(i).Count();
-                      }
-
-                  }
-                  else
-                  {
-
-                      ModelStatistics.Add(column);
-                  }
-
-              }));
-                  #endregion
-            
+            Application.Current.Dispatcher.Invoke(() =>
+            {
+                ProductionHourList.Clear();
+                Achievement.Clear();
+                #region 小时产量统计
+                List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
+                if (listTime == null) return;
+                // List<string> xList = new List<string>();
+                foreach (WorkTime workTime in listTime)
+                {
+                    // xList.Add(workTime.startTime.Hour.ToString());
+                    ProductionHourList.Add(workTime.startTime.Hour.ToString());
+                }
+                // ProductionHourList = xList;
+                // y轴
+                if (list == null || list.Count <= 0) return;
+                var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
+                .Select(g => new
+                {
+                    Hour = g.Key.ToString(), // 小时
+                    Count = g.Count() // 统计每个小时的个数
+                }).ToList();
+
+                ChartValues<ObservablePoint> achievement2 = new ChartValues<ObservablePoint>();
+                int i = 0;
+                foreach (string item in ProductionHourList)
+                {
+                    var target = result.Where(x => x.Hour == item).FirstOrDefault();
+                    if (target != null)
+                    {
+                        achievement2.Add(new ObservablePoint(i, target.Count));
+                    }
+                    else
+                    {
+                        achievement2.Add(new ObservablePoint(i, 0));
+                    }
+                    i++;
+                }
+
+                var column2 = new ColumnSeries();
+                column2.DataLabels = true;
+                column2.Title = "产量";
+                column2.Values = achievement2;
+                column2.Foreground = Brushes.White;
+                Achievement.Add(column2);
+                #endregion
+
+                #region 型号统计
+                List<string> nameList = new List<string>();
+                ChartValues<int> achievement = new ChartValues<int>();
+                var column = new ColumnSeries();
+
+                List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
+                var modelList = offList.GroupBy(x => x.ProductModel);
+
+                foreach (var item in modelList)
+                {
+                    achievement.Add(item.Count());
+                    nameList.Add(item.Key);
+                }
+                column.DataLabels = true;
+                column.Title = "型号";
+                column.Values = achievement;
+                column.Foreground = Brushes.White;
+
+                // x轴
+                MaterialNameList = null;
+                MaterialNameList = nameList;
+                // y轴
+                //if (ModelStatistics.Count > 0)
+                //{
+                //    for (int j = 0; j < modelList.Count(); j++)
+                //    {
+                //        Achievement.FirstOrDefault().Values[j] = modelList.ElementAt(j).Count();
+                //    }
+
+                //}
+                //else
+                //{
+                ModelStatistics.Clear();
+                ModelStatistics.Add(column);
+               // }
+
+
+                #endregion
+
+
+
+
+            });
+        }
+
+        private async void InitEveryDayMethod11(List<OffLineInfo> list)
+        {
+           
+            Application.Current.Dispatcher.Invoke(() =>
+            {
+                ProductionHourList.Clear();
+                Achievement.Clear();
+                #region 小时产量统计
+                List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
+                if (listTime == null) return;
+               // List<string> xList = new List<string>();
+                foreach (WorkTime workTime in listTime)
+                {
+                    // xList.Add(workTime.startTime.Hour.ToString());
+                    ProductionHourList.Add(workTime.startTime.Hour.ToString());
+                }
+               // ProductionHourList = xList;
+                // y轴
+                if (list == null || list.Count <= 0) return;
+                var result = list.GroupBy(x => x.ProductScanTime.Hour) // 按照小时进行分组
+                .Select(g => new
+                {
+                    Hour = g.Key.ToString(), // 小时
+                    Count = g.Count() // 统计每个小时的个数
+                }).ToList();
+                ChartValues<int> achievement2 = new ChartValues<int>();
+                foreach (string item in ProductionHourList)
+                {
+                    var target = result.Where(x => x.Hour == item).FirstOrDefault();
+                    if (target != null)
+                    {
+                        achievement2.Add(target.Count);
+                    }
+                    else
+                    {
+                        achievement2.Add(0);
+                    }
+                }
+
+                var column2 = new ColumnSeries();
+                column2.DataLabels = true;
+                column2.Title = "产量";
+                column2.Values = achievement2;
+                column2.Foreground = Brushes.White;
+                Achievement.Add(column2);
+                #endregion
+
+
+                #region 型号统计
+                List<string> nameList = new List<string>();
+                ChartValues<int> achievement = new ChartValues<int>();
+                var column = new ColumnSeries();
+
+                List<OffLineInfo> offList = _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
+                var modelList = offList.GroupBy(x => x.ProductModel);
+
+                foreach (var item in modelList)
+                {
+                    achievement.Add(item.Count());
+                    nameList.Add(item.Key);
+                }
+                column.DataLabels = true;
+                column.Title = "型号";
+                column.Values = achievement;
+                column.Foreground = Brushes.White;
+
+                // x轴
+                MaterialNameList = null;
+                MaterialNameList = nameList;
+                // y轴
+                if (ModelStatistics.Count > 0)
+                {
+                    for (int i = 0; i < modelList.Count(); i++)
+                    {
+                        Achievement.FirstOrDefault().Values[i] = modelList.ElementAt(i).Count();
+                    }
+
+                }
+                else
+                {
+
+                    ModelStatistics.Add(column);
+                }
+
+
+                #endregion
+
+            });
         }
         //private async void InitEveryDayMethod()
         //{
@@ -553,32 +548,44 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         //    };
         //}
 
-        public void LoadData()
+        public List<OffLineInfo> LoadData()
         {
-            List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
-            if (listTime == null) return;
-           List<OffLineInfo> list = _offLineInfoServices.Query(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].endTime);
-          if(list==null || list.Count<=0) return;
-          list = list.OrderBy(x=>x.ProductScanTime).ToList();
-         //   OffLineInfo record = _offLineInfoServices.FirstAsync().Result;
-
-            Application.Current.Dispatcher.Invoke(() =>
+            try
             {
-                foreach(OffLineInfo record in list)
+               
+                List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
+                if (listTime == null) return null;
+                List<OffLineInfo> list = _offLineInfoServices.Query(x => x.ProductScanTime >= listTime[0].startTime && x.ProductScanTime <= listTime[11].endTime && x.ProductLineCode == "CX_02");
+                OffLineQty = list.Count.ToString();
+                if (list == null || list.Count <= 0) return null;
+                list = list.OrderBy(x => x.ProductScanTime).ToList();
+                //   OffLineInfo record = _offLineInfoServices.FirstAsync().Result;
+                
+                Application.Current.Dispatcher.Invoke(() =>
                 {
-                    ListItems.Insert(0, new TempInfo()
+                    ListItems.Clear();
+                    foreach (OffLineInfo record in list)
                     {
-                        No = ListItems.Count + 1,
-                        ProductOrderNo = record.ProductOrderNo,
-                        ProductSNCode = record.ProductSNCode,
-                        ProductModel = record.ProductModel,
-                        ProductRemark = record.ProductRemark,
-                        QualityResult = "成功",
-                        ProductScanTime = record.ProductScanTime,
-                    }); 
-                }
-               
-            });
+                        ListItems.Insert(0, new TempInfo()
+                        {
+                            No = ListItems.Count + 1,
+                            ProductOrderNo = record.ProductOrderNo,
+                            ProductSNCode = record.ProductSNCode,
+                            ProductModel = record.ProductModel,
+                            ProductRemark = record.ProductRemark,
+                            QualityResult = "成功",
+                            ProductScanTime = record.ProductScanTime,
+                        });
+                    }
+
+                });
+                return list;
+            }
+            catch (Exception ex)
+            {
+                log.Error("首页LoadData()方法异常:" + ex.Message.ToString());
+                return null;
+            }
         }
 
         public void AddDataGrid()
@@ -589,7 +596,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
             if (list == null || list.Count <= 0) return;
             OffLineInfo record = list.OrderByDescending(x => x.ProductScanTime).FirstOrDefault();
             //OffLineInfo record = _offLineInfoServices.FirstAsync(x=>x.ProductScanTime).Result;
-            if(record.ProductSNCode!= ListItems[0].ProductSNCode && record.ProductSNCode != ListItems[1].ProductSNCode)
+            if (record.ProductSNCode != ListItems[0].ProductSNCode && record.ProductSNCode != ListItems[1].ProductSNCode)
             {
                 Application.Current.Dispatcher.Invoke(() =>
                 {
@@ -606,7 +613,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
 
                 });
             }
-         
+
         }
 
 
diff --git a/Aucma.Core.ProductOffLine/ViewModels/LoginViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/LoginViewModel.cs
new file mode 100644
index 00000000..00938655
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/ViewModels/LoginViewModel.cs
@@ -0,0 +1,118 @@
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Service;
+using Aucma.Core.ProductOffLine.Config;
+using Aucma.Core.ProductOffLine.Models;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Aucma.Core.ProductOffLine.ViewModels
+{
+    public partial class LoginViewModel : ObservableObject
+    {
+        private AppConfig appConfig = AppConfig.Instance;
+
+        public RelayCommand<object> CloseWindowCommand { get; set; }
+
+        public RelayCommand SaveCommand { get; set; }
+
+
+        public LoginViewModel()
+        {
+            _barcodeAccount = appConfig.BarCodeAccount;
+           // SelectedMaterialType.Content = appConfig.LoginTeam;
+            CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
+            SaveCommand = new RelayCommand(Login);
+
+        }
+
+
+        //关闭窗口
+        private void CloseWindow(object parameter)
+        {
+            var window = parameter as Window;
+            if (window != null)
+            {
+                window.Close();
+            }
+
+        }
+
+        private async void Login()
+        {
+
+            if (SelectedMaterialType == null)
+            {
+                MessageBox.Show("未选择班组");
+               
+                return;
+               
+            }
+            if (_barcodeAccount =="")
+            {
+                MessageBox.Show("未设置条码系统账号");
+
+                return;
+                
+            }
+            else
+            {
+                MessageBoxResult result = MessageBox.Show("确认登录吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
+                if (result == MessageBoxResult.Yes)
+                {
+                    appConfig.BarCodeAccount = _barcodeAccount;
+                    appConfig.LoginTeam = SelectedMaterialType.Content.ToString();
+                    MessageBox.Show("登录成功");
+                 //   CloseWindow();
+                }
+                   
+                
+            }
+         
+
+        }
+
+
+
+        /// <summary>
+        /// 班组,二线白班,二线夜班
+        /// </summary>
+        /// private string _selectedMaterialType;
+        private ComboBoxItem _selectedMaterialType;
+        public ComboBoxItem SelectedMaterialType
+        {
+            get { return _selectedMaterialType; }
+            set
+            {
+                if (_selectedMaterialType != value)
+                {
+                    _selectedMaterialType = value;
+                    OnPropertyChanged(nameof(SelectedMaterialType));
+                }
+            }
+        }
+
+        #region 条码系统账号
+        private string _barcodeAccount;
+        public string BarcodeAccount
+        {
+            get { return _barcodeAccount; }
+            set
+            {
+                _barcodeAccount = value;
+                OnPropertyChanged(nameof(BarcodeAccount));
+            }
+        }
+        #endregion
+
+    
+    }
+}
diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
index 78c31e9b..61d9846a 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
@@ -7,13 +7,14 @@ using log4net;
 using System.Diagnostics;
 using System.Threading;
 using NPOI.HSSF.Record;
-using Aucma.Core.PLc;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows.Threading;
 using Admin.Core.Common;
 using Admin.Core.Tasks;
 using Aucma.Core.ProductOffLine.Business;
+using Aucma.Core.HwPLc;
+using Aucma.Core.ProductOffLine.Config;
 
 namespace Aucma.Core.ProductOffLine.ViewModels
 {
@@ -25,7 +26,15 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         /// </summary>
         public delegate void RefreshCharts();
         public static event RefreshCharts? RefreshChartsEvent;
+
+        /// <summary>
+        /// 首页图表刷新
+        /// </summary>
+        public delegate void RefreshFirstPageCharts();
+        public static event RefreshFirstPageCharts? RefreshFirstPageChartsEvent;
+
         #endregion
+        private AppConfig appConfig = AppConfig.Instance;
 
         private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
         private IndexPageView firstPage = new IndexPageView();//首页
@@ -41,9 +50,10 @@ namespace Aucma.Core.ProductOffLine.ViewModels
             timer.Tick += Timer_Tick;
             timer.Start();
             MvCodeHelper.RefreshStateEvent += RefreshScanner;
-
+        
             MesDbState(true);
-            PlcState(true);
+            PlcState(false);
+            //PlcState(true);
             Scanner1State(false);
             Scanner2State(false);
 
@@ -59,7 +69,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
                 Task.Run(() =>
                 {
                     Thread.Sleep(2000);
-                   
+                 
                     //MvCodeHelper1.DeviceListAcq();//获取创建设备
                     // MvCodeHelper1.StartGrab();  // 开启触发扫码接收数据
                     Business.MvCodeHelper.Shell();
@@ -68,6 +78,16 @@ namespace Aucma.Core.ProductOffLine.ViewModels
                 Task.Run(() =>
                 {
                     Thread.Sleep(4000);
+                    //更新plc状态
+                    var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
+                    if (obj.plc.IsConnected)
+                    {
+                        PlcState(true);
+                    }
+                    else
+                    {
+                        PlcState(false);
+                    }
                     //MvCodeHelper1.DeviceListAcq();//获取创建设备
                     // MvCodeHelper1.StartGrab();  // 开启触发扫码接收数据
                     Business.MvCodeHelper.Liner();
@@ -263,6 +283,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
             switch (page)
             {
                 case "FirstPage":
+                    RefreshFirstPageChartsEvent?.Invoke();
                     UserContent = firstPage;
                     break;
                 case "RecordPage":
@@ -519,18 +540,26 @@ namespace Aucma.Core.ProductOffLine.ViewModels
         private void Timer_Tick(object sender, EventArgs e)
         {
             DateTime now = DateTime.Now;
-
-            // 判断当前是否是白班时间段
-            if (now.Hour >= 8 && now.Hour < 20)
+            if (appConfig.LoginTeam == "")
             {
-                ShiftStr = $"白班 08点-20点";
+                ShiftStr = $"未登录";
             }
             else
             {
-
-                ShiftStr = $"夜班 20点-08点";
+                ShiftStr = appConfig.LoginTeam;
             }
-            CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+        // 判断当前是否是白班时间段
+        //if (now.Hour >= 8 && now.Hour < 20)
+        //{
+        //    ShiftStr = $"白班 08点-20点";
+        //}
+        //else
+        //{
+
+        //    ShiftStr = $"夜班 20点-08点";
+        //}
+        CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         }
 
 
diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs
index 06fbbf6b..631a8748 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs
@@ -22,7 +22,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
     public partial class QualityItemViewModel : ObservableObject
     {
         public RelayCommand<object> CloseWindowCommand { get; set; }
-      
+       
         public RelayCommand SaveCommand { get; set; }
 
 
diff --git a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml
new file mode 100644
index 00000000..dbec5e51
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml
@@ -0,0 +1,19 @@
+<Window x:Class="Aucma.Core.ProductOffLine.Views.ChooseDirectionWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views"
+        mc:Ignorable="d" FontFamily="Microsoft YaHei"  WindowStartupLocation="CenterScreen"
+        Title="选择放行方向" Height="300" Width="300">
+    <Grid Background="#1152AC">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="97*"/>
+            <ColumnDefinition Width="3*"/>
+        </Grid.ColumnDefinitions>
+        <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="50,0,0,0">
+            <Button Content="外侧提升机" Click="LeftButton_Click"  Width="100" Height="50" HorizontalAlignment="Center" Margin="50 0 0 20"/>
+            <Button Content="内侧提升机" Click="RightButton_Click" Width="100" Height="50" HorizontalAlignment="Center" Margin="50 0 0 20"/>
+        </StackPanel>
+    </Grid>
+</Window>
diff --git a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml.cs b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml.cs
new file mode 100644
index 00000000..0f017a97
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml.cs
@@ -0,0 +1,77 @@
+using Aucma.Core.ProductOffLine.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Aucma.Core.ProductOffLine.Views
+{
+    /// <summary>
+    /// ChooseDirectionWindow.xaml 的交互逻辑
+    /// </summary>
+    public partial class ChooseDirectionWindow : Window
+    {
+       
+        /// <summary>
+        /// 下发plc放行信号,传进来扫码器编号,分垛方向A或者B,返回plc反馈结果
+        /// scannerNo == 1内侧,scannerNo == 2外侧
+        /// strDirection "A" ? 1 : 2;入库方向A,B
+        /// </summary>
+        public delegate bool SendPlcPass(int scannerNo, string strDirection);
+        public static event SendPlcPass? SendPlcPassEvent;
+
+
+        private bool directionSelected = false; // 用来标识是否已经选择了方向
+
+        public ChooseDirectionWindow()
+        {
+            InitializeComponent();
+        }
+
+        private void LeftButton_Click(object sender, RoutedEventArgs e)
+        {
+            ShowConfirmationAndClose("外侧提升机箱体");
+        }
+
+        private void RightButton_Click(object sender, RoutedEventArgs e)
+        {
+            ShowConfirmationAndClose("内侧提升机箱体");
+        }
+
+        /// <summary>
+        /// 默认放行A库
+        /// </summary>
+        /// <param name="direction"></param>
+        private void ShowConfirmationAndClose(string direction)
+        {
+            if (!directionSelected)
+            {
+                MessageBoxResult result = MessageBox.Show("确认放行 " + direction + " 吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
+                if (result == MessageBoxResult.Yes)
+                {
+                    directionSelected = true;
+                    this.Close();
+                    if (direction== "外侧提升机箱体")
+                    {
+                        SendPlcPassEvent?.Invoke(2,"A");
+                    }
+                    else
+                    {
+                        SendPlcPassEvent?.Invoke(1,"A");
+                    }
+                    
+                   
+                }
+            }
+        }
+    }
+}
diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
index 99b3f38e..54fbb4e2 100644
--- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
+++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
@@ -164,7 +164,7 @@
                 <Border Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Background="#1157b9">
                     <TextBlock Text="成品下线" Foreground="White" FontWeight="Bold" FontSize="30"/>
                 </Border>
-                
+
                 <Border Grid.Row="0"  Grid.Column="1" Background="#1157b9">
                     <TextBlock Text="产品条码" Foreground="White"  FontSize="20"/>
                 </Border>
@@ -207,18 +207,17 @@
                 <Border Grid.Row="3"  Grid.Column="2"  Grid.ColumnSpan="3">
                     <TextBlock Text="{Binding MsgInfo}" Foreground="{Binding MsgColor}"  FontSize="20"/>
                 </Border>
-                
                 <Border Grid.Row="0"  Grid.Column="5" Background="#1157b9">
                     <TextBlock Text="下线产量" Foreground="White"  FontSize="20" />
                 </Border>
                 <Border Grid.Row="1" Grid.RowSpan="2"  Grid.Column="5" Height="78" VerticalAlignment="Top">
                     <TextBlock Text="{Binding OffLineQty}" Foreground="White" FontSize="70"/>
                 </Border>
-                <Border Grid.Row="3"  Grid.Column="5" Height="39" VerticalAlignment="Center">
-                    <WrapPanel  HorizontalAlignment="Center"  VerticalAlignment="Center">
-                        <RadioButton Content="A库" Margin="5 0" Foreground="White"/>
-                        <RadioButton Content="B库" Margin="5 0" Foreground="White" />
-                    </WrapPanel>
+                
+               
+                <Border Grid.Row="3" Grid.Column="5">
+                    <Button Content="手动放行" Background="Green" FontSize="20" Width="150" Click="Button_Click"
+            HorizontalAlignment="Stretch"  Margin="0" />
                 </Border>
             </Grid>
         </Border>
@@ -245,7 +244,7 @@
                         </Border>
                         <Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" >
                             <lvc:CartesianChart Series="{Binding Achievement,UpdateSourceTrigger=PropertyChanged}"  DisableAnimations="True">
-                  
+
                                 <lvc:CartesianChart.AxisX>
                                     <lvc:Axis Labels="{Binding ProductionHourList}" FontSize="15">
                                         <lvc:Axis.Separator>
@@ -281,7 +280,7 @@
                                 <lvc:CartesianChart.AxisX>
                                     <lvc:Axis Labels="{Binding MaterialNameList}" FontSize="15">
                                         <lvc:Axis.Separator>
-                                            <lvc:Separator Visibility="Hidden" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" >
+                                            <lvc:Separator Step="1" Visibility="Hidden" StrokeThickness="1.5" StrokeDashArray="0" Stroke="#404F56" >
                                             </lvc:Separator>
                                         </lvc:Axis.Separator>
                                     </lvc:Axis>
@@ -289,7 +288,7 @@
                                 <lvc:CartesianChart.AxisY>
                                     <lvc:Axis FontSize="15" MinValue="0">
                                         <lvc:Axis.Separator>
-                                            <lvc:Separator  Step="10" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3"  Stroke="#404F56" >
+                                            <lvc:Separator  Step="50" Visibility="Hidden" StrokeThickness="1" StrokeDashArray="3"  Stroke="#404F56" >
                                             </lvc:Separator>
                                         </lvc:Axis.Separator>
                                     </lvc:Axis>
diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml.cs b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml.cs
index eae2c59c..5744ca52 100644
--- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml.cs
+++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml.cs
@@ -27,6 +27,12 @@ namespace Aucma.Core.ProductOffLine.Views
             InitializeComponent();
             this.DataContext = new IndexPageViewModel();
         }
-   
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            ChooseDirectionWindow directionWindow = new ChooseDirectionWindow();
+            directionWindow.Owner = Application.Current.MainWindow;
+            directionWindow.ShowDialog();
+        }
     }
 }
diff --git a/Aucma.Core.ProductOffLine/Views/Login.xaml b/Aucma.Core.ProductOffLine/Views/Login.xaml
new file mode 100644
index 00000000..98efa4eb
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/Views/Login.xaml
@@ -0,0 +1,58 @@
+<Window x:Class="Aucma.Core.ProductOffLine.Views.Login"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:Aucma.Core.ProductOffLine.Views"
+      mc:Ignorable="d" WindowStartupLocation="CenterScreen"
+        Title="登录"  Height="500" Width="500" Name="window" Background="White"
+        ResizeMode="NoResize" Topmost="True">
+    <Border Margin="5" Background="#1254AB" CornerRadius="10">
+        <Border.Effect>
+            <DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
+        </Border.Effect>
+
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*"/>
+            </Grid.ColumnDefinitions>
+
+            <Border Grid.Column="0" BorderBrush="#1254AB" BorderThickness="3" CornerRadius="5" Background="Transparent" Margin="5,5">
+                <Border.Effect>
+                    <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
+                </Border.Effect>
+
+                <Grid>
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="*"/>
+                        <RowDefinition Height="*"/>
+
+                    </Grid.RowDefinitions>
+                   
+                    <StackPanel Grid.Row="1" Orientation="Horizontal"  VerticalAlignment="Center" Margin="50,0,0,0">
+                        <TextBlock Text="       选择班组:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0" Width="129"/>
+                        <ComboBox   SelectedItem="{Binding SelectedMaterialType}"  Width="150" Margin="5 0 0 0" VerticalAlignment="Center" FontSize="30" Foreground="White">
+                            <ComboBoxItem Content="二线白班" Foreground="Blue"/>
+                            <ComboBoxItem Content="二线夜班" Foreground="Blue" />
+                        </ComboBox>
+                      
+                    </StackPanel>
+                   
+                    <StackPanel Grid.Row="2" Orientation="Horizontal"  VerticalAlignment="Center" Margin="50,0,0,0">
+                        <TextBlock Text="条码系统账号:" FontSize="20" Foreground="#FFFFFF" Margin="10,0,0,0"/>
+                        <TextBox  FontSize="20" Text="{Binding BarcodeAccount}"  Foreground="#FFFFFF" Width="150"  Margin="5,0,10,0"/>
+                    </StackPanel>
+
+                    <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+                        <Button Content="登  录" FontSize="20" Command="{Binding SaveCommand}" Background="#FF36B5C1" BorderBrush="#FF36B5C1" Foreground="white" Margin="0,0,10,0"  Height="50" Width="100" />
+                        <Button Content="取  消" FontSize="20" Command="{Binding CloseWindowCommand}" CommandParameter="{Binding ElementName=window}" Background="#FF9900" Foreground="white" Margin="10,0,0,0" Height="50" BorderBrush="#FF9900" Width="100" />
+                    </StackPanel>
+                </Grid>
+            </Border>
+
+        </Grid>
+    </Border>
+</Window>
diff --git a/Aucma.Core.ProductOffLine/Views/Login.xaml.cs b/Aucma.Core.ProductOffLine/Views/Login.xaml.cs
new file mode 100644
index 00000000..267f126b
--- /dev/null
+++ b/Aucma.Core.ProductOffLine/Views/Login.xaml.cs
@@ -0,0 +1,29 @@
+using Aucma.Core.ProductOffLine.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Aucma.Core.ProductOffLine.Views
+{
+    /// <summary>
+    /// Login.xaml 的交互逻辑
+    /// </summary>
+    public partial class Login : Window
+    {
+        public Login()
+        {
+            InitializeComponent();
+            this.DataContext = new LoginViewModel();
+        }
+    }
+}
diff --git a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml
index 8384ca9a..838ef967 100644
--- a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml
+++ b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml
@@ -17,14 +17,14 @@
         </Border.Effect>
         <Grid>
             <Grid.RowDefinitions>
-                <RowDefinition Height="0.5*"/>
+                <RowDefinition Height="0.7*"/>
                 <RowDefinition Height="6*"/>
                 <RowDefinition Height="auto"/>
             </Grid.RowDefinitions>
             <Border Grid.Row="0" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,2" Height="100">
                 <Grid>
                     <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="2*"/>
+                        <ColumnDefinition Width="2.3*"/>
                         <ColumnDefinition Width="7*"/>
                         <ColumnDefinition Width="2*"/>
                     </Grid.ColumnDefinitions>
@@ -44,25 +44,27 @@
                             <Grid.RowDefinitions>
                                 <RowDefinition Height="*"/>
                                 <RowDefinition Height="*"/>
+                                <RowDefinition Height="2*"/>
                             </Grid.RowDefinitions>
                             <TextBlock Grid.Row="0" Text="{Binding ShiftStr}" FontSize="20" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
                             <TextBlock Grid.Row="1" Text="{Binding CurrentDateTime}" FontSize="20" Foreground="White" FontWeight="Bold" Margin="0,0,30,10"/>
                             <!--<TextBlock Grid.Column="1" Text="|" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,30,0"/>
                             <TextBlock Grid.Column="2" Text="SCADA" FontSize="25" Foreground="White" FontWeight="Bold" Margin="0,0,10,0"/>-->
+                            <Button Grid.Row="2"  Content="登录" Width="120" FontSize="20" Foreground="White" Click="Button_Click" />
                         </Grid>
                     </StackPanel>
                 </Grid>
 
             </Border>
 
-            <Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,25,2,2">
+            <Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="2,5,2,2">
                 <ContentControl Content="{Binding UserContent}"/>
             </Border>
-            
+
             <DockPanel  Grid.Row="2" Margin="5 0 5 3">
                 <Border  Margin="5" BorderBrush="#0288d1" BorderThickness="0"  CornerRadius="5"  HorizontalAlignment="Stretch"  VerticalAlignment="Bottom">
                     <Grid>
-                        
+
                         <StackPanel  Grid.Row="1" Height="50" Orientation="Horizontal"  Margin="5 0" HorizontalAlignment="Left">
                             <Button Content="实时监控" x:Name="FirstPage"  Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FirstPage}"  Margin="5 0" Height="40" />
                             <Button Content="任务记录" x:Name="RecordPage" Margin="5 0" Height="40" Command="{Binding SwitchPagesCommand}"  CommandParameter="{Binding Name,ElementName=RecordPage}" />
@@ -99,7 +101,7 @@
                         </StackPanel>
                     </Grid>
                 </Border>
-            
+
             </DockPanel>
         </Grid>
     </Border>
diff --git a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs
index 6381e997..37f0c30c 100644
--- a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs
+++ b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml.cs
@@ -13,5 +13,11 @@ namespace Aucma.Core.ProductOffLine.Views
             InitializeComponent();
             this.DataContext = new MainWindowViewModel();
         }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            Login login = new Login();
+            login.ShowDialog();
+        }
     }
 }
diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json
index 7fd823cf..7145ab76 100644
--- a/Aucma.Core.ProductOffLine/appsettings.json
+++ b/Aucma.Core.ProductOffLine/appsettings.json
@@ -196,7 +196,7 @@
       "Enabled": true
     },
     "QuartzNetJob": {
-      "Enabled": true
+      "Enabled": false
     },
     "Scanner": { //扫码器
       "Enabled": false
@@ -208,14 +208,14 @@
   "ScannerServer": [
     {
       "Id": 1,
-      //"Ip": "10.10.92.140",
-      "Ip": "10.10.92.121",
+      "Ip": "10.10.92.140",
+      //  "Ip": "10.10.92.121",
       "Name": "内侧扫码器1"
     },
     {
       "Id": 2,
-     // "Ip": "10.10.92.141",
-      "Ip": "10.10.92.122",
+      "Ip": "10.10.92.141",
+      //  "Ip": "10.10.92.122",
       "Name": "外侧扫码器2"
     }
   ],
@@ -225,11 +225,17 @@
       "EquipName": "成品下线Plc",
       "PlcType": "Melsec",
       "Enabled": true,
+      //"IP": "127.0.0.1",
+      //"Port": 6000
       "IP": "10.10.92.70",
       "Port": 2015
     }
 
   ],
+  "AppConfig": {
+    "BarCodeAccount": "6945",
+    "ProductlineCode": "CX_02"
+  },
   "IpRateLimiting": {
     "EnableEndpointRateLimiting": false, //False: globally executed, true: executed for each
     "StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter