From 1e7283cacb5eb6de492c6c6874aeaa316063989c Mon Sep 17 00:00:00 2001
From: Demo <Demo@DESKTOP-CPA90BF>
Date: 星期三, 13 三月 2024 16:46:35 +0800
Subject: [PATCH] Merge branch 'csc'

---
 HTML/views/ASNSetting/PalletBindFrom.html       |    1 
 Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs    |   12 
 Wms/WMS.Entity/BllSoEntity/BllExportAllot.cs    |    8 
 Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs         |  559 +++++++++++++++++++++++++++++++++++++++
 Wms/WMS.Entity/BllSoEntity/BllCompleteDetail.cs |    8 
 Wms/Wms/Controllers/BllAsnController.cs         |    2 
 Pda/View/SoSetting/SampleOut.html               |  227 ++++++++++-----
 Wms/WMS.Entity/BllSoEntity/BLLExportNotice.cs   |    7 
 8 files changed, 738 insertions(+), 86 deletions(-)

diff --git a/HTML/views/ASNSetting/PalletBindFrom.html b/HTML/views/ASNSetting/PalletBindFrom.html
index bf81733..b3d50ff 100644
--- a/HTML/views/ASNSetting/PalletBindFrom.html
+++ b/HTML/views/ASNSetting/PalletBindFrom.html
@@ -299,6 +299,7 @@
 						AsnNo: $("#BillCode").val(),
 						PalletNo: $("#palletNo").val(),
 						AsnDetailId: parseInt($("#detail").val()),
+						LotNo: $("#detail").find("option:selected").text(),
 						BoxNo: $("#boxNo").val(),
 						IsContinue :IsContinue,
 						TailBoxNo: $("#boxNo2").val(),
diff --git a/Pda/View/SoSetting/SampleOut.html b/Pda/View/SoSetting/SampleOut.html
index 4fc9be3..e54a94e 100644
--- a/Pda/View/SoSetting/SampleOut.html
+++ b/Pda/View/SoSetting/SampleOut.html
@@ -243,7 +243,7 @@
                             <div id="layout-bill" class="layui-form-item layout-dropdownlist">
                                 <label class="layui-form-label lableWidth">鍏ュ簱鍗曪細</label>
                                 <div class="layui-input-block" id="selectDiv">
-                                    <select id="bar" lay-filter="getbar" lay-search>
+                                    <select id="AsnBar" lay-filter="getAsnBar" lay-search>
                                         <option value=""></option>
                                     </select>
                                     <img src="/assets/down_arraw.png">
@@ -296,7 +296,7 @@
 							</table>						
 						</div>
 						<div id="" class="layout-tab-page">
-							<table class="layout-tab-content" border="" cellspacing="" cellpadding="">
+							<table id="kuneiQty" class="layout-tab-content" border="" cellspacing="" cellpadding="">
 								<tr>
 									<td>
 										<table class="tbl-box-sim-info" border="" cellspacing="" cellpadding="">
@@ -380,63 +380,74 @@
 				
 				<div id="" class="layout-bill-info">
 					<form class="layui-form" action="" style="height: auto;">
+                        <div id="kuneilabel2" >
+                            <div id="layout-bill2" class="layui-form-item layout-dropdownlist">
+                                <label class="layui-form-label lableWidth">鍑哄簱鍗曪細</label>
+                                <div class="layui-input-block" id="selectDiv2">
+                                    <select id="bar2" lay-filter="getbar2" lay-search>
+                                        <option value=""></option>
+                                    </select>
+                                    <img src="/assets/down_arraw.png">
+                                </div>
+                            </div>
+                            <div id="layout-skuLotNo2" class="layui-form-item layout-dropdownlist">
+                                <label class="layui-form-label lableWidth">鐗╂枡 - 鎵规锛�</label>
+                                <div class="layui-input-block">
+                                    <select id="skuLotNo2" lay-filter="getSkuLotNo2" lay-search>
+                                        <option value=""></option>
+                                    </select>
+                                    <img src="/assets/down_arraw.png">
+                                </div>
+                            </div>
+                            <div id="" class="layout-tab-page">
+                                <table class="tbl-box-sim-info" border="" cellspacing="" cellpadding="">
+                                    <tr>
+                                        <td>
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label" style="width: 50%;">璁″垝鏁伴噺锛�</label>
+                                                <div class="layui-input-block" style="width: 50%;margin-left:50%;">
+                                                    <input id="planQty2" type="text" lay-verify="" disabled placeholder=""
+                                                        class="layui-input">
+                                                </div>
+                                            </div>
+                                        </td>
+                                        <td>
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label" style="width: 50%">瀹屾垚鏁伴噺锛�</label>
+                                                <div class="layui-input-block" style="width: 50%;margin-left:50%;">
+                                                    <input id="finishQty2" type="text" lay-verify="" disabled placeholder=""
+                                                        class="layui-input">
+                                                </div>
+                                            </div>
 
-						<div id="layout-bill2" class="layui-form-item layout-dropdownlist">
-							<label class="layui-form-label lableWidth">鍑哄簱鍗曪細</label>
-							<div class="layui-input-block" id="selectDiv2">
-								<select id="bar2" lay-filter="getbar2" lay-search>
-									<option value=""></option>
-								</select>
-								<img src="/assets/down_arraw.png">
-							</div>
-						</div>
-						<div id="layout-skuLotNo2" class="layui-form-item layout-dropdownlist">
-							<label class="layui-form-label lableWidth">鐗╂枡 - 鎵规锛�</label>
-							<div class="layui-input-block">
-								<select id="skuLotNo2" lay-filter="getSkuLotNo2" lay-search>
-									<option value=""></option>
-								</select>
-								<img src="/assets/down_arraw.png">
-							</div>
-						</div>
-						<div id="" class="layout-tab-page">
-							<table class="tbl-box-sim-info" border="" cellspacing="" cellpadding="">
-								<tr>
-									<td>
-										<div class="layui-form-item">
-											<label class="layui-form-label" style="width: 50%;">璁″垝鏁伴噺锛�</label>
-											<div class="layui-input-block" style="width: 50%;margin-left:50%;">
-												<input id="planQty2" type="text" lay-verify="" disabled placeholder=""
-													class="layui-input">
-											</div>
-										</div>
-									</td>
-									<td>
-										<div class="layui-form-item">
-											<label class="layui-form-label" style="width: 50%">瀹屾垚鏁伴噺锛�</label>
-											<div class="layui-input-block" style="width: 50%;margin-left:50%;">
-												<input id="finishQty2" type="text" lay-verify="" disabled placeholder=""
-													class="layui-input">
-											</div>
-										</div>
-
-									</td> 
-								</tr>
-								<tr>
-									<td colspan="3">
-										<div class="layui-form-item">
-											<label class="layui-form-label" style="width: 17%;">瑙勬牸锛�</label>
-											<div class="layui-input-block" style="width: 83%;margin-left:17%;">
-												<input id="standard2" type="text" lay-verify="" disabled placeholder=""
-													class="layui-input">
-											</div>
-										</div>
-									</td>
-									
-								</tr>
-							</table>
-						</div>
-
+                                        </td> 
+                                    </tr>
+                                    <tr>
+                                        <td colspan="3">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label" style="width: 17%;">瑙勬牸锛�</label>
+                                                <div class="layui-input-block" style="width: 83%;margin-left:17%;">
+                                                    <input id="standard2" type="text" lay-verify="" disabled placeholder=""
+                                                        class="layui-input">
+                                                </div>
+                                            </div>
+                                        </td>
+                                        
+                                    </tr>
+                                </table>
+                            </div>
+                        </div>
+                        <div id="kuqianlabel2" >
+                            <div id="layout-bill" class="layui-form-item layout-dropdownlist">
+                                <label class="layui-form-label lableWidth">鍏ュ簱鍗曪細</label>
+                                <div class="layui-input-block" id="selectDiv">
+                                    <select id="AsnBar2" lay-filter="getAsnBar2" lay-search>
+                                        <option value=""></option>
+                                    </select>
+                                    <img src="/assets/down_arraw.png">
+                                </div>
+                            </div>
+                        </div>
 						<div id="layout-pallet" class="layui-form-item layout-input">
 							<label class="layui-form-label lableWidth">鎵樼洏鏉$爜锛�</label>
 							<div class="layui-input-block">
@@ -543,6 +554,11 @@
             
             $('#kuneilabel').hide();
             $('#kuqianlabel').hide();
+            $('#kuneilabel2').hide();
+            $('#kuqianlabel2').hide();
+            
+            $('#kuneiQty').hide();
+
 			$('#option1').attr("style", "background-color: aqua;width: 45.77%;float: left;text-align: center;"); //閫変腑鍚庨鑹�
 			$('#option2').attr("style", "background-color: #999;width: 45.77%;float: right;text-align: center;"); //榛樿棰滆壊
 			$('#content2').hide();
@@ -637,11 +653,15 @@
                             if (res.code == 0){
                                 if (res.data == "0") {//搴撳唴鍙栨牱
                                     $('#kuneilabel').show();
+                                    $('#kuneiQty').show();
                                     $('#kuqianlabel').hide();
                                 }
                                 if (res.data == "1") {//搴撳墠鍙栨牱
                                     $('#kuqianlabel').show();
                                     $('#kuneilabel').hide();
+                                    $('#kuneiQty').hide();
+                                    
+                                    updateAsnBillList();
                                 }
                                 // updateBillList();
                                 // if ($('#bar').val() == "") {
@@ -672,21 +692,21 @@
             //鍒濆鍖栨覆鏌� 鍏ュ簱鍗�
 			function updateAsnBillList() {
 
-                $("#bar").empty()
-                $("#bar").append('<option value =>' + '</option>');
+                $("#AsnBar").empty()
+                $("#AsnBar").append('<option value =>' + '</option>');
                 form.render('select');
 
                 var param = {
-                    PalletNo: $("#palletNo").val(),
+                    palletNo: $("#palletNo").val(),
                 };
-                synData(IP + "/PdaSo/GetRunSoNoticeList", param, 'post', function (res) {
+                synData(IP + "/PdaSo/GetAsnNoByPallet", param, 'get', function (res) {
                     if (res.code == 0) { //鎴愬姛
                         console.log(res.data);
                         for (var i = 0; i < res.data.length; i++) {
                             if (i == 0) {
-                                $("#bar").append('<option value =' + res.data[i] + ' selected>' + res.data[i] + '</option>');
+                                $("#AsnBar").append('<option value =' + res.data[i] + ' selected>' + res.data[i] + '</option>');
                             } else {
-                                $("#bar").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
+                                $("#AsnBar").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
                             }
                         }
                         form.render('select');
@@ -1209,27 +1229,76 @@
 				}
 				checkPalletState2()
 			})
+             //鍒濆鍖栨覆鏌� 鍏ュ簱鍗�
+			function updateAsnBillList2() {
+
+                $("#AsnBar2").empty()
+                $("#AsnBar2").append('<option value =>' + '</option>');
+                form.render('select');
+                console.log("afdsaf")
+                var param = {
+                    palletNo: $("#palletNo2").val(),
+                };
+                synData(IP + "/PdaSo/GetAsnNoByPallet", param, 'get', function (res) {
+                    if (res.code == 0) { //鎴愬姛
+                        console.log(res.data);
+                        for (var i = 0; i < res.data.length; i++) {
+                            if (i == 0) {
+                                $("#AsnBar2").append('<option value =' + res.data[i] + ' selected>' + res.data[i] + '</option>');
+                            } else {
+                                $("#AsnBar2").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
+                            }
+                        }
+                        form.render('select');
+
+                    } else { //涓嶆垚鍔�
+                        layer.msg(res.msg, {
+                            icon: 2,
+                            time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+                        });
+                    }
+                });
+            }
+
 			//妫�鏌ユ墭鐩樼姸鎬�
 			function checkPalletState2() {
 				var param = {
 					"PalletNo": $("#palletNo2").val()
-				}
+				} 
 				synData(IP + "/PdaSo/IsEnableOkPalletNo", param, 'post', function (res) {
+                     
 					if (res.code == 0) { //鎴愬姛 
-						updateBillList2();
-						console.log($('#bar2').val())
-						if ($('#bar2').val() == "") {
-							console.log(1)
-							clear21();
-							return;
-						} else {
-							console.log(2)
-							updateSkuLotNoList2();
-							updateQtyList2();
-							getBar2();
-							GetDataInfo();
-						}
-
+                        synData(IP + "/PdaSo/GetSampleType", param, 'get', function (res) {
+                            if (res.code == 0){
+                                if (res.data == "0") {//搴撳唴鍙栨牱
+                                    $('#kuneilabel2').show();
+                                    $('#kuqianlabel2').hide();
+                                }
+                                if (res.data == "1") {//搴撳墠鍙栨牱
+                                    $('#kuqianlabel2').show();
+                                    $('#kuneilabel2').hide();
+                                    updateAsnBillList2();
+                                }
+                                // updateBillList2();
+                                // console.log($('#bar2').val())
+                                // if ($('#bar2').val() == "") {
+                                // 	console.log(1)
+                                // 	clear21();
+                                // 	return;
+                                // } else {
+                                // 	console.log(2)
+                                // 	updateSkuLotNoList2();
+                                // 	updateQtyList2();
+                                // 	getBar2();
+                                // 	GetDataInfo();
+                                // }
+                            }else { //涓嶆垚鍔�
+                                layer.msg(res.msg, {
+                                    icon: 2,
+                                    time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+                                }, function () { });
+                            }
+                        });  
 					} else { //涓嶆垚鍔�
 						layer.msg(res.msg, {
 							icon: 2,
diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
index 8c2988c..a78bdc4 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -681,12 +681,13 @@
                             {
                                 throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
                             }
-                            maxLotNoStr = label.Max(a => a.LotNo);
-                            maxBoxCode = label.Max(a => a.BoxNo);
+                            maxLotNoStr = labelCount.Max(a => a.LotNo);
+                            
                             if (string.IsNullOrWhiteSpace(maxLotNoStr))
                             {
                                 maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
                             }
+                            maxBoxCode = label.Where(m => m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
                         }
                         
                     }
@@ -846,13 +847,14 @@
                             {
                                 throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
                             }
-                            maxCodestr2 = label.Max(a => a.LotNo); ;
-                            maxboxcode2 = label.Max(a => a.BoxNo);//绠卞彿;
-                            maxboxcode3 = label.Max(a => a.BoxNo3);//鏀彿;
+                            maxCodestr2 = labelCount.Max(a => a.LotNo); ;
+                            
                             if (string.IsNullOrWhiteSpace(maxCodestr2))
                             {
                                 maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
                             }
+                            maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);//绠卞彿;
+                            maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿;
                         }
                         
                     }
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
index f2b5cc7..211d77a 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
@@ -341,7 +341,6 @@
             {
                 throw new Exception(e.Message);
             }
-            throw new NotImplementedException();
         }
 
         //鍑哄簱pda鎷h揣
@@ -1314,6 +1313,7 @@
                 }
                 else
                 {
+                    //鍒ゆ柇褰撳墠鎵樼洏鏄惁鏄湪骞冲簱鎴栧簱澶�
                     type = "1";//搴撳墠鍙栨牱
                 }
                 return type;
@@ -1350,6 +1350,563 @@
             }
         }
 
+        //鍙栨牱鍑哄簱鎷h揣(鏍囩)
+        public void SampleSoSetPick(string soType,string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, string asnNo, int userId)
+        {
+            Db.BeginTran();
+            try
+            {
+                if (string.IsNullOrWhiteSpace(soType))
+                {
+                    throw new Exception("鍙栨牱鏍囪瘑涓嶈兘涓虹┖");
+                }
+                
+                //soType: 0搴撳唴鍙栨牱锛屾湁鍑哄簱鍗曞強鍒嗛厤淇℃伅锛� 1搴撳墠鍙栨牱锛屽弽鍚戞坊鍔犲嚭搴撳崟鍙婂垎閰嶄俊鎭�
+                if (soType == "1")
+                {
+
+                    #region 鍒ゆ柇
+
+                    if (string.IsNullOrWhiteSpace(asnNo))
+                    {
+                        throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�");
+                    } 
+                    if (string.IsNullOrWhiteSpace(palletNo))
+                    {
+                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    }
+                    if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
+                    {
+                        throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                    }
+                    //鍏堝垽鏂槸鍚︽槸搴撳鍙栨牱鎵樼洏
+                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                        m.IsDel == "0" && m.PalletNo == palletNo && m.Status != "5" && m.Status != "6");
+                    if (allot != null)
+                    {
+                        throw new Exception("褰撳墠鎵樼洏涓嶅睘浜庡簱鍓嶅彇鏍�");
+                    }
+
+
+                    //鍑哄簱鍗�
+                    var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.AsnSampleNo == asnNo);
+                    BllExportNoticeDetail noticeDetail2;
+                    if (notice != null && notice.Status != "6")
+                    {
+                       
+                    }
+                    else
+                    {
+                        //鍒涘缓鍑哄簱鍗曞強鏄庣粏
+
+                    }
+                   
+                    //鍑哄簱鍗曟槑缁�
+                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
+                        .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                    if (noticeDetail == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    }
+                    //鍑哄簱鍒嗛厤淇℃伅
+                    var allot2 = Db.Queryable<BllExportAllot>().First(m => m.IsDel == "0" && m.Status == "5" && m.SONo == soNo && m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
+                    if (allot2 == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    }
+                    
+
+                    //搴撳瓨鏄庣粏
+                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                    if (stockDetail == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    }
+                    //搴撳瓨鎬昏〃
+                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    if (stock == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    }
+
+                    #endregion
+
+                    
+                    
+                    
+
+                    //鍒ゆ柇鏄暎鏀嫞璐ц繕鏄暟閲忔嫞璐�
+                    var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
+                    List<DataBoxInfo> boxInfos;
+                    var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
+                    if (boxInfo.Count() == 0)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                    }
+                    boxInfos = boxInfo.ToList();
+
+                    if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
+                    {
+                        boxInfos = boxInfos.Where(m => m.BoxNo3 == boxNo3).ToList();
+
+                        if (boxInfos.Count() == 0)
+                        {
+                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        }
+                        if (boxInfos.Count() > 1)
+                        {
+                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                        }
+
+                        if (boxInfos.Any(m => m.PalletNo != palletNo))
+                        {
+                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                        }
+
+                        biaoShi = "1";
+                    }
+                    else if (!string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)//鏁伴噺鎷h揣
+                    {
+                        if (boxInfo.Count() > 1)
+                        {
+                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                        }
+                        int boxQty = boxInfo.First().Qty;
+                        if (Convert.ToInt32(pickQty1) > boxQty)
+                        {
+                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                        }
+
+                        biaoShi = "2";
+                    }
+                    else //鏁寸鎷h揣
+                    {
+                        if (boxInfo.Count() == 0)
+                        {
+                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                        }
+                        if (boxInfo.Any(m => m.PalletNo != palletNo))
+                        {
+                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                        }
+                        
+                    }
+                    var pickQty = 0;//鎷h揣鐨勬暟閲�
+                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    var comList = new List<BllCompleteDetail>();
+                    foreach (var item in boxInfos)
+                    {
+                        if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
+                        {
+                            throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                        }
+                        //娣诲姞鎷h揣鏄庣粏
+                        var completeDetail = new BllCompleteDetail()
+                        {
+                            SONo = soNo,
+                            SODetailNo = int.Parse(soDetailId),
+                            ExportAllotId = allot.Id,
+                            StockId = allot.StockId,
+                            BoxNo = item.BoxNo,
+                            BoxNo2 = item.BoxNo2,
+                            BoxNo3 = item.BoxNo3,
+
+                            LotNo = allot.LotNo,
+                            LotText = allot.LotText,
+                            SupplierLot = allot.SupplierLot,
+                            SkuNo = allot.SkuNo,
+                            SkuName = allot.SkuName,
+                            Standard = allot.Standard,
+                            PalletNo = palletNo,
+                            CompleteQty = biaoShi == "2" ? int.Parse(pickQty1) : item.Qty,
+                            InspectMark = "1",
+
+                            CreateUser = userId
+                        };
+                        comList.Add(completeDetail);
+
+                        if (biaoShi != "2")
+                        {
+                            //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
+                            Db.Deleteable(item).ExecuteCommand();
+                        }
+                        else//鏁伴噺鎷h揣
+                        {
+                            if (int.Parse(pickQty1) == item.Qty)
+                            {
+                                //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
+                                Db.Deleteable(item).ExecuteCommand();
+                            }
+                            else
+                            {
+                                item.Qty -= int.Parse(pickQty1);
+                                item.BitBoxMark = "1";//闆剁鏍囪瘑
+                                item.InspectMark = "1";//鎶芥绠辨爣璇�
+                                Db.Updateable(item).ExecuteCommand();
+                            }
+                        }
+                        pickQty += item.Qty;
+                    }
+                    //鏀瑰彉搴撳唴绠辩爜鏄惁闆剁淇℃伅
+                    if (biaoShi == "1")
+                    {
+                        var boxSurplusList = boxInfo.Where(m => m.BoxNo3 != boxNo3).ToList();
+                        foreach (var item in boxSurplusList)
+                        {
+                            item.BitBoxMark = "1";
+                            item.InspectMark = "1";
+                            Db.Updateable(item).ExecuteCommand();
+                        }
+                    }
+
+                    Db.Insertable(comList).ExecuteCommand();
+                    //淇敼鍑哄簱鍒嗛厤淇℃伅
+                    allot.CompleteQty += pickQty;
+                    allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
+                    if (allot.Status == "5")
+                    {
+                        //鍒ゆ柇璇ユ墭鐩樻槸鍚﹁繕瀛樺湪鐗╂枡 瀛樺湪鏀逛负寰呭洖搴� 寰呭洖搴撳畬鎴愬悗鏀逛负宸插畬鎴�
+                    }
+                    Db.Updateable(allot).ExecuteCommand();
+
+                    //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
+                    stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
+                    stockDetail.Qty -= pickQty;
+                    stockDetail.LockQty -= pickQty;
+                    if (stockDetail.Qty == stockDetail.LockQty)
+                    {
+                        stockDetail.Status = "2";
+                    }
+                    else if (stockDetail.Qty > stockDetail.LockQty && stockDetail.LockQty > 0)
+                    {
+                        stockDetail.Status = "1";
+                    }
+                    else
+                    {
+                        stockDetail.Status = "0";
+                    }
+
+                    if (stockDetail.Qty <= 0)
+                    {
+                        Db.Deleteable(stockDetail).ExecuteCommand();
+                    }
+                    else
+                    {
+                        Db.Updateable(stockDetail).ExecuteCommand();
+                    }
+                    stock.Qty -= pickQty;
+                    stock.LockQty -= pickQty;
+                    if (stock.Qty <= 0)
+                    {
+                        Db.Deleteable(stock).ExecuteCommand();
+                    }
+                    else
+                    {
+                        Db.Updateable(stock).ExecuteCommand();
+                    }
+                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    if (num2 <= 0)
+                    {
+                        //鏀瑰彉鎵樼洏鐘舵��
+                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        }
+                        pallet.Status = "0";
+                        Db.Updateable(pallet).ExecuteCommand();
+                    }
+                    //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
+                    noticeDetail.CompleteQty += pickQty;
+                    Db.Updateable(noticeDetail).ExecuteCommand();
+
+                    var num = Db.Queryable<BllExportNoticeDetail>()
+                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    if (num <= 0)
+                    {
+                        notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                    }
+                    //淇敼鍑哄簱鍗曚俊鎭�
+                    Db.Updateable(notice).ExecuteCommand();
+
+                }
+                else if(soType == "0")
+                {
+                    #region 鍒ゆ柇
+
+                    if (string.IsNullOrWhiteSpace(soNo))
+                    {
+                        throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                    }
+                    if (string.IsNullOrWhiteSpace(soDetailId))
+                    {
+                        throw new Exception("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
+                    }
+                    if (string.IsNullOrWhiteSpace(palletNo))
+                    {
+                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    }
+                    if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
+                    {
+                        throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                    }
+
+                    //鍑哄簱鍗�
+                    var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                    if (notice == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                    }
+                    if (notice.Status != "3")
+                    {
+                        throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    }
+                    //鍑哄簱鍗曟槑缁�
+                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
+                        .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                    if (noticeDetail == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    }
+                    //鍑哄簱鍒嗛厤淇℃伅
+                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                        m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
+                        m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
+                    if (allot == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    }
+                    //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
+                    var needQty = allot.Qty - allot.CompleteQty;
+
+                    //搴撳瓨鏄庣粏
+                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                    if (stockDetail == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    }
+                    //搴撳瓨鎬昏〃
+                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    if (stock == null)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    }
+
+                    #endregion
+
+                    var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
+                    List<DataBoxInfo> boxInfos;
+                    var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
+                    if (boxInfo.Count() == 0)
+                    {
+                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                    }
+                    boxInfos = boxInfo.ToList();
+                    if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
+                    {
+                        boxInfos = boxInfos.Where(m => m.BoxNo3 == boxNo3).ToList();
+
+                        if (boxInfos.Count() == 0)
+                        {
+                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        }
+                        if (boxInfos.Count() > 1)
+                        {
+                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                        }
+
+                        if (boxInfos.Any(m => m.PalletNo != palletNo))
+                        {
+                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                        }
+                        var boxQty = boxInfos.First().Qty;
+                        if (boxQty > needQty)
+                        {
+                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                        }
+
+                        biaoShi = "1";
+                    }
+                    else if (!string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)//鏁伴噺鎷h揣
+                    {
+                        if (boxInfo.Count() > 1)
+                        {
+                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                        }
+                        int boxQty = boxInfo.First().Qty;
+                        if (Convert.ToInt32(pickQty1) > boxQty)
+                        {
+                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                        }
+                        if (Convert.ToInt32(pickQty1) > needQty)
+                        {
+                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                        }
+
+                        biaoShi = "2";
+                    }
+                    else //鏁寸鎷h揣
+                    {
+                        if (boxInfo.Count() == 0)
+                        {
+                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                        }
+                        if (boxInfo.Any(m => m.PalletNo != palletNo))
+                        {
+                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                        }
+                        var boxQty = boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
+                        if (boxQty[0] > needQty)
+                        {
+                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                        }
+                    }
+                    var pickQty = 0;//鎷h揣鐨勬暟閲�
+                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    var comList = new List<BllCompleteDetail>();
+                    foreach (var item in boxInfos)
+                    {
+                        if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
+                        {
+                            throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                        }
+                        //娣诲姞鎷h揣鏄庣粏
+                        var completeDetail = new BllCompleteDetail()
+                        {
+                            SONo = soNo,
+                            SODetailNo = int.Parse(soDetailId),
+                            ExportAllotId = allot.Id,
+                            StockId = allot.StockId,
+                            BoxNo = item.BoxNo,
+                            BoxNo2 = item.BoxNo2,
+                            BoxNo3 = item.BoxNo3,
+
+                            LotNo = allot.LotNo,
+                            LotText = allot.LotText,
+                            SupplierLot = allot.SupplierLot,
+                            SkuNo = allot.SkuNo,
+                            SkuName = allot.SkuName,
+                            Standard = allot.Standard,
+                            PalletNo = palletNo,
+                            CompleteQty = biaoShi == "2" ? int.Parse(pickQty1) : item.Qty,
+
+                            CreateUser = userId
+                        };
+                        comList.Add(completeDetail);
+
+                        if (biaoShi != "2")
+                        {
+                            //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
+                            Db.Deleteable(item).ExecuteCommand();
+                        }
+                        else//鏁伴噺鎷h揣
+                        {
+                            if (int.Parse(pickQty1) == item.Qty)
+                            {
+                                //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
+                                Db.Deleteable(item).ExecuteCommand();
+                            }
+                            else
+                            {
+                                item.Qty -= int.Parse(pickQty1);
+                                item.BitBoxMark = "1";//闆剁鏍囪瘑
+                                Db.Updateable(item).ExecuteCommand();
+                            }
+                        }
+                        pickQty += item.Qty;
+                    }
+                    //鏀瑰彉搴撳唴绠辩爜鏄惁闆剁淇℃伅
+                    if (biaoShi == "1")
+                    {
+                        var boxSurplusList = boxInfo.Where(m => m.BoxNo3 != boxNo3).ToList();
+                        foreach (var item in boxSurplusList)
+                        {
+                            item.BitBoxMark = "1";
+                            Db.Updateable(item).ExecuteCommand();
+                        }
+                    }
+
+                    Db.Insertable(comList).ExecuteCommand();
+                    //淇敼鍑哄簱鍒嗛厤淇℃伅
+                    allot.CompleteQty += pickQty;
+                    allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
+                    if (allot.Status == "5")
+                    {
+                        //鍒ゆ柇璇ユ墭鐩樻槸鍚﹁繕瀛樺湪鐗╂枡 瀛樺湪鏀逛负寰呭洖搴� 寰呭洖搴撳畬鎴愬悗鏀逛负宸插畬鎴�
+                    }
+                    Db.Updateable(allot).ExecuteCommand();
+
+                    //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
+                    stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
+                    stockDetail.Qty -= pickQty;
+                    stockDetail.LockQty -= pickQty;
+                    if (stockDetail.Qty == stockDetail.LockQty)
+                    {
+                        stockDetail.Status = "2";
+                    }
+                    else if (stockDetail.Qty > stockDetail.LockQty && stockDetail.LockQty > 0)
+                    {
+                        stockDetail.Status = "1";
+                    }
+                    else
+                    {
+                        stockDetail.Status = "0";
+                    }
+
+                    if (stockDetail.Qty <= 0)
+                    {
+                        Db.Deleteable(stockDetail).ExecuteCommand();
+                    }
+                    else
+                    {
+                        Db.Updateable(stockDetail).ExecuteCommand();
+                    }
+                    stock.Qty -= pickQty;
+                    stock.LockQty -= pickQty;
+                    if (stock.Qty <= 0)
+                    {
+                        Db.Deleteable(stock).ExecuteCommand();
+                    }
+                    else
+                    {
+                        Db.Updateable(stock).ExecuteCommand();
+                    }
+                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    if (num2 <= 0)
+                    {
+                        //鏀瑰彉鎵樼洏鐘舵��
+                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        if (pallet == null)
+                        {
+                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        }
+                        pallet.Status = "0";
+                        Db.Updateable(pallet).ExecuteCommand();
+                    }
+                    //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
+                    noticeDetail.CompleteQty += pickQty;
+                    Db.Updateable(noticeDetail).ExecuteCommand();
+
+                    var num = Db.Queryable<BllExportNoticeDetail>()
+                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    if (num <= 0)
+                    {
+                        notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
+                    }
+                    //淇敼鍑哄簱鍗曚俊鎭�
+                    Db.Updateable(notice).ExecuteCommand();
+                }
+                //娣诲姞鎿嶄綔鏃ュ織璁板綍
+                var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鍑哄簱", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勬墭鐩樼爜涓猴細{palletNo}鐨勬嫞璐ф搷浣�", userId);
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                Db.RollbackTran();
+                throw new Exception(e.Message);
+            }
+        }
+
 
     }
 }
diff --git a/Wms/WMS.Entity/BllSoEntity/BLLExportNotice.cs b/Wms/WMS.Entity/BllSoEntity/BLLExportNotice.cs
index 0fe0ca2..b8549d4 100644
--- a/Wms/WMS.Entity/BllSoEntity/BLLExportNotice.cs
+++ b/Wms/WMS.Entity/BllSoEntity/BLLExportNotice.cs
@@ -112,6 +112,13 @@
         public string Demo { get; set; }
 
         /// <summary>
+        /// Desc:鍏ュ簱鍓嶅彇鏍峰嚭搴撶殑鍏ュ簱鍗曟嵁鏍囪瘑
+        /// Default:
+        /// Nullable:True
+        /// </summary>
+        public string AsnSampleNo { get; set; }
+
+        /// <summary>
         /// 瀹屾垚鏃堕棿
         /// </summary>
         public DateTime? CompleteTime { get; set; }
diff --git a/Wms/WMS.Entity/BllSoEntity/BllCompleteDetail.cs b/Wms/WMS.Entity/BllSoEntity/BllCompleteDetail.cs
index 95eb98c..c13d2d5 100644
--- a/Wms/WMS.Entity/BllSoEntity/BllCompleteDetail.cs
+++ b/Wms/WMS.Entity/BllSoEntity/BllCompleteDetail.cs
@@ -124,6 +124,14 @@
         public string NowPalletNo {get;set;}
 
 
+        /// <summary>
+        /// 鏄惁鎶芥绠� 0锛氬惁 1锛氭槸
+        /// Default:
+        /// Nullable:True
+        /// </summary>           
+        public string InspectMark { get; set; }
+
+
         [Navigate(NavigateType.OneToOne, nameof(CreateUser))]
         public SysUserInfor CreateUserInfo { get; set; }
 
diff --git a/Wms/WMS.Entity/BllSoEntity/BllExportAllot.cs b/Wms/WMS.Entity/BllSoEntity/BllExportAllot.cs
index 2e7369d..0718c18 100644
--- a/Wms/WMS.Entity/BllSoEntity/BllExportAllot.cs
+++ b/Wms/WMS.Entity/BllSoEntity/BllExportAllot.cs
@@ -168,6 +168,14 @@
         public string UnstackingMode { get; set; }
 
 
+        /// <summary>
+        /// 鏄惁鎶芥鎵� 0锛氬惁 1锛氭槸
+        /// Default:
+        /// Nullable:True
+        /// </summary>           
+        public string InspectMark { get; set; }
+
+
         [Navigate(NavigateType.OneToOne, nameof(LogisticsId))]
         public SysLogisticsInfo LogisticsInfoInfo { get; set; }
 
diff --git a/Wms/Wms/Controllers/BllAsnController.cs b/Wms/Wms/Controllers/BllAsnController.cs
index d6db2ab..badb7b4 100644
--- a/Wms/Wms/Controllers/BllAsnController.cs
+++ b/Wms/Wms/Controllers/BllAsnController.cs
@@ -979,7 +979,7 @@
                     return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
                 }
                 _BoxInfoSvc.DelLabelByAsnNo(model.AsnNo,model.LotNo,int.Parse(userId));
-                return Ok(new { code = 0, msg = "鎴愬姛鑾峰彇鍗曟嵁涓嬫墍鏈夋壒娆″彿淇℃伅", data = "" });
+                return Ok(new { code = 0, msg = "鍒犻櫎鎴愬姛", data = "" });
             }
             catch (Exception e)
             {

--
Gitblit v1.8.0