From cb020af49d74255d8d0a73f75eb7df42245d6ede Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期四, 15 八月 2024 16:16:20 +0800
Subject: [PATCH] Merge branch 'master' of http://47.95.120.53:8083/r/JC26WMS

---
 Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs           |    4 
 HTML/views/ASNSetting/PalletUpShelf.html                |  124 --
 Wms/Wms/Controllers/PdaCrController.cs                  |   34 
 Pda/View/SoSetting/pinTuoOut.html                       |   13 
 Wms/Wms/Controllers/PdaAsnController.cs                 |    9 
 HTML/views/ASNSetting/ProcurePlanNotice.html            |   10 
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs                | 2398 +++++++++++++++++++++++++++-------------------
 Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs |   10 
 Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs                 |   10 
 Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs           |    1 
 Wms/Model/ModelDto/PdaDto/PdaSoDto.cs                   |    4 
 Pda/View/HouseDataSetting/lingXiangUnbind.html          |  169 +++
 Wms/Wms/appsettings.json                                |    5 
 Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs                |    2 
 Wms/Wms/Controllers/PdaSoController.cs                  |   17 
 Wms/Model/ModelVm/PdaVm/PdaCrVm.cs                      |    6 
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs                 |   81 +
 Wms/WMS.BLL/SysServer/MaterialsServer.cs                |    4 
 Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs            |  149 +-
 19 files changed, 1,826 insertions(+), 1,224 deletions(-)

diff --git a/HTML/views/ASNSetting/PalletUpShelf.html b/HTML/views/ASNSetting/PalletUpShelf.html
index 0355c9d..66a957c 100644
--- a/HTML/views/ASNSetting/PalletUpShelf.html
+++ b/HTML/views/ASNSetting/PalletUpShelf.html
@@ -122,32 +122,9 @@
 							lay-filter="LAY-app-contlist-search">
 							<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>鎼滅储
 						</button>
-						<!-- <button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-normal buDaLabelClass" style="margin-left: 5px;" lay-event="BuDaLabel" id="BuDaLabel">
-							<i class="layui-icon layui-icon-print layuiadmin-button-btn"></i>琛ユ墦鏍囩
-						</button>
-						<button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-danger delLabelClass" style="margin-left: 5px;" lay-event="delLabel" id="delLabel">
-							<i class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>鍒犻櫎鏍囩
-						</button> -->
-					</div>
-					<!-- 纭鍑哄簱鍙e脊绐� -->
-					<!-- <div class="layui-inline" id="divDelLotNo" style="display: none; padding-top: 10px;">
-						<div class="layui-inline">
-							<label class="layui-form-label">鍏ュ簱鍗曟嵁</label>
-							<div class="layui-input-inline" style="width: 220px;">
-								<input type="text" id="AsnNoSelect" name="AsnNoSelect" placeholder="鍏ュ簱鍗曟嵁" autocomplete="off" class="layui-input">
-								 
-							</div>
-						</div>
-						<div class="layui-inline DivLoadingArea" style="margin-top: 10px;">
-							<label class="layui-form-label">鎵规鍙�</label>
-							<div class="layui-input-inline" style="width: 220px;">
-								<select name="LotNoSelect" id="LotNoSelect" lay-search>
-									<option value=""></option> 
-								</select>
-							</div>
-						</div>							
 						 
-					</div> -->
+					</div>
+					 
 				</div>
 			</div>
 			<div class="layui-card-body"> 
@@ -217,10 +194,7 @@
 	<script src="../../js/jquery-3.5.1.min.js"></script>
 	<script src="../../js/jquery.cookie.js"></script>
 	<script>
-		// layui.extend({
-		// 	excel: '../../layuiadmin/layui/layui_exts/excel' // {/}鐨勬剰鎬濆嵆浠h〃閲囩敤鑷湁璺緞锛屽嵆涓嶈窡闅� base 璺緞
-		// })
-
+		
 		layui.config({
 			base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
 		}).extend({
@@ -240,98 +214,6 @@
 			// 椤甸潰鍔犺浇缁戝畾Table
 			bindTable();
 
-			//鐢熸垚
-			$('#BuDaLabel').on('click', function () {
-                layer.open({
-					type: 2,
-					title: '鎵撳嵃',
-					content: 'LabelBoxBuDa.html',
-					maxmin: true,
-					area: ['430px', '390px'],
-					// btn: ['鍙栨秷']
-				});
-            });
-			$("#AsnNoSelect").on('input', function () {
-
-				if ($("#AsnNoSelect").val() == "" || $("#AsnNoSelect").val().length < 16) {
-					return
-				}
-				if ($("#AsnNoSelect").val().length >= 16) {
-					$("#AsnNoSelect").val($("#AsnNoSelect").val().substr(-16))
-				}
-				GetLotNoByAsnNo()
-			})
-			function GetLotNoByAsnNo() {
-
-				$("#LotNoSelect").empty()
-                $("#LotNoSelect").append('<option value =>' + '</option>');
-				form.render('select');
-				var param = {
-					asnNo: $("#AsnNoSelect").val(),
-				};
-				sendData(IP + "/BllAsn/GetLotNoListByAsn", param, 'get', function(res) {
-					if (res.code == 0) { //鎴愬姛
-						for (var i = 0; i < res.data.length; i++) {
-							$("#LotNoSelect").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
-						} 
-						form.render('select');
-					} else { //涓嶆垚鍔�
-						layer.msg(res.msg, {
-							icon: 2,
-							time: 3000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
-						}, function() {
-							 
-						});
-					} 
-				});
-			}
-
-            //鍒犻櫎鏍囩
-			$('#delLabel').on('click', function () {
-
-				layer.open({
-					type: 1,
-					title: '鍒犻櫎鏍囩',
-					content: $('#divDelLotNo'),
-					maxmin: false,
-					area: ['350px','340px'],
-					btn: ['纭畾', '鍙栨秷'],
-					yes: function(index, layero) { 
-						var param = {
-							AsnNo: $('#AsnNoSelect').val(),
-							LotNo: $('#LotNoSelect').val(),
-						};
-						sendData(IP + "/BllAsn/DelLabelByAsnNo", param, 'post', function(res) {
-							if (res.code == 0) { //鎴愬姛
-								bindTable();
-								layer.msg(res.msg, {
-									icon: 1,
-									time: 1500 //1绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
-								}, function() {
-									$('#AsnNoSelect').val("");
-									$("#LotNoSelect").empty()
-									$("#LotNoSelect").append('<option value =>' + '</option>');
-									form.render('select');
-								});
-							} else { //涓嶆垚鍔�
-								layer.msg(res.msg, {
-									icon: 2,
-									time: 3000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
-								}, function() {
-									bindTable();
-									$('#AsnNoSelect').val("");
-									$("#LotNoSelect").empty()
-									$("#LotNoSelect").append('<option value =>' + '</option>');
-									form.render('select');
-								});
-							}
-							layer.close(index);
-						});
-					}
-				});
-            });
-
-			
 			//鑷畾涔夎〃澶�
 			var TotalColsArr = [[
 
diff --git a/HTML/views/ASNSetting/ProcurePlanNotice.html b/HTML/views/ASNSetting/ProcurePlanNotice.html
index 103015b..733b7c0 100644
--- a/HTML/views/ASNSetting/ProcurePlanNotice.html
+++ b/HTML/views/ASNSetting/ProcurePlanNotice.html
@@ -292,7 +292,7 @@
 				{ field: 'CreateTime', title: '涓嬪彂鏃堕棿', align: 'center', templet: '#templetCreateTime' },
 				{ field: 'UpdateUserName', title: '淇敼浜�', align: 'center', width: 110 },
 				{ field: 'UpdateTime', title: '淇敼鏃堕棿', align: 'center', templet: '#templetUpdateTime' },
-				{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', width: 280, align: 'center', toolbar: '#toolbarDemo1', "disabled": true }
+				//{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', width: 280, align: 'center', toolbar: '#toolbarDemo1', "disabled": true }
 			]];
 			var TotalColsSysArr = encodeURIComponent(encodeURIComponent(JSON.stringify(TotalColsArr)))//灏嗚〃澶存暟鎹繘琛寀rl缂栫爜
 			//#endregion
@@ -367,15 +367,15 @@
 				{ field: 'Qty', title: '鏁伴噺', align: 'center', width: 70 },
 				{ field: 'CompleteQty', title: '瀹屾垚鏁伴噺', align: 'center', width: 90 },
 				{ field: 'CompleteTime', title: '瀹屾垚鏃堕棿', align: 'center', width: 160, templet: '#templetCompleteTime2' },
-				{ field: 'UnitName', title: '璁¢噺鍗曚綅', align: 'center', width: 90 },
-				{ field: 'Price', title: '鍗曚环', align: 'center', width: 65 },
-				{ field: 'Money', title: '閲戦', align: 'center', width: 65 },
+				//{ field: 'UnitName', title: '璁¢噺鍗曚綅', align: 'center', width: 90 },
+				//{ field: 'Price', title: '鍗曚环', align: 'center', width: 65 },
+				//{ field: 'Money', title: '閲戦', align: 'center', width: 65 },
 				{ field: 'PackagName', title: '鍖呰鍚嶇О', align: 'center', width: 110, },
 				{ field: 'CreateUserName', title: '鍒涘缓浜�', align: 'center', width: 100 },
 				{ field: 'CreateTime', title: '鍒涘缓鏃堕棿', align: 'center', width: 160, templet: '#templetCreateTime2' },
 				{ field: 'UpdateUserName', title: '淇敼浜�', align: 'center', width: 150, },
 				{ field: 'UpdateTime', title: '淇敼鏃堕棿', align: 'center', width: 150, templet: '#templetUpdateTime3' },
-				{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', align: 'center', toolbar: '#toolbarDemoList', "disabled": true }
+				//{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', align: 'center', toolbar: '#toolbarDemoList', "disabled": true }
 			]];
 			var DetailColsSysArr = encodeURIComponent(encodeURIComponent(JSON.stringify(DetailColsArr)))//灏嗚〃澶存暟鎹繘琛寀rl缂栫爜
 			//#endregion
diff --git a/Pda/View/HouseDataSetting/lingXiangUnbind.html b/Pda/View/HouseDataSetting/lingXiangUnbind.html
new file mode 100644
index 0000000..3d3e72e
--- /dev/null
+++ b/Pda/View/HouseDataSetting/lingXiangUnbind.html
@@ -0,0 +1,169 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<meta charset="UTF-8" />
+		<meta name="viewport" content="user-scalable=0,width=device-width,initial-scale=1.0" />
+		<!-- <meta name="viewport" content="width=device-width, initial-scale=0.665, minimum-scale=0.5, maximum-scale=2.0, user-scalable=no" /> -->
+		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
+		<title>Boxline PDA</title>
+
+		<link rel="stylesheet" href="/layui/css/layui.css" />
+		<link rel="stylesheet" href="/css/style.css" />
+		<script src="/js/adaptive.js"></script>
+		<link rel="stylesheet" href="/css/my.css" />
+		<link rel="stylesheet" href="/css/adapter.css" />
+		<style type="text/css">
+			.layout-bill-info {
+				height: 255px;
+			}
+			.layout-tbl-submit {
+				margin-top: 10px;
+			}
+		</style>
+	</head>
+	<body>
+		<div id="" class="main-content">
+			<div id="" class="layout-title">
+				<table border="" cellspacing="" cellpadding="">
+					<tr>
+						<td class="img-back"><a href="../index.html"><img src="/assets/back.jpg" ></a></td>
+						<td class="title-text">闆剁瑙g粦</td>
+						<td class="title-menu-icon"><img id="menuImg" src="/assets/menu.jpg" ></td>
+					</tr>
+				</table>
+			</div>
+			<div id="" class="layout-sub-content">
+				<div id="menuList" class="menu">
+					<ul class="" style="text-align: center;">
+						<li><a href="../index.html">涓婚〉</a></li>
+						<!-- <li><a href="productEnterConfirm.html">鍏ュ簱淇℃伅纭</a></li> -->
+						<li><a href="../login.html">閲嶆柊鐧诲綍</a></li>
+					</ul>
+				</div>
+				
+				<div id="" class="layout-bill-info">
+					<form class="layui-form" action="">
+						<div id="layout-boxcode" class="layui-form-item layout-input">
+							<label class="layui-form-label">鎵樼洏鏉$爜锛�</label>
+							<div class="layui-input-block">
+								<input id="PalletNo" type="text" lay-verify="required" placeholder="璇锋壂鎻忔墭鐩樻潯鐮�"
+									autocomplete="off" class="layui-input">
+							</div>
+						</div>
+                        <div id="BOX" class="layui-form-item layout-input">
+                            <label class="layui-form-label" lang>澶栫鏉$爜锛�</label>
+                            <div class="layui-input-block">
+                                <input id="BOXCODE" type="text" lay-verify="required" lang langholder
+                                    placeholder="璇锋壂鎻忓绠辨潯鐮�" autocomplete="off" class="layui-input">
+                            </div>
+                        </div>
+
+						<table class="layout-tbl-submit" border="" cellspacing="" cellpadding="">
+                            <tr>
+                                <td style="width: 23%;"></td>
+                                <td>
+                                    <button class="layout-btn layout-btn-red" lang type="button" lay-submit
+                                        lay-filter="formUnbind">瑙g粦</button>
+                                </td>
+                                <td style="width: 33%;"></td>
+
+                            </tr>
+                        </table>
+					</form>
+				</div>
+			</div>
+		</div>
+		
+		
+		<script src="/js/jquery-3.5.1.min.js"></script>
+		<script src="/layui/layui.js"></script>
+		<script src="/js/public.js"></script>
+		<script src="/js/jquery.cookie.js"></script>
+		<script>
+			layui.use(['form', 'jquery'], function() {
+				var form = layui.form
+				
+				$("#menuImg").click(function(e){
+					//console.log("menuImg")
+					e.stopPropagation()
+					
+					if($("#menuList").is(":hidden")){
+						$("#menuList").show()
+					}else{
+						$("#menuList").hide()
+					}
+				})
+				$('body').click(function(){
+					// //console.log("body")
+					$("#menuList").hide()
+				})				
+				
+				//褰撴墭鐩樻潯鐮佽緭鍏ユ澶卞幓鐒︾偣鏃�,妫�鏌ヤ竴涓嬫墭鐩樼姸鎬�
+				$("#PalletNo").on('input',function(){
+					  
+					if($("#PalletNo").val() == "" || $("#PalletNo").val().length<10){
+						return
+					}
+					if ($("#PalletNo").val().length>=10) {
+						$("#PalletNo").val($("#PalletNo").val().substr(-10))
+						  
+					}
+				}) 
+                var isChongFu = true;
+				form.on('submit(formUnbind)', function(data) {					
+					if (!$("#PalletNo").val()) {
+						layer.msg('璇锋壂鎻忔墭鐩樻潯鐮�', {
+							icon: 2,
+							time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+						});
+						return;
+					}
+                    if (!$("#BOXCODE").val()) {
+						layer.msg('璇锋壂鎻忓绠辨潯鐮�', {
+							icon: 2,
+							time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+						});
+						return;
+					}
+					if (isChongFu == true) {
+                        isChongFu = false; 
+                        var param = {
+                            "PalletNo": $("#PalletNo").val(),
+                            "BoxNo": $("#BOXCODE").val(),
+                        }
+                        sendData(IP + "/PdaCr/LingxingUnbind", param, 'post', function(res) {
+                            if (res.code == 0) { //鎴愬姛
+                                layer.msg("瑙g粦鎴愬姛", {
+                                    icon: 1,
+                                    time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+                                }, function () {
+                                    tableData = null
+                                    $("#PalletNo").val('')
+                                    $("#BOXCODE").val('')
+
+                                    isChongFu = true;
+                                });
+                            } else { //涓嶆垚鍔�
+                                layer.msg(res.msg, {
+                                    icon: 2,
+                                    time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+                                }, function() {isChongFu = true;});
+                            }
+                        });					
+                        return false; //闃绘琛ㄥ崟璺宠浆銆傚鏋滈渶瑕佽〃鍗曡烦杞紝鍘绘帀杩欐鍗冲彲銆�
+                    }else{
+						layer.msg("璇峰嬁閲嶅鐐瑰嚮", {
+							icon: 2,
+							time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+						});
+					}
+					
+				});
+				
+				// form.verify({
+				// 	stock: [/^[\S]{6}$/, '鎵樼洏鏉$爜蹇呴』涓哄叚浣嶅瓧绗�']
+				// });
+			})
+		</script>
+	</body>
+</html>
diff --git a/Pda/View/SoSetting/pinTuoOut.html b/Pda/View/SoSetting/pinTuoOut.html
index c06d395..982a286 100644
--- a/Pda/View/SoSetting/pinTuoOut.html
+++ b/Pda/View/SoSetting/pinTuoOut.html
@@ -808,7 +808,9 @@
 					SoNo: $("#bar").val(),
 				};
 				synData(IP + "/PdaSo/GetSoSkuLotNoListByPallet", param, 'post', function (res) {
+					console.log(res);
 					if (res.code == 0) { //鎴愬姛
+
 						for (var i = 0; i < res.data.length; i++) {
 							if (i == 0) {
 								$("#skuLotNo").append('<option value =' + res.data[i].SoDetailId + ' selected>' + res.data[i].SkuName + " - " + res.data[i].LotNo + '</option>');
@@ -835,6 +837,7 @@
 					SoDetailId: $("#skuLotNo").val(),
 				};
 				synData(IP + "/PdaSo/GetPlanAndFinishQty", param, 'post', function (res) {
+					console.log("A00");
 					if (res.code == 0) { //鎴愬姛
 						console.log(res.data);
 						$("#planQty").val(res.data.PlanQty)
@@ -1256,8 +1259,8 @@
 							console.log(2)
 							updateSkuLotNoList2();
 							updateQtyList2();
-							getBar2();
-							GetDataInfo();
+							// getBar2();
+							// GetDataInfo();
 						}
 
 					} else { //涓嶆垚鍔�
@@ -1306,6 +1309,8 @@
 					SoNo: $("#bar2").val(),
 				};
 				synData(IP + "/PdaSo/GetSoSkuLotNoListByPallet", param, 'post', function (res) {
+
+					console.log(res);
 					if (res.code == 0) { //鎴愬姛
 						for (var i = 0; i < res.data.length; i++) {
 							if (i == 0) {
@@ -1337,12 +1342,14 @@
 			//鍒濆鍖栨覆鍗曟嵁鐨勮鍒掓暟閲忓拰瀹屾垚鏁伴噺
 			function updateQtyList2() {
 				clear23();
+				console.log("AA");
 				var param = {
 					SoDetailId: $("#skuLotNo2").val(),
 				};
 				synData(IP + "/PdaSo/GetPlanAndFinishQty", param, 'post', function (res) {
+					console.log(res);
+					console.log(res.data);
 					if (res.code == 0) { //鎴愬姛
-						console.log(res.data);
 						$("#planQty2").val(res.data.PlanQty)
 						$("#finishQty2").val(res.data.FinishQty)
 					} else { //涓嶆垚鍔�
diff --git a/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs b/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
index d7af22e..6ae7ac9 100644
--- a/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
+++ b/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
@@ -7,10 +7,10 @@
     public class OutPdaInfo
     {
         public string OutModel { get; set; }                     // 鎷h揣鍖猴紙鍑哄簱鍙o級
-        public decimal PlanQty { get; set; }                       // 璁″垝鏁伴噺
+        public decimal? PlanQty { get; set; }                       // 璁″垝鏁伴噺--
         public decimal? FinishQty { get; set; }                       // 瀹屾垚鏁伴噺
         public string Standard { get; set; }                       // 瑙勬牸
-        public decimal PickQty { get; set; }                       // 鎵樼洏寰呮嫞鏁伴噺
+        public decimal? PickQty { get; set; }                       // 鎵樼洏寰呮嫞鏁伴噺--
         public decimal? PickedQty { get; set; }                       // 鎵樼洏宸叉嫞鏁伴噺
         public string SkuNo { get; set; }                           // 鐗╂枡缂栧彿
     }
diff --git a/Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs b/Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs
index dd0f540..f22756a 100644
--- a/Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs
+++ b/Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs
@@ -102,9 +102,9 @@
         /// <summary>
         /// 绠辨敮淇℃伅
         /// </summary>
-        public List<BoxInfo> BoxInfoList { get; set; }
+        public List<BoxInfosVm> BoxInfoList { get; set; }
     }
-    public class BoxInfo
+    public class BoxInfosVm
     { 
         public string OrderCode { get; set; }
         public string BoxNo { get; set; }
diff --git a/Wms/Model/ModelVm/PdaVm/PdaCrVm.cs b/Wms/Model/ModelVm/PdaVm/PdaCrVm.cs
index 149bf87..1e79eb3 100644
--- a/Wms/Model/ModelVm/PdaVm/PdaCrVm.cs
+++ b/Wms/Model/ModelVm/PdaVm/PdaCrVm.cs
@@ -69,4 +69,10 @@
         /// </summary>
         public string Ruku { get; set; }
     }
+
+    public class PdaPalletUnBindVm
+    {
+        public string PalletNo { get; set; }
+        public string BoxNo { get; set; }
+    }
 }
diff --git a/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs b/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
index 283f9ed..898544e 100644
--- a/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
@@ -1834,7 +1834,7 @@
                     }
                     //濡傛灉璺冲贩閬撳苟涓旀湭鎵惧埌鍚堥�傜┖鍌ㄤ綅,鍒欒烦鍒版渶鍚庝竴娆′娇鐢ㄧ殑宸烽亾鏌ヨ
 
-                    if (roadNo == "")
+                    if (string.IsNullOrWhiteSpace(roadNo))
                     {
                         if (useLog != null)
                         {
@@ -1867,7 +1867,7 @@
                             roadNo = item;
                         }
                         //褰撳墠宸锋湁浣嶇疆鍒欓��鍑�
-                        if (roadNo != null)
+                        if (!string.IsNullOrWhiteSpace(roadNo))
                         {
                             break;
                         }
@@ -1919,6 +1919,7 @@
                     };
                     Db.Insertable(exTask).ExecuteCommand();
 
+                    var asnNo = "";
                     // 娣诲姞鎵樼洏缁戝畾琛ㄦ墭鐩樺叆搴撲换鍔″彿  liudl
                     if (palletBindList.Count < 1)
                     {
@@ -1932,9 +1933,33 @@
                                 bindModel.WareHouseNo = houseNo;
                                 bindModel.RoadwayNo = roadNo;
                                 Db.Updateable(bindModel).ExecuteCommand();
+                                asnNo = stockModel.ASNNo;
                             }
                         }
                     }
+                    foreach (DataStockDetail stockModel in stockDetail)
+                    {
+                        //娣诲姞鎵樼洏涓婃灦璁板綍
+                        var upShelf = new BllPalletUpShelf()
+                        {
+                            TaskNo = exTask.TaskNo,
+                            TraceNo = asnNo,
+                            PalletNo = palletNo,
+                            SkuNo = stockModel.SkuNo,
+                            SkuName = stockModel.SkuName,
+                            LotNo = stockModel.LotNo,
+                            Status = "1",
+
+                            WareHouseNo = houseNo,
+                            RoadwayNo = roadNo,
+                            AreaNo = "",
+                            LocatNo = "",
+
+                            CreateUser = 0,
+                        };
+                        Db.Insertable(upShelf).ExecuteCommand();
+                    }
+                       
 
                     if (palletBindList.Count >= 1)
                     {
@@ -2242,7 +2267,7 @@
 
                         };
                         Db.Insertable(exTask).ExecuteCommand();
-
+                        var asnNo = "";
                         // 娣诲姞鎵樼洏缁戝畾琛ㄦ墭鐩樺叆搴撲换鍔″彿 liudl
                         foreach (DataStockDetail stockModel in stockDetail)
                         {
@@ -2255,9 +2280,32 @@
                                 bindModel.RoadwayNo = locate.RoadwayNo;
                                 bindModel.LocatNo = locate.LocatNo;
                                 Db.Updateable(bindModel).ExecuteCommand();
+                                asnNo = stockModel.ASNNo;
                             }
                         }
+                        foreach (DataStockDetail stockModel in stockDetail)
+                        {
+                            //娣诲姞鎵樼洏涓婃灦璁板綍
+                            var upShelf = new BllPalletUpShelf()
+                            {
+                                TaskNo = exTask.TaskNo,
+                                TraceNo = asnNo,
+                                PalletNo = palletNo,
+                                SkuNo = stockModel.SkuNo,
+                                SkuName = stockModel.SkuName,
+                                LotNo = stockModel.LotNo,
+                                Status = "1",
 
+                                WareHouseNo = houseNo,
+                                RoadwayNo = locate.RoadwayNo,
+                                AreaNo = locate.AreaNo,
+                                LocatNo = locate.LocatNo,
+
+                                CreateUser = 0,
+                            };
+                            Db.Insertable(upShelf).ExecuteCommand();
+                        }
+                            
                         oldTaskNo = taskNo;
                     }
                     else
@@ -2272,16 +2320,34 @@
                         }
                         Db.Updateable(oldTask).ExecuteCommand();
 
-                        var bindModel = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.Status == "2"
-                           && m.PalletNo == oldTask.PalletNo && m.TaskNo == oldTaskNo);
-                        if (bindModel != null && string.IsNullOrWhiteSpace(bindModel.LocatNo))
+
+                        var bindModelList = Db.Queryable<BllPalletBind>().Where(m => m.IsDel == "0" && m.Status == "2"
+                           && m.PalletNo == oldTask.PalletNo && m.TaskNo == oldTaskNo).ToList();
+                        foreach (var bindModel in bindModelList)
                         {
-                            bindModel.TaskNo = oldTask.TaskNo;
-                            bindModel.WareHouseNo = locate.WareHouseNo;
-                            bindModel.RoadwayNo = locate.RoadwayNo;
-                            bindModel.LocatNo = locate.LocatNo;
-                            Db.Updateable(bindModel).ExecuteCommand();
+                            if (string.IsNullOrWhiteSpace(bindModel.LocatNo))
+                            {
+                                bindModel.TaskNo = oldTask.TaskNo;
+                                bindModel.WareHouseNo = locate.WareHouseNo;
+                                bindModel.RoadwayNo = locate.RoadwayNo;
+                                bindModel.LocatNo = locate.LocatNo;
+                                Db.Updateable(bindModel).ExecuteCommand();
+                                
+                            }
                         }
+                        //鏇存敼涓婃灦淇℃伅
+                        var upShelfList = Db.Queryable<BllPalletUpShelf>().Where(m => m.IsDel == "0" && m.TaskNo == oldTask.TaskNo && m.PalletNo == palletNo).ToList();
+                        foreach (var upShelf in upShelfList)
+                        {
+                            upShelf.WareHouseNo = locate.WareHouseNo;
+                            upShelf.RoadwayNo = locate.RoadwayNo;
+                            upShelf.LocatNo = locate.LocatNo;
+                            upShelf.Status = "1";
+                            Db.Updateable(upShelf).ExecuteCommand();
+                             
+                        }
+
+
                     }
 
                     locate.Status = "2";
@@ -2652,6 +2718,7 @@
                     //娣诲姞鎿嶄綔鏃ュ織璁板綍
                     var k = new OperationASNServer().AddLogOperationAsn("鍏ュ簱浣滀笟", "鍏ュ簱鏃ュ織", taskNo, "瀹屾垚", $"鐐瑰嚮瀹屾垚鎸夐挳銆佸畬鎴愪换鍔″彿涓猴細{taskNo}鐨勪换鍔�", userId);
                 }
+                
                 //鍒ゆ柇鏄惁鏄洖娴佸叆搴撳畬鎴�
                 if (stockDetail.Any())
                 {
@@ -3251,7 +3318,13 @@
                 task.FinishDate = comTime;//瀹屾垚鏃堕棿
                 //鏇存柊浠诲姟淇℃伅
                 Db.Updateable(task).ExecuteCommand();
-
+                //鏇存敼鎵樼洏涓婃灦璁板綍淇℃伅
+                var upShelfList = Db.Queryable<BllPalletUpShelf>().Where(m => m.IsDel == "0" && m.TaskNo == taskNo && m.PalletNo == task.PalletNo).ToList();
+                foreach (var upShelf in upShelfList)
+                {
+                    upShelf.Status = "2";
+                    Db.Updateable(upShelf).ExecuteCommand();
+                } 
                 //鍒ゆ柇鏄惁鏄洖娴佸叆搴撳畬鎴�
                 if (stockDetail.Any())
                 {
@@ -3294,49 +3367,6 @@
                         Db.Updateable(dataBoxInfoList).ExecuteCommand();
                         #endregion
 
-                        #region 閲囪喘璁″垝
-                        //var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == item.ASNDetailNo);
-                        //if (noticeDetail == null)
-                        //{
-                        //    throw new Exception("鏈煡璇㈠埌鎵樼洏缁戝畾鐨勫叆搴撳崟鏄庣粏淇℃伅");
-                        //}
-                        //var notice = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == noticeDetail.ASNNo);
-                        //if (notice == null)
-                        //{
-                        //    throw new Exception("鏈煡璇㈠埌鎵樼洏缁戝畾鐨勫叆搴撳崟淇℃伅");
-                        //}
-                        //if (notice.Type == "1" && !string.IsNullOrEmpty(noticeDetail.OrderDetailCode))
-                        //{
-                        //    //閲囪喘鍗曟槑缁�
-                        //    var planDetail = Db.Queryable<BllProcurePlanNoticeDetail>().First(it => it.OrderDetailCode == noticeDetail.OrderDetailCode && it.IsDel == "0");
-                        //    planDetail.CompleteQty += item.Qty;
-                        //    if (planDetail.CompleteQty >= planDetail.Qty)
-                        //    {
-                        //        planDetail.Status = "2";
-                        //        planDetail.CompleteTime = comTime;
-                        //    }
-                        //    Db.Updateable(planDetail).ExecuteCommand();
-
-                        //    //閲囪喘鍗�
-                        //    var planOrd = Db.Queryable<BllProcurePlanNotice>().First(it => it.Id == planDetail.ParentId && it.IsDel == "0");
-                        //    var planDetailNum = Db.Queryable<BllProcurePlanNoticeDetail>()
-                        //    .Count(m => m.IsDel == "0" && m.ParentId == planDetail.ParentId && m.Status != "2");
-                        //    if (planDetailNum == 0)
-                        //    {
-                        //        planOrd.Status = "2";
-                        //        planOrd.CompleteTime = comTime;
-                        //        Db.Updateable(planOrd).ExecuteCommand();
-                        //    }
-                        //    else
-                        //    {
-                        //        if (planOrd.Status == "0")
-                        //        {
-                        //            planOrd.Status = "1";
-                        //            Db.Updateable(planOrd).ExecuteCommand();
-                        //        }
-                        //    }
-                        //}
-                        #endregion
                         item.Status = "3";
                         item.CompleteTime = comTime;
                     }
@@ -3587,6 +3617,15 @@
                     }
                     Db.Updateable(bind).ExecuteCommand();
                 }
+                //鏇存敼鎵樼洏涓婃灦璁板綍淇℃伅
+                var upShelfList = Db.Queryable<BllPalletUpShelf>().Where(m => m.IsDel == "0" && m.TaskNo == taskNo && m.PalletNo == task.PalletNo).ToList();
+                foreach (var upShelf in upShelfList)
+                {
+                    upShelf.IsDel = "1";
+                    Db.Updateable(upShelf).ExecuteCommand();
+                } 
+
+                //鍌ㄤ綅淇℃伅
                 var locate = Db.Queryable<SysStorageLocat>().First(m => m.LocatNo == task.EndLocat);
                 if (locate != null)
                 {
diff --git a/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs b/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
index 3e0f48b..db806fa 100644
--- a/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
@@ -271,6 +271,7 @@
                 {
                     Status = "0",                   
                     OrderCode = model.OrderCode,
+                    UserName = model.Username  //鍒跺崟浜�
                 };
                 // 鎻掑叆閲囪喘鍗曟�昏〃
                 int parentId = Db.Insertable(planModel).ExecuteReturnIdentity();
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index c439b34..3b1572c 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -261,7 +261,7 @@
                 {
                     throw new Exception("褰撳墠鍗曞彿瀛樺湪寮傚父锛�");
                 }
-                
+
 
                 return notice;
             }
@@ -310,14 +310,14 @@
                 {
                     throw new Exception("绌烘墭鐩樻暟閲忎笉鍙负绌�");
                 }
-                var stockDetail = Db.Queryable<DataStockDetail>().Where(m=>m.IsDel == "0" && m.PalletNo == model.PalletNo).ToList();
+                var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == model.PalletNo).ToList();
                 if (stockDetail.Count > 0)
                 {
                     throw new Exception("褰撳墠鎵樼洏鍦ㄥ簱鍐呭凡鏈夊簱瀛樹俊鎭紝璇锋牳瀹�");
                 }
-                
+
                 //鑾峰彇鎵樼洏淇℃伅
-                var pallet = Db.Queryable<SysPallets>().First(m=>m.IsDel == "0" && m.PalletNo == model.PalletNo);
+                var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
                 if (pallet == null)
                 {
                     throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅");
@@ -327,11 +327,11 @@
                     throw new Exception("鎵樼洏鐘舵�佷笉鑳芥湭浣跨敤鐘舵��");
                 }
                 //鑾峰彇鎵樼洏淇℃伅
-                var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel == "0" && m.SkuNo == "100099");
+                var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == "100099");
                 var pNum = 0;
                 var bNum = 0;
 
-                new Common().GetPackQtyInfo(sku.PackagNo,ref pNum,ref bNum);
+                new Common().GetPackQtyInfo(sku.PackagNo, ref pNum, ref bNum);
 
                 var datetime = Db.GetDate();
                 Db.BeginTran();
@@ -352,8 +352,8 @@
                     LotNo = "",
                     LotText = "",
                     SupplierLot = "",
-                    InspectMark ="0", //0 鍚� 1 鏄�
-                    BitPalletMark = pNum== (int)model.Qty? "0":"1",
+                    InspectMark = "0", //0 鍚� 1 鏄�
+                    BitPalletMark = pNum == (int)model.Qty ? "0" : "1",
                     IsBale = "0",
                     IsBelt = "0",
                     CreateUser = (int)model.CreateUser,
@@ -372,7 +372,7 @@
                     Status = "2",
                     CompleteTime = DateTime.Now,
                     Qty = (int)model.Qty,
-                    FullQty = pNum, 
+                    FullQty = pNum,
                     SkuNo = sku.SkuNo,
                     SkuName = sku.PackagNo,
                     LotNo = "",
@@ -392,7 +392,7 @@
                 Db.Insertable(modelbb).ExecuteCommand();
 
                 //娣诲姞搴撳瓨
-                 
+
                 #region 搴撳瓨鏄庣粏
                 var sd1 = new DataStockDetail()
                 {
@@ -464,7 +464,7 @@
 
                     CreateUser = 0,
                     CreateTime = datetime
-                };  
+                };
                 Db.Insertable(box2).ExecuteCommand();
                 #endregion
 
@@ -541,12 +541,12 @@
                     throw new Exception("褰撳墠鎵樼洏宸叉湁浠诲姟锛岃鍏堝彇娑堜换鍔″啀瑙g粦鎵樼洏");
                 }
                 //鑾峰彇浠诲姟淇℃伅
-                var logtask = Db.Queryable<LogTask>().First(a => a.PalletNo == upBindPalletNo && a.IsDel == "0" &&( a.Status == "1" || a.Status == "0"));
+                var logtask = Db.Queryable<LogTask>().First(a => a.PalletNo == upBindPalletNo && a.IsDel == "0" && (a.Status == "1" || a.Status == "0"));
                 if (logtask != null)
                 {
                     throw new Exception("璇ユ墭鐩樻湁浠诲姟浠诲姟姝e湪鎵ц 璇锋牳瀹烇紒");
                 }
-                
+
                 //鑾峰彇绠辩爜淇℃伅
                 var box = Db.Queryable<BllBoxInfo>().First(a => a.PalletNo == upBindPalletNo && a.IsDel == "0" && a.BindNo == bind.Id);
                 //鍒ゆ柇绌烘墭鍏ュ簱鐨勬墭鐩樻槸鍚︽湁璇ユ墭鐩�
@@ -555,8 +555,8 @@
                     strMsg = "璇ユ墭鐩樹笉鏄┖鎵樻墭鐩� 鎴栨湭缁戝畾 璇锋牳瀹炴墭鐩�";
                     return strMsg;
                 }
-                
-                
+
+
                 Db.BeginTran();
 
                 var time = DateTime.Now;
@@ -589,13 +589,13 @@
                 Db.Insertable(modelpb).ExecuteCommand();
 
                 //鍒犻櫎搴撳瓨淇℃伅
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m=>m.IsDel == "0" && m.PalletNo == upBindPalletNo);
+                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == upBindPalletNo);
                 Db.Deleteable(stockDetail).ExecuteCommand();
                 var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id).ToList();
                 Db.Deleteable(boxInfo).ExecuteCommand();
                 var stock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == box.SkuNo);
                 stock.Qty -= bind.Qty;
-                if (stock.Qty==0)
+                if (stock.Qty == 0)
                 {
                     Db.Deleteable(stock).ExecuteCommand();
                 }
@@ -607,8 +607,8 @@
                 {
                     Db.Updateable(stock).ExecuteCommand();
                 }
-               
-                
+
+
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
                 string sqlStr = string.Empty;
                 sqlStr = $"update SysPallets set Status = '0' where PalletNo = '{upBindPalletNo}';";
@@ -773,10 +773,10 @@
                     throw new Exception("-1:鏈幏鍙栧埌瀵瑰簲鍏ュ簱鍗曞崟鎹槑缁嗕俊鎭紝璇锋牳瀹烇紒");
                 }
                 var bind2 = Db.Queryable<BllPalletBind>().Where(a => a.IsDel == "0" && a.Id != model.Id && model.ASNDetailNo == noticeDetail.Id).ToList();
-                
+
 
                 Db.BeginTran();
-                if (bind2.Count(m=>m.InspectMark == "1")>0)
+                if (bind2.Count(m => m.InspectMark == "1") > 0)
                 {
                     noticeDetail.IsSampling = "1";
                 }
@@ -789,9 +789,9 @@
                 //鍒ゆ柇宸茬粍鏁伴噺鏄惁涓�0
                 if (noticeDetail.FactQty == 0)
                 {
-                   
+
                     noticeDetail.Status = "0"; //鍏ュ簱鍗曟槑缁嗙姸鎬�
-                    
+
                     //鑾峰彇鐘舵�佷笉鏄瓑寰呮墽琛岀殑鏄庣粏淇℃伅
                     var count = Db.Queryable<BllArrivalNoticeDetail>().Count(m => m.IsDel == "0" && m.Id != noticeDetail.Id && m.ASNNo == bind.ASNNo && m.Status != "0");
                     if (count == 0)
@@ -1901,7 +1901,7 @@
                 {
                     throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
                 }
-                
+
                 return models;
             }
             catch (Exception ex)
@@ -2454,9 +2454,9 @@
                     }
                 }
 
-                
+
                 int isTextTable = model.TableType;
-                
+
                 #endregion
 
                 Db.BeginTran();
@@ -2648,7 +2648,7 @@
 
                             //box.Qty = box.Qty;
                             //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
-                            
+
                             factQty += box.Qty;
                             boxFullQty += box.Qty;
                             if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
@@ -2684,7 +2684,7 @@
                 if (isSample == "1")
                 {
                     bind.InspectMark = "1";
-                    bind.SamplingQty = bind.SamplingQty == null? sampleQty : bind.SamplingQty + sampleQty;
+                    bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
                 }
                 Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
 
@@ -2717,7 +2717,7 @@
                     var sqlString2 = string.Empty;
                     sqlString2 += $"update BllArrivalNotice set Status = '1',UpdateTime= getDate(),UpdateUser = {userId} where ASNNo = '{model.AsnNo}' and Status ='0';";
                     sqlString2 += $"update BllArrivalNoticeDetail set Status = '1',UpdateTime= getDate(),UpdateUser = {userId} where id = '{model.AsnDetailId}' and Status ='0';";
-                    
+
                     Db.Ado.ExecuteCommand(sqlString2);
                 }
                 else if (detail.Status == "1")
@@ -2725,7 +2725,7 @@
                     var sqlString2 = string.Empty;
                     sqlString2 += $"update BllArrivalNotice set UpdateTime= getDate(),UpdateUser = {userId} where ASNNo = '{model.AsnNo}' and Status ='1';";
                     sqlString2 += $"update BllArrivalNoticeDetail set UpdateTime= getDate(),UpdateUser = {userId} where id = '{model.AsnDetailId}' and Status ='1';";
-                    
+
                     Db.Ado.ExecuteCommand(sqlString2);
                 }
 
@@ -2780,7 +2780,7 @@
 
                 if (string.IsNullOrEmpty(model.LotNo))
                 {
-                     throw new Exception("鐗╂枡涓嶄负绌�!");
+                    throw new Exception("鐗╂枡涓嶄负绌�!");
                 }
                 else
                 {
@@ -2839,7 +2839,7 @@
                 }
                 //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶�
                 var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
-                if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))    
+                if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
                 {
                     throw new Exception("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒");
                 }
@@ -2847,7 +2847,7 @@
                 {
                     throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�");
                 }
-                
+
                 #region 鍖呰
                 var package = Db.Queryable<SysPackag>().Where(m => m.IsDel == "0");
                 var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
@@ -2859,39 +2859,39 @@
                 //鍒ゆ柇鏄惁鏍囩椤靛垽鏂寘瑁�
                 //if (isTextTable == 0)
                 //{
-                    if (pack == null)
-                    {
-                        throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
-                    }
-                    if (pack.L5Num.HasValue)
-                    {
-                        pNum = (int)pack.L5Num;
-                        bNum = (int)pack.L4Num;
-                    }
-                    else if (pack.L4Num.HasValue)
-                    {
-                        pNum = (int)pack.L4Num;
-                        bNum = (int)pack.L3Num;
-                    }
-                    else if (pack.L3Num.HasValue)
-                    {
-                        pNum = (int)pack.L3Num;
-                        bNum = (int)pack.L2Num;
-                    }
-                    else if (pack.L2Num.HasValue)
-                    {
-                        pNum = (int)pack.L2Num;
-                        bNum = (int)pack.L1Num;
-                    }
-                    else if (pack.L1Num.HasValue)
-                    {
-                        pNum = (int)pack.L1Num;
-                        bNum = (int)pack.L1Num;
-                    }
-                    if (pNum == 0 || bNum == 0)
-                    {
-                        throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
-                    }
+                if (pack == null)
+                {
+                    throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
+                }
+                if (pack.L5Num.HasValue)
+                {
+                    pNum = (int)pack.L5Num;
+                    bNum = (int)pack.L4Num;
+                }
+                else if (pack.L4Num.HasValue)
+                {
+                    pNum = (int)pack.L4Num;
+                    bNum = (int)pack.L3Num;
+                }
+                else if (pack.L3Num.HasValue)
+                {
+                    pNum = (int)pack.L3Num;
+                    bNum = (int)pack.L2Num;
+                }
+                else if (pack.L2Num.HasValue)
+                {
+                    pNum = (int)pack.L2Num;
+                    bNum = (int)pack.L1Num;
+                }
+                else if (pack.L1Num.HasValue)
+                {
+                    pNum = (int)pack.L1Num;
+                    bNum = (int)pack.L1Num;
+                }
+                if (pNum == 0 || bNum == 0)
+                {
+                    throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
+                }
                 //}
                 #endregion
 
@@ -2911,7 +2911,7 @@
                 }
                 #endregion
                 //liudl  && m.Status != "2"  缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂�
-                var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);   
+                var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
                 var bindId = 0;
                 if (bind == null)
                 {
@@ -2988,7 +2988,7 @@
 
                     Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
                 }
-                else 
+                else
                 {
                     // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
                     sd1 = new DataStockDetail()
@@ -3059,7 +3059,7 @@
                     }
                     //娣诲姞搴撳瓨鏄庣粏
                     sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
-                }       
+                }
                 #endregion
 
                 #region 绠辩爜淇℃伅
@@ -3260,7 +3260,7 @@
                 #endregion
 
                 #region 搴撳瓨鏄庣粏
-                sd1.Qty = bind.Qty;   
+                sd1.Qty = bind.Qty;
                 //鏇存敼搴撳瓨鏄庣粏鏁伴噺
                 Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
                 #endregion
@@ -3277,7 +3277,7 @@
                     {
                         dataStock.Qty += model.SkuQty;
                     }
-                    
+
                     if (bind.InspectMark == "1")
                     {
                         dataStock.IsSampling = bind.InspectMark;
@@ -3352,14 +3352,12 @@
             }
         }
 
-
         //JC26缁戝畾鎵樼洏 璐存爣鐗╂枡
         public void BindPalletPasteCode(PdaPalletBindVm model, int userId)
         {
             try
             {
                 #region 鍒ゆ柇
-
                 //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴�
                 var TypeLot = "5, 6";
 
@@ -3375,7 +3373,6 @@
                 {
                     throw new Exception("鎵樼洏鍙蜂笉鍙负绌�!");
                 }
-
                 //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
                 var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
                 if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2")
@@ -3397,20 +3394,16 @@
                     }
                     else
                     {
-                        if (!TypeLot.Contains(notice.Type))
-                        {
-                            throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
-                        }
-
-                        model.LotNo = "";
+                        throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
                     }
                 }
 
+                //鍒ゆ柇绠辩爜淇℃伅
                 if (string.IsNullOrEmpty(model.BoxNo))
                 {
                     throw new Exception("绠辩爜淇℃伅涓嶅彲涓虹┖!");
                 }
-
+                //鏄惁杩炵画缁勬墭 0锛氬惁  1锛氭槸
                 if (model.IsContinue == "1")
                 {
                     if (string.IsNullOrWhiteSpace(model.TailBoxNo))
@@ -3419,15 +3412,13 @@
                     }
                 }
 
-                var comTime = DateTime.Now;
-
-                //鎵樼洏鏄惁瀛樺湪
+                //鎵樼洏淇℃伅鏄惁瀛樺湪
                 var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
                 if (pallet == null)
                 {
                     throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
                 }
-                // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
+                //楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
                 var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
                 if (detail == null)
                 {
@@ -3439,17 +3430,21 @@
                 {
                     throw new Exception("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒");
                 }
-                if (stockDetail != null && (stockDetail.SkuNo != detail.SkuNo || stockDetail.LotNo != model.LotNo))
+                /*if (stockDetail != null && stockDetail.SkuNo != detail.SkuNo)
                 {
-                    throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�");
-                }
-
+                    throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡淇℃伅锛岃鏍稿疄锛�");
+                }*/
                 #endregion
 
-                #region 鍖呰
+                //寮�鍚簨鍔�
+                Db.BeginTran();
+                //褰撳墠鏃堕棿
+                var comTime = DateTime.Now;
 
+                #region 鍖呰
+                var package = Db.Queryable<SysPackag>().Where(m => m.IsDel == "0");
                 var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
-                var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
+                var pack = package.First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
 
                 var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 
                 var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 
@@ -3491,7 +3486,6 @@
                 #endregion
 
                 #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
-
                 var palletBind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo && m.PalletNo == model.PalletNo && m.ASNDetailNo != model.AsnDetailId);
                 if (palletBind != null)
                 {
@@ -3505,1012 +3499,1380 @@
                         }
                     }
                 }
-
                 #endregion
 
-                /* 鍥犺�冭檻鍙兘浼氭湁鎷肩(鍚岀墿鏂欎笉鍚屾壒娆�)锛岄�昏緫濡備笅
-                 * 鏌ヨ鍑鸿缁戝畾鎵樼洏鐨勭鐮佷俊鎭�佸垎缁勬暣鐞嗐�佸垽鏂槸鍚︽湁鎷肩(鍏佽鏈夊涓�)锛屽惊鐜坊鍔犵鐮�<->搴撳瓨绠辩爜 鍜� 瀵瑰簲鐨勬墭鐩樼粦瀹�<->搴撳瓨鎵樼洏鏄庣粏淇℃伅 
-                 * 寰幆绠辩爜闇�瑕佸垽鏂槸鍚︽槸褰撳墠鍗曟嵁锛屽涓嶆槸锛氭洿鏂板搴斿崟鎹�
-                 * 
-                 *
-                 */
+                #region 绠辩爜淇℃伅
+                var msgStr = $"绠卞彿涓簕model.BoxNo}";
+                var boxInfoList = new List<BllBoxInfo>();
 
-                //#region 绠辩爜淇℃伅
-                //var msgStr = $"绠卞彿涓簕model.BoxNo}";
-                //var boxInfoList = new List<BllBoxInfo>();
+                //棣栫
+                var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo).ToList();
+                if (boxInfo.Count == 0)
+                {
+                    throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
+                }
+                boxInfoList.AddRange(boxInfo);
+                //鏄惁杩炵画缁勬墭
+                if (model.IsContinue == "1")
+                {
+                    //灏剧
+                    var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo).ToList();
+                    if (boxInfo2.Count == 0)
+                    {
+                        throw new Exception("灏剧鐮佷俊鎭笉瀛樺湪!");
+                    }
+                    boxInfoList.AddRange(boxInfo2);
+                    var sql = $"select * from BllBoxInfo where IsDel = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}'; ";
+                    var list = Db.Ado.SqlQuery<BllBoxInfo>(sql);
+                    boxInfoList.AddRange(list);
+                    msgStr += $"灏剧鍙蜂负{model.TailBoxNo}";
+                }
+                //缁戝畾绠辨�绘暟閲�
+                //model.SkuQty = boxInfoList.Sum(s => s.Qty);
+                //鍜岄�夋嫨鐨勬壒娆″悓鎵规鐨勭鐮佷俊鎭�
+                var sameBoxInfoList = boxInfoList.Where(w => w.LotNo == model.LotNo).ToList();
+                //鍜岄�夋嫨鐨勬壒娆′笉鍚屾壒娆$殑绠辩爜淇℃伅锛堟嫾绠辨壒娆★級
+                var notBoxInfoList = boxInfoList.Where(w => w.LotNo != model.LotNo).ToList();
+                #endregion
 
-                ////棣栫
-                //var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo).ToList();
-                //if (boxInfo.Count == 0)
-                //{
-                //    throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
-                //}
-                //boxInfo = boxInfo.Where(m => m.Status == "0").ToList();
-                //if (boxInfo.Count == 0)
-                //{
-                //    throw new Exception("绠辩爜宸茶浣跨敤!");
-                //}
-                //boxInfoList.AddRange(boxInfo);
-                ////鏄惁杩炵画缁勬墭
-                //if (model.IsContinue == "1")
-                //{
-                //    //灏剧
-                //    var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo).ToList();
-                //    if (boxInfo2.Count == 0)
-                //    {
-                //        throw new Exception("灏剧鐮佷俊鎭笉瀛樺湪!");
-                //    }
-                //    boxInfo2 = boxInfo2.Where(m => m.Status == "0").ToList();
-                //    if (boxInfo2.Count == 0)
-                //    {
-                //        throw new Exception("灏剧绠辩爜宸茶浣跨敤!");
-                //    }
-                //    boxInfoList.AddRange(boxInfo2);
-                //    var sql = $"select * from BllBoxInfo where IsDel = '0' and Status = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}'; ";
-                //    var list = Db.Ado.SqlQuery<BllBoxInfo>(sql);
-                //    boxInfoList.AddRange(list);
-                //    msgStr += $"灏剧鍙蜂负{model.TailBoxNo}";
-                //}
+                if (sameBoxInfoList.Count <= 0)
+                {
+                    throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
+                }
+                else
+                {
+                    #region 鎵樼洏缁戝畾淇℃伅
+                    var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
+                    var bindId = 0;
+                    if (bind == null)
+                    {
+                        bind = new BllPalletBind
+                        {
+                            ASNNo = model.AsnNo,
+                            ASNDetailNo = (int)model.AsnDetailId,
+                            PalletNo = model.PalletNo,
+                            PalletNo2 = "",
+                            PalletNo3 = "",
+                            Qty = model.SkuQty,//涓嶅寘鍚嫾绠变腑闈炲悓鎵规鏁伴噺
+                            FullQty = pNum,
+                            Status = "2",//鍏ュ簱瀹屾垚
+                            Type = "0",
+                            LotNo = model.LotNo,
+                            LotText = detail.LotText,
+                            SupplierLot = detail.SupplierLot,
+                            //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                            //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                            BitPalletMark = "1",
+                            IsBale = "0",
+                            IsBelt = "0",
+                            CreateUser = userId,
+                            Demo = model.Demo,
+                        };
+                        // 鎻掑叆鎵樼洏缁戝畾琛�
+                        bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+                    }
+                    else
+                    {
+                        bindId = bind.Id;
+                        bind.Qty += model.SkuQty;
+                    }
+                    /*if (bind.Qty < 0)
+                    {
+                        throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0");
+                    }*/
+                    #endregion
 
-                //#endregion
+                    #region 搴撳瓨鏄庣粏鍜岃川妫�淇℃伅
+                    //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
+                    BllQualityInspect quality = new BllQualityInspect();
+                    //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
+                    if (notice.Type == "3")
+                    {
+                        quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
+                    }
+                    else
+                    {
+                        quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
+                    }
+                    var tags = "0";
+                    if (notice.Type == "3" || notice.Type == "4")
+                    {
+                        tags = "1";
+                    }
 
-                //// 鏇存敼绠辨敮鍏崇郴琛�
-                //decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
-                //var isSample = "0";//鏄惁鍙栨牱
-                //var sampleQty = 0m;//鍙栨牱鏁伴噺
+                    // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
+                    var sd1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo);
+                    var sdId1 = 0;
+                    if (sd1 != null)
+                    {
+                        sdId1 = sd1.Id;
+                        // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁
+                        sd1.Qty = bind.Qty;
+                        sd1.CompleteTime = comTime;
+                        sd1.UpdateUser = userId;
+                        sd1.UpdateTime = comTime;
 
-                //var boxInfoStr = boxInfoList.Select(m => m.BoxNo3).ToList();//鏀爜闆嗗悎
-                //var dataBoxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && boxInfoStr.Contains(m.BoxNo3));//浠庡簱瀛樹腑鑾峰彇瀵瑰簲鐨勭鐮佷俊鎭泦鍚�
+                        Db.Updateable(sd1).ExecuteCommand();
+                    }
+                    else
+                    {
+                        // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
+                        sd1 = new DataStockDetail()
+                        {
+                            LotNo = bind.LotNo,
+                            LotText = bind.LotText,
+                            SupplierLot = bind.SupplierLot,
+                            SkuNo = sku.SkuNo,
+                            SkuName = sku.SkuName,
+                            Standard = sku.Standard,
+                            Qty = bind.Qty,
+                            LockQty = 0,
+                            FrozenQty = 0,
+                            InspectQty = 0,
+                            ASNNo = bind.ASNNo,
+                            ASNDetailNo = bind.ASNDetailNo,
+                            WareHouseNo = "",//鎵�灞炰粨搴�
+                            RoadwayNo = "",//鎵�灞炲贩閬�
+                            AreaNo = "",//鎵�灞炲尯鍩�
+                            LocatNo = "",//鍌ㄤ綅鍦板潃
+                            PalletNo = bind.PalletNo,
+                            PalletNo2 = bind.PalletNo2,
+                            PalletNo3 = bind.PalletNo3,
+                            PalletTags = tags,
+                            CompleteTime = comTime,
+                            ProductionTime = bind.ProductionTime,
+                            ExpirationTime = bind.ExpirationTime,
+                            Status = "0",
+                            InspectMark = bind.InspectMark,
+                            InspectStatus = sku.IsInspect,
+                            BitPalletMark = bind.BitPalletMark,
+                            PackagNo = detail.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
+                            IsBale = bind.IsBale,
+                            IsBelt = bind.IsBelt,
 
-                //var boxGroup = boxInfoList.GroupBy(m => new {  m.BoxNo ,m.LotNo}).ToList();  //鏍规嵁绠辩爜銆佹壒姝ゅ垎缁�
-                //foreach (var g in boxGroup)//21
-                //{
-                    
-                //    var isYou = false;//闇�鍒ゆ柇鏄惁鏄瓨鍦ㄥ簱瀛�
-                //    var count = dataBoxInfo.Count(m => m.BoxNo == g.Key.BoxNo);
-                //    if (count >0)
-                //    {
-                //        isYou = true;
-                //    }
+                            IsDel = "0",
+                            CreateUser = 0,
+                            CreateTime = comTime
+                        };
 
-                //    var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo && m.LotNo == g.Key.LotNo);
+                        //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                        if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                        {
+                            sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                            sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                        }
+                        else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
+                        {
+                            sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+                            sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
+                        }
+                        if (quality != null)
+                        {
+                            //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
+                            if (quality.IsQualified == "1") //鍚堟牸
+                            {
+                                //澧炲姞鍚堟牸鏁伴噺
+                                quality.PassQty += bind.Qty;
+                                sd1.InspectStatus = "1";
+                            }
+                            else if (quality.IsQualified == "0") //涓嶅悎鏍�
+                            {
+                                //澧炲姞涓嶅悎鏍兼暟閲�
+                                quality.FailQty += bind.Qty;
+                                sd1.InspectStatus = "2";
+                            }
+                            Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
+                        }
+                        //娣诲姞搴撳瓨鏄庣粏
+                        sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
+                    }
+                    #endregion
 
-                //    var bindId = 0;
-                //    if (bind == null && !isYou)
-                //    {
-                //        bind = new BllPalletBind
-                //        {
-                //            ASNNo = model.AsnNo,
-                //            ASNDetailNo = (int)model.AsnDetailId,
-                //            PalletNo = model.PalletNo,
+                    // 鏇存敼绠辨敮鍏崇郴琛�
+                    decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+                    var isSample = "0";//鏄惁鍙栨牱
+                    var sampleQty = 0m;//鍙栨牱鏁伴噺
 
-                //            Qty = model.SkuQty,
-                //            FullQty = pNum,
-                //            Status = "2",//鍏ュ簱瀹屾垚
-                //            Type = "0",
-                //            LotNo = model.LotNo,
-                //            LotText = detail.LotText,
-                //            SupplierLot = detail.SupplierLot,
-                //            //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //            //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //            BitPalletMark = "1",
-                //            IsBale = "0",
-                //            IsBelt = "0",
-                //            CreateUser = userId,
-                //            Demo = model.Demo,
+                    //鏍囩缁勬墭
+                    var boxGroup = sameBoxInfoList.GroupBy(m => m.BoxNo).ToList();
+                    foreach (var g in boxGroup)
+                    {
+                        decimal boxFullQty = 0;//绠卞唴鎬绘暟閲�
+                        foreach (var box in g)
+                        {
+                            if (box.BindNo != null && box.BindNo != 0)
+                            {
+                                continue;
+                            }
+                            //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
+                            if (box.SkuNo != detail.SkuNo || box.LotNo != model.LotNo)
+                            {
+                                throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
+                            }
 
-                //        };
-                //        // 鎻掑叆鎵樼洏缁戝畾琛�
-                //        bindId = Db.Insertable(bind).ExecuteReturnIdentity();
-                //    }
-                //    else
-                //    {
-                //        bindId = bind.Id;
-                //        bind.Qty += model.SkuQty;
-                //    }
-                //    if (bind.Qty < 0)
-                //    {
-                //        throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0");
-                //    }
+                            box.ASNNo = model.AsnNo;
+                            box.ASNDetailNo = model.AsnDetailId;
+                            box.BindNo = bindId;
+                            box.PalletNo = model.PalletNo;
+                            box.Status = "2";
+                            //box.InspectMark = model.IsSample;  //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                            //box.SamplingQty = 0;    //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                            box.CompleteTime = comTime;
+                            box.UpdateTime = comTime;
+                            box.UpdateUser = userId;
 
+                            //box.Qty = box.Qty;
+                            //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
 
-                //    decimal boxFullQty = 0;//绠卞唴鎬绘暟閲�
-                //    foreach (var box in g)//鏀爜 2
-                //    {
-                //        if (box.BindNo != null && box.BindNo != 0)
-                //        {
-                //            continue;
-                //        }
-                //        //绠卞唴鐗╂枡涓庡崟鎹槑缁嗕笉绗﹀悎  鍚屾墭鐩樺彲鍚岀墿鏂欎笉鍚屾壒娆�
-                //        if (box.SkuNo != detail.SkuNo)
-                //        {
-                //            throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
-                //        }
-                        
-                        
-                        
+                            factQty += box.Qty;
+                            boxFullQty += box.Qty;
+                            if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
+                            {
+                                isSample = "1";
+                                sampleQty += (decimal)box.SamplingQty;
+                            }
 
-                //        box.ASNNo = model.AsnNo;
-                //        box.ASNDetailNo = model.AsnDetailId;
-                //        box.BindNo = bindId;
-                //        box.PalletNo = model.PalletNo;
-                //        box.Status = "2";
-                //        //box.InspectMark = model.IsSample;  //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //        //box.SamplingQty = 0;    //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //        box.CompleteTime = comTime;
-                //        box.UpdateTime = comTime;
-                //        box.UpdateUser = userId;
+                            #region 搴撳瓨绠辩爜鏄庣粏
+                            var box2 = new DataBoxInfo()
+                            {
+                                StockDetailId = sdId1,
+                                BindNo = bind.Id,
+                                BoxNo = box.BoxNo,
+                                BoxNo2 = box.BoxNo2,
+                                BoxNo3 = box.BoxNo3,
+                                PalletNo = box.PalletNo,
+                                PalletNo2 = box.PalletNo2,
+                                PalletNo3 = box.PalletNo3,
+                                Qty = box.Qty,
+                                FullQty = box.FullQty,
+                                Status = "2",//0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
+                                LotNo = box.LotNo,
+                                LotText = box.LotText,
+                                SkuNo = box.SkuNo,
+                                SkuName = box.SkuName,
+                                Standard = sku.Standard,
+                                ProductionTime = box.ProductionTime,
+                                SupplierLot = box.SupplierLot,
+                                InspectStatus = sku.IsInspect,
+                                InspectMark = box.InspectMark,
+                                BitBoxMark = box.BitBoxMark,
+                                ExpirationTime = box.ExpirationTime,
 
-                //        //box.Qty = box.Qty;
-                //        //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
+                                CreateUser = 0,
+                                CreateTime = comTime
+                            };
+                            //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                            Db.Insertable(box2).ExecuteCommand();
+                            #endregion
+                        }
+                        if (boxFullQty > bNum)
+                        {
+                            throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+                        }
+                    }
+                    //鏇存敼绠辨敮鍏崇郴琛ㄤ俊鎭�
+                    Db.Updateable(boxInfoList).ExecuteCommand();
 
-                //        factQty += box.Qty;
-                //        boxFullQty += box.Qty;
-                //        if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
-                //        {
-                //            isSample = "1";
-                //            sampleQty += (decimal)box.SamplingQty;
-                //        }
+                    // 鏇存柊鎵樼洏缁戝畾琛�
+                    bind.Qty += factQty;
 
-                //        #region 搴撳瓨绠辩爜鏄庣粏
-                //        var box2 = new DataBoxInfo()
-                //        {
-                //            StockDetailId = sdId1,
-                //            BindNo = bind.Id,
-                //            BoxNo = box.BoxNo,
-                //            BoxNo2 = box.BoxNo2,
-                //            BoxNo3 = box.BoxNo3,
-                //            PalletNo = box.PalletNo,
-                //            PalletNo2 = box.PalletNo2,
-                //            PalletNo3 = box.PalletNo3,
-                //            Qty = box.Qty,
-                //            FullQty = box.FullQty,
-                //            Status = "2",//0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
-                //            LotNo = box.LotNo,
-                //            LotText = box.LotText,
-                //            SkuNo = box.SkuNo,
-                //            SkuName = box.SkuName,
-                //            Standard = sku.Standard,
-                //            ProductionTime = box.ProductionTime,
-                //            SupplierLot = box.SupplierLot,
-                //            InspectStatus = sku.IsInspect,
-                //            InspectMark = box.InspectMark,
-                //            BitBoxMark = box.BitBoxMark,
-                //            ExpirationTime = box.ExpirationTime,
+                    if (bind.FullQty < bind.Qty)
+                    {
+                        throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+                    }
 
-                //            CreateUser = 0,
-                //            CreateTime = comTime
-                //        };
-                //        //娣诲姞搴撳瓨绠辩爜鏄庣粏
-                //        Db.Insertable(box2).ExecuteCommand();
-                //        #endregion
-                //    }
-                //    if (boxFullQty > bNum)
-                //    {
-                //        throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
-                //    }
-                //}
-                //Db.Updateable(boxInfoList).ExecuteCommand();
+                    if (bind.FullQty == bind.Qty)
+                    {
+                        bind.BitPalletMark = "0";
+                        sd1.BitPalletMark = "0";
+                    }
+                    if (bind.Qty > pNum)
+                    {
+                        throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                    }
 
+                    if (isSample == "1")
+                    {
+                        bind.InspectMark = "1";
+                        bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
+                    }
+                    Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
 
-                //#region 搴撳瓨鏄庣粏
-                ////鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
-                //BllQualityInspect quality = new BllQualityInspect();
-                ////鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
-                //if (notice.Type == "3")
-                //{
-                //    quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
-                //}
-                //else
-                //{
-                //    quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
-                //}
-                //var tags = "0";
-                //if (notice.Type == "3" || notice.Type == "4")
-                //{
-                //    tags = "1";
-                //}
+                    #region 鍏ュ簱鍗曞強鏄庣粏
+                    detail.FactQty += factQty;//宸茬粍鏁伴噺
+                    detail.CompleteQty += factQty;//瀹屾垚鏁伴噺
+                    if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍�
+                    {
+                        detail.IsSampling = "1";
+                    }
+                    detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
+                    if (detail.CompleteQty >= detail.Qty)
+                    {
+                        detail.Status = "2";
+                        detail.CompleteTime = comTime;
+                    }
+                    detail.UpdateUser = userId;
+                    detail.UpdateTime = comTime;
+                    //鏇存柊鍏ュ簱鍗曟槑缁�
+                    Db.Updateable(detail).ExecuteCommand();
 
-                //// 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
-                //var sd1 = Db.Queryable<DataStockDetail>()
-                //    .First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo);
-                //var sdId1 = 0;
-                //if (sd1 != null)
-                //{
-                //    sdId1 = sd1.Id;
-                //    // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁
-                //    sd1.Qty = bind.Qty;
-                //    sd1.CompleteTime = comTime;
-                //    sd1.UpdateUser = userId;
-                //    sd1.UpdateTime = comTime;
+                    notice.UpdateUser = userId;
+                    notice.UpdateTime = comTime;
+                    if (notice.Status == "0")
+                    {
+                        notice.Status = "1";
+                    }
+                    var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>().Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2");
+                    if (asnDetailNum == 0)
+                    {
+                        notice.Status = "2";//鎵ц瀹屾垚
+                        notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
+                    }
+                    //鏇存柊鍏ュ簱鍗�
+                    Db.Updateable(notice).ExecuteCommand();
+                    #endregion
 
-                //    Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
-                //}
-                //else
-                //{
-                //    // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
-                //    sd1 = new DataStockDetail()
-                //    {
-                //        LotNo = bind.LotNo,
-                //        LotText = bind.LotText,
-                //        SupplierLot = bind.SupplierLot,
-                //        SkuNo = sku.SkuNo,
-                //        SkuName = sku.SkuName,
-                //        Standard = sku.Standard,
-                //        Qty = bind.Qty,
-                //        LockQty = 0,
-                //        FrozenQty = 0,
-                //        InspectQty = 0,
-                //        ASNNo = bind.ASNNo,
-                //        ASNDetailNo = bind.ASNDetailNo,
-                //        WareHouseNo = "",//鎵�灞炰粨搴�
-                //        RoadwayNo = "",//鎵�灞炲贩閬�
-                //        AreaNo = "",//鎵�灞炲尯鍩�
-                //        LocatNo = "",//鍌ㄤ綅鍦板潃
-                //        PalletNo = bind.PalletNo,
-                //        PalletNo2 = bind.PalletNo2,
-                //        PalletNo3 = bind.PalletNo3,
-                //        PalletTags = tags,
-                //        CompleteTime = comTime,
-                //        ProductionTime = bind.ProductionTime,
-                //        ExpirationTime = bind.ExpirationTime,
-                //        Status = "0",
-                //        InspectMark = bind.InspectMark,
-                //        InspectStatus = sku.IsInspect,
-                //        BitPalletMark = bind.BitPalletMark,
-                //        PackagNo = detail.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
-                //        IsBale = bind.IsBale,
-                //        IsBelt = bind.IsBelt,
+                    #region 搴撳瓨鏄庣粏
+                    sd1.Qty = bind.Qty;
+                    //鏇存敼搴撳瓨鏄庣粏鏁伴噺
+                    Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
+                    #endregion
 
-                //        IsDel = "0",
-                //        CreateUser = 0,
-                //        CreateTime = comTime
-                //    };
+                    #region 搴撳瓨
+                    var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo);
+                    if (dataStock != null)
+                    {
+                        dataStock.Qty += factQty;
 
-                //    //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
-                //    if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
-                //    {
-                //        sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
-                //        sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О
-                //    }
-                //    else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
-                //    {
-                //        sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
-                //        sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
-                //    }
-                //    if (quality != null)
-                //    {
-                //        //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
-                //        if (quality.IsQualified == "1") //鍚堟牸
-                //        {
-                //            //澧炲姞鍚堟牸鏁伴噺
-                //            quality.PassQty += bind.Qty;
-                //            sd1.InspectStatus = "1";
-                //        }
-                //        else if (quality.IsQualified == "0") //涓嶅悎鏍�
-                //        {
-                //            //澧炲姞涓嶅悎鏍兼暟閲�
-                //            quality.FailQty += bind.Qty;
-                //            sd1.InspectStatus = "2";
-                //        }
-                //        Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
-                //    }
-                //    //娣诲姞搴撳瓨鏄庣粏
-                //    sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
-                //}
-                //#endregion
+                        if (bind.InspectMark == "1")
+                        {
+                            dataStock.IsSampling = bind.InspectMark;
+                        }
+                        Db.Updateable(dataStock).ExecuteCommand();
+                    }
+                    else
+                    {
+                        var stock = new DataStock()
+                        {
+                            SkuNo = sku.SkuNo,
+                            SkuName = sku.SkuName,
+                            Standard = sku.Standard,
+                            LotNo = bind.LotNo,
+                            LotText = bind.LotText,
+                            Qty = bind.Qty,
+                            LockQty = 0,
+                            FrozenQty = 0,
+                            IsSampling = bind.InspectMark,
+                            IsDel = "0",
+                            CreateUser = userId,
+                            CreateTime = comTime
+                        };
+                        //缁存姢搴撳瓨璐т富淇℃伅
+                        if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                        {
+                            stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                            stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                        }
+                        Db.Insertable(stock).ExecuteCommand();
+                    }
+                    #endregion
 
-                //#region 绠辩爜淇℃伅
-                //var msgStr = $"绠卞彿涓簕model.BoxNo}";
-                //var boxInfoList = new List<BllBoxInfo>();
+                    #region 璐ㄦ璇烽獙
+                    if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
+                    {
+                        var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
+                        if (qualityRequest == null)
+                        {
+                            string qcNo = new Common().GetMaxNo("QC");
+                            qualityRequest = new BllQualityInspectionRequest();
+                            qualityRequest.QcNo = qcNo;
+                            qualityRequest.Status = "0";
+                            qualityRequest.SkuNo = sku.SkuNo;
+                            qualityRequest.SkuName = sku.SkuName;
+                            qualityRequest.LotNo = bind.LotNo;
+                            qualityRequest.SupplierLot = bind.SupplierLot;
+                            qualityRequest.Qty = detail.Qty;
+                            qualityRequest.SamplingQty = 0;
+                            qualityRequest.ASNNo = detail.ASNNo;
+                            qualityRequest.CreateUser = userId;
+                            qualityRequest.CreateTime = comTime;
+                            //娣诲姞璐ㄦ璇烽獙鍗�
+                            Db.Insertable(qualityRequest).ExecuteCommand();
+                        }
+                    }
+                    #endregion
+                }
+                //鎷肩
+                if (notBoxInfoList.Count > 0)
+                {
+                    var gbox = notBoxInfoList.GroupBy(g => g.BoxNo).ToList();
+                    if (gbox.Count > 1)
+                    {
+                        throw new Exception("涓�涓墭鐩樹笂鍙兘鏈�1涓嫾绠�!");
+                    }
+                    gbox = notBoxInfoList.GroupBy(g => g.LotNo).ToList();
+                    if (gbox.Count > 1)
+                    {
+                        throw new Exception("涓�涓鍐呮渶澶氳兘鏈�2涓笉鍚屾壒娆$墿鏂�!");
+                    }
+                    var pinBoxNo = notBoxInfoList[0].BoxNo;//鎷肩绠辩爜
+                    var pinBoxLotNo = notBoxInfoList[0].LotNo;//鎷肩鎵规鍙�
+                    //鎷肩鏁伴噺(鍜岄�夋嫨鐨勬壒娆′笉鍚屾壒娆$殑绠辩爜鏁伴噺)
+                    decimal pinBoxQty = notBoxInfoList.Sum(s => s.Qty);
 
-                ////棣栫
-                //var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo).ToList();
-                //if (boxInfo.Count == 0)
-                //{
-                //    throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
-                //}
-                //boxInfo = boxInfo.Where(m => m.Status == "0").ToList();
-                //if (boxInfo.Count == 0)
-                //{
-                //    throw new Exception("绠辩爜宸茶浣跨敤!");
-                //}
-                //boxInfoList.AddRange(boxInfo);
-                ////鏄惁杩炵画缁勬墭
-                //if (model.IsContinue == "1")
-                //{
-                //    //灏剧
-                //    var boxInfo2 = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo).ToList();
-                //    if (boxInfo2.Count == 0)
-                //    {
-                //        throw new Exception("灏剧鐮佷俊鎭笉瀛樺湪!");
-                //    }
-                //    boxInfo2 = boxInfo2.Where(m => m.Status == "0").ToList();
-                //    if (boxInfo2.Count == 0)
-                //    {
-                //        throw new Exception("灏剧绠辩爜宸茶浣跨敤!");
-                //    }
-                //    boxInfoList.AddRange(boxInfo2);
-                //    var sql = $"select * from BllBoxInfo where IsDel = '0' and Status = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}'; ";
-                //    var list = Db.Ado.SqlQuery<BllBoxInfo>(sql);
-                //    boxInfoList.AddRange(list);
-                //    msgStr += $"灏剧鍙蜂负{model.TailBoxNo}";
-                //}
+                    var dataBoxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.BoxNo == pinBoxNo && w.LotNo == pinBoxLotNo).ToList();
+                    if (dataBoxList.Count > 0)//宸叉湁搴撳瓨
+                    {
+                        //鍘熸墭鐩樼粦瀹氫俊鎭�
+                        var oldPalletBind = Db.Queryable<BllPalletBind>().First(w => w.Id == notBoxInfoList[0].BindNo);
+                        //鍘熷叆搴撳崟鏄庣粏
+                        var oldAsnDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.Id == oldPalletBind.ASNDetailNo);
+                        //鍘熷叆搴撳崟
+                        var oldAsnNotice = Db.Queryable<BllArrivalNotice>().First(w => w.ASNNo == oldAsnDetail.ASNNo);
+                        #region 鎵樼洏缁戝畾淇℃伅
+                        var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == oldAsnDetail.Id && m.PalletNo == model.PalletNo);
+                        var bindId = 0;
+                        if (bind == null)
+                        {
+                            bind = new BllPalletBind
+                            {
+                                ASNNo = oldAsnDetail.ASNNo,
+                                ASNDetailNo = oldAsnDetail.Id,
+                                PalletNo = model.PalletNo,
+                                PalletNo2 = "",
+                                PalletNo3 = "",
+                                Qty = 0,
+                                FullQty = pNum,
+                                Status = "2",//鍏ュ簱瀹屾垚
+                                Type = "0",
+                                LotNo = pinBoxLotNo,
+                                LotText = oldAsnDetail.LotText,
+                                SupplierLot = oldAsnDetail.SupplierLot,
+                                //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                BitPalletMark = "1",
+                                IsBale = "0",
+                                IsBelt = "0",
+                                CreateUser = userId,
+                                Demo = model.Demo,
+                            };
+                            // 鎻掑叆鎵樼洏缁戝畾琛�
+                            bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+                        }
+                        else
+                        {
+                            bindId = bind.Id;
+                            bind.Qty += pinBoxQty;
 
-                //#endregion
+                            Db.Updateable(bind).ExecuteCommand();
+                        }
+                        #endregion
 
-                //// 鏇存敼绠辨敮鍏崇郴琛�
-                //decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
-                //var isSample = "0";//鏄惁鍙栨牱
-                //var sampleQty = 0m;//鍙栨牱鏁伴噺
+                        // 鎻掑叆搴撳瓨鏄庣粏鏁版嵁
+                        var sd1 = new DataStockDetail()
+                        {
+                            LotNo = pinBoxLotNo,
+                            LotText = notBoxInfoList[0].LotText,
+                            SupplierLot = notBoxInfoList[0].SupplierLot,
+                            SkuNo = sku.SkuNo,
+                            SkuName = sku.SkuName,
+                            Standard = sku.Standard,
+                            Qty = pinBoxQty,
+                            LockQty = 0,
+                            FrozenQty = 0,
+                            InspectQty = 0,
+                            ASNNo = oldPalletBind.ASNNo,
+                            ASNDetailNo = oldPalletBind.ASNDetailNo,
+                            WareHouseNo = "",//鎵�灞炰粨搴�
+                            RoadwayNo = "",//鎵�灞炲贩閬�
+                            AreaNo = "",//鎵�灞炲尯鍩�
+                            LocatNo = "",//鍌ㄤ綅鍦板潃
+                            PalletNo = bind.PalletNo,
+                            PalletNo2 = bind.PalletNo2,
+                            PalletNo3 = bind.PalletNo3,
+                            PalletTags = "0",
+                            CompleteTime = comTime,
+                            ProductionTime = oldPalletBind.ProductionTime,
+                            ExpirationTime = oldPalletBind.ExpirationTime,
+                            Status = "0",
+                            InspectMark = oldPalletBind.InspectMark,
+                            InspectStatus = sku.IsInspect,
+                            BitPalletMark = oldPalletBind.BitPalletMark,
+                            PackagNo = oldAsnDetail.PackagNo,
+                            IsBale = oldPalletBind.IsBale,
+                            IsBelt = oldPalletBind.IsBelt,
 
+                            IsDel = "0",
+                            CreateUser = 0,
+                            CreateTime = comTime
+                        };
+                        //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                        if (oldAsnNotice.Type == "0" || oldAsnNotice.Type == "2" || oldAsnNotice.Type == "4" || oldAsnNotice.Type == "6" || oldAsnNotice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                        {
+                            sd1.OwnerNo = oldAsnNotice.CustomerNo;//璐т富缂栫爜
+                            sd1.OwnerName = oldAsnNotice.CustomerName;//璐т富鍚嶇О
+                        }
+                        else if (oldAsnNotice.Type == "1" || oldAsnNotice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
+                        {
+                            sd1.SupplierNo = oldAsnNotice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+                            sd1.SupplierName = oldAsnNotice.CustomerName;//渚涘簲鍟嗗悕绉�
+                        }
+                        //娣诲姞搴撳瓨鏄庣粏
+                        var sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
+                        foreach (var item in dataBoxList)
+                        {
+                            item.StockDetailId = sdId1;//搴撳瓨鏄庣粏id
+                            item.BindNo = bind.Id;//鎵樼洏缁戝畾id
+                        }
+                        //鏇存柊搴撳瓨绠辨敮鏄庣粏琛�
+                        Db.Updateable(dataBoxList).ExecuteCommand();
 
-                //var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
-                //foreach (var g in boxGroup)
-                //{
-                //    decimal boxFullQty = 0;//绠卞唴鎬绘暟閲�
-                //    foreach (var box in g)
-                //    {
-                //        if (box.BindNo != null && box.BindNo != 0)
-                //        {
-                //            continue;
-                //        }
-                //        //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
-                //        if (box.SkuNo != detail.SkuNo || box.LotNo != model.LotNo)
-                //        {
-                //            throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
-                //        }
+                        //鎵樼洏瑙g粦淇℃伅
+                        var palletUnbind = Db.Queryable<BllPalletUnbind>().First(w => w.IsDel == "0" && w.UpbindPalletNo == oldPalletBind.PalletNo && w.BoxNo == pinBoxNo);
+                        if (palletUnbind == null)
+                        {
+                            throw new Exception("鎷肩鐨勬墭鐩樿В缁戜俊鎭笉瀛樺湪!");
+                        }
+                        palletUnbind.BindPalletNo = model.PalletNo;//缁戝畾鎵樼洏鍙�
+                        palletUnbind.UpdateTime = comTime;
+                        palletUnbind.UpdateUser = userId;
+                        //鏇存柊鎵樼洏瑙g粦缁戝畾琛ㄤ俊鎭�
+                        Db.Updateable(palletUnbind).ExecuteCommand();
+                    }
+                    else
+                    {
+                        string sql = $@"SELECT detail.* FROM BllArrivalNoticeDetail as detail
+                                        JOIN BllArrivalNotice as notice ON detail.ASNNo=notice.ASNNo
+                                        WHERE notice.IsDel='0'
+                                        AND ( notice.Status=0 or notice.Status=1 )
+                                        AND detail.IsDel='0' 
+                                        AND detail.LotNo='{pinBoxLotNo}' 
+                                        AND detail.SkuNo='{sku.SkuNo}'
+                                        ORDER BY detail.CreateTime ";
+                        //鎵惧埌鎷肩鍐呭叾浠栨壒娆℃墍灞炲叆搴撳崟鏄庣粏
+                        var arrDetail = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault();
+                        if (arrDetail == null)
+                        {
+                            throw new Exception("鎷肩鍐呯墿鏂欐墍灞炲叆搴撳崟鏄庣粏涓嶅瓨鍦�!");
+                        }
+                        //鎵惧埌鎷肩鍐呭叾浠栨壒娆℃墍灞炲叆搴撳崟
+                        var arrNotice = Db.Queryable<BllArrivalNotice>().First(w => w.IsDel == "0" && w.ASNNo == arrDetail.ASNNo);
+                        if (arrNotice == null)
+                        {
+                            throw new Exception("鎷肩鍐呯墿鏂欐墍灞炲叆搴撳崟涓嶅瓨鍦�!");
+                        }
+                        #region 鎵樼洏缁戝畾淇℃伅
+                        var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == arrDetail.Id && m.PalletNo == model.PalletNo);
+                        var bindId = 0;
+                        if (bind == null)
+                        {
+                            bind = new BllPalletBind
+                            {
+                                ASNNo = arrDetail.ASNNo,
+                                ASNDetailNo = arrDetail.Id,
+                                PalletNo = model.PalletNo,
+                                PalletNo2 = "",
+                                PalletNo3 = "",
+                                Qty = 0,
+                                FullQty = pNum,
+                                Status = "2",//鍏ュ簱瀹屾垚
+                                Type = "0",
+                                LotNo = pinBoxLotNo,
+                                LotText = arrDetail.LotText,
+                                SupplierLot = arrDetail.SupplierLot,
+                                //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                BitPalletMark = "1",
+                                IsBale = "0",
+                                IsBelt = "0",
+                                CreateUser = userId,
+                                Demo = model.Demo,
+                            };
+                            // 鎻掑叆鎵樼洏缁戝畾琛�
+                            bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+                        }
+                        else
+                        {
+                            bindId = bind.Id;
+                        }
+                        #endregion
 
-                //        box.ASNNo = model.AsnNo;
-                //        box.ASNDetailNo = model.AsnDetailId;
-                //        box.BindNo = bindId;
-                //        box.PalletNo = model.PalletNo;
-                //        box.Status = "2";
-                //        //box.InspectMark = model.IsSample;  //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //        //box.SamplingQty = 0;    //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                //        box.CompleteTime = comTime;
-                //        box.UpdateTime = comTime;
-                //        box.UpdateUser = userId;
+                        #region 搴撳瓨鏄庣粏鍜岃川妫�淇℃伅
+                        //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
+                        BllQualityInspect quality = new BllQualityInspect();
+                        //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
+                        if (arrNotice.Type == "3")
+                        {
+                            quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == arrDetail.ASNNo && a.SkuNo == arrDetail.SkuNo && a.LotNo == arrDetail.LotNo).OrderByDescending(a => a.CreateTime).First();
+                        }
+                        else
+                        {
+                            quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == arrDetail.SkuNo && a.LotNo == arrDetail.LotNo).OrderByDescending(a => a.CreateTime).First();
+                        }
+                        var tags = "0";
+                        if (arrNotice.Type == "3" || arrNotice.Type == "4")
+                        {
+                            tags = "1";
+                        }
 
-                //        //box.Qty = box.Qty;
-                //        //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
+                        // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
+                        var sd1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.ASNDetailNo == arrDetail.Id && m.PalletNo == model.PalletNo);
+                        var sdId1 = 0;
+                        if (sd1 != null)
+                        {
+                            sdId1 = sd1.Id;
+                            // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁
+                            sd1.Qty = bind.Qty;
+                            sd1.CompleteTime = comTime;
+                            sd1.UpdateUser = userId;
+                            sd1.UpdateTime = comTime;
 
-                //        factQty += box.Qty;
-                //        boxFullQty += box.Qty;
-                //        if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
-                //        {
-                //            isSample = "1";
-                //            sampleQty += (decimal)box.SamplingQty;
-                //        }
+                            Db.Updateable(sd1).ExecuteCommand();
+                        }
+                        else
+                        {
+                            // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
+                            sd1 = new DataStockDetail()
+                            {
+                                LotNo = pinBoxLotNo,
+                                LotText = notBoxInfoList[0].LotText,
+                                SupplierLot = bind.SupplierLot,
+                                SkuNo = sku.SkuNo,
+                                SkuName = sku.SkuName,
+                                Standard = sku.Standard,
+                                Qty = bind.Qty,
+                                LockQty = 0,
+                                FrozenQty = 0,
+                                InspectQty = 0,
+                                ASNNo = arrDetail.ASNNo,
+                                ASNDetailNo = arrDetail.Id,
+                                WareHouseNo = "",//鎵�灞炰粨搴�
+                                RoadwayNo = "",//鎵�灞炲贩閬�
+                                AreaNo = "",//鎵�灞炲尯鍩�
+                                LocatNo = "",//鍌ㄤ綅鍦板潃
+                                PalletNo = bind.PalletNo,
+                                PalletNo2 = bind.PalletNo2,
+                                PalletNo3 = bind.PalletNo3,
+                                PalletTags = tags,
+                                CompleteTime = comTime,
+                                ProductionTime = bind.ProductionTime,
+                                ExpirationTime = bind.ExpirationTime,
+                                Status = "0",
+                                InspectMark = bind.InspectMark,
+                                InspectStatus = sku.IsInspect,
+                                BitPalletMark = bind.BitPalletMark,
+                                PackagNo = arrDetail.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
+                                IsBale = bind.IsBale,
+                                IsBelt = bind.IsBelt,
 
-                //        #region 搴撳瓨绠辩爜鏄庣粏
-                //        var box2 = new DataBoxInfo()
-                //        {
-                //            StockDetailId = sdId1,
-                //            BindNo = bind.Id,
-                //            BoxNo = box.BoxNo,
-                //            BoxNo2 = box.BoxNo2,
-                //            BoxNo3 = box.BoxNo3,
-                //            PalletNo = box.PalletNo,
-                //            PalletNo2 = box.PalletNo2,
-                //            PalletNo3 = box.PalletNo3,
-                //            Qty = box.Qty,
-                //            FullQty = box.FullQty,
-                //            Status = "2",//0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
-                //            LotNo = box.LotNo,
-                //            LotText = box.LotText,
-                //            SkuNo = box.SkuNo,
-                //            SkuName = box.SkuName,
-                //            Standard = sku.Standard,
-                //            ProductionTime = box.ProductionTime,
-                //            SupplierLot = box.SupplierLot,
-                //            InspectStatus = sku.IsInspect,
-                //            InspectMark = box.InspectMark,
-                //            BitBoxMark = box.BitBoxMark,
-                //            ExpirationTime = box.ExpirationTime,
+                                IsDel = "0",
+                                CreateUser = 0,
+                                CreateTime = comTime
+                            };
 
-                //            CreateUser = 0,
-                //            CreateTime = comTime
-                //        };
-                //        //娣诲姞搴撳瓨绠辩爜鏄庣粏
-                //        Db.Insertable(box2).ExecuteCommand();
-                //        #endregion
-                //    }
-                //    if (boxFullQty > bNum)
-                //    {
-                //        throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
-                //    }
-                //}
-                //Db.Updateable(boxInfoList).ExecuteCommand();
+                            //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                            if (arrNotice.Type == "0" || arrNotice.Type == "2" || arrNotice.Type == "4" || arrNotice.Type == "6" || arrNotice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                            {
+                                sd1.OwnerNo = arrNotice.CustomerNo;//璐т富缂栫爜
+                                sd1.OwnerName = arrNotice.CustomerName;//璐т富鍚嶇О
+                            }
+                            else if (arrNotice.Type == "1" || arrNotice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
+                            {
+                                sd1.SupplierNo = arrNotice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+                                sd1.SupplierName = arrNotice.CustomerName;//渚涘簲鍟嗗悕绉�
+                            }
+                            if (quality != null)
+                            {
+                                //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
+                                if (quality.IsQualified == "1") //鍚堟牸
+                                {
+                                    //澧炲姞鍚堟牸鏁伴噺
+                                    quality.PassQty += bind.Qty;
+                                    sd1.InspectStatus = "1";
+                                }
+                                else if (quality.IsQualified == "0") //涓嶅悎鏍�
+                                {
+                                    //澧炲姞涓嶅悎鏍兼暟閲�
+                                    quality.FailQty += bind.Qty;
+                                    sd1.InspectStatus = "2";
+                                }
+                                Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
+                            }
+                            //娣诲姞搴撳瓨鏄庣粏
+                            sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
+                        }
+                        #endregion
 
-                //// 鏇存柊鎵樼洏缁戝畾琛�
-                //bind.Qty += factQty;
+                        // 鏇存敼绠辨敮鍏崇郴琛�
+                        decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+                        var isSample = "0";//鏄惁鍙栨牱
+                        var sampleQty = 0m;//鍙栨牱鏁伴噺
 
-                ////if (bind.FullQty < bind.Qty && isTextTable == 0)
-                //if (bind.FullQty < bind.Qty)
-                //{
-                //    throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
-                //}
+                        //鏍囩缁勬墭
+                        var boxGroup = notBoxInfoList.GroupBy(m => m.BoxNo).ToList();
+                        foreach (var g in boxGroup)
+                        {
+                            decimal boxFullQty = 0;//绠卞唴鎬绘暟閲�
+                            foreach (var box in g)
+                            {
+                                if (box.BindNo != null && box.BindNo != 0)
+                                {
+                                    continue;
+                                }
+                                //绠卞唴鐗╂枡鎵规涓庡崟鎹槑缁嗕笉绗﹀悎
+                                if (box.SkuNo != arrDetail.SkuNo || box.LotNo != arrDetail.LotNo)
+                                {
+                                    throw new Exception($"-1:{box.BoxNo}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
+                                }
 
-                //if (bind.FullQty == bind.Qty)
-                //{
-                //    bind.BitPalletMark = "0";
-                //    sd1.BitPalletMark = "0";
-                //}
-                ////if (bind.Qty > pNum && isTextTable == 0)
-                //if (bind.Qty > pNum)
-                //{
-                //    throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
-                //}
+                                box.ASNNo = arrDetail.ASNNo;
+                                box.ASNDetailNo = arrDetail.Id;
+                                box.BindNo = bindId;
+                                box.PalletNo = model.PalletNo;
+                                box.Status = "2";
+                                //box.InspectMark = model.IsSample;  //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                //box.SamplingQty = 0;    //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                                box.CompleteTime = comTime;
+                                box.UpdateTime = comTime;
+                                box.UpdateUser = userId;
 
-                //if (isSample == "1")
-                //{
-                //    bind.InspectMark = "1";
-                //    bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
-                //}
-                //Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
+                                //box.Qty = box.Qty;
+                                //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
 
-                //#region 鍏ュ簱鍗曞強鏄庣粏
-                //decimal addQty = factQty;
+                                factQty += box.Qty;
+                                boxFullQty += box.Qty;
+                                if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
+                                {
+                                    isSample = "1";
+                                    sampleQty += (decimal)box.SamplingQty;
+                                }
 
-                //detail.FactQty += addQty;//宸茬粍鏁伴噺
-                //detail.CompleteQty += addQty;//瀹屾垚鏁伴噺
-                //if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍�
-                //{
-                //    detail.IsSampling = "1";
-                //}
-                //detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
-                //if (detail.CompleteQty >= detail.Qty)
-                //{
-                //    detail.Status = "2";
-                //    detail.CompleteTime = comTime;
-                //}
-                //detail.UpdateUser = userId;
-                //detail.UpdateTime = comTime;
-                ////鏇存柊鍏ュ簱鍗曟槑缁�
-                //Db.Updateable(detail).ExecuteCommand();
+                                #region 搴撳瓨绠辩爜鏄庣粏
+                                var box2 = new DataBoxInfo()
+                                {
+                                    StockDetailId = sdId1,
+                                    BindNo = bind.Id,
+                                    BoxNo = box.BoxNo,
+                                    BoxNo2 = box.BoxNo2,
+                                    BoxNo3 = box.BoxNo3,
+                                    PalletNo = box.PalletNo,
+                                    PalletNo2 = box.PalletNo2,
+                                    PalletNo3 = box.PalletNo3,
+                                    Qty = box.Qty,
+                                    FullQty = box.FullQty,
+                                    Status = "2",//0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
+                                    LotNo = box.LotNo,
+                                    LotText = box.LotText,
+                                    SkuNo = box.SkuNo,
+                                    SkuName = box.SkuName,
+                                    Standard = sku.Standard,
+                                    ProductionTime = box.ProductionTime,
+                                    SupplierLot = box.SupplierLot,
+                                    InspectStatus = sku.IsInspect,
+                                    InspectMark = box.InspectMark,
+                                    BitBoxMark = box.BitBoxMark,
+                                    ExpirationTime = box.ExpirationTime,
 
-                //notice.UpdateUser = userId;
-                //notice.UpdateTime = comTime;
-                //if (notice.Status == "0")
-                //{
-                //    notice.Status = "1";
-                //}
-                //var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>()
-                //                .Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2");
-                //if (asnDetailNum == 0)
-                //{
-                //    notice.Status = "2";
-                //    notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
-                //}
-                ////鏇存柊鍏ュ簱鍗�
-                //Db.Updateable(notice).ExecuteCommand();
-                //#endregion
+                                    CreateUser = 0,
+                                    CreateTime = comTime
+                                };
+                                //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                                Db.Insertable(box2).ExecuteCommand();
+                                #endregion
+                            }
+                            if (boxFullQty > bNum)
+                            {
+                                throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+                            }
+                        }
+                        //鏇存敼绠辨敮鍏崇郴琛ㄤ俊鎭�
+                        Db.Updateable(boxInfoList).ExecuteCommand();
 
-                //#region 搴撳瓨鏄庣粏
-                //sd1.Qty = bind.Qty;
-                ////鏇存敼搴撳瓨鏄庣粏鏁伴噺
-                //Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
-                //#endregion
+                        // 鏇存柊鎵樼洏缁戝畾琛�
+                        bind.Qty += factQty;
 
-                //#region 搴撳瓨
-                //var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo);
-                //if (dataStock != null)
-                //{
-                //    dataStock.Qty += factQty;
+                        if (bind.FullQty < bind.Qty)
+                        {
+                            throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+                        }
 
-                //    if (bind.InspectMark == "1")
-                //    {
-                //        dataStock.IsSampling = bind.InspectMark;
-                //    }
-                //    Db.Updateable(dataStock).ExecuteCommand();
-                //}
-                //else
-                //{
-                //    var stock = new DataStock()
-                //    {
-                //        SkuNo = sku.SkuNo,
-                //        SkuName = sku.SkuName,
-                //        Standard = sku.Standard,
-                //        LotNo = bind.LotNo,
-                //        LotText = bind.LotText,
-                //        Qty = bind.Qty,
-                //        LockQty = 0,
-                //        FrozenQty = 0,
-                //        IsSampling = bind.InspectMark,
-                //        IsDel = "0",
-                //        CreateUser = userId,
-                //        CreateTime = comTime
-                //    };
-                //    //缁存姢搴撳瓨璐т富淇℃伅
-                //    if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
-                //    {
-                //        stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
-                //        stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О
-                //    }
-                //    Db.Insertable(stock).ExecuteCommand();
-                //}
-                //#endregion
+                        if (bind.FullQty == bind.Qty)
+                        {
+                            bind.BitPalletMark = "0";
+                            sd1.BitPalletMark = "0";
+                        }
+                        if (bind.Qty > pNum)
+                        {
+                            throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+                        }
 
-                //#region 璐ㄦ璇烽獙
-                //if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
-                //{
-                //    var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
-                //    if (qualityRequest == null)
-                //    {
-                //        string qcNo = new Common().GetMaxNo("QC");
-                //        qualityRequest = new BllQualityInspectionRequest();
-                //        qualityRequest.QcNo = qcNo;
-                //        qualityRequest.Status = "0";
-                //        qualityRequest.SkuNo = sku.SkuNo;
-                //        qualityRequest.SkuName = sku.SkuName;
-                //        qualityRequest.LotNo = bind.LotNo;
-                //        qualityRequest.SupplierLot = bind.SupplierLot;
-                //        qualityRequest.Qty = detail.Qty;
-                //        qualityRequest.SamplingQty = 0;
-                //        qualityRequest.ASNNo = detail.ASNNo;
-                //        qualityRequest.CreateUser = userId;
-                //        qualityRequest.CreateTime = comTime;
-                //        //娣诲姞璐ㄦ璇烽獙鍗�
-                //        Db.Insertable(qualityRequest).ExecuteCommand();
-                //    }
-                //}
-                //#endregion
+                        if (isSample == "1")
+                        {
+                            bind.InspectMark = "1";
+                            bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
+                        }
+                        Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
 
+                        #region 鍏ュ簱鍗曞強鏄庣粏
+                        arrDetail.FactQty += factQty;//宸茬粍鏁伴噺
+                        arrDetail.CompleteQty += factQty;//瀹屾垚鏁伴噺
+                        if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍�
+                        {
+                            arrDetail.IsSampling = "1";
+                        }
+                        arrDetail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
+                        if (arrDetail.CompleteQty >= arrDetail.Qty)
+                        {
+                            arrDetail.Status = "2";
+                            arrDetail.CompleteTime = comTime;
+                        }
+                        arrDetail.UpdateUser = userId;
+                        arrDetail.UpdateTime = comTime;
+                        //鏇存柊鍏ュ簱鍗曟槑缁�
+                        Db.Updateable(arrDetail).ExecuteCommand();
+
+                        arrNotice.UpdateUser = userId;
+                        arrNotice.UpdateTime = comTime;
+                        if (arrNotice.Status == "0")
+                        {
+                            arrNotice.Status = "1";
+                        }
+                        var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>().Count(m => m.IsDel == "0" && m.ASNNo == arrDetail.ASNNo && m.Status != "2");
+                        if (asnDetailNum == 0)
+                        {
+                            arrNotice.Status = "2";//鎵ц瀹屾垚
+                            arrNotice.CompleteTime = comTime;//瀹屾垚鏃堕棿
+                        }
+                        //鏇存柊鍏ュ簱鍗�
+                        Db.Updateable(arrNotice).ExecuteCommand();
+                        #endregion
+
+                        #region 搴撳瓨鏄庣粏
+                        sd1.Qty = bind.Qty;
+                        //鏇存敼搴撳瓨鏄庣粏鏁伴噺
+                        Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
+                        #endregion
+
+                        #region 搴撳瓨
+                        var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo);
+                        if (dataStock != null)
+                        {
+                            dataStock.Qty += factQty;
+
+                            if (bind.InspectMark == "1")
+                            {
+                                dataStock.IsSampling = bind.InspectMark;
+                            }
+                            Db.Updateable(dataStock).ExecuteCommand();
+                        }
+                        else
+                        {
+                            var stock = new DataStock()
+                            {
+                                SkuNo = sku.SkuNo,
+                                SkuName = sku.SkuName,
+                                Standard = sku.Standard,
+                                LotNo = bind.LotNo,
+                                LotText = bind.LotText,
+                                Qty = bind.Qty,
+                                LockQty = 0,
+                                FrozenQty = 0,
+                                IsSampling = bind.InspectMark,
+                                IsDel = "0",
+                                CreateUser = userId,
+                                CreateTime = comTime
+                            };
+                            //缁存姢搴撳瓨璐т富淇℃伅
+                            if (arrNotice.Type == "0" || arrNotice.Type == "2" || arrNotice.Type == "4" || arrNotice.Type == "6" || arrNotice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                            {
+                                stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                                stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                            }
+                            Db.Insertable(stock).ExecuteCommand();
+                        }
+                        #endregion
+
+                        #region 璐ㄦ璇烽獙
+                        if ((arrNotice.Type == "1" || arrNotice.Type == "4" || arrNotice.Type == "5") && sku.IsInspect != "1")
+                        {
+                            var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
+                            if (qualityRequest == null)
+                            {
+                                string qcNo = new Common().GetMaxNo("QC");
+                                qualityRequest = new BllQualityInspectionRequest();
+                                qualityRequest.QcNo = qcNo;
+                                qualityRequest.Status = "0";
+                                qualityRequest.SkuNo = sku.SkuNo;
+                                qualityRequest.SkuName = sku.SkuName;
+                                qualityRequest.LotNo = bind.LotNo;
+                                qualityRequest.SupplierLot = bind.SupplierLot;
+                                qualityRequest.Qty = arrDetail.Qty;
+                                qualityRequest.SamplingQty = 0;
+                                qualityRequest.ASNNo = arrDetail.ASNNo;
+                                qualityRequest.CreateUser = userId;
+                                qualityRequest.CreateTime = comTime;
+                                //娣诲姞璐ㄦ璇烽獙鍗�
+                                Db.Insertable(qualityRequest).ExecuteCommand();
+                            }
+                        }
+                        #endregion
+                    }
+                }
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
                 var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
                 //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
                 sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','缁勭洏','0',getDate(),{userId},NULL,NULL);";
                 Db.Ado.ExecuteCommand(sqlStr);
-                //new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
+                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}銆亄msgStr}鐨勭粍鐩樹俊鎭�", userId);
 
+                //鎻愪氦浜嬪姟
                 Db.CommitTran();
             }
             catch (Exception e)
             {
+                //鍥炴粴浜嬪姟
                 Db.RollbackTran();
                 throw new Exception(e.Message);
             }
         }
 
-
         //JC26缁戝畾鎵樼洏 涓嶈创鏍囩墿鏂�
         public void BindPalletNoPasteCode(PdaPalletBindVm model, int userId)
         {
-            
-                #region 鍒ゆ柇
-                
-                //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴�
-                var TypeLot = "5, 6";
 
-                if (string.IsNullOrEmpty(model.AsnNo))
-                {
-                    throw new Exception("鍗曟嵁鍙蜂笉鍙负绌�!");
-                }
-                if (model.AsnDetailId == null || model.AsnDetailId == 0)
-                {
-                    throw new Exception("鐗╂枡涓嶅彲涓虹┖!");
-                }
-                if (string.IsNullOrEmpty(model.PalletNo))
-                {
-                    throw new Exception("鎵樼洏鍙蜂笉鍙负绌�!");
-                }
-                if (model.SkuQty < 0)
-                {
-                    throw new Exception("鐗╂枡鏁伴噺涓嶈兘灏忎簬0!");
-                }
-                //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
-                var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
-                if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2")
-                {
-                    throw new Exception("璇ュ崟鎹凡鍏冲崟!");
-                }
+            #region 鍒ゆ柇
 
-                if (string.IsNullOrEmpty(model.LotNo))
+            //0锛氭垚鍝佸叆搴� 1锛氶噰璐叆搴� 3锛氶��璐у叆搴� 4锛氳溅闂翠綑鏂欏叆搴� 5锛氬叾瀹冨叆搴� 6锛氫唬鍌ㄥ叆搴�
+            var TypeLot = "5, 6";
+
+            if (string.IsNullOrEmpty(model.AsnNo))
+            {
+                throw new Exception("鍗曟嵁鍙蜂笉鍙负绌�!");
+            }
+            if (model.AsnDetailId == null || model.AsnDetailId == 0)
+            {
+                throw new Exception("鐗╂枡涓嶅彲涓虹┖!");
+            }
+            if (string.IsNullOrEmpty(model.PalletNo))
+            {
+                throw new Exception("鎵樼洏鍙蜂笉鍙负绌�!");
+            }
+            if (model.SkuQty < 0)
+            {
+                throw new Exception("鐗╂枡鏁伴噺涓嶈兘灏忎簬0!");
+            }
+            //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
+            var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
+            if (notice.Status != "0" && notice.Status != "1" && notice.Status != "2")
+            {
+                throw new Exception("璇ュ崟鎹凡鍏冲崟!");
+            }
+
+            if (string.IsNullOrEmpty(model.LotNo))
+            {
+                throw new Exception("鐗╂枡鎵规涓嶄负绌�!");
+            }
+            else
+            {
+                //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
+                int indexOfDash = model.LotNo.IndexOf("-");
+                if (indexOfDash != -1)
                 {
-                    throw new Exception("鐗╂枡鎵规涓嶄负绌�!");
+                    model.LotNo = model.LotNo.Substring(indexOfDash + 1);
                 }
                 else
                 {
-                    //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
-                    int indexOfDash = model.LotNo.IndexOf("-");
-                    if (indexOfDash != -1)
+                    if (!TypeLot.Contains(notice.Type))
                     {
-                        model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+                        throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
                     }
-                    else
-                    {
-                        if (!TypeLot.Contains(notice.Type))
-                        {
-                            throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
-                        }
 
-                        model.LotNo = "";
+                    model.LotNo = "";
+                }
+            }
+
+            //int isTextTable = model.TableType;
+            #endregion
+
+            var comTime = DateTime.Now;
+
+            //鎵樼洏鏄惁瀛樺湪
+            var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
+            if (pallet == null)
+            {
+                throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
+            }
+            // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
+            var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
+            if (detail == null)
+            {
+                throw new Exception("褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
+            }
+            //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶�
+            var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
+            if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
+            {
+                throw new Exception("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒");
+            }
+            if (stockDetail != null && (stockDetail.SkuNo != detail.SkuNo || stockDetail.LotNo != model.LotNo))
+            {
+                throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�");
+            }
+
+            #region 鍖呰
+            var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
+            var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
+
+            var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 
+            var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 
+
+            if (pack == null)
+            {
+                throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
+            }
+            if (pack.L5Num.HasValue)
+            {
+                pNum = (int)pack.L5Num;
+                bNum = (int)pack.L4Num;
+            }
+            else if (pack.L4Num.HasValue)
+            {
+                pNum = (int)pack.L4Num;
+                bNum = (int)pack.L3Num;
+            }
+            else if (pack.L3Num.HasValue)
+            {
+                pNum = (int)pack.L3Num;
+                bNum = (int)pack.L2Num;
+            }
+            else if (pack.L2Num.HasValue)
+            {
+                pNum = (int)pack.L2Num;
+                bNum = (int)pack.L1Num;
+            }
+            else if (pack.L1Num.HasValue)
+            {
+                pNum = (int)pack.L1Num;
+                bNum = (int)pack.L1Num;
+            }
+            if (pNum == 0 || bNum == 0)
+            {
+                throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
+            }
+
+            #endregion
+
+            #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
+            var palletBind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo && m.PalletNo == model.PalletNo && m.ASNDetailNo != model.AsnDetailId);
+            if (palletBind != null)
+            {
+                var box = Db.Queryable<BllBoxInfo>().First(m => m.IsDel == "0" && m.BindNo == palletBind.Id && m.BitBoxMark == "0");
+                if (box != null && (box.SkuNo != detail.SkuNo || !detail.LotNo.Contains(box.LotNo)))
+                {
+                    var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
+                    if (funSetting == null || funSetting.IsEnable == "OFF")
+                    {
+                        throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
                     }
                 }
+            }
+            #endregion
+            //liudl  && m.Status != "2"  缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂�
+            var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
+            var bindId = 0;
+            if (bind == null)
+            {
+                bind = new BllPalletBind
+                {
+                    ASNNo = model.AsnNo,
+                    ASNDetailNo = (int)model.AsnDetailId,
+                    PalletNo = model.PalletNo,
 
-                //int isTextTable = model.TableType;
-                #endregion
+                    Qty = model.SkuQty,
+                    FullQty = pNum,
+                    Status = "2",//鍏ュ簱瀹屾垚
+                    Type = "0",
+                    LotNo = model.LotNo,
+                    LotText = detail.LotText,
+                    SupplierLot = detail.SupplierLot,
+                    //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                    //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
+                    BitPalletMark = "1",
+                    IsBale = "0",
+                    IsBelt = "0",
+                    CreateUser = userId,
+                    Demo = model.Demo,
 
-                var comTime = DateTime.Now;
+                };
+                // 鎻掑叆鎵樼洏缁戝畾琛�
+                bindId = Db.Insertable(bind).ExecuteReturnIdentity();
+            }
+            else
+            {
+                bindId = bind.Id;
+                bind.Qty += model.SkuQty;
+            }
+            if (bind.Qty < 0)
+            {
+                throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0");
+            }
 
-                //鎵樼洏鏄惁瀛樺湪
-                var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
-                if (pallet == null)
-                {
-                    throw new Exception("鏈煡璇㈠埌鎵樼洏淇℃伅锛岃鏍稿疄锛�");
-                }
-                // 楠岃瘉鍏ュ簱鍗曟槑缁嗘槸鍚﹀瓨鍦�
-                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
-                if (detail == null)
-                {
-                    throw new Exception("褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
-                }
-                //鍒ゆ柇鎵樼洏鏄惁鍦ㄥ簱澶�
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
-                if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
-                {
-                    throw new Exception("璇ユ墭鐩樺凡鏈夊偍浣嶄俊鎭紝璇锋牳瀹烇紒");
-                }
-                if (stockDetail != null && (stockDetail.SkuNo != detail.SkuNo || stockDetail.LotNo != model.LotNo))
-                {
-                    throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡鎵规淇℃伅锛岃鏍稿疄锛�");
-                }
+            #region 搴撳瓨鏄庣粏
+            //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
+            BllQualityInspect quality = new BllQualityInspect();
+            //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
+            if (notice.Type == "3")
+            {
+                quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
+            }
+            else
+            {
+                quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
+            }
+            var tags = "0";
+            if (notice.Type == "3" || notice.Type == "4")
+            {
+                tags = "1";
+            }
 
-                #region 鍖呰
-                var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == detail.SkuNo);
-                var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
-
-                var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 
-                var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 
-
-                if (pack == null)
-                {
-                    throw new Exception("鑾峰彇鐗╂枡鍖呰澶辫触锛岃鏍稿疄!");
-                }
-                if (pack.L5Num.HasValue)
-                {
-                    pNum = (int)pack.L5Num;
-                    bNum = (int)pack.L4Num;
-                }
-                else if (pack.L4Num.HasValue)
-                {
-                    pNum = (int)pack.L4Num;
-                    bNum = (int)pack.L3Num;
-                }
-                else if (pack.L3Num.HasValue)
-                {
-                    pNum = (int)pack.L3Num;
-                    bNum = (int)pack.L2Num;
-                }
-                else if (pack.L2Num.HasValue)
-                {
-                    pNum = (int)pack.L2Num;
-                    bNum = (int)pack.L1Num;
-                }
-                else if (pack.L1Num.HasValue)
-                {
-                    pNum = (int)pack.L1Num;
-                    bNum = (int)pack.L1Num;
-                }
-                if (pNum == 0 || bNum == 0)
-                {
-                    throw new Exception($"缁戝畾澶辫触锛寋detail.SkuNo}鐗╁搧鍖呰鏈壘鍒帮紒");
-                }
-                
-                #endregion
-
-                #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
-                var palletBind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo && m.PalletNo == model.PalletNo && m.ASNDetailNo != model.AsnDetailId);
-                if (palletBind != null)
-                {
-                    var box = Db.Queryable<BllBoxInfo>().First(m => m.IsDel == "0" && m.BindNo == palletBind.Id && m.BitBoxMark == "0");
-                    if (box != null && (box.SkuNo != detail.SkuNo || !detail.LotNo.Contains(box.LotNo)))
-                    {
-                        var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
-                        if (funSetting == null || funSetting.IsEnable == "OFF")
-                        {
-                            throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
-                        }
-                    }
-                }
-                #endregion
-                //liudl  && m.Status != "2"  缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂�
-                var bind = Db.Queryable<BllPalletBind>().First(m => m.IsDel == "0" && m.ASNDetailNo == model.AsnDetailId && m.PalletNo == model.PalletNo);
-                var bindId = 0;
-                if (bind == null)
-                {
-                    bind = new BllPalletBind
-                    {
-                        ASNNo = model.AsnNo,
-                        ASNDetailNo = (int)model.AsnDetailId,
-                        PalletNo = model.PalletNo,
-                        
-                        Qty = model.SkuQty,
-                        FullQty = pNum,
-                        Status = "2",//鍏ュ簱瀹屾垚
-                        Type = "0",
-                        LotNo = model.LotNo,
-                        LotText = detail.LotText,
-                        SupplierLot = detail.SupplierLot,
-                        //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                        //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                        BitPalletMark = "1",
-                        IsBale = "0",
-                        IsBelt = "0",
-                        CreateUser = userId,
-                        Demo = model.Demo,
-
-                    };
-                    // 鎻掑叆鎵樼洏缁戝畾琛�
-                    bindId = Db.Insertable(bind).ExecuteReturnIdentity();
-                }
-                else
-                {
-                    bindId = bind.Id;
-                    bind.Qty += model.SkuQty;
-                }
-                if (bind.Qty < 0)
-                {
-                    throw new Exception("缁勭洏鏁伴噺涓嶈兘灏忎簬0");
-                }
-
-                #region 搴撳瓨鏄庣粏
-                //鑾峰彇璇ユ壒娆℃渶缁堣川妫�缁撴灉
-                BllQualityInspect quality = new BllQualityInspect();
-                //鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
-                if (notice.Type == "3")
-                {
-                    quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.ASNNo == detail.ASNNo && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
-                }
-                else
-                {
-                    quality = Db.Queryable<BllQualityInspect>().Where(a => a.IsDel == "0" && a.SkuNo == detail.SkuNo && a.LotNo == detail.LotNo).OrderByDescending(a => a.CreateTime).First();
-                }
-                var tags = "0";
-                if (notice.Type == "3" || notice.Type == "4")
-                {
-                    tags = "1";
-                }
-
-                // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
-                var sd1 = Db.Queryable<DataStockDetail>()
-                    .First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo && m.LotNo == bind.LotNo);
-                var sdId1 = 0;
-                if (sd1 != null)
-                {
-                    sdId1 = sd1.Id;
-                    // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁
-                    sd1.Qty = bind.Qty;
-                    sd1.CompleteTime = comTime;
-                    sd1.UpdateUser = userId;
-                    sd1.UpdateTime = comTime;
-
-                    Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
-                }
-                else
-                {
-                    // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
-                    sd1 = new DataStockDetail()
-                    {
-                        LotNo = bind.LotNo,
-                        LotText = bind.LotText,
-                        SupplierLot = bind.SupplierLot,
-                        SkuNo = sku.SkuNo,
-                        SkuName = sku.SkuName,
-                        Standard = sku.Standard,
-                        Qty = bind.Qty,
-                        LockQty = 0,
-                        FrozenQty = 0,
-                        InspectQty = 0,
-                        ASNNo = bind.ASNNo,
-                        ASNDetailNo = bind.ASNDetailNo,
-                        WareHouseNo = "",//鎵�灞炰粨搴�
-                        RoadwayNo = "",//鎵�灞炲贩閬�
-                        AreaNo = "",//鎵�灞炲尯鍩�
-                        LocatNo = "",//鍌ㄤ綅鍦板潃
-                        PalletNo = bind.PalletNo,
-                        PalletNo2 = bind.PalletNo2,
-                        PalletNo3 = bind.PalletNo3,
-                        PalletTags = tags,
-                        CompleteTime = comTime,
-                        ProductionTime = bind.ProductionTime,
-                        ExpirationTime = bind.ExpirationTime,
-                        Status = "0",
-                        InspectMark = bind.InspectMark,
-                        InspectStatus = sku.IsInspect,
-                        BitPalletMark = bind.BitPalletMark,
-                        PackagNo = detail.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
-                        IsBale = bind.IsBale,
-                        IsBelt = bind.IsBelt,
-
-                        IsDel = "0",
-                        CreateUser = 0,
-                        CreateTime = comTime
-                    };
-
-                    //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
-                    if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
-                    {
-                        sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
-                        sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О
-                    }
-                    else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
-                    {
-                        sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
-                        sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
-                    }
-                    if (quality != null)
-                    {
-                        //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
-                        if (quality.IsQualified == "1") //鍚堟牸
-                        {
-                            //澧炲姞鍚堟牸鏁伴噺
-                            quality.PassQty += bind.Qty;
-                            sd1.InspectStatus = "1";
-                        }
-                        else if (quality.IsQualified == "0") //涓嶅悎鏍�
-                        {
-                            //澧炲姞涓嶅悎鏍兼暟閲�
-                            quality.FailQty += bind.Qty;
-                            sd1.InspectStatus = "2";
-                        }
-                        Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
-                    }
-                    //娣诲姞搴撳瓨鏄庣粏
-                    sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
-                }
-                #endregion
-
-                
-
-                // 鏇存敼绠辨敮鍏崇郴琛�
-                
-                var isSample = "0";//鏄惁鍙栨牱
-                var sampleQty = 0m;//鍙栨牱鏁伴噺
-
-                
-                //if (bind.FullQty < bind.Qty && isTextTable == 0)
-                if (bind.FullQty < bind.Qty)
-                {
-                    throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
-                }
-
-                if (bind.FullQty == bind.Qty)
-                {
-                    bind.BitPalletMark = "0";
-                    sd1.BitPalletMark = "0";
-                }
-                //if (bind.Qty > pNum && isTextTable == 0)
-                if (bind.Qty > pNum)
-                {
-                    throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
-                }
-
-                if (isSample == "1")
-                {
-                    bind.InspectMark = "1";
-                    bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
-                }
-                Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
-
-                #region 鍏ュ簱鍗曞強鏄庣粏
-                decimal addQty = model.SkuQty;
-                
-                detail.FactQty += addQty;//宸茬粍鏁伴噺
-                detail.CompleteQty += addQty;//瀹屾垚鏁伴噺
-                if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍�
-                {
-                    detail.IsSampling = "1";
-                }
-                detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
-                if (detail.CompleteQty >= detail.Qty)
-                {
-                    detail.Status = "2";
-                    detail.CompleteTime = comTime;
-                }
-                detail.UpdateUser = userId;
-                detail.UpdateTime = comTime;
-                //鏇存柊鍏ュ簱鍗曟槑缁�
-                Db.Updateable(detail).ExecuteCommand();
-
-                notice.UpdateUser = userId;
-                notice.UpdateTime = comTime;
-                if (notice.Status == "0")
-                {
-                    notice.Status = "1";
-                }
-                var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>()
-                                .Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2");
-                if (asnDetailNum == 0)
-                {
-                    notice.Status = "2";
-                    notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
-                }
-                //鏇存柊鍏ュ簱鍗�
-                Db.Updateable(notice).ExecuteCommand();
-                #endregion
-
-                #region 搴撳瓨鏄庣粏
+            // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
+            var sd1 = Db.Queryable<DataStockDetail>()
+                .First(m => m.IsDel == "0" && m.ASNDetailNo == bind.ASNDetailNo && m.PalletNo == model.PalletNo && m.LotNo == bind.LotNo);
+            var sdId1 = 0;
+            if (sd1 != null)
+            {
+                sdId1 = sd1.Id;
+                // 搴撳瓨宸插瓨鍦� 鏇存柊鏁版嵁
                 sd1.Qty = bind.Qty;
-                //鏇存敼搴撳瓨鏄庣粏鏁伴噺
-                Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
-                #endregion
+                sd1.CompleteTime = comTime;
+                sd1.UpdateUser = userId;
+                sd1.UpdateTime = comTime;
 
-                #region 搴撳瓨
-                var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo);
-                if (dataStock != null)
+                Db.Updateable(sd1).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
+            }
+            else
+            {
+                // 搴撳瓨涓嶅瓨鍦� 鎻掑叆鏁版嵁
+                sd1 = new DataStockDetail()
                 {
-                    dataStock.Qty += model.SkuQty;
-                    
+                    LotNo = bind.LotNo,
+                    LotText = bind.LotText,
+                    SupplierLot = bind.SupplierLot,
+                    SkuNo = sku.SkuNo,
+                    SkuName = sku.SkuName,
+                    Standard = sku.Standard,
+                    Qty = bind.Qty,
+                    LockQty = 0,
+                    FrozenQty = 0,
+                    InspectQty = 0,
+                    ASNNo = bind.ASNNo,
+                    ASNDetailNo = bind.ASNDetailNo,
+                    WareHouseNo = "",//鎵�灞炰粨搴�
+                    RoadwayNo = "",//鎵�灞炲贩閬�
+                    AreaNo = "",//鎵�灞炲尯鍩�
+                    LocatNo = "",//鍌ㄤ綅鍦板潃
+                    PalletNo = bind.PalletNo,
+                    PalletNo2 = bind.PalletNo2,
+                    PalletNo3 = bind.PalletNo3,
+                    PalletTags = tags,
+                    CompleteTime = comTime,
+                    ProductionTime = bind.ProductionTime,
+                    ExpirationTime = bind.ExpirationTime,
+                    Status = "0",
+                    InspectMark = bind.InspectMark,
+                    InspectStatus = sku.IsInspect,
+                    BitPalletMark = bind.BitPalletMark,
+                    PackagNo = detail.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
+                    IsBale = bind.IsBale,
+                    IsBelt = bind.IsBelt,
 
-                    if (bind.InspectMark == "1")
-                    {
-                        dataStock.IsSampling = bind.InspectMark;
-                    }
-                    Db.Updateable(dataStock).ExecuteCommand();
-                }
-                else
+                    IsDel = "0",
+                    CreateUser = 0,
+                    CreateTime = comTime
+                };
+
+                //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
                 {
-                    var stock = new DataStock()
-                    {
-                        SkuNo = sku.SkuNo,
-                        SkuName = sku.SkuName,
-                        Standard = sku.Standard,
-                        LotNo = bind.LotNo,
-                        LotText = bind.LotText,
-                        Qty = bind.Qty,
-                        LockQty = 0,
-                        FrozenQty = 0,
-                        IsSampling = bind.InspectMark,
-                        IsDel = "0",
-                        CreateUser = userId,
-                        CreateTime = comTime
-                    };
-                    //缁存姢搴撳瓨璐т富淇℃伅
-                    if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
-                    {
-                        stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
-                        stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О
-                    }
-                    Db.Insertable(stock).ExecuteCommand();
+                    sd1.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                    sd1.OwnerName = notice.CustomerName;//璐т富鍚嶇О
                 }
-                #endregion
-
-                #region 璐ㄦ璇烽獙
-                if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
+                else if (notice.Type == "1" || notice.Type == "5")//1:閲囪喘鍏ュ簱,2:鍏跺畠鍏ュ簱
                 {
-                    var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
-                    if (qualityRequest == null)
-                    {
-                        string qcNo = new Common().GetMaxNo("QC");
-                        qualityRequest = new BllQualityInspectionRequest();
-                        qualityRequest.QcNo = qcNo;
-                        qualityRequest.Status = "0";
-                        qualityRequest.SkuNo = sku.SkuNo;
-                        qualityRequest.SkuName = sku.SkuName;
-                        qualityRequest.LotNo = bind.LotNo;
-                        qualityRequest.SupplierLot = bind.SupplierLot;
-                        qualityRequest.Qty = detail.Qty;
-                        qualityRequest.SamplingQty = 0;
-                        qualityRequest.ASNNo = detail.ASNNo;
-                        qualityRequest.CreateUser = userId;
-                        qualityRequest.CreateTime = comTime;
-                        //娣诲姞璐ㄦ璇烽獙鍗�
-                        Db.Insertable(qualityRequest).ExecuteCommand();
-                    }
+                    sd1.SupplierNo = notice.CustomerNo;//渚涘簲鍟嗙紪鐮�
+                    sd1.SupplierName = notice.CustomerName;//渚涘簲鍟嗗悕绉�
                 }
-                #endregion
+                if (quality != null)
+                {
+                    //淇敼鍚堟牸涓嶅悎鏍兼暟閲�
+                    if (quality.IsQualified == "1") //鍚堟牸
+                    {
+                        //澧炲姞鍚堟牸鏁伴噺
+                        quality.PassQty += bind.Qty;
+                        sd1.InspectStatus = "1";
+                    }
+                    else if (quality.IsQualified == "0") //涓嶅悎鏍�
+                    {
+                        //澧炲姞涓嶅悎鏍兼暟閲�
+                        quality.FailQty += bind.Qty;
+                        sd1.InspectStatus = "2";
+                    }
+                    Db.Updateable(quality).ExecuteCommand(); //淇敼璐ㄦ淇℃伅
+                }
+                //娣诲姞搴撳瓨鏄庣粏
+                sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
+            }
+            #endregion
 
-                // 鏇存敼鎵樼洏浣跨敤鐘舵��
-                var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
-                //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
-                sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','缁勭洏','0',getDate(),{userId},NULL,NULL);";
-                Db.Ado.ExecuteCommand(sqlStr);
-                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}鐨勭粍鐩樹俊鎭�", userId);
 
-                
-           
+
+            // 鏇存敼绠辨敮鍏崇郴琛�
+
+            var isSample = "0";//鏄惁鍙栨牱
+            var sampleQty = 0m;//鍙栨牱鏁伴噺
+
+
+            //if (bind.FullQty < bind.Qty && isTextTable == 0)
+            if (bind.FullQty < bind.Qty)
+            {
+                throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+            }
+
+            if (bind.FullQty == bind.Qty)
+            {
+                bind.BitPalletMark = "0";
+                sd1.BitPalletMark = "0";
+            }
+            //if (bind.Qty > pNum && isTextTable == 0)
+            if (bind.Qty > pNum)
+            {
+                throw new Exception($"缁戝畾澶辫触锛寋bind.PalletNo}鎵樼洏缁戝畾鏁伴噺澶т簬璇ョ墿鍝佹墭鐩樺寘瑁呮暟閲忥紒");
+            }
+
+            if (isSample == "1")
+            {
+                bind.InspectMark = "1";
+                bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
+            }
+            Db.Updateable(bind).Where(m => m.Id == bindId).ExecuteCommand();
+
+            #region 鍏ュ簱鍗曞強鏄庣粏
+            decimal addQty = model.SkuQty;
+
+            detail.FactQty += addQty;//宸茬粍鏁伴噺
+            detail.CompleteQty += addQty;//瀹屾垚鏁伴噺
+            if (isSample == "1") //鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�兼敼涓哄垽鏂槸鍚﹀彇鏍�
+            {
+                detail.IsSampling = "1";
+            }
+            detail.Status = "1";//0锛氱瓑寰呮墽琛� 1锛氭鍦ㄦ墽琛� 2锛氭墽琛屽畬鎴�
+            if (detail.CompleteQty >= detail.Qty)
+            {
+                detail.Status = "2";
+                detail.CompleteTime = comTime;
+            }
+            detail.UpdateUser = userId;
+            detail.UpdateTime = comTime;
+            //鏇存柊鍏ュ簱鍗曟槑缁�
+            Db.Updateable(detail).ExecuteCommand();
+
+            notice.UpdateUser = userId;
+            notice.UpdateTime = comTime;
+            if (notice.Status == "0")
+            {
+                notice.Status = "1";
+            }
+            var asnDetailNum = Db.Queryable<BllArrivalNoticeDetail>()
+                            .Count(m => m.IsDel == "0" && m.ASNNo == detail.ASNNo && m.Status != "2");
+            if (asnDetailNum == 0)
+            {
+                notice.Status = "2";
+                notice.CompleteTime = comTime;//瀹屾垚鏃堕棿
+            }
+            //鏇存柊鍏ュ簱鍗�
+            Db.Updateable(notice).ExecuteCommand();
+            #endregion
+
+            #region 搴撳瓨鏄庣粏
+            sd1.Qty = bind.Qty;
+            //鏇存敼搴撳瓨鏄庣粏鏁伴噺
+            Db.Updateable(sd1).Where(m => m.Id == sdId1).ExecuteCommand();
+            #endregion
+
+            #region 搴撳瓨
+            var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo);
+            if (dataStock != null)
+            {
+                dataStock.Qty += model.SkuQty;
+
+
+                if (bind.InspectMark == "1")
+                {
+                    dataStock.IsSampling = bind.InspectMark;
+                }
+                Db.Updateable(dataStock).ExecuteCommand();
+            }
+            else
+            {
+                var stock = new DataStock()
+                {
+                    SkuNo = sku.SkuNo,
+                    SkuName = sku.SkuName,
+                    Standard = sku.Standard,
+                    LotNo = bind.LotNo,
+                    LotText = bind.LotText,
+                    Qty = bind.Qty,
+                    LockQty = 0,
+                    FrozenQty = 0,
+                    IsSampling = bind.InspectMark,
+                    IsDel = "0",
+                    CreateUser = userId,
+                    CreateTime = comTime
+                };
+                //缁存姢搴撳瓨璐т富淇℃伅
+                if (notice.Type == "0" || notice.Type == "2" || notice.Type == "4" || notice.Type == "6" || notice.Type == "7")//0:鎴愬搧鍏ュ簱锛�2:涓棿鍝佸叆搴�,4:杞﹂棿浣欐枡鍏ュ簱,6:浠e偍鍏ュ簱,7:瀵勫瓨鍏ュ簱
+                {
+                    stock.OwnerNo = notice.CustomerNo;//璐т富缂栫爜
+                    stock.OwnerName = notice.CustomerName;//璐т富鍚嶇О
+                }
+                Db.Insertable(stock).ExecuteCommand();
+            }
+            #endregion
+
+            #region 璐ㄦ璇烽獙
+            if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
+            {
+                var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
+                if (qualityRequest == null)
+                {
+                    string qcNo = new Common().GetMaxNo("QC");
+                    qualityRequest = new BllQualityInspectionRequest();
+                    qualityRequest.QcNo = qcNo;
+                    qualityRequest.Status = "0";
+                    qualityRequest.SkuNo = sku.SkuNo;
+                    qualityRequest.SkuName = sku.SkuName;
+                    qualityRequest.LotNo = bind.LotNo;
+                    qualityRequest.SupplierLot = bind.SupplierLot;
+                    qualityRequest.Qty = detail.Qty;
+                    qualityRequest.SamplingQty = 0;
+                    qualityRequest.ASNNo = detail.ASNNo;
+                    qualityRequest.CreateUser = userId;
+                    qualityRequest.CreateTime = comTime;
+                    //娣诲姞璐ㄦ璇烽獙鍗�
+                    Db.Insertable(qualityRequest).ExecuteCommand();
+                }
+            }
+            #endregion
+
+            // 鏇存敼鎵樼洏浣跨敤鐘舵��
+            var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
+            //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
+            sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','缁勭洏','0',getDate(),{userId},NULL,NULL);";
+            Db.Ado.ExecuteCommand(sqlStr);
+            new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "鎵樼洏缁戝畾", model.AsnNo, "娣诲姞", $"娣诲姞浜嗘墭鐩樼爜涓猴細{model.PalletNo}鐨勭粍鐩樹俊鎭�", userId);
+
+
+
         }
 
         #endregion
@@ -4954,7 +5316,7 @@
         #region JC23鍙栨牱涓氬姟鎺ュ彛
 
         //鑾峰彇鏈粍鎵樻垨宸茬粍鎵樼殑绠辩爜绾у埆
-        public BoxInfoDto GetBoxLevel(string boxNo,string boxNo3)
+        public BoxInfoDto GetBoxLevel(string boxNo, string boxNo3)
         {
             try
             {
@@ -4974,7 +5336,7 @@
                 }
                 var str = "0";
                 var data = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo && m.Status != "2")
-                    .GroupBy(m=>new {m.BoxNo,m.SkuNo,m.SkuName,m.LotNo}).Select(m=>new BoxInfoDto()
+                    .GroupBy(m => new { m.BoxNo, m.SkuNo, m.SkuName, m.LotNo }).Select(m => new BoxInfoDto()
                     {
                         SkuNo = m.SkuNo,
                         SkuName = m.SkuName,
@@ -4989,7 +5351,7 @@
                 }
                 var count = Db.Queryable<BllBoxInfo>().Count(m =>
                     m.IsDel == "0" && m.BoxNo == boxNo && !string.IsNullOrWhiteSpace(m.BoxNo3));
-                str = count>0 ? "2" : "1";  
+                str = count > 0 ? "2" : "1";
                 data[0].BoxLevel = str;
                 return data[0];
             }
@@ -5020,7 +5382,7 @@
                     throw new Exception("鏈煡璇㈠埌绛夊緟鎵ц鐨勬墭鐩樼粦瀹氫俊鎭�");
                 }
 
-                if (bindList.Count>1)
+                if (bindList.Count > 1)
                 {
                     throw new Exception("鎵樼洏缁戝畾淇℃伅瀛樺湪澶氭潯淇℃伅锛岃鏍稿疄");
                 }
@@ -5067,7 +5429,7 @@
                     throw new Exception("鍙栨牱鏁伴噺涓嶈兘涓虹┖");
                 }
 
-                if (model.BoxLevel!= "1" && model.BoxLevel != "2")
+                if (model.BoxLevel != "1" && model.BoxLevel != "2")
                 {
                     throw new Exception("鍙栨牱鏍囪瘑閿欒锛岃鍒锋柊椤甸潰");
                 }
@@ -5114,7 +5476,7 @@
                         {
                             item.Qty -= sampleQty;
                             item.InspectMark = "1";//鎶芥鎵樻爣璁�
-                            item.SamplingQty = item.SamplingQty == null? sampleQty: item.SamplingQty + sampleQty;
+                            item.SamplingQty = item.SamplingQty == null ? sampleQty : item.SamplingQty + sampleQty;
                         }
                     }
                     Db.Updateable(boxList).ExecuteCommand();
@@ -5128,7 +5490,7 @@
                             throw new Exception("绠辩爜鐘舵�佸凡缁勬墭锛屼絾鏈煡璇㈠埌鎵樼洏缁戝畾淇℃伅");
                         }
                         bind.BitPalletMark = "1";
-                        bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty; 
+                        bind.SamplingQty = bind.SamplingQty == null ? sampleQty : bind.SamplingQty + sampleQty;
                         bind.Qty -= sampleQty;
                         bind.InspectMark = "1";
                         Db.Updateable(bind).ExecuteCommand();
@@ -5145,11 +5507,11 @@
 
 
                     }
-                    
-                } 
+
+                }
                 else if (model.BoxLevel == "1")
                 {
-                    if (boxList.Count>1)
+                    if (boxList.Count > 1)
                     {
                         throw new Exception("涓�绾х鐮佹煡璇㈤敊璇紝鍚湁澶氭潯鐩稿悓绠辩爜鏁版嵁");
                     }
@@ -5229,7 +5591,7 @@
 
                 var bind = bindList.First();
                 var boxInfoCount = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.BindNo == bind.Id);
-                if (boxInfoCount>0)
+                if (boxInfoCount > 0)
                 {
                     throw new Exception("褰撳墠鎵樼洏缁戝畾淇℃伅鏄湁绠辩爜鐨勶紝璇峰湪鏍囩椤靛彇鏍�");
                 }
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index 1b53369..2c3e986 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -1083,5 +1083,86 @@
         }
         #endregion
 
+        #region 闆剁瑙g粦
+        public void LingxingUnbind(string palletNo,string boxNo, int userId)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(palletNo))
+                {
+                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
+                }
+                if (string.IsNullOrEmpty(boxNo))
+                {
+                    throw new Exception("绠辩爜涓嶈兘涓虹┖");
+                }
+                //寮�鍚簨鍔�
+                Db.BeginTran();
+                var comTime = DateTime.Now;
+
+                //鎵樼洏搴撳瓨鏄庣粏淇℃伅
+                var detail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (detail == null)
+                {
+                    throw new Exception("璇ユ墭鐩樺簱瀛樻槑缁嗕俊鎭笉瀛樺湪");
+                }
+                //搴撳瓨绠辨敮鏄庣粏淇℃伅
+                var boxList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.StockDetailId == detail.Id && w.BoxNo == boxNo).ToList();
+                if (boxList.Count <= 0)
+                {
+                    throw new Exception("璇ョ鐮佸簱瀛樼鏀俊鎭笉瀛樺湪");
+                }
+                decimal boxQty = 0;//绠卞唴鏁伴噺
+                foreach (var item in boxList)
+                {
+                    boxQty += item.Qty;
+
+                    item.StockDetailId = 0;//娓呯┖鎵樼洏澶栭敭
+                }
+                //鏇存柊搴撳瓨绠辨敮鏄庣粏琛�
+                Db.Updateable(boxList).ExecuteCommand();
+
+                detail.Qty -= boxQty;//鎵樼洏搴撳瓨鏁伴噺
+                detail.BitPalletMark = "1";//闆舵墭鏍囪
+                //鏇存柊鎵樼洏搴撳瓨琛�
+                Db.Updateable(detail).ExecuteCommand();
+
+                //娣诲姞鎵樼洏瑙g粦缁戝畾璁板綍
+                var unBind = new BllPalletUnbind()
+                {
+                    UpbindPalletNo = palletNo,
+                    BindPalletNo = "",
+                    LotNo = detail.LotNo,
+                    LotText = detail.LotText,
+                    SupplierLot = detail.SupplierLot,
+                    SkuNo = detail.SkuNo,
+                    SkuName = detail.SkuName,
+                    Standard = detail.Standard,
+                    Qty = boxQty,
+                    PalletNo2 = detail.PalletNo2,
+                    PalletNo3 = detail.PalletNo3,
+                    BoxNo = boxNo,
+                    InspectNo = "",
+                    InspectStatus = detail.InspectStatus,
+
+                    IsDel = "0",
+                    CreateTime = comTime,
+                    CreateUser = userId
+                };
+                Db.Insertable(unBind).ExecuteCommand();
+
+                //娣诲姞鎿嶄綔鏃ュ織
+                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"闆剁瑙g粦锛氬師鎵樼洏鐮侊細{palletNo}涓婄殑绠辩爜{boxNo}瑙g粦", userId);
+                //鎻愪氦浜嬪姟
+                Db.CommitTran();
+            }
+            catch (Exception e)
+            {
+                //鍥炴粴浜嬪姟
+                Db.RollbackTran();
+                throw new Exception(e.Message);
+            }
+        }
+        #endregion
     }
 }
diff --git a/Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs b/Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs
index 19db4a1..616764b 100644
--- a/Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs
+++ b/Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs
@@ -476,20 +476,20 @@
                         // 姝e紡杩愯绋嬪簭鏀惧紑
                         var list2 = outWhs.Select(m => m.TaskNo).ToList();
                         var jsonData = JsonConvert.SerializeObject(outWhs);
-                        string response = "";
+                        //string response = "";
 
                         try
                         {
-                            var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
-                            response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
-                            var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+                            //var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+                            //response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+                            //var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
 
                             ////瑙f瀽杩斿洖鏁版嵁 
                             //var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
                             //if (wcsModel.StatusCode == 0)
                             //{
                             //    //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
-                                new TaskServer().EditTaskIssueOk(list2, time1, time2);
+                                //new TaskServer().EditTaskIssueOk(list2, time1, time2);
                             //}
                             //if (wcsModel.StatusCode == -1)
                             //{
diff --git a/Wms/WMS.BLL/SysServer/MaterialsServer.cs b/Wms/WMS.BLL/SysServer/MaterialsServer.cs
index 6b0d9c7..e10d30f 100644
--- a/Wms/WMS.BLL/SysServer/MaterialsServer.cs
+++ b/Wms/WMS.BLL/SysServer/MaterialsServer.cs
@@ -57,6 +57,8 @@
         {
             return Db.Queryable<SysMaterials>()
                      .LeftJoin<SysUserInfor>((a, b) => a.CreateUser == b.Id)
+                     .LeftJoin<SysPackag>((a, b,c) => a.PackagNo == c.PackagNo) 
+                     .Where((a,b,c) => c.IsDel == "0")
                      .WhereIF(!string.IsNullOrEmpty(skuNo), a => a.SkuNo.Contains(skuNo))
                      .WhereIF(!string.IsNullOrEmpty(skuName), a => a.SkuNo.Contains(skuName))
                      .WhereIF(!string.IsNullOrEmpty(auditStatusNo), a => a.AuditStatusNo == auditStatusNo)
@@ -66,7 +68,7 @@
                      .WhereIF(!string.IsNullOrEmpty(environment), a => a.Environment == environment)
                      .WhereIF(!string.IsNullOrEmpty(categoryNo), a => a.CategoryNo == categoryNo)
                      .Where(a => a.IsDel == "0")
-                     .Select<MaterialsDto>((a, b) => new MaterialsDto() { CreateUserName = b.RealName }, true)
+                     .Select<MaterialsDto>((a, b, c) => new MaterialsDto() { CreateUserName = b.RealName,PackagName = c.PackagName }, true)
                      .ToListAsync();
         }
 
diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
index bbb4008..702e76c 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
@@ -58,7 +58,7 @@
         ///// </summary>
         ///// <param name="model"></param>
         ///// <param name="userId"></param>
-        //void BindPalletPasteCode(PdaPalletBindVm model, int userId);
+        void BindPalletPasteCode(PdaPalletBindVm model, int userId);
 
         /// <summary>
         /// JC26缁戝畾鎵樼洏 涓嶈创鏍囩墿鏂�
diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
index 746c614..2a0e958 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
@@ -140,5 +140,15 @@
         /// <param name="userId"></param>
         Task AgvTransport2(string soNo, string palletNo, string areaNo, int userId);
         #endregion
+
+        #region 闆舵墭瑙g粦
+        /// <summary>
+        /// 闆舵墭瑙g粦
+        /// </summary>
+        /// <param name="palletNo"></param>
+        /// <param name="boxNo"></param>
+        /// <param name="userId"></param>
+        public void LingxingUnbind(string palletNo, string boxNo, int userId);
+        #endregion
     }
 }
diff --git a/Wms/Wms/Controllers/PdaAsnController.cs b/Wms/Wms/Controllers/PdaAsnController.cs
index f59a6ce..d896832 100644
--- a/Wms/Wms/Controllers/PdaAsnController.cs
+++ b/Wms/Wms/Controllers/PdaAsnController.cs
@@ -583,7 +583,14 @@
                 {
                     throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
                 }
-                _PdaAsnSvc.BindPalletNoPasteCode(model, int.Parse(UserId));
+                if (model.TableType == 0)
+                {
+                    _PdaAsnSvc.BindPalletPasteCode(model, int.Parse(UserId));
+                }
+                else if (model.TableType == 1)
+                {
+                    _PdaAsnSvc.BindPalletNoPasteCode(model, int.Parse(UserId));
+                }
 
                 return Ok(new { code = 0, msg = "缁戝畾鎴愬姛!" });
 
diff --git a/Wms/Wms/Controllers/PdaCrController.cs b/Wms/Wms/Controllers/PdaCrController.cs
index 5170c06..86c1d5e 100644
--- a/Wms/Wms/Controllers/PdaCrController.cs
+++ b/Wms/Wms/Controllers/PdaCrController.cs
@@ -248,5 +248,39 @@
 
         #endregion
 
+        #region 闆剁瑙g粦
+        /// <summary>
+        /// 闆剁瑙g粦
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult LingxingUnbind(PdaPalletUnBindVm model)
+        {
+            try
+            {
+                //鑾峰彇褰撳墠鐧诲綍鐨勭敤鎴稩D
+                var claimsIdentity = this.User.Identity as ClaimsIdentity;
+                if (claimsIdentity == null)
+                {
+                    return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                }
+                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
+                if (string.IsNullOrWhiteSpace(userId))
+                {
+                    return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
+                }
+
+                var uId = int.Parse(userId);
+                _pdaCrSvc.LingxingUnbind(model.PalletNo, model.BoxNo, uId);
+
+                return Ok(new { data = "", code = 0, msg = "鎴愬姛" });
+            }
+            catch (Exception e)
+            {
+                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
+            }
+        }
+        #endregion
     }
 }
diff --git a/Wms/Wms/Controllers/PdaSoController.cs b/Wms/Wms/Controllers/PdaSoController.cs
index 006663b..0056a0e 100644
--- a/Wms/Wms/Controllers/PdaSoController.cs
+++ b/Wms/Wms/Controllers/PdaSoController.cs
@@ -10,7 +10,6 @@
 using Model.ModelVm.PdaVm;
 using WMS.IBLL.IPdaServer;
 using Model.ModelDto;
-using Model.ModelVm;
 using Wms.Tools;
 using Utility;
 using System.Security.Cryptography;
@@ -65,9 +64,9 @@
         /// <param name="model">PalletNo:鎵樼洏鐮併�丼oNo:鍗曟嵁鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public async Task GetSoSkuLotNoListByPallet(PdaSoVm model)
+        public async Task<List<DetailIdSkuLotNo>> GetSoSkuLotNoListByPallet(PdaSoVm model)
         {
-            var models = await _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
+           return await _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
         }
 
         /// <summary>
@@ -89,18 +88,20 @@
         [HttpPost]
         public async Task<OutPdaInfo> GetPlanAndFinishQty(PdaSoVm model)
         {
-            return await _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
+            var data = await _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
+            return data;
         }
 
         /// <summary>
         /// 鑾峰彇绠辩爜淇℃伅锛堟牴鎹鐮佸湪搴撳瓨绠辩爜鏄庣粏涓煡璇級
         /// </summary>
-        /// <param name="model">BoxNo:绠辩爜鍙�</param> 
+        /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public async Task<dynamic> GetDataComBoxInfo(PdaSoVm model)
+        public async Task<List<BoxInfo>> GetDataComBoxInfo(PdaSoVm model)
         {
-            return await _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3);
+            var data = await _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3);
+            return data;
         }
 
         /// <summary>
@@ -109,7 +110,7 @@
         /// <param name="model">BoxNo:绠辩爜鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public async Task<dynamic> GetAllotPlnInfo(PdaSoVm model)
+        public async Task<List<BoxInfo>> GetAllotPlnInfo(PdaSoVm model)
         {
             return await _pdaSoSvc.GetAllotPlnInfo(model.SoDetailId, model.PalletNo);
         }
diff --git a/Wms/Wms/appsettings.json b/Wms/Wms/appsettings.json
index bf36940..6de1f01 100644
--- a/Wms/Wms/appsettings.json
+++ b/Wms/Wms/appsettings.json
@@ -11,7 +11,8 @@
     //"ConnectionString": "Server=47.95.120.93;Database=WMS_JC09;User ID=sa;password=boxline!@#; Integrated Security=True;",
     //"ConnectionString": "Server=47.95.120.53;Database=WMS_JC09;User ID=sa;Password=boxline!@#;Integrated Security=False;",
     //"ConnectionString": "Server=192.168.62.106;Database=WMS_JC24;User ID=sa;Password=sql2019;Integrated Security=False;",
-    "ConnectionString": "Server=192.168.62.200;Database=WMS_JC26;User ID=sa;Password=sql2019;Integrated Security=False;"
+    //"ConnectionString": "Server=192.168.62.200;Database=WMS_JC26;User ID=sa;Password=sql2019;Integrated Security=False;",
+    "ConnectionString": "Server=.;Database=WMS_JC26;User ID=sa;Password=sql2019;Integrated Security=False;"
     //"ConnectionString": "Server=.;Database=WMS_JC09;User ID=sa;Password=sql2019;Integrated Security=False;"
     //"ConnectionString": "Data Source=DESKTOP-0EJDG95\\MSSQLSERVER1;Initial Catalog=WMS_V01;Integrated Security=True;"
   },
@@ -46,7 +47,7 @@
   },
   "Quartz": {
     "dbProviderName": "SqlServer",
-    "connectionString": "Server=192.168.62.200;Database=QRTZ;User ID=sa;Password=sql2019;Integrated Security=False;"
+    "connectionString": "Server=.;Database=QRTZ;User ID=sa;Password=sql2019;Integrated Security=False;"
   }
 
 

--
Gitblit v1.8.0