From 6cd2a2d6991f13ac11796abd11d61c098cdd3ce1 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期六, 28 十二月 2024 08:32:39 +0800
Subject: [PATCH] 修改问题

---
 Wms/WMS.BLL/BllTransServer/NoticeServer.cs |  501 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 268 insertions(+), 233 deletions(-)

diff --git a/Wms/WMS.BLL/BllTransServer/NoticeServer.cs b/Wms/WMS.BLL/BllTransServer/NoticeServer.cs
index 9887f0a..59d0c0c 100644
--- a/Wms/WMS.BLL/BllTransServer/NoticeServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/NoticeServer.cs
@@ -5,6 +5,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using Utility.Tools;
 using WMS.BLL.LogServer;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
@@ -15,6 +16,7 @@
 using WMS.Entity.LogEntity;
 using WMS.Entity.SysEntity;
 using WMS.IBLL.IBllTransServer;
+using static Model.InterFaceModel.RCSModel;
 
 namespace WMS.BLL.BllTransServer
 {
@@ -163,31 +165,17 @@
 
                     resultModel.Success = 0;
                     resultModel.Message = "鎴愬姛";
+
+                    //鎻愪氦浜嬪姟
+                    Db.CommitTran();
+
                     return resultModel;
                 }
                 switch (taskInfo.OrderType)
                 {
                     #region 鍏ュ簱瀹屾垚
                     case "0":
-                        //鍏ュ簱鍗曟槑缁嗕俊鎭�
-                        var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.Id == taskInfo.NoticeDetailNo);
-                        if (noticeDetail == null)
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍏ュ簱鍗曟槑缁嗕笉瀛樺湪!";
-                            return resultModel;
-                        }
-                        //鍏ュ簱鍗曚俊鎭�
-                        var notice = Db.Queryable<BllArrivalNotice>().First(w => w.ASNNo == noticeDetail.ASNNo);
-                        if (notice == null)
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍏ュ簱鍗曚笉瀛樺湪!";
-                            return resultModel;
-                        }
-                        if (notice.Status == "3" || notice.Status == "4")
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍏ュ簱鍗曞凡鎵ц瀹屾垚!";
-                            return resultModel;
-                        }
+                        
                         //鐩爣鍌ㄤ綅淇℃伅
                         var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
                         if (locatInfo == null)
@@ -195,51 +183,13 @@
                             resultModel.Message = "鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�!";
                             return resultModel;
                         }
+
                         //搴撳瓨鏄庣粏
                         var sd1 = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo);
                         if (sd1 == null)
                         {
-                            sd1 = new DataStockDetail()
-                            {
-                                LotNo = noticeDetail.LotNo,
-                                LotText = noticeDetail.LotText,
-                                SupplierLot = noticeDetail.SupplierLot,
-                                SkuNo = noticeDetail.SkuNo,
-                                SkuName = noticeDetail.SkuName,
-                                Standard = noticeDetail.Standard,
-                                Qty = 1,
-                                LockQty = 0,
-                                FrozenQty = 0,
-                                InspectQty = 0,
-                                ASNNo = noticeDetail.ASNNo,
-                                ASNDetailNo = noticeDetail.Id,
-                                WareHouseNo = locatInfo.WareHouseNo,//鎵�灞炰粨搴�
-                                RoadwayNo = locatInfo.RoadwayNo,//鎵�灞炲贩閬�
-                                AreaNo = locatInfo.AreaNo,//鎵�灞炲尯鍩�
-                                LocatNo = locatInfo.LocatNo,//鍌ㄤ綅鍦板潃
-                                PalletNo = taskInfo.PalletNo,
-                                PalletNo2 = "",
-                                PalletNo3 = "",
-                                PalletTags = "0",
-                                CompleteTime = comTime,
-                                ProductionTime = null,
-                                ExpirationTime = null,
-                                Status = "0",
-                                InspectMark = "0",
-                                InspectStatus = "0",//寰呮楠�
-                                BitPalletMark = "0",
-                                PackagNo = "",
-                                IsBale = "0",
-                                IsBelt = "0",
-
-                                PalletStatus = "1",
-
-                                IsDel = "0",
-                                CreateUser = 0,
-                                CreateTime = comTime
-                            };
-                            //鎻掑叆搴撳瓨鏄庣粏
-                            Db.Insertable(sd1).ExecuteCommand();
+                            resultModel.Message = $"璇ユ《瀵瑰簲鐨勫簱瀛樹俊鎭笉瀛樺湪锛屾《鍙凤細{taskInfo.PalletNo}!";
+                            return resultModel;
                         }
                         else
                         {
@@ -247,140 +197,154 @@
                             sd1.LockQty = 0;
                             sd1.FrozenQty = 0;
                             sd1.InspectQty = 0;
-                            sd1.ASNNo = noticeDetail.ASNNo;
-                            sd1.ASNDetailNo = noticeDetail.Id;
                             sd1.WareHouseNo = locatInfo.WareHouseNo;//鎵�灞炰粨搴�
                             sd1.RoadwayNo = locatInfo.RoadwayNo;//鎵�灞炲贩閬�
                             sd1.AreaNo = locatInfo.AreaNo;//鎵�灞炲尯鍩�
                             sd1.LocatNo = locatInfo.LocatNo;//鍌ㄤ綅鍦板潃
                             sd1.CompleteTime = comTime;
                             sd1.InspectStatus = "0";//寰呮楠�
-                            sd1.PalletStatus = "1";//棰勬贩
+                            sd1.PalletStatus = "2";//鍗婃垚鍝�
 
                             //淇敼搴撳瓨鏄庣粏
                             Db.Updateable(sd1).ExecuteCommand();
                         }
-
-                        noticeDetail.CompleteQty += 1;//瀹屾垚鏁伴噺
-                        noticeDetail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
-                        if (noticeDetail.CompleteQty >= noticeDetail.Qty)
-                        {
-                            noticeDetail.Status = "2";
-                            noticeDetail.CompleteTime = comTime;
-                        }
-                        noticeDetail.UpdateUser = 0;
-                        noticeDetail.UpdateTime = comTime;
-                        //鏇存柊鍏ュ簱鍗曟槑缁�
-                        Db.Updateable(noticeDetail).ExecuteCommand();
-
-                        notice.UpdateUser = 0;
-                        notice.UpdateTime = comTime;
-                        if (notice.Status == "0")
-                        {
-                            notice.Status = "1";
-                        }
-                        var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>().Count(m => m.IsDel == "0" && m.ASNNo == noticeDetail.ASNNo && m.Status != "2");
-                        if (asnDetailNum == 0)
-                        {
-                            notice.Status = "2";
-                            notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
-                        }
-                        //鏇存柊鍏ュ簱鍗�
-                        Db.Updateable(notice).ExecuteCommand();
-
                         locatInfo.Status = "1";//鏈夌墿鍝�
                         //鏇存柊鍌ㄤ綅鐘舵��
                         Db.Updateable(locatInfo).ExecuteCommand();
 
-                        #region 璐ㄦ璇烽獙
-                        var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == noticeDetail.SkuNo && m.LotNo == noticeDetail.LotNo && m.SupplierLot == noticeDetail.SupplierLot);
-                        if (qualityRequest == null)
+                        //鍏ュ簱鍗曟槑缁嗕俊鎭�
+                        var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.Id == taskInfo.NoticeDetailNo);
+                        if (noticeDetail != null)
                         {
-                            //璐ㄦ璇烽獙鍗曚俊鎭�
-                            string qcNo = new Common().GetMaxNo("QC");
-                            qualityRequest = new BllQualityInspectionRequest();
-                            qualityRequest.QcNo = qcNo;
-                            qualityRequest.Status = "0";
-                            qualityRequest.SkuNo = noticeDetail.SkuNo;
-                            qualityRequest.SkuName = noticeDetail.SkuName;
-                            qualityRequest.LotNo = noticeDetail.LotNo;
-                            qualityRequest.SupplierLot = noticeDetail.SupplierLot;
-                            qualityRequest.Qty = noticeDetail.Qty;
-                            qualityRequest.SamplingQty = 0;
-                            qualityRequest.ASNNo = noticeDetail.ASNNo;
-                            qualityRequest.CreateUser = 0;
-                            qualityRequest.CreateTime = comTime;
-
-                            // 璁板綍浠诲姟鏃ュ織
-                            var taskNo = new Common().GetMaxNo("TK");
-                            var exTask = new LogTask()
+                            //鍏ュ簱鍗曚俊鎭�
+                            var notice = Db.Queryable<BllArrivalNotice>().First(w => w.ASNNo == noticeDetail.ASNNo);
+                            if (notice == null)
                             {
-                                TaskNo = taskNo,
-                                Sender = "WMS",
-                                Receiver = "Limes",
-                                IsSuccess = 0,//鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
-                                StartLocat = "",//璧峰浣嶇疆
-                                PalletNo = "",//鎵樼洏鐮�
-                                IsSend = 1,//鏄惁鍙啀娆′笅鍙�
-                                IsCancel = 1,//鏄惁鍙彇娑�
-                                IsFinish = 1,//鏄惁鍙畬鎴�    
-                                Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
-                                OrderType = "5",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗� 4 鍙栨牱鍑哄簱鍗� 5 鍏朵粬
-                                EndLocat = "",//鐩爣浣嶇疆
-                                Type = "3",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
-                                Msg = "璇烽獙浠诲姟"
-                            };
-                            // 鎻掑叆浠诲姟鏃ュ織
-                            Db.Insertable(exTask).ExecuteCommand();
-
-                            // 璋冪敤Limes鎺ュ彛鍙戣捣璇烽獙
-                            var sendModel = new SendLimesModel()
-                            {
-                                QcNo = qualityRequest.QcNo,
-                                SkuNo = qualityRequest.SkuNo,
-                                Qty = qualityRequest.Qty.ToString(),
-                                LotNo = qualityRequest.LotNo,
-                                SupplierLot = qualityRequest.SupplierLot,
-                                RequestUser = "",                       // 璇烽獙浜�
-                            };
-                            var jsonData = JsonConvert.SerializeObject(sendModel);
-                            string response = "";
-                            try
-                            {
-                                var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
-                                //response = HttpHelper.DoPost(url, jsonData, "涓婁紶Limes绯荤粺鍙戣捣璇烽獙", "Limes");
-                                var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
-
-                                ////瑙f瀽杩斿洖鏁版嵁 
-                                //var limesModel = JsonConvert.DeserializeObject<LimesModel>(response);
-                                List<string> list1 = new List<string>();
-                                list1.Add(taskNo);
-                                //if (limesModel.Success == 0)
-                                //{
-                                //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
-                                new TaskServer().EditTaskIssueOk(list1, time1, time2);
-
-                                // 鏇存柊璇烽獙鍗曚俊鎭�
-                                qualityRequest.Status = "1";
-                                qualityRequest.SamplingQty = 10;//decimal.Parse(limesModel.SamplingQty);
-                                qualityRequest.RequestUser = 0;
-                                qualityRequest.RequestTime = DateTime.Now;
-                                qualityRequest.UpdateTime = DateTime.Now;
-                                qualityRequest.UpdateUser = 0;
-                                //娣诲姞璐ㄦ璇烽獙鍗�
-                                Db.Insertable(qualityRequest).ExecuteCommand();
-                                //}
-                                //if (limesModel.Success == -1)
-                                //{
-                                //    new TaskServer().EditTaskIssueNo(list1, time1, time2,limesModel.Message);
-                                //    throw new Exception(limesModel.Message);
-                                //}
+                                resultModel.Message = "璇ヤ换鍔″搴旂殑鍏ュ簱鍗曚笉瀛樺湪!";
+                                return resultModel;
                             }
-                            catch (Exception ex)
+                            if (notice.Status == "3" || notice.Status == "4")
                             {
-                                throw new Exception(ex.Message);
+                                resultModel.Message = "璇ヤ换鍔″搴旂殑鍏ュ簱鍗曞凡鎵ц瀹屾垚!";
+                                return resultModel;
                             }
+                            noticeDetail.CompleteQty += 1;//瀹屾垚鏁伴噺
+                            noticeDetail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
+                            if (noticeDetail.CompleteQty >= noticeDetail.Qty)
+                            {
+                                noticeDetail.Status = "2";
+                                noticeDetail.CompleteTime = comTime;
+                            }
+                            noticeDetail.UpdateUser = 0;
+                            noticeDetail.UpdateTime = comTime;
+                            //鏇存柊鍏ュ簱鍗曟槑缁�
+                            Db.Updateable(noticeDetail).ExecuteCommand();
+
+                            notice.UpdateUser = 0;
+                            notice.UpdateTime = comTime;
+                            if (notice.Status == "0")
+                            {
+                                notice.Status = "1";
+                            }
+                            var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>().Count(m => m.IsDel == "0" && m.ASNNo == noticeDetail.ASNNo && m.Status != "2");
+                            if (asnDetailNum == 0)
+                            {
+                                notice.Status = "2";
+                                notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
+                            }
+                            //鏇存柊鍏ュ簱鍗�
+                            Db.Updateable(notice).ExecuteCommand();
                         }
+
+                        #region 璐ㄦ璇烽獙锛屽幓鎺塎ES
+                        //var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == noticeDetail.SkuNo && m.LotNo == noticeDetail.LotNo && m.SupplierLot == noticeDetail.SupplierLot);
+                        //if (qualityRequest == null)
+                        //{
+                        //    //璐ㄦ璇烽獙鍗曚俊鎭�
+                        //    string qcNo = new Common().GetMaxNo("QC");
+                        //    qualityRequest = new BllQualityInspectionRequest();
+                        //    qualityRequest.QcNo = qcNo;
+                        //    qualityRequest.Status = "0";
+                        //    qualityRequest.SkuNo = noticeDetail.SkuNo;
+                        //    qualityRequest.SkuName = noticeDetail.SkuName;
+                        //    qualityRequest.LotNo = noticeDetail.LotNo;
+                        //    qualityRequest.SupplierLot = noticeDetail.SupplierLot;
+                        //    qualityRequest.Qty = noticeDetail.Qty;
+                        //    qualityRequest.SamplingQty = 0;
+                        //    qualityRequest.ASNNo = noticeDetail.ASNNo;
+                        //    qualityRequest.CreateUser = 0;
+                        //    qualityRequest.CreateTime = comTime;
+
+                        //    // 璁板綍浠诲姟鏃ュ織
+                        //    var taskNo = new Common().GetMaxNo("TK");
+                        //    var exTask = new LogTask()
+                        //    {
+                        //        TaskNo = taskNo,
+                        //        Sender = "WMS",
+                        //        Receiver = "Limes",
+                        //        IsSuccess = 0,//鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+                        //        StartLocat = "",//璧峰浣嶇疆
+                        //        PalletNo = "",//鎵樼洏鐮�
+                        //        IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+                        //        IsCancel = 1,//鏄惁鍙彇娑�
+                        //        IsFinish = 1,//鏄惁鍙畬鎴�    
+                        //        Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+                        //        OrderType = "5",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗� 4 鍙栨牱鍑哄簱鍗� 5 鍏朵粬
+                        //        EndLocat = "",//鐩爣浣嶇疆
+                        //        Type = "3",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
+                        //        Msg = "璇烽獙浠诲姟"
+                        //    };
+                        //    // 鎻掑叆浠诲姟鏃ュ織
+                        //    Db.Insertable(exTask).ExecuteCommand();
+
+                        //    // 璋冪敤Limes鎺ュ彛鍙戣捣璇烽獙
+                        //    var sendModel = new SendLimesModel()
+                        //    {
+                        //        QcNo = qualityRequest.QcNo,
+                        //        SkuNo = qualityRequest.SkuNo,
+                        //        Qty = qualityRequest.Qty.ToString(),
+                        //        LotNo = qualityRequest.LotNo,
+                        //        SupplierLot = qualityRequest.SupplierLot,
+                        //        RequestUser = "",                       // 璇烽獙浜�
+                        //    };
+                        //    var jsonData = JsonConvert.SerializeObject(sendModel);
+                        //    string response = "";
+                        //    try
+                        //    {
+                        //        var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+                        //        //response = HttpHelper.DoPost(url, jsonData, "涓婁紶Limes绯荤粺鍙戣捣璇烽獙", "Limes");
+                        //        var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+
+                        //        ////瑙f瀽杩斿洖鏁版嵁 
+                        //        //var limesModel = JsonConvert.DeserializeObject<LimesModel>(response);
+                        //        List<string> list1 = new List<string>();
+                        //        list1.Add(taskNo);
+                        //        //if (limesModel.Success == 0)
+                        //        //{
+                        //        //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
+                        //        new TaskServer().EditTaskIssueOk(list1, time1, time2);
+
+                        //        // 鏇存柊璇烽獙鍗曚俊鎭�
+                        //        qualityRequest.Status = "1";
+                        //        qualityRequest.SamplingQty = 10;//decimal.Parse(limesModel.SamplingQty);
+                        //        qualityRequest.RequestUser = 0;
+                        //        qualityRequest.RequestTime = DateTime.Now;
+                        //        qualityRequest.UpdateTime = DateTime.Now;
+                        //        qualityRequest.UpdateUser = 0;
+                        //        //娣诲姞璐ㄦ璇烽獙鍗�
+                        //        Db.Insertable(qualityRequest).ExecuteCommand();
+                        //        //}
+                        //        //if (limesModel.Success == -1)
+                        //        //{
+                        //        //    new TaskServer().EditTaskIssueNo(list1, time1, time2,limesModel.Message);
+                        //        //    throw new Exception(limesModel.Message);
+                        //        //}
+                        //    }
+                        //    catch (Exception ex)
+                        //    {
+                        //        throw new Exception(ex.Message);
+                        //    }
+                        //}
                         #endregion
 
                         break;
@@ -388,37 +352,12 @@
 
                     #region 鍑哄簱瀹屾垚
                     case "1":
-                        //鍑哄簱鍗曟槑缁嗕俊鎭�
-                        var exNoticeDetail = Db.Queryable<BllExportNoticeDetail>().First(w => w.Id == taskInfo.NoticeDetailNo);
-                        if (exNoticeDetail == null)
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍑哄簱鍗曟槑缁嗕笉瀛樺湪!";
-                            return resultModel;
-                        }
-                        //鍑哄簱鍗曚俊鎭�
-                        var exNotice = Db.Queryable<BllExportNotice>().First(w => w.SONo == exNoticeDetail.SONo);
-                        if (exNotice == null)
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍑哄簱鍗曚笉瀛樺湪!";
-                            return resultModel;
-                        }
-                        if (exNotice.Status == "4" || exNotice.Status == "5")
-                        {
-                            resultModel.Message = "璇ヤ换鍔″搴旂殑鍑哄簱鍗曞凡鎵ц瀹屾垚!";
-                            return resultModel;
-                        }
+
                         //璧峰鍌ㄤ綅淇℃伅
                         var startLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
                         if (startLocatInfo == null)
                         {
                             resultModel.Message = "璧峰鍌ㄤ綅淇℃伅涓嶅瓨鍦�!";
-                            return resultModel;
-                        }
-                        //鐩爣鍌ㄤ綅淇℃伅
-                        var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
-                        if (endLocatInfo == null)
-                        {
-                            resultModel.Message = "鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�!";
                             return resultModel;
                         }
                         //搴撳瓨鏄庣粏
@@ -428,34 +367,16 @@
                             resultModel.Message = "搴撳瓨淇℃伅涓嶅瓨鍦�!";
                             return resultModel;
                         }
-                        //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
-                        exNoticeDetail.CompleteQty += sd2.Qty;
-                        Db.Updateable(exNoticeDetail).ExecuteCommand();
-
-                        exNotice.UpdateUser = 0;
-                        exNotice.UpdateTime = comTime;
-                        if (exNotice.Status == "0" || exNotice.Status == "1" || exNotice.Status == "2")
-                        {
-                            exNotice.Status = "3";//鏇存敼涓烘鍦ㄦ墽琛�
-                        }
-                        var num = Db.Queryable<BllExportNoticeDetail>().Count(m => m.IsDel == "0" && m.SONo == exNoticeDetail.SONo && m.CompleteQty < m.Qty);
-                        if (num <= 0)
-                        {
-                            exNotice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�                            
-                        }
-                        //淇敼鍑哄簱鍗曚俊鎭�
-                        Db.Updateable(exNotice).ExecuteCommand();
-
                         sd2.Qty = 0;
                         sd2.LockQty = 0;
                         sd2.FrozenQty = 0;
                         sd2.InspectQty = 0;
                         sd2.ASNNo = "";
                         sd2.ASNDetailNo = null;
-                        sd2.WareHouseNo = endLocatInfo.WareHouseNo;//鎵�灞炰粨搴�
-                        sd2.RoadwayNo = endLocatInfo.RoadwayNo;//鎵�灞炲贩閬�
-                        sd2.AreaNo = endLocatInfo.AreaNo;//鎵�灞炲尯鍩�
-                        sd2.LocatNo = endLocatInfo.LocatNo;//鍌ㄤ綅鍦板潃
+                        sd2.WareHouseNo = "";//鎵�灞炰粨搴�
+                        sd2.RoadwayNo = "";//鎵�灞炲贩閬�
+                        sd2.AreaNo = "";//鎵�灞炲尯鍩�
+                        sd2.LocatNo = "";//鍌ㄤ綅鍦板潃
                         sd2.CompleteTime = comTime;
                         //淇敼搴撳瓨鏄庣粏
                         Db.Updateable(sd2).ExecuteCommand();
@@ -463,11 +384,40 @@
                         startLocatInfo.Status = "0";//绌哄偍浣�
                         //淇敼璧峰鍌ㄤ綅鐘舵��
                         Db.Updateable(startLocatInfo).ExecuteCommand();
+                        //鍑哄簱鍗曟槑缁嗕俊鎭�
+                        var exNoticeDetail = Db.Queryable<BllExportNoticeDetail>().First(w => w.Id == taskInfo.NoticeDetailNo);
+                        if (exNoticeDetail != null)
+                        {
+                            //鍑哄簱鍗曚俊鎭�
+                            var exNotice = Db.Queryable<BllExportNotice>().First(w => w.SONo == exNoticeDetail.SONo);
+                            if (exNotice == null)
+                            {
+                                resultModel.Message = "璇ヤ换鍔″搴旂殑鍑哄簱鍗曚笉瀛樺湪!";
+                                return resultModel;
+                            }
+                            if (exNotice.Status == "4" || exNotice.Status == "5")
+                            {
+                                resultModel.Message = "璇ヤ换鍔″搴旂殑鍑哄簱鍗曞凡鎵ц瀹屾垚!";
+                                return resultModel;
+                            }
+                            exNotice.UpdateUser = 0;
+                            exNotice.UpdateTime = comTime;
+                            if (exNotice.Status == "0" || exNotice.Status == "1" || exNotice.Status == "2")
+                            {
+                                exNotice.Status = "3";//鏇存敼涓烘鍦ㄦ墽琛�
+                            }
+                            var num = Db.Queryable<BllExportNoticeDetail>().Count(m => m.IsDel == "0" && m.SONo == exNoticeDetail.SONo && m.CompleteQty < m.Qty);
+                            if (num <= 0)
+                            {
+                                exNotice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�                            
+                            }
+                            //淇敼鍑哄簱鍗曚俊鎭�
+                            Db.Updateable(exNotice).ExecuteCommand();
 
-                        endLocatInfo.Status = "1";//鏈夌墿鍝�
-                        //淇敼鐩爣鍌ㄤ綅鐘舵��
-                        Db.Updateable(endLocatInfo).ExecuteCommand();
-
+                            //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
+                            exNoticeDetail.CompleteQty += sd2.Qty;
+                            Db.Updateable(exNoticeDetail).ExecuteCommand();
+                        }                        
                         break;
                     #endregion
 
@@ -497,24 +447,28 @@
                             sd3.RoadwayNo = endLocatInfo2.RoadwayNo;//鎵�灞炲贩閬�
                             sd3.AreaNo = endLocatInfo2.AreaNo;//鎵�灞炲尯鍩�
                             sd3.LocatNo = endLocatInfo2.LocatNo;//鍌ㄤ綅鍦板潃
-                            if (endLocatInfo2.AreaNo == "A01")//娲佸噣鍖�
+                            if (endLocatInfo2.AreaNo.Contains("01"))//鍑�妗跺尯
                             {
-                                sd3.PalletStatus = "0";
+                                sd3.PalletStatus = "0";                               
                             }
-                            else if (endLocatInfo2.AreaNo == "A02")//棰勬贩鍖�
+                            else if (endLocatInfo2.AreaNo.Contains("02"))//棰勬贩鍖�
                             {
                                 sd3.PalletStatus = "1";
                             }
-                            else if (endLocatInfo2.AreaNo == "A03")//鍗婃垚鍝佸尯
+                            else if (endLocatInfo2.AreaNo.Contains("03"))//鍗婃垚鍝佸尯
                             {
                                 sd3.PalletStatus = "2";
                             }
-                            else if (endLocatInfo2.AreaNo == "A04")//鑴忔《鍖�
+                            else if (endLocatInfo2.AreaNo.Contains("04"))//鑴忔《鍖�
                             {
                                 sd3.PalletStatus = "3";
-                            }
+                                sd3.LotNo = "";//鎵规
+                                sd3.SkuNo = "";
+                                sd3.SkuName = "";
+                                sd3.InspectStatus = "0";//寰呮楠�
+                            }                            
                         }
-                        if (taskInfo.Type == "1")//鍑哄簱浠诲姟
+                        else if (taskInfo.Type == "1")//鍑哄簱浠诲姟
                         {
                             //璧峰鍌ㄤ綅淇℃伅
                             var startLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
@@ -532,8 +486,64 @@
                             sd3.AreaNo = "";//鎵�灞炲尯鍩�
                             sd3.LocatNo = "";//鍌ㄤ綅鍦板潃
                         }
+                        else if (taskInfo.Type == "2")//绉诲簱浠诲姟
+                        {
+                            //璧峰鍌ㄤ綅淇℃伅
+                            var startLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0");
+                            if (startLocatInfo2 == null)
+                            {
+                                resultModel.Message = "璧峰鍌ㄤ綅淇℃伅涓嶅瓨鍦�!";
+                                return resultModel;
+                            }
+                            startLocatInfo2.Status = "0";//绌哄偍浣�
+                            //淇敼璧峰鍌ㄤ綅鐘舵��
+                            Db.Updateable(startLocatInfo2).ExecuteCommand();
+
+                            //鐩爣鍌ㄤ綅淇℃伅
+                            var endLocatInfo2 = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0");
+                            if (endLocatInfo2 == null)
+                            {
+                                resultModel.Message = "鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�!";
+                                return resultModel;
+                            }
+                            endLocatInfo2.Status = "1";//鏈夌墿鍝�
+                            //淇敼鐩爣鍌ㄤ綅鐘舵��
+                            Db.Updateable(endLocatInfo2).ExecuteCommand();
+
+                            sd3.WareHouseNo = endLocatInfo2.WareHouseNo;//鎵�灞炰粨搴�
+                            sd3.RoadwayNo = endLocatInfo2.RoadwayNo;//鎵�灞炲贩閬�
+                            sd3.AreaNo = endLocatInfo2.AreaNo;//鎵�灞炲尯鍩�
+                            sd3.LocatNo = endLocatInfo2.LocatNo;//鍌ㄤ綅鍦板潃
+                            sd3.Status = "0";
+                            if (endLocatInfo2.AreaNo.Contains("01"))//娲佸噣鍖�
+                            {
+                                sd3.PalletStatus = "0";
+                                sd3.Status = "0";
+                            }
+                            else if (endLocatInfo2.AreaNo.Contains("02"))//棰勬贩鍖�
+                            {
+                                sd3.PalletStatus = "1";
+                            }
+                            else if (endLocatInfo2.AreaNo.Contains("03"))//鍗婃垚鍝佸尯
+                            {
+                                sd3.PalletStatus = "2";
+                            }
+                            else if (endLocatInfo2.AreaNo.Contains("04"))//鑴忔《鍖�
+                            {
+                                sd3.PalletStatus = "3";
+                                sd3.LotNo = "";//鎵规
+                                sd3.SkuNo = "";
+                                sd3.SkuName = "";
+                                sd3.InspectStatus = "0";//寰呮楠�
+                            }
+                        }
                         //淇敼搴撳瓨鏄庣粏
                         Db.Updateable(sd3).ExecuteCommand();
+
+                        #region 鍘绘帀MES
+                        //鍥炰紶妗剁姸鎬佺粰MES
+                        //BackPalletStatus(taskInfo.PalletNo, sd3.PalletStatus);
+                        #endregion
 
                         break;    
                     #endregion
@@ -558,6 +568,31 @@
         }
 
         /// <summary>
+        /// 鍥炰紶妗剁姸鎬佺粰MES
+        /// </summary>
+        /// <param name="PalletNo">妗跺彿</param>
+        /// <param name="Status">0锛氬噣妗� 1锛氶娣� 2锛氬崐鎴愬搧 3锛氳剰妗�</param>
+        /// <param name="url"></param>
+        public void BackPalletStatus(string PalletNo, string Status,string url="")
+        {
+            try
+            {
+                var obj = new
+                {
+                    PalletNo = PalletNo,
+                    Status = Status
+                };
+                string jsonReq = JsonConvert.SerializeObject(obj);
+                var response = HttpHelper.DoPost(url, jsonReq, "鍥炰紶MES妗剁姸鎬�", "MES").ToString();
+                var result = JsonConvert.DeserializeObject<ReMes>(response);//瑙f瀽杩斿洖鏁版嵁
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        /// <summary>
         /// 涓嬪彂鍑哄簱鍗�
         /// </summary>
         /// <param name="model"></param>

--
Gitblit v1.8.0