From 7c63794aa85ab939308d10a9ad5c1a57c46bbf6f Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周六, 14 12月 2024 14:01:46 +0800
Subject: [PATCH] 222

---
 CC/iWareCC_ASRS/FormCC.cs |  306 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 202 insertions(+), 104 deletions(-)

diff --git a/CC/iWareCC_ASRS/FormCC.cs b/CC/iWareCC_ASRS/FormCC.cs
index c26f950..bab25df 100644
--- a/CC/iWareCC_ASRS/FormCC.cs
+++ b/CC/iWareCC_ASRS/FormCC.cs
@@ -20,6 +20,7 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.Data.Entity.Core.Metadata.Edm;
 using System.Drawing;
 using System.Linq;
 using System.Linq.Expressions;
@@ -29,12 +30,18 @@
 using System.Windows.Forms;
 using XiGang.Core.Model;
 using XiGang.Core.Model.ViewModels;
+using static WZ.Useful.Commons.NativeMethods;
 
 
 namespace iWareCC
 {
     public partial class FormCC : Form
     {
+
+        /// <summary>
+        /// 鍏ㄥ眬-閰嶇疆鎶ヨ淇℃伅鍒楄〃
+        /// </summary>
+        public static DeviceWarningOutput configDeviceWarningList = DeviceWarningHandler.GetConfigWarningList();
 
         /// <summary>
         /// 鍏ㄥ眬鈥旀槸鍚﹀彲浠ヨ繍琛屾墽琛屽嚭搴撴ā寮�
@@ -172,31 +179,12 @@
             startModelTipsThread.Start();
 
             #region 鑾峰彇璁惧鏁版嵁
-            ParameterizedThreadStart parStart1 = new ParameterizedThreadStart(GetSrmInfo);
-            Thread thread1 = new Thread(parStart1);
-            object o1 = (int)EDevice.涓�鍙峰爢鍨涙満;
-            thread1.Start(o1);
-
-            ParameterizedThreadStart parStart2 = new ParameterizedThreadStart(GetSrmInfo);
-            Thread thread2 = new Thread(parStart2);
-            object o2 = (int)EDevice.浜屽彿鍫嗗灈鏈�;
-            thread2.Start(o2);
-
-            ParameterizedThreadStart parStart3 = new ParameterizedThreadStart(GetSrmInfo);
-            Thread thread3 = new Thread(parStart3);
-            object o3 = (int)EDevice.涓夊彿鍫嗗灈鏈�;
-            thread3.Start(o3);
-
-            ParameterizedThreadStart parStart4 = new ParameterizedThreadStart(GetSrmInfo);
-            Thread thread4 = new Thread(parStart4);
-            object o4 = (int)EDevice.鍥涘彿鍫嗗灈鏈�;
-            thread4.Start(o4);
-
-
-
 
             var tskGetStationInfo = new Thread(GetStationInfo);
             tskGetStationInfo.Start();
+
+            var _GetStationWarningInfo = new Thread(GetStationWarningInfo);
+            _GetStationWarningInfo.Start();
 
 
             tskSetSrmLable = new Thread(SrmRead_Label);
@@ -391,84 +379,6 @@
 
 
 
-        /// <summary>
-        /// 鑾峰彇鍫嗗灈鏈虹殑瀹炴椂淇℃伅
-        /// </summary>
-        private void GetSrmInfo(object int_device)
-        {
-            while (true)
-            {
-                EDevice device = (EDevice)Enum.Parse(typeof(EDevice), int_device.ToString());
-                Thread.Sleep(cycleDelay_Device);
-                try
-                {
-                    using (var opcClinet = new SrmService.SrmServiceClient())
-                    {
-                        srmViewDict[(int)device] = opcClinet.GetSrmInfo((int)device);
-                        CastToDevice_SrmRealTime(srmViewDict[(int)device]);
-                        List<String> warningAddressList = new List<string>();
-                        if (srmViewDict[(int)device].R_WarningDBList != null && srmViewDict[(int)device].R_WarningDBList.Length > 0)
-                        {
-                            var waringList = srmViewDict[(int)device].R_WarningDBList.ToList();
-                            if (waringList != null && waringList.Count > 0)
-                            {
-                                for (int i = 0; i < waringList.Count; i++)
-                                {
-                                    DeviceWarningHandler.SaveWarning(device, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask,
-                                        waringList[i].Code, waringList[i].Address, waringList[i].Context);//鏂板鎶ヨ
-                                    warningAddressList.Add(waringList[i].Address);
-                                }
-                            }
-                        }
-                        DeviceWarningHandler.AutoCloseWarning(device, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask, warningAddressList);//鑷姩鍏抽棴鎶ヨ
-                    }
-                }
-                catch (Exception ex)
-                {
-                    Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask, "鑾峰彇" + device.ToString() + "鐨勫疄鏃朵俊鎭紓甯�:" + ex.Message, ex);
-                    continue;
-                }
-            };
-        }
-
-        /// <summary>
-        /// 杞崲涓篠RM鐨勫疄鏃剁姸鎬�
-        /// </summary>
-        /// <param name="view"></param>
-        private void CastToDevice_SrmRealTime(SrmView view)
-        {
-            List<Device_SrmRealTime> realTimeList = new List<Device_SrmRealTime>();
-            Device_SrmRealTime obj = new Device_SrmRealTime();
-            EDevice device = (EDevice)Enum.Parse(typeof(EDevice), view.R_SrmNo.ToString());
-            obj = new Device_SrmRealTime()
-            {
-                SrmCode = view.R_SrmNo.ToString(),
-                SrmName = device.ToString(),
-                Mode = view.R_Mode.ToString(),
-                ModeName = view.ModeName,
-                State = view.R_State.ToString(),
-                StateName = view.StateName,
-
-                TaskID = view.R_TaskNo.ToString(),
-                LiftFull = view.R_LiftFull == 1,
-                PosX = view.R_PosX,
-                PosY = view.R_PosY,
-                PosZ = view.R_PosZ,
-                PosZName = EnumberHelper.GetEnumName<ESrmForkPosition>(view.R_PosZ).ToString(),
-                // XCoordinate=view.r_xc
-
-                SrmToPlace = view.SrmToPlace,
-                SrmSourcePlace = view.SrmSourcePlace,
-                ZCoordinate = view.R_PosZmm.ToString(),
-                XCoordinate = view.R_PosXmm.ToString(),
-                YCoordinate = view.R_PosYmm.ToString()
-
-            };
-            realTimeList.Add(obj);
-
-            DeviceSrmRealTimeHandler.Update(realTimeList, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask);
-
-        }
 
 
 
@@ -603,19 +513,19 @@
 
                     this.lbl_Mode_FJ.Text = "璁惧妯″紡:" + PlcHelper.GetModeName(stationView.R_Mode_FJ);
                     this.lbl_XinTiao_FJ.Text = "蹇冭烦:" + stationView.R_HandShake_FJ;
-                    this.lbl_Warning_FJ.Text = "蹇冭烦:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_FJ);
+                    this.lbl_Warning_FJ.Text = "鎶ヨ绫诲瀷:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_FJ);
 
                     this.lbl_Mode_MB.Text = "璁惧妯″紡:" + PlcHelper.GetModeName(stationView.R_Mode_MB);
                     this.lbl_XinTiao_MB.Text = "蹇冭烦:" + stationView.R_HandShake_MB;
-                    this.lbl_Warning_MB.Text = "蹇冭烦:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_MB);
+                    this.lbl_Warning_MB.Text = "鎶ヨ绫诲瀷:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_MB);
 
                     this.lbl_Mode_HB.Text = "璁惧妯″紡:" + PlcHelper.GetModeName(stationView.R_Mode_HB);
                     this.lbl_XinTiao_HB.Text = "蹇冭烦:" + stationView.R_HandShake_HB;
-                    this.lbl_Warning_HB.Text = "蹇冭烦:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_HB);
+                    this.lbl_Warning_HB.Text = "鎶ヨ绫诲瀷:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_HB);
 
                     this.lbl_Mode_FX.Text = "璁惧妯″紡:" + PlcHelper.GetModeName(stationView.R_Mode_FX);
                     this.lbl_XinTiao_FX.Text = "蹇冭烦:" + stationView.R_HandShake_FX;
-                    this.lbl_Warning_FX.Text = "蹇冭烦:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_FX);
+                    this.lbl_Warning_FX.Text = "鎶ヨ绫诲瀷:" + PlcHelper.GetWarningTypeName(stationView.R_Warning_FX);
 
                     ////鏄剧ずRGV浠诲姟瀹屾垚鍜屽畬鎴愮‘璁や俊鍙�
                     //this.lbl_R_RGV_Finish.Text = "RGV浠诲姟瀹屾垚:" + rgvView.R_RGV_Finish;
@@ -683,6 +593,55 @@
                         tb_Rgv_Alter.Text = "";
                     }
                     DeviceWarningHandler.AutoCloseWarning(EDevice.RGV, iWareCommon.Utils.LogType.RgvThreadService, warningAddressList);//鑷姩鍏抽棴鎶ヨ
+
+                    //*/
+                }
+                catch (Exception ex)
+                {
+                    rgvView = null;
+                    Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.StationThreadService, "鑾峰彇绔欑偣淇℃伅鍑虹幇寮傚父:" + ex.Message, ex);
+                    continue;
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 鑾峰彇Station 鎶ヨ淇℃伅
+        /// </summary>
+        /// <param name="obj"></param>
+        private async void GetStationWarningInfo(object obj)
+        {
+            while (true)
+            {
+                Thread.Sleep(2000);//1绉掗挓璇诲彇涓�娆�
+                try
+                {
+                    if (stationServiceClient == null)
+                    {
+                        continue;
+                    }
+                    /*
+                    iWareCC.StationService.DeviceWarningInfo[] waringList = await stationServiceClient.GetWaringInfoListAsync((int)EDevice.Station, configDeviceWarningList.wmsConfigDeviceWarnings.ToArray());
+
+                    //鏄剧ず鎶ヨ淇℃伅
+                    List<String> warningCodeList = new List<string>();
+                    if (waringList != null && waringList.Length > 0)
+                    {
+                        for (int i = 0; i < waringList.Length; i++)
+                        {
+                            var findObj = configDeviceWarningList.wms_config_device_warning_list.Where(x => x.WarningCode == waringList[i].Codek__BackingField).FirstOrDefault();
+                            DeviceWarningHandler.SaveWarning(EDevice.Station, iWareCommon.Utils.LogType.StationThreadService,
+                                findObj.WarningCode, findObj.DeviceAreaCode, findObj.WarningContent, findObj.DeviceWarningType);//鏂板鎶ヨ
+                            warningCodeList.Add(findObj.WarningCode);
+                        }
+
+                    }
+                    else
+                    {
+
+                    }
+                    DeviceWarningHandler.AutoCloseWarning(EDevice.Station, iWareCommon.Utils.LogType.StationThreadService, warningCodeList);//鑷姩鍏抽棴鎶ヨ
 
                     //*/
                 }
@@ -1520,6 +1479,145 @@
                     item.UpiStatus = (int)UpiStatusEnum.鍒濆;
                 }
 
+                //娓呯┖闃熷垪鏁版嵁
+                var list = db.mes_upi_linequeue.ToList();
+                db.mes_upi_linequeue.RemoveRange(list);
+
+                db.SaveChanges();
+            }
+            if (!string.IsNullOrEmpty(alertMsg))
+            {
+                MessageBox.Show("閿欒:" + alertMsg);
+            }
+            else
+            {
+                MessageBox.Show("宸插鐞�");
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+
+
+            var alertMsg = "";
+            using (WmsDBModel db = new WmsDBModel())
+            {
+                //鏌ヨ绔嬩綋搴撲腑鐨剈pi鍒楄〃
+                var quanList = db.wms_stock_quan.ToList().Select(x => x.Upi).ToList();
+                var upiList = db.mes_batchOrderUPI_new.Where(x => !quanList.Contains(x.UPI)).ToList();
+                foreach (var item in upiList)
+                {
+                    item.AreaCode = (int)AreaCodeEnum.鏃犲尯鍩�;
+                    item.UpiStatus = (int)UpiStatusEnum.鍒濆;
+                }
+
+                var packageCodeList = upiList.Select(x => x.PackageCode).ToList();
+                var pList = db.mes_package_gather.Where(x => packageCodeList.Contains(x.PackageCode)).ToList();
+                foreach (var item in pList)
+                {
+                    item.AreaCode = (int)AreaCodeEnum.鏃犲尯鍩�;
+                    item.UpiStatus = (int)UpiStatusEnum.鍒濆;
+                }
+                //娓呯┖闃熷垪鏁版嵁
+                var list = db.mes_upi_linequeue.ToList();
+                db.mes_upi_linequeue.RemoveRange(list);
+
+                db.SaveChanges();
+            }
+            if (!string.IsNullOrEmpty(alertMsg))
+            {
+                MessageBox.Show("閿欒:" + alertMsg);
+            }
+            else
+            {
+                MessageBox.Show("宸插鐞�");
+            }
+        }
+
+        private void btn1_Click(object sender, EventArgs e)
+        {
+            var taskNo = this.tb_taskNo.Text.Trim();
+
+            var alertMsg = "";
+            using (WmsDBModel wmsDB = new WmsDBModel())
+            {
+                var task = wmsDB.wms_rbline_task.Where(x => x.TaskNo == taskNo && x.RbTaskType == (int)RbTaskTypeEnum.鍏ュ簱浠诲姟 && x.TaskStatus == (int)TaskStatusEnum.宸蹭笅鍙�).FirstOrDefault();
+                if (task == null)
+                {
+                    MessageBox.Show("娌℃壘鍒颁换鍔�");
+                    return;
+                }
+
+                var upiCode = task.Upi;
+                var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
+                if (upiObj == null)
+                {
+                    MessageBox.Show($"鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ");
+                    return;
+                }
+                //澧炲姞搴撳瓨
+                wms_stock_quan qun = new wms_stock_quan()
+                {
+                    Id = Yitter.IdGenerator.YitIdHelper.NextId(),
+                    Shelf = upiObj.Shelf,
+                    Upi = upiCode,
+                    PlanNo = task.PlanNo,
+                    DetailName = upiObj.DetailName,
+                    OrderId = task.OrderId,
+                    CreateTime = DateTime.Now,
+                    CreateUserName = SysGloble.WCSSystem,
+                    InTime = DateTime.Now,
+                    OperReason = "鍏ュ簱",
+                    PackageCode = task.PackageCode,
+                    Length = task.Length,
+                    Width = task.Width,
+                    Thk = task.Thk,
+                    PlaceCode = task.PlaceCode,
+                    StockStatus = (int)StockStatusEnum.鍦ㄥ簱,
+                    StockStatusName = StockStatusEnum.鍦ㄥ簱.ToString(),
+
+                };
+                wmsDB.wms_stock_quan.Add(qun);
+
+                task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
+                task.FinishedTime = DateTime.Now;
+
+
+                var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
+                place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
+
+
+                WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缂撳瓨鍏ュ簱瀹屾垚:" + task.PlaceCode);
+
+                wmsDB.SaveChanges();
+            }
+            if (!string.IsNullOrEmpty(alertMsg))
+            {
+                MessageBox.Show("閿欒:" + alertMsg);
+            }
+            else
+            {
+                MessageBox.Show("宸插鐞�");
+            }
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            //鏇存柊搴撳瓨琛ㄤ腑鐨勬搴忓瓧娈�
+            var alertMsg = "";
+            using (WmsDBModel db = new WmsDBModel())
+            {
+                //鏌ヨ绔嬩綋搴撲腑鐨剈pi鍒楄〃
+                var quanList = db.wms_stock_quan.ToList();
+                var query_quanList = quanList.Select(x => x.Upi).ToList();
+                var upiList = db.mes_batchOrderUPI_new.Where(x => query_quanList.Contains(x.UPI)).ToList();
+                foreach (var item in quanList)
+                {
+                    var _shelf = upiList.Find(x => x.UPI == item.Upi);
+                    item.Shelf = _shelf.Shelf;
+                }
+
+
                 db.SaveChanges();
             }
             if (!string.IsNullOrEmpty(alertMsg))

--
Gitblit v1.9.3