From 86985a3e211ab4cc1e94a696c15a6f77d21c462a Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期二, 15 十月 2024 18:36:51 +0800
Subject: [PATCH] 修改出库单据问题

---
 Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs        |   80 +++++++++++--------
 Wms/WMS.BLL/BllSoServer/ExportNoticeDetailServer.cs  |    5 +
 Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs              |   88 ++++++++++++++++++++--
 HTML/views/SOSetting/ExportNotice.html               |    6 +
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs             |   26 +++---
 Wms/Model/ModelDto/BllSoDto/ExportNoticeDetailDto.cs |    9 ++
 6 files changed, 158 insertions(+), 56 deletions(-)

diff --git a/HTML/views/SOSetting/ExportNotice.html b/HTML/views/SOSetting/ExportNotice.html
index f1becef..846a008 100644
--- a/HTML/views/SOSetting/ExportNotice.html
+++ b/HTML/views/SOSetting/ExportNotice.html
@@ -387,7 +387,11 @@
 					<script type="text/html" id="table-content-list2">
 						{{# function GetBtn2(d){
 								var html = '';
-								
+								if((d.StatusZ == "2" || d.StatusZ == "3"|| d.StatusZ == "4") && (d.Type == "1" || d.Type == "2" || d.Type == "3") && d.IsWave == "0"){
+									html += `<a class="layui-btn layui-btn-normal layui-btn-xs shoufenClass" lay-event="wan">
+										<i class="layui-icon layui-icon-ok"></i>鎵嬪姩鍒嗛厤
+									</a>`;
+								}
 								if((d.Status == "0" ||d.Status == "1") && d.Qty > d.AllotQty && d.IsWave == "0"){ 
 									html += `<a class="layui-btn layui-btn-normal layui-btn-xs shoufenClass" lay-event="wan">
 												<i class="layui-icon layui-icon-ok"></i>鎵嬪姩鍒嗛厤
diff --git a/Wms/Model/ModelDto/BllSoDto/ExportNoticeDetailDto.cs b/Wms/Model/ModelDto/BllSoDto/ExportNoticeDetailDto.cs
index 4ef74ba..d5fb657 100644
--- a/Wms/Model/ModelDto/BllSoDto/ExportNoticeDetailDto.cs
+++ b/Wms/Model/ModelDto/BllSoDto/ExportNoticeDetailDto.cs
@@ -19,6 +19,15 @@
         /// Desc:鍑哄簱鍗曞彿
         /// </summary>           
         public string SONo { get; set; }
+        /// <summary>
+        /// Desc:鍗曟嵁绫诲瀷
+        /// </summary>           
+        public string Type { get; set; }
+
+        /// <summary>
+        /// Desc:鎬诲崟鐘舵��
+        /// </summary>           
+        public string StatusZ { get; set; }
 
         /// <summary>
         /// Desc:鐗╂枡缂栫爜
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index c905806..faa19db 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -2247,29 +2247,29 @@
                             factQty += box.Qty;
                             boxFullQty += box.Qty;
                         }
-                        if (boxFullQty > bNum)
-                        {
-                            throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
-                        }
+                        //if (boxFullQty > bNum)
+                        //{
+                        //    throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+                        //}
                     }
                     Db.Updateable(boxInfoList).ExecuteCommand();
 
                     // 鏇存柊鎵樼洏缁戝畾琛�
                     bind.Qty += factQty;
                 }
-                if (bind.FullQty < bind.Qty && isDeposit == 0 && isTextTable == 0)
-                {
-                    throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
-                }
+                //if (bind.FullQty < bind.Qty && isDeposit == 0 && isTextTable == 0)
+                //{
+                //    throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+                //}
 
-                if (bind.FullQty == bind.Qty)
+                if (bind.FullQty <= bind.Qty)
                 {
                     bind.BitPalletMark = "0";
                 }
-                if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0)
-                {
-                    throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
-                }
+                //if (bind.Qty > pNum && isDeposit == 0 && isTextTable == 0)
+                //{
+                //    throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                //}
                 Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
 
                 // 鏇存敼鍏ュ簱鍗曟槑缁嗗凡缁勬暟閲�
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
index 594ae57..7ccaf70 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
@@ -520,6 +520,7 @@
                     Db.Updateable(pallet).ExecuteCommand();
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
+                    noticeDetail.Status = "2";
                     Db.Updateable(noticeDetail).ExecuteCommand();
 
                     var num = Db.Queryable<BllExportNoticeDetail>()
@@ -527,7 +528,10 @@
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                        noticeDetail.Status = "3";
+                        Db.Updateable(noticeDetail).ExecuteCommand();
                     }
+                    
                     //淇敼鍑哄簱鍗曚俊鎭�
                     Db.Updateable(notice).ExecuteCommand();
                 }
@@ -739,6 +743,7 @@
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
+                    noticeDetail.Status = "2"; 
                     Db.Updateable(noticeDetail).ExecuteCommand();
 
                     var num = Db.Queryable<BllExportNoticeDetail>()
@@ -746,6 +751,9 @@
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+
+                        noticeDetail.Status = "3";
+                        Db.Updateable(noticeDetail).ExecuteCommand();
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
                     Db.Updateable(notice).ExecuteCommand();
@@ -940,6 +948,7 @@
 
                 //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                 noticeDetail.CompleteQty += int.Parse(PickQty);
+                noticeDetail.Status = "2";
                 Db.Updateable(noticeDetail).ExecuteCommand();
 
                 var num = Db.Queryable<BllExportNoticeDetail>()
@@ -947,6 +956,8 @@
                 if (num <= 0)
                 {
                     notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                    noticeDetail.Status = "3";
+                    Db.Updateable(noticeDetail).ExecuteCommand();
                 }
                 //淇敼鍑哄簱鍗曚俊鎭�
                 Db.Updateable(notice).ExecuteCommand();
@@ -3857,10 +3868,14 @@
                 {
                     throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                 }
-                if (notice.Status != "3")
+                if (notice.Type != "1" && notice.Type != "2" && notice.Type != "3")
                 {
-                    throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    if (notice.Status != "3")
+                    {
+                        throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    }
                 }
+               
                 //鍑哄簱鍗曟槑缁�
                 var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
                     .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
@@ -3897,7 +3912,7 @@
                 #region 鎷兼墭淇℃伅
                 var sdId = 0;
                 bool isNew = false;
-                var pinStockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.SkuNo == allot.SkuNo && m.LotNo == allot.LotNo);
+                var pinStockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
                 if (pinStockDetail != null)
                 {
                     if (palletNo != palletNoNew)//闈炴暣鎵樻嫞璐�
@@ -4068,6 +4083,7 @@
                    
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
+                    noticeDetail.Status = "2";
                     Db.Updateable(noticeDetail).ExecuteCommand();
 
                     var num = Db.Queryable<BllExportNoticeDetail>()
@@ -4075,6 +4091,8 @@
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                        noticeDetail.Status = "3";
+                        Db.Updateable(noticeDetail).ExecuteCommand();
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
                     Db.Updateable(notice).ExecuteCommand();
@@ -4083,7 +4101,7 @@
                 {
                     var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
                     List<DataBoxInfo> boxInfos;
-                    var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
+                    var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo && m.StockDetailId == stockDetail.Id);
                     if (boxInfo.Count() == 0)
                     {
                         throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
@@ -4220,6 +4238,8 @@
                         }
                         else//鏁伴噺鎷h揣
                         {
+                            var boxInfo2 = Db.Queryable<DataBoxInfo>().First(m => m.IsDel == "0" && m.BoxNo == boxNo && m.StockDetailId == sdId);
+                            
                             if (decimal.Parse(pickQty1) == item.Qty)
                             {
                                 //淇敼搴撳瓨绠辩爜鏄庣粏
@@ -4231,9 +4251,53 @@
                             }
                             else
                             {
+                                if (boxInfo2 == null)
+                                {
+                                    var dataBoxInfo = new DataBoxInfo()
+                                    {
+                                        StockDetailId = sdId,
+                                        BindNo = item.BindNo,
+                                        BoxNo = item.BoxNo,
+                                        BoxNo2 = item.BoxNo2,
+                                        BoxNo3 = item.BoxNo3,
+                                        PalletNo = item.PalletNo,
+                                        PalletNo2 = item.PalletNo2,
+                                        PalletNo3 = item.PalletNo3,
+                                        Qty = decimal.Parse(pickQty1),
+                                        FullQty = item.FullQty,
+                                        Status = "4",
+                                        LotNo = item.LotNo,
+                                        LotText = item.LotText,
+                                        SkuNo = item.SkuNo,
+                                        SkuName = item.SkuName,
+                                        Standard = item.Standard,
+                                        ProductionTime = item.ProductionTime,
+                                        SupplierLot = item.SupplierLot,
+                                        InspectMark = item.InspectMark,
+                                        BitBoxMark = "1",
+                                        InspectStatus = item.InspectStatus,
+                                        InspectTime = item.InspectTime,
+                                    };
+
+                                    Db.Insertable(dataBoxInfo).ExecuteCommand();
+                                }
+                                else
+                                {
+                                    boxInfo2.Qty += decimal.Parse(pickQty1);
+                                    item.BitBoxMark = boxInfo2.Qty>= boxInfo2.FullQty? "0":"1" ;//闆剁鏍囪瘑
+                                    Db.Updateable(boxInfo2).ExecuteCommand();
+                                }
                                 item.Qty -= decimal.Parse(pickQty1);
                                 item.BitBoxMark = "1";//闆剁鏍囪瘑
-                                Db.Updateable(item).ExecuteCommand();
+                                if (item.Qty<=0)
+                                {
+                                    Db.Deleteable(item).ExecuteCommand();
+                                }
+                                else
+                                {
+                                    Db.Updateable(item).ExecuteCommand();
+                                }
+
                             }
 
                             pickQty += int.Parse(pickQty1);
@@ -4300,6 +4364,7 @@
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
+                    noticeDetail.Status = "2";
                     Db.Updateable(noticeDetail).ExecuteCommand();
 
                     var num = Db.Queryable<BllExportNoticeDetail>()
@@ -4307,17 +4372,21 @@
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                        noticeDetail.Status = "3";
+                        Db.Updateable(noticeDetail).ExecuteCommand();
                     }
+                    
                     //淇敼鍑哄簱鍗曚俊鎭�
                     Db.Updateable(notice).ExecuteCommand();
                 }
 
                 if (isNew)
                 {
-                    sd.Qty = pickQty;
-                    sd.LockQty = pickQty;
+                    var sd2 = Db.Queryable<DataStockDetail>().First(m=>m.Id == sdId);
+                    sd2.Qty = pickQty;
+                    sd2.LockQty = pickQty;
 
-                    Db.Updateable(sd).ExecuteCommand();
+                    Db.Updateable(sd2).ExecuteCommand();
                 }
                 else
                 {
@@ -4633,6 +4702,7 @@
 
                 //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                 noticeDetail.CompleteQty += int.Parse(PickQty);
+                noticeDetail.Status = "2";
                 Db.Updateable(noticeDetail).ExecuteCommand();
 
                 var num = Db.Queryable<BllExportNoticeDetail>()
@@ -4640,6 +4710,8 @@
                 if (num <= 0)
                 {
                     notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                    noticeDetail.Status = "3";
+                    Db.Updateable(noticeDetail).ExecuteCommand();
                 }
                 //淇敼鍑哄簱鍗曚俊鎭�
                 Db.Updateable(notice).ExecuteCommand();
diff --git a/Wms/WMS.BLL/BllSoServer/ExportNoticeDetailServer.cs b/Wms/WMS.BLL/BllSoServer/ExportNoticeDetailServer.cs
index 3b27db8..85fa002 100644
--- a/Wms/WMS.BLL/BllSoServer/ExportNoticeDetailServer.cs
+++ b/Wms/WMS.BLL/BllSoServer/ExportNoticeDetailServer.cs
@@ -40,12 +40,15 @@
                     .LeftJoin<SysPackag>((a,b)=> a.PackagNo == b.PackagNo)
                     .LeftJoin<SysUserInfor>((a,b,c)=> a.CreateUser == c.Id)
                     .LeftJoin<SysUserInfor>((a,b,c,d)=> a.UpdateUser == d.Id)
-                    .Select((a, b, c, d) => new ExportNoticeDetailDto()
+                    .LeftJoin<BllExportNotice>((a, b, c, d, e) => a.SONo == e.SONo)
+                    .Select((a, b, c, d, e) => new ExportNoticeDetailDto()
                     {
                         Id = a.Id,
                         Status = a.Status,
                         Origin = notice.Origin,
                         SONo = a.SONo,
+                        Type = e.Type,
+                        StatusZ = e.Status,
                         SkuNo = a.SkuNo,
                         SkuName = a.SkuName,
                         Standard = a.Standard,
diff --git a/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
index b50ab13..19e38e9 100644
--- a/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
+++ b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
@@ -433,12 +433,12 @@
                         inspectStatus = "0";
                         break;
                     case "4"://涓嶅悎鏍煎搧鍑哄簱
-                        skuType = "(0,1,2,3)";
+                        skuType = "(0,1,2,3,4)";
                         inspectStatus = "2";
                         break;
                     case "5"://涓棿鍝佸嚭搴�
                         skuType = "(4)";
-                        inspectStatus = "0,1";
+                        inspectStatus = "1";
                         break;
                     case "6"://浠e偍鍑哄簱
                         skuType = "(0,1,2,3,4)";
@@ -3217,23 +3217,29 @@
                 {
                     throw new Exception("鑾峰彇澶辫触锛屾湭鎵惧埌鎸囧畾鍑哄簱鍗曪紒");
                 }
-                if (detail.Status != "0" && detail.Status != "1" && detail.AllotQty >= detail.Qty)
-                {
-                    throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟鐘舵�佷笉鏄瓑寰呮墽琛屾垨鍒嗛厤涓紒");
-                }
-                if (detail.AllotQty >= detail.Qty)
-                {
-                    throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴�!");
-                }
+
                 var notice = Db.Queryable<BllExportNotice>().First(a => a.SONo == detail.SONo);
                 if (notice == null)
                 {
                     throw new Exception("鑾峰彇澶辫触锛屾湭鎵惧埌鎸囧畾鍑哄簱鍗�!");
                 }
-                if (notice.Status == "3" && detail.AllotQty >= detail.Qty || notice.Status == "4" || notice.Status == "5")
+                if (notice.Type != "1" && notice.Type != "2" && notice.Type != "3")
                 {
-                    throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟鐘舵�佷笉鍏佽!");
+                    if (detail.Status != "0" && detail.Status != "1" && detail.AllotQty >= detail.Qty)
+                    {
+                        throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟鐘舵�佷笉鏄瓑寰呮墽琛屾垨鍒嗛厤涓紒");
+                    }
+                    if (detail.AllotQty >= detail.Qty)
+                    {
+                        throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴�!");
+                    }
+
+                    if (notice.Status == "3" && detail.AllotQty >= detail.Qty || notice.Status == "4" || notice.Status == "5")
+                    {
+                        throw new Exception("鑾峰彇澶辫触锛屽嚭搴撳崟鐘舵�佷笉鍏佽!");
+                    }
                 }
+                   
                 #endregion
 
                 Expression<Func<DataStockDetail, bool>> item = Expressionable.Create<DataStockDetail>()
@@ -3284,29 +3290,36 @@
                 {
                     throw new Exception("鎿嶄綔澶辫触锛屾湭鎵惧埌鎸囧畾鍑哄簱鍗曡鎯咃紒");
                 }
-                if (detail.AllotQty >= detail.Qty || (detail.Status != "0" && detail.Status != "1"))
-                {
-                    throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴愶紒");
-                }
                 var notice = Db.Queryable<BllExportNotice>().First(a => a.IsDel == "0" && a.SONo == detail.SONo);
                 if (notice == null)
                 {
                     throw new Exception("鎿嶄綔澶辫触锛屾湭鎵惧埌鎸囧畾鍑哄簱鍗曪紒");
                 }
-                if (notice.Status == "3" && detail.AllotQty >= detail.Qty || notice.Status == "4" || notice.Status == "5")
+                if (notice.Type != "1" && notice.Type != "2" && notice.Type !="3")
                 {
-                    throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴愶紒");
+                    if (detail.AllotQty >= detail.Qty || (detail.Status != "0" && detail.Status != "1"))
+                    {
+                        throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴愶紒");
+                    }
+
+                    if (notice.Status == "3" && detail.AllotQty >= detail.Qty || notice.Status == "4" || notice.Status == "5")
+                    {
+                        throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撳崟宸插垎閰嶅畬鎴愶紒");
+                    }
+
+                    //鍗曟嵁鏄庣粏闇�瑕佺殑鍑哄簱鏁伴噺
+                    var needQty = detail.Qty - detail.AllotQty;
+                    //鍒嗛厤鐨勫嚭搴撴暟閲�
+                    var outQty = model.StockList.Select(s => s.Qty).ToList().Sum();
+                    if (outQty != needQty)
+                    {
+                        throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撴暟閲忎笌璁″垝鏁伴噺涓嶄竴鑷达紒");
+                    }
                 }
+                
                 #endregion
 
-                //鍗曟嵁鏄庣粏闇�瑕佺殑鍑哄簱鏁伴噺
-                var needQty = detail.Qty - detail.AllotQty;
-                //鍒嗛厤鐨勫嚭搴撴暟閲�
-                var outQty = model.StockList.Select(s => s.Qty).ToList().Sum();
-                if (outQty != needQty)
-                {
-                    throw new Exception("鎿嶄綔澶辫触锛屽嚭搴撴暟閲忎笌璁″垝鏁伴噺涓嶄竴鑷达紒");
-                }
+                
                 var stockIds = model.StockList.Select(a => a.StockId).ToList();
                 //搴撳瓨鏄庣粏
                 var stockList = Db.Queryable<DataStockDetail>().Where(a => stockIds.Contains(a.Id)).ToList();
@@ -3315,7 +3328,7 @@
                 var allots = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SODetailNo == detail.Id && m.Status == "0").ToList();
 
                 //搴撳瓨鎬昏〃
-                //var stockz = Db.Queryable<DataStock>().First(d => d.IsDel == "0" && d.SkuNo == detail.SkuNo && d.LotNo == detail.LotNo);
+                var stockz = Db.Queryable<DataStock>().First(d => d.IsDel == "0" && d.SkuNo == detail.SkuNo && d.LotNo == detail.LotNo);
 
                 var allotList = new List<BllExportAllot>();
                 decimal outQtys = 0;
@@ -3352,7 +3365,7 @@
                             IsBelt = stock.IsBelt,
                             Qty = st.Qty,
                             CompleteQty = 0,
-                            Status = "0",
+                            Status = notice.Status == "4"? "2":"0",
                             LogisticsId = notice.LogisticsId,
                             IsAdvance = "0",
                             OutMode = "",//鍑哄簱鍙�
@@ -3371,11 +3384,12 @@
                     //搴撳瓨鏄庣粏
                     stock.LockQty += st.Qty;
                     stock.Status = stock.LockQty == stock.Qty ? "2" : "1";
-
-                    //搴撳瓨鎬昏〃
-                    //stockz.LockQty += st.Qty;
-                    //Db.Updateable(stockz).ExecuteCommand();
-
+                    if (detail.AllotQty+ st.Qty > detail.Qty)
+                    {
+                        //搴撳瓨鎬昏〃
+                        stockz.LockQty += (decimal)detail.AllotQty + st.Qty - detail.Qty;
+                        Db.Updateable(stockz).ExecuteCommand();
+                    }
 
                     Db.Updateable(stock).UpdateColumns(it => new { it.LockQty, it.Status }).ExecuteCommand();
                     outQtys += st.Qty;

--
Gitblit v1.8.0