From 1310b47a24f0cc70f0128c820bd490dca6a1a921 Mon Sep 17 00:00:00 2001
From: yyk <2336760928@qq.com>
Date: 星期四, 22 八月 2024 14:08:03 +0800
Subject: [PATCH] Merge branch 'master' into yyk

---
 HTML/js/public.js                                           |    9 
 HTML/views/ASNSetting/BoxInfo.html                          |    5 
 Wms/Model/ModelVm/BllTaskVm/TaskSyncInfoVm.cs               |    4 
 Wms/WMS.BLL/BllAsnServer/PalletUpShelfServer.cs             |   71 
 Wms/WMS.IBLL/IPdaServer/IPdaSoServer.cs                     |   51 
 HTML/views/HouseWithinSetting/images/400x400.jpg            |    0 
 HTML/views/SystemSettings/PrintModule.html                  |  153 +
 Wms/Wms/Controllers/PdaAsnController.cs                     |   18 
 Wms/Wms/Controllers/BllCheckController.cs                   |    2 
 Wms/Model/ModelDto/PdaDto/PdaSoDto.cs                       |    6 
 HTML/views/QualityControl/QualityChangeLog.html             |    2 
 Pda/View/AsnSetting/productEnterQuantity.html               |    4 
 Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs                     | 2014 ++++++------
 HTML/views/ASNSetting/ArrivalNotice.html                    |   24 
 HTML/views/HouseWithinSetting/CRLogTask.html                |    4 
 Pda/View/SoSetting/pingKuOut.html                           |    4 
 Wms/Wms/Controllers/BasisController.cs                      |    3 
 HTML/layuiadmin/dragMove/dragMove.js                        |  261 +
 HTML/views/ASNSetting/PalletUpShelf.html                    |  313 ++
 Wms/Wms/Controllers/PdaCrController.cs                      |  261 -
 Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs             |    8 
 Wms/WMS.BLL/Logic/AllotSku.cs                               |  132 
 Wms/WMS.DAL/SysInfrastructure/StorageLocatRepository.cs     |   64 
 Wms/Wms/Controllers/BllAsnController.cs                     |   24 
 Wms/Model/ModelDto/BllAsnDto/PalletUpShelfDto.cs            |   89 
 HTML/views/ASNSetting/ProcurePlanNotice.html                |   10 
 Wms/WMS.BLL/BllQualityServer/InspectionRequestServer.cs     |   10 
 Pda/View/HouseDataSetting/lingXiangUnbind.html              |  169 +
 Wms/Utility/Filter/CustomerExceptionFilter.cs               |    8 
 Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs               |   65 
 HTML/views/BaseSetting/Materials.html                       |   77 
 HTML/views/SystemSettings/Role.html                         |   52 
 Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs                     | 1831 +++++------
 Wms/WMS.BLL/SysServer/MaterialsServer.cs                    |    4 
 Wms/WMS.BLL/BllCheckServer/WarehouseOutsidePalletsServer.cs |   16 
 Wms/WMS.Entity/BllAsnEntity/BllPalletUpShelf.cs             |   63 
 Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs                |  324 +
 HTML/views/HouseWithinSetting/images/1920x400.jpg           |    0 
 Pda/View/HouseDataSetting/stockCheck.html                   |    1 
 Wms/Wms/Controllers/WeatherForecastController.cs            |    7 
 HTML/views/ASNSetting/PalletBind.html                       |    1 
 HTML/views/HouseWithinSetting/ViewPicture.html              |  104 
 HTML/views/HouseWithinSetting/images/1920x1080.jpg          |    0 
 Wms/WMS.BLL/BllSoServer/WaveMageServer.cs                   |    2 
 Pda/View/SoSetting/pinTuoOut.html                           |   13 
 HTML/views/HouseWithinSetting/FreezeUnfreeze.html           |   36 
 Pda/js/public.js                                            |  171 
 Wms/Model/ModelVm/BllAsnVm/PalletUpShelfVm.cs               |   43 
 Wms/WMS.BLL/BllCheckServer/StockCheckServer.cs              |   66 
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs                    | 1688 ++++++++++
 Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs                     |   41 
 HTML/views/HouseWithinSetting/images/400x900.jpg            |    0 
 Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs               |    1 
 Wms/Wms/appsettings.json                                    |    3 
 Wms/WMS.IBLL/IBllAsnServer/IPalletUpShelfServer.cs          |   41 
 Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs                    |   16 
 HTML/layuiadmin/dragMove/dragMove.css                       |   20 
 Wms/Model/ModelVm/PdaVm/PdaCrVm.cs                          |    6 
 HTML/views/SystemSettings/Dictionary.html                   |   43 
 HTML/views/SystemSettings/Category.html                     |   43 
 Wms/Model/ModelVm/BllCheckVm/StockCheckVm.cs                |   28 
 HTML/views/HouseWithinSetting/StockCheck.html               |   37 
 HTML/views/SystemSettings/UserManage.html                   |   78 
 Wms/Wms/Controllers/PdaSoController.cs                      |  480 --
 HTML/views/QualityControl/QualityInformation.html           |    5 
 Wms/Wms/Controllers/DownApiController.cs                    |    1 
 66 files changed, 5,987 insertions(+), 3,143 deletions(-)

diff --git a/HTML/js/public.js b/HTML/js/public.js
index f209f46..59bbbe0 100644
--- a/HTML/js/public.js
+++ b/HTML/js/public.js
@@ -38,8 +38,15 @@
   if (url!=IP+"/WeatherForecast/Login") {
     if (!$.cookie('token')) {
       callbackFun("鐧诲綍浜轰俊鎭凡澶辨晥");
+      try{
+        parent.window.location.href = '/views/Login.html';
+      }
+      catch(error){
+        window.location.href = '/views/Login.html';
+      }
+      return;
     }
-    if(isExpired = isTokenExpired($.cookie('token'))){
+    if(isTokenExpired($.cookie('token'))){
       try{
         parent.window.location.href = '/views/Login.html';
       }
diff --git a/HTML/layuiadmin/dragMove/dragMove.css b/HTML/layuiadmin/dragMove/dragMove.css
new file mode 100644
index 0000000..e3fee1e
--- /dev/null
+++ b/HTML/layuiadmin/dragMove/dragMove.css
@@ -0,0 +1,20 @@
+/**
+ @ Name锛歭ayui.dragMove 鍥剧墖鏌ョ湅鍣�
+ @ Author锛欶QSong
+ @ License锛歁IT 
+ */
+ 
+/* 鏍峰紡鍔犺浇瀹屾瘯鐨勬爣璇� */
+html #layuicss-dragMove{display: none; position: absolute; width: 1989px;} 
+ 
+ 
+/* 缁勪欢鏍峰紡 */ 
+.dragMove-skin .layui-layer-content {overflow: hidden !important;}
+.layui-dragMove {position: relative; width: 100%; height: 100%; display: -webkit-flex; display: flex; flex-direction:column;}
+.layui-dragMove .dragMove-img {position: relative; width: 100%; height: 100%; overflow: hidden; -webkit-flex: 1;  flex: 1; background-color:#eee;}
+.layui-dragMove .dragMove-img img {position: absolute; left: 0; top: 0; user-select:none; cursor: grab;}
+.layui-dragMove .dragMove-btn {width:100%; padding: 10px 0; text-align:center; -webkit-flex: none;  flex: none;}
+.layui-dragMove .dragMove-btn .layui-btn {height: 28px; line-height: 28px;}
+.layui-icon-loading {position: absolute; left: 50%; top: 50%; display: block; width: 36px; height: 36px; font-size: 36px; line-height: 36px; }
+
+.transitioning {-webkit-transition: -webkit-transform .24s ease-out; transition: transform .24s ease-out;}
\ No newline at end of file
diff --git a/HTML/layuiadmin/dragMove/dragMove.js b/HTML/layuiadmin/dragMove/dragMove.js
new file mode 100644
index 0000000..1c5d2d4
--- /dev/null
+++ b/HTML/layuiadmin/dragMove/dragMove.js
@@ -0,0 +1,261 @@
+/**
+ @ Name锛歭ayui.dragMove 鍥剧墖鏌ョ湅鍣�
+ @ Author锛欶QSong
+ @ License锛歁IT 
+ */
+ 
+layui.define('layer', function(exports){ 
+  var $ = layui.$
+  ,layer = layui.layer
+  
+  //瀛楃甯搁噺
+  ,MOD_NAME = 'dragMove', ELEM = '.layui-dragMove'
+  
+  //澶栭儴鎺ュ彛
+  ,dragMove = {
+    index: layui.dragMove ? (layui.dragMove.index + 10000) : 0
+    
+    //璁剧疆鍏ㄥ眬椤�
+    ,set: function(options){
+      var that = this;
+      that.config = $.extend({}, that.config, options);
+      return that;
+    }
+    
+    //浜嬩欢鐩戝惉
+    ,on: function(events, callback){
+      return layui.onevent.call(this, MOD_NAME, events, callback);
+    }
+  }
+    
+  //鏋勯�犲櫒
+  ,Class = function(options){
+    var that = this;
+    that.index = ++dragMove.index;
+    that.config = $.extend({}, that.config, dragMove.config, options);
+    that.render();
+  };
+  
+  //榛樿閰嶇疆
+  Class.prototype.config = {
+    layerArea: ["960px","720px"],
+    layerShade: 0.6,
+    layerMove: 0,
+    maxZoom: 1
+  };
+  
+  //娓叉煋瑙嗗浘
+  Class.prototype.render = function(){
+    var that = this
+    ,options = that.config
+    ,dragMoveView = "<div class='layui-dragMove'>"
+    + "<div class='dragMove-img'>"
+    +   "<span class='layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop'></span>"
+    + "</div>"
+    + "<div class='dragMove-btn'>"
+    +   "<button type='button' class='layui-btn layui-btn-sm' data-method='default'>榛樿澶у皬</button>"
+    +   "<button type='button' class='layui-btn layui-btn-sm' data-method='real'>瀹為檯澶у皬</button>"
+    +   "<button type='button' class='layui-btn layui-btn-sm' data-method='zoomin'>鏀惧ぇ</button>"
+    +   "<button type='button' class='layui-btn layui-btn-sm' data-method='zoomout'>缂╁皬</button>"
+    + "</div>"
+    + "</div>";
+
+    options.elem = $(options.elem);
+
+    options.elem.on("click","img",function(e){
+      let imgObj =  $(this),
+      imgSrc = imgObj.attr("src"),
+      imgTitle = imgObj.attr("alt") || imgSrc.replace(/(.*\/)*([^.]+).*/ig,"$2");
+      
+      layer.open({
+        type: 1,
+        resize: 0,
+        btn: 0,
+        skin: "dragMove-skin",
+        move: options.layerMove,
+        area: options.layerArea,
+        shade: options.layerShade,
+        title: imgTitle,
+        content: dragMoveView,
+        success: function(layero){
+          var imgbox = layero.find(".dragMove-img");
+          options.imgboxWidth = imgbox.innerWidth();
+          options.imgboxHeight = imgbox.innerHeight();
+
+          var nImg = new Image();
+          nImg.src = imgSrc;
+          if (nImg.complete) { 
+            imgbox.empty().append(nImg);
+            that.init(nImg)
+          } else {
+            nImg.onload = function () {
+              imgbox.empty().append(nImg);
+              that.init(nImg)
+            }
+          }
+        }
+      });
+    });    
+  }
+
+  //
+  Class.prototype.init = function(img){
+    var that = this
+    ,options = that.config;
+
+    let $img = $(img),
+    parent = $img.closest(".layui-dragMove"),
+    zoomData = {};
+
+    zoomData.img = img;
+    zoomData.imgWidth = img.width;
+    zoomData.imgHeight = img.height;
+
+    zoomData.zoomSize = Math.min(Math.min(options.imgboxWidth / zoomData.imgWidth, options.imgboxHeight / zoomData.imgHeight), 1);
+    zoomData.left = (options.imgboxWidth - zoomData.imgWidth * zoomData.zoomSize) / 2;
+    zoomData.top = (options.imgboxHeight - zoomData.imgHeight * zoomData.zoomSize) / 2;
+    zoomData.defaultZoom = zoomData.zoomSize;
+
+    that.zoomData = zoomData;
+    $img.css({ "transform-origin": "0 0", "transform": "matrix(" + zoomData.zoomSize + ",0,0," + zoomData.zoomSize + "," + zoomData.left + "," + zoomData.top + ")" });
+
+    $img.on("mousedown", function (e) {
+      e.preventDefault();      
+      let currentX = e.clientX,
+      currentY = e.clientY;
+      $img.removeClass("transitioning").css({"cursor": "grabbing"});
+
+      $(document).on("mousemove", function (even) {
+        let moveX = even.clientX - currentX,
+        moveY = even.clientY - currentY;
+        $img.css({ "transform": "matrix(" + zoomData.zoomSize + ",0,0," + zoomData.zoomSize + "," + (zoomData.left + moveX) + "," + (zoomData.top + moveY) + ")" });
+      });
+      $(document).on("mouseup", function (even) {
+        var matrix = $img.css("transform").slice(7, -1).split(','),
+        center = that.getCenter(parseFloat(matrix[4]), parseFloat(matrix[5]), zoomData);
+
+        zoomData.left = center.left;
+        zoomData.top = center.top;
+
+        $img.addClass("transitioning").css({
+          "transform": "matrix(" + zoomData.zoomSize + ",0,0," + zoomData.zoomSize + "," + zoomData.left + "," + zoomData.top + ")",
+          "cursor": "grab"
+        });
+
+        $(document).off("mousemove");
+        $(document).off("mouseup");
+      });
+    });
+
+    parent.on("click", "button", function (e) {
+      e.preventDefault();
+      var method = $(this).attr("data-method"),
+      scaleSize = 0;
+      switch (method) {
+        case "default":
+          scaleSize = zoomData.defaultZoom;
+          break;
+        case "real":
+          scaleSize = 1;
+          break;
+        case "zoomin":
+          scaleSize = zoomData.zoomSize * 1.2;
+          scaleSize = scaleSize > options.maxZoom ? options.maxZoom : scaleSize;
+          break;
+        case "zoomout":
+          scaleSize = zoomData.zoomSize / 1.2;
+          scaleSize = scaleSize < zoomData.defaultZoom ? zoomData.defaultZoom : scaleSize;
+          break;
+      
+        default:
+          break;
+      }
+      scaleSize && that.scaleZoom(scaleSize);
+    });
+    
+    //榧犳爣婊氳疆
+    parent.on("mousewheel", function (e) {
+      e.preventDefault();
+      let scaleSize = 0;
+      if (e.originalEvent.wheelDelta > 0) {
+        scaleSize = zoomData.zoomSize * 1.2;
+      } else {
+        scaleSize = zoomData.zoomSize / 1.2;
+      }
+      scaleSize = Math.min(Math.max(scaleSize, zoomData.defaultZoom),options.maxZoom);
+      that.scaleZoom(scaleSize);
+    });
+
+    $img.on("transitionend webkitTransitionend", function () {
+      $(this).removeClass("transitioning")
+    });
+
+  };
+
+  Class.prototype.scaleZoom = function(index){
+    var that = this
+    ,options = that.config
+    ,zoomData = that.zoomData;
+    
+    zoomData.left = zoomData.left - zoomData.imgWidth * (index - zoomData.zoomSize) / 2;
+    zoomData.top = zoomData.top -  zoomData.imgHeight * (index - zoomData.zoomSize) / 2;
+    zoomData.zoomSize = index;   
+
+    var center = that.getCenter(zoomData.left,zoomData.top,zoomData);
+    zoomData.left = center.left;
+    zoomData.top = center.top;
+     
+    $(zoomData.img).addClass("transitioning").css({          
+      "transform":"matrix("+ zoomData.zoomSize +",0,0," + zoomData.zoomSize +","+zoomData.left+","+zoomData.top+")"
+    });  
+  };
+
+  Class.prototype.getCenter = function(x,y,zoomData){
+    var that = this
+    ,options = that.config
+    ,zoomData = that.zoomData;
+    
+    let newleft,newtop;
+    newleft = (function(){
+      var left;
+      if(zoomData.imgWidth * zoomData.zoomSize < options.imgboxWidth){
+        left = (options.imgboxWidth - zoomData.imgWidth * zoomData.zoomSize) / 2;
+      }else{
+        left = Math.max(Math.min(0,x), options.imgboxWidth - zoomData.imgWidth * zoomData.zoomSize);
+      }
+      return left;
+    })();
+    newtop = (function(){
+      var top;
+      if(zoomData.imgHeight * zoomData.zoomSize < options.imgboxHeight){
+        top = (options.imgboxHeight - zoomData.imgHeight * zoomData.zoomSize) / 2;
+      }else{
+        top = Math.max(Math.min(0, y), options.imgboxHeight - zoomData.imgHeight * zoomData.zoomSize);
+      }
+      return top;
+    })();
+    return {left:newleft,top:newtop} 
+  };
+
+  Class.prototype.decimal = function(num){
+    var result = parseFloat(num);
+    if (isNaN(result)) {
+      return false;
+    }
+    result = Math.round(num * 100) / 100;
+    return result;
+  };
+
+  //鏍稿績鍏ュ彛
+  dragMove.render = function(options){
+    var ins = new Class(options);
+    return ins;
+  };
+  
+  //鍔犺浇缁勪欢鎵�闇�鏍峰紡
+  layui.link(layui.cache.base + 'dragMove/dragMove.css', function(){
+    //鏍峰紡鍔犺浇瀹屾瘯鐨勫洖璋�
+  }, MOD_NAME); 
+  
+  exports(MOD_NAME, dragMove);
+});
\ No newline at end of file
diff --git a/HTML/views/ASNSetting/ArrivalNotice.html b/HTML/views/ASNSetting/ArrivalNotice.html
index 3d4ae65..396741c 100644
--- a/HTML/views/ASNSetting/ArrivalNotice.html
+++ b/HTML/views/ASNSetting/ArrivalNotice.html
@@ -291,7 +291,10 @@
 							<i class="layui-icon">&#xe654;</i>娣诲姞
 						</button>
 					</script>
-
+					<!-- if((d.AsnType =="1" || d.AsnType == "4" || d.AsnType == "5" || d.AsnType == "6") && d.IsPasteCode == "1" && (d.Status == "0" || d.Status == "1")){  
+							html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel"> 
+								<i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`; 
+						} -->
 					<script type="text/html" id="toolbarDemoList">
 						{{# function GetBtn2(d){ 
 							console.log(d);
@@ -300,10 +303,7 @@
 									html = `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del"> 
 										<i class="layui-icon layui-icon-delete"></i>鍒犻櫎</a>`; 
 								}
-								if((d.AsnType =="1" || d.AsnType == "4" || d.AsnType == "5" || d.AsnType == "6") && d.IsPasteCode == "1" && (d.Status == "0" || d.Status == "1")){  
-									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel"> 
-										<i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`; 
-								}
+								
 								
 								return html;
 							} 
@@ -401,7 +401,7 @@
 			base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
 		}).extend({
 			index: 'lib/index' //涓诲叆鍙fā鍧�
-		}).use(['index', 'table', 'laypage', 'layer', 'laydate'], function () {
+		}).use(['index', 'form','table', 'laypage', 'layer', 'laydate'], function () {
 
 			var doing = true;
 
@@ -600,7 +600,7 @@
 					$(".clossClass").hide();
 					$(".editDemoClass").hide();//澶囨敞
 					$(".checkClass").hide(); //澶嶆牳
-					$(".addLabelClass").hide(); //澶嶆牳
+					//$(".addLabelClass").hide(); //鐢熸垚鏍囩
 
 				});
 				sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function (res) {
@@ -641,11 +641,11 @@
 									$(".checkClass").show();
 								});
 							}
-							if (res.data[k].MenuName == "鐢熸垚鏍囩") {
-								$(function () {
-									$(".addLabelClass").show();
-								});
-							}
+							// if (res.data[k].MenuName == "鐢熸垚鏍囩") {
+							// 	$(function () {
+							// 		$(".addLabelClass").show();
+							// 	});
+							// }
 						}
 					} else { //涓嶆垚鍔�
 						layer.msg('鑾峰彇鏉冮檺淇℃伅澶辫触', {
diff --git a/HTML/views/ASNSetting/BoxInfo.html b/HTML/views/ASNSetting/BoxInfo.html
index b930e6b..eea6ff8 100644
--- a/HTML/views/ASNSetting/BoxInfo.html
+++ b/HTML/views/ASNSetting/BoxInfo.html
@@ -754,8 +754,8 @@
 									BoxNo2: data[0].Sheet1[i].BoxNo2,
 									BoxNo3: data[0].Sheet1[i].BoxNo3,
 									Qty: Qty,
-									SkuNo: data[0].Sheet1[i].SkuNo,
-									LotNo: data[0].Sheet1[i].LotNo,
+									SkuNo: data[0].Sheet1[i].SkuNo.toString(),
+									LotNo: data[0].Sheet1[i].LotNo.toString(),
 									LotText: data[0].Sheet1[i].LotText,
 									ProductionTime: data[0].Sheet1[i].ProductionTime,
 									InspectMark: InspectMark,
@@ -772,6 +772,7 @@
 							console.log(param)
 							layer.load();//鎵撳紑loading
 							sendData(IP + "/BllAsn/ImportBllBoxInfo", param, 'post', function (res) {
+								console.log(res);
 								layer.closeAll(); //鍏抽棴loading
 								if (res.code == 0) { //鎴愬姛
 									layer.msg(res.msg, {
diff --git a/HTML/views/ASNSetting/PalletBind.html b/HTML/views/ASNSetting/PalletBind.html
index 8a091f9..c769367 100644
--- a/HTML/views/ASNSetting/PalletBind.html
+++ b/HTML/views/ASNSetting/PalletBind.html
@@ -469,6 +469,7 @@
 				{ field: 'WareHouseNo', title: '鎵�灞炰粨搴�', align: 'center', width: 90, templet: '#WareHouseButton' },
 				{ field: 'SkuNo', title: '鐗╂枡缂栫爜', align: 'center', width: 110 },
 				{ field: 'SkuName', title: '鐗╂枡鍚嶇О', align: 'center' },
+				{ field: 'LotNo', title: '鎵规鍙�', align: 'center',width: 120 },
 				{ field: 'Qty', title: '鏁伴噺', align: 'center', width: 90 },
 				{ field: 'FullQty', title: '鏁存墭鏁伴噺', align: 'center', width: 90 },
 				{ field: 'SamplingQty', title: '鍙栨牱鏁伴噺', align: 'center', width: 90 },
diff --git a/HTML/views/ASNSetting/PalletUpShelf.html b/HTML/views/ASNSetting/PalletUpShelf.html
new file mode 100644
index 0000000..517a855
--- /dev/null
+++ b/HTML/views/ASNSetting/PalletUpShelf.html
@@ -0,0 +1,313 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+	<meta charset="utf-8">
+	<title>鎵樼洏涓婃灦</title>
+	<meta name="renderer" content="webkit">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta name="viewport"
+		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+	<link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
+	<link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
+	<link rel="stylesheet" href="../../css/public.css" media="all">
+	<style>
+		.rightMargin {
+			margin-right: 0px;
+		}
+
+		.buJu {
+			margin-top: 10px;
+			display: flex;
+			flex-direction: row-reverse;
+		}
+
+		.beiJing {
+			background-color: #fafafa;
+			padding-top: 5px;
+			border-radius: 3px;
+			box-shadow: inset 0 0 3px 1px #ccc;
+		}
+
+		/* 琛ㄦ牸涓嬫媺灏忕澶撮殣钘� */
+		.layui-table-grid-down {
+			display: none;
+		}
+	</style>
+	<script>
+		// 杩欓噷鏄渶瑕佸湪椤甸潰娓叉煋涔嬪墠鎵ц鐨勪唬鐮�
+		document.addEventListener("DOMContentLoaded", function () {
+
+			//鑾峰彇table榛樿鏄剧ず鏁�
+			pageCntFirst();
+			//鍒ゆ柇鏄惁寮�鍚痶able鍒楄〃鍒楀璋冩暣鍔熻兘銆�
+			GetIsSetColW();
+		});
+	</script>
+</head>
+
+
+<body>
+
+	<div class="layui-fluid" style="padding: 3px;">
+		<div class="layui-card">
+			<div class="layui-form layui-card-header layuiadmin-card-header-auto">
+				<div class="layui-form-item">
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">杩芥函鍙�</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<input type="text" id="TraceNo" name="TraceNo" placeholder="杩芥函鍙�" autocomplete="off"
+								class="layui-input">
+						</div>
+					</div>
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">浠诲姟鍙�</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<input type="text" id="TaskNo" name="TaskNo" placeholder="浠诲姟鍙�" autocomplete="off"
+								class="layui-input">
+						</div>
+					</div>
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">鎵樼洏鍙�</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<div class="layui-input-inline" style="margin-right: 0;">
+								<input type="text" id="PalletNo" name="PalletNo" placeholder="鎵樼洏鍙�" autocomplete="off"
+									class="layui-input">
+							</div>
+						</div>
+					</div>
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">鐗╁搧缂栫爜</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<input type="text" id="SkuNo" name="SkuNo" placeholder="鐗╂枡缂栫爜" autocomplete="off"
+								class="layui-input">
+						</div>
+					</div>
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">鐗╁搧鍚嶇О</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<input type="text" id="SkuName" name="SkuName" placeholder="鐗╂枡鍚嶇О" autocomplete="off"
+								class="layui-input">
+						</div>
+					</div>
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label" style="width: 60px;">鎵规鍙�</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<div class="layui-input-inline" style="margin-right: 0;">
+								<input type="text" id="LotNo" name="LotNo" placeholder="鎵规鍙�" autocomplete="off"
+									class="layui-input">
+							</div>
+						</div>
+					</div>
+
+
+					<div class="layui-inline" style="margin-right: 0;">
+						<label class="layui-form-label">鐘舵��</label>
+						<div class="layui-input-inline" style="margin-right: 0;">
+							<div class="layui-input-inline" style="margin-right: 0;">
+								<select name="Status" id="Status" lay-filter="Status" lay-search>
+									<option value=""></option>
+									<option value="0">绛夊緟鎵ц</option>
+									<option value="1">姝e湪鎵ц</option>
+									<option value="2">鎵ц瀹屾垚</option>
+									<option value="4">宸插彇娑�</option>
+
+								</select>
+							</div>
+						</div>
+					</div>
+
+					<div class="layui-inline">
+						<button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit
+							lay-filter="LAY-app-contlist-search">
+							<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>鎼滅储
+						</button>
+
+					</div>
+
+				</div>
+			</div>
+			<div class="layui-card-body">
+				<div class="position-relative">
+					<table id="Box-list" lay-filter="Box-list"></table>
+
+					<div class="headerSetIcon">
+						<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="customCols">
+							<i class="layui-icon">&#xe610;</i>
+						</button>
+					</div>
+
+
+
+					<script type="text/html" id="templetStatus">
+						{{# function GetBtn1(d){
+								switch (d.Status) {
+									case "0": return '<button class="layui-btn layui-btn-radius layui-btn-xs">绛夊緟鎵ц</button>';
+									case "1": return '<button class="layui-btn layui-btn-radius layui-btn-xs layui-btn-danger ">姝e湪鎵ц</button>'; 
+									case "2": return '<button class="layui-btn layui-btn-radius layui-btn-xs layui-btn-normal ">鎵ц瀹屾垚</button>'; 
+									case "3": return '<button class="layui-btn layui-btn-radius layui-btn-xs layui-btn-normal ">宸插彇娑�</button>'; 
+									default: return "";
+								}	
+							}	
+						}}
+						{{ GetBtn1(d) }}
+					</script>
+
+					<script type="text/html" id="templetCreateTime">
+						{{# function GetBtn2(d){
+								return formatDate(d.CreateTime);
+							}	
+						}}
+						{{ GetBtn2(d) }}
+					</script>
+					<script type="text/html" id="templetUpdateTime">
+						{{# function GetBtn3(d){
+								return formatDate(d.UpdateTime);
+							}	
+						}}
+						{{ GetBtn3(d) }}
+					</script>
+
+				</div>
+
+				<script type="text/html" id="toolbarDemoList">
+					{{# function GetBtn2(d){
+							var html = '';
+							if(d.Origin == "WMS鐢熸垚" || d.Status == "0"){ 
+								html = `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del"> 
+									<i class="layui-icon layui-icon-delete"></i>鍒犻櫎</a>`; 
+								
+							}
+							return html;
+						} 
+					}}
+					{{ GetBtn2(d) }}
+				</script>
+			</div>
+
+		</div>
+	</div>
+
+
+	<script src="../../layuiadmin/layui/layui.js"></script>
+	<script src="../../js/public.js"></script>
+	<script src="../../js/jquery-3.5.1.min.js"></script>
+	<script src="../../js/jquery.cookie.js"></script>
+	<script>
+
+		layui.config({
+			base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
+		}).extend({
+			index: 'lib/index' //涓诲叆鍙fā鍧�
+		}).use(['index', 'form', 'layer', 'table', 'laydate',], function () {
+			var form = layui.form,
+				table = layui.table,
+				layer = layui.layer,
+				laydate = layui.laydate;
+
+			// 鎼滅储鏂规硶
+			form.on('submit(LAY-app-contlist-search)', function (data) {
+				bindTable();
+
+			});
+
+			// 椤甸潰鍔犺浇缁戝畾Table
+			bindTable();
+
+			//鑷畾涔夎〃澶�
+			var TotalColsArr = [[
+
+				{ field: 'TraceNo', title: '杩芥函鍙�', align: 'center', fixed: 'left', width: 180, "disabled": true },
+				{ field: 'TaskNo', title: '浠诲姟鍙�', align: 'center', fixed: 'left', width: 220, "disabled": true },
+				{ field: 'PalletNo', title: '鎵樼洏鍙�', align: 'center', fixed: 'left', width: 220, "disabled": true },
+				{ field: 'Status', title: '鐘舵��', align: 'center', templet: '#templetStatus', width: 90 },
+				{ field: 'SkuNo', title: '鐗╂枡缂栫爜', align: 'center', width: 140 },
+				{ field: 'SkuName', title: '鐗╂枡鍚嶇О', align: 'center' },
+				{ field: 'LotNo', title: '鎵规鍙�', align: 'center', width: 155 },
+
+				{ field: 'LocatNo', title: '鍌ㄤ綅鍦板潃', align: 'center', width: 90 },
+				{ field: 'RoadwayName', title: '鎵�灞炲贩閬�', align: 'center', width: 90 },
+				{ field: 'WareHouseName', title: '鎵�灞炰粨搴�', align: 'center', width: 90 },
+
+				{ field: 'CreateUserName', title: '鍒涘缓浜�', align: 'center', width: 100 },
+				{ field: 'CreateTime', title: '鍒涘缓鏃堕棿', align: 'center', width: 160, templet: '#templetCreateTime' },
+
+				{ field: 'UpdateUserName', title: '鏇存柊浜�', align: 'center', width: 100 },
+				{ field: 'UpdateTime', title: '鏇存柊鏃堕棿', align: 'center', width: 160, templet: '#templetUpdateTime' },
+				//{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', width: 100, align: 'center', toolbar: '#toolbarDemoList', "disabled": true }
+			]];
+			//url缂栫爜
+			var TotalColsSysArr = encodeURIComponent(encodeURIComponent(JSON.stringify(TotalColsArr)))//灏嗚〃澶存暟鎹繘琛寀rl缂栫爜
+			//#endregion
+			function bindTable() {
+
+				var colsJson
+				var param1 = {
+					Href: 'BllAsn/GetPalletUpShelfList'
+				};
+				sendData(IP + "/Sys/GetTableColsByUserId", param1, 'post', function (res) {
+					if (res.code == 0) {
+						if (res.data == '' || res.data == undefined || res.data == null) {
+							colsJson = TotalColsArr
+						} else {
+							colsJson = eval(res.data);
+						}
+					} else {
+						colsJson = TotalColsArr
+					}
+					var param = {
+						TraceNo: $("#ASNNo").val(),
+						TaskNo: $("#BoxNo").val(),
+						PalletNo: $("#PalletNo").val(),
+						SkuNo: $("#SkuNo").val(),
+						SkuName: $("#SkuName").val(),
+						LotNo: $("#LotNo").val(),
+						Status: $("#Status").val(),
+					};
+					table.render({
+						elem: '#Box-list',
+						url: IP + "/BllAsn/GetPalletUpShelfList",
+						method: 'POST',
+						height: 'full-96',
+						id: 'Box-list',
+						where: param,
+						contentType: 'application/json',
+						headers: { ToKen: $.cookie('token') },
+						page: true,
+						even: true,
+						limit: pageCnt,
+						limits: pageLimits,
+						cellMinWidth: 60, //鍏ㄥ眬瀹氫箟甯歌鍗曞厓鏍肩殑鏈�灏忓搴︼紝layui 2.2.1 鏂板
+						done: function (res) {
+
+							//鑷畾涔夊垪瀹�
+							SetTableColW('Box-list', 'BllAsn/GetPalletUpShelfList', TotalColsSysArr);
+						},
+						cols: colsJson
+					});
+				});
+				//#endregion
+			}
+
+			//鑷畾涔夎〃澶�			
+			active = {
+				customCols: function () {
+					layer.open({
+						type: 2,
+						title: '鑷畾涔夊垪',
+						content: '../SystemSettings/HeaderSetting.html?Href=BllAsn/GetPalletUpShelfList&ColsSysArr=' + TotalColsSysArr,
+						maxmin: false,
+						resize: false,
+						area: ['970px', '650px']
+					});
+				},
+			};
+			$('.layui-btn').on('click', function () {
+				var type = $(this).data('type');
+				active[type] ? active[type].call(this) : '';
+			});
+		})
+	</script>
+</body>
+
+</html>
\ No newline at end of file
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/HTML/views/BaseSetting/Materials.html b/HTML/views/BaseSetting/Materials.html
index a28aba1..60597c2 100644
--- a/HTML/views/BaseSetting/Materials.html
+++ b/HTML/views/BaseSetting/Materials.html
@@ -264,35 +264,79 @@
 							}, function() {});
 						}
 					});
-				}
-				sendData(IP + "/basis/GetRoleRightList", {}, "get", function (res) {
-					$(function() {
-						$("#approvalBtn").hide();
+					sendData(IP + "/basis/GetRoleRightList", {}, "get", function (res) {
+						$(function () {
+							$(".approvalBtn").hide();
+						});
+						$(function () {
+							$(".approvalBtndel").hide();
+						});
+						$(function () {
+							$(".approvalBtnupt").hide();
+						});
+						if (res.code == 0) //鎴愬姛
+						{
+							for (var k = 0; k < res.data.length; k++) {
+								if (res.data[k].MenuName == "娣诲姞鐗╂枡") {
+									$(function () {
+										$(".approvalBtn").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒犻櫎鐗╂枡") {
+									$(function () {
+										$(".approvalBtndel").show();
+									});
+								}
+								if (res.data[k].MenuName == "缂栬緫鐗╂枡") {
+									$(function () {
+										$(".approvalBtnupt").show();
+									});
+								}
+							}
+						}
+						else //涓嶆垚鍔�
+						{
+							layer.msg(
+								"鑾峰彇淇℃伅澶辫触",
+								{
+									icon: 2,
+									time: 2000, //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+								},
+								function () {
+									//鍥炶皟
+								}
+							);
+						}
 					});
-					$(function() {
+				}
+				
+
+				
+				sendData(IP + "/basis/GetRoleRightList", {}, "get", function (res) {
+					$(function () {
+						$(".approvalBtn").hide();
+					});
+					$(function () {
 						$(".approvalBtndel").hide();
 					});
-					$(function() {
+					$(function () {
 						$(".approvalBtnupt").hide();
 					});
 					if (res.code == 0) //鎴愬姛
 					{
 						for (var k = 0; k < res.data.length; k++) {
-							if (res.data[k].MenuName == "娣诲姞鐗╂枡")
-							{
-								$(function() {
-									$("#approvalBtn").show();
+							if (res.data[k].MenuName == "娣诲姞鐗╂枡") {
+								$(function () {
+									$(".approvalBtn").show();
 								});
 							}
-							if (res.data[k].MenuName == "鍒犻櫎鐗╂枡")
-							{
-								$(function() {
+							if (res.data[k].MenuName == "鍒犻櫎鐗╂枡") {
+								$(function () {
 									$(".approvalBtndel").show();
 								});
 							}
-							if (res.data[k].MenuName == "缂栬緫鐗╂枡")
-							{
-								$(function() {
+							if (res.data[k].MenuName == "缂栬緫鐗╂枡") {
+								$(function () {
 									$(".approvalBtnupt").show();
 								});
 							}
@@ -313,6 +357,7 @@
 					}
 				});
 				
+				
 				var infoOptions = {
 					elem: "#LAY-app-content-list",
 					height: h1,
diff --git a/HTML/views/HouseWithinSetting/CRLogTask.html b/HTML/views/HouseWithinSetting/CRLogTask.html
index 26d6a65..9fd6296 100644
--- a/HTML/views/HouseWithinSetting/CRLogTask.html
+++ b/HTML/views/HouseWithinSetting/CRLogTask.html
@@ -161,6 +161,10 @@
 							html = `<p>鐩樼偣鍗�</p>`; 
 						} else if(d.OrderType=='3') { 
 							html = `<p>绉诲簱鍗�</p>`; 
+						}else if(d.OrderType=='4') { 
+							html = `<p>鍙栨牱鍑哄簱鍗�</p>`; 
+						}else if(d.OrderType=='6') { 
+							html = `<p>瑙嗚鐩樼偣</p>`; 
 						} else {
 							
 						}
diff --git a/HTML/views/HouseWithinSetting/FreezeUnfreeze.html b/HTML/views/HouseWithinSetting/FreezeUnfreeze.html
index b1c4b14..aea0ab3 100644
--- a/HTML/views/HouseWithinSetting/FreezeUnfreeze.html
+++ b/HTML/views/HouseWithinSetting/FreezeUnfreeze.html
@@ -114,8 +114,8 @@
 							<li class="layui-this">鍐荤粨璁板綍</li>
 							<li>瑙e喕璁板綍</li>
                             <div style="float: right;">
-                                <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-dong">鍐荤粨</button>
-                                <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-jie">瑙e喕</button>
+                                <button class="layui-btn layui-btn-sm layuiadmin-btn-list Frozen" lay-submit lay-filter="LAY-app-contlist-dong">鍐荤粨</button>
+                                <button class="layui-btn layui-btn-sm layuiadmin-btn-list Unfrozen" lay-submit lay-filter="LAY-app-contlist-jie">瑙e喕</button>
                             </div>
                            
 						</ul>
@@ -297,7 +297,8 @@
 						limits: pageLimits,
 						even: true,
 						cellMinWidth: 80, //鍏ㄥ眬瀹氫箟甯歌鍗曞厓鏍肩殑鏈�灏忓搴︼紝layui 2.2.1 鏂板
-						done: function(){							
+						done: function(){	
+							setRight();						
 							//鑷畾涔夊垪瀹�
 							SetTableColW('LAY-app-content-list','BllCheck/GetDataFreezeList',TotalColsSysArr);
 						}, 
@@ -384,6 +385,7 @@
 						even: true,
 						cellMinWidth: 80, //鍏ㄥ眬瀹氫箟甯歌鍗曞厓鏍肩殑鏈�灏忓搴︼紝layui 2.2.1 鏂板
 						done: function(){
+							setRight();
 							//鑷畾涔夊垪瀹�
 							SetTableColW('LAY-app-content-list2','BllCheck/GetDataUnFreezeList',DetailColsSysArr);
 						}, 	
@@ -421,6 +423,34 @@
 				});
 				//#endregion				
 			}
+			// 鏉冮檺璁剧疆
+			function setRight() {
+				$(function () {
+					$(".Frozen").hide();
+					$(".Unfrozen").hide();
+				});
+				sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function (res) {
+					if (res.code == 0) { //鎴愬姛 
+						for (var k = 0; k < res.data.length; k++) {
+							if (res.data[k].MenuName == "鍐荤粨") {
+								$(function () {
+									$(".Frozen").show();
+								});
+							}
+							if (res.data[k].MenuName == "瑙e喕") {
+								$(function () {
+									$(".Unfrozen").show();
+								});
+							}
+						}
+					} else { //涓嶆垚鍔�
+						layer.msg('鑾峰彇鏉冮檺淇℃伅澶辫触', {
+							icon: 2,
+							time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+						}, function () { });
+					}
+				});
+			}
 			
 			//var url = IP + "/Statistical/GetInventoryList1";
 
diff --git a/HTML/views/HouseWithinSetting/StockCheck.html b/HTML/views/HouseWithinSetting/StockCheck.html
index 7adf894..e6dfbd0 100644
--- a/HTML/views/HouseWithinSetting/StockCheck.html
+++ b/HTML/views/HouseWithinSetting/StockCheck.html
@@ -188,7 +188,20 @@
 						}}
 						 
 					</script>
-
+				<script type="text/html" id="table-content-list2">
+						{{# 
+								var html = ''; 
+								
+                                if(d.Status >= 1){
+                                    html += `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="viewPicture"> 
+                                                <i class="layui-icon layui-icon-ok"></i>鏌ョ湅鍥剧墖
+                                            </a>`;
+                                }
+								return html;
+							
+						}}
+						 
+					</script>
 				<script type="text/html" id="toolbarDemo">
 
 						<button class="layui-btn layuiadmin-btn-list layui-btn-sm  addClass" lay-event="add">
@@ -401,6 +414,7 @@
 					{ field: 'CreateTime', title: '鍒涘缓鏃堕棿', align: 'center', width: 160, templet: '#CreateTimeButton', },
 					{ field: 'UpdateUserName', title: '淇敼浜�', align: 'center', width: 120, hide: true },
 					{ field: 'UpdateTime', title: '淇敼鏃堕棿', align: 'center', width: 160, hide: true, templet: '#UpdateTimeButton', },
+					{ field: 'caozuo', title: '鎿嶄綔', fixed: 'right', align: 'center', toolbar: '#table-content-list2', width: 100 }
 				]];
 			var TotalColsSysArrm = encodeURIComponent(encodeURIComponent(JSON.stringify(TotalColsArrm)))//灏嗚〃澶存暟鎹繘琛寀rl缂栫爜
 			refreshTable();
@@ -783,7 +797,7 @@
 						}
 					});
 				} else if (obj.event === 'vision') {
-					
+
 					layer.confirm('纭畾瑙嗚鐩樼偣', function () {
 						if (isChongFu == true) {
 							isChongFu = false;
@@ -860,7 +874,24 @@
 					});
 				}
 			});
-
+			table.on('tool(LAY-app-content-list2)', function (obj) {
+				var data = obj.data;
+				if (obj.event === 'viewPicture') {//鏌ョ湅鍥剧墖
+					debugger;
+					layer.open({
+						type: 2,
+						title: '鏌ョ湅鍥剧墖',
+						content: 'ViewPicture.html',
+						maxmin: true,
+						area: ['100%', '100%'],
+						success: function (layero, index) {
+							var body = layer.getChildFrame('body', index);
+							body.find('#CrNo').val(data.CrNo);
+							body.find('#PalletNo').val(data.PalletNo);
+						}
+					});
+				}
+			});
 			var $ = layui.$,
 				active = {
 					customCols: function () {
diff --git a/HTML/views/HouseWithinSetting/ViewPicture.html b/HTML/views/HouseWithinSetting/ViewPicture.html
new file mode 100644
index 0000000..c188431
--- /dev/null
+++ b/HTML/views/HouseWithinSetting/ViewPicture.html
@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <title>鏌ョ湅鍥剧墖</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
+</head>
+
+<body>
+    <input type="hidden" id="CrNo" name="CrNo">
+    <input type="hidden" id="PalletNo" name="PalletNo">
+    <div class="layui-bg-gray" style="padding: 16px;" id="imgDragmove">
+        <div class="layui-row layui-col-space15">
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100101绠�</div>
+              <div class="layui-card-body">
+                <img src="images/1920x1080.jpg" height="200" width="100%" alt="0100101绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100102绠�</div>
+              <div class="layui-card-body">
+                <img src="images/1920x400.jpg" height="200" width="100%" alt="0100102绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100103绠�</div>
+              <div class="layui-card-body">
+                <img src="images/400x400.jpg" height="200" width="100%" alt="0100103绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100104绠�</div>
+              <div class="layui-card-body">
+                <img src="images/400x400.jpg" height="200" width="100%" alt="0100104绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100105绠�</div>
+              <div class="layui-card-body">
+                <img src="images/400x400.jpg" height="200" width="100%" alt="0100105绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100106绠�</div>
+              <div class="layui-card-body">
+                <img src="images/400x400.jpg" height="200" width="100%" alt="0100106绠�">
+              </div>
+            </div>
+          </div>
+          <div class="layui-col-md2">
+            <div class="layui-card">
+              <div class="layui-card-header">0100107绠�</div>
+              <div class="layui-card-body">
+                <img src="images/400x400.jpg" height="200" width="100%" alt="0100107绠�">
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+
+
+    <script src="../../layuiadmin/layui/layui.js"></script>
+    <script src="../../js/jquery-3.5.1.min.js"></script>
+    <script src="../../js/jquery.cookie.js"></script>
+    <script src="../../js/public.js"></script>
+    <script>
+        layui.config({
+            base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
+        }).extend({
+            index: 'lib/index', //涓诲叆鍙fā鍧�
+            dragMove: 'dragMove/dragMove'
+        }).use(['dragMove'], function () {
+            var $ = layui.$;
+            var dragMove = layui.dragMove;
+            //鎵ц绀轰緥
+            dragMove.render({
+                elem: "#imgDragmove", //鎸囧悜鍥剧墖鐨勭埗瀹瑰櫒
+                layerArea: ["960px", "720px"], //寮圭獥鐨勫楂橈紝鍚宭ayer鐨刟rea锛岄粯璁"960px","720px"]
+                layerShade: 0.6, //閬僵鐨勯�忔槑搴︼紝鍚宭ayer鐨剆hade锛岄粯璁�0.6
+                layerMove: false, //瑙﹀彂鎷栧姩鐨勫厓绱狅紝鍚宭ayer鐨刴ove锛岃繖閲岄粯璁ょ姝紝鍙缃负'.layui-layer-title'
+                maxZoom: 1 //鍥剧墖鑳芥斁澶х殑鏈�澶у�嶆暟锛岄粯璁�1鍊�
+            });
+        })
+    </script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/HTML/views/HouseWithinSetting/images/1920x1080.jpg b/HTML/views/HouseWithinSetting/images/1920x1080.jpg
new file mode 100644
index 0000000..6d249ba
--- /dev/null
+++ b/HTML/views/HouseWithinSetting/images/1920x1080.jpg
Binary files differ
diff --git a/HTML/views/HouseWithinSetting/images/1920x400.jpg b/HTML/views/HouseWithinSetting/images/1920x400.jpg
new file mode 100644
index 0000000..5644449
--- /dev/null
+++ b/HTML/views/HouseWithinSetting/images/1920x400.jpg
Binary files differ
diff --git a/HTML/views/HouseWithinSetting/images/400x400.jpg b/HTML/views/HouseWithinSetting/images/400x400.jpg
new file mode 100644
index 0000000..e8d4564
--- /dev/null
+++ b/HTML/views/HouseWithinSetting/images/400x400.jpg
Binary files differ
diff --git a/HTML/views/HouseWithinSetting/images/400x900.jpg b/HTML/views/HouseWithinSetting/images/400x900.jpg
new file mode 100644
index 0000000..24dc8dc
--- /dev/null
+++ b/HTML/views/HouseWithinSetting/images/400x900.jpg
Binary files differ
diff --git a/HTML/views/QualityControl/QualityChangeLog.html b/HTML/views/QualityControl/QualityChangeLog.html
index c48fff2..0a0e60c 100644
--- a/HTML/views/QualityControl/QualityChangeLog.html
+++ b/HTML/views/QualityControl/QualityChangeLog.html
@@ -165,7 +165,7 @@
 							LotNo: LotNo,
 							SkuNo: SkuNo,
 							SkuName: SkuName,
-                            Origin:'Time'
+                            Origin:'WMS'
 						};
 						// console.log(param)
 						var url  = "/BllQuality/GetBllQualityList";
diff --git a/HTML/views/QualityControl/QualityInformation.html b/HTML/views/QualityControl/QualityInformation.html
index 6536610..c8760be 100644
--- a/HTML/views/QualityControl/QualityInformation.html
+++ b/HTML/views/QualityControl/QualityInformation.html
@@ -290,8 +290,9 @@
 
 				// 鏉冮檺璁剧疆
 				function setRight() {
+					
 					$(function() {
-						$("#approvalBtn").hide();
+						$(".approvalBtn").hide(); 
 					});
 					sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function (res) {
 						if (res.code == 0) { //鎴愬姛 
@@ -299,7 +300,7 @@
 								if (res.data[k].MenuName == "娣诲姞璐ㄦ缁撴灉")
 								{
 									$(function() {
-										$("#approvalBtn").show();
+										$(".approvalBtn").show();
 									});
 								}
 							}
diff --git a/HTML/views/SystemSettings/Category.html b/HTML/views/SystemSettings/Category.html
index 5aefbcb..4613a2b 100644
--- a/HTML/views/SystemSettings/Category.html
+++ b/HTML/views/SystemSettings/Category.html
@@ -125,10 +125,49 @@
 							}, function() {});
 						}
 					});
+					sendData(IP + "/basis/GetRoleRightList", {}, 'get', function (res) {
+						$(function () {
+							$(".approvalBtn").hide();
+						});
+						$(function () {
+							$(".approvalBtnupt").hide();
+						});
+						$(function () {
+							$(".approvalBtndel").hide();
+						});
+						if (res.code == 0) { //鎴愬姛
+							for (var k = 0; k < res.data.length; k++) {
+								if (res.data[k].MenuName == "鏂板绫诲埆") {
+									$(function () {
+										$(".approvalBtn").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒犻櫎绫诲埆") {
+									$(function () {
+										$(".approvalBtndel").show();
+									});
+								}
+								if (res.data[k].MenuName == "缂栬緫绫诲埆") {
+									console.log(1)
+									$(function () {
+										$(".approvalBtnupt").show();
+									});
+								}
+							}
+						}
+						else { //涓嶆垚鍔�
+							layer.msg('鑾峰彇淇℃伅澶辫触', {
+								icon: 2,
+								time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+							}, function () {
+								//鍥炶皟
+							});
+						}
+					});
 				}
 				sendData(IP + "/basis/GetRoleRightList", {}, 'get', function(res) {
 					$(function() {
-						$("#approvalBtn").hide();
+						$(".approvalBtn").hide();
 					});
 					$(function() {
 						$(".approvalBtnupt").hide();
@@ -140,7 +179,7 @@
 						for (var k = 0; k < res.data.length; k++) {
 							if (res.data[k].MenuName == "鏂板绫诲埆") {
 								$(function() {
-									$("#approvalBtn").show();
+									$(".approvalBtn").show();
 								});
 							}
 							if (res.data[k].MenuName == "鍒犻櫎绫诲埆") {
diff --git a/HTML/views/SystemSettings/Dictionary.html b/HTML/views/SystemSettings/Dictionary.html
index af6d469..d421a3c 100644
--- a/HTML/views/SystemSettings/Dictionary.html
+++ b/HTML/views/SystemSettings/Dictionary.html
@@ -206,10 +206,49 @@
 							}, function() {});
 						}
 					});
+				
+				sendData(IP + "/basis/GetRoleRightList", {}, 'get', function (res) {
+						$(function () {
+							$(".approvalBtn").hide();
+						});
+						$(function () {
+							$(".approvalBtnupt").hide();
+						});
+						$(function () {
+							$(".approvalBtndel").hide();
+						});
+						if (res.code == 0) { //鎴愬姛
+							for (var k = 0; k < res.data.length; k++) {
+								if (res.data[k].MenuName == "娣诲姞瀛楀吀") {
+									$(function () {
+										$(".approvalBtn").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒犻櫎瀛楀吀") {
+									$(function () {
+										$(".approvalBtndel").show();
+									});
+								}
+								if (res.data[k].MenuName == "缂栬緫瀛楀吀") {
+									$(function () {
+										$(".approvalBtnupt").show();
+									});
+								}
+							}
+						}
+						else { //涓嶆垚鍔�
+							layer.msg('鑾峰彇淇℃伅澶辫触', {
+								icon: 2,
+								time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+							}, function () {
+								//鍥炶皟
+							});
+						}
+					});
 				}
 				sendData(IP + "/basis/GetRoleRightList", {}, 'get', function(res) {
 					$(function() {
-						$("#approvalBtn").hide();
+						$(".approvalBtn").hide();
 					});
 					$(function() {
 						$(".approvalBtnupt").hide();
@@ -221,7 +260,7 @@
 						for (var k = 0; k < res.data.length; k++) {
 							if (res.data[k].MenuName == "娣诲姞瀛楀吀") {
 								$(function() {
-									$("#approvalBtn").show();
+									$(".approvalBtn").show();
 								});
 							}
 							if (res.data[k].MenuName == "鍒犻櫎瀛楀吀") {
diff --git a/HTML/views/SystemSettings/PrintModule.html b/HTML/views/SystemSettings/PrintModule.html
new file mode 100644
index 0000000..5298460
--- /dev/null
+++ b/HTML/views/SystemSettings/PrintModule.html
@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+	<meta charset="utf-8">
+	<title>鎵撳嵃妯℃澘淇℃伅缁存姢</title>
+	<meta name="renderer" content="webkit">
+	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+	<meta name="viewport"
+		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+	<link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
+	<link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/hiprint.css?t=' + Math.random() + '" />
+	<link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/print-lock.css" />
+	<link rel="stylesheet" media="print" href="../../js/HiPrint/css/print-lock.css" />
+	<!-- <link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/bootstrap.min.css" > -->
+	<style>
+		.layui-form-label {
+			padding: 5px 1px;
+			text-align: center;
+		}
+
+		div {
+			font-size: inherit;
+		}
+	</style>
+</head>
+
+<body>
+	<div class="layui-card">
+		<input type="hidden" id="printData" name="printData">
+		<input type="hidden" id="printType" name="printType">
+		<div class="row">
+
+			<!--宸︿晶div-->
+			<div class="layui-col-xs2" style="padding-right:0px;max-height:250mm;">
+				<div class="small-printElement-types hiprintEpContainer">
+				</div>
+			</div>
+			<!--鎵撳嵃閮ㄥ垎-->
+			<div class="layui-col-xs6" style="margin-right: 50px;margin-left: 30px;">
+				<!--鎵撳嵃澶撮儴鍒�-->
+				<div class="hiprint-toolbar" style="margin-top:15px;">
+					<ul>
+						<li><a class="hiprint-toolbar-item"><input type="number" id="customWidth"
+									style="width: 50px;height: 19px;border: 0px;" placeholder="瀹�/mm" /></a></li>
+						<li><a class="hiprint-toolbar-item"><input type="number" id="customHeight"
+									style="width: 50px;height: 19px;border: 0px;" placeholder="楂�/mm" /></a></li>
+						<li><a class="hiprint-tizee-btn" onclick="clearTemplate()">娓呯┖</a></li>
+						<!-- <li> <a class="btn hiprint-toolbar-item "
+								style="color: #fff;background-color: #d9534f;border-color: #d43f3a;"
+								id="preview">蹇�熼瑙�</a> </li> -->
+						<li> <a id="directPrint" class="btn hiprint-toolbar-item "
+								style="color: #fff;background-color: #d9534f; border-color: #d43f3a;">鎵撳嵃</a>
+						</li>
+						<!-- <li>
+							<a class="btn hiprint-toolbar-item"
+								style="color: #fff;background-color: #d9534f; border-color: #d43f3a;"
+								id="A4_getJson_toTextarea" onclick="BtnSubmit_Click()">淇濆瓨</a>
+						</li> -->
+					</ul>
+					<div style="clear:both;"></div>
+				</div>
+				<!--鎵撳嵃涓讳綋閮ㄥ垎-->
+				<div id="hiprint-printTemplate" class="hiprint-printTemplate" style="margin-top:20px;">
+
+				</div>
+				<textarea class="form-control" rows="10" id="A4_textarea_json" style="display: none;"></textarea>
+			</div>
+			<!--鍙充晶div-->
+			<div class="layui-col-xs2" style="margin-left: 6%;max-height:260mm; overflow-y: scroll;">
+				<div id="PrintElementOptionSetting" style="margin-top: 10px;"></div>
+			</div>
+		</div>
+	</div>
+
+	<script src="../../js/jquery-3.5.1.min.js"></script>
+	<script src="../../js/jquery.cookie.js"></script>
+	<script src="../../js/hiprint/content/bootstrap.min.js"></script>
+	<script src="../../js/HiPrint/polyfill.min.js"></script>
+	<script src="../../js/HiPrint/plugins/jquery.minicolors.min.js"></script>
+	<script src="../../js/HiPrint/plugins/JsBarcode.all.min.js"></script>
+	<script src="../../js/HiPrint/plugins/qrcode.js"></script>
+	<script src="../../js/HiPrint/hiprint.bundle.js"></script>
+	<script src="../../js/HiPrint/plugins/jquery.hiwprint.js"></script>
+	<!-- <script src="../../js/HiPrint/plugins/socket.io.js"></script> -->
+	<script src="../../js/HiPrint/plugins/config-etype-provider.js"></script>
+	<script src="../../js/HiPrint/plugins/jspdf/canvas2image.js"></script>
+	<script src="../../js/HiPrint/plugins/jspdf/canvg.min.js"></script>
+	<script src="../../js/HiPrint/plugins/jspdf/html2canvas.min.js"></script>
+	<script src="../../js/HiPrint/plugins/jspdf/jspdf.min.js"></script>
+	<script src="../../js/HiPrint/plugins/print-data-list.js"></script>
+	<script src="../../js/HiPrint/hiprint.config.js"></script>
+	<script src="../../layuiadmin/layui/layui.js"></script>
+	<script src="../../js/public.js"></script>
+	<script>
+		var configPrintJson;
+		var datalist = [];
+		//鍒濆鍖栨墦鍗版彃浠舵覆鏌�
+		$(".hiprintEpContainer").html(""); //娓呴櫎div鍐呭
+
+
+
+		var hiprintTemplate;
+		// var JsonData = JSON.parse('{"panels":[{"index":0,"height":50,"width":50,"paperHeader":0,"paperFooter":141.73228346456693,"printElements":[{"tid":"configModule.SkuName","options":{"left":9,"top":12,"height":9.75,"width":120}},{"tid":"configModule.SkuNo","options":{"left":9,"top":37.5,"height":78,"width":120,"textType":"qrcode"}}],"paperNumberLeft":178.5,"paperNumberTop":123}]}')
+		var JsonData = {};
+		setTimeout(function () {
+			var printType = $("#printType").val();
+			datalist = getPrintDataList()(printType);
+			synData(IP + "/sys/GetDefaultPrintTemplate?Type=" + printType, {}, 'get', function (res) {
+				if (res.code == 0) { //鎴愬姛
+					hiprint.init({
+						providers: [new configElementTypeProvider()]
+					});
+					//璁剧疆宸︿晶鎷栨嫿浜嬩欢
+					hiprint.PrintElementTypeManager.build('.hiprintEpContainer', 'testModule');
+					JsonData = JSON.parse(res.data.PositionJson);
+					$("#customWidth").val(JsonData.panels[0].width);
+					$("#customHeight").val(JsonData.panels[0].height);
+					hiprintTemplate = new hiprint.PrintTemplate({
+						template: JsonData,//妯℃澘JSON
+						settingContainer: '#PrintElementOptionSetting',
+						paginationContainer: '.hiprint-printPagination'
+					});
+
+					//鎵撳嵃璁捐
+					hiprintTemplate.design('#hiprint-printTemplate');
+
+					//鎵撳嵃
+					//杩欓噷鑾峰彇涓婄骇椤甸潰鐨刾rintData鏁版嵁鎵撳嵃
+					// var printData = deepClone(parent.printData);
+					var printData = JSON.parse($("#printData").val());
+					hiprintTemplate.print(printData, '鎵撳嵃');
+					parent.layer.closeAll();
+				}
+				else //涓嶆垚鍔�
+				{
+					layer.msg(res.msg, {
+						icon: 2,
+						time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+					}, function () { parent.layer.closeAll(); });
+				}
+			});
+		}, 100);
+
+
+
+		$('#directPrint').click(function () {
+			hiprintTemplate.print(printData);
+		});
+	</script>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/HTML/views/SystemSettings/Role.html b/HTML/views/SystemSettings/Role.html
index 7c65efe..b3826ec 100644
--- a/HTML/views/SystemSettings/Role.html
+++ b/HTML/views/SystemSettings/Role.html
@@ -122,6 +122,58 @@
 							);
 						}
 					});
+					sendData(IP + "/basis/GetRoleRightList", {}, "get", function (res) {
+						$(function () {
+							$("#approvalBtn").hide();
+						});
+						$(function () {
+							$(".editClass").hide();
+						});
+						$(function () {
+							$(".roleClass").hide();
+						});
+						$(function () {
+							$(".approvalBtndel").hide();
+						});
+						if (res.code == 0) {
+							//鎴愬姛
+							for (var k = 0; k < res.data.length; k++) {
+								if (res.data[k].MenuName == "缂栬緫瑙掕壊") {
+									$(function () {
+										$(".editClass").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒嗛厤鏉冮檺") {
+									$(function () {
+										$(".roleClass").show();
+									});
+								}
+								if (res.data[k].MenuName == "娣诲姞瑙掕壊") {
+									$(function () {
+										$("#approvalBtn").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒犻櫎瑙掕壊") {
+									$(function () {
+										$(".approvalBtndel").show();
+									});
+								}
+							}
+						}
+						else {
+							//涓嶆垚鍔�
+							layer.msg(
+								"鑾峰彇淇℃伅澶辫触",
+								{
+									icon: 2,
+									time: 2000, //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+								},
+								function () {
+									//鍥炶皟
+								}
+							);
+						}
+					});
 				}
 				sendData(IP + "/basis/GetRoleRightList", {}, "get", function (res) {
 					$(function() {
diff --git a/HTML/views/SystemSettings/UserManage.html b/HTML/views/SystemSettings/UserManage.html
index 7264537..a1383c8 100644
--- a/HTML/views/SystemSettings/UserManage.html
+++ b/HTML/views/SystemSettings/UserManage.html
@@ -165,7 +165,83 @@
 							}, function() {});
 						}
 					});
+					var xml = '';
+					function getchiled(data, mainId) {
+						if (data) {
+							var list = data.filter(item => item.ParentId == mainId);
+							if (list) {
+								for (var i = 0; i < list.length; i++) {
+									var id = list[i].Id;
+									//鏌ヨ鏈夋棤瀛愯彍鍗�
+									var count = data.filter(item => item.ParentId == id).length;
+									if (count > 0) {
+										xml = xml + '<dd>' + '<a href="javascript:;">' + list[i].Name + '</a>' + '<dl class="layui-nav-child">';
+										getchiled(data, id);
+										xml = xml + '</dl></dd>';
+									}
+									else {
+										xml = xml + '<dd>' + '<a lay-href="' + list[i].Url + '">' + list[i].Name + '</a>' + '</dd>';
+									}
+								}
+							}
+						}
+					}
 
+					sendData(IP + "/basis/GetRoleRightList", {}, 'get', function (res) {
+						$(function () {
+							$("#approvalBtn").hide();
+						});
+						$(function () {
+							$(".approvalBtndel").hide();
+						});
+						$(function () {
+							$(".approvalBtnupt").hide();
+						});
+						if (res.code == 0) //鎴愬姛
+						{
+							var list = res.data.filter(item => item.Layer == 0);
+							if (list) {
+								for (var i = 0; i < list.length; i++) {
+									xml = xml + '<li class="layui-nav-item">' + '<a href="javascript:;" lay-tips=' + list[i].Icon + ' lay-direction="2">' + '<span class="iconfont ' + list[i].Icon + '"></span>' + '<cite>' + list[i].MenuName + '</cite>' + '</a>';
+									var id = list[i].Id;
+									//鏌ヨ鏈夋棤瀛愯彍鍗�	
+									var count = res.data.filter(item => item.ParentId == id).length;
+									if (count > 0) {
+										xml = xml + '<dl class="layui-nav-child">';
+										getchiled(res.data, id);
+										xml = xml + '</dl>';
+									}
+									xml = xml + '</li>'
+								}
+							}
+							for (var k = 0; k < res.data.length; k++) {
+								if (res.data[k].MenuName == "娣诲姞鐢ㄦ埛") {
+									$(function () {
+										$("#approvalBtn").show();
+									});
+								}
+								if (res.data[k].MenuName == "鍒犻櫎鐢ㄦ埛") {
+									$(function () {
+										$(".approvalBtndel").show();
+									});
+								}
+								if (res.data[k].MenuName == "缂栬緫鐢ㄦ埛") {
+									$(function () {
+										$(".approvalBtnupt").show();
+									});
+								}
+							}
+						}
+						else //涓嶆垚鍔�
+						{
+							layer.msg('鑾峰彇淇℃伅澶辫触', {
+								icon: 2,
+								time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+							}, function () {
+								//鍥炶皟
+							});
+						}
+					})
 				}
 				var xml = '';
 				function getchiled(data, mainId) {
@@ -193,6 +269,7 @@
 						}
 					}
 				}
+				
 				sendData(IP + "/basis/GetRoleRightList", {}, 'get', function(res) {
 					$(function() {
 						$("#approvalBtn").hide();
@@ -251,6 +328,7 @@
 						});
 					}
 				})
+				
 				var infoOptions = {
 					elem: '#LAY-app-content-list',
 					height: h1,
diff --git a/Pda/View/AsnSetting/productEnterQuantity.html b/Pda/View/AsnSetting/productEnterQuantity.html
index 24537f3..53fecbf 100644
--- a/Pda/View/AsnSetting/productEnterQuantity.html
+++ b/Pda/View/AsnSetting/productEnterQuantity.html
@@ -587,7 +587,7 @@
                     form.render('select');
 
                     var param = {
-                        Type: "0,1,3,4,5,6"
+                        Type: "0,3"
                     };
                     sendData(IP + "/PdaAsn/GetArrivalNotices", param, 'post', function (res) {
                         if (res.code == 0) { //鎴愬姛
@@ -622,7 +622,7 @@
                     form.render('select');
 
                     var param = {
-                        Type: "1,2,3,4,5,6"
+                        Type: "1,2,4"
                     };
                     sendData(IP + "/PdaAsn/GetArrivalNotices", param, 'post', function (res) {
                         if (res.code == 0) { //鎴愬姛
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/HouseDataSetting/stockCheck.html b/Pda/View/HouseDataSetting/stockCheck.html
index 1ce8639..82897ac 100644
--- a/Pda/View/HouseDataSetting/stockCheck.html
+++ b/Pda/View/HouseDataSetting/stockCheck.html
@@ -583,6 +583,7 @@
 								refreshTable()
 								GetOutInfo()
 								canPickBox = true
+								form.render('select')
 							});
 
 						} else { //涓嶆垚鍔�
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/Pda/View/SoSetting/pingKuOut.html b/Pda/View/SoSetting/pingKuOut.html
index 20043e3..e8c5d73 100644
--- a/Pda/View/SoSetting/pingKuOut.html
+++ b/Pda/View/SoSetting/pingKuOut.html
@@ -186,6 +186,8 @@
 					Type: "1",
 				};
 				synData(IP + "/PdaSo/GetRunSoNoticeList", param, 'post', function (res) {
+					console.log(res);
+
 					if (res.code == 0) { //鎴愬姛
 						console.log(res.data);
 						for (var i = 0; i < res.data.length; i++) {
@@ -280,6 +282,8 @@
 					"PalletNo": $("#PalletNo").val()
 				}
 				synData(IP + "/PdaSo/IsEnableOkPalletNo", param, 'post', function (res) {
+					console.log("AAA");
+					console.log(res);
 
 					if (res.code == 0) { //鎴愬姛 
 						updateBillList();
diff --git a/Pda/js/public.js b/Pda/js/public.js
index f5ee6a9..5217d3a 100644
--- a/Pda/js/public.js
+++ b/Pda/js/public.js
@@ -1,8 +1,8 @@
 //  var IP = "http://47.104.149.73:1991";//鎺ュ彛IP
 // var IP = "https://localhost:44368";
- //var IP = "http://localhost:13243/api";
- var IP = "http://localhost:50515/api";
- //var IP = "http://192.168.1.2:8017/";
+//var IP = "http://localhost:13243/api";
+var IP = "http://localhost:50515/api";
+//var IP = "http://192.168.1.2:8017/";
 // var IP = "http://192.168.10.112/WmsService/";
 // var IP = "http://192.168.1.226:8086";
 // var IP = "http://192.168.62.200:8888/api";  
@@ -10,92 +10,141 @@
 function sendData(url, data, type, callbackFun) {
 	// callbackFun("{}");
 	// return;
-	
- 	var deferred = $.Deferred();
- 	if (type != "get") {
+	var deferred = $.Deferred();
+	if (type != "get") {
 		data = JSON.stringify(data);
-	} 
-	if (url!=IP+"/WeatherForecast/Login") {
+	}
+	if (url != IP + "/WeatherForecast/Login") {
 		if (!$.cookie('token')) {
 			callbackFun("鐧诲綍浜轰俊鎭凡澶辨晥");
+			try {
+				parent.window.location.href = '/views/Login.html';
+			}
+			catch (error) {
+				window.location.href = '/views/Login.html';
+			}
+			return;
 		}
-	} 
- 	$.ajax({
- 		url: url,
- 		data: data,
- 		type: type,
- 		headers: {
- 			'Content-Type': 'application/json',
-			"ToKen":$.cookie('token')
- 		},
- 		timeout: 45000,
- 		async: true,
- 		cache: false,
- 		beforeSend: function(xhr, settings) {},
- 		success: function(res, status, xhr) {
- 			callbackFun(res);
- 		},
- 		error: function(xhr, status, error) {
+		if (isTokenExpired($.cookie('token'))) {
+			try {
+				parent.window.location.href = '/views/Login.html';
+			}
+			catch (error) {
+				window.location.href = '/views/Login.html';
+			}
+			return;
+		}
+	}
+	$.ajax({
+		url: url,
+		data: data,
+		type: type,
+		headers: {
+			'Content-Type': 'application/json',
+			"ToKen": $.cookie('token')
+		},
+		timeout: 45000,
+		async: true,
+		cache: false,
+		beforeSend: function (xhr, settings) { },
+		success: function (res, status, xhr) {
+			callbackFun(res);
+		},
+		error: function (xhr, status, error) {
 			callbackFun(xhr, status, error);
 			// layer.msg(xhr.statusText, {
 			//   icon: 2,
 			//   time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
 			// }, function() {});
- 		}
- 	});
+		}
+	});
 }
 function synData(url, data, type, callbackFun) {
 	var deferred = $.Deferred();
 	if (type != "get") {
 		data = JSON.stringify(data);
-	} 
-	if (url!=IP+"/WeatherForecast/Login") {
+	}
+	if (url != IP + "/WeatherForecast/Login") {
 		if (!$.cookie('token')) {
 			callbackFun("鐧诲綍浜轰俊鎭凡澶辨晥");
+			try {
+				parent.window.location.href = '/view/Login.html';
+			}
+			catch (error) {
+				window.location.href = '/view/Login.html';
+			}
+			return;
 		}
-	} 
+		if (isTokenExpired($.cookie('token'))) {
+			try {
+				parent.window.location.href = '/view/Login.html';
+			}
+			catch (error) {
+				window.location.href = '/view/Login.html';
+			}
+			return;
+		}
+	}
 	$.ajax({
-	  url: url,
-	  data: data,
-	  type: type,
-	  headers: {
-		"Content-Type": "application/json",
-		"ToKen":$.cookie('token'),
-	  },
-	  timeout: 45000,
-	  async: false,
-	  cache: false,
-	  beforeSend: function (xhr, settings) {},
-	  success: function (res, status, xhr) {
-		callbackFun(res);
-	  },
-	  error: function (xhr, status, error) {
-		console.log("澶辫触浜�");
-		console.log(xhr);
-		callbackFun(xhr, status, error);
-	  },
+		url: url,
+		data: data,
+		type: type,
+		headers: {
+			"Content-Type": "application/json",
+			"ToKen": $.cookie('token'),
+		},
+		timeout: 45000,
+		async: false,
+		cache: false,
+		beforeSend: function (xhr, settings) { },
+		success: function (res, status, xhr) {
+			callbackFun(res);
+		},
+		error: function (xhr, status, error) {
+			console.log("澶辫触浜�");
+			console.log(xhr);
+			callbackFun(xhr, status, error);
+		},
 	});
 }
-  
-$("#navIcon").click(function(){
-    if($(".nav_list").css('display')=='none'){
-        $(".nav_list").show();
-    }else{
-        $(".nav_list").hide();
-    }
+
+$("#navIcon").click(function () {
+	if ($(".nav_list").css('display') == 'none') {
+		$(".nav_list").show();
+	} else {
+		$(".nav_list").hide();
+	}
 });
 
 //娣辨嫹璐�
 function deepCopy(obj) {
 	let newobj = null     // 鎺ュ彈鎷疯礉鐨勬柊瀵硅薄
-	if(typeof(obj) == 'object' && typeof(obj) !== null) {   // 鍒ゆ柇鏄惁鏄紩鐢ㄧ被鍨�
-		newobj = obj instanceof Array? []: {}               // 鍒ゆ柇鏄暟缁勮繕鏄璞�
-		for(var i in obj) {   
+	if (typeof (obj) == 'object' && typeof (obj) !== null) {   // 鍒ゆ柇鏄惁鏄紩鐢ㄧ被鍨�
+		newobj = obj instanceof Array ? [] : {}               // 鍒ゆ柇鏄暟缁勮繕鏄璞�
+		for (var i in obj) {
 			newobj[i] = deepCopy(obj[i])                        // 鍒ゆ柇涓嬩竴绾ф槸鍚﹁繕鏄紩鐢ㄧ被鍨�
-		} 
+		}
 	} else {
 		newobj = obj
 	}
-	
+
 	return newobj
 }
+
+function isTokenExpired(token) {
+	const tokenParts = token.split('.');
+	if (tokenParts.length !== 3) {
+	  return true; // JWT 鏍煎紡涓嶆纭�
+	}
+	const payloadBase64 = tokenParts[1];
+	const payload = JSON.parse(atob(payloadBase64));
+	
+	if (!payload || !payload.exp) {
+	  return true; // 娌℃湁鏈夋晥杞借嵎鎴栬�呮病鏈夎繃鏈熸椂闂�
+	}
+	
+	const now = Date.now() / 1000; // 褰撳墠鏃堕棿鎴筹紙绉掞級
+	const expiration = payload.exp;
+	
+	return now >= expiration;
+  }
\ No newline at end of file
diff --git a/Wms/Model/ModelDto/BllAsnDto/PalletUpShelfDto.cs b/Wms/Model/ModelDto/BllAsnDto/PalletUpShelfDto.cs
new file mode 100644
index 0000000..268a877
--- /dev/null
+++ b/Wms/Model/ModelDto/BllAsnDto/PalletUpShelfDto.cs
@@ -0,0 +1,89 @@
+锘縰sing Model.ModelDto.SysDto;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model.ModelDto.BllAsnDto
+{
+    public class PalletUpShelfDto
+    {
+        public int Id { get; set; }
+        /// <summary>
+        /// 杩芥函鍙�  --鍏ュ簱鍗曞彿
+        /// </summary>
+        public string TraceNo { get; set; }
+
+        /// <summary>
+        /// 浠诲姟鍙�
+        /// </summary>
+        public string TaskNo { get; set; }
+        /// <summary>
+        /// 鎵樼洏鍙�
+        /// </summary>
+        public string PalletNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡缂栫爜
+        /// </summary>
+        public string SkuNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡鍚嶇О
+        /// </summary>
+        public string SkuName { get; set; }
+        /// <summary>
+        /// 鎵规鍙�
+        /// </summary>
+        public string LotNo { get; set; }
+        /// <summary>
+        /// 鐘舵��
+        /// </summary>
+        public string Status { get; set; }
+        /// <summary>
+        /// 浠撳簱
+        /// </summary>
+        public string WareHouseNo { get; set; }
+
+        /// <summary>
+        /// 浠撳簱鍚嶇О
+        /// </summary>
+        public string WareHouseName { get; set; }
+        /// <summary>
+        /// 宸烽亾
+        /// </summary>
+        public string RoadwayNo { get; set; }
+        /// <summary>
+        /// 宸烽亾鍚嶇О
+        /// </summary>
+        public string RoadwayName { get; set; }
+        /// <summary>
+        /// 鍖哄煙
+        /// </summary>
+        public string AreaNo { get; set; }
+        /// <summary>
+        /// 鍖哄煙鍚嶇О
+        /// </summary>
+        public string AreaName { get; set; }
+        /// <summary>
+        /// 鍌ㄤ綅
+        /// </summary>
+        public string LocatNo { get; set; }
+
+
+        /// <summary>
+        /// 鍒涘缓鏃堕棿
+        /// </summary>
+        public DateTime CreateTime { get; set; }
+        /// <summary>
+        /// 鍒涘缓浜哄悕绉�
+        /// </summary>
+        public string CreateUserName { get; set; }
+
+        /// <summary>
+        /// 淇敼鏃堕棿
+        /// </summary>
+        public DateTime? UpdateTime { get; set; }
+        /// <summary>
+        /// 淇敼浜哄悕绉�
+        /// </summary>
+        public string UpdateUserName { get; set; }
+    }
+}
diff --git a/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs b/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
index d7af22e..7171287 100644
--- a/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
+++ b/Wms/Model/ModelDto/PdaDto/PdaSoDto.cs
@@ -7,17 +7,17 @@
     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; }                           // 鐗╂枡缂栧彿
     }
     public class BoxInfo
     {
         public string BoxNo { get; set; }                     // 绠辩爜/鏀爜
-        public decimal Qty { get; set; }                       // 绠卞唴鏁伴噺 
+        public decimal? Qty { get; set; }                       // 绠卞唴鏁伴噺 
         public string SkuNo { get; set; }                   // 鐗╂枡缂栫爜 
         public string SkuName { get; set; }                 // 鐗╂枡鍚嶇О
         public string LotNo { get; set; }                   // 鎵规 
diff --git a/Wms/Model/ModelVm/BllAsnVm/PalletUpShelfVm.cs b/Wms/Model/ModelVm/BllAsnVm/PalletUpShelfVm.cs
new file mode 100644
index 0000000..8958280
--- /dev/null
+++ b/Wms/Model/ModelVm/BllAsnVm/PalletUpShelfVm.cs
@@ -0,0 +1,43 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Model.ModelVm.BllAsnVm
+{
+    /// <summary>
+    /// 涓婃灦浠诲姟璁板綍Vm
+    /// </summary>
+    public class PalletUpShelfVm : IndexPage
+    {
+        /// <summary>
+        /// 杩芥函鍙�  --鍏ュ簱鍗曞彿
+        /// </summary>
+        public string TraceNo { get; set; }
+
+        /// <summary>
+        /// 浠诲姟鍙�
+        /// </summary>
+        public string TaskNo { get; set; }
+        /// <summary>
+        /// 鎵樼洏鍙�
+        /// </summary>
+        public string PalletNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡缂栫爜
+        /// </summary>
+        public string SkuNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡鍚嶇О
+        /// </summary>
+        public string SkuName { get; set; }
+        /// <summary>
+        /// 鎵规鍙�
+        /// </summary>
+        public string LotNo { get; set; }
+        /// <summary>
+        /// 鐘舵��
+        /// </summary>
+        public string Status { get; set; }
+
+    }
+}
diff --git a/Wms/Model/ModelVm/BllCheckVm/StockCheckVm.cs b/Wms/Model/ModelVm/BllCheckVm/StockCheckVm.cs
index 0558089..a67e6e5 100644
--- a/Wms/Model/ModelVm/BllCheckVm/StockCheckVm.cs
+++ b/Wms/Model/ModelVm/BllCheckVm/StockCheckVm.cs
@@ -99,4 +99,32 @@
     { 
         public string taskNo { get; set; }
     }
+
+    public class CheckVm
+    {
+        /// <summary>
+        /// 鍗曟嵁鍙�
+        /// </summary>
+        public string CrNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡缂栫爜
+        /// </summary>
+        public string SkuNo { get; set; }
+        /// <summary>
+        /// 鎵规
+        /// </summary>
+        public string LotNo { get; set; }
+        /// <summary>
+        /// 鎵樼洏鍙�
+        /// </summary>
+        public string PalletNo { get; set; }
+        /// <summary>
+        /// 绠辩爜鍙�
+        /// </summary>
+        public string BoxNo { get; set; }
+        /// <summary>
+        /// 鏀爜鍙�
+        /// </summary>
+        public List<string> BoxNo3 { 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/Utility/Filter/CustomerExceptionFilter.cs b/Wms/Utility/Filter/CustomerExceptionFilter.cs
index 2c2c54d..051506a 100644
--- a/Wms/Utility/Filter/CustomerExceptionFilter.cs
+++ b/Wms/Utility/Filter/CustomerExceptionFilter.cs
@@ -28,11 +28,11 @@
             // 濡傛灉寮傚父娌℃湁琚鐞嗗垯杩涜澶勭悊
             if (context.ExceptionHandled == false)
             {
-                var result = "绯荤粺寮傚父锛岃鑱旂郴绠$悊鍛�";
-                if (context.Exception is AppFriendlyException)
-                    result = context.Exception.Message;
+                //var result = "绯荤粺寮傚父锛岃鑱旂郴绠$悊鍛�";
+                //if (context.Exception is AppFriendlyException)
+                var result = context.Exception.Message;
                 var apiResponse = new ApiResponse<object>(
-                        code: (int)ResponseEnum.Error,
+                        code: (int)ResponseEnum.Fail,
                         message: result,
                         data: result
                     );
diff --git a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
index 93c6c16..ba41cd5 100644
--- a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -92,7 +92,7 @@
                 .LeftJoin<BllArrivalNotice>((tb1, tb2) => tb1.ASNNo == tb2.ASNNo)
                 .LeftJoin<SysUserInfor>((tb1, tb2,tb3) => tb1.CreateUser == tb3.Id)
                 .LeftJoin<SysUserInfor>((tb1,tb2,tb3,tb4) => tb1.UpdateUser == tb4.Id)
-                .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4,tb5) => tb1.SkuNo == tb5.SkuNo)
+                .LeftJoin<SysMaterials>((tb1, tb2, tb3, tb4,tb5) => tb1.SkuNo == tb5.SkuNo && tb5.IsDel == "0")
                 .LeftJoin<SysUnit>((tb1, tb2, tb3, tb4, tb5,tb6) => tb5.UnitNo == tb6.UnitNo)
                 .LeftJoin<SysPackag>((tb1, tb2, tb3, tb4, tb5, tb6,tb7) => tb1.PackagNo == tb7.PackagNo)
                 .Select((tb1, tb2, tb3, tb4, tb5,tb6, tb7) => new ArrivalNoticeDetailDto()
@@ -492,6 +492,7 @@
                     string toDayTime = dateTime.ToString("yyyymmdd");
                     List<BllArrivalNoticeDetail> addDetails = new List<BllArrivalNoticeDetail>();
                     List<BllArrivalNoticeDetail> editDetails = new List<BllArrivalNoticeDetail>();
+                    var maxLotNo = "";
                     foreach (ArrivalNoticeDetailVm detailModel in detailModels)
                     {
                         if (string.IsNullOrEmpty(detailModel.SkuNo))
@@ -534,7 +535,10 @@
                         if (detailModel.Id == 0 || detailModel.Id == null || string.IsNullOrWhiteSpace(detailModel.LotNo))
                         {
                             var notice = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && TypeLot.Contains(m.Type)).Select(m => m.ASNNo).ToList();
-                            var maxLotNo = Db.Queryable<BllArrivalNoticeDetail>().Where(m=>m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LotNo) && notice.Contains(m.ASNNo)).Max(m=>m.LotNo);
+                            if (string.IsNullOrWhiteSpace(maxLotNo))
+                            {
+                                maxLotNo = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LotNo) && notice.Contains(m.ASNNo)).Max(m => m.LotNo);
+                            }
                             if (string.IsNullOrWhiteSpace(maxLotNo))
                             {
                                 maxLotNo = toDayTime.Substring(2, 6) + "0001";
diff --git a/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs b/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
index ffc8278..4c0e2f0 100644
--- a/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/PalletBindServer.cs
@@ -97,9 +97,9 @@
                         throw new Exception("褰撳墠鐗╂枡鍙婃壒娆′笌鍗曟嵁鏃犲叧鑱旓紝璇锋牳瀹�!");
                     }
                 }
-               
-                
-               
+
+
+
 
                 #endregion
 
@@ -113,13 +113,13 @@
                 {
                     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 == model.SkuNo);
-                SysPackag pack = null ;
+                SysPackag pack = null;
                 if (model.Type == "0")
                 {
                     pack = package.First(m => m.IsDel == "0" && m.PackagNo == detail.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
@@ -128,7 +128,7 @@
                 {
                     pack = package.First(m => m.IsDel == "0" && m.PackagNo == sku.PackagNo);    // liudl 鐢盨ku鍖呰缂栧彿鍙樻洿涓哄叆搴撳崟鏄庣粏鍖呰缂栧彿
                 }
-                
+
 
                 var pNum = 0;//鎵樼洏鐗╁搧鏁伴噺 
                 var bNum = 0;//绠辩爜鐗╁搧鏁伴噺 
@@ -172,7 +172,7 @@
                 #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
                 var list = model.Detail.GroupBy(m => new { m.SkuNo, m.LotNo }).ToList();
 
-                if (list.Count>=2)
+                if (list.Count >= 2)
                 {
                     var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
                     if (funSetting == null || funSetting.IsEnable == "OFF")
@@ -180,7 +180,7 @@
                         throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
                     }
                 }
-                 
+
                 #endregion
 
                 //liudl  && m.Status != "2"  缁勭洏鏃㈠叆搴撳畬鎴愭棤闇�鏍规嵁鎵樼洏鐘舵�佸垽鏂�
@@ -204,10 +204,10 @@
                         SupplierLot = model.SupplierLot,
                         //InspectMark = model.IsSample,      //鏄惁鍙栨牱鎵樼洏  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
                         //SamplingQty = 0,     //鍙栨牱鏁伴噺  鍚庢湡涓氬姟寮�鍙戞椂 鎺ュ彛浼犲�奸渶娣诲姞瀵瑰簲瀛楁鍒ゆ柇
-                        BitPalletMark = model.Qty == pNum ? "0": "1",
+                        BitPalletMark = model.Qty == pNum ? "0" : "1",
                         IsBale = "0",
                         IsBelt = "0",
-                        CreateUser = userId, 
+                        CreateUser = userId,
 
                     };
                     if (bind.FullQty < bind.Qty)
@@ -242,7 +242,7 @@
                     sd1 = Db.Queryable<DataStockDetail>()
                   .First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
                 }
-               
+
                 var sdId1 = 0;
                 if (sd1 != null)
                 {
@@ -280,11 +280,11 @@
                         InspectMark = bind.InspectMark,
                         InspectStatus = sku.IsInspect,
                         BitPalletMark = bind.BitPalletMark,
-                        PackagNo = model.Type =="0"? detail.PackagNo : sku.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
+                        PackagNo = model.Type == "0" ? detail.PackagNo : sku.PackagNo,                    //liudl 鐢眘ku鐨勫寘瑁呯紪鍙峰彉涓哄叆搴撳崟鏄庣粏鐨勫寘瑁呯紪鐮�       
                         IsBale = bind.IsBale,
                         IsBelt = bind.IsBelt,
-                        OwnerNo = model.Type == "0" ? notice.CustomerNo: null,//璐т富缂栫爜
-                        OwnerName = model.Type == "0" ? notice.CustomerName :null,//璐т富鍚嶇О
+                        OwnerNo = model.Type == "0" ? notice.CustomerNo : null,//璐т富缂栫爜
+                        OwnerName = model.Type == "0" ? notice.CustomerName : null,//璐т富鍚嶇О
                         IsDel = "0",
                         CreateUser = 0,
                         CreateTime = comTime
@@ -357,8 +357,8 @@
                             CreateUser = userId,
                             CreateTime = comTime,
                         };
-                        
-                        boxInfoList.Add(boxInfo); 
+
+                        boxInfoList.Add(boxInfo);
                         factQty += box.Qty;
 
                         #region 搴撳瓨绠辩爜鏄庣粏
@@ -399,10 +399,11 @@
                 }
                 else if (model.Type == "0")//鐗╂枡鎵�
                 {
-                    if (model.Detail.Count(m=>m.OrderCode != detail.OrderDetailCode)>0)
-                    {
-                        throw new Exception($"鎵樼洏缁戝畾鏄庣粏涓紝鍚湁绠辩爜鐢熶骇宸ュ崟涓嶄竴鑷�");
-                    }
+                    // 浣跨敤鍦烘櫙涓嶆槑纭�
+                    //if (model.Detail.Count(m => m.OrderCode != detail.OrderDetailCode) > 0)
+                    //{
+                    //    throw new Exception($"鎵樼洏缁戝畾鏄庣粏涓紝鍚湁绠辩爜鐢熶骇宸ュ崟涓嶄竴鑷�");
+                    //}
                     if (model.Detail.Count(m => m.SkuNo != model.SkuNo || m.LotNo != model.LotNo) > 0)
                     {
                         throw new Exception($"鎵樼洏缁戝畾鏄庣粏涓紝鍚湁绠辩爜鐗╂枡鎴栨壒娆′笉涓�鑷�");
@@ -486,19 +487,19 @@
                             throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
                         }
                     }
-                } 
-                
+                }
+
                 Db.Insertable(boxInfoList).ExecuteCommand();
                 #endregion
-                 
-                
+
+
                 if (factQty != bind.Qty)
                 {
                     throw new Exception("绠辩爜鏄庣粏鎬绘暟閲忎笉鍚屼簬鎵樼洏鎬绘暟閲忥紝璇锋牳瀹�");
                 }
 
                 #region 鍏ュ簱鍗曞強鏄庣粏
-                if (model.Type =="0")
+                if (model.Type == "0")
                 {
                     detail.FactQty += factQty;//宸茬粍鏁伴噺
                     detail.CompleteQty += factQty;//瀹屾垚鏁伴噺
@@ -529,7 +530,7 @@
                     //鏇存柊鍏ュ簱鍗�
                     Db.Updateable(notice).ExecuteCommand();
                 }
-                
+
                 #endregion
 
                 #region 搴撳瓨
@@ -537,7 +538,7 @@
                 if (dataStock != null)
                 {
                     dataStock.Qty += factQty;
-                    
+
                     if (bind.InspectMark == "1")
                     {
                         dataStock.IsSampling = bind.InspectMark;
@@ -573,7 +574,7 @@
                     Db.Insertable(stock).ExecuteCommand();
                 }
                 #endregion
-                
+
                 // 鏇存敼鎵樼洏浣跨敤鐘舵��
                 var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
                 //娣诲姞鎵樼洏璁板綍琛ㄦ暟鎹�
@@ -712,7 +713,7 @@
                     {
                         BoxNo = a.BoxNo,
                         PalletNo = a.PalletNo,
-                        BindNo=a.BindNo,
+                        BindNo = a.BindNo,
                         Qty = SqlFunc.AggregateSum(a.Qty),
                         SamplingQty = SqlFunc.AggregateSum(a.SamplingQty),
                         FullQty = a.FullQty,
@@ -743,7 +744,7 @@
         /// <param name="boxNo">绠辩爜</param>
         /// <param name="boxNo3">鏀爜</param>
         /// <returns></returns>
-        public List<BoxInfoDto> GetBoxInfoByBoxNo(string boxNo, string boxNo3,int bindNo)
+        public List<BoxInfoDto> GetBoxInfoByBoxNo(string boxNo, string boxNo3, int bindNo)
         {
             Expression<Func<BllBoxInfo, bool>> item = Expressionable.Create<BllBoxInfo>()
                 .AndIF(!string.IsNullOrWhiteSpace(boxNo), it => it.BoxNo == boxNo.Trim())
@@ -805,16 +806,16 @@
                 #region 楠岃瘉褰撳墠鎵樼洏淇℃伅鏄惁鍙垹闄�
                 // 鍒ゆ柇璁㈠崟鏄惁鍏抽棴
                 var asnData = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == bind.ASNNo);
-                if (asnData != null) 
+                if (asnData != null)
                 {
-                    if (asnData.Status == "3" ||asnData.Status == "4") 
+                    if (asnData.Status == "3" || asnData.Status == "4")
                     {
                         throw new Exception("鍗曟嵁宸插叧鍗曚笉鍙垹闄�");
                     }
                 }
 
                 // 鍒ゆ柇鏄惁宸叉湁宸烽亾鍜屽偍浣�
-                if ( !string.IsNullOrWhiteSpace(bind.LocatNo) || !string.IsNullOrWhiteSpace(bind.RoadwayNo) ) 
+                if (!string.IsNullOrWhiteSpace(bind.LocatNo) || !string.IsNullOrWhiteSpace(bind.RoadwayNo))
                 {
                     throw new Exception("鎵樼洏宸蹭笂鏋朵笉鍙垹闄ょ粍鎵�");
                 }
@@ -827,9 +828,9 @@
                 {
                     throw new Exception("搴撳唴涓嶅瓨鍦ㄦ鎵樼洏!");
                 }
-                else 
+                else
                 {
-                    if (dataBindItem.Status != "0") 
+                    if (dataBindItem.Status != "0")
                     {
                         throw new Exception("鎵樼洏涓嶆槸寰呭垎閰嶇姸鎬侊紝涓嶅彲鍒犻櫎");
                     }
@@ -842,35 +843,35 @@
                 {
                     throw new Exception("搴撳唴涓嶅瓨鍦ㄦ鎵樼洏涓婄墿鏂欐壒娆′俊鎭�!");
                 }
-                if (dataStocks.Qty - dataBindItem.Qty < dataStocks.LockQty) 
+                if (dataStocks.Qty - dataBindItem.Qty < dataStocks.LockQty)
                 {
                     throw new Exception("鎵樼洏涓婅揣鐗╁凡琚攣瀹氫笉鍙垹闄�");
                 }
-                
+
                 // 楠岃瘉搴撳唴鎵樼洏淇℃伅鍜岀粦瀹氭墭鐩樹俊鎭槸鍚︿竴鑷�
                 var bllboxItem = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BindNo == bind.Id).ToList();
                 var databoxItem = new List<DataBoxInfo>();
-                if (bllboxItem.Count == 0)         
+                if (bllboxItem.Count == 0)
                 {
                     // 鎸夋暟閲忕粍鎵橈紝娌℃湁绠辨敮鍏崇郴
                     if (dataBindItem.ASNDetailNo != bind.ASNDetailNo
                         || dataBindItem.ASNNo != bind.ASNNo
-                        || dataBindItem.LotNo != bind.LotNo 
-                        || dataBindItem.Qty != bind.Qty) 
+                        || dataBindItem.LotNo != bind.LotNo
+                        || dataBindItem.Qty != bind.Qty)
                     {
                         throw new Exception("鎵樼洏涓婅揣鐗╁凡鍙樻洿涓嶅彲鍒犻櫎");
                     }
                 }
-                else 
+                else
                 {
                     // 寰幆瀵规瘮绠辨敮鍏崇郴鏄惁瀛樺湪
-                    foreach (BllBoxInfo box in bllboxItem) 
+                    foreach (BllBoxInfo box in bllboxItem)
                     {
                         var databox = Db.Queryable<DataBoxInfo>()
-                            .First(m => m.IsDel == "0" && m.BoxNo == box.BoxNo 
+                            .First(m => m.IsDel == "0" && m.BoxNo == box.BoxNo
                             && m.BoxNo2 == box.BoxNo2 && m.BoxNo3 == box.BoxNo3);
 
-                        if (databox == null) 
+                        if (databox == null)
                         {
                             throw new Exception("鎵樼洏涓婅揣鐗╁凡鍙樻洿涓嶅彲鍒犻櫎");
                         }
@@ -882,13 +883,13 @@
 
                 // 楠岃瘉鏄惁宸叉湁鍏ュ簱浠诲姟
                 var taskitem = new LogTask();
-                if (!string.IsNullOrWhiteSpace(bind.TaskNo)) 
+                if (!string.IsNullOrWhiteSpace(bind.TaskNo))
                 {
                     taskitem = Db.Queryable<LogTask>().First(m => m.TaskNo == bind.TaskNo);
 
-                    if (taskitem != null) 
+                    if (taskitem != null)
                     {
-                        if (taskitem.IsSuccess == 1) 
+                        if (taskitem.IsSuccess == 1)
                         {
                             throw new Exception("鎵樼洏鍏宠仈鐨勫叆搴撲换鍔″凡涓嬪彂涓嶅彲鍒犻櫎");
                         }
@@ -907,10 +908,10 @@
                 var time = DateTime.Now;
                 //鎵樼洏缁戝畾鐨勭鏀俊鎭泦鍚�
                 //var boxList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BindNo == bind.Id).ToList();
-                if (bllboxItem.Count != 0) 
+                if (bllboxItem.Count != 0)
                 {
                     var ids = databoxItem.Select(m => m.StockDetailId).Distinct().ToList();
-                    var dataStockDetail = Db.Queryable<DataStockDetail>().Where(m=>m.IsDel == "0" && ids.Contains(m.Id)).ToList();
+                    var dataStockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && ids.Contains(m.Id)).ToList();
                     var stockItem = new List<DataStock>();
                     foreach (var item in dataStockDetail)
                     {
@@ -920,10 +921,10 @@
                             stockItem.Add(dataStock);
                         }
                     }
-                    
+
                     foreach (var b in bllboxItem)
                     {
-                        b.IsDel = "0";  
+                        b.IsDel = "0";
                         b.PalletNo = "";
                         b.BindNo = null;
                         b.Status = "0";
@@ -936,7 +937,7 @@
                             throw new Exception($"{b.BoxNo}绠辩爜銆亄b.BoxNo3}鏀爜鍒犻櫎澶辫触");
                         }
                         //鍒犻櫎搴撳瓨绠辩爜鏄庣粏淇℃伅
-                        var box = databoxItem.FirstOrDefault(m=>m.BoxNo == b.BoxNo && m.BoxNo2 == b.BoxNo2 && m.BoxNo3 == b.BoxNo3);
+                        var box = databoxItem.FirstOrDefault(m => m.BoxNo == b.BoxNo && m.BoxNo2 == b.BoxNo2 && m.BoxNo3 == b.BoxNo3);
                         if (box == null)
                         {
                             throw new Exception($"鏈煡璇㈠埌{b.BoxNo}绠辩爜銆亄b.BoxNo3}鏀爜鐨勫簱瀛樹俊鎭�");
@@ -948,8 +949,8 @@
                             throw new Exception($"鏈煡璇㈠埌{b.BoxNo}绠辩爜銆亄b.BoxNo3}鏀爜鐨勫簱瀛樻墭鐩樹俊鎭�");
                         }
                         stockDetail.Qty -= box.Qty;
-                       
-                        if (stockDetail.Qty<=0)
+
+                        if (stockDetail.Qty <= 0)
                         {
                             Db.Deleteable(stockDetail).ExecuteCommand();
                         }
@@ -958,7 +959,7 @@
                             Db.Updateable(stockDetail).ExecuteCommand();
                         }
                         //鍒犻櫎/淇敼搴撳瓨鎬昏〃淇℃伅
-                        var stock = stockItem.FirstOrDefault(m=>m.SkuNo == b.SkuNo && m.LotNo == b.LotNo);
+                        var stock = stockItem.FirstOrDefault(m => m.SkuNo == b.SkuNo && m.LotNo == b.LotNo);
                         if (stock == null)
                         {
                             throw new Exception($"鏈煡璇㈠埌{b.BoxNo}绠辩爜銆亄b.BoxNo3}鏀爜鐨勫簱瀛樻�讳俊鎭�");
@@ -981,7 +982,7 @@
                 {
                     //鍒犻櫎/淇敼搴撳瓨鎵樼洏鏄庣粏淇℃伅
                     var stockDetail = dataBindItem;
-                    
+
                     stockDetail.Qty -= bind.Qty;
 
                     if (stockDetail.Qty <= 0)
@@ -994,7 +995,7 @@
                     }
                     //鍒犻櫎/淇敼搴撳瓨鎬昏〃淇℃伅
                     var stock = dataStocks;
-                   
+
                     stock.Qty -= bind.Qty;
                     if (stock.Qty <= 0)
                     {
@@ -1006,7 +1007,7 @@
                     }
                 }
                 //鍒ゆ柇鏄惁鏈夋寚瀹氬偍浣�
-                if (taskitem != null) 
+                if (taskitem != null)
                 {
                     if (!string.IsNullOrWhiteSpace(taskitem.EndLocat))
                     {
@@ -1044,10 +1045,10 @@
                     {
                         throw new Exception("鏌ヨ鍒扮┖鎵樻湁鍗曟嵁淇℃伅锛岄敊璇��");
                     }
-                    
+
                     //淇敼鍏ュ簱鍗曟槑缁�
                     noticeDetail.FactQty -= bind.Qty;
-                    noticeDetail.CompleteQty -= bind.Qty;                    
+                    noticeDetail.CompleteQty -= bind.Qty;
                     //鍒ゆ柇鍏ュ簱鍗曟槑缁嗙粍鎵樻暟閲忔槸鍚︿负0锛屾槸锛氫慨鏀规槑缁嗙姸鎬�
                     //鍏ュ簱鎬诲崟淇℃伅
                     var notice = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == bind.ASNNo);
@@ -1147,7 +1148,7 @@
                     item.UpdateTime = time;
                     item.UpdateUser = userId;
                     qty += item.Qty;
-                    qty2 += item.SamplingQty == null? 0 : item.SamplingQty;
+                    qty2 += item.SamplingQty == null ? 0 : item.SamplingQty;
 
                 }
                 Db.Updateable(boxInfos).ExecuteCommand();
@@ -1155,11 +1156,11 @@
                 //淇敼鎵樼洏缁戝畾淇℃伅
                 bind.Qty -= qty;                    // 鏁伴噺鍙樻洿
                 bind.BitPalletMark = "1";           // 闆舵墭鏍囪鍙樻洿
-                if (bind.SamplingQty!= null)
+                if (bind.SamplingQty != null)
                 {
                     bind.SamplingQty -= qty2;
                 }
-                
+
                 if (bind.Qty == 0)
                 {
                     //鍒ゆ柇鏄惁鏈夋寚瀹氬偍浣�
@@ -1361,7 +1362,7 @@
                    .AndIF(!string.IsNullOrWhiteSpace(layer), m => m.Layer == int.Parse(layer))
                    .AndIF(!string.IsNullOrWhiteSpace(locateNo), m => m.LocatNo.Contains(locateNo))
                    .And(m => m.IsDel == "0" && m.Status == "0" && m.Flag == "0" && m.WareHouseNo == houseNo)
-                   .And(m => m.AreaNo.Contains(categoryAreaNo))
+                   .And(m => m.AreaNo == categoryAreaNo)
                    .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
                 var total = 0;
                 var list = Db.Queryable<SysStorageLocat>().Where(item).OrderByDescending(a => a.Depth).OrderBy(a => a.Column)
@@ -1588,7 +1589,7 @@
                         {
                             throw new Exception("璇ユ墭鐩樻鍦ㄥ叆搴擄紝浣嗘湭鏌ヨ鍒颁换鍔′俊鎭�");
                         }
-                        
+
                         comDto = new OutCommandDto()
                         {
                             PalletNo = palletNo,//鎵樼洏鍙�
@@ -1607,7 +1608,7 @@
                             Db.Updateable(beingTask).ExecuteCommand();
                         }
                         return comDto;
-                        
+
                     }
                     if (haveLocate != null)
                     {
@@ -1661,7 +1662,7 @@
                     skuNo = stockDetail.First().SkuNo;
 
                     #region 鍒ゆ柇浠诲姟鏄惁宸茬粡瀛樺湪锛岃嫢瀛樺湪鐩存帴杩斿洖浠诲姟锛�
-                    var beingTask = Db.Queryable<LogTask>().First(m => m.IsDel == "0" 
+                    var beingTask = Db.Queryable<LogTask>().First(m => m.IsDel == "0"
                     && (m.Status == "0" || m.Status == "1") && m.PalletNo == palletNo && m.Type == "0");
                     if (beingTask != null)
                     {
@@ -1680,7 +1681,7 @@
                         if (beingTask.IsSuccess == 0)
                         {
                             beingTask.IsSuccess = 1;
-                            beingTask.Status = "1"; 
+                            beingTask.Status = "1";
                             Db.Updateable(beingTask).ExecuteCommand();
                         }
 
@@ -1690,12 +1691,12 @@
 
                     #region 鍒ゆ柇璇ユ墭鐩橈紝鏄惁绗﹀悎鍥炲簱鍔熻兘璁惧畾鐨勫洖搴撹鍒�
                     //鑾峰彇瀵瑰簲鍥炲簱瑙勫垯
-                    var function = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" 
+                    var function = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0"
                     && a.FunSetNo == "Fun041" && a.IsEnable == "NO");
                     if (function != null)
                     {
                         //鎷h揣瀹屾垚鍚庡厑璁告墭鐩樺洖搴�
-                        var allot = Db.Queryable<BllExportAllot>().First(a => a.IsDel == "0" 
+                        var allot = Db.Queryable<BllExportAllot>().First(a => a.IsDel == "0"
                         && a.LotNo == stockDetail[0].LotNo && a.PalletNo == palletNo && a.SkuNo == stockDetail[0].SkuNo);
 
                         //楠岃瘉鎷h揣鏄庣粏鏄惁瀛樺湪
@@ -1834,7 +1835,7 @@
                     }
                     //濡傛灉璺冲贩閬撳苟涓旀湭鎵惧埌鍚堥�傜┖鍌ㄤ綅,鍒欒烦鍒版渶鍚庝竴娆′娇鐢ㄧ殑宸烽亾鏌ヨ
 
-                    if (roadNo == "")
+                    if (string.IsNullOrWhiteSpace(roadNo))
                     {
                         if (useLog != null)
                         {
@@ -1867,7 +1868,7 @@
                             roadNo = item;
                         }
                         //褰撳墠宸锋湁浣嶇疆鍒欓��鍑�
-                        if (roadNo != null)
+                        if (!string.IsNullOrWhiteSpace(roadNo))
                         {
                             break;
                         }
@@ -1919,6 +1920,7 @@
                     };
                     Db.Insertable(exTask).ExecuteCommand();
 
+                    var asnNo = "";
                     // 娣诲姞鎵樼洏缁戝畾琛ㄦ墭鐩樺叆搴撲换鍔″彿  liudl
                     if (palletBindList.Count < 1)
                     {
@@ -1932,9 +1934,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)
                     {
@@ -2104,13 +2130,13 @@
                     {
                         throw new Exception($"{palletNo}鎵樼洏鏉$爜涓嶅叿鏈夌鐮佷俊鎭紝涓嶅彲鍏ュ簱锛�");
                     }
-                    if (stockDetail.Count(m=>!string.IsNullOrWhiteSpace(m.LocatNo)) >0)
+                    if (stockDetail.Count(m => !string.IsNullOrWhiteSpace(m.LocatNo)) > 0)
                     {
                         throw new Exception("褰撳墠鎵樼洏宸插湪搴撳唴锛岃鏍稿疄");
                     }
                     skuNo = stockDetail.First().SkuNo;
 
-                    var beingTask = Db.Queryable<LogTask>().First(m => m.IsDel == "0" 
+                    var beingTask = Db.Queryable<LogTask>().First(m => m.IsDel == "0"
                     && (m.Status == "0" || m.Status == "1") && m.PalletNo == palletNo && m.Type == "0");
                     if (beingTask != null)
                     {
@@ -2215,7 +2241,7 @@
                 Db.BeginTran();
                 try
                 {
-                    
+
                     if (isAddTask) // 姝e父鍏ュ簱
                     {
                         var taskNo = new Common().GetMaxNo("TK");
@@ -2242,7 +2268,7 @@
 
                         };
                         Db.Insertable(exTask).ExecuteCommand();
-
+                        var asnNo = "";
                         // 娣诲姞鎵樼洏缁戝畾琛ㄦ墭鐩樺叆搴撲换鍔″彿 liudl
                         foreach (DataStockDetail stockModel in stockDetail)
                         {
@@ -2255,9 +2281,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,18 +2321,36 @@
                         }
                         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";
                     Db.Updateable(locate).ExecuteCommand();
                     if (palletBindList.Count >= 1)
@@ -2610,7 +2677,7 @@
         //        throw new Exception(e.Message);
         //    }
         //}
-        
+
         #endregion
 
         //鍏ュ簱瀹屾垚(wcs鍙嶉銆亀ms鎵嬪姩瀹屾垚)
@@ -2652,6 +2719,7 @@
                     //娣诲姞鎿嶄綔鏃ュ織璁板綍
                     var k = new OperationASNServer().AddLogOperationAsn("鍏ュ簱浣滀笟", "鍏ュ簱鏃ュ織", taskNo, "瀹屾垚", $"鐐瑰嚮瀹屾垚鎸夐挳銆佸畬鎴愪换鍔″彿涓猴細{taskNo}鐨勪换鍔�", userId);
                 }
+                
                 //鍒ゆ柇鏄惁鏄洖娴佸叆搴撳畬鎴�
                 if (stockDetail.Any())
                 {
@@ -2667,7 +2735,7 @@
                             item.UpdateUser = userId;
                         }
                     }
-                   
+
                     locate.Status = "1";
                     Db.Updateable(locate).ExecuteCommand();
                     Db.Updateable(stockDetail).ExecuteCommand();
@@ -2756,7 +2824,7 @@
                                 InspectStatus = sku.IsInspect,
                                 InspectMark = boxInfo.InspectMark,
                                 BitBoxMark = boxInfo.BitBoxMark,
-                                ExpirationTime=boxInfo.ExpirationTime,
+                                ExpirationTime = boxInfo.ExpirationTime,
 
                                 CreateUser = 0,
                                 CreateTime = comTime
@@ -2789,7 +2857,7 @@
                                     Qty = item.Qty,
                                     LockQty = 0,
                                     FrozenQty = 0,
-                                    IsSampling = item.InspectMark, 
+                                    IsSampling = item.InspectMark,
                                     IsDel = "0",
                                     CreateUser = userId,
                                     CreateTime = comTime
@@ -3251,7 +3319,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())
                 {
@@ -3272,7 +3346,7 @@
                     Db.Updateable(locate).ExecuteCommand();
                     //鏇存柊搴撳瓨鏄庣粏淇℃伅
                     Db.Updateable(stockDetail).ExecuteCommand();
-                   
+
                     var bindList = Db.Queryable<BllPalletBind>().Where(m => m.IsDel == "0" && m.TaskNo == taskNo && m.Status == "2").ToList();
                     foreach (var item in bindList)
                     {
@@ -3294,49 +3368,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 +3618,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)
                 {
@@ -3614,11 +3654,11 @@
                 if (!string.IsNullOrWhiteSpace(model.SkuNo) || !string.IsNullOrWhiteSpace(model.SkuName))
                 {
                     string sql = $"select Distinct Id from ArchivingArrivalNoticeDetail where IsDel='0' and SkuNo like '%{model.SkuNo}%' and SkuName like '{model.SkuName}'";
-                    var detailList= Db.Ado.SqlQuery<int>(sql);
-                    
+                    var detailList = Db.Ado.SqlQuery<int>(sql);
+
                     strList = detailList;
                 }
-                string strListStr= string.Join(",", strList);
+                string strListStr = string.Join(",", strList);
 
                 string sqlString = string.Empty;
                 string sqlCount = string.Empty;
@@ -3697,7 +3737,7 @@
                         item.SkuName = sku.SkuName;
                     }
                 }
-                
+
                 return modelList;
             }
             catch (Exception ex)
@@ -3783,11 +3823,11 @@
             sqlPub += "where tb1.IsDel = '0' ";
             if (!string.IsNullOrEmpty(boxNo))
             {
-                sqlPub += $"AND tb1.BoxNo = '{ boxNo.Trim()}' ";
+                sqlPub += $"AND tb1.BoxNo = '{boxNo.Trim()}' ";
             }
             if (!string.IsNullOrEmpty(boxNo3))
             {
-                sqlPub += $"AND tb1.BoxNo3 = '{ boxNo3.Trim()}' ";
+                sqlPub += $"AND tb1.BoxNo3 = '{boxNo3.Trim()}' ";
             }
 
             sqlString += sqlPub;
diff --git a/Wms/WMS.BLL/BllAsnServer/PalletUpShelfServer.cs b/Wms/WMS.BLL/BllAsnServer/PalletUpShelfServer.cs
new file mode 100644
index 0000000..72e3d9b
--- /dev/null
+++ b/Wms/WMS.BLL/BllAsnServer/PalletUpShelfServer.cs
@@ -0,0 +1,71 @@
+锘縰sing Model.ModelDto.BllAsnDto;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Text;
+using System.Threading.Tasks;
+using WMS.DAL;
+using WMS.Entity.BllAsnEntity;
+using WMS.Entity.Context;
+using WMS.Entity.SysEntity;
+using WMS.IBLL.IBllAsnServer;
+
+namespace WMS.BLL.BllAsnServer
+{
+    public class PalletUpShelfServer : DbHelper<BllPalletUpShelf>, IPalletUpShelfServer
+    {
+        private static readonly SqlSugarScope Db = DataContext.Db;
+        public PalletUpShelfServer() : base(Db)
+        {
+        }
+
+        public async Task<List<PalletUpShelfDto>> GetPalletUpShelfList(string traceNo, string taskNo, string palletNo, string skuNo, string skuName, string lotNo, string status, int page, int limit, RefAsync<int> count)
+        {
+            Expression<Func<BllPalletUpShelf, bool>> item = Expressionable.Create<BllPalletUpShelf>()
+                   .AndIF(!string.IsNullOrWhiteSpace(traceNo), it => it.TraceNo.Contains(traceNo.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(taskNo), it => it.TaskNo.Contains(taskNo.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(palletNo), it => it.PalletNo.Contains(palletNo.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(skuNo), it => it.SkuNo.Contains(skuNo.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(skuName), it => it.SkuName.Contains(skuName.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(lotNo), it => it.LotNo.Contains(lotNo.Trim()))
+                   .AndIF(!string.IsNullOrWhiteSpace(status), it => it.Status == status)
+                   .And(it => it.IsDel == "0")
+                   .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
+
+            
+            var list = await Db.Queryable<BllPalletUpShelf>().Where(item)
+                .LeftJoin<SysUserInfor>((a, b) => a.CreateUser == b.Id)
+                .LeftJoin<SysUserInfor>((a, b, c) => a.UpdateUser == c.Id)
+                .LeftJoin<SysWareHouse>((a,b,c,d)=> a.WareHouseNo == d.WareHouseNo)
+                .LeftJoin<SysStorageRoadway>((a,b,c,d,e) => a.RoadwayNo == e.RoadwayNo)
+                .LeftJoin<SysStorageArea>((a,b,c,d,e,f) => a.AreaNo == f.AreaNo)
+                .Select((a, b,c,d,e,f) => new PalletUpShelfDto
+                {
+                    Id = a.Id,
+                    TraceNo = a.TraceNo,
+                    TaskNo = a.TaskNo,
+                    PalletNo = a.PalletNo,
+                    SkuNo = a.SkuNo,
+                    SkuName = a.SkuName,
+                    LotNo = a.LotNo,
+                    Status = a.Status,
+                    WareHouseNo = a.WareHouseNo,
+                    WareHouseName = d.WareHouseName,
+                    RoadwayNo = a.RoadwayNo,
+                    RoadwayName = e.RoadwayName,
+                    AreaNo = a.AreaNo,
+                    AreaName = f.AreaName,
+                    LocatNo = a.LocatNo,
+
+                    CreateTime = a.CreateTime,
+                    CreateUserName = b.RealName,
+                    UpdateTime = a.UpdateTime,
+                    UpdateUserName = c.RealName,
+
+                }).OrderByDescending(a => a.CreateTime).ToOffsetPageAsync(page, limit, count);
+
+            return list;
+        }
+    }
+}
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/BllCheckServer/StockCheckServer.cs b/Wms/WMS.BLL/BllCheckServer/StockCheckServer.cs
index a93d0a0..22739af 100644
--- a/Wms/WMS.BLL/BllCheckServer/StockCheckServer.cs
+++ b/Wms/WMS.BLL/BllCheckServer/StockCheckServer.cs
@@ -1226,7 +1226,7 @@
             return outDtoList;
             #endregion
         }
-        
+
         /// <summary>
         /// 瑙嗚鐩樼偣
         /// </summary>
@@ -1423,9 +1423,8 @@
                 #endregion
                 if (locate.Status == "1") //鏈夌墿鍝�
                 {
-                    #region 娣诲姞鍑哄簱浠诲姟
+                    #region 娣诲姞瑙嗚鐩樼偣浠诲姟
                     var taskNo = new Common().GetMaxNo("TK");
-                    //娣诲姞鍑哄簱浠诲姟
                     var exTask = new LogTask
                     {
                         TaskNo = taskNo,
@@ -1440,8 +1439,8 @@
                         IsFinish = 1,//鏄惁鍙畬鎴�
                         Type = "1",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
                         Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
-                        OrderType = "4",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗� 4瑙嗚鐩樼偣
-
+                        OrderType = "6",////0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗� 4 鍙栨牱鍑哄簱鍗� 6瑙嗚鐩樼偣
+                        Msg = $"{locateNo}鐨勮瑙夌洏鐐逛换鍔�",
                         CreateTime = time
                     };
                     await Db.Insertable(exTask).ExecuteCommandAsync();
@@ -1471,7 +1470,7 @@
                             await Db.Updateable(notice).ExecuteCommandAsync();
                         }
                     }
-                    locate.Status = "3"; //瑕佸嚭搴撶殑鍌ㄤ綅鏀瑰彉鐘舵�� 姝e湪鍑哄簱
+                    //locate.Status = "3"; //瑕佸嚭搴撶殑鍌ㄤ綅鏀瑰彉鐘舵�� 姝e湪鍑哄簱
                     await Db.Updateable(locate).ExecuteCommandAsync();
 
                     item.TaskNo = exTask.TaskNo; // 鍑哄簱鍒嗛厤淇℃伅涓洿鏂颁换鍔″彿
@@ -1572,6 +1571,42 @@
             return outDtoList;
             #endregion
         }
+
+        /// <summary>
+        /// 瑙嗚鐩樼偣浼犵粨鏋�
+        /// </summary>
+        /// <param name="crNo"></param>
+        /// <param name="url"></param>
+        /// <param name="str"></param>
+        /// <returns></returns>
+        public async Task CheckVision(CheckVm model)
+        {
+            if (string.IsNullOrWhiteSpace(model.CrNo))
+            {
+                throw Oops.Bah("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(model.SkuNo))
+            {
+                throw Oops.Bah("鐗╂枡涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(model.LotNo))
+            {
+                throw Oops.Bah("鐗╂枡鎵规涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(model.PalletNo))
+            {
+                throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
+            }
+            //鐩樼偣鏄庣粏
+            var checkDetail = await Db.Queryable<BllStockCheckDetail>().FirstAsync(m =>
+                m.IsDel == "0" && m.CRNo == model.CrNo && m.PalletNo == model.PalletNo && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo);
+            if (checkDetail == null)
+            {
+                throw Oops.Bah("鏈煡璇㈠埌鏈洏鐐圭殑鐩樼偣鏄庣粏淇℃伅");
+            }
+            var modSku = await Db.Queryable<SysMaterials>().Where(s => s.SkuNo == model.SkuNo).FirstAsync();
+
+        }
         //鐩樼偣鍑哄簱瀹屾垚
         public async Task CheckSuccess(string taskNo, int userId)
         {
@@ -1600,15 +1635,18 @@
                 task.IsFinish = 0;
                 task.FinishDate = DateTime.Now;//瀹屾垚鏃堕棿
                 await Db.Updateable(task).ExecuteCommandAsync();
-                locate.Status = "0"; // 鏇存敼褰撳墠浠诲姟涓殑鍌ㄤ綅鐘舵�侊紙鏀逛负0绌哄偍浣嶏級
-                await Db.Updateable(locate).ExecuteCommandAsync();
-                foreach (var item in stockDetail)
+                if(task.OrderType != "6")//瑙嗚鐩樼偣涓嶆洿鏀圭姸鎬�
                 {
-                    item.LocatNo = "";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖锛�
-                    item.WareHouseNo = "";//鎵�灞炰粨搴撴洿鏀癸紙鏀逛负绌猴級
-                    item.RoadwayNo = "";//鎵�灞炲贩閬撴洿鏀癸紙鏀逛负绌猴級
-                    item.AreaNo = "";//鎵�灞炲尯鍩熸洿鏀癸紙鏀逛负绌猴級
-                    await Db.Updateable(item).ExecuteCommandAsync();
+                    locate.Status = "0"; // 鏇存敼褰撳墠浠诲姟涓殑鍌ㄤ綅鐘舵�侊紙鏀逛负0绌哄偍浣嶏級
+                    await Db.Updateable(locate).ExecuteCommandAsync();
+                    foreach (var item in stockDetail)
+                    {
+                        item.LocatNo = "";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖锛�
+                        item.WareHouseNo = "";//鎵�灞炰粨搴撴洿鏀癸紙鏀逛负绌猴級
+                        item.RoadwayNo = "";//鎵�灞炲贩閬撴洿鏀癸紙鏀逛负绌猴級
+                        item.AreaNo = "";//鎵�灞炲尯鍩熸洿鏀癸紙鏀逛负绌猴級
+                        await Db.Updateable(item).ExecuteCommandAsync();
+                    }
                 }
                 //鐩樼偣鏄庣粏锛堟洿鏀圭姸鎬侊級
                 var checkDetails = await Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && (m.TaskNo == taskNo || (m.Status == 1 && m.PalletNo == task.PalletNo))).ToListAsync();
diff --git a/Wms/WMS.BLL/BllCheckServer/WarehouseOutsidePalletsServer.cs b/Wms/WMS.BLL/BllCheckServer/WarehouseOutsidePalletsServer.cs
index 9e2a432..b2cbc5a 100644
--- a/Wms/WMS.BLL/BllCheckServer/WarehouseOutsidePalletsServer.cs
+++ b/Wms/WMS.BLL/BllCheckServer/WarehouseOutsidePalletsServer.cs
@@ -1,5 +1,6 @@
 锘縰sing Model.ModelDto.DataDto;
 using Model.ModelDto.SysDto;
+using Model.ModelVm.LogVm;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -14,6 +15,7 @@
 using WMS.Entity.LogEntity;
 using WMS.Entity.SysEntity;
 using WMS.IBLL.IBllCheckServer;
+using WMS.IBLL.ILogServer;
 
 namespace WMS.BLL.BllCheckServer
 {
@@ -21,9 +23,11 @@
     {
         private static readonly SqlSugarScope Db = DataContext.Db;
         private readonly UserManager _userManager;
-        public WarehouseOutsidePalletsServer(UserManager userManager) : base(Db)
+        private readonly IOperationCRServer _operation;
+        public WarehouseOutsidePalletsServer(UserManager userManager, IOperationCRServer operation) : base(Db)
         {
             _userManager = userManager;
+            _operation = operation;
         }
 
         /// <summary>
@@ -178,8 +182,14 @@
                     await Db.Updateable(bindModel).ExecuteCommandAsync();
                 }
                 // 鎻掑叆鎿嶄綔鏃ュ織
-                new OperationASNServer().AddLogOperationAsn("搴撳唴浣滀笟", "搴撳鎵樼洏", stockDetail.PalletNo, "缂栬緫",
-                        $"鎸囧畾浜嗗偍浣嶏細{locate.LocatNo}銆佸崟鎹彿锛歿stockDetail.ASNNo}銆佹墭鐩樼爜锛歿stockDetail.PalletNo}鐨勪俊鎭�", _userManager.UserId);
+                await _operation.AddLogOperationCr(new OperationInputVm()
+                {
+                    ParentName = "搴撳唴浣滀笟",
+                    MenuName = "搴撳鎵樼洏",
+                    FkNo = stockDetail.PalletNo,
+                    TypeName = "缂栬緫",
+                    Msg = $"鎸囧畾浜嗗偍浣嶏細{locate.LocatNo}銆佸崟鎹彿锛歿stockDetail.ASNNo}銆佹墭鐩樼爜锛歿stockDetail.PalletNo}鐨勪俊鎭�"
+                });
                 //鎻愪氦浜嬪姟
                 Db.CommitTran();
             }
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index d328fe6..27ac2ea 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;
@@ -3351,6 +3351,1530 @@
                 throw new Exception(e.Message);
             }
         }
+
+        //JC26缁戝畾鎵樼洏 璐存爣鐗╂枡
+        public void BindPalletPasteCode(PdaPalletBindVm model, int userId)
+        {
+            try
+            {
+                #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("鎵樼洏鍙蜂笉鍙负绌�!");
+                }
+                //鏍规嵁鍗曟嵁鍙疯幏鍙栧叆搴撳崟鎬诲崟
+                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)
+                    {
+                        model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+                    }
+                    else
+                    {
+                        throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
+                    }
+                }
+
+                //鍒ゆ柇绠辩爜淇℃伅
+                if (string.IsNullOrEmpty(model.BoxNo))
+                {
+                    throw new Exception("绠辩爜淇℃伅涓嶅彲涓虹┖!");
+                }
+                //鏄惁杩炵画缁勬墭 0锛氬惁  1锛氭槸
+                if (model.IsContinue == "1")
+                {
+                    if (string.IsNullOrWhiteSpace(model.TailBoxNo))
+                    {
+                        throw new Exception("寮�鍚繛缁粍鎵樻椂锛屽熬绠辩爜淇℃伅涓嶅彲涓虹┖!");
+                    }
+                }
+
+                //鎵樼洏淇℃伅鏄惁瀛樺湪
+                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)
+                {
+                    throw new Exception("璇ユ墭鐩樺湪搴撳瓨宸叉湁鍏跺畠鐗╂枡淇℃伅锛岃鏍稿疄锛�");
+                }*/
+                #endregion
+
+                //寮�鍚簨鍔�
+                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 = package.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
+
+                #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 && w.Status == "0").ToList();
+                //鍜岄�夋嫨鐨勬壒娆′笉鍚屾壒娆$殑绠辩爜淇℃伅锛堟嫾绠辨壒娆★級
+                var notBoxInfoList = boxInfoList.Where(w => w.LotNo != model.LotNo).ToList();
+                #endregion
+
+                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
+
+                    #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);
+                    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
+
+                    // 鏇存敼绠辨敮鍏崇郴琛�
+                    decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+                    var isSample = "0";//鏄惁鍙栨牱
+                    var sampleQty = 0m;//鍙栨牱鏁伴噺
+
+                    //鏍囩缁勬墭
+                    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}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
+                            }
+
+                            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";
+
+                            factQty += box.Qty;
+                            boxFullQty += box.Qty;
+                            if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
+                            {
+                                isSample = "1";
+                                sampleQty += (decimal)box.SamplingQty;
+                            }
+
+                            #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,
+
+                                CreateUser = 0,
+                                CreateTime = comTime
+                            };
+                            //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                            Db.Insertable(box2).ExecuteCommand();
+                            #endregion
+                        }
+                        if (boxFullQty > bNum)
+                        {
+                            throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+                        }
+                    }
+                    //鏇存敼绠辨敮鍏崇郴琛ㄤ俊鎭�
+                    Db.Updateable(boxInfoList).ExecuteCommand();
+
+                    // 鏇存柊鎵樼洏缁戝畾琛�
+                    bind.Qty += factQty;
+
+                    if (bind.FullQty < bind.Qty)
+                    {
+                        throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+                    }
+
+                    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 鍏ュ簱鍗曞強鏄庣粏
+                    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();
+
+                    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 += 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 (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
+                }
+                //鎷肩
+                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 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;
+
+                            Db.Updateable(bind).ExecuteCommand();
+                        }
+                        #endregion
+
+                        // 鎻掑叆搴撳瓨鏄庣粏鏁版嵁
+                        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();
+
+                        //鎵樼洏瑙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
+
+                        #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";
+                        }
+
+                        // 鍒ゆ柇搴撳瓨鏄庣粏鏄惁宸叉湁姝ゆ墭鐩樹俊鎭�  
+                        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;
+
+                            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,
+
+                                IsDel = "0",
+                                CreateUser = 0,
+                                CreateTime = comTime
+                            };
+
+                            //缁存姢搴撳瓨鏄庣粏璐т富/渚涘簲鍟嗕俊鎭�
+                            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
+
+                        // 鏇存敼绠辨敮鍏崇郴琛�
+                        decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+                        var isSample = "0";//鏄惁鍙栨牱
+                        var sampleQty = 0m;//鍙栨牱鏁伴噺
+
+                        //鏍囩缁勬墭
+                        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}绠卞唴鐗╂枡鍙婃壒娆′笌鍗曟嵁涓嶄竴鑷达紝璇锋牳瀹�!");
+                                }
+
+                                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;
+
+                                //box.Qty = box.Qty;
+                                //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
+
+                                factQty += box.Qty;
+                                boxFullQty += box.Qty;
+                                if (box.InspectMark == "1") //鍒ゆ柇鏄惁鍙栨牱
+                                {
+                                    isSample = "1";
+                                    sampleQty += (decimal)box.SamplingQty;
+                                }
+
+                                #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,
+
+                                    CreateUser = 0,
+                                    CreateTime = comTime
+                                };
+                                //娣诲姞搴撳瓨绠辩爜鏄庣粏
+                                Db.Insertable(box2).ExecuteCommand();
+                                #endregion
+                            }
+                            if (boxFullQty > bNum)
+                            {
+                                throw new Exception($"缁戝畾澶辫触锛寋g.Key}绠辩爜缁戝畾鏁伴噺澶т簬璇ョ墿鍝佸寘瑁呮暟閲忥紒");
+                            }
+                        }
+                        //鏇存敼绠辨敮鍏崇郴琛ㄤ俊鎭�
+                        Db.Updateable(boxInfoList).ExecuteCommand();
+
+                        // 鏇存柊鎵樼洏缁戝畾琛�
+                        bind.Qty += factQty;
+
+                        if (bind.FullQty < bind.Qty)
+                        {
+                            throw new Exception("鎵樼洏缁戝畾鏁伴噺宸茶秴鍑鸿鐗╂枡鍖呰鏁伴噺");
+                        }
+
+                        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 鍏ュ簱鍗曞強鏄庣粏
+                        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);
+
+                //鎻愪氦浜嬪姟
+                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("璇ュ崟鎹凡鍏冲崟!");
+            }
+
+            if (string.IsNullOrEmpty(model.LotNo))
+            {
+                throw new Exception("鐗╂枡鎵规涓嶄负绌�!");
+            }
+            else
+            {
+                //浠庣墿鏂欏悕绉�-鎵规涓彇鍑烘壒娆�
+                int indexOfDash = model.LotNo.IndexOf("-");
+                if (indexOfDash != -1)
+                {
+                    model.LotNo = model.LotNo.Substring(indexOfDash + 1);
+                }
+                else
+                {
+                    if (!TypeLot.Contains(notice.Type))
+                    {
+                        throw new Exception("鐗╂枡鎵规涓嶅彲涓虹┖!");
+                    }
+
+                    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,
+
+                    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 搴撳瓨鏄庣粏
+            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
 
         #region 骞冲簱鍏ュ簱
@@ -3792,7 +5316,7 @@
         #region JC23鍙栨牱涓氬姟鎺ュ彛
 
         //鑾峰彇鏈粍鎵樻垨宸茬粍鎵樼殑绠辩爜绾у埆
-        public BoxInfoDto GetBoxLevel(string boxNo,string boxNo3)
+        public BoxInfoDto GetBoxLevel(string boxNo, string boxNo3)
         {
             try
             {
@@ -3812,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,
@@ -3827,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];
             }
@@ -3858,7 +5382,7 @@
                     throw new Exception("鏈煡璇㈠埌绛夊緟鎵ц鐨勬墭鐩樼粦瀹氫俊鎭�");
                 }
 
-                if (bindList.Count>1)
+                if (bindList.Count > 1)
                 {
                     throw new Exception("鎵樼洏缁戝畾淇℃伅瀛樺湪澶氭潯淇℃伅锛岃鏍稿疄");
                 }
@@ -3905,7 +5429,7 @@
                     throw new Exception("鍙栨牱鏁伴噺涓嶈兘涓虹┖");
                 }
 
-                if (model.BoxLevel!= "1" && model.BoxLevel != "2")
+                if (model.BoxLevel != "1" && model.BoxLevel != "2")
                 {
                     throw new Exception("鍙栨牱鏍囪瘑閿欒锛岃鍒锋柊椤甸潰");
                 }
@@ -3952,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();
@@ -3966,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();
@@ -3983,11 +5507,11 @@
 
 
                     }
-                    
-                } 
+
+                }
                 else if (model.BoxLevel == "1")
                 {
-                    if (boxList.Count>1)
+                    if (boxList.Count > 1)
                     {
                         throw new Exception("涓�绾х鐮佹煡璇㈤敊璇紝鍚湁澶氭潯鐩稿悓绠辩爜鏁版嵁");
                     }
@@ -4067,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 f2b8b13..2c3e986 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -2,9 +2,11 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Threading.Tasks;
 using Model.ModelDto.BllCheckDto;
 using Model.ModelDto.PdaDto;
 using SqlSugar;
+using Utility;
 using WMS.BLL.LogServer;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
@@ -26,401 +28,376 @@
         #region 鐩樼偣
 
         //鑾峰彇鐩樺簱鍗曟鍦ㄦ墽琛屽崟鍙�
-        public List<string> GetStockCheckNoList(string palletNo)
+        public async Task<List<string>> GetStockCheckNoList(string palletNo)
         {
-            try
+            List<string> list;
+            if (!string.IsNullOrWhiteSpace(palletNo))
             {
-                List<string> list;
-                if (!string.IsNullOrWhiteSpace(palletNo))
-                {
-                    list = Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Status == 2).Select(m => m.CRNo).Distinct().ToList();
-
-                }
-                else
-                {
-                    list = Db.Queryable<BllStockCheck>().Where(m => m.IsDel == "0" && m.Status == 1).Select(m => m.CRNo)
-                        .Distinct().ToList();
-                }
-
-                return list;
+                list = await Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Status == 2).Select(m => m.CRNo).Distinct().ToListAsync();
 
             }
-            catch (Exception e)
+            else
             {
-                throw new Exception(e.Message);
+                list = await Db.Queryable<BllStockCheck>().Where(m => m.IsDel == "0" && m.Status == 1).Select(m => m.CRNo)
+                    .Distinct().ToListAsync();
             }
+            return list;
         }
 
         //鑾峰彇鐩樼偣鏄庣粏鐗╂枡鎵规淇℃伅
-        public List<StockCheckDetailDto> GetStockCheckDetailList(string crNo, string palletNo)
+        public async Task<List<StockCheckDetailDto>> GetStockCheckDetailList(string crNo, string palletNo)
         {
-            try
+            if (string.IsNullOrWhiteSpace(crNo))
             {
-                if (string.IsNullOrWhiteSpace(crNo))
-                {
-                    throw new Exception("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
-                }
-
-                var list = Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.CRNo == crNo);
-
-                if (!string.IsNullOrWhiteSpace(palletNo))
-                {
-                    list = list.Where(m => m.PalletNo == palletNo);
-                }
-
-                var data = list.GroupBy(m => new { m.SkuNo, m.SkuName, m.LotNo }).Select(m => new StockCheckDetailDto()
-                {
-                    SkuNo = m.SkuNo,
-                    SkuName = m.SkuName,
-                    LotNo = m.LotNo
-                }).ToList();
-
-                return data;
-
+                throw Oops.Bah("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
             }
-            catch (Exception e)
+
+            var list = Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.CRNo == crNo);
+
+            if (!string.IsNullOrWhiteSpace(palletNo))
             {
-                throw new Exception(e.Message);
+                list = list.Where(m => m.PalletNo == palletNo);
             }
+
+            var data = await list.GroupBy(m => new { m.SkuNo, m.SkuName, m.LotNo }).Select(m => new StockCheckDetailDto()
+            {
+                SkuNo = m.SkuNo,
+                SkuName = m.SkuName,
+                LotNo = m.LotNo
+            }).ToListAsync();
+
+            return data;
         }
 
         //鑾峰彇瑕佺洏鐐圭殑绠辩爜淇℃伅锛堢洏鐐硅褰曚腑鏁版嵁锛�
-        public List<StockCheckLogDto> GetStockCheckLogList(string crNo, string crDetail, string palletNo, string boxNo, string isContinue)
+        public async Task<List<StockCheckLogDto>> GetStockCheckLogList(string crNo, string crDetail, string palletNo, string boxNo, string isContinue)
         {
-            try
+            if (string.IsNullOrWhiteSpace(crNo))
             {
-                if (string.IsNullOrWhiteSpace(crNo))
-                {
-                    throw new Exception("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
-                }
-                if (string.IsNullOrWhiteSpace(crDetail))
-                {
-                    throw new Exception("鐗╂枡鎵规涓嶈兘涓虹┖");
-                }
-                if (string.IsNullOrWhiteSpace(palletNo))
-                {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
-                }
+                throw Oops.Bah("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(crDetail))
+            {
+                throw Oops.Bah("鐗╂枡鎵规涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(palletNo))
+            {
+                throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
+            }
 
-                var detail = crDetail.Split("-");
-                var sku = detail[0];
-                //鍒ゆ柇鏄惁涓烘棤鐮佺墿鏂�
-                var skuinfo = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == sku);
-                //鍒ゆ柇鏄惁瀛樺湪鐗╂枡娑堟伅
-                if (skuinfo == null)
+            var detail = crDetail.Split("-");
+            var sku = detail[0];
+            //鍒ゆ柇鏄惁涓烘棤鐮佺墿鏂�
+            var skuinfo = await Db.Queryable<SysMaterials>().FirstAsync(m => m.IsDel == "0" && m.SkuNo == sku);
+            //鍒ゆ柇鏄惁瀛樺湪鐗╂枡娑堟伅
+            if (skuinfo == null)
+            {
+                throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
+            }
+            int isQtySku = 0;
+            if (skuinfo.Type == "4" && isContinue == "1")
+            {
+                isQtySku = 1;
+            }
+            var lotNo = detail[1];
+            var list = Db.Queryable<BllStockCheckLog>().Where(m => m.IsDel == "0" && m.CRNo == crNo);
+            //var deList= Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.SkuNo == sku && m.LotNo == lotNo && m.PalletNo == palletNo);
+            //if (deList.Count() == 0)
+            //{
+            //    throw new Exception("鏈煡璇㈠埌鎵樼洏涓婄殑鐩樼偣鐗╂枡鎵规淇℃伅");
+            //}
+            list = list.Where(m => m.SkuNo == sku && m.LotNo == lotNo && m.PalletNo == palletNo);
+            if (!string.IsNullOrWhiteSpace(boxNo))
+            {
+                list = list.Where(m => m.BoxNo == boxNo);
+            }
+            List<StockCheckLogDto> data = new List<StockCheckLogDto>();
+            //鍒ゆ柇鏄惁涓烘棤鐮佺墿鏂�
+            if (isQtySku == 1)
+            {
+                //鑾峰彇搴撳瓨淇℃伅
+                var stockDetail = Db.Queryable<DataStockDetail>().First(a => a.IsDel == "0" && a.Status == "3" && a.SkuNo == sku && a.PalletNo == palletNo);
+
+                var model = new StockCheckLogDto()
                 {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
-                }
-                int isQtySku = 0;
-                if (skuinfo.Type == "4" && isContinue == "1")
+                    PalletNo = palletNo,
+                    SkuNo = sku,
+                    Qty = stockDetail.Qty,
+                    CheckResult = 4,
+                };
+
+                data.Add(model);
+
+            }
+            else
+            {
+                data = await list.Select(m => new StockCheckLogDto()
                 {
-                    isQtySku = 1;
-                }
-                var lotNo = detail[1];
-                var list = Db.Queryable<BllStockCheckLog>().Where(m => m.IsDel == "0" && m.CRNo == crNo);
-                //var deList= Db.Queryable<BllStockCheckDetail>().Where(m => m.IsDel == "0" && m.SkuNo == sku && m.LotNo == lotNo && m.PalletNo == palletNo);
-                //if (deList.Count() == 0)
-                //{
-                //    throw new Exception("鏈煡璇㈠埌鎵樼洏涓婄殑鐩樼偣鐗╂枡鎵规淇℃伅");
-                //}
-                list = list.Where(m => m.SkuNo == sku && m.LotNo == lotNo && m.PalletNo == palletNo);
+                    BoxNo = m.BoxNo,
+                    BoxNo3 = m.BoxNo3,
+                    SkuNo = m.SkuNo,
+                    SkuName = m.SkuName,
+                    LotNo = m.LotNo,
+                    Qty = m.Qty,
+                    CheckResult = m.CheckResult,
+
+                }).ToListAsync();
+
+            }
+
+            return data;
+
+        }
+
+        public async Task CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo, string boxNo3, string result, decimal? qty, string isContinue, int userId)
+        {
+            if (string.IsNullOrWhiteSpace(crNo))
+            {
+                throw Oops.Bah("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(crDetail))
+            {
+                throw Oops.Bah("鐗╂枡鎵规涓嶈兘涓虹┖");
+            }
+            if (string.IsNullOrWhiteSpace(palletNo))
+            {
+                throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
+            }
+            //绠辩爜涓虹┖  鏄暣鎵樿鐩樼偣鐨勯兘姝e父
+            var detail = crDetail.Split("-");
+            var sku = detail[0];
+            var lotNo = detail[1];
+            //鐩樼偣鏄庣粏
+            var checkDetail = await Db.Queryable<BllStockCheckDetail>().FirstAsync(m =>
+                m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+            if (checkDetail == null)
+            {
+                throw Oops.Bah("鏈煡璇㈠埌鏈洏鐐圭殑鐩樼偣鏄庣粏淇℃伅");
+            }
+            var modSku = await Db.Queryable<SysMaterials>().Where(s => s.SkuNo == sku).FirstAsync();
+            if (modSku.IsPasteCode == "1" && isContinue == "1")
+            {
+                throw Oops.Bah("璐存爣鐗╂枡涓嶅厑璁告暟閲忕洏鐐�");
+            }
+            else if (modSku.IsPasteCode == "0" && isContinue == "0")
+            {
+                throw Oops.Bah("涓嶈创鏍囩墿鏂欒浣跨敤鏁伴噺鐩樼偣");
+            }
+            //鐩樼偣璁板綍
+            var checkLog = Db.Queryable<BllStockCheckLog>().Where(m =>
+                m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo && m.CheckResult == null);
+            var time = DateTime.Now;
+            //姝e父
+            if (result == "0")
+            {
                 if (!string.IsNullOrWhiteSpace(boxNo))
                 {
-                    list = list.Where(m => m.BoxNo == boxNo);
+                    checkLog = checkLog.Where(m => m.BoxNo == boxNo);
                 }
-                List<StockCheckLogDto> data = new List<StockCheckLogDto>();
-                //鍒ゆ柇鏄惁涓烘棤鐮佺墿鏂�
-                if (isQtySku == 1)
+                if (!string.IsNullOrWhiteSpace(boxNo3))
                 {
-                    //鑾峰彇搴撳瓨淇℃伅
-                    var stockDetail = Db.Queryable<DataStockDetail>().First(a => a.IsDel == "0" && a.Status == "3" && a.SkuNo == sku && a.PalletNo == palletNo);
+                    checkLog = checkLog.Where(m => m.BoxNo3 == boxNo3);
+                }
 
-                    var model = new StockCheckLogDto()
+                if (await checkLog.CountAsync() == 0 && isContinue == "0")
+                {
+                    throw Oops.Bah("鏈煡璇㈠埌鏈洏鐐圭殑绠辨敮淇℃伅");
+                }
+
+                var list = await checkLog.ToListAsync();
+                var num = 0;
+                foreach (var l in list)
+                {
+                    if (l.CheckResult != null)
                     {
+                        continue;
+                    }
+                    l.RealQty = l.Qty;
+                    l.CheckResult = 0;
+                    l.CheckDate = time;
+                    l.CheckUserId = userId;
+
+                    num += Convert.ToInt32(l.Qty);
+                }
+
+                if (checkDetail.RealQty == null)
+                {
+                    checkDetail.RealQty = 0;
+                }
+                checkDetail.RealQty += num;
+                checkDetail.CheckResult = 0;
+                //if (checkDetail.CheckResult == null || checkDetail.CheckResult == 0)
+                //{
+                //    checkDetail.CheckResult = 0;
+                //}
+                await Db.Updateable(checkDetail).ExecuteCommandAsync();
+                await Db.Updateable(list).ExecuteCommandAsync();
+            }
+            //鐩樹簭
+            else if (result == "1")
+            {
+                if (!string.IsNullOrWhiteSpace(boxNo))
+                {
+                    checkLog = checkLog.Where(m => m.BoxNo == boxNo);
+                }
+                if (!string.IsNullOrWhiteSpace(boxNo3))
+                {
+                    checkLog = checkLog.Where(m => m.BoxNo3 == boxNo3);
+                }
+
+                if (checkLog.Count() == 0 && isContinue == "0")
+                {
+                    throw Oops.Bah("鏈煡璇㈠埌绠辨敮淇℃伅");
+                }
+
+                //
+                if (isContinue == "1")
+                {
+                    if (qty == null || qty <= 0)
+                    {
+                        throw Oops.Bah("鏁伴噺鐩樼偣鏃躲�佺洏浜忔暟閲忎笉鑳戒负绌轰笖闇�澶т簬0");
+                    }
+                }
+
+
+                var list = checkLog.ToList();
+                var num = 0;
+                foreach (var l in list)
+                {
+                    l.RealQty = 0;
+                    l.CheckResult = 1;
+                    l.CheckDate = time;
+                    l.CheckUserId = userId;
+                    num -= Convert.ToInt32(l.RealQty);
+                }
+                if (checkDetail.RealQty == null)
+                {
+                    checkDetail.RealQty = 0;
+                }
+                checkDetail.RealQty += num;
+                if (isContinue == "1")
+                {
+                    checkDetail.RealQty = qty;
+                }
+                checkDetail.CheckResult = 1;
+                var checkInfo = await Db.Queryable<BllStockCheckLog>().FirstAsync(m =>
+                m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+                checkInfo.RealQty = qty;
+                checkInfo.CheckResult = 1;
+
+                checkInfo.CheckUserId = userId;
+                checkInfo.CheckDate = time;
+
+                checkInfo.UpdateUser = userId;
+                checkInfo.UpdateTime = time;
+                await Db.Updateable(checkInfo).ExecuteCommandAsync();
+                await Db.Updateable(checkDetail).ExecuteCommandAsync();
+                await Db.Updateable(list).ExecuteCommandAsync();
+            }
+            //鐩樼泩
+            else if (result == "2")
+            {
+                if (isContinue == "0")
+                {
+                    if (string.IsNullOrWhiteSpace(boxNo) || string.IsNullOrWhiteSpace(boxNo3))
+                    {
+                        throw Oops.Bah("鐩樼泩鏃剁鐮佷笌鏀爜涓嶈兘涓虹┖");
+                    }
+                }
+                if (qty == null || qty <= 0)
+                {
+                    throw Oops.Bah("鐩樼泩鏃舵暟閲忎笉鑳戒负绌轰笖闇�澶т簬0");
+                }
+                if (isContinue == "0")
+                {
+                    var count = await Db.Queryable<DataBoxInfo>()
+                    .CountAsync(m => m.IsDel == "0" && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
+                    var count2 = await Db.Queryable<BllStockCheckLog>()
+                        .CountAsync(m => m.IsDel == "0" && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
+                    if (count > 0 || count2 > 0)
+                    {
+                        throw Oops.Bah("褰撳墠搴撳瓨涓凡瀛樺湪璇ョ鏀俊鎭�");
+                    }
+                }
+                BllStockCheckLog crLog = new BllStockCheckLog();
+                if (isContinue == "0")
+                {
+                    crLog = new BllStockCheckLog()
+                    {
+                        CRNo = crNo,
                         PalletNo = palletNo,
-                        SkuNo = sku,
-                        Qty = stockDetail.Qty,
-                        CheckResult = 4,
+                        BoxNo = boxNo,
+                        BoxNo2 = null,
+                        BoxNo3 = boxNo3,
+                        Qty = qty,
+                        SkuNo = checkDetail.SkuNo,
+                        SkuName = checkDetail.SkuName,
+                        Standard = checkDetail.Standard,
+                        LotNo = checkDetail.LotNo,
+                        LotText = checkDetail.LotText,
+                        SupplierLot = checkDetail.SupplierLot,
+
+                        RealQty = qty,
+                        CheckResult = 2,
+                        CheckDate = time,
+                        CheckUserId = userId,
+
+                        CreateUser = userId,
+                        CreateTime = time
                     };
-
-                    data.Add(model);
-
                 }
                 else
                 {
-                    data = list.Select(m => new StockCheckLogDto()
-                    {
-                        BoxNo = m.BoxNo,
-                        BoxNo3 = m.BoxNo3,
-                        SkuNo = m.SkuNo,
-                        SkuName = m.SkuName,
-                        LotNo = m.LotNo,
-                        Qty = m.Qty,
-                        CheckResult = m.CheckResult,
-
-                    }).ToList();
-
-                }
-
-                return data;
-
-            }
-            catch (Exception e)
-            {
-                throw new Exception(e.Message);
-            }
-        }
-
-        public void CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo, string boxNo3, string result, decimal? qty, string isContinue, int userId)
-        {
-            try
-            {
-                if (string.IsNullOrWhiteSpace(crNo))
-                {
-                    throw new Exception("鐩樼偣鍗曟嵁涓嶈兘涓虹┖");
-                }
-                if (string.IsNullOrWhiteSpace(crDetail))
-                {
-                    throw new Exception("鐗╂枡鎵规涓嶈兘涓虹┖");
-                }
-                if (string.IsNullOrWhiteSpace(palletNo))
-                {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
-                }
-                //绠辩爜涓虹┖  鏄暣鎵樿鐩樼偣鐨勯兘姝e父
-                var detail = crDetail.Split("-");
-                var sku = detail[0];
-                var lotNo = detail[1];
-                //鐩樼偣鏄庣粏
-                var checkDetail = Db.Queryable<BllStockCheckDetail>().First(m =>
-                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
-                if (checkDetail == null)
-                {
-                    throw new Exception("鏈煡璇㈠埌鏈洏鐐圭殑鐩樼偣鏄庣粏淇℃伅");
-                }
-                //鐩樼偣璁板綍
-                var checkLog = Db.Queryable<BllStockCheckLog>().Where(m =>
-                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo && m.CheckResult == null);
-                var time = DateTime.Now;
-                //姝e父
-                if (result == "0")
-                {
-                    if (!string.IsNullOrWhiteSpace(boxNo))
-                    {
-                        checkLog = checkLog.Where(m => m.BoxNo == boxNo);
-                    }
-                    if (!string.IsNullOrWhiteSpace(boxNo3))
-                    {
-                        checkLog = checkLog.Where(m => m.BoxNo3 == boxNo3);
-                    }
-
-                    if (checkLog.Count() == 0 && isContinue == "0")
-                    {
-                        throw new Exception("鏈煡璇㈠埌鏈洏鐐圭殑绠辨敮淇℃伅");
-                    }
-
-                    var list = checkLog.ToList();
-                    var num = 0;
-                    foreach (var l in list)
-                    {
-                        if (l.CheckResult != null)
-                        {
-                            continue;
-                        }
-                        l.RealQty = l.Qty;
-                        l.CheckResult = 0;
-                        l.CheckDate = time;
-                        l.CheckUserId = userId;
-
-                        num += int.Parse(l.Qty.ToString());
-                    }
-
-                    if (checkDetail.RealQty == null)
-                    {
-                        checkDetail.RealQty = 0;
-                    }
-                    checkDetail.RealQty += num;
-                    checkDetail.CheckResult = 0;
-                    //if (checkDetail.CheckResult == null || checkDetail.CheckResult == 0)
-                    //{
-                    //    checkDetail.CheckResult = 0;
-                    //}
-                    Db.Updateable(checkDetail).ExecuteCommand();
-                    Db.Updateable(list).ExecuteCommand();
-                }
-                //鐩樹簭
-                else if (result == "1")
-                {
-                    if (!string.IsNullOrWhiteSpace(boxNo))
-                    {
-                        checkLog = checkLog.Where(m => m.BoxNo == boxNo);
-                    }
-                    if (!string.IsNullOrWhiteSpace(boxNo3))
-                    {
-                        checkLog = checkLog.Where(m => m.BoxNo3 == boxNo3);
-                    }
-
-                    if (checkLog.Count() == 0 && isContinue == "0")
-                    {
-                        throw new Exception("鏈煡璇㈠埌绠辨敮淇℃伅");
-                    }
-
-                    //
-                    if (isContinue == "1")
-                    {
-                        if (qty == null || qty <= 0)
-                        {
-                            throw new Exception("鏁伴噺鐩樼偣鏃躲�佺洏浜忔暟閲忎笉鑳戒负绌轰笖闇�澶т簬0");
-                        }
-                    }
-
-
-                    var list = checkLog.ToList();
-                    var num = 0;
-                    foreach (var l in list)
-                    {
-                        l.RealQty = 0;
-                        l.CheckResult = 1;
-                        l.CheckDate = time;
-                        l.CheckUserId = userId;
-                        num -= int.Parse(l.RealQty.ToString());
-                    }
-                    if (checkDetail.RealQty == null)
-                    {
-                        checkDetail.RealQty = 0;
-                    }
-                    checkDetail.RealQty += num;
-                    if (isContinue == "1")
-                    {
-                        checkDetail.RealQty = qty;
-                    }
-                    checkDetail.CheckResult = 1;
-                    var checkInfo = Db.Queryable<BllStockCheckLog>().First(m =>
-                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+                    var checkInfo = await Db.Queryable<BllStockCheckLog>().FirstAsync(m =>
+                m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
                     checkInfo.RealQty = qty;
-                    checkInfo.CheckResult = 1;
+                    checkInfo.CheckResult = 2;
 
                     checkInfo.CheckUserId = userId;
                     checkInfo.CheckDate = time;
 
                     checkInfo.UpdateUser = userId;
                     checkInfo.UpdateTime = time;
-                    Db.Updateable(checkInfo).ExecuteCommand();
-                    Db.Updateable(checkDetail).ExecuteCommand();
-                    Db.Updateable(list).ExecuteCommand();
+                    await Db.Updateable(checkInfo).ExecuteCommandAsync();
                 }
-                //鐩樼泩
-                else if (result == "2")
+
+                if (checkDetail.RealQty == null && isContinue == "0")
                 {
-                    if (isContinue == "0")
-                    {
-                        if (string.IsNullOrWhiteSpace(boxNo) || string.IsNullOrWhiteSpace(boxNo3))
-                        {
-                            throw new Exception("鐩樼泩鏃剁鐮佷笌鏀爜涓嶈兘涓虹┖");
-                        }
-                    }
-                    if (qty == null || qty <= 0)
-                    {
-                        throw new Exception("鐩樼泩鏃舵暟閲忎笉鑳戒负绌轰笖闇�澶т簬0");
-                    }
-                    if (isContinue == "0")
-                    {
-                        var count = Db.Queryable<DataBoxInfo>()
-                        .Count(m => m.IsDel == "0" && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
-                        var count2 = Db.Queryable<BllStockCheckLog>()
-                            .Count(m => m.IsDel == "0" && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
-                        if (count > 0 || count2 > 0)
-                        {
-                            throw new Exception("褰撳墠搴撳瓨涓凡瀛樺湪璇ョ鏀俊鎭�");
-                        }
-                    }
-                    BllStockCheckLog crLog = new BllStockCheckLog();
-                    if (isContinue == "0")
-                    {
-                        crLog = new BllStockCheckLog()
-                        {
-                            CRNo = crNo,
-                            PalletNo = palletNo,
-                            BoxNo = boxNo,
-                            BoxNo2 = null,
-                            BoxNo3 = boxNo3,
-                            Qty = qty,
-                            SkuNo = checkDetail.SkuNo,
-                            SkuName = checkDetail.SkuName,
-                            Standard = checkDetail.Standard,
-                            LotNo = checkDetail.LotNo,
-                            LotText = checkDetail.LotText,
-                            SupplierLot = checkDetail.SupplierLot,
-
-                            RealQty = qty,
-                            CheckResult = 2,
-                            CheckDate = time,
-                            CheckUserId = userId,
-
-                            CreateUser = userId,
-                            CreateTime = time
-                        };
-                    }
-                    else
-                    {
-                        var checkInfo = Db.Queryable<BllStockCheckLog>().First(m =>
-                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
-                        checkInfo.RealQty = qty;
-                        checkInfo.CheckResult = 2;
-
-                        checkInfo.CheckUserId = userId;
-                        checkInfo.CheckDate = time;
-
-                        checkInfo.UpdateUser = userId;
-                        checkInfo.UpdateTime = time;
-                        Db.Updateable(checkInfo).ExecuteCommand();
-                    }
-
-                    if (checkDetail.RealQty == null && isContinue == "0")
-                    {
-                        checkDetail.RealQty = 0;
-                    }
-                    checkDetail.RealQty += qty;
-                    if (isContinue == "1")
-                    {
-                        checkDetail.RealQty = qty;
-                    }
-                    checkDetail.CheckResult = 2;
-                    Db.Updateable(checkDetail).ExecuteCommand();
-                    if (isContinue == "0")
-                    {
-                        Db.Insertable(crLog).ExecuteCommand();
-                    }
+                    checkDetail.RealQty = 0;
                 }
-                else
+                checkDetail.RealQty += qty;
+                if (isContinue == "1")
                 {
-                    Db.RollbackTran();
-                    throw new Exception("鐩樼偣缁撴灉涓嶇锛岃鏍稿疄锛�");
+                    checkDetail.RealQty = qty;
                 }
-                var checkLogNum = Db.Queryable<BllStockCheckLog>().Where(m => m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
-                if (checkLogNum.Count(m => m.CheckResult == null) == 0)
+                checkDetail.CheckResult = 2;
+                await Db.Updateable(checkDetail).ExecuteCommandAsync();
+                if (isContinue == "0")
                 {
-                    var checkDe = Db.Queryable<BllStockCheckDetail>().First(m =>
-                        m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
-                    checkDe.Status = 3;
-                    Db.Updateable(checkDe).ExecuteCommand();
-                    var checkDeNum = Db.Queryable<BllStockCheckDetail>().Count(m =>
-                        m.IsDel == "0" && m.CRNo == crNo && m.Status != 3 && m.Id != checkDe.Id);
-                    if (checkDeNum == 0)
-                    {
-                        var check = Db.Queryable<BllStockCheck>().First(m => m.CRNo == crNo && m.IsDel == "0");
-                        check.Status = 2;
-                        check.CompleteDate = DateTime.Now;
-                        Db.Updateable(check).ExecuteCommand();
-
-                    }
+                    await Db.Insertable(crLog).ExecuteCommandAsync();
                 }
-                Db.CommitTran();
             }
-            catch (Exception e)
+            else
             {
-                Db.RollbackTran();
-                throw new Exception(e.Message);
+                throw Oops.Bah("鐩樼偣缁撴灉涓嶇锛岃鏍稿疄锛�");
+            }
+            var checkLogNum = Db.Queryable<BllStockCheckLog>().Where(m => m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+            if (await checkLogNum.CountAsync(m => m.CheckResult == null) == 0)
+            {
+                var checkDe = await Db.Queryable<BllStockCheckDetail>().FirstAsync(m =>
+                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+                checkDe.Status = 3;
+                await Db.Updateable(checkDe).ExecuteCommandAsync();
+                var checkDeNum = await Db.Queryable<BllStockCheckDetail>().CountAsync(m =>
+                    m.IsDel == "0" && m.CRNo == crNo && m.Status != 3 && m.Id != checkDe.Id);
+                if (checkDeNum == 0)
+                {
+                    var check = await Db.Queryable<BllStockCheck>().FirstAsync(m => m.CRNo == crNo && m.IsDel == "0");
+                    check.Status = 2;
+                    check.CompleteDate = DateTime.Now;
+                    await Db.Updateable(check).ExecuteCommandAsync();
+
+                }
             }
         }
 
@@ -434,29 +411,13 @@
         /// <param name="locatNo">鍌ㄤ綅缂栧彿</param>
         /// <param name="palletNo">鎵樼洏鍙�</param> 
         /// <returns></returns>
-        public List<DataStockDetail> GetStockQueryList(string locatNo, string palletNo)
+        public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
         {
-            string str = "select LocatNo,PalletNo,SkuName,SkuNo,Standard,LotNo,Qty,LockQty,FrozenQty,InspectQty from DataStockDetail Where IsDel = @isdel";
-            //鍒ゆ柇鍌ㄤ綅缂栧彿鏄惁涓虹┖
-            if (!string.IsNullOrEmpty(locatNo))
-            {
-                str += " and LocatNo like @locatno";
-            }
-            //鍒ゆ柇鎵樼洏鍙锋槸鍚︿负绌�
-            if (!string.IsNullOrEmpty(palletNo))
-            {
-                str += " and PalletNo like @palletno";
-            }
+            return await Db.Queryable<DataStockDetail>()
+                     .Where(s => s.IsDel == "0" && s.LocatNo.Contains(locatNo) && s.PalletNo.Contains(palletNo))
+                     .OrderBy(s => new { s.LotNo, s.LocatNo, s.PalletNo })
+                     .ToListAsync();
 
-            //鎺掑簭
-            str += " order by LotNo,LocatNo,PalletNo";
-            List<DataStockDetail> stockList = Db.Ado.SqlQuery<DataStockDetail>(str, new
-            {
-                isdel = "0", //鏄惁鍒犻櫎
-                locatno = "%" + locatNo + "%", //鍌ㄤ綅缂栧彿
-                palletno = "%" + palletNo + "%", //鎵樼洏鍙�
-            });
-            return stockList;
         }
 
         #endregion
@@ -464,238 +425,145 @@
         #region 鎵樼洏鍙樻洿锛堟墭鐩樿В缁戠粦瀹氾級
 
         //鏍规嵁鎵樼洏鍙疯幏鍙栫鐮佸拰绠卞唴鏁伴噺
-        public List<PdaPalletNoCheckDto> GetDataDetailList(string palletNo)
+        public async Task<List<PdaPalletNoCheckDto>> GetDataDetailList(string palletNo)
         {
-            try
+            if (string.IsNullOrWhiteSpace(palletNo))
             {
-                if (string.IsNullOrWhiteSpace(palletNo))
+                throw Oops.Bah("鎵樼洏鍙蜂笉鑳戒负绌�");
+            }
+            var detail = await Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).Select(m => m.Id).ToListAsync();
+            var info = await Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && detail.Contains(m.StockDetailId))
+                .GroupBy(m => m.BoxNo).Select(a => new PdaPalletNoCheckDto
                 {
-                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
-                }
-                var detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).Select(m => m.Id).ToList();
-                var info = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && detail.Contains(m.StockDetailId))
-                    .GroupBy(m => m.BoxNo).Select(a => new PdaPalletNoCheckDto
-                    {
-                        BoxNo = a.BoxNo,
-                        Qty = SqlFunc.AggregateSum(a.Qty)
-                    }).ToList();
-                return info;
-            }
-            catch (Exception e)
-            {
-                throw new Exception(e.Message);
-            }
+                    BoxNo = a.BoxNo,
+                    Qty = SqlFunc.AggregateSum(a.Qty)
+                }).ToListAsync();
+            return info;
         }
 
         //鏍规嵁绠辩爜鑾峰彇鐗╂枡銆佹壒娆°�佹暟閲忕瓑淇℃伅
-        public PdaPalletNoCheckDto GetBoxInfoByBox(string boxNo)
+        public async Task<PdaPalletNoCheckDto> GetBoxInfoByBox(string boxNo)
         {
-            try
+            if (string.IsNullOrWhiteSpace(boxNo))
             {
-                if (string.IsNullOrWhiteSpace(boxNo))
-                {
-                    throw new Exception("绠辩爜涓嶈兘涓虹┖");
-                }
-
-                var info = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo)
-                    .GroupBy(m => new { m.BoxNo, m.SkuNo, m.SkuName, m.LotNo }).Select(a => new PdaPalletNoCheckDto
-                    {
-                        BoxNo = a.BoxNo,
-                        SkuNo = a.SkuNo,
-                        SkuName = a.SkuName,
-                        LotNo = a.LotNo,
-                        Qty = SqlFunc.AggregateSum(a.Qty)
-                    }).ToList();
-                if (info.Count > 1)
-                {
-                    throw new Exception("褰撳墠绠辩爜鏌ヨ鍑哄鏉$墿鏂欐垨鎵规淇℃伅锛岃鏍稿疄");
-                }
-
-                return info.FirstOrDefault();
+                throw Oops.Bah("绠辩爜涓嶈兘涓虹┖");
             }
-            catch (Exception e)
+
+            var info = await Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo)
+                .GroupBy(m => new { m.BoxNo, m.SkuNo, m.SkuName, m.LotNo }).Select(a => new PdaPalletNoCheckDto
+                {
+                    BoxNo = a.BoxNo,
+                    SkuNo = a.SkuNo,
+                    SkuName = a.SkuName,
+                    LotNo = a.LotNo,
+                    Qty = SqlFunc.AggregateSum(a.Qty)
+                }).ToListAsync();
+            if (info.Count > 1)
             {
-                throw new Exception(e.Message);
+                throw Oops.Bah("褰撳墠绠辩爜鏌ヨ鍑哄鏉$墿鏂欐垨鎵规淇℃伅锛岃鏍稿疄");
             }
+
+            return info.FirstOrDefault();
         }
 
         //瑙g粦鍘熸墭鐩樼粦瀹氭柊鎵樼洏
-        public void SaveUnbind(string palletNo, string boxNo, string palletNoNew, int userId)
+        public async Task SaveUnbind(string palletNo, string boxNo, string palletNoNew, int userId)
         {
-            try
+            if (string.IsNullOrWhiteSpace(palletNo) || string.IsNullOrWhiteSpace(palletNoNew))
             {
-                if (string.IsNullOrWhiteSpace(palletNo) || string.IsNullOrWhiteSpace(palletNoNew))
+                throw Oops.Bah("鏂版棫鎵樼洏鍙蜂笉鑳戒负绌�");
+            }
+            if (palletNo == palletNoNew)
+            {
+                throw Oops.Bah("鏂版棫鎵樼洏鍙蜂笉鑳戒负鐩稿悓");
+            }
+            //搴撳瓨绠辨敮淇℃伅
+            var infos = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo);//鏁存墭鍙樻洿
+            if (!string.IsNullOrWhiteSpace(boxNo))
+            {
+                //鎸夌鍙樻洿
+                infos = infos.Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
+            }
+            List<DataBoxInfo> infosList = await infos.ToListAsync();
+            if (infosList.Count <= 0)
+            {
+                throw Oops.Bah("鍘熸墭鐩樹笂鏈煡鍒扮鏀槑缁嗭紝璇锋牳瀹�");
+            }
+            //搴撳瓨鏄庣粏id
+            var infoIds = await infos.GroupBy(m => m.StockDetailId).Select(a => a.StockDetailId).ToListAsync();
+            if (infoIds.Count == 0)
+            {
+                throw Oops.Bah("鏈煡璇㈠埌褰撳墠绠辩爜淇℃伅锛岃鏍稿疄");
+            }
+            var comTime = DateTime.Now;
+            //鏂版墭鐩樺簱瀛樻槑缁�
+            bool newPalletHaveGoods = false;//鏂版墭鐩樹笂鏄惁鏈夌墿鍝�
+            string pallWareHouseNo = string.Empty;//鏂版墭鐩樻墍鍦ㄧ殑浣嶇疆锛堝簱澶�/骞冲簱锛�
+            var stockDetailList = await Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew).ToListAsync();
+            if (stockDetailList != null && stockDetailList.Count() > 0)
+            {
+                newPalletHaveGoods = true;
+                pallWareHouseNo = stockDetailList[0].WareHouseNo;
+                if (!string.IsNullOrEmpty(stockDetailList[0].LocatNo))
                 {
-                    throw new Exception("鏂版棫鎵樼洏鍙蜂笉鑳戒负绌�");
+                    throw Oops.Bah("鏂版墭鐩樺湪绔嬪簱鍐呬笉鍏佽鍙樻洿锛岃鏍稿疄");
                 }
-                if (palletNo == palletNoNew)
+                #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
+                var box = await Db.Queryable<DataBoxInfo>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.BitBoxMark == "0");
+                if (box != null)
                 {
-                    throw new Exception("鏂版棫鎵樼洏鍙蜂笉鑳戒负鐩稿悓");
-                }
-                //搴撳瓨绠辨敮淇℃伅
-                var infos = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo);//鏁存墭鍙樻洿
-                if (!string.IsNullOrWhiteSpace(boxNo))
-                {
-                    //鎸夌鍙樻洿
-                    infos = infos.Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
-                }
-                List<DataBoxInfo> infosList = infos.ToList();
-                if (infosList.Count <= 0)
-                {
-                    throw new Exception("鍘熸墭鐩樹笂鏈煡鍒扮鏀槑缁嗭紝璇锋牳瀹�");
-                }
-                //搴撳瓨鏄庣粏id
-                var infoIds = infos.GroupBy(m => m.StockDetailId).Select(a => a.StockDetailId).ToList();
-                if (infoIds.Count == 0)
-                {
-                    throw new Exception("鏈煡璇㈠埌褰撳墠绠辩爜淇℃伅锛岃鏍稿疄");
-                }
-                //寮�鍚簨鍔�
-                Db.BeginTran();
-                var comTime = DateTime.Now;
-                //鏂版墭鐩樺簱瀛樻槑缁�
-                bool newPalletHaveGoods = false;//鏂版墭鐩樹笂鏄惁鏈夌墿鍝�
-                string pallWareHouseNo = string.Empty;//鏂版墭鐩樻墍鍦ㄧ殑浣嶇疆锛堝簱澶�/骞冲簱锛�
-                var stockDetailList = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNoNew).ToList();
-                if (stockDetailList != null && stockDetailList.Count() > 0)
-                {
-                    newPalletHaveGoods = true;
-                    pallWareHouseNo = stockDetailList[0].WareHouseNo;
-                    if (!string.IsNullOrEmpty(stockDetailList[0].LocatNo))
+                    foreach (var item in infosList)
                     {
-                        throw new Exception("鏂版墭鐩樺湪绔嬪簱鍐呬笉鍏佽鍙樻洿锛岃鏍稿疄");
-                    }
-                    #region 楠岃瘉鏄惁鍏佽绔嬪簱鍚屾墭鐩樹笉鍚岀墿鏂欏叆搴撴垨鍚屾墭鐩樺悓鐗╂枡涓嶅悓鎵规鍏ュ簱
-                    var box = Db.Queryable<DataBoxInfo>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.BitBoxMark == "0");
-                    if (box != null)
-                    {
-                        foreach (var item in infosList)
+                        if (box.SkuNo != item.SkuNo || box.LotNo != item.LotNo)
                         {
-                            if (box.SkuNo != item.SkuNo || box.LotNo != item.LotNo)
+                            var funSetting = await Db.Queryable<SysFunSetting>().FirstAsync(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
+                            if (funSetting == null || funSetting.IsEnable == "OFF")
                             {
-                                var funSetting = Db.Queryable<SysFunSetting>().First(a => a.IsDel == "0" && a.FunSetNo == "Fun045");
-                                if (funSetting == null || funSetting.IsEnable == "OFF")
-                                {
-                                    throw new Exception($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
-                                }
+                                throw Oops.Bah($"涓嶅厑璁哥珛搴撳悓鎵樼洏涓嶅悓鐗╂枡鍏ュ簱鎴栧悓鎵樼洏涓嶅悓鎵规鍏ュ簱锛�");
                             }
                         }
                     }
-                    #endregion
                 }
-                if (!newPalletHaveGoods)//鏂版墭鐩樹笂娌℃湁鐗╁搧
+                #endregion
+            }
+            if (!newPalletHaveGoods)//鏂版墭鐩樹笂娌℃湁鐗╁搧
+            {
+                var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
+                if (pallet == null)
                 {
-                    var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
-                    if (pallet == null)
-                    {
-                        throw new Exception("鏈煡璇㈠埌鏂版墭鐩樺彿淇℃伅");
-                    }
-                    if (pallet.Status == "0")
-                    {
-                        pallet.Status = "1";//灏嗘柊鎵樼洏鐘舵�佷慨鏀逛负宸蹭娇鐢�
-                        Db.Updateable(pallet).ExecuteCommand();
-                    }
-                    else
-                    {
-                        throw new Exception("鏂版墭鐩樺彿鐘舵�佷笉鏄湭浣跨敤");
-                    }
+                    throw Oops.Bah("鏈煡璇㈠埌鏂版墭鐩樺彿淇℃伅");
                 }
-                foreach (var infoIdItem in infoIds)
+                if (pallet.Status == "0")
                 {
-                    var infosList2 = infosList.Where(w => w.StockDetailId == infoIdItem).ToList();
-                    //鍘熸墭鐩樺簱瀛樻槑缁�
-                    var stockDetail1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id == infoIdItem);
-                    if (stockDetail1 == null)
-                    {
-                        throw new Exception("鏈湪鍘熸墭鐩樹笂鏌ヨ鍒扮鐮佷俊鎭紝璇锋牳瀹�");
-                    }
-                    if (!string.IsNullOrEmpty(stockDetail1.LocatNo))
-                    {
-                        throw new Exception("鍘熸墭鐩樺湪绔嬪簱鍐呬笉鍏佽鍙樻洿锛岃鏍稿疄");
-                    }
-                    var stockDetail2 = stockDetailList.FirstOrDefault(w => w.SkuNo == stockDetail1.SkuNo && w.LotNo == stockDetail1.LotNo);
+                    pallet.Status = "1";//灏嗘柊鎵樼洏鐘舵�佷慨鏀逛负宸蹭娇鐢�
+                    await Db.Updateable(pallet).ExecuteCommandAsync();
+                }
+                else
+                {
+                    throw Oops.Bah("鏂版墭鐩樺彿鐘舵�佷笉鏄湭浣跨敤");
+                }
+            }
+            foreach (var infoIdItem in infoIds)
+            {
+                var infosList2 = infosList.Where(w => w.StockDetailId == infoIdItem).ToList();
+                //鍘熸墭鐩樺簱瀛樻槑缁�
+                var stockDetail1 = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id == infoIdItem);
+                if (stockDetail1 == null)
+                {
+                    throw Oops.Bah("鏈湪鍘熸墭鐩樹笂鏌ヨ鍒扮鐮佷俊鎭紝璇锋牳瀹�");
+                }
+                if (!string.IsNullOrEmpty(stockDetail1.LocatNo))
+                {
+                    throw Oops.Bah("鍘熸墭鐩樺湪绔嬪簱鍐呬笉鍏佽鍙樻洿锛岃鏍稿疄");
+                }
+                var stockDetail2 = stockDetailList.FirstOrDefault(w => w.SkuNo == stockDetail1.SkuNo && w.LotNo == stockDetail1.LotNo);
 
-                    var stId = 0;
-                    if (stockDetail2 == null) //娣诲姞-鏂版墭鐩樹笂娌℃湁鍚岀墿鏂欏悓鎵规鐗╁搧
+                var stId = 0;
+                if (stockDetail2 == null) //娣诲姞-鏂版墭鐩樹笂娌℃湁鍚岀墿鏂欏悓鎵规鐗╁搧
+                {
+                    //鏂版墭鐩樻坊鍔犲簱瀛樻槑缁�
+                    var detail = new DataStockDetail()
                     {
-                        //鏂版墭鐩樻坊鍔犲簱瀛樻槑缁�
-                        var detail = new DataStockDetail()
-                        {
-                            LotNo = stockDetail1.LotNo,
-                            LotText = stockDetail1.LotText,
-                            SupplierLot = stockDetail1.SupplierLot,
-                            SkuNo = stockDetail1.SkuNo,
-                            SkuName = stockDetail1.SkuName,
-                            Standard = stockDetail1.Standard,
-                            Qty = infosList2.Sum(m => m.Qty),
-                            LockQty = 0,
-                            FrozenQty = 0,
-                            InspectQty = 0,
-                            ASNNo = stockDetail1.ASNNo,
-                            ASNDetailNo = stockDetail1.ASNDetailNo,
-                            WareHouseNo = pallWareHouseNo,
-                            RoadwayNo = "",
-                            AreaNo = "",
-                            LocatNo = stockDetail1.LocatNo,
-                            PalletNo = palletNoNew,//鏂版墭鐩樺彿
-                            PalletNo2 = "",
-                            PalletNo3 = "",
-
-                            CompleteTime = comTime,
-                            ProductionTime = stockDetail1.ProductionTime,
-                            ExpirationTime = stockDetail1.ExpirationTime,
-                            Status = "0",
-                            InspectMark = stockDetail1.InspectMark,
-                            InspectStatus = stockDetail1.InspectStatus,
-                            BitPalletMark = stockDetail1.BitPalletMark,
-                            PackagNo = stockDetail1.PackagNo,
-                            IsBale = "0",
-                            IsBelt = "0",
-
-                            IsDel = "0",
-                            CreateUser = userId,
-                            CreateTime = DateTime.Now
-                        };
-                        stId = Db.Insertable(detail).ExecuteReturnIdentity();
-                    }
-                    else //淇敼-鏂版墭鐩樻湁鐗╁搧
-                    {
-                        stockDetail2.Qty += infosList2.Sum(m => m.Qty);//鏂版墭鐩樺鍔犲簱瀛�
-                        Db.Updateable(stockDetail2).ExecuteCommand();
-                        stId = stockDetail2.Id;
-                    }
-                    //淇敼搴撳瓨
-                    stockDetail1.Qty -= infosList2.Sum(m => m.Qty);
-                    stockDetail1.BitPalletMark = "1";//鏄惁闆舵墭 0锛氬惁 1锛氭槸
-                    if (stockDetail1.Qty == 0)
-                    {
-                        Db.Deleteable(stockDetail1).ExecuteCommand();//鍒犻櫎鍘熸墭鐩樺簱瀛樻槑缁�
-                        //鍒ゅ師鎵樼洏杩樻湁娌℃湁璐х墿
-                        var stockDetail3 = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id != infoIds.First()).ToList();
-                        if (stockDetail3 == null || stockDetail3.Count <= 0)
-                        {
-                            var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
-                            pallet.Status = "0";//鍘熸墭鐩樻病鏈夎揣鐗╁悗灏嗙姸鎬佷慨鏀逛负鏈娇鐢�
-                            Db.Updateable(pallet).ExecuteCommand();
-                        }
-                    }
-                    else
-                    {
-                        Db.Updateable(stockDetail1).ExecuteCommand();//淇敼鍘熸墭鐩樺簱瀛樻槑缁�
-                    }
-                    foreach (var item in infosList2)
-                    {
-                        //淇敼搴撳瓨绠辩爜鏄庣粏
-                        item.StockDetailId = stId;
-                        item.BindNo = null;
-                        item.PalletNo = palletNoNew;
-                        Db.Updateable(item).ExecuteCommand();
-                    }
-                    //娣诲姞鎵樼洏瑙g粦缁戝畾璁板綍
-                    var unBind = new BllPalletUnbind()
-                    {
-                        UpbindPalletNo = palletNo,
-                        BindPalletNo = palletNoNew,
                         LotNo = stockDetail1.LotNo,
                         LotText = stockDetail1.LotText,
                         SupplierLot = stockDetail1.SupplierLot,
@@ -703,32 +571,99 @@
                         SkuName = stockDetail1.SkuName,
                         Standard = stockDetail1.Standard,
                         Qty = infosList2.Sum(m => m.Qty),
-                        PalletNo2 = stockDetail1.PalletNo2,
-                        PalletNo3 = stockDetail1.PalletNo3,
-                        BoxNo = boxNo,
-                        InspectNo = "",
+                        LockQty = 0,
+                        FrozenQty = 0,
+                        InspectQty = 0,
+                        ASNNo = stockDetail1.ASNNo,
+                        ASNDetailNo = stockDetail1.ASNDetailNo,
+                        WareHouseNo = pallWareHouseNo,
+                        RoadwayNo = "",
+                        AreaNo = "",
+                        LocatNo = stockDetail1.LocatNo,
+                        PalletNo = palletNoNew,//鏂版墭鐩樺彿
+                        PalletNo2 = "",
+                        PalletNo3 = "",
+
+                        CompleteTime = comTime,
+                        ProductionTime = stockDetail1.ProductionTime,
+                        ExpirationTime = stockDetail1.ExpirationTime,
+                        Status = "0",
+                        InspectMark = stockDetail1.InspectMark,
                         InspectStatus = stockDetail1.InspectStatus,
+                        BitPalletMark = stockDetail1.BitPalletMark,
+                        PackagNo = stockDetail1.PackagNo,
+                        IsBale = "0",
+                        IsBelt = "0",
 
                         IsDel = "0",
-                        CreateTime = comTime,
-                        CreateUser = userId
+                        CreateUser = userId,
+                        CreateTime = DateTime.Now
                     };
-                    Db.Insertable(unBind).ExecuteCommand();
+                    stId = await Db.Insertable(detail).ExecuteReturnIdentityAsync();
                 }
-                //娣诲姞鎿嶄綔鏃ュ織
-                if (string.IsNullOrEmpty(boxNo))
+                else //淇敼-鏂版墭鐩樻湁鐗╁搧
                 {
-                    boxNo = "鍏ㄩ儴";
+                    stockDetail2.Qty += infosList2.Sum(m => m.Qty);//鏂版墭鐩樺鍔犲簱瀛�
+                    await Db.Updateable(stockDetail2).ExecuteCommandAsync();
+                    stId = stockDetail2.Id;
                 }
-                new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鎵樼洏鍙樻洿锛氬師鎵樼洏鐮侊細{palletNo}涓婄殑绠辩爜{boxNo}瑙g粦锛岀粦瀹氬埌鏂版墭鐩榹palletNoNew}涓�", userId);
-                //鎻愪氦浜嬪姟
-                Db.CommitTran();
+                //淇敼搴撳瓨
+                stockDetail1.Qty -= infosList2.Sum(m => m.Qty);
+                stockDetail1.BitPalletMark = "1";//鏄惁闆舵墭 0锛氬惁 1锛氭槸
+                if (stockDetail1.Qty == 0)
+                {
+                    await Db.Deleteable(stockDetail1).ExecuteCommandAsync();//鍒犻櫎鍘熸墭鐩樺簱瀛樻槑缁�
+                                                                            //鍒ゅ師鎵樼洏杩樻湁娌℃湁璐х墿
+                    var stockDetail3 = await Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo && m.Id != infoIds.First()).ToListAsync();
+                    if (stockDetail3 == null || stockDetail3.Count <= 0)
+                    {
+                        var pallet = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                        pallet.Status = "0";//鍘熸墭鐩樻病鏈夎揣鐗╁悗灏嗙姸鎬佷慨鏀逛负鏈娇鐢�
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
+                    }
+                }
+                else
+                {
+                    await Db.Updateable(stockDetail1).ExecuteCommandAsync();//淇敼鍘熸墭鐩樺簱瀛樻槑缁�
+                }
+                foreach (var item in infosList2)
+                {
+                    //淇敼搴撳瓨绠辩爜鏄庣粏
+                    item.StockDetailId = stId;
+                    item.BindNo = null;
+                    item.PalletNo = palletNoNew;
+                    await Db.Updateable(item).ExecuteCommandAsync();
+                }
+                //娣诲姞鎵樼洏瑙g粦缁戝畾璁板綍
+                var unBind = new BllPalletUnbind()
+                {
+                    UpbindPalletNo = palletNo,
+                    BindPalletNo = palletNoNew,
+                    LotNo = stockDetail1.LotNo,
+                    LotText = stockDetail1.LotText,
+                    SupplierLot = stockDetail1.SupplierLot,
+                    SkuNo = stockDetail1.SkuNo,
+                    SkuName = stockDetail1.SkuName,
+                    Standard = stockDetail1.Standard,
+                    Qty = infosList2.Sum(m => m.Qty),
+                    PalletNo2 = stockDetail1.PalletNo2,
+                    PalletNo3 = stockDetail1.PalletNo3,
+                    BoxNo = boxNo,
+                    InspectNo = "",
+                    InspectStatus = stockDetail1.InspectStatus,
+
+                    IsDel = "0",
+                    CreateTime = comTime,
+                    CreateUser = userId
+                };
+                await Db.Insertable(unBind).ExecuteCommandAsync();
             }
-            catch (Exception e)
+            //娣诲姞鎿嶄綔鏃ュ織
+            if (string.IsNullOrEmpty(boxNo))
             {
-                Db.RollbackTran();
-                throw new Exception(e.Message);
+                boxNo = "鍏ㄩ儴";
             }
+            new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "鎿嶄綔鏃ュ織", boxNo, "缂栬緫", $"鎵樼洏鍙樻洿锛氬師鎵樼洏鐮侊細{palletNo}涓婄殑绠辩爜{boxNo}瑙g粦锛岀粦瀹氬埌鏂版墭鐩榹palletNoNew}涓�", userId);
         }
 
         #endregion
@@ -739,29 +674,22 @@
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        public string GetPalletLocatNo(string palletNo)
+        public async Task<string> GetPalletLocatNo(string palletNo)
         {
-            try
+            var models = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+            if (models == null)
             {
-                var models = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
-                if (models == null)
-                {
-                    throw new Exception("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                }
-                if (string.IsNullOrEmpty(models.LocatNo))
-                {
-                    throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                }
-                if (models.WareHouseNo != "W02")
-                {
-                    throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
-                }
-                return models.LocatNo;
+                throw Oops.Bah("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
             }
-            catch (Exception ex)
+            if (string.IsNullOrEmpty(models.LocatNo))
             {
-                throw new Exception(ex.Message);
+                throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
             }
+            if (models.WareHouseNo != "W02")
+            {
+                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+            }
+            return models.LocatNo;
         }
 
         /// <summary>
@@ -769,109 +697,79 @@
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        public List<SysStorageArea> GetStorageArea(string palletNo)
+        public async Task<List<SysStorageArea>> GetStorageArea(string palletNo)
         {
-            try
+            var storageArea = new List<SysStorageArea>();
+            if (string.IsNullOrEmpty(palletNo))
             {
-                var storageArea = new List<SysStorageArea>();
-                if (string.IsNullOrEmpty(palletNo))
+                storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToListAsync();
+            }
+            else
+            {
+                var models = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+                if (models == null)
                 {
-                    storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o=>o.AreaNo).ToList();
+                    throw Oops.Bah("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                if (string.IsNullOrEmpty(models.LocatNo))
+                {
+                    throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                if (models.WareHouseNo != "W02")
+                {
+                    throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+                }
+                var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == models.LocatNo);
+                if (storageLocat == null)
+                {
+                    throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+
+                if (storageLocat.AreaNo.Contains("B0"))
+                {
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B0") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToListAsync();
                 }
                 else
                 {
-                    var models = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
-                    if (models == null)
-                    {
-                        throw new Exception("鎵樼洏搴撳瓨淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
-                    if (string.IsNullOrEmpty(models.LocatNo))
-                    {
-                        throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
-                    if (models.WareHouseNo != "W02")
-                    {
-                        throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
-                    }
-                    var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == models.LocatNo);
-                    if (storageLocat == null)
-                    {
-                        throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
-                   
-                    if (storageLocat.AreaNo.Contains("B0"))
-                    {
-                        storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B0") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList();
-                    }
-                    else
-                    {
-                        storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B1") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList();
-                    }
-                }                
-                return storageArea;
+                    storageArea = await Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B1") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToListAsync();
+                }
             }
-            catch (Exception ex)
-            {
-                throw new Exception(ex.Message);
-            }
+            return storageArea;
         }
         /// <summary>
         /// 鑾峰彇宸插垎閰嶇殑鍑哄簱鍗曟嵁
         /// </summary>
         /// <returns></returns>
-        public List<string> GetRunSoNoticeList()
+        public async Task<List<string>> GetRunSoNoticeList()
         {
-            try
-            {
-                var allotList = Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && m.Status == "2").Select(m => m.SONo).Distinct().ToList();
-                return allotList;
-            }
-            catch (Exception ex)
-            {
-                throw new Exception(ex.Message);
-            }
+            return await Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && m.Status == "2").Select(m => m.SONo).Distinct().ToListAsync();
         }
         /// <summary>
         /// 鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樹笂鐗╂枡淇℃伅
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        public List<DataStockDetail> GetSkuInfoByPalletNo(string palletNo)
+        public async Task<List<DataStockDetail>> GetSkuInfoByPalletNo(string palletNo)
         {
-            try
+            if (string.IsNullOrEmpty(palletNo))
             {
-                if (string.IsNullOrEmpty(palletNo))
-                {
-                    throw new Exception("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
-                }
-                var skuInfoList = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
-                return skuInfoList;
+                throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
             }
-            catch (Exception ex)
-            {
-                throw new Exception(ex.Message);
-            }
+            return await Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToListAsync();
         }
         /// <summary>
         /// 鏍规嵁鍑哄簱鍗曞彿鑾峰彇鍒嗛厤鐨勬墭鐩樹俊鎭�
         /// </summary>
         /// <param name="soNo"></param>
         /// <returns></returns>
-        public List<string> GetPalletNoListBySoNo(string soNo)
+        public async Task<List<string>> GetPalletNoListBySoNo(string soNo)
         {
-            try
+            if (string.IsNullOrEmpty(soNo))
             {
-                if (string.IsNullOrEmpty(soNo))
-                {
-                    throw new Exception("璇烽�夋嫨鍑哄簱鍗曞彿锛�");
-                }
-                var palletNoList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo).Select(m => m.PalletNo).Distinct().ToList();
-                return palletNoList;
+                throw Oops.Bah("璇烽�夋嫨鍑哄簱鍗曞彿锛�");
             }
-            catch (Exception ex)
-            {
-                throw new Exception(ex.Message);
-            }
+            var palletNoList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo).Select(m => m.PalletNo).Distinct().ToListAsync();
+            return palletNoList;
         }
 
         /// <summary>
@@ -880,79 +778,215 @@
         /// <param name="palletNo"></param>
         /// <param name="areaNo"></param>
         /// <param name="ruku"></param>
-        public void AgvTransport(string palletNo, string areaNo, string ruku, int userId)
+        public async Task AgvTransport(string palletNo, string areaNo, string ruku, int userId)
         {
             if (string.IsNullOrEmpty(palletNo))
             {
-                throw new Exception("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+                throw Oops.Bah("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
             }
             if (string.IsNullOrEmpty(areaNo) && string.IsNullOrEmpty(ruku))
             {
-                throw new Exception("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�");
+                throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�");
             }
             if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku))
             {
-                throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�");
-            }            
-            try
-            {
-                string EndLocat = string.Empty;//鐩爣浣嶇疆                
+                throw Oops.Bah("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�");
+            }
+            string EndLocat = string.Empty;//鐩爣浣嶇疆                
 
-                var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
-                if (log != null)
+            var log = await Db.Queryable<LogTask>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+            if (log != null)
+            {
+                throw Oops.Bah("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+            }
+            var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+            if (stockDetail == null)
+            {
+                throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!");
+            }
+            if (!string.IsNullOrEmpty(areaNo))
+            {
+                var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+                if (storageArea == null)
                 {
-                    throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
-                }                
-                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
-                if (stockDetail == null)
-                {
-                    throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!");
+                    throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
                 }
-                if (!string.IsNullOrEmpty(areaNo))
+                EndLocat = await GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo, palletNo);
+            }
+            else
+            {
+                EndLocat = ruku;
+            }
+            var stock = await Db.Queryable<DataStock>().FirstAsync(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
+            if (stock == null)
+            {
+                throw Oops.Bah("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+            }
+            if (string.IsNullOrEmpty(stockDetail.LocatNo))
+            {
+                throw Oops.Bah("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+            }
+            if (stockDetail.WareHouseNo != "W02")
+            {
+                throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+            }
+            //璧峰鍌ㄤ綅淇℃伅
+            var storageLocat = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+            if (storageLocat == null)
+            {
+                throw Oops.Bah("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+            }
+            //鐩爣鍌ㄤ綅淇℃伅
+            var storageLocatEnd = new SysStorageLocat();
+            if (!string.IsNullOrEmpty(areaNo))
+            {
+                storageLocatEnd = await Db.Queryable<SysStorageLocat>().FirstAsync(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
+                if (storageLocatEnd == null)
                 {
-                    var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo);
-                    if (storageArea == null)
-                    {
-                        throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
-                    }
-                    EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo);
+                    throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+            }
+
+            //娣诲姞鍑哄簱浠诲姟
+            var taskNo = new Common().GetMaxNo("TK");
+            var exTask = new LogTask
+            {
+                TaskNo = taskNo,
+                Sender = "WMS",
+                Receiver = "AGV",
+                IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+                StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+                EndLocat = EndLocat,//鐩爣浣嶇疆
+                PalletNo = palletNo,//鎵樼洏鐮�
+                Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", stockDetail.LocatNo, EndLocat),
+                IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+                IsCancel = 1,//鏄惁鍙彇娑�
+                IsFinish = 1,//鏄惁鍙畬鎴�
+                Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
+                Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+                OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
+
+                CreateTime = DateTime.Now
+            };
+            await Db.Insertable(exTask).ExecuteCommandAsync();
+
+            //淇敼搴撳瓨鏄庣粏淇℃伅
+            stockDetail.Status = "4";//绉诲簱閿佸畾
+            stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
+            await Db.Updateable(stockDetail).ExecuteCommandAsync();
+            //淇敼搴撳瓨淇℃伅
+            stock.LockQty += (decimal)stockDetail.Qty;
+            await Db.Updateable(stock).ExecuteCommandAsync();
+
+            //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
+            storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+            await Db.Updateable(storageLocat).ExecuteCommandAsync();
+
+            //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
+            if (storageLocatEnd != null)
+            {
+                storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+            }
+            //娣诲姞鎿嶄綔鏃ュ織璁板綍
+            var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+
+            #region 鍛煎彨灏忚溅浠g爜
+
+            #endregion
+        }
+        /// <summary>
+        /// agv杞繍鍛煎彨灏忚溅鍙栬揣
+        /// </summary>
+        /// <param name="soNo"></param>
+        /// <param name="palletNo"></param>
+        /// <param name="areaNo"></param>
+        /// <param name="userId"></param>
+        public async Task AgvTransport2(string soNo, string palletNo, string areaNo, int userId)
+        {
+            if (string.IsNullOrEmpty(soNo))
+            {
+                throw Oops.Bah("璇烽�夋嫨鍑哄簱鍗曟嵁锛�");
+            }
+            if (string.IsNullOrEmpty(areaNo))
+            {
+                throw Oops.Bah("璇烽�夋嫨鐩爣鍖哄煙锛�");
+            }
+            //鍑哄簱鍗曚俊鎭�
+            var notice = await Db.Queryable<BllExportNotice>().FirstAsync(w => w.IsDel == "0" && w.SONo == soNo);
+            if (notice == null)
+            {
+                throw Oops.Bah("鍑哄簱鍗曟嵁淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+            }
+            //鐩爣鍖哄煙淇℃伅
+            var storageArea = await Db.Queryable<SysStorageArea>().FirstAsync(w => w.IsDel == "0" && w.AreaNo == areaNo);
+            if (storageArea == null)
+            {
+                throw Oops.Bah("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+            }
+            List<DataStockDetail> stockDetailList = new List<DataStockDetail>();//闇�瑕佺殑鎵樼洏鏄庣粏
+            if (!string.IsNullOrEmpty(palletNo))//鍗曟墭鐩樺彨璐�
+            {
+                stockDetailList = await Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.PalletNo == palletNo).ToListAsync();
+            }
+            else//鏁翠釜鍑哄簱鍗曞彨璐�
+            {
+                string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')";
+                stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList();
+            }
+            if (stockDetailList.Count <= 0)
+            {
+                throw Oops.Bah("鎵樼洏鏄庣粏涓嶅瓨鍦�,璇锋鏌�!");
+            }
+
+            var log = Db.Queryable<LogTask>().Where(w => w.IsDel == "0" && (w.Status == "0" || w.Status == "1"));//浠诲姟琛�
+            var storageLocat = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0");//鍌ㄤ綅琛�
+            var stock = Db.Queryable<DataStock>().Where(w => w.IsDel == "0");//搴撳瓨鎬昏〃
+            string EndLocat = string.Empty;//鐩爣浣嶇疆
+            string hasLocatNoList = string.Empty;//宸插垎閰嶇殑鍌ㄤ綅
+            foreach (var item in stockDetailList)
+            {
+                //浠诲姟淇℃伅
+                var logInfo = await log.FirstAsync(w => w.PalletNo == item.PalletNo);
+                if (logInfo != null)
+                {
+                    throw Oops.Bah($"鎵樼洏鍙凤細{item.PalletNo}宸叉湁灏忚溅绛夊緟鎵ц鎴栨鍦ㄦ墽琛岀殑浠诲姟!");
+                }
+                if (string.IsNullOrEmpty(item.LocatNo))
+                {
+                    throw Oops.Bah($"鎵樼洏鍙凤細{item.PalletNo}鐨勫偍浣嶄俊鎭笉瀛樺湪,璇锋鏌�!");
+                }
+                if (item.WareHouseNo != "W02")
+                {
+                    throw Oops.Bah($"鎵樼洏鍙凤細{item.PalletNo}鏈湪骞冲簱鍐�,璇锋鏌�!");
+                }
+                //璧峰鍌ㄤ綅淇℃伅
+                var storageLocatBegin = await storageLocat.FirstAsync(w => w.LocatNo == item.LocatNo);
+                if (storageLocat == null)
+                {
+                    throw Oops.Bah($"鎵樼洏鍙凤細{item.PalletNo}鎵�鍦ㄧ殑鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                }
+                //鑾峰彇鐩爣鍌ㄤ綅
+                EndLocat = await GetLocat(areaNo, item.SkuNo, item.LotNo, palletNo);
+                if (string.IsNullOrEmpty(EndLocat))
+                {
+                    throw Oops.Bah("鍒嗛厤鐩爣鍌ㄤ綅澶辫触,璇锋鏌�!");
+                }
+                if (string.IsNullOrEmpty(hasLocatNoList))
+                {
+                    hasLocatNoList = EndLocat;
                 }
                 else
                 {
-                    EndLocat = ruku;
-                }
-                var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
-                if (stock == null)
-                {
-                    throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
-                }
-                if (string.IsNullOrEmpty(stockDetail.LocatNo))
-                {
-                    throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                }
-                if (stockDetail.WareHouseNo != "W02")
-                {
-                    throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
-                }
-                //璧峰鍌ㄤ綅淇℃伅
-                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
-                if (storageLocat == null)
-                {
-                    throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+                    hasLocatNoList = hasLocatNoList + "," + EndLocat;
                 }
                 //鐩爣鍌ㄤ綅淇℃伅
-                var storageLocatEnd = new SysStorageLocat();
-                if (!string.IsNullOrEmpty(areaNo))
+                var storageLocatEnd = storageLocat.First(w => w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
+                if (storageLocatEnd == null)
                 {
-                    storageLocatEnd = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
-                    if (storageLocatEnd == null)
-                    {
-                        throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
+                    throw Oops.Bah("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
                 }
-                
-                //寮�鍚簨鍔�
-                Db.BeginTran();
 
                 //娣诲姞鍑哄簱浠诲姟
                 var taskNo = new Common().GetMaxNo("TK");
@@ -962,11 +996,10 @@
                     Sender = "WMS",
                     Receiver = "AGV",
                     IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
-
-                    StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", item.LocatNo, EndLocat),
+                    StartLocat = item.LocatNo,//璧峰浣嶇疆
                     EndLocat = EndLocat,//鐩爣浣嶇疆
                     PalletNo = palletNo,//鎵樼洏鐮�
-                    Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", stockDetail.LocatNo, EndLocat),
                     IsSend = 1,//鏄惁鍙啀娆′笅鍙�
                     IsCancel = 1,//鏄惁鍙彇娑�
                     IsFinish = 1,//鏄惁鍙畬鎴�
@@ -976,199 +1009,39 @@
 
                     CreateTime = DateTime.Now
                 };
-                Db.Insertable(exTask).ExecuteCommand();
+                await Db.Insertable(exTask).ExecuteCommandAsync();
 
                 //淇敼搴撳瓨鏄庣粏淇℃伅
-                stockDetail.Status = "4";//绉诲簱閿佸畾
-                stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
-                Db.Updateable(stockDetail).ExecuteCommand();
-                //淇敼搴撳瓨淇℃伅
-                stock.LockQty += (decimal)stockDetail.Qty;
-                Db.Updateable(stock).ExecuteCommand();
+                item.Status = "4";//绉诲簱閿佸畾
+                item.LockQty = item.Qty;//閿佸畾搴撳瓨鏁伴噺
+                await Db.Updateable(item).ExecuteCommandAsync();
 
                 //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
-                storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
-                Db.Updateable(storageLocat).ExecuteCommand();
-
+                storageLocatBegin.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                await Db.Updateable(storageLocatBegin).ExecuteCommandAsync();
                 //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
-                if (storageLocatEnd != null)
-                {
-                    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
-                    Db.Updateable(storageLocatEnd).ExecuteCommand();
-                }               
+                storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
+                await Db.Updateable(storageLocatEnd).ExecuteCommandAsync();
+
+                var stockInfo = await stock.FirstAsync(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo);
+                //淇敼搴撳瓨淇℃伅
+                stockInfo.LockQty += (decimal)item.Qty;//閿佸畾鏁伴噺
+                await Db.Updateable(stockInfo).ExecuteCommandAsync();
+            }
+            if (string.IsNullOrEmpty(palletNo))
+            {
+                //娣诲姞鎿嶄綔鏃ュ織璁板綍
+                var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵瑰嚭搴撳崟锛歿soNo}涓嬫墍鏈夋墭鐩樺彂璧疯浆杩�", userId);
+            }
+            else
+            {
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
-                //鎻愪氦浜嬪姟
-                Db.CommitTran();
-
-                #region 鍛煎彨灏忚溅浠g爜
-
-                #endregion
             }
-            catch (Exception ex)
-            {
-                Db.RollbackTran();
-                throw new Exception(ex.Message);
-            }
-        }
-        /// <summary>
-        /// agv杞繍鍛煎彨灏忚溅鍙栬揣
-        /// </summary>
-        /// <param name="soNo"></param>
-        /// <param name="palletNo"></param>
-        /// <param name="areaNo"></param>
-        /// <param name="userId"></param>
-        public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId)
-        {
-            if (string.IsNullOrEmpty(soNo))
-            {
-                throw new Exception("璇烽�夋嫨鍑哄簱鍗曟嵁锛�");
-            }
-            if (string.IsNullOrEmpty(areaNo))
-            {
-                throw new Exception("璇烽�夋嫨鐩爣鍖哄煙锛�");
-            }
-            try
-            {
-                //寮�鍚簨鍔�
-                Db.BeginTran();
-                //鍑哄簱鍗曚俊鎭�
-                var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo);
-                if (notice == null)
-                {
-                    throw new Exception("鍑哄簱鍗曟嵁淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                }
-                //鐩爣鍖哄煙淇℃伅
-                var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo);
-                if (storageArea == null)
-                {
-                    throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
-                }
-                List<DataStockDetail> stockDetailList = new List<DataStockDetail>();//闇�瑕佺殑鎵樼洏鏄庣粏
-                if (!string.IsNullOrEmpty(palletNo))//鍗曟墭鐩樺彨璐�
-                {
-                    stockDetailList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.PalletNo == palletNo).ToList();
-                }
-                else//鏁翠釜鍑哄簱鍗曞彨璐�
-                {
-                    string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')";
-                    stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList();
-                }
-                if (stockDetailList.Count<=0)
-                {
-                    throw new Exception("鎵樼洏鏄庣粏涓嶅瓨鍦�,璇锋鏌�!");
-                }
 
-                var log = Db.Queryable<LogTask>().Where(w => w.IsDel == "0" && (w.Status == "0" || w.Status == "1"));//浠诲姟琛�
-                var storageLocat = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0");//鍌ㄤ綅琛�
-                var stock = Db.Queryable<DataStock>().Where(w => w.IsDel == "0");//搴撳瓨鎬昏〃
-                string EndLocat = string.Empty;//鐩爣浣嶇疆
-                string hasLocatNoList = string.Empty;//宸插垎閰嶇殑鍌ㄤ綅
-                foreach (var item in stockDetailList)
-                {
-                    //浠诲姟淇℃伅
-                    var logInfo = log.First(w =>w.PalletNo == item.PalletNo);
-                    if (logInfo != null)
-                    {
-                        throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}宸叉湁灏忚溅绛夊緟鎵ц鎴栨鍦ㄦ墽琛岀殑浠诲姟!");
-                    }
-                    if (string.IsNullOrEmpty(item.LocatNo))
-                    {
-                        throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}鐨勫偍浣嶄俊鎭笉瀛樺湪,璇锋鏌�!");
-                    }
-                    if (item.WareHouseNo != "W02")
-                    {
-                        throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}鏈湪骞冲簱鍐�,璇锋鏌�!");
-                    }
-                    //璧峰鍌ㄤ綅淇℃伅
-                    var storageLocatBegin = storageLocat.First(w => w.LocatNo == item.LocatNo);
-                    if (storageLocat == null)
-                    {
-                        throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}鎵�鍦ㄧ殑鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
-                    //鑾峰彇鐩爣鍌ㄤ綅
-                    EndLocat = GetLocat(areaNo, item.SkuNo, item.LotNo, palletNo);
-                    if (string.IsNullOrEmpty(EndLocat))
-                    {
-                        throw new Exception("鍒嗛厤鐩爣鍌ㄤ綅澶辫触,璇锋鏌�!");
-                    }
-                    if (string.IsNullOrEmpty(hasLocatNoList))
-                    {
-                        hasLocatNoList = EndLocat;
-                    }
-                    else
-                    {
-                        hasLocatNoList = hasLocatNoList + "," + EndLocat;
-                    }
-                    //鐩爣鍌ㄤ綅淇℃伅
-                    var storageLocatEnd = storageLocat.First(w => w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
-                    if (storageLocatEnd == null)
-                    {
-                        throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
-                    }
+            #region 鍛煎彨灏忚溅浠g爜
 
-                    //娣诲姞鍑哄簱浠诲姟
-                    var taskNo = new Common().GetMaxNo("TK");
-                    var exTask = new LogTask
-                    {
-                        TaskNo = taskNo,
-                        Sender = "WMS",
-                        Receiver = "AGV",
-                        IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
-                        Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", item.LocatNo, EndLocat),
-                        StartLocat = item.LocatNo,//璧峰浣嶇疆
-                        EndLocat = EndLocat,//鐩爣浣嶇疆
-                        PalletNo = palletNo,//鎵樼洏鐮�
-                        IsSend = 1,//鏄惁鍙啀娆′笅鍙�
-                        IsCancel = 1,//鏄惁鍙彇娑�
-                        IsFinish = 1,//鏄惁鍙畬鎴�
-                        Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
-                        Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
-                        OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
-
-                        CreateTime = DateTime.Now
-                    };
-                    Db.Insertable(exTask).ExecuteCommand();
-
-                    //淇敼搴撳瓨鏄庣粏淇℃伅
-                    item.Status = "4";//绉诲簱閿佸畾
-                    item.LockQty = item.Qty;//閿佸畾搴撳瓨鏁伴噺
-                    Db.Updateable(item).ExecuteCommand();
-
-                    //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵��
-                    storageLocatBegin.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
-                    Db.Updateable(storageLocatBegin).ExecuteCommand();
-                    //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵��
-                    storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 
-                    Db.Updateable(storageLocatEnd).ExecuteCommand();
-
-                    var stockInfo = stock.First(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo);
-                    //淇敼搴撳瓨淇℃伅
-                    stockInfo.LockQty += (decimal)item.Qty;//閿佸畾鏁伴噺
-                    Db.Updateable(stockInfo).ExecuteCommand();
-                }
-                if (string.IsNullOrEmpty(palletNo))
-                {
-                    //娣诲姞鎿嶄綔鏃ュ織璁板綍
-                    var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵瑰嚭搴撳崟锛歿soNo}涓嬫墍鏈夋墭鐩樺彂璧疯浆杩�", userId);
-                }
-                else
-                {
-                    //娣诲姞鎿嶄綔鏃ュ織璁板綍
-                    var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
-                }
-                //鎻愪氦浜嬪姟
-                Db.CommitTran();
-
-                #region 鍛煎彨灏忚溅浠g爜
-
-                #endregion
-            }
-            catch (Exception ex)
-            {
-                Db.RollbackTran();
-                throw new Exception(ex.Message);
-            }
+            #endregion
         }
         /// <summary>
         /// 鏍规嵁鍖哄煙鍒嗛厤鍌ㄤ綅
@@ -1177,45 +1050,119 @@
         /// <param name="skuNo"></param>
         /// <param name="lotNo"></param>
         /// <returns></returns>
-        private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo,string hasLocatNoList="")
+        private async Task<string> GetLocat(string areaNo, string skuNo, string lotNo, string palletNo, string hasLocatNoList = "")
         {
-            try
+            string endLocat = string.Empty;//鐩爣鍌ㄤ綅
+                                           //褰撶劧鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
+            var storageLocatList = await Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToListAsync();
+            //鍚屽尯鍩熷悓鎵规鐗╂枡鐨勫偍浣嶄俊鎭�
+            List<string> locatList = await Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo)
+                .OrderByDescending(o => o.LocatNo).Select(s => s.LocatNo).Distinct().ToListAsync();
+            foreach (var item in locatList)
             {
-                string endLocat = string.Empty;//鐩爣鍌ㄤ綅
-                //褰撶劧鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
-                var storageLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToList();
-                //鍚屽尯鍩熷悓鎵规鐗╂枡鐨勫偍浣嶄俊鎭�
-                List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo)
-                    .OrderByDescending(o=>o.LocatNo).Select(s=>s.LocatNo).Distinct().ToList();
-                foreach (var item in locatList)
-                {
-                    var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First();
+                var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First();
 
-                    var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.LocatNo != locatInfo.LocatNo && w.Row == locatInfo.Row && !hasLocatNoList.Contains(w.LocatNo))
-                        .OrderByDescending(o => o.Column).First();
-                    if (locatInfo2 != null)
-                    {
-                        endLocat = locatInfo2.LocatNo;
-                    }
-                }
-                if (string.IsNullOrEmpty(endLocat))
+                var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.LocatNo != locatInfo.LocatNo && w.Row == locatInfo.Row && !hasLocatNoList.Contains(w.LocatNo))
+                    .OrderByDescending(o => o.Column).First();
+                if (locatInfo2 != null)
                 {
-                    var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0" && !hasLocatNoList.Contains(w.LocatNo))
-                                .OrderByDescending(m => m.Layer).OrderByDescending(m=>m.Column).OrderByDescending(m=> m.Row).First();
-
-                    if (locatInfo3 != null)
-                    {
-                        endLocat = locatInfo3.LocatNo;
-                    }
+                    endLocat = locatInfo2.LocatNo;
                 }
-                return endLocat;
             }
-            catch (Exception ex)
+            if (string.IsNullOrEmpty(endLocat))
             {
-                throw new Exception(ex.Message);
+                var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0" && !hasLocatNoList.Contains(w.LocatNo))
+                            .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First();
+
+                if (locatInfo3 != null)
+                {
+                    endLocat = locatInfo3.LocatNo;
+                }
             }
+            return endLocat;
         }
         #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/BllPdaServer/PdaSoServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
index 6526b6b..3a75010 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaSoServer.cs
@@ -20,6 +20,8 @@
 using WMS.Entity.LogEntity;
 using WMS.Entity.BllQualityEntity;
 using WMS.Entity.BllAsnEntity;
+using System.Threading.Tasks;
+using Utility;
 
 namespace WMS.BLL.BllPdaServer
 {
@@ -28,348 +30,296 @@
         private static readonly SqlSugarScope Db = DataContext.Db;
 
         //楠岃瘉鎵樼洏鏄惁瀛樺湪骞舵槸鍚﹀彲鍑哄簱
-        public string IsEnableOkPalletNo(string palletNo)
+        public async Task<string> IsEnableOkPalletNo(string palletNo)
         {
-            try
-            {
-                string sqlMsg = "";
-                var models = Db.Queryable<SysPallets>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+            string sqlMsg = "";
+            var models = await Db.Queryable<SysPallets>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToListAsync();
 
-                if (models.Count > 1)
-                {
-                    sqlMsg = "-1:瀛樺湪閲嶅鎵樼洏鍙�,璇锋鏌�!";
-                    return sqlMsg;
-                }
-                if (models.Count > 0)
-                {
-                    if (models[0].Status == "0")
-                    {
-                        sqlMsg = "-1:鎵樼洏鍙风姸鎬佷负鏈娇鐢�!";
-                    }
-                }
-                else
-                {
-                    sqlMsg = "-1:鎵樼洏鍙蜂笉瀛樺湪!";
-                }
-
-                return sqlMsg;
-            }
-            catch (Exception ex)
+            if (models.Count > 1)
             {
-                throw new Exception(ex.Message);
+                throw Oops.Bah("-1:瀛樺湪閲嶅鎵樼洏鍙�,璇锋鏌�!");
             }
+            if (models.Count > 0)
+            {
+                if (models[0].Status == "0")
+                {
+                    throw Oops.Bah("-1:鎵樼洏鍙风姸鎬佷负鏈娇鐢�!");
+                }
+            }
+            else
+            {
+                throw Oops.Bah("-1:鎵樼洏鍙蜂笉瀛樺湪!");
+            }
+
+            return sqlMsg;
         }
 
         //鑾峰彇鎵樼洏涓惈鏈夌殑鎵ц涓殑鍗曟嵁
-        public List<string> GetRunSoNoticeList(string palletNo, string type)
+        public async Task<List<string>> GetRunSoNoticeList(string palletNo, string type)
         {
-            try
+            if (string.IsNullOrWhiteSpace(palletNo))//鍒ゆ柇鎵樼洏鏄惁涓虹┖
             {
-                if (string.IsNullOrWhiteSpace(palletNo))//鍒ゆ柇鎵樼洏鏄惁涓虹┖
-                {
-                    throw new Exception("鎵樼洏鐮佷负绌猴紝璇疯緭鍏ユ墭鐩樼爜");
-                }
-                var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
-                if (!string.IsNullOrEmpty(palletInfo.WareHouseNo) && type != "1")
-                {
-                    throw new Exception("璇ユ墭鐩樿繕鏈嚭搴�");
-                }
-                if (type == "1")//骞冲簱鍑哄簱鑾峰彇鍗曟嵁
-                {
-                    var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "1" && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
-                    return allotList;
-                }
-                //鑾峰彇鐘舵�佷负寰呮嫞璐ф垨鑰呴儴鍒嗘嫞璐х殑鍑哄簱鍗�
-                var allotList2 = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
-
-                //var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
-                //鑾峰彇鍑哄簱鍗曟嵁涓嶄负寰呮嫞璐� 鎵ц瀹屾瘯 璁㈠崟鍏抽棴 绛夊緟鎵ц鐨勫崟鎹�
-                //var export = Db.Queryable<BllExportNotice>().Where(a => a.IsDel == "0" && a.Status == "1" || a.Status == "2" || a.Status == "3").Select(a => a.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
-
-                return allotList2;
+                throw Oops.Bah("鎵樼洏鐮佷负绌猴紝璇疯緭鍏ユ墭鐩樼爜");
             }
-            catch (Exception ex)
+            var palletInfo = await Db.Queryable<DataStockDetail>().FirstAsync(w => w.IsDel == "0" && w.PalletNo == palletNo);
+            if (!string.IsNullOrEmpty(palletInfo.WareHouseNo) && type != "1")
             {
-                throw new Exception(ex.Message);
+                throw Oops.Bah("璇ユ墭鐩樿繕鏈嚭搴�");
             }
+            if (type == "1")//骞冲簱鍑哄簱鑾峰彇鍗曟嵁
+            {
+                var allotList = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "1" && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
+                return allotList;
+            }
+            //鑾峰彇鐘舵�佷负寰呮嫞璐ф垨鑰呴儴鍒嗘嫞璐х殑鍑哄簱鍗�
+            var allotList2 = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToListAsync();
+
+            //var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).Select(m => m.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
+            //鑾峰彇鍑哄簱鍗曟嵁涓嶄负寰呮嫞璐� 鎵ц瀹屾瘯 璁㈠崟鍏抽棴 绛夊緟鎵ц鐨勫崟鎹�
+            //var export = Db.Queryable<BllExportNotice>().Where(a => a.IsDel == "0" && a.Status == "1" || a.Status == "2" || a.Status == "3").Select(a => a.SONo).Distinct().Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
+
+            return allotList2;
         }
 
         //鑾峰彇鍑哄簱鎵樼洏涓婄殑鐗╂枡鎵规(鏍规嵁鎵樼洏鐮�)
-        public List<DetailIdSkuLotNo> GetSoSkuLotNoListByPallet(string palletNo, string soNo)
+        public async Task<List<DetailIdSkuLotNo>> GetSoSkuLotNoListByPallet(string palletNo, string soNo)
         {
-            try
+            if (string.IsNullOrWhiteSpace(palletNo))//鍒ゆ柇鎵樼洏鏄惁涓虹┖
             {
-                if (string.IsNullOrWhiteSpace(palletNo))//鍒ゆ柇鎵樼洏鏄惁涓虹┖
-                {
-                    throw new Exception("鎵樼洏鐮佷负绌猴紝璇疯緭鍏ユ墭鐩樼爜");
-                }
-                //鑾峰彇鐘舵�佷负寰呮嫞璐ф垨鑰呴儴鍒嗘嫞璐х殑鍑哄簱鍗�
-                var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.PalletNo == palletNo);
-                //var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo && m.Status != "4" && m.Status != "5");
-                if (!string.IsNullOrWhiteSpace(soNo))
-                {
-                    allotList = allotList.Where(m => m.SONo == soNo);
-                }
-
-                var list = allotList.GroupBy(m => new { m.SODetailNo, m.PalletNo, m.SkuNo, m.SkuName, m.LotNo }).Select(m => new DetailIdSkuLotNo()
-                {
-                    SoDetailId = m.SODetailNo,
-                    PalletNo = m.PalletNo,
-                    SkuNo = m.SkuNo,
-                    SkuName = m.SkuName,
-                    LotNo = m.LotNo,
-                }).ToList();
-
-                return list;
+                throw Oops.Bah("鎵樼洏鐮佷负绌猴紝璇疯緭鍏ユ墭鐩樼爜");
             }
-            catch (Exception ex)
+            //鑾峰彇鐘舵�佷负寰呮嫞璐ф垨鑰呴儴鍒嗘嫞璐х殑鍑哄簱鍗�
+            var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.PalletNo == palletNo);
+            //var allotList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo && m.Status != "4" && m.Status != "5");
+            if (!string.IsNullOrWhiteSpace(soNo))
             {
-                throw new Exception(ex.Message);
+                allotList = allotList.Where(m => m.SONo == soNo);
             }
+
+            var list = await allotList.GroupBy(m => new { m.SODetailNo, m.PalletNo, m.SkuNo, m.SkuName, m.LotNo }).Select(m => new DetailIdSkuLotNo()
+            {
+                SoDetailId = m.SODetailNo,
+                PalletNo = m.PalletNo,
+                SkuNo = m.SkuNo,
+                SkuName = m.SkuName,
+                LotNo = m.LotNo,
+            }).ToListAsync();
+
+            return list;
         }
 
         //鑾峰彇鍑哄簱鍙c�佽鏍笺�佸緟鎷e強宸叉嫞鏁伴噺锛堟牴鎹嚭搴撳崟鏄庣粏ID銆佹墭鐩樺彿锛�
-        public OutPdaInfo GetOutlets(string soDetailId, string palletNo)
+        public async Task<OutPdaInfo> GetOutlets(string soDetailId, string palletNo)
         {
-            try
+            var allotInfo = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo && (m.Status == "2" || m.Status == "3")).ToListAsync();
+            if (allotInfo.Count == 0)
             {
-
-                var allotInfo = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo && (m.Status == "2" || m.Status == "3")).ToList();
-                if (allotInfo.Count == 0)
-                {
-                    throw new Exception($"{palletNo}鎵樼洏涓婃湭鏌ヨ鍒板垎閰嶄俊鎭紝璇锋牳瀹�");
-                }
-                if (allotInfo.Count > 1)
-                {
-                    throw new Exception($"{palletNo}鎵樼洏涓婂瓨鍦ㄥ鏉$浉鍚岀殑鍒嗛厤淇℃伅锛岃鏍稿疄");
-                }
-                var data = allotInfo.First();
-                var data2 = new OutPdaInfo()
-                {
-                    OutModel = data.OutMode,
-                    Standard = data.Standard,
-                    PickQty = data.Qty,
-                    PickedQty = data.CompleteQty
-                };
-                return data2;
+                throw Oops.Bah($"{palletNo}鎵樼洏涓婃湭鏌ヨ鍒板垎閰嶄俊鎭紝璇锋牳瀹�");
             }
-            catch (Exception e)
+            if (allotInfo.Count > 1)
             {
-                throw new Exception(e.Message);
+                throw Oops.Bah($"{palletNo}鎵樼洏涓婂瓨鍦ㄥ鏉$浉鍚岀殑鍒嗛厤淇℃伅锛岃鏍稿疄");
             }
+            var data = allotInfo.First();
+            var data2 = new OutPdaInfo()
+            {
+                OutModel = data.OutMode,
+                Standard = data.Standard,
+                PickQty = data.Qty,
+                PickedQty = data.CompleteQty
+            };
+            return data2;
         }
 
         //鑾峰彇鍑哄簱鍗曠殑璁″垝鏁伴噺鍜屽畬鎴�
-        public OutPdaInfo GetPlanAndFinishQty(string soDetailId)
+        public async Task<OutPdaInfo> GetPlanAndFinishQty(string soDetailId)
         {
-            try
+            var detail = await Db.Queryable<BllExportNoticeDetail>().FirstAsync(m => m.Id == int.Parse(soDetailId) && m.IsDel == "0");
+            if (detail == null)
             {
-                var detail = Db.Queryable<BllExportNoticeDetail>().First(m => m.Id == int.Parse(soDetailId) && m.IsDel == "0");
-                if (detail == null)
-                {
-                    throw new Exception("鏈煡璇㈠埌鍑哄簱鍗曠殑鏄庣粏");
-                }
-                var data = new OutPdaInfo()
-                {
-                    PlanQty = detail.Qty,
-                    FinishQty = detail.CompleteQty
-                };
-                return data;
+                throw Oops.Bah("鏈煡璇㈠埌鍑哄簱鍗曠殑鏄庣粏");
             }
-            catch (Exception e)
+            var data = new OutPdaInfo()
             {
-                throw new Exception(e.Message);
-            }
+                PlanQty = detail.Qty,
+                FinishQty = detail.CompleteQty
+            };
+            return data;
         }
 
         //鑾峰彇绠辩爜淇℃伅锛堟牴鎹鐮佸湪搴撳瓨绠辩爜鏄庣粏涓煡璇㈠強鎷h揣鏄庣粏涓嫞璐ф暟閲忥級
-        public List<Model.ModelDto.BoxInfo> GetDataComBoxInfo(string soDetailId, string palletNo, string boxNo, string boxNo3)
+        public async Task<List<BoxInfo>> GetDataComBoxInfo(string soDetailId, string palletNo, string boxNo, string boxNo3)
         {
-            try
+            if (string.IsNullOrWhiteSpace(palletNo))
             {
-                if (string.IsNullOrWhiteSpace(palletNo))
+                throw Oops.Bah("鎵樼洏鍙蜂笉鑳戒负绌�");
+            }
+            Expression<Func<DataBoxInfo, bool>> item = Expressionable.Create<DataBoxInfo>()
+                .And(it => it.PalletNo == palletNo)
+                .AndIF(!string.IsNullOrWhiteSpace(boxNo), it => it.BoxNo == boxNo)
+                .AndIF(!string.IsNullOrWhiteSpace(boxNo3), it => it.BoxNo3 == boxNo3)
+                .And(m => m.IsDel == "0")
+                .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
+            var info = Db.Queryable<DataBoxInfo>().Where(item);
+            if (info.Count() == 0)
+            {
+                throw Oops.Bah("鏈湪搴撳瓨涓煡璇㈠埌淇℃伅");
+            }
+
+            var type = "0";//0锛氭煡绠辩爜鎴栨敮鐮佷笉鍒嗙粍 1锛氭煡鎵樼洏鍒嗙粍 鏄剧ず绠�
+            var list = new List<BoxInfo>();
+            if (!string.IsNullOrWhiteSpace(boxNo3) || !string.IsNullOrWhiteSpace(boxNo))//鍒ゆ柇鏀爜鏄惁涓虹┖
+            {
+                foreach (var demo in await info.ToListAsync())
                 {
-                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
-                }
-                Expression<Func<DataBoxInfo, bool>> item = Expressionable.Create<DataBoxInfo>()
-                    .And(it => it.PalletNo == palletNo)
-                    .AndIF(!string.IsNullOrWhiteSpace(boxNo), it => it.BoxNo == boxNo)
-                    .AndIF(!string.IsNullOrWhiteSpace(boxNo3), it => it.BoxNo3 == boxNo3)
-                    .And(m => m.IsDel == "0")
-                    .ToExpression();//娉ㄦ剰 杩欎竴鍙� 涓嶈兘灏�
-                var info = Db.Queryable<DataBoxInfo>().Where(item);
-                if (info.Count() == 0)
-                {
-                    throw new Exception("鏈湪搴撳瓨涓煡璇㈠埌淇℃伅");
+                    var t = new BoxInfo()
+                    {
+                        BoxNo = demo.BoxNo3,
+                        Qty = demo.Qty,
+                        //SkuNo = demo.SkuNo,
+                        //SkuName = demo.SkuName,
+                        //LotNo = demo.LotNo, 
+                    };
+                    list.Add(t);
                 }
 
-                var type = "0";//0锛氭煡绠辩爜鎴栨敮鐮佷笉鍒嗙粍 1锛氭煡鎵樼洏鍒嗙粍 鏄剧ず绠�
-                var list = new List<BoxInfo>();
-                if (!string.IsNullOrWhiteSpace(boxNo3) || !string.IsNullOrWhiteSpace(boxNo))//鍒ゆ柇鏀爜鏄惁涓虹┖
+            }
+            else if (!string.IsNullOrWhiteSpace(palletNo))
+            {
+                list = await info.GroupBy(m => new { m.BoxNo }).Select(it => new BoxInfo
                 {
-                    foreach (var demo in info.ToList())
+                    BoxNo = it.BoxNo,
+                    Qty = SqlFunc.AggregateSum(it.Qty)
+                }).ToListAsync();
+                type = "1";
+            }
+            if (!string.IsNullOrWhiteSpace(soDetailId))
+            {
+                var allotInfos = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo && (m.Status == "2" || m.Status == "3")).ToListAsync();
+                if (allotInfos.Count == 0)
+                {
+                    throw Oops.Bah($"{palletNo}鎵樼洏涓婃湭鏌ヨ鍒板垎閰嶄俊鎭紝璇锋牳瀹�");
+                }
+                if (allotInfos.Count > 1)
+                {
+                    throw Oops.Bah($"{palletNo}鎵樼洏涓婂瓨鍦ㄥ鏉$浉鍚岀殑鍒嗛厤淇℃伅锛岃鏍稿疄");
+                }
+                var allotInfo = allotInfos.First();
+                var comInfo = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allotInfo.Id).ToListAsync();
+                if (comInfo.Count != 0)
+                {
+                    if (type == "0")
                     {
-                        var t = new BoxInfo()
+                        foreach (var demo in list)
                         {
-                            BoxNo = demo.BoxNo3,
-                            Qty = demo.Qty,
-                            //SkuNo = demo.SkuNo,
-                            //SkuName = demo.SkuName,
-                            //LotNo = demo.LotNo, 
-                        };
-                        list.Add(t);
-                    }
+                            //if (!string.IsNullOrWhiteSpace(boxNo3))
+                            //{
+                            //    var com = comInfo.FirstOrDefault(m => m.IsDel == "0" && m.BoxNo3 == demo.BoxNo);
+                            //}
+                            //else if (!string.IsNullOrWhiteSpace(boxNo))
+                            //{
+                            //    if (expr)
+                            //    {
 
-                }
-                else if (!string.IsNullOrWhiteSpace(palletNo))
-                {
-                    list = info.GroupBy(m => new { m.BoxNo }).Select(it => new BoxInfo
-                    {
-                        BoxNo = it.BoxNo,
-                        Qty = SqlFunc.AggregateSum(it.Qty)
-                    }).ToList();
-                    type = "1";
-                }
-                if (!string.IsNullOrWhiteSpace(soDetailId))
-                {
-                    var allotInfos = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo && (m.Status == "2" || m.Status == "3")).ToList();
-                    if (allotInfos.Count == 0)
-                    {
-                        throw new Exception($"{palletNo}鎵樼洏涓婃湭鏌ヨ鍒板垎閰嶄俊鎭紝璇锋牳瀹�");
-                    }
-                    if (allotInfos.Count > 1)
-                    {
-                        throw new Exception($"{palletNo}鎵樼洏涓婂瓨鍦ㄥ鏉$浉鍚岀殑鍒嗛厤淇℃伅锛岃鏍稿疄");
-                    }
-                    var allotInfo = allotInfos.First();
-                    var comInfo = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allotInfo.Id).ToList();
-                    if (comInfo.Count != 0)
-                    {
-                        if (type == "0")
-                        {
-                            foreach (var demo in list)
+                            //    }
+
+                            //}
+                            var com = comInfo.FirstOrDefault(m => m.IsDel == "0" && m.BoxNo3 != null && m.BoxNo3 == demo.BoxNo);
+                            if (com != null)
                             {
-                                //if (!string.IsNullOrWhiteSpace(boxNo3))
-                                //{
-                                //    var com = comInfo.FirstOrDefault(m => m.IsDel == "0" && m.BoxNo3 == demo.BoxNo);
-                                //}
-                                //else if (!string.IsNullOrWhiteSpace(boxNo))
-                                //{
-                                //    if (expr)
-                                //    {
-
-                                //    }
-
-                                //}
-                                var com = comInfo.FirstOrDefault(m => m.IsDel == "0" && m.BoxNo3 != null && m.BoxNo3 == demo.BoxNo);
-                                if (com != null)
-                                {
-                                    demo.PickedQty = com.CompleteQty;
-                                }
-                            }
-                        }
-                        if (type == "1")
-                        {
-                            var com = comInfo.Where(m => m.IsDel == "0").GroupBy(m => m.BoxNo).Select(it => new BoxInfo
-                            {
-                                BoxNo = it.Key,
-                                PickedQty = it.Sum(a => a.CompleteQty)
-                            }).ToList();
-                            foreach (var demo in list)
-                            {
-
-                                var com2 = com.FirstOrDefault(m => m.BoxNo == demo.BoxNo);
-                                if (com2 != null)
-                                {
-                                    demo.PickedQty = com2.PickedQty;
-                                }
+                                demo.PickedQty = com.CompleteQty;
                             }
                         }
                     }
+                    if (type == "1")
+                    {
+                        var com = comInfo.Where(m => m.IsDel == "0").GroupBy(m => m.BoxNo).Select(it => new BoxInfo
+                        {
+                            BoxNo = it.Key,
+                            PickedQty = it.Sum(a => a.CompleteQty)
+                        }).ToList();
+                        foreach (var demo in list)
+                        {
 
+                            var com2 = com.FirstOrDefault(m => m.BoxNo == demo.BoxNo);
+                            if (com2 != null)
+                            {
+                                demo.PickedQty = com2.PickedQty;
+                            }
+                        }
+                    }
                 }
 
-                return list;
             }
-            catch (Exception e)
-            {
-                throw new Exception(e.Message);
-            }
+
+            return list;
         }
 
         //鑾峰彇搴撳唴鏃犵鐮佺殑鎵樼洏鍒嗛厤淇℃伅
-        public List<Model.ModelDto.BoxInfo> GetAllotPlnInfo(string soDetailId, string palletNo)
+        public async Task<List<BoxInfo>> GetAllotPlnInfo(string soDetailId, string palletNo)
         {
-            try
+            #region 鍒ゆ柇
+
+            //鏍规嵁id鍙婃墭鐩樿幏鍙栧嚭搴撳崟鍜屾墭鐩樻嫞璐т俊鎭�
+            if (string.IsNullOrWhiteSpace(palletNo))
             {
-                #region 鍒ゆ柇
-
-                //鏍规嵁id鍙婃墭鐩樿幏鍙栧嚭搴撳崟鍜屾墭鐩樻嫞璐т俊鎭�
-                if (string.IsNullOrWhiteSpace(palletNo))
-                {
-                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
-                }
-                //鑾峰彇瀵瑰簲鎵樼洏涓嬫槸鍚﹀瓨鍦ㄧ鐮佷俊鎭�
-                var boxInfo = Db.Queryable<DataBoxInfo>().First(b => b.IsDel == "0" && b.PalletNo == palletNo);
-                if (boxInfo != null)
-                {
-                    throw new Exception($"{palletNo}鎵樼洏涓婂瓨鍦ㄧ鐮佷俊鎭紝鏃犳硶鍦ㄦ暟閲忔嫞璐ц繘琛屾搷浣滐紒");
-                }
-
-                BllExportAllot allot = null;
-                if (!string.IsNullOrWhiteSpace(soDetailId))
-                {
-                    //鍑哄簱鍗曟槑缁�
-                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>().First(a => a.Id == int.Parse(soDetailId) && a.IsDel == "0");
-                    if (noticeDetail == null)
-                    {
-                        throw new Exception($"鏈煡璇㈠埌瀵瑰簲鍑哄簱鍗曟槑缁嗕俊鎭紝璇锋牳瀹烇紒");
-                    }
-                    //鍑哄簱鍗曟�诲崟
-                    var notice = Db.Queryable<BllExportNotice>().First(a => a.IsDel == "0" && a.SONo == noticeDetail.SONo);
-                    if (notice == null)
-                    {
-                        throw new Exception($"鏈煡璇㈠埌瀵瑰簲鍑哄簱鍗曟�诲崟淇℃伅锛岃鏍稿疄锛�");
-                    }
-                    //鍒嗛厤淇℃伅
-                    allot = Db.Queryable<BllExportAllot>().First(a => a.IsDel == "0" && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.PalletNo == palletNo && (a.Status == "2" || a.Status == "3"));
-                    if (allot == null)
-                    {
-                        throw new Exception($"鏈煡璇㈠埌瀵瑰簲鍒嗛厤淇℃伅锛岃鏍稿疄锛�");
-                    }
-                }
-
-                //搴撳瓨鏄庣粏
-                var detail = Db.Queryable<DataStockDetail>().First(a => a.IsDel == "0" && a.PalletNo == palletNo);
-                if (detail == null)
-                {
-                    throw new Exception($"鏈煡璇㈠埌搴撳瓨鏄庣粏淇℃伅锛岃鏍稿疄锛�");
-                }
-
-                #endregion
-
-                List<BoxInfo> pdaInfo = new List<BoxInfo>();
-
-                BoxInfo info = new BoxInfo()
-                {
-                    SkuNo = detail.SkuNo,
-                    BoxNo = detail.SkuNo,
-                    Qty = allot == null ? (int)(detail.Qty - detail.LockQty) : (int)allot.Qty,
-                    PickedQty = allot == null ? 0 : (int)allot.CompleteQty,
-                };
-
-                pdaInfo.Add(info);
-                return pdaInfo;
-
+                throw Oops.Bah("鎵樼洏鍙蜂笉鑳戒负绌�");
             }
-            catch (Exception e)
+            //鑾峰彇瀵瑰簲鎵樼洏涓嬫槸鍚﹀瓨鍦ㄧ鐮佷俊鎭�
+            var boxInfo = await Db.Queryable<DataBoxInfo>().FirstAsync(b => b.IsDel == "0" && b.PalletNo == palletNo);
+            if (boxInfo != null)
             {
-                throw new Exception(e.Message);
+                throw Oops.Bah($"{palletNo}鎵樼洏涓婂瓨鍦ㄧ鐮佷俊鎭紝鏃犳硶鍦ㄦ暟閲忔嫞璐ц繘琛屾搷浣滐紒");
             }
+
+            BllExportAllot allot = null;
+            if (!string.IsNullOrWhiteSpace(soDetailId))
+            {
+                //鍑哄簱鍗曟槑缁�
+                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>().FirstAsync(a => a.Id == int.Parse(soDetailId) && a.IsDel == "0");
+                if (noticeDetail == null)
+                {
+                    throw Oops.Bah($"鏈煡璇㈠埌瀵瑰簲鍑哄簱鍗曟槑缁嗕俊鎭紝璇锋牳瀹烇紒");
+                }
+                //鍑哄簱鍗曟�诲崟
+                var notice = await Db.Queryable<BllExportNotice>().FirstAsync(a => a.IsDel == "0" && a.SONo == noticeDetail.SONo);
+                if (notice == null)
+                {
+                    throw Oops.Bah($"鏈煡璇㈠埌瀵瑰簲鍑哄簱鍗曟�诲崟淇℃伅锛岃鏍稿疄锛�");
+                }
+                //鍒嗛厤淇℃伅
+                allot = await Db.Queryable<BllExportAllot>().FirstAsync(a => a.IsDel == "0" && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.PalletNo == palletNo && (a.Status == "2" || a.Status == "3"));
+                if (allot == null)
+                {
+                    throw Oops.Bah($"鏈煡璇㈠埌瀵瑰簲鍒嗛厤淇℃伅锛岃鏍稿疄锛�");
+                }
+            }
+
+            //搴撳瓨鏄庣粏
+            var detail = await Db.Queryable<DataStockDetail>().FirstAsync(a => a.IsDel == "0" && a.PalletNo == palletNo);
+            if (detail == null)
+            {
+                throw Oops.Bah($"鏈煡璇㈠埌搴撳瓨鏄庣粏淇℃伅锛岃鏍稿疄锛�");
+            }
+
+            #endregion
+
+            List<BoxInfo> pdaInfo = new List<BoxInfo>();
+
+            BoxInfo info = new BoxInfo()
+            {
+                SkuNo = detail.SkuNo,
+                BoxNo = detail.SkuNo,
+                Qty = allot == null ? (int)(detail.Qty - detail.LockQty) : (int)allot.Qty,
+                PickedQty = allot == null ? 0 : (int)allot.CompleteQty,
+            };
+
+            pdaInfo.Add(info);
+            return pdaInfo;
         }
 
         //鍑哄簱pda鎷h揣
-        public void SoSetPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, int userId)
+        public async Task SoSetPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, int userId)
         {
             Db.BeginTran();
             try
@@ -378,60 +328,60 @@
 
                 if (string.IsNullOrWhiteSpace(soNo))
                 {
-                    throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(soDetailId))
                 {
-                    throw new Exception("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                 }
                 if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
                 {
-                    throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                    throw Oops.Bah("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
                 }
 
                 //鍑哄簱鍗�
-                var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.SONo == soNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                 }
                 if (notice.Status != "3")
                 {
-                    throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                 }
                 //鍑哄簱鍗曟槑缁�
-                var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
-                    .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>()
+                    .FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                 if (noticeDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                 }
                 //鍑哄簱鍒嗛厤淇℃伅
-                var allot = Db.Queryable<BllExportAllot>().First(m =>
+                var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                     m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                     m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                 if (allot == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                 }
                 //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                 var needQty = allot.Qty - allot.CompleteQty;
 
                 //搴撳瓨鏄庣粏
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                 }
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                 }
                 #endregion
 
@@ -439,28 +389,28 @@
                 {
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo);//鎵惧埌鎵樼洏涓婃墍鏈夌鐮�
-                    boxInfos = boxInfo.ToList();
+                    boxInfos = await boxInfo.ToListAsync();
                     if (boxInfo.Count() <= 0)
                     {
-                        throw new Exception("璇ユ墭鐩樹笂娌℃湁鍙嫞璐х殑绠卞瓙");
+                        throw Oops.Bah("璇ユ墭鐩樹笂娌℃湁鍙嫞璐х殑绠卞瓙");
                     }
-                    var boxQty = boxInfo.GroupBy(m => m.PalletNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
+                    var boxQty = await boxInfo.GroupBy(m => m.PalletNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToListAsync();
                     if (boxQty[0] > needQty)
                     {
-                        throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                        throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
                     }
                     decimal pickQty = 0;//鎷h揣鐨勬暟閲�
-                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    var comDetailList = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToListAsync();
                     var comList = new List<BllCompleteDetail>();
                     foreach (var item in boxInfos)
                     {
                         if (comDetailList.Any(m => m.BoxNo3 == item.BoxNo3) && item.BoxNo3 != null)
                         {
-                            throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                            throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                         }
                         if (item.SkuNo != allot.SkuNo || item.LotNo != allot.LotNo)
                         {
-                            throw new Exception("褰撳墠鎵樼洏涓婃湁鍏朵粬涓嶅悓鐗╂枡鎵规锛屾嫞璐уけ璐�");
+                            throw Oops.Bah("褰撳墠鎵樼洏涓婃湁鍏朵粬涓嶅悓鐗╂枡鎵规锛屾嫞璐уけ璐�");
                         }
                         //娣诲姞鎷h揣鏄庣粏
                         var completeDetail = new BllCompleteDetail()
@@ -487,76 +437,76 @@
                         comList.Add(completeDetail);
 
                         //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                        Db.Deleteable(item).ExecuteCommand();
+                        await Db.Deleteable(item).ExecuteCommandAsync();
                         pickQty += item.Qty;
                     }
                     //娣诲姞鎷h揣鏄庣粏
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot.CompleteQty += pickQty;
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
                     allot.UpdateTime = DateTime.Now;
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
                     //鍒犻櫎搴撳瓨鏄庣粏
-                    Db.Deleteable(stockDetail).ExecuteCommand();
+                    await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛�
                     stock.Qty -= pickQty;
                     stock.LockQty -= pickQty;
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
                     //鏀瑰彉鎵樼洏鐘舵�佷负锛氭湭浣跨敤
                     var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
                     if (pallet == null)
                     {
-                        throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                     }
                     pallet.Status = "0";
-                    Db.Updateable(pallet).ExecuteCommand();
+                    await Db.Updateable(pallet).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                    var num = Db.Queryable<BllExportNoticeDetail>()
-                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    var num = await Db.Queryable<BllExportNoticeDetail>()
+                        .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                         //淇敼鍑哄簱鍗曚俊鎭�
-                        Db.Updateable(notice).ExecuteCommand();
+                        await Db.Updateable(notice).ExecuteCommandAsync();
                         if (notice.IsWave == "1")
                         {
-                            var waveNum = Db.Queryable<BllExportNotice>().Count(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status != "4");
+                            var waveNum = await Db.Queryable<BllExportNotice>().CountAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status != "4");
                             if (waveNum == 0)
                             {
-                                var wave = Db.Queryable<BllWaveMage>().First(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
+                                var wave = await Db.Queryable<BllWaveMage>().FirstAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
                                 if (wave != null)
                                 {
                                     wave.Status = "4";
                                     wave.UpdateUser = userId;
                                     wave.UpdateTime = DateTime.Now;
-                                    Db.Updateable(wave).ExecuteCommand();
+                                    await Db.Updateable(wave).ExecuteCommandAsync();
                                 }
                             }
                         }
                     }
-                    
+
                 }
                 else
                 {
                     var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
-                    if (boxInfo.Count() == 0)
+                    if (await boxInfo.CountAsync() == 0)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                     }
-                    boxInfos = boxInfo.ToList();
+                    boxInfos = await boxInfo.ToListAsync();
 
                     var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
                     if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
@@ -565,28 +515,28 @@
 
                         if (boxInfos.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                         }
                         if (boxInfos.Count() > 1)
                         {
-                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                            throw Oops.Bah("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
                         }
 
                         if (boxInfos.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         var boxQty = boxInfos.First().Qty;
                         if (boxQty > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
 
@@ -596,16 +546,16 @@
                     {
                         if (boxInfo.Count() > 1)
                         {
-                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                            throw Oops.Bah("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
                         }
                         decimal boxQty = boxInfo.First().Qty;
                         if (Convert.ToInt32(pickQty1) > boxQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         if (Convert.ToInt32(pickQty1) > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         biaoShi = "2";
@@ -614,23 +564,23 @@
                     {
                         if (boxInfo.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
                         }
                         if (boxInfo.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
-                        var boxQty = boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
+                        var boxQty = await boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToListAsync();
                         if (boxQty[0] > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo == item.BoxNo))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                     }
@@ -666,20 +616,20 @@
                         if (biaoShi != "2")
                         {
                             //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                            Db.Deleteable(item).ExecuteCommand();
+                            await Db.Deleteable(item).ExecuteCommandAsync();
                         }
                         else//鏁伴噺鎷h揣
                         {
                             if (decimal.Parse(pickQty1) == item.Qty)
                             {
                                 //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                                Db.Deleteable(item).ExecuteCommand();
+                                await Db.Deleteable(item).ExecuteCommandAsync();
                             }
                             else
                             {
                                 item.Qty -= decimal.Parse(pickQty1);
                                 item.BitBoxMark = "1";//闆剁鏍囪瘑
-                                Db.Updateable(item).ExecuteCommand();
+                                await Db.Updateable(item).ExecuteCommandAsync();
                             }
                         }
                         pickQty += item.Qty;
@@ -691,11 +641,11 @@
                         foreach (var item in boxSurplusList)
                         {
                             item.BitBoxMark = "1";
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
                         }
                     }
 
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot.CompleteQty += pickQty;
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
@@ -704,7 +654,7 @@
                     {
                         //鍒ゆ柇璇ユ墭鐩樻槸鍚﹁繕瀛樺湪鐗╂枡 瀛樺湪鏀逛负寰呭洖搴� 寰呭洖搴撳畬鎴愬悗鏀逛负宸插畬鎴�
                     }
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
 
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
                     stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
@@ -725,58 +675,58 @@
 
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                     stock.Qty -= pickQty;
                     stock.LockQty -= pickQty;
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
-                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    var num2 = await Db.Queryable<DataStockDetail>().CountAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
                     if (num2 <= 0)
                     {
                         //鏀瑰彉鎵樼洏鐘舵��
-                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                         if (pallet == null)
                         {
-                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                            throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                         }
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                    var num = Db.Queryable<BllExportNoticeDetail>()
-                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    var num = await Db.Queryable<BllExportNoticeDetail>()
+                        .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                         //淇敼鍑哄簱鍗曚俊鎭�
-                        Db.Updateable(notice).ExecuteCommand();
+                        await Db.Updateable(notice).ExecuteCommandAsync();
                         if (notice.IsWave == "1")
                         {
-                            var waveNum = Db.Queryable<BllExportNotice>()
-                                .Count(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status !="4");
+                            var waveNum = await Db.Queryable<BllExportNotice>()
+                                .CountAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status != "4");
                             if (waveNum == 0)
                             {
-                                var wave = Db.Queryable<BllWaveMage>().First(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
-                                if (wave!= null)
+                                var wave = await Db.Queryable<BllWaveMage>().FirstAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
+                                if (wave != null)
                                 {
                                     wave.Status = "4";
                                     wave.UpdateUser = userId;
                                     wave.UpdateTime = DateTime.Now;
-                                    Db.Updateable(wave).ExecuteCommand();
+                                    await Db.Updateable(wave).ExecuteCommandAsync();
                                 }
                             }
                         }
@@ -786,6 +736,10 @@
                 var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鍑哄簱", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勬墭鐩樼爜涓猴細{palletNo}鐨勬嫞璐ф搷浣�", userId);
                 Db.CommitTran();
             }
+            catch (AppFriendlyException e)
+            {
+                Db.RollbackTran();
+            }
             catch (Exception e)
             {
                 Db.RollbackTran();
@@ -794,7 +748,7 @@
         }
 
         //鍑哄簱pda鎷h揣
-        public void SoSetQtyPick(string soNo, string soDetailId, string palletNo, string PickQty, int userId)
+        public async Task SoSetQtyPick(string soNo, string soDetailId, string palletNo, string PickQty, int userId)
         {
             Db.BeginTran();
             try
@@ -803,7 +757,7 @@
 
                 if (string.IsNullOrWhiteSpace(soNo))
                 {
-                    throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                 }
                 //if (string.IsNullOrWhiteSpace(soDetailId))
                 //{
@@ -811,56 +765,56 @@
                 //}
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                 }
 
                 //鍑哄簱鍗�
-                var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.SONo == soNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                 }
                 if (notice.Status != "3")
                 {
-                    throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                 }
                 //鍑哄簱鍗曟槑缁�
-                var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
-                    .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>()
+                    .FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                 if (noticeDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                 }
                 //鍑哄簱鍒嗛厤淇℃伅
-                var allot = Db.Queryable<BllExportAllot>().First(m =>
+                var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                     m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                     m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                 if (allot == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                 }
                 //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                 var needQty = allot.Qty - allot.CompleteQty;
                 if (int.Parse(PickQty) > needQty)
                 {
-                    throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
+                    throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
                 }
 
                 //搴撳瓨鏄庣粏
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                 }
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                 }
                 #endregion
                 //鑾峰彇褰撳墠鎵樼洏鎷h揣鏄庣粏
-                var complete = Db.Queryable<BllCompleteDetail>().First(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
+                var complete = await Db.Queryable<BllCompleteDetail>().FirstAsync(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
 
                 //鍒よ鏄惁瀛樺湪鎷h揣鏄庣粏
                 int isComplete = 0;
@@ -900,7 +854,7 @@
                     comList.Add(completeDetail);
 
                     //娣诲姞鎷h揣鏄庣粏
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                 }
                 else if (isComplete == 1)
                 {
@@ -908,14 +862,14 @@
                     complete.UpdateUser = userId;
                     complete.UpdateTime = Db.GetDate();
 
-                    Db.Updateable(complete).ExecuteCommand();
+                    await Db.Updateable(complete).ExecuteCommandAsync();
                 }
 
                 //淇敼鍑哄簱鍒嗛厤淇℃伅
                 allot.CompleteQty += int.Parse(PickQty);
                 allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
                 allot.UpdateTime = DateTime.Now;
-                Db.Updateable(allot).ExecuteCommand();
+                await Db.Updateable(allot).ExecuteCommandAsync();
 
                 int isDel = 0;
 
@@ -937,67 +891,67 @@
                 }
                 if (stockDetail.Qty <= 0)
                 {
-                    Db.Deleteable(stockDetail).ExecuteCommand();
+                    await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                 }
                 else
                 {
                     isDel = 1;
-                    Db.Updateable(stockDetail).ExecuteCommand();
+                    await Db.Updateable(stockDetail).ExecuteCommandAsync();
                 }
                 //鍒犻櫎鎴栦慨鏀瑰簱瀛�
                 stock.Qty -= int.Parse(PickQty);
                 stock.LockQty -= int.Parse(PickQty);
                 if (stock.Qty <= 0)
                 {
-                    Db.Deleteable(stock).ExecuteCommand();
+                    await Db.Deleteable(stock).ExecuteCommandAsync();
                 }
                 else
                 {
-                    Db.Updateable(stock).ExecuteCommand();
+                    await Db.Updateable(stock).ExecuteCommandAsync();
                 }
 
                 //鏀瑰彉鎵樼洏鐘舵�佷负锛氭湭浣跨敤
-                var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                 if (pallet == null)
                 {
-                    throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                    throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                 }
 
                 //鍒ゆ柇鎵樼洏涓婄墿鏂欐槸鍚︽嫞璐у畬姣�
                 if (isDel == 0)
                 {
                     pallet.Status = "0";
-                    Db.Updateable(pallet).ExecuteCommand();
+                    await Db.Updateable(pallet).ExecuteCommandAsync();
                 }
 
                 //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                 noticeDetail.CompleteQty += int.Parse(PickQty);
-                Db.Updateable(noticeDetail).ExecuteCommand();
+                await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                var num = Db.Queryable<BllExportNoticeDetail>()
-                    .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                var num = await Db.Queryable<BllExportNoticeDetail>()
+                    .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                 if (num <= 0)
                 {
                     notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                     //淇敼鍑哄簱鍗曚俊鎭�
-                    Db.Updateable(notice).ExecuteCommand();
+                    await Db.Updateable(notice).ExecuteCommandAsync();
                     if (notice.IsWave == "1")
                     {
-                        var waveNum = Db.Queryable<BllExportNotice>().Count(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status != "4");
+                        var waveNum = await Db.Queryable<BllExportNotice>().CountAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo && m.Status != "4");
                         if (waveNum <= 0)
                         {
-                            var wave = Db.Queryable<BllWaveMage>().First(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
+                            var wave = await Db.Queryable<BllWaveMage>().FirstAsync(m => m.IsDel == "0" && m.WaveNo == notice.WaveNo);
                             if (wave != null)
                             {
                                 wave.Status = "4";
                                 wave.UpdateUser = userId;
                                 wave.UpdateTime = DateTime.Now;
-                                Db.Updateable(wave).ExecuteCommand();
+                                await Db.Updateable(wave).ExecuteCommandAsync();
                             }
                         }
                     }
                 }
-                
+
 
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鍑哄簱", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勬墭鐩樼爜涓猴細{palletNo}鐨勬嫞璐ф搷浣�", userId);
@@ -1006,7 +960,6 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
 
@@ -1018,33 +971,31 @@
         /// <param name="url"> </param>
         /// <returns></returns>
         /// <exception cref="Exception"></exception>
-        public string IssuePlnOutHouse(OutModePalletVm model, int userId, string url)
+        public async Task<string> IssuePlnOutHouse(OutModePalletVm model, int userId, string url)
         {
             try
             {
-                string strMsg = "";
                 var outDtoList = new List<OutCommandDto>(); //鍑哄簱鏁版嵁鐨勯泦鍚� 
                 //鑾峰彇褰撳墠鏃堕棿
                 DateTime serverTime = Db.GetDate();
                 //鑾峰彇搴撳瓨鏄庣粏鏄惁灏忎簬绛変簬璇ュ灈鏁�
-                string str = "select * from DataStockDetail where IsDel = '0' and SkuNo = '100099' and Status = '0' ";
-                var stockDetail = Db.Ado.SqlQuery<DataStockDetail>(str);
+                //string str = "select * from DataStockDetail where IsDel = '0' and SkuNo = '100099' and Status = '0' ";
+                //var stockDetail = Db.Ado.SqlQuery<DataStockDetail>(str);
+                var stockDetail = await Db.Queryable<DataStockDetail>().Where(s => s.IsDel == "0" && s.SkuNo == "100099" && s.Status == "0").ToListAsync();
                 if (stockDetail.Count > 0)
                 {
                     //鍒ゆ柇鏄惁澶т簬闇�瑕佸灈鏁�
                     if (stockDetail.Count < int.Parse(model.Num))
                     {
-                        strMsg = "闇�瑕佸灈鏁板ぇ浜庡簱瀛樺灈鏁帮紝璇烽噸鏂拌緭鍏�!";
-                        return strMsg;
+                        throw Oops.Bah("闇�瑕佸灈鏁板ぇ浜庡簱瀛樺灈鏁帮紝璇烽噸鏂拌緭鍏�!");
                     }
                 }
                 //鑾峰彇搴撳瓨鎬昏〃淇℃伅
-                var stock = Db.Queryable<DataStock>().First(s => s.IsDel == "0" && s.SkuNo == "100099");
+                var stock = await Db.Queryable<DataStock>().FirstAsync(s => s.IsDel == "0" && s.SkuNo == "100099");
                 //楠岃瘉搴撳瓨鎬昏〃鏄惁涓虹┖
                 if (stock == null)
                 {
-                    strMsg = "搴撳瓨淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!";
-                    return strMsg;
+                    throw Oops.Bah("搴撳瓨淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
                 }
 
                 int i = 0;
@@ -1055,7 +1006,7 @@
                 foreach (var s in stockDetail)
                 {
                     //鑾峰彇鍌ㄤ綅淇℃伅
-                    var locat = Db.Queryable<SysStorageLocat>().First(l => l.LocatNo == s.LocatNo && l.IsDel == "0" && l.WareHouseNo == "W01");
+                    var locat = await Db.Queryable<SysStorageLocat>().FirstAsync(l => l.LocatNo == s.LocatNo && l.IsDel == "0" && l.WareHouseNo == "W01");
 
                     if (locat != null)
                     {
@@ -1068,7 +1019,7 @@
                         locat.UpdateTime = serverTime; //淇敼鏃堕棿
                         locat.UpdateUser = userId; //淇敼浜�
                         //淇敼鍌ㄤ綅淇℃伅
-                        Db.Updateable(locat).ExecuteCommand();
+                        await Db.Updateable(locat).ExecuteCommandAsync();
                     }
 
                     //澧炲姞搴撳瓨閿佸畾鏁伴噺
@@ -1077,7 +1028,7 @@
                     stock.UpdateTime = serverTime; //淇敼鏃堕棿
                     stock.UpdateUser = userId; //淇敼浜�
                     //淇敼搴撳瓨鎬昏〃淇℃伅
-                    Db.Updateable(stock).ExecuteCommand();
+                    await Db.Updateable(stock).ExecuteCommandAsync();
 
                     //澧炲姞搴撳瓨鏄庣粏閿佸畾鏁伴噺
                     //s.AllotQty += 
@@ -1086,7 +1037,7 @@
                     s.UpdateUser = userId; //淇敼浜�
                     s.Status = "2"; //2 宸插垎閰�
                     //淇敼搴撳瓨鏄庣粏淇℃伅
-                    Db.Updateable(s).ExecuteCommand();
+                    await Db.Updateable(s).ExecuteCommandAsync();
 
                     #region 鍒嗛厤
 
@@ -1118,7 +1069,7 @@
                         CreateUser = userId,
                         CreateTime = DateTime.Now
                     };
-                    Db.Insertable(allot).ExecuteCommand();
+                    await Db.Insertable(allot).ExecuteCommandAsync();
 
                     #endregion
 
@@ -1157,7 +1108,7 @@
                         OutMode = model.OutMode,  //鐩爣鍦板潃
                         Order = 1
                     });
-                    Db.Insertable(exTask).ExecuteCommand();
+                    await Db.Insertable(exTask).ExecuteCommandAsync();
 
                     #endregion
                     i += 1;
@@ -1187,13 +1138,17 @@
                         {
                             //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�//
                             new TaskServer().EditTaskIssueOk(list2, time1, time2);
-                            str += "涓嬪彂鎴愬姛";
+                            //str += "涓嬪彂鎴愬姛";
                         }
                         if (wcsModel.StatusCode == -1)
                         {
                             new TaskServer().EditTaskIssueNo(list2, time1, time2, wcsModel.Msg);
-                            throw new Exception(wcsModel.Msg);
+                            throw Oops.Bah(wcsModel.Msg);
                         }
+                    }
+                    catch (AppFriendlyException e)
+                    {
+                        throw Oops.Bah(e.Message);
                     }
                     catch (Exception ex)
                     {
@@ -1212,35 +1167,28 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
+                return "";
             }
 
         }
 
         //鑾峰彇骞冲簱鎵樼洏淇℃伅
-        public List<Model.ModelDto.BoxInfo> GetPingKuInfoByPallet(string soNo, string palletNo)
+        public async Task<List<BoxInfo>> GetPingKuInfoByPallet(string soNo, string palletNo)
         {
-            try
+            var info = Db.Queryable<BllExportAllot>().Where(m => m.SONo == soNo && m.PalletNo == palletNo && m.IsDel == "0");
+            if (await info.CountAsync() == 0)
             {
-                var info = Db.Queryable<BllExportAllot>().Where(m => m.SONo == soNo && m.PalletNo == palletNo && m.IsDel == "0");
-                if (info.Count() == 0)
-                {
-                    throw new Exception("鏈煡璇㈠埌鎵樼洏鍒嗛厤涓嬪彂鐨勪俊鎭�");
-                }
-
-                var data = info.GroupBy(m => new { m.SkuNo, m.SkuName, m.LotNo }).Select(m => new BoxInfo()
-                {
-                    SkuNo = m.SkuNo,
-                    SkuName = m.SkuName,
-                    LotNo = m.LotNo
-                }).ToList();
-
-                return data;
+                throw Oops.Bah("鏈煡璇㈠埌鎵樼洏鍒嗛厤涓嬪彂鐨勪俊鎭�");
             }
-            catch (Exception e)
+
+            var data = await info.GroupBy(m => new { m.SkuNo, m.SkuName, m.LotNo }).Select(m => new BoxInfo()
             {
-                throw new Exception(e.Message);
-            }
+                SkuNo = m.SkuNo,
+                SkuName = m.SkuName,
+                LotNo = m.LotNo
+            }).ToListAsync();
+
+            return data;
         }
 
         /// <summary>
@@ -1249,224 +1197,202 @@
         /// <param name="soNo">鍗曟嵁鍙�</param>
         /// <param name="palletNo">鎵樼洏鐮�</param>
         /// <param name="userId">鎿嶄綔浜�</param>
-        public void PlaneExportSuccess(string soNo, string palletNo, int userId)
+        public async Task PlaneExportSuccess(string soNo, string palletNo, int userId)
         {
+            #region 鎵樼洏淇℃伅
+
+            //鑾峰彇鎵樼洏淇℃伅
+            var pallet = await Db.Queryable<SysPallets>().FirstAsync(p => p.IsDel == "0" && p.PalletNo == palletNo);
+            //楠岃瘉鎵樼洏淇℃伅鏄惁涓虹┖
+            if (pallet == null)
+            {
+                throw Oops.Bah("鎵樼洏淇℃伅涓嶅瓨鍦紝璇锋鏌�!");
+            }
+            if (pallet.Status == "0")
+            {
+                throw Oops.Bah("鎵樼洏鏈娇鐢紝璇锋鏌�!");
+            }
+            #endregion
+
+            #region 鎵樼洏鏄惁鍦ㄥ钩搴撻獙璇�
+
+            var result = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.PalletNo == palletNo);
+            if (result == null)
+            {
+                throw Oops.Bah("搴撳瓨淇℃伅涓笉瀛樺湪璇ユ墭鐩樹俊鎭紝璇锋鏌�!");
+            }
+
+            //if (result.WareHouseNo != "W02")//W02锛氶浂绠卞簱
+            //{
+            //    throw Oops.Bah("璇ユ墭鐩樻湭鍦ㄩ浂绠卞簱锛岃妫�鏌�!");
+            //}
+
+            #endregion
+
+            #region 楠岃瘉鍌ㄤ綅鐘舵�佹槸鍚︽甯�
+
+            var locat = await Db.Queryable<SysStorageLocat>().FirstAsync(a => a.IsDel == "0" && a.LocatNo == result.LocatNo);
+            if (locat == null)
+            {
+                throw Oops.Bah("鏈幏鍙栧埌瀵瑰簲鍌ㄤ綅淇℃伅锛岃妫�鏌�!");
+            }
+            if (locat.Status != "3")
+            {
+                throw Oops.Bah("褰撳墠鍌ㄤ綅涓嶆槸鏈夌墿鍝侊紝璇锋鏌�!");
+            }
+
+            #endregion
+
+            //鑾峰彇搴撳瓨鏄庣粏淇℃伅
+            var stockDetail = await Db.Queryable<DataStockDetail>().Where(s => s.IsDel == "0" && s.PalletNo == palletNo).ToListAsync();
+            //楠岃瘉搴撳瓨鏄庣粏淇℃伅鏄惁瀛樺湪
+            if (stockDetail == null)
+            {
+                throw Oops.Bah("搴撳瓨鏄庣粏涓嶅瓨鍦紝璇锋鏌ュ簱瀛樹俊鎭�!");
+            }
+
+            Db.BeginTran();
+
             try
             {
-                #region 鎵樼洏淇℃伅
-
-                //鑾峰彇鎵樼洏淇℃伅
-                var pallet = Db.Queryable<SysPallets>().First(p => p.IsDel == "0" && p.PalletNo == palletNo);
-                //楠岃瘉鎵樼洏淇℃伅鏄惁涓虹┖
-                if (pallet == null)
+                foreach (var item in stockDetail)
                 {
-                    throw new Exception("鎵樼洏淇℃伅涓嶅瓨鍦紝璇锋鏌�!");
-                }
-                if (pallet.Status == "0")
-                {
-                    throw new Exception("鎵樼洏鏈娇鐢紝璇锋鏌�!");
-                }
-                #endregion
-
-                #region 鎵樼洏鏄惁鍦ㄥ钩搴撻獙璇�
-
-                var result = Db.Queryable<DataStockDetail>().First(m => m.PalletNo == palletNo);
-                if (result == null)
-                {
-                    throw new Exception("搴撳瓨淇℃伅涓笉瀛樺湪璇ユ墭鐩樹俊鎭紝璇锋鏌�!");
-                }
-
-                if (result.WareHouseNo != "W02")//W02锛氶浂绠卞簱
-                {
-                    throw new Exception("璇ユ墭鐩樻湭鍦ㄩ浂绠卞簱锛岃妫�鏌�!");
-                }
-
-                #endregion
-
-                #region 楠岃瘉鍌ㄤ綅鐘舵�佹槸鍚︽甯�
-
-                var locat = Db.Queryable<SysStorageLocat>().First(a=>a.IsDel == "0" && a.LocatNo == result.LocatNo);
-                if (locat == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌瀵瑰簲鍌ㄤ綅淇℃伅锛岃妫�鏌�!");
-                }
-                if (locat.Status != "1")
-                {
-                    throw new Exception("褰撳墠鍌ㄤ綅涓嶆槸鏈夌墿鍝侊紝璇锋鏌�!");
-                }
-
-                #endregion
-
-                //鑾峰彇搴撳瓨鏄庣粏淇℃伅
-                var stockDetail = Db.Queryable<DataStockDetail>().Where(s => s.IsDel == "0" && s.PalletNo == palletNo).ToList();
-                //楠岃瘉搴撳瓨鏄庣粏淇℃伅鏄惁瀛樺湪
-                if (stockDetail == null)
-                {
-                    throw new Exception("搴撳瓨鏄庣粏涓嶅瓨鍦紝璇锋鏌ュ簱瀛樹俊鎭�!");
-                }
-
-                Db.BeginTran();
-
-                try
-                {
-                    foreach (var item in stockDetail)
+                    if (item.SkuNo == "100099")//鍒ゆ柇鏄惁鏄┖鎵樺嚭搴�
                     {
-                        if (item.SkuNo == "100099")//鍒ゆ柇鏄惁鏄┖鎵樺嚭搴�
+                        //鍒ゆ柇鎬诲簱瀛樻槸鍚︿负0锛屽鏋滀负0鍒犻櫎 鍚﹀垯鍑忓幓鏁伴噺
+                        var stock = await Db.Queryable<DataStock>().FirstAsync(m => m.SkuNo == "100099");
+
+                        if (stock != null)
                         {
-                            //鍒ゆ柇鎬诲簱瀛樻槸鍚︿负0锛屽鏋滀负0鍒犻櫎 鍚﹀垯鍑忓幓鏁伴噺
-                            var stock = Db.Queryable<DataStock>().First(m => m.SkuNo == "100099");
-
-                            if (stock != null)
+                            if (item.LockQty != null)
                             {
-                                if (item.LockQty != null)
-                                {
-                                    stock.Qty -= item.LockQty.Value;
-                                    stock.LockQty -= item.LockQty.Value;
-                                    Db.Updateable(stock).ExecuteCommand();
-                                }
-
-                                if (stock.Qty == 0)
-                                {
-                                    Db.Deleteable(stock).ExecuteCommand();
-                                }
+                                stock.Qty -= item.LockQty.Value;
+                                stock.LockQty -= item.LockQty.Value;
+                                await Db.Updateable(stock).ExecuteCommandAsync();
                             }
 
-                            //鎵樼洏鐘舵�佹敼涓烘湭浣跨敤
-                            var sCode = Db.Queryable<SysPallets>().First(m => m.PalletNo == item.PalletNo);
-                            if (sCode != null)
+                            if (stock.Qty == 0)
                             {
-                                sCode.Status = "0";
-                                Db.Updateable(sCode).ExecuteCommand();
+                                await Db.Deleteable(stock).ExecuteCommandAsync();
                             }
-                            Db.Deleteable(item).ExecuteCommand();
-
-                            continue;
                         }
-                        item.LocatNo = "";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖锛�
-                        item.WareHouseNo = "";//鎵�灞炰粨搴撴洿鏀癸紙鏀逛负绌猴級
-                        item.RoadwayNo = "";//鎵�灞炲贩閬撴洿鏀癸紙鏀逛负绌猴級
-                        item.AreaNo = "";//鎵�灞炲尯鍩熸洿鏀癸紙鏀逛负绌猴級
-                        Db.Updateable(item).ExecuteCommand();
-                    }
-                    //鍙樻洿鍌ㄤ綅鐘舵��
-                    locat.Status = "0";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖鍌ㄤ綅锛�
-                    Db.Updateable(locat).ExecuteCommand();
 
-                    //鍑哄簱娴佹按锛堟洿鏀圭姸鎬侊級
-                    var allot = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "1" && m.PalletNo == palletNo && m.SONo == soNo).ToList();
-
-                    foreach (var item in allot)
-                    {
-                        if (item.SkuNo == "100099")
+                        //鎵樼洏鐘舵�佹敼涓烘湭浣跨敤
+                        var sCode = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == item.PalletNo);
+                        if (sCode != null)
                         {
-                            item.Status = "5";
-                            item.CompleteQty += stockDetail[0].Qty;
+                            sCode.Status = "0";
+                            await Db.Updateable(sCode).ExecuteCommandAsync();
                         }
-                        else
-                        {
-                            item.Status = "2";
-                        }
+                        await Db.Deleteable(item).ExecuteCommandAsync();
 
+                        continue;
                     }
-                    Db.Updateable(allot).ExecuteCommand();
-
-                    #region 娣诲姞鍑哄簱鎿嶄綔鏃ュ織璁板綍淇℃伅
-
-                    //娣诲姞鎿嶄綔鏃ュ織璁板綍
-                    var k = new OperationSOServer().AddLogOperationSo("鍑哄簱浣滀笟", "鎷h揣鏄庣粏", soNo, "瀹屾垚", $"鐢≒DA瀹屾垚浜嗗崟鎹彿涓簕soNo}鐨勫钩搴撳嚭搴�", userId);
-
-                    #endregion
-
-                    Db.CommitTran();
+                    item.LocatNo = "";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖锛�
+                    item.WareHouseNo = "";//鎵�灞炰粨搴撴洿鏀癸紙鏀逛负绌猴級
+                    item.RoadwayNo = "";//鎵�灞炲贩閬撴洿鏀癸紙鏀逛负绌猴級
+                    item.AreaNo = "";//鎵�灞炲尯鍩熸洿鏀癸紙鏀逛负绌猴級
+                    await Db.Updateable(item).ExecuteCommandAsync();
                 }
-                catch (Exception e)
+                //鍙樻洿鍌ㄤ綅鐘舵��
+                locat.Status = "0";//鍌ㄤ綅鏇存敼锛堟敼涓虹┖鍌ㄤ綅锛�
+                await Db.Updateable(locat).ExecuteCommandAsync();
+
+                //鍑哄簱娴佹按锛堟洿鏀圭姸鎬侊級
+                var allot = await Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.Status == "1" && m.PalletNo == palletNo && m.SONo == soNo).ToListAsync();
+
+                foreach (var item in allot)
                 {
-                    Db.RollbackTran();
-                    throw new Exception(e.Message);
+                    if (item.SkuNo == "100099")
+                    {
+                        item.Status = "5";
+                        item.CompleteQty += stockDetail[0].Qty;
+                    }
+                    else
+                    {
+                        item.Status = "2";
+                    }
+
                 }
+                await Db.Updateable(allot).ExecuteCommandAsync();
+
+                #region 娣诲姞鍑哄簱鎿嶄綔鏃ュ織璁板綍淇℃伅
+
+                //娣诲姞鎿嶄綔鏃ュ織璁板綍
+                var k = new OperationSOServer().AddLogOperationSo("鍑哄簱浣滀笟", "鎷h揣鏄庣粏", soNo, "瀹屾垚", $"鐢≒DA瀹屾垚浜嗗崟鎹彿涓簕soNo}鐨勫钩搴撳嚭搴�", userId);
+
+                #endregion
+
+                Db.CommitTran();
             }
             catch (Exception e)
             {
-                throw new Exception(e.Message);
+                Db.RollbackTran();
             }
         }
 
         //鏍规嵁鎵樼洏鍙疯幏鍙栧彇鏍风被鍨�
-        public string GetSampleType(string palletNo)
+        public async Task<string> GetSampleType(string palletNo)
         {
-            try
+            var type = "";
+            var detail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
+            if (detail == null)
             {
-                var type = "";
-                var detail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
-                if (detail == null)
-                {
-                    throw new Exception("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
-                }
-                //鎬庝箞鍒ゆ柇褰撳墠鎵樼洏鏄簱澶栬鍙栨牱鐨勬墭鐩橈紝姝e父鍑哄簱鍓╀綑鎵樼洏鐩墠杩欑鎯呭喌涔熻兘鎷h揣鍟婏紝涔熸病鏈夊垎閰嶄俊鎭�
-                var allot = Db.Queryable<BllExportAllot>().First(m =>
-                    m.IsDel == "0" && m.PalletNo == palletNo && m.Status != "5" && m.Status != "6");
-                if (allot != null)
-                {
-                    var soNo = Db.Queryable<BllExportNotice>()
-                        .First(m => m.IsDel == "0" && m.SONo == allot.SONo);
-                    if (soNo == null)
-                    {
-                        throw new Exception("鏈壘鍒版墭鐩樹笂鍑哄簱鍗曟嵁淇℃伅");
-                    }
-                    if (soNo.Type != "3")
-                    {
-                        throw new Exception("璇ユ墭鐩樹笉鏄彇鏍锋墭鐩�");
-                    }
-                    type = "0";//搴撳唴鍙栨牱
-                }
-                else
-                {
-                    //鍒ゆ柇褰撳墠鎵樼洏鏄惁鏄湪骞冲簱鎴栧簱澶�
-                    type = "1";//搴撳墠鍙栨牱
-                }
-                return type;
+                throw Oops.Bah("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
             }
-            catch (Exception e)
+            //鎬庝箞鍒ゆ柇褰撳墠鎵樼洏鏄簱澶栬鍙栨牱鐨勬墭鐩橈紝姝e父鍑哄簱鍓╀綑鎵樼洏鐩墠杩欑鎯呭喌涔熻兘鎷h揣鍟婏紝涔熸病鏈夊垎閰嶄俊鎭�
+            var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
+                m.IsDel == "0" && m.PalletNo == palletNo && m.Status != "5" && m.Status != "6");
+            if (allot != null)
             {
-                throw new Exception(e.Message);
+                var soNo = await Db.Queryable<BllExportNotice>()
+                    .FirstAsync(m => m.IsDel == "0" && m.SONo == allot.SONo);
+                if (soNo == null)
+                {
+                    throw Oops.Bah("鏈壘鍒版墭鐩樹笂鍑哄簱鍗曟嵁淇℃伅");
+                }
+                if (soNo.Type != "3")
+                {
+                    throw Oops.Bah("璇ユ墭鐩樹笉鏄彇鏍锋墭鐩�");
+                }
+                type = "0";//搴撳唴鍙栨牱
             }
+            else
+            {
+                //鍒ゆ柇褰撳墠鎵樼洏鏄惁鏄湪骞冲簱鎴栧簱澶�
+                type = "1";//搴撳墠鍙栨牱
+            }
+            return type;
         }
 
         //鏍规嵁鎵樼洏鍙疯幏鍙栧叆搴撳崟鎹�
-        public List<string> GetAsnNoByPallet(string palletNo)
+        public async Task<List<string>> GetAsnNoByPallet(string palletNo)
         {
-            try
+            var type = "";
+            var detail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
+            if (detail == null)
             {
-                var type = "";
-                var detail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
-                if (detail == null)
-                {
-                    throw new Exception("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
-                }
+                throw Oops.Bah("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
+            }
 
-                var list = new List<string>();
-                if (string.IsNullOrWhiteSpace(detail.ASNNo))
-                {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍏ュ簱鍗曚俊鎭�");
-                }
-                list.Add(detail.ASNNo);
-                return list;
-            }
-            catch (Exception e)
+            var list = new List<string>();
+            if (string.IsNullOrWhiteSpace(detail.ASNNo))
             {
-                throw new Exception(e.Message);
+                throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍏ュ簱鍗曚俊鎭�");
             }
+            list.Add(detail.ASNNo);
+            return list;
         }
 
         //鍙栨牱鍑哄簱鎷h揣(鏍囩)
-        public void SampleSoSetPick(string soType, string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, string asnNo, int userId)
+        public async Task SampleSoSetPick(string soType, string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, string asnNo, int userId)
         {
             Db.BeginTran();
             try
             {
                 if (string.IsNullOrWhiteSpace(soType))
                 {
-                    throw new Exception("鍙栨牱鏍囪瘑涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍙栨牱鏍囪瘑涓嶈兘涓虹┖");
                 }
 
                 //soType: 0搴撳唴鍙栨牱锛屾湁鍑哄簱鍗曞強鍒嗛厤淇℃伅锛� 1搴撳墠鍙栨牱锛屽弽鍚戞坊鍔犲嚭搴撳崟鍙婂垎閰嶄俊鎭�
@@ -1477,46 +1403,46 @@
 
                     if (string.IsNullOrWhiteSpace(asnNo))
                     {
-                        throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�");
+                        throw Oops.Bah("鍏ュ簱鍗曚笉鑳戒负绌�");
                     }
                     if (string.IsNullOrWhiteSpace(palletNo))
                     {
-                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                        throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                     }
                     if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
                     {
-                        throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                        throw Oops.Bah("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
                     }
                     //鍏堝垽鏂槸鍚︽槸搴撳鍙栨牱鎵樼洏
-                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                    var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                         m.IsDel == "0" && m.PalletNo == palletNo && m.Status != "5" && m.Status != "6");
                     if (allot != null)
                     {
-                        throw new Exception("褰撳墠鎵樼洏涓嶅睘浜庡簱鍓嶅彇鏍�");
+                        throw Oops.Bah("褰撳墠鎵樼洏涓嶅睘浜庡簱鍓嶅彇鏍�");
                     }
 
 
                     //搴撳瓨鏄庣粏
-                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.ASNNo == asnNo && m.PalletNo == palletNo);
+                    var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == asnNo && m.PalletNo == palletNo);
                     if (stockDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑搴撳瓨鏄庣粏淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑搴撳瓨鏄庣粏淇℃伅锛�");
                     }
 
                     var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == stockDetail.SkuNo);
                     if (sku == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌褰撳墠鎵樼洏涓婄殑鐗╂枡淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌褰撳墠鎵樼洏涓婄殑鐗╂枡淇℃伅");
                     }
                     //搴撳瓨鎬昏〃
-                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                     if (stock == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                     }
 
                     //鍑哄簱鍗�
-                    var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.AsnSampleNo == asnNo);
+                    var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.AsnSampleNo == asnNo);
                     //鍒涘缓鍑哄簱鍗�
                     if (notice == null || notice.Status == "6")
                     {
@@ -1527,7 +1453,7 @@
                             //鑾峰彇鑷鍗曟嵁鍙�
                             billNo = new Common().GetMaxNo("SO");
                             var no = billNo;
-                            bl = Db.Queryable<BllExportNotice>().Any(m => m.SONo == no);
+                            bl = await Db.Queryable<BllExportNotice>().AnyAsync(m => m.SONo == no);
                         } while (bl);
 
 
@@ -1545,12 +1471,12 @@
                             CreateUser = userId,
                         };
 
-                        var n = Db.Insertable(addNotice).ExecuteReturnEntity();
+                        var n = await Db.Insertable(addNotice).ExecuteReturnEntityAsync();
                         notice = n;
                     }
 
                     //鍒涘缓鍑哄簱鍗曟槑缁�
-                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>().First(m => m.IsDel == "0" && m.SONo == notice.SONo && m.SkuNo == stockDetail.SkuNo && m.LotNo.Contains(stockDetail.LotNo));
+                    var noticeDetail = await Db.Queryable<BllExportNoticeDetail>().FirstAsync(m => m.IsDel == "0" && m.SONo == notice.SONo && m.SkuNo == stockDetail.SkuNo && m.LotNo.Contains(stockDetail.LotNo));
                     if (noticeDetail == null)
                     {
                         var addNoticeDetail = new BllExportNoticeDetail()
@@ -1578,11 +1504,11 @@
                             CreateUser = userId,
 
                         };
-                        var m = Db.Insertable(addNoticeDetail).ExecuteReturnEntity();
+                        var m = await Db.Insertable(addNoticeDetail).ExecuteReturnEntityAsync();
                         noticeDetail = m;
                     }
                     //鍑哄簱鍒嗛厤淇℃伅
-                    var allot2 = Db.Queryable<BllExportAllot>().First(m => m.IsDel == "0" && m.Status == "5" && m.SONo == notice.SONo && m.PalletNo == palletNo);
+                    var allot2 = await Db.Queryable<BllExportAllot>().FirstAsync(m => m.IsDel == "0" && m.Status == "5" && m.SONo == notice.SONo && m.PalletNo == palletNo);
                     if (allot2 == null)
                     {
                         //娣诲姞鍒嗛厤琛ㄤ俊鎭�
@@ -1614,7 +1540,7 @@
                             UpdateTime = DateTime.Now
                         };
 
-                        var fp = Db.Insertable(addAllot).ExecuteReturnEntity();
+                        var fp = await Db.Insertable(addAllot).ExecuteReturnEntityAsync();
                         allot2 = fp;
                     }
 
@@ -1626,34 +1552,34 @@
                     var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
-                    if (boxInfo.Count() == 0)
+                    if (await boxInfo.CountAsync() == 0)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                     }
-                    boxInfos = boxInfo.ToList();
-                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot2.Id && m.PalletNo == palletNo).ToList();
+                    boxInfos = await boxInfo.ToListAsync();
+                    var comDetailList = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot2.Id && m.PalletNo == palletNo).ToListAsync();
                     if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
                     {
                         boxInfos = boxInfos.Where(m => m.BoxNo3 == boxNo3).ToList();
 
                         if (boxInfos.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                         }
                         if (boxInfos.Count() > 1)
                         {
-                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                            throw Oops.Bah("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
                         }
 
                         if (boxInfos.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                         biaoShi = "1";
@@ -1662,12 +1588,12 @@
                     {
                         if (boxInfo.Count() > 1)
                         {
-                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                            throw Oops.Bah("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
                         }
                         decimal boxQty = boxInfo.First().Qty;
                         if (Convert.ToInt32(pickQty1) > boxQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
 
                         biaoShi = "2";
@@ -1676,17 +1602,17 @@
                     {
                         if (boxInfo.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
                         }
                         if (boxInfo.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo == item.BoxNo))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                     }
@@ -1727,21 +1653,21 @@
                         if (biaoShi != "2")
                         {
                             //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                            Db.Deleteable(item).ExecuteCommand();
+                            await Db.Deleteable(item).ExecuteCommandAsync();
                         }
                         else//鏁伴噺鎷h揣
                         {
                             if (decimal.Parse(pickQty1) == item.Qty)
                             {
                                 //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                                Db.Deleteable(item).ExecuteCommand();
+                                await Db.Deleteable(item).ExecuteCommandAsync();
                             }
                             else
                             {
                                 item.Qty -= decimal.Parse(pickQty1);
                                 item.BitBoxMark = "1";//闆剁鏍囪瘑
                                 item.InspectMark = "1";//鎶芥绠辨爣璇�
-                                Db.Updateable(item).ExecuteCommand();
+                                await Db.Updateable(item).ExecuteCommandAsync();
                             }
                         }
                         pickQty += biaoShi == "2" ? decimal.Parse(pickQty1) : item.Qty;
@@ -1756,15 +1682,15 @@
                         {
                             item.BitBoxMark = "1";
                             item.InspectMark = "1";
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
                         }
                     }
 
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot2.Qty += pickQty;
                     allot2.CompleteQty += pickQty;
-                    Db.Updateable(allot2).ExecuteCommand();
+                    await Db.Updateable(allot2).ExecuteCommandAsync();
 
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
                     stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
@@ -1772,32 +1698,32 @@
 
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                     stock.Qty -= pickQty;
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
-                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    var num2 = await Db.Queryable<DataStockDetail>().CountAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
                     if (num2 <= 0)
                     {
                         //鏀瑰彉鎵樼洏鐘舵��
-                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                         if (pallet == null)
                         {
-                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                            throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                         }
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.Qty += pickQty;
@@ -1805,7 +1731,7 @@
                     noticeDetail.FactQty += pickQty;
                     noticeDetail.CompleteQty += pickQty;
                     noticeDetail.Money = string.IsNullOrWhiteSpace(sku.Price.ToString()) ? null : sku.Price * noticeDetail.Qty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
                 }
                 else if (soType == "0")
@@ -1814,60 +1740,60 @@
 
                     if (string.IsNullOrWhiteSpace(soNo))
                     {
-                        throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                        throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                     }
                     if (string.IsNullOrWhiteSpace(soDetailId))
                     {
-                        throw new Exception("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
+                        throw Oops.Bah("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
                     }
                     if (string.IsNullOrWhiteSpace(palletNo))
                     {
-                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                        throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                     }
                     if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
                     {
-                        throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                        throw Oops.Bah("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
                     }
 
                     //鍑哄簱鍗�
-                    var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                    var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.SONo == soNo);
                     if (notice == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                     }
                     if (notice.Status != "3")
                     {
-                        throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                        throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                     }
                     //鍑哄簱鍗曟槑缁�
-                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
-                        .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                    var noticeDetail = await Db.Queryable<BllExportNoticeDetail>()
+                        .FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                     if (noticeDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                     }
                     //鍑哄簱鍒嗛厤淇℃伅
-                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                    var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                         m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                         m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                     if (allot == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                     }
                     //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                     var needQty = allot.Qty - allot.CompleteQty;
 
                     //搴撳瓨鏄庣粏
-                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                    var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                     if (stockDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                     }
                     //搴撳瓨鎬昏〃
-                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                     if (stock == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                     }
 
                     #endregion
@@ -1875,39 +1801,39 @@
                     var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
-                    if (boxInfo.Count() == 0)
+                    if (await boxInfo.CountAsync() == 0)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                     }
-                    boxInfos = boxInfo.ToList();
-                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    boxInfos = await boxInfo.ToListAsync();
+                    var comDetailList = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToListAsync();
                     if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
                     {
                         boxInfos = boxInfos.Where(m => m.BoxNo3 == boxNo3).ToList();
 
                         if (boxInfos.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                         }
                         if (boxInfos.Count() > 1)
                         {
-                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                            throw Oops.Bah("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
                         }
 
                         if (boxInfos.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         var boxQty = boxInfos.First().Qty;
                         if (boxQty > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                         biaoShi = "1";
@@ -1916,16 +1842,16 @@
                     {
                         if (boxInfo.Count() > 1)
                         {
-                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                            throw Oops.Bah("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
                         }
                         decimal boxQty = boxInfo.First().Qty;
                         if (Convert.ToInt32(pickQty1) > boxQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         if (Convert.ToInt32(pickQty1) > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         biaoShi = "2";
@@ -1934,22 +1860,22 @@
                     {
                         if (boxInfo.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
                         }
                         if (boxInfo.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         var boxQty = boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
                         if (boxQty[0] > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
                         }
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo == item.BoxNo))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                     }
@@ -1989,21 +1915,21 @@
                         if (biaoShi != "2")
                         {
                             //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                            Db.Deleteable(item).ExecuteCommand();
+                            await Db.Deleteable(item).ExecuteCommandAsync();
                         }
                         else//鏁伴噺鎷h揣
                         {
                             if (decimal.Parse(pickQty1) == item.Qty)
                             {
                                 //鍒犻櫎搴撳瓨绠辩爜鏄庣粏
-                                Db.Deleteable(item).ExecuteCommand();
+                                await Db.Deleteable(item).ExecuteCommandAsync();
                             }
                             else
                             {
                                 item.Qty -= decimal.Parse(pickQty1);
                                 item.BitBoxMark = "1";//闆剁鏍囪瘑
                                 item.InspectMark = "1"; //鎶芥绠辨爣璇�
-                                Db.Updateable(item).ExecuteCommand();
+                                await Db.Updateable(item).ExecuteCommandAsync();
                             }
                         }
                         pickQty += item.Qty;
@@ -2015,11 +1941,11 @@
                         foreach (var item in boxSurplusList)
                         {
                             item.BitBoxMark = "1";
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
                         }
                     }
 
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot.CompleteQty += pickQty;
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
@@ -2028,7 +1954,7 @@
                     {
                         //鍒ゆ柇璇ユ墭鐩樻槸鍚﹁繕瀛樺湪鐗╂枡 瀛樺湪鏀逛负寰呭洖搴� 寰呭洖搴撳畬鎴愬悗鏀逛负宸插畬鎴�
                     }
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
 
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
                     stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
@@ -2050,47 +1976,47 @@
 
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                     stock.Qty -= pickQty;
                     stock.LockQty -= pickQty;
                     stock.IsSampling = "1";
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
-                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    var num2 = await Db.Queryable<DataStockDetail>().CountAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
                     if (num2 <= 0)
                     {
                         //鏀瑰彉鎵樼洏鐘舵��
-                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                         if (pallet == null)
                         {
-                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                            throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                         }
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                    var num = Db.Queryable<BllExportNoticeDetail>()
-                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    var num = await Db.Queryable<BllExportNoticeDetail>()
+                        .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
-                    Db.Updateable(notice).ExecuteCommand();
+                    await Db.Updateable(notice).ExecuteCommandAsync();
                 }
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鍑哄簱", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勬墭鐩樼爜涓猴細{palletNo}鐨勬嫞璐ф搷浣�", userId);
@@ -2099,61 +2025,60 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
 
         //鍙栨牱鍑哄簱鎷h揣(鏃犳爣绛�)
-        public void SampleSoSetQtyPick(string soType, string soNo, string soDetailId, string palletNo, string PickQty, string asnNo, int userId)
+        public async Task SampleSoSetQtyPick(string soType, string soNo, string soDetailId, string palletNo, string PickQty, string asnNo, int userId)
         {
             Db.BeginTran();
             try
             {
                 if (string.IsNullOrWhiteSpace(soType))
                 {
-                    throw new Exception("鍙栨牱鏍囪瘑涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍙栨牱鏍囪瘑涓嶈兘涓虹┖");
                 }
 
                 if (soType == "1")
                 {
                     if (string.IsNullOrWhiteSpace(asnNo))
                     {
-                        throw new Exception("鍏ュ簱鍗曟嵁涓嶈兘涓虹┖");
+                        throw Oops.Bah("鍏ュ簱鍗曟嵁涓嶈兘涓虹┖");
                     }
                     if (string.IsNullOrWhiteSpace(palletNo))
                     {
-                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                        throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                     }
                     //鍏堝垽鏂槸鍚︽槸搴撳鍙栨牱鎵樼洏
-                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                    var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                         m.IsDel == "0" && m.PalletNo == palletNo && m.Status != "5" && m.Status != "6");
                     if (allot != null)
                     {
-                        throw new Exception("褰撳墠鎵樼洏涓嶅睘浜庡簱鍓嶅彇鏍�");
+                        throw Oops.Bah("褰撳墠鎵樼洏涓嶅睘浜庡簱鍓嶅彇鏍�");
                     }
 
 
                     //搴撳瓨鏄庣粏
-                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.ASNNo == asnNo && m.PalletNo == palletNo);
+                    var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == asnNo && m.PalletNo == palletNo);
                     if (stockDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑搴撳瓨鏄庣粏淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑搴撳瓨鏄庣粏淇℃伅锛�");
                     }
 
-                    var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == stockDetail.SkuNo);
+                    var sku = await Db.Queryable<SysMaterials>().FirstAsync(m => m.IsDel == "0" && m.SkuNo == stockDetail.SkuNo);
                     if (sku == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌褰撳墠鎵樼洏涓婄殑鐗╂枡淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌褰撳墠鎵樼洏涓婄殑鐗╂枡淇℃伅");
                     }
                     //搴撳瓨鎬昏〃
-                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                     if (stock == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                     }
 
                     //鍑哄簱鍗�
-                    var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.AsnSampleNo == asnNo);
+                    var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.AsnSampleNo == asnNo);
                     //鍒涘缓鍑哄簱鍗�
                     if (notice == null || notice.Status == "6")
                     {
@@ -2164,7 +2089,7 @@
                             //鑾峰彇鑷鍗曟嵁鍙�
                             billNo = new Common().GetMaxNo("SO");
                             var no = billNo;
-                            bl = Db.Queryable<BllExportNotice>().Any(m => m.SONo == no);
+                            bl = await Db.Queryable<BllExportNotice>().AnyAsync(m => m.SONo == no);
                         } while (bl);
 
                         var addNotice = new BllExportNotice()
@@ -2181,12 +2106,12 @@
                             CreateUser = userId,
                         };
 
-                        var n = Db.Insertable(addNotice).ExecuteReturnEntity();
+                        var n = await Db.Insertable(addNotice).ExecuteReturnEntityAsync();
                         notice = n;
                     }
 
                     //鍒涘缓鍑哄簱鍗曟槑缁�
-                    var noticeDetail = Db.Queryable<BllExportNoticeDetail>().First(m => m.IsDel == "0" && m.SONo == notice.SONo && m.SkuNo == stockDetail.SkuNo && m.LotNo.Contains(stockDetail.LotNo));
+                    var noticeDetail = await Db.Queryable<BllExportNoticeDetail>().FirstAsync(m => m.IsDel == "0" && m.SONo == notice.SONo && m.SkuNo == stockDetail.SkuNo && m.LotNo.Contains(stockDetail.LotNo));
                     if (noticeDetail == null)
                     {
                         var addNoticeDetail = new BllExportNoticeDetail()
@@ -2214,11 +2139,11 @@
                             CreateUser = userId,
 
                         };
-                        var m = Db.Insertable(addNoticeDetail).ExecuteReturnEntity();
+                        var m = await Db.Insertable(addNoticeDetail).ExecuteReturnEntityAsync();
                         noticeDetail = m;
                     }
                     //鍑哄簱鍒嗛厤淇℃伅
-                    var allot2 = Db.Queryable<BllExportAllot>().First(m => m.IsDel == "0" && m.Status == "5" && m.SONo == notice.SONo && m.PalletNo == palletNo);
+                    var allot2 = await Db.Queryable<BllExportAllot>().FirstAsync(m => m.IsDel == "0" && m.Status == "5" && m.SONo == notice.SONo && m.PalletNo == palletNo);
                     if (allot2 == null)
                     {
                         //娣诲姞鍒嗛厤琛ㄤ俊鎭�
@@ -2250,12 +2175,12 @@
                             UpdateTime = DateTime.Now
                         };
 
-                        var fp = Db.Insertable(addAllot).ExecuteReturnEntity();
+                        var fp = await Db.Insertable(addAllot).ExecuteReturnEntityAsync();
                         allot2 = fp;
                     }
 
                     //鑾峰彇褰撳墠鎵樼洏鎷h揣鏄庣粏
-                    var complete = Db.Queryable<BllCompleteDetail>().First(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.ExportAllotId == allot2.Id && a.StockId == stockDetail.Id);
+                    var complete = await Db.Queryable<BllCompleteDetail>().FirstAsync(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.ExportAllotId == allot2.Id && a.StockId == stockDetail.Id);
 
                     //鍒よ鏄惁瀛樺湪鎷h揣鏄庣粏
                     int isComplete = 0;
@@ -2294,7 +2219,7 @@
                         comList.Add(completeDetail);
 
                         //娣诲姞鎷h揣鏄庣粏
-                        Db.Insertable(comList).ExecuteCommand();
+                        await Db.Insertable(comList).ExecuteCommandAsync();
                     }
                     else if (isComplete == 1)
                     {
@@ -2302,7 +2227,7 @@
                         complete.UpdateUser = userId;
                         complete.UpdateTime = Db.GetDate();
 
-                        Db.Updateable(complete).ExecuteCommand();
+                        await Db.Updateable(complete).ExecuteCommandAsync();
                     }
 
 
@@ -2310,7 +2235,7 @@
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot2.Qty += int.Parse(PickQty);
                     allot2.CompleteQty += int.Parse(PickQty);
-                    Db.Updateable(allot2).ExecuteCommand();
+                    await Db.Updateable(allot2).ExecuteCommandAsync();
 
                     int isDel = 0;
 
@@ -2332,36 +2257,36 @@
                     }
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
                         isDel = 1;
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛�
                     stock.Qty -= int.Parse(PickQty);
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
 
                     //鏀瑰彉鎵樼洏鐘舵�佷负锛氭湭浣跨敤
-                    var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                    var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                     if (pallet == null)
                     {
-                        throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                     }
 
                     //鍒ゆ柇鎵樼洏涓婄墿鏂欐槸鍚︽嫞璐у畬姣�
                     if (isDel == 0)
                     {
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
 
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
@@ -2370,7 +2295,7 @@
                     noticeDetail.FactQty += int.Parse(PickQty);
                     noticeDetail.CompleteQty += int.Parse(PickQty);
                     noticeDetail.Money = string.IsNullOrWhiteSpace(sku.Price.ToString()) ? null : sku.Price * noticeDetail.Qty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
                 }
                 else if (soType == "0")
@@ -2379,7 +2304,7 @@
 
                     if (string.IsNullOrWhiteSpace(soNo))
                     {
-                        throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                        throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                     }
                     //if (string.IsNullOrWhiteSpace(soDetailId))
                     //{
@@ -2387,56 +2312,56 @@
                     //}
                     if (string.IsNullOrWhiteSpace(palletNo))
                     {
-                        throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                        throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                     }
 
                     //鍑哄簱鍗�
                     var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
                     if (notice == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                     }
                     if (notice.Status != "3")
                     {
-                        throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                        throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                     }
                     //鍑哄簱鍗曟槑缁�
                     var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
                         .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                     if (noticeDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                     }
                     //鍑哄簱鍒嗛厤淇℃伅
-                    var allot = Db.Queryable<BllExportAllot>().First(m =>
+                    var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                         m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                         m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                     if (allot == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                     }
                     //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                     var needQty = allot.Qty - allot.CompleteQty;
                     if (int.Parse(PickQty) > needQty)
                     {
-                        throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
+                        throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
                     }
 
                     //搴撳瓨鏄庣粏
-                    var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                    var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                     if (stockDetail == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                     }
                     //搴撳瓨鎬昏〃
-                    var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                    var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                     if (stock == null)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                     }
                     #endregion
                     //鑾峰彇褰撳墠鎵樼洏鎷h揣鏄庣粏
-                    var complete = Db.Queryable<BllCompleteDetail>().First(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
+                    var complete = await Db.Queryable<BllCompleteDetail>().FirstAsync(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
 
                     //鍒よ鏄惁瀛樺湪鎷h揣鏄庣粏
                     int isComplete = 0;
@@ -2475,7 +2400,7 @@
                         comList.Add(completeDetail);
 
                         //娣诲姞鎷h揣鏄庣粏
-                        Db.Insertable(comList).ExecuteCommand();
+                        await Db.Insertable(comList).ExecuteCommandAsync();
                     }
                     else if (isComplete == 1)
                     {
@@ -2483,7 +2408,7 @@
                         complete.UpdateUser = userId;
                         complete.UpdateTime = Db.GetDate();
 
-                        Db.Updateable(complete).ExecuteCommand();
+                        await Db.Updateable(complete).ExecuteCommandAsync();
                     }
 
 
@@ -2493,7 +2418,7 @@
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
 
                     allot.UpdateTime = DateTime.Now;
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
 
                     int isDel = 0;
 
@@ -2516,12 +2441,12 @@
                     }
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
                         isDel = 1;
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛�
                     stock.Qty -= int.Parse(PickQty);
@@ -2529,39 +2454,39 @@
                     stock.IsSampling = "1"; //鏄惁鍙栨牱
                     if (stock.Qty <= 0)
                     {
-                        Db.Deleteable(stock).ExecuteCommand();
+                        await Db.Deleteable(stock).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stock).ExecuteCommand();
+                        await Db.Updateable(stock).ExecuteCommandAsync();
                     }
 
                     //鏀瑰彉鎵樼洏鐘舵�佷负锛氭湭浣跨敤
-                    var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                    var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                     if (pallet == null)
                     {
-                        throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                     }
 
                     //鍒ゆ柇鎵樼洏涓婄墿鏂欐槸鍚︽嫞璐у畬姣�
                     if (isDel == 0)
                     {
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
 
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += int.Parse(PickQty);
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                    var num = Db.Queryable<BllExportNoticeDetail>()
-                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    var num = await Db.Queryable<BllExportNoticeDetail>()
+                        .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
-                    Db.Updateable(notice).ExecuteCommand();
+                    await Db.Updateable(notice).ExecuteCommandAsync();
 
                 }
 
@@ -2572,7 +2497,6 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
 
@@ -2588,7 +2512,7 @@
         /// <param name="pickQty1"></param>
         /// <param name="palletNoNew"></param>
         /// <param name="userId"></param>
-        public void SoSetPinPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, string palletNoNew, int userId)
+        public async Task SoSetPinPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string pickQty1, string palletNoNew, int userId)
         {
             Db.BeginTran();
             try
@@ -2598,71 +2522,71 @@
 
                 if (string.IsNullOrWhiteSpace(soNo))
                 {
-                    throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(soDetailId))
                 {
-                    throw new Exception("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鐗╂枡-鎵规涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                 }
                 if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty1) && int.Parse(pickQty1) > 0)
                 {
-                    throw new Exception("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
+                    throw Oops.Bah("杩芥函鏉$爜鍜屾嫞璐ф暟閲忎笉鑳藉悓鏃惰緭鍏�");
                 }
                 if (string.IsNullOrWhiteSpace(palletNoNew))
                 {
-                    throw new Exception("鏂版墭鐩樼爜涓嶈兘涓虹┖");
+                    throw Oops.Bah("鏂版墭鐩樼爜涓嶈兘涓虹┖");
                 }
                 if (palletNo == palletNoNew)//鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷�
                 {
                     if (!string.IsNullOrEmpty(boxNo))
                     {
-                        throw new Exception("鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷达紝璇烽�夋嫨鏁存墭鍑哄簱");
+                        throw Oops.Bah("鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷达紝璇烽�夋嫨鏁存墭鍑哄簱");
                     }
                 }
 
                 //鍑哄簱鍗�
-                var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.SONo == soNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                 }
                 if (notice.Status != "3")
                 {
-                    throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                 }
                 //鍑哄簱鍗曟槑缁�
-                var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
-                    .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>()
+                    .FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                 if (noticeDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                 }
                 //鍑哄簱鍒嗛厤淇℃伅
-                var allot = Db.Queryable<BllExportAllot>().First(m =>
+                var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                     m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                     m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                 if (allot == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                 }
                 //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                 var needQty = allot.Qty - allot.CompleteQty;
 
                 //搴撳瓨鏄庣粏
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                 }
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                 }
 
                 #endregion
@@ -2670,14 +2594,14 @@
                 #region 鎷兼墭淇℃伅
                 var sdId = 0;
                 bool isNew = false;
-                var pinStockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
+                var pinStockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
                 if (pinStockDetail != null)
                 {
                     if (palletNo != palletNoNew)//闈炴暣鎵樻嫞璐�
                     {
                         if (pinStockDetail.SONo != notice.SONo)
                         {
-                            throw new Exception("鎷兼墭鎵樼洏涓婂彧鑳芥斁鍚屼竴涓嚭搴撳崟涓嬬殑鐗╂枡锛�");
+                            throw Oops.Bah("鎷兼墭鎵樼洏涓婂彧鑳芥斁鍚屼竴涓嚭搴撳崟涓嬬殑鐗╂枡锛�");
                         }
                         if (pinStockDetail.SkuName != stockDetail.SkuName || pinStockDetail.LotNo != stockDetail.LotNo)
                         {
@@ -2690,14 +2614,14 @@
                 {
                     isNew = true;
 
-                    var newPalletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Status == "0");
+                    var newPalletInfo = await Db.Queryable<SysPallets>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Status == "0");
                     if (newPalletInfo == null)
                     {
-                        throw new Exception("鏂版墭鐩樹俊鎭笉瀛樺湪鎴栧凡琚娇鐢紒");
+                        throw Oops.Bah("鏂版墭鐩樹俊鎭笉瀛樺湪鎴栧凡琚娇鐢紒");
                     }
                     //淇敼鏂版墭鐩樼姸鎬�
                     newPalletInfo.Status = "1";
-                    Db.Updateable(newPalletInfo).ExecuteCommand();
+                    await Db.Updateable(newPalletInfo).ExecuteCommandAsync();
                 }
                 var sd = new DataStockDetail();
                 if (isNew)
@@ -2743,7 +2667,7 @@
                     sd.CreateTime = nowDate;
 
                     //鏂板鎷兼墭搴撳瓨鏄庣粏淇℃伅
-                    sdId = Db.Insertable(sd).ExecuteReturnIdentity();
+                    sdId = await Db.Insertable(sd).ExecuteReturnIdentityAsync();
                 }
                 #endregion
 
@@ -2752,28 +2676,28 @@
                 {
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo);//鎵惧埌鎵樼洏涓婃墍鏈夌鐮�
-                    boxInfos = boxInfo.ToList();
+                    boxInfos = await boxInfo.ToListAsync();
                     if (boxInfo.Count() <= 0)
                     {
-                        throw new Exception("璇ユ墭鐩樹笂娌℃湁鍙嫞璐х殑绠卞瓙");
+                        throw Oops.Bah("璇ユ墭鐩樹笂娌℃湁鍙嫞璐х殑绠卞瓙");
                     }
-                    var boxQty = boxInfo.GroupBy(m => m.PalletNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
+                    var boxQty = await boxInfo.GroupBy(m => m.PalletNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToListAsync();
                     if (boxQty[0] > needQty)
                     {
-                        throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                        throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
                     }
 
-                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    var comDetailList = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToListAsync();
                     var comList = new List<BllCompleteDetail>();
                     foreach (var item in boxInfos)
                     {
                         if (comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
                         {
-                            throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                            throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                         }
                         if (item.SkuNo != allot.SkuNo || item.LotNo != allot.LotNo)
                         {
-                            throw new Exception("褰撳墠鎵樼洏涓婃湁鍏朵粬涓嶅悓鐗╂枡鎵规锛屾嫞璐уけ璐�");
+                            throw Oops.Bah("褰撳墠鎵樼洏涓婃湁鍏朵粬涓嶅悓鐗╂枡鎵规锛屾嫞璐уけ璐�");
                         }
                         //娣诲姞鎷h揣鏄庣粏
                         var completeDetail = new BllCompleteDetail()
@@ -2798,7 +2722,7 @@
                             CreateUser = userId
                         };
                         comList.Add(completeDetail);
-                        
+
                         if (palletNo != palletNoNew)
                         {
                             item.StockDetailId = sdId;
@@ -2807,41 +2731,41 @@
                         }
                         item.Status = "5";//绠辨敮鐘舵�侊紝0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
                         //淇敼搴撳瓨绠辩爜鏄庣粏
-                        Db.Updateable(item).ExecuteCommand();
+                        await Db.Updateable(item).ExecuteCommandAsync();
 
                         pickQty += item.Qty;
                     }
                     //娣诲姞鎷h揣鏄庣粏
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot.CompleteQty += pickQty;
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
                     allot.UpdateTime = DateTime.Now;
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
 
                     if (palletNo != palletNoNew)
                     {
                         //鍒犻櫎鍘熸墭鐩樺簱瀛樻槑缁�
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
 
                         //鏀瑰彉鍘熸墭鐩樼姸鎬佷负锛氭湭浣跨敤
-                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                         if (pallet == null)
                         {
-                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                            throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                         }
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
                     else
                     {
                         stockDetail.SONo = soNo;
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
-                   
+
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
                     var num = Db.Queryable<BllExportNoticeDetail>()
                         .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
@@ -2850,48 +2774,48 @@
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
-                    Db.Updateable(notice).ExecuteCommand();
+                    await Db.Updateable(notice).ExecuteCommandAsync();
                 }
                 else
                 {
                     var biaoShi = "0";//0锛氭暣绠辨嫞璐с��1锛氭暎鏀嫞璐с��2锛氭暟閲忔嫞璐�
                     List<DataBoxInfo> boxInfos;
                     var boxInfo = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo);
-                    if (boxInfo.Count() == 0)
+                    if (await boxInfo.CountAsync() == 0)
                     {
-                        throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                        throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                     }
-                    boxInfos = boxInfo.ToList();
+                    boxInfos = await boxInfo.ToListAsync();
 
-                    var comDetailList = Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToList();
+                    var comDetailList = await Db.Queryable<BllCompleteDetail>().Where(m => m.IsDel == "0" && m.ExportAllotId == allot.Id && m.PalletNo == palletNo).ToListAsync();
                     if (!string.IsNullOrWhiteSpace(boxNo3)) //鏁f敮鎷h揣
                     {
                         boxInfos = boxInfos.Where(m => m.BoxNo3 == boxNo3).ToList();
 
                         if (boxInfos.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佸強杩芥函鐮佺殑淇℃伅");
                         }
                         if (boxInfos.Count() > 1)
                         {
-                            throw new Exception("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
+                            throw Oops.Bah("璇ヨ拷婧敮鐮佺殑淇℃伅澶т簬1鏉★紝淇℃伅閿欒锛岃鏍稿疄锛�");
                         }
 
                         if (boxInfos.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
                         var boxQty = boxInfos.First().Qty;
                         if (boxQty > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo3 == item.BoxNo3))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}涓瓄item.BoxNo3}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
 
@@ -2901,16 +2825,16 @@
                     {
                         if (boxInfo.Count() > 1)
                         {
-                            throw new Exception("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
+                            throw Oops.Bah("璇ョ鐮佸唴瀛樺湪鏀爜涓嶈兘杩涜鏁伴噺鎷h揣");
                         }
                         decimal boxQty = boxInfo.First().Qty;
                         if (Convert.ToInt32(pickQty1) > boxQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         if (Convert.ToInt32(pickQty1) > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         biaoShi = "2";
@@ -2919,23 +2843,23 @@
                     {
                         if (boxInfo.Count() == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌璇ョ鐮佺殑淇℃伅");
                         }
                         if (boxInfo.Any(m => m.PalletNo != palletNo))
                         {
-                            throw new Exception("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
+                            throw Oops.Bah("璇ユ墭鐩樹笌绠辩爜娌℃湁缁戝畾鍏崇郴");
                         }
-                        var boxQty = boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToList();
+                        var boxQty = await boxInfo.GroupBy(m => m.BoxNo).Select(m => SqlFunc.AggregateSum(m.Qty)).ToListAsync();
                         if (boxQty[0] > needQty)
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鍓╀綑寰呮嫞鏁伴噺");
                         }
 
                         foreach (var item in boxInfos)
                         {
                             if (biaoShi != "2" && comDetailList.Any(m => m.BoxNo == item.BoxNo))
                             {
-                                throw new Exception($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
+                                throw Oops.Bah($"褰撳墠{item.BoxNo}宸叉嫞璐у畬鎴愶紝璇峰嬁閲嶅鎷h揣");
                             }
                         }
                     }
@@ -2974,7 +2898,7 @@
                             item.BindNo = null;//鎵樼洏缁戝畾鍙�
                             item.PalletNo = palletNoNew;
                             item.Status = "5";//绠辨敮鐘舵�侊紝0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
 
                             pickQty += item.Qty;
                         }
@@ -2987,7 +2911,7 @@
                             item.BoxNo = item.BoxNo3;//灏嗘敮鐮佽祴缁欑鐮�
                             item.BitBoxMark = "1";//闆剁鏍囪
                             item.Status = "5";//绠辨敮鐘舵�侊紝0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
 
                             pickQty += item.Qty;
                         }
@@ -3000,13 +2924,13 @@
                                 item.BindNo = null;//鎵樼洏缁戝畾鍙�
                                 item.PalletNo = palletNoNew;
                                 item.Status = "5";//绠辨敮鐘舵�侊紝0锛氭湭缁勬墭  1锛氬凡缁勬墭 2锛氬凡鍏ュ簱 3锛氬凡鍑哄簱 4:宸插垎閰� 5锛氬凡鎷h揣
-                                Db.Updateable(item).ExecuteCommand();
+                                await Db.Updateable(item).ExecuteCommandAsync();
                             }
                             else
                             {
                                 item.Qty -= decimal.Parse(pickQty1);
                                 item.BitBoxMark = "1";//闆剁鏍囪瘑
-                                Db.Updateable(item).ExecuteCommand();
+                                await Db.Updateable(item).ExecuteCommandAsync();
                             }
 
                             pickQty += int.Parse(pickQty1);
@@ -3019,11 +2943,11 @@
                         foreach (var item in boxSurplusList)
                         {
                             item.BitBoxMark = "1";
-                            Db.Updateable(item).ExecuteCommand();
+                            await Db.Updateable(item).ExecuteCommandAsync();
                         }
                     }
 
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                     //淇敼鍑哄簱鍒嗛厤淇℃伅
                     allot.CompleteQty += pickQty;
                     allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
@@ -3032,7 +2956,7 @@
                     {
                         //鍒ゆ柇璇ユ墭鐩樻槸鍚﹁繕瀛樺湪鐗╂枡 瀛樺湪鏀逛负寰呭洖搴� 寰呭洖搴撳畬鎴愬悗鏀逛负宸插畬鎴�
                     }
-                    Db.Updateable(allot).ExecuteCommand();
+                    await Db.Updateable(allot).ExecuteCommandAsync();
 
                     //鍒犻櫎鎴栦慨鏀瑰簱瀛樻槑缁�
                     stockDetail.BitPalletMark = "1";//淇敼涓洪浂鎵樻爣璇�
@@ -3053,36 +2977,36 @@
 
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
-                    var num2 = Db.Queryable<DataStockDetail>().Count(m => m.IsDel == "0" && m.PalletNo == palletNo);
+                    var num2 = await Db.Queryable<DataStockDetail>().CountAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
                     if (num2 <= 0)
                     {
                         //鏀瑰彉鎵樼洏鐘舵��
-                        var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                        var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                         if (pallet == null)
                         {
-                            throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                            throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                         }
                         pallet.Status = "0";
-                        Db.Updateable(pallet).ExecuteCommand();
+                        await Db.Updateable(pallet).ExecuteCommandAsync();
                     }
                     //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                     noticeDetail.CompleteQty += pickQty;
-                    Db.Updateable(noticeDetail).ExecuteCommand();
+                    await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                    var num = Db.Queryable<BllExportNoticeDetail>()
-                        .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                    var num = await Db.Queryable<BllExportNoticeDetail>()
+                        .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                     if (num <= 0)
                     {
                         notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                     }
                     //淇敼鍑哄簱鍗曚俊鎭�
-                    Db.Updateable(notice).ExecuteCommand();
+                    await Db.Updateable(notice).ExecuteCommandAsync();
                 }
 
                 if (isNew)
@@ -3097,10 +3021,10 @@
                         //淇敼鎷兼墭鎵樼洏搴撳瓨鏄庣粏
                         pinStockDetail.Qty += pickQty;
                         pinStockDetail.LockQty += pickQty;
-                        Db.Updateable(pinStockDetail).ExecuteCommand();
+                        await Db.Updateable(pinStockDetail).ExecuteCommandAsync();
                     }
                 }
-                
+
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鎷兼墭", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勫師鎵樼洏鐮佷负锛歿palletNo}锛屾柊鎵樼洏鐮佷负锛歿palletNoNew}鐨勬嫞璐ф嫾鎵樻搷浣�", userId);
                 Db.CommitTran();
@@ -3108,7 +3032,6 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
         /// <summary>
@@ -3120,7 +3043,7 @@
         /// <param name="PickQty"></param>
         /// <param name="palletNoNew"></param>
         /// <param name="userId"></param>
-        public void SoSetQtyPinPick(string soNo, string soDetailId, string palletNo, string PickQty, string palletNoNew, int userId)
+        public async Task SoSetQtyPinPick(string soNo, string soDetailId, string palletNo, string PickQty, string palletNoNew, int userId)
         {
             Db.BeginTran();
             try
@@ -3130,7 +3053,7 @@
 
                 if (string.IsNullOrWhiteSpace(soNo))
                 {
-                    throw new Exception("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("鍑哄簱鍗曟嵁涓嶈兘涓虹┖");
                 }
                 //if (string.IsNullOrWhiteSpace(soDetailId))
                 //{
@@ -3138,76 +3061,76 @@
                 //}
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鐮佷笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鐮佷笉鑳戒负绌�");
                 }
                 if (string.IsNullOrWhiteSpace(palletNoNew))
                 {
-                    throw new Exception("鏂版墭鐩樼爜涓嶈兘涓虹┖");
+                    throw Oops.Bah("鏂版墭鐩樼爜涓嶈兘涓虹┖");
                 }
 
                 //鍑哄簱鍗�
-                var notice = Db.Queryable<BllExportNotice>().First(m => m.IsDel == "0" && m.SONo == soNo);
+                var notice = await Db.Queryable<BllExportNotice>().FirstAsync(m => m.IsDel == "0" && m.SONo == soNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鐨勪俊鎭�");
                 }
                 if (notice.Status != "3")
                 {
-                    throw new Exception("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
+                    throw Oops.Bah("鍑哄簱鍗曠殑鐘舵�佷笉鏄鍦ㄦ墽琛岋紝涓嶈兘鎷h揣");
                 }
                 //鍑哄簱鍗曟槑缁�
-                var noticeDetail = Db.Queryable<BllExportNoticeDetail>()
-                    .First(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
+                var noticeDetail = await Db.Queryable<BllExportNoticeDetail>()
+                    .FirstAsync(m => m.IsDel == "0" && m.Id == int.Parse(soDetailId));
                 if (noticeDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ュ嚭搴撳崟鏄庣粏鐨勪俊鎭�");
                 }
                 //鍑哄簱鍒嗛厤淇℃伅
-                var allot = Db.Queryable<BllExportAllot>().First(m =>
+                var allot = await Db.Queryable<BllExportAllot>().FirstAsync(m =>
                     m.IsDel == "0" && (m.Status == "2" || m.Status == "3") && m.SONo == soNo &&
                     m.SODetailNo == int.Parse(soDetailId) && m.PalletNo == palletNo);
                 if (allot == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樼殑鍒嗛厤淇℃伅");
                 }
                 //鍓╀綑鎷h揣鏁伴噺锛堝緟鎷e噺鍘诲凡鎷o級
                 var needQty = allot.Qty - allot.CompleteQty;
                 if (int.Parse(PickQty) > needQty)
                 {
-                    throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
+                    throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬鎵樺唴鍓╀綑寰呮嫞鏁伴噺");
                 }
 
                 //搴撳瓨鏄庣粏
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.Id == allot.StockId);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.Id == allot.StockId);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨鏄庣粏淇℃伅锛�");
                 }
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(a => a.IsDel == "0" && a.SkuNo == stockDetail.SkuNo && a.LotNo == stockDetail.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇ユ墭鐩樺垎閰嶇殑搴撳瓨淇℃伅锛�");
                 }
                 if (palletNo == palletNoNew)//鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷�
                 {
                     if (int.Parse(PickQty) != stockDetail.Qty)
                     {
-                        throw new Exception("鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷达紝闇�瑕佹妸鎵樼洏涓婃墍鏈夋暟閲忔嫞璐�");
+                        throw Oops.Bah("鍘熸墭鐩樹笌鏂版墭鐩樹竴鑷达紝闇�瑕佹妸鎵樼洏涓婃墍鏈夋暟閲忔嫞璐�");
                     }
                 }
                 #endregion
 
                 #region 鎷兼墭淇℃伅
                 bool isNew = false;
-                var pinStockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
+                var pinStockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew);
                 if (pinStockDetail != null)
                 {
                     if (palletNo != palletNoNew)//闈炴暣鎵樻嫞璐�
                     {
                         if (pinStockDetail.SONo != notice.SONo)
                         {
-                            throw new Exception("鎷兼墭鎵樼洏涓婂彧鑳芥斁鍚屼竴涓嚭搴撳崟涓嬬殑鐗╂枡锛�");
+                            throw Oops.Bah("鎷兼墭鎵樼洏涓婂彧鑳芥斁鍚屼竴涓嚭搴撳崟涓嬬殑鐗╂枡锛�");
                         }
                         if (pinStockDetail.SkuName != stockDetail.SkuName || pinStockDetail.LotNo != stockDetail.LotNo)
                         {
@@ -3219,14 +3142,14 @@
                 {
                     isNew = true;
 
-                    var newPalletInfo = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Status == "0");
+                    var newPalletInfo = await Db.Queryable<SysPallets>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNoNew && m.Status == "0");
                     if (newPalletInfo == null)
                     {
-                        throw new Exception("鏂版墭鐩樹俊鎭笉瀛樺湪鎴栧凡琚娇鐢紒");
+                        throw Oops.Bah("鏂版墭鐩樹俊鎭笉瀛樺湪鎴栧凡琚娇鐢紒");
                     }
                     //淇敼鏂版墭鐩樼姸鎬�
                     newPalletInfo.Status = "1";
-                    Db.Updateable(newPalletInfo).ExecuteCommand();
+                    await Db.Updateable(newPalletInfo).ExecuteCommandAsync();
                 }
 
                 if (isNew)
@@ -3277,7 +3200,7 @@
                     sd.CreateTime = nowDate;
 
                     //鏂板鎷兼墭搴撳瓨鏄庣粏淇℃伅
-                    Db.Insertable(sd).ExecuteReturnIdentity();
+                    await Db.Insertable(sd).ExecuteReturnIdentityAsync();
                 }
                 else
                 {
@@ -3286,18 +3209,18 @@
                         //淇敼鎷兼墭鎵樼洏搴撳瓨鏄庣粏
                         pinStockDetail.Qty += int.Parse(PickQty);
                         pinStockDetail.LockQty += int.Parse(PickQty);
-                        Db.Updateable(pinStockDetail).ExecuteCommand();
+                        await Db.Updateable(pinStockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
                         pinStockDetail.SONo = soNo;
-                        Db.Updateable(pinStockDetail).ExecuteCommand();
+                        await Db.Updateable(pinStockDetail).ExecuteCommandAsync();
                     }
                 }
                 #endregion
 
                 //鑾峰彇褰撳墠鎵樼洏鎷h揣鏄庣粏
-                var complete = Db.Queryable<BllCompleteDetail>().First(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
+                var complete = await Db.Queryable<BllCompleteDetail>().FirstAsync(a => a.IsDel == "0" && a.PalletNo == palletNo && a.SONo == notice.SONo && a.SODetailNo == noticeDetail.Id && a.ExportAllotId == allot.Id && a.StockId == stockDetail.Id);
 
                 //鍒よ鏄惁瀛樺湪鎷h揣鏄庣粏
                 int isComplete = 0;
@@ -3337,7 +3260,7 @@
                     comList.Add(completeDetail);
 
                     //娣诲姞鎷h揣鏄庣粏
-                    Db.Insertable(comList).ExecuteCommand();
+                    await Db.Insertable(comList).ExecuteCommandAsync();
                 }
                 else if (isComplete == 1)
                 {
@@ -3345,14 +3268,14 @@
                     complete.UpdateUser = userId;
                     complete.UpdateTime = Db.GetDate();
 
-                    Db.Updateable(complete).ExecuteCommand();
+                    await Db.Updateable(complete).ExecuteCommandAsync();
                 }
 
                 //淇敼鍑哄簱鍒嗛厤淇℃伅
                 allot.CompleteQty += int.Parse(PickQty);
                 allot.Status = allot.Qty == allot.CompleteQty ? "5" : "3";
                 allot.UpdateTime = DateTime.Now;
-                Db.Updateable(allot).ExecuteCommand();
+                await Db.Updateable(allot).ExecuteCommandAsync();
 
                 int isDel = 0;
 
@@ -3376,12 +3299,12 @@
                     }
                     if (stockDetail.Qty <= 0)
                     {
-                        Db.Deleteable(stockDetail).ExecuteCommand();
+                        await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                     }
                     else
                     {
                         isDel = 1;
-                        Db.Updateable(stockDetail).ExecuteCommand();
+                        await Db.Updateable(stockDetail).ExecuteCommandAsync();
                     }
                 }
                 else
@@ -3392,28 +3315,28 @@
                 if (isDel == 0)
                 {
                     //鏀瑰彉鎵樼洏鐘舵�佷负锛氭湭浣跨敤
-                    var pallet = Db.Queryable<SysPallets>().First(m => m.PalletNo == palletNo && m.IsDel == "0");
+                    var pallet = await Db.Queryable<SysPallets>().FirstAsync(m => m.PalletNo == palletNo && m.IsDel == "0");
                     if (pallet == null)
                     {
-                        throw new Exception("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
+                        throw Oops.Bah("鏈湪鎵樼洏琛ㄤ腑鏌ヨ鍒版墭鐩樹俊鎭�");
                     }
 
                     pallet.Status = "0";
-                    Db.Updateable(pallet).ExecuteCommand();
+                    await Db.Updateable(pallet).ExecuteCommandAsync();
                 }
 
                 //淇敼鍑哄簱鍗曟槑缁嗘嫞璐ф暟閲�
                 noticeDetail.CompleteQty += int.Parse(PickQty);
-                Db.Updateable(noticeDetail).ExecuteCommand();
+                await Db.Updateable(noticeDetail).ExecuteCommandAsync();
 
-                var num = Db.Queryable<BllExportNoticeDetail>()
-                    .Count(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
+                var num = await Db.Queryable<BllExportNoticeDetail>()
+                    .CountAsync(m => m.IsDel == "0" && m.SONo == soNo && m.CompleteQty < m.Qty);
                 if (num <= 0)
                 {
                     notice.Status = "4"; //鏇存敼涓烘墽琛屽畬鎴�
                 }
                 //淇敼鍑哄簱鍗曚俊鎭�
-                Db.Updateable(notice).ExecuteCommand();
+                await Db.Updateable(notice).ExecuteCommandAsync();
 
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
                 var k = new OperationSOServer().AddLogOperationSo("PDA妯″潡", "鎷h揣鎷兼墭", soNo, "鎷h揣", $"鍦≒DA涓婂鍑哄簱鍗曞彿涓猴細{soNo}鐨勬墭鐩樼爜涓猴細{palletNo}锛屾柊鎵樼洏鐮佷负锛歿palletNoNew}鐨勬嫞璐ф搷浣�", userId);
@@ -3422,7 +3345,6 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
         #endregion
@@ -3430,75 +3352,53 @@
         #region JC23鐗堝彇鏍�
 
         //鏍规嵁鎵樼洏鍙疯幏鍙栧彇鏍风被鍨�
-        public string GetSampleType2(string palletNo)
+        public async Task<string> GetSampleType2(string palletNo)
         {
-            try
+            var type = "";
+            var detail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo);
+            if (detail == null)
             {
-                var type = "";
-                var detail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
-                if (detail == null)
-                {
-                    throw new Exception("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
-                }
-
-                var boxInfo = Db.Queryable<DataBoxInfo>().Count(m=>m.IsDel == "0" && m.StockDetailId == detail.Id);
-
-                //鍒ゆ柇鎵樼洏涓婃槸鍚︽湁绠辩爜淇℃伅
-                if (boxInfo > 0)
-                {
-                    type = "0";//鏍囩鍙栨牱
-                }
-                else
-                {
-                    type = "1";//鏁伴噺鍙栨牱
-                }
-                return type;
+                throw Oops.Bah("褰撳墠鎵樼洏鏈湪搴撳瓨涓�");
             }
-            catch (Exception e)
+
+            var boxInfo = await Db.Queryable<DataBoxInfo>().CountAsync(m => m.IsDel == "0" && m.StockDetailId == detail.Id);
+
+            //鍒ゆ柇鎵樼洏涓婃槸鍚︽湁绠辩爜淇℃伅
+            if (boxInfo > 0)
             {
-                throw new Exception(e.Message);
+                type = "0";//鏍囩鍙栨牱
             }
+            else
+            {
+                type = "1";//鏁伴噺鍙栨牱
+            }
+            return type;
         }
 
         //鑾峰彇寰呭嚭搴撴垨寰呭彇鏍风殑璇烽獙鍗�
-        public List<string> GetInspectionNo()
+        public async Task<List<string>> GetInspectionNo()
         {
-            try
-            {
-                var data = Db.Queryable<BllQualityInspectionRequest>().Where(m => m.IsDel == "0" && (m.Status == "1" || m.Status == "2")).OrderByDescending(m => m.QcNo).Select(m=>m.QcNo).ToList();
-                return data;
-            }
-            catch (Exception e)
-            {
-                throw new Exception(e.Message);
-            }
+            return await Db.Queryable<BllQualityInspectionRequest>().Where(m => m.IsDel == "0" && (m.Status == "1" || m.Status == "2")).OrderByDescending(m => m.QcNo).Select(m => m.QcNo).ToListAsync();
         }
 
         //鑾峰彇璇烽獙鍗曠浉鍏充俊鎭�
-        public InspectionRequestDto GetInspectionRequestInfo(string qcNo)
+        public async Task<InspectionRequestDto> GetInspectionRequestInfo(string qcNo)
         {
-            try
-            {
-                var data = new InspectionRequestDto();
-                var inspectionRequest = Db.Queryable<BllQualityInspectionRequest>().First(m=>m.IsDel == "0" && m.QcNo == qcNo);
-                var samplingQty = Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo).Sum(m=>m.CompleteQty);
+            var data = new InspectionRequestDto();
+            var inspectionRequest = await Db.Queryable<BllQualityInspectionRequest>().FirstAsync(m => m.IsDel == "0" && m.QcNo == qcNo);
+            var samplingQty = await Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo).SumAsync(m => m.CompleteQty);
 
-                data.QcNo = qcNo;
-                data.Sku = inspectionRequest.SkuNo;
-                data.LotNo = inspectionRequest.LotNo;
-                data.Qty = inspectionRequest.SamplingQty.ToString();
-                data.SamplingQty = samplingQty == null? "0": samplingQty.ToString();
+            data.QcNo = qcNo;
+            data.Sku = inspectionRequest.SkuNo;
+            data.LotNo = inspectionRequest.LotNo;
+            data.Qty = inspectionRequest.SamplingQty.ToString();
+            data.SamplingQty = samplingQty == null ? "0" : samplingQty.ToString();
 
-                return data;
-            }
-            catch (Exception e)
-            {
-                throw new Exception(e.Message);
-            }
+            return data;
         }
 
         //鍙栨牱鍑哄簱鎷h揣(鏍囩)
-        public void SampleSetPick(string qcNo, string palletNo, string boxNo, string boxNo3, string pickQty, int userId)
+        public async Task SampleSetPick(string qcNo, string palletNo, string boxNo, string boxNo3, string pickQty, int userId)
         {
             try
             {
@@ -3506,20 +3406,20 @@
 
                 if (string.IsNullOrWhiteSpace(qcNo))
                 {
-                    throw new Exception("璇烽獙鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("璇烽獙鍗曟嵁涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鍙蜂笉鑳戒负绌�");
                 }
-                var type = GetSampleType2(palletNo);
+                var type = await GetSampleType2(palletNo);
                 if (type != "0")
                 {
-                    throw new Exception("褰撳墠鎵樼洏璇峰湪鏁伴噺椤电鍙栨牱");
+                    throw Oops.Bah("褰撳墠鎵樼洏璇峰湪鏁伴噺椤电鍙栨牱");
                 }
                 if (string.IsNullOrEmpty(boxNo))
                 {
-                    throw new Exception("澶栫鏉$爜涓嶈兘涓虹┖");
+                    throw Oops.Bah("澶栫鏉$爜涓嶈兘涓虹┖");
                 }
                 //if (!string.IsNullOrEmpty(boxNo3) && !string.IsNullOrEmpty(pickQty) && int.Parse(pickQty) > 0)
                 //{
@@ -3527,44 +3427,44 @@
                 //}
 
                 //璇烽獙鍗�
-                var inspecd = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.QcNo == qcNo);
+                var inspecd = await Db.Queryable<BllQualityInspectionRequest>().FirstAsync(m => m.IsDel == "0" && m.QcNo == qcNo);
                 if (inspecd == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇烽獙鍗曚俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇烽獙鍗曚俊鎭�");
                 }
                 if (inspecd.Status == "0" || inspecd.Status == "3")
                 {
-                    throw new Exception("璇烽獙鍗曠姸鎬侀敊璇紝璇锋牳瀹�");
+                    throw Oops.Bah("璇烽獙鍗曠姸鎬侀敊璇紝璇锋牳瀹�");
                 }
                 //搴撳瓨鏄庣粏淇℃伅
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈湪搴撳瓨涓煡璇㈠嚭褰撳墠鎵樼洏淇℃伅");
+                    throw Oops.Bah("鏈湪搴撳瓨涓煡璇㈠嚭褰撳墠鎵樼洏淇℃伅");
                 }
                 if (!string.IsNullOrWhiteSpace(stockDetail.LocatNo))
                 {
-                    throw new Exception("褰撳墠鎵樼洏涓嶆槸搴撳鎵樼洏锛岃鏍稿疄");
+                    throw Oops.Bah("褰撳墠鎵樼洏涓嶆槸搴撳鎵樼洏锛岃鏍稿疄");
                 }
                 //绠辨敮淇℃伅 
-                var boxInfoList = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo).ToList();
+                var boxInfoList = await Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo).ToListAsync();
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠嚭搴撳瓨鎬讳俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠嚭搴撳瓨鎬讳俊鎭�");
                 }
                 //鍏ュ簱鍗�
-                var notice = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo);
+                var notice = await Db.Queryable<BllArrivalNotice>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌鍏ュ簱鍗曚俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌鍏ュ簱鍗曚俊鎭�");
                 }
 
                 #endregion
 
                 //鍙栨牱鏄庣粏璁板綍琛�
-                var sampld = Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo).ToList();
+                var sampld = await Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo).ToListAsync();
 
                 var isAddSampld = false;
                 var PickType = ""; //0鏁伴噺鎷h揣  1 绠辨敮鎷h揣
@@ -3581,16 +3481,16 @@
                     {
                         if (boxInfoList.Count(m => m.BoxNo3 == boxNo3) == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌鏀爜淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌鏀爜淇℃伅");
                         }
                         if (boxInfoList.Count(m => m.BoxNo3 == boxNo3) > 1)
                         {
-                            throw new Exception("鏀爜淇℃伅鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
+                            throw Oops.Bah("鏀爜淇℃伅鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
                         }
-                        EditboxInfo = Db.Queryable<DataBoxInfo>().First(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
+                        EditboxInfo = await Db.Queryable<DataBoxInfo>().FirstAsync(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo && m.BoxNo3 == boxNo3);
                         if (EditboxInfo.Qty < decimal.Parse(pickQty))
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         isAddSampld = sampld.Count(m => m.PalletNo == palletNo && m.BoxNo == EditboxInfo.BoxNo && m.BoxNo3 == EditboxInfo.BoxNo3) == 0;
                     }
@@ -3599,33 +3499,33 @@
 
                         if (boxInfoList.Count == 0)
                         {
-                            throw new Exception("鏈湪鎵樼洏涓婃煡璇㈠埌绠辩爜淇℃伅锛岃鏍稿疄");
+                            throw Oops.Bah("鏈湪鎵樼洏涓婃煡璇㈠埌绠辩爜淇℃伅锛岃鏍稿疄");
                         }
                         if (boxInfoList.Count > 1)
                         {
-                            throw new Exception("绠辩爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
+                            throw Oops.Bah("绠辩爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
                         }
                         if (boxInfoList.Count(m => !string.IsNullOrWhiteSpace(m.BoxNo3)) > 0)
                         {
-                            throw new Exception("褰撳墠绠辩爜涓惈鏈夋敮鐮侊紝璇疯緭鍏ユ敮鐮佷俊鎭彇鏍�");
+                            throw Oops.Bah("褰撳墠绠辩爜涓惈鏈夋敮鐮侊紝璇疯緭鍏ユ敮鐮佷俊鎭彇鏍�");
                         }
-                        EditboxInfo = Db.Queryable<DataBoxInfo>().First(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo);
+                        EditboxInfo = await Db.Queryable<DataBoxInfo>().FirstAsync(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo);
 
                         if (EditboxInfo.Qty < decimal.Parse(pickQty))
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         isAddSampld = sampld.Count(m => m.PalletNo == palletNo && m.BoxNo == EditboxInfo.BoxNo) == 0;
 
                     }
                     if (sampld.Sum(m => m.CompleteQty) + decimal.Parse(pickQty) > inspecd.SamplingQty)
                     {
-                        throw new Exception("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
+                        throw Oops.Bah("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
                     }
                     //鍒ゆ柇绠变腑鏄惁鍚湁鏀爜锛屾湁锛氫笉璁╂嫞鏁伴噺
                     if (stockDetail.Qty - stockDetail.LockQty - stockDetail.FrozenQty < decimal.Parse(pickQty))
                     {
-                        throw new Exception("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
+                        throw Oops.Bah("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
                     }
                 }
                 else //绠辨敮鎷h揣
@@ -3638,16 +3538,16 @@
 
                         if (boxInfoList.Count(m => m.BoxNo3 == boxNo3) == 0)
                         {
-                            throw new Exception("鏈煡璇㈠埌鏀爜淇℃伅");
+                            throw Oops.Bah("鏈煡璇㈠埌鏀爜淇℃伅");
                         }
                         if (boxInfoList.Count(m => m.BoxNo3 == boxNo3) > 1)
                         {
-                            throw new Exception("鏀爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
+                            throw Oops.Bah("鏀爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
                         }
-                        EditboxInfoList = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo && m.BoxNo3 == boxNo3).ToList();
+                        EditboxInfoList = await Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo && m.BoxNo3 == boxNo3).ToListAsync();
                         if (EditboxInfoList.Sum(m => m.Qty) + sampld.Sum(m => m.CompleteQty) > inspecd.SamplingQty)
                         {
-                            throw new Exception("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
+                            throw Oops.Bah("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
                         }
                         qty = EditboxInfoList.Sum(m => m.Qty);
                         //isAddSampld = sampld.Count(m => m.PalletNo == palletNo && m.BoxNo == EditboxInfo.BoxNo && m.BoxNo3 == EditboxInfo.BoxNo3) == 0;
@@ -3657,32 +3557,32 @@
 
                         if (boxInfoList.Count == 0)
                         {
-                            throw new Exception("鏈湪鎵樼洏涓婃煡璇㈠埌绠辩爜淇℃伅锛岃鏍稿疄");
+                            throw Oops.Bah("鏈湪鎵樼洏涓婃煡璇㈠埌绠辩爜淇℃伅锛岃鏍稿疄");
                         }
                         if (boxInfoList.Count > 1)
                         {
-                            throw new Exception("绠辩爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
+                            throw Oops.Bah("绠辩爜鏁版嵁淇℃伅閿欒锛岃鏍稿疄");
                         }
                         if (boxInfoList.Count(m => !string.IsNullOrWhiteSpace(m.BoxNo3)) > 0)
                         {
-                            throw new Exception("褰撳墠绠辩爜涓惈鏈夋敮鐮侊紝璇疯緭鍏ユ敮鐮佷俊鎭彇鏍�");
+                            throw Oops.Bah("褰撳墠绠辩爜涓惈鏈夋敮鐮侊紝璇疯緭鍏ユ敮鐮佷俊鎭彇鏍�");
                         }
-                        EditboxInfoList = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo).ToList();
+                        EditboxInfoList = await Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.StockDetailId == stockDetail.Id && m.BoxNo == boxNo).ToListAsync();
 
                         if (EditboxInfo.Qty < decimal.Parse(pickQty))
                         {
-                            throw new Exception("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
+                            throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘澶т簬绠卞唴鏁伴噺");
                         }
                         qty = EditboxInfoList.Sum(m => m.Qty);
                         //isAddSampld = sampld.Count(m => m.PalletNo == palletNo && m.BoxNo == EditboxInfo.BoxNo) == 0;
                     }
                     if (sampld.Sum(m => m.CompleteQty) + qty > inspecd.SamplingQty)
                     {
-                        throw new Exception("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
+                        throw Oops.Bah("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
                     }
                     if (stockDetail.Qty - stockDetail.LockQty - stockDetail.FrozenQty < qty)
                     {
-                        throw new Exception("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
+                        throw Oops.Bah("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
                     }
                 }
                 #endregion
@@ -3700,24 +3600,24 @@
 
                     //if (isAddSampld) //娣诲姞鍙栨牱鏄庣粏
                     //{
-                        var sampleDetail = new BllSamplingDetails()
-                        {
-                            QcNo = qcNo,
-                            ASNNo = inspecd.ASNNo,
-                            PalletNo = palletNo,
-                            BoxNo = boxInfo.BoxNo,
-                            BoxNo2 = boxInfo.BoxNo2,
-                            BoxNo3 = boxInfo.BoxNo3,
-                            SkuNo = boxInfo.SkuNo,
-                            SkuName = boxInfo.SkuName,
-                            Standard = boxInfo.Standard,
-                            LotNo = boxInfo.LotNo,
-                            SupplierLot = boxInfo.SupplierLot,
-                            CompleteQty = decimal.Parse(pickQty),
-                            CreateTime = DateTime.Now,
-                            CreateUser = userId
-                        };
-                        Db.Insertable(sampleDetail).ExecuteCommand();
+                    var sampleDetail = new BllSamplingDetails()
+                    {
+                        QcNo = qcNo,
+                        ASNNo = inspecd.ASNNo,
+                        PalletNo = palletNo,
+                        BoxNo = boxInfo.BoxNo,
+                        BoxNo2 = boxInfo.BoxNo2,
+                        BoxNo3 = boxInfo.BoxNo3,
+                        SkuNo = boxInfo.SkuNo,
+                        SkuName = boxInfo.SkuName,
+                        Standard = boxInfo.Standard,
+                        LotNo = boxInfo.LotNo,
+                        SupplierLot = boxInfo.SupplierLot,
+                        CompleteQty = decimal.Parse(pickQty),
+                        CreateTime = DateTime.Now,
+                        CreateUser = userId
+                    };
+                    Db.Insertable(sampleDetail).ExecuteCommand();
                     //}
                     //else
                     //{
@@ -3742,7 +3642,7 @@
                     {
                         item.BitBoxMark = "1";
                         item.InspectMark = "1";
-                            
+
                         if (unpackWarranty > 0 && boxInfoList.Count(m => m.ProductionTime != null) > 0)
                         {
                             if (item.ProductionTime != null)
@@ -3757,7 +3657,7 @@
 
                     }
                     Db.Updateable(boxInfoList).ExecuteCommand();
-                    
+
                     //搴撳瓨绠辩爜
                     boxInfo.Qty -= decimal.Parse(pickQty);
                     if (boxInfo.Qty == 0)
@@ -3830,24 +3730,24 @@
 
                         //if (isAddSampld) //娣诲姞鍙栨牱鏄庣粏
                         //{
-                            var sampleDetail = new BllSamplingDetails()
-                            {
-                                QcNo = qcNo,
-                                ASNNo = inspecd.ASNNo,
-                                PalletNo = palletNo,
-                                BoxNo = boxInfo.BoxNo,
-                                BoxNo2 = boxInfo.BoxNo2,
-                                BoxNo3 = boxInfo.BoxNo3,
-                                SkuNo = boxInfo.SkuNo,
-                                SkuName = boxInfo.SkuName,
-                                Standard = boxInfo.Standard,
-                                LotNo = boxInfo.LotNo,
-                                SupplierLot = boxInfo.SupplierLot,
-                                CompleteQty = boxInfo.Qty,
-                                CreateTime = DateTime.Now,
-                                CreateUser = userId
-                            };
-                            Db.Insertable(sampleDetail).ExecuteCommand();
+                        var sampleDetail = new BllSamplingDetails()
+                        {
+                            QcNo = qcNo,
+                            ASNNo = inspecd.ASNNo,
+                            PalletNo = palletNo,
+                            BoxNo = boxInfo.BoxNo,
+                            BoxNo2 = boxInfo.BoxNo2,
+                            BoxNo3 = boxInfo.BoxNo3,
+                            SkuNo = boxInfo.SkuNo,
+                            SkuName = boxInfo.SkuName,
+                            Standard = boxInfo.Standard,
+                            LotNo = boxInfo.LotNo,
+                            SupplierLot = boxInfo.SupplierLot,
+                            CompleteQty = boxInfo.Qty,
+                            CreateTime = DateTime.Now,
+                            CreateUser = userId
+                        };
+                        await Db.Insertable(sampleDetail).ExecuteCommandAsync();
                         //}
                         //else
                         //{
@@ -3866,8 +3766,8 @@
                         #region 淇敼搴撳瓨涓夎〃
 
                         //鎷嗗寘鏈夋晥鏈熸洿鏀�
-                        var unpackWarranty = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo).UnpackWarranty;
-                        
+                        var unpackWarranty = (await Db.Queryable<SysMaterials>().FirstAsync(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo)).UnpackWarranty;
+
                         foreach (var item in boxInfoList)
                         {
                             item.BitBoxMark = "1";
@@ -3884,31 +3784,31 @@
                                 }
                             }
                         }
-                        Db.Updateable(boxInfoList).ExecuteCommand();
+                        await Db.Updateable(boxInfoList).ExecuteCommandAsync();
 
                         //搴撳瓨绠辩爜
 
-                        Db.Deleteable(boxInfo).ExecuteCommand();
+                        await Db.Deleteable(boxInfo).ExecuteCommandAsync();
 
                         //搴撳瓨鏄庣粏
                         stockDetail.Qty -= boxInfo.Qty;
                         if (stockDetail.Qty == 0)
                         {
-                            Db.Deleteable(stockDetail).ExecuteCommand();
+                            await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                         }
                         else
                         {
-                            Db.Updateable(stockDetail).ExecuteCommand();
+                            await Db.Updateable(stockDetail).ExecuteCommandAsync();
                         }
                         //搴撳瓨鎬昏〃
                         stock.Qty -= boxInfo.Qty;
                         if (stock.Qty == 0)
                         {
-                            Db.Deleteable(stock).ExecuteCommand();
+                            await Db.Deleteable(stock).ExecuteCommandAsync();
                         }
                         else
                         {
-                            Db.Updateable(stock).ExecuteCommand();
+                            await Db.Updateable(stock).ExecuteCommandAsync();
                         }
 
                         #endregion
@@ -3918,12 +3818,12 @@
                         //涓嶆槸涓婁紶瀹屾瘯鐨勪慨鏀瑰彇鏍风姸鎬�
                         if (notice.Status != "4")
                         {
-                            var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                            var noticeDetail = await Db.Queryable<BllArrivalNoticeDetail>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                             if (noticeDetail.IsSampling == "0")
                             {
                                 noticeDetail.IsSampling = "1";
 
-                                Db.Updateable(noticeDetail).ExecuteCommand();
+                                await Db.Updateable(noticeDetail).ExecuteCommandAsync();
                             }
 
                         }
@@ -3941,7 +3841,7 @@
                         inspecd.Status = "3";
                     }
 
-                    Db.Updateable(inspecd).ExecuteCommand();
+                    await Db.Updateable(inspecd).ExecuteCommandAsync();
                     #endregion
                 }
 
@@ -3955,13 +3855,12 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
 
 
         //鍙栨牱鍑哄簱鎷h揣(鏁伴噺)
-        public void SampleSetQtyPick(string qcNo, string palletNo, string pickQty, int userId)
+        public async Task SampleSetQtyPick(string qcNo, string palletNo, string pickQty, int userId)
         {
             try
             {
@@ -3969,77 +3868,77 @@
 
                 if (string.IsNullOrWhiteSpace(qcNo))
                 {
-                    throw new Exception("璇烽獙鍗曟嵁涓嶈兘涓虹┖");
+                    throw Oops.Bah("璇烽獙鍗曟嵁涓嶈兘涓虹┖");
                 }
                 if (string.IsNullOrWhiteSpace(palletNo))
                 {
-                    throw new Exception("鎵樼洏鍙蜂笉鑳戒负绌�");
+                    throw Oops.Bah("鎵樼洏鍙蜂笉鑳戒负绌�");
                 }
-                var type = GetSampleType2(palletNo);
+                var type = await GetSampleType2(palletNo);
                 if (type != "1")
                 {
-                    throw new Exception("褰撳墠鎵樼洏璇峰湪鏍囩椤电鍙栨牱");
+                    throw Oops.Bah("褰撳墠鎵樼洏璇峰湪鏍囩椤电鍙栨牱");
                 }
                 if (string.IsNullOrWhiteSpace(pickQty))
                 {
-                    throw new Exception("鎷h揣鏁伴噺涓嶈兘涓虹┖");
+                    throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘涓虹┖");
                 }
                 if (decimal.Parse(pickQty) <= 0)
                 {
-                    throw new Exception("鎷h揣鏁伴噺涓嶈兘灏忎簬绛変簬0");
+                    throw Oops.Bah("鎷h揣鏁伴噺涓嶈兘灏忎簬绛変簬0");
                 }
 
                 //璇烽獙鍗�
-                var inspecd = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.QcNo == qcNo);
+                var inspecd = await Db.Queryable<BllQualityInspectionRequest>().FirstAsync(m => m.IsDel == "0" && m.QcNo == qcNo);
                 if (inspecd == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌璇烽獙鍗曚俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌璇烽獙鍗曚俊鎭�");
                 }
                 if (inspecd.Status == "0" || inspecd.Status == "3")
                 {
-                    throw new Exception("璇烽獙鍗曠姸鎬侀敊璇紝璇锋牳瀹�");
+                    throw Oops.Bah("璇烽獙鍗曠姸鎬侀敊璇紝璇锋牳瀹�");
                 }
                 //搴撳瓨鏄庣粏淇℃伅
-                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == palletNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                var stockDetail = await Db.Queryable<DataStockDetail>().FirstAsync(m => m.IsDel == "0" && m.PalletNo == palletNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                 if (stockDetail == null)
                 {
-                    throw new Exception("鏈湪搴撳瓨涓煡璇㈠嚭褰撳墠鎵樼洏淇℃伅");
+                    throw Oops.Bah("鏈湪搴撳瓨涓煡璇㈠嚭褰撳墠鎵樼洏淇℃伅");
                 }
                 if (!string.IsNullOrWhiteSpace(stockDetail.LocatNo))
                 {
-                    throw new Exception("褰撳墠鎵樼洏涓嶆槸搴撳鎵樼洏锛岃鏍稿疄");
+                    throw Oops.Bah("褰撳墠鎵樼洏涓嶆槸搴撳鎵樼洏锛岃鏍稿疄");
                 }
                 //搴撳瓨鎬昏〃
-                var stock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                var stock = await Db.Queryable<DataStock>().FirstAsync(m => m.IsDel == "0" && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                 if (stock == null)
                 {
-                    throw new Exception("鏈煡璇㈠嚭搴撳瓨鎬讳俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠嚭搴撳瓨鎬讳俊鎭�");
                 }
                 //鍏ュ簱鍗�
-                var notice = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo);
+                var notice = await Db.Queryable<BllArrivalNotice>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo);
                 if (notice == null)
                 {
-                    throw new Exception("鏈煡璇㈠埌鍏ュ簱鍗曚俊鎭�");
+                    throw Oops.Bah("鏈煡璇㈠埌鍏ュ簱鍗曚俊鎭�");
                 }
 
                 #endregion
 
                 //鍙栨牱鏄庣粏璁板綍琛�
-                var sampld = Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo ).ToList();
+                var sampld = await Db.Queryable<BllSamplingDetails>().Where(m => m.IsDel == "0" && m.QcNo == qcNo).ToListAsync();
                 var qty = decimal.Parse(pickQty);
                 //var isAddSampld = sampld.Count(m => m.PalletNo == palletNo) == 0; 
-                  
+
 
                 #region 鍒ゆ柇鏁伴噺
 
                 if (sampld.Sum(m => m.CompleteQty) + qty > inspecd.SamplingQty)
                 {
-                    throw new Exception("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
+                    throw Oops.Bah("鍙栨牱鎬绘嫞璐ф暟閲忓ぇ浜庤楠屽崟鍙栨牱鏁伴噺");
                 }
                 //鍒ゆ柇绠变腑鏄惁鍚湁鏀爜锛屾湁锛氫笉璁╂嫞鏁伴噺
                 if (stockDetail.Qty - stockDetail.LockQty - stockDetail.FrozenQty < qty)
                 {
-                    throw new Exception("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
+                    throw Oops.Bah("鎵樼洏涓婂彲鐢ㄦ暟閲忓皬浜庡彇鏍锋暟閲忥紝璇锋牳瀹為攣瀹氥�佸喕缁撴暟閲�");
                 }
 
 
@@ -4047,25 +3946,25 @@
 
                 #region 娣诲姞鎴栦慨鏀瑰彇鏍锋槑缁�
 
-                Db.BeginTran();     
+                Db.BeginTran();
 
                 //if (isAddSampld) //娣诲姞鍙栨牱鏄庣粏
                 //{
-                    var sampleDetail = new BllSamplingDetails()
-                    {
-                        QcNo = qcNo,
-                        ASNNo = inspecd.ASNNo,
-                        PalletNo = palletNo,
-                        SkuNo = stockDetail.SkuNo,
-                        SkuName = stockDetail.SkuName,
-                        Standard = stockDetail.Standard,
-                        LotNo = stockDetail.LotNo,
-                        SupplierLot = stockDetail.SupplierLot,
-                        CompleteQty = qty,
-                        CreateTime = DateTime.Now,
-                        CreateUser = userId
-                    };
-                    Db.Insertable(sampleDetail).ExecuteCommand();
+                var sampleDetail = new BllSamplingDetails()
+                {
+                    QcNo = qcNo,
+                    ASNNo = inspecd.ASNNo,
+                    PalletNo = palletNo,
+                    SkuNo = stockDetail.SkuNo,
+                    SkuName = stockDetail.SkuName,
+                    Standard = stockDetail.Standard,
+                    LotNo = stockDetail.LotNo,
+                    SupplierLot = stockDetail.SupplierLot,
+                    CompleteQty = qty,
+                    CreateTime = DateTime.Now,
+                    CreateUser = userId
+                };
+                await Db.Insertable(sampleDetail).ExecuteCommandAsync();
                 //}
                 //else
                 //{
@@ -4084,24 +3983,24 @@
                 stockDetail.Qty -= qty;
                 if (stockDetail.Qty == 0)
                 {
-                    Db.Deleteable(stockDetail).ExecuteCommand();
+                    await Db.Deleteable(stockDetail).ExecuteCommandAsync();
                 }
                 else
                 {
                     stockDetail.BitPalletMark = "1";
                     stockDetail.InspectMark = "1";
 
-                    Db.Updateable(stockDetail).ExecuteCommand();
+                    await Db.Updateable(stockDetail).ExecuteCommandAsync();
                 }
                 //搴撳瓨鎬昏〃
                 stock.Qty -= qty;
                 if (stock.Qty == 0)
                 {
-                    Db.Deleteable(stock).ExecuteCommand();
+                    await Db.Deleteable(stock).ExecuteCommandAsync();
                 }
                 else
                 {
-                    Db.Updateable(stock).ExecuteCommand();
+                    await Db.Updateable(stock).ExecuteCommandAsync();
                 }
 
                 #endregion
@@ -4111,12 +4010,12 @@
                 //涓嶆槸涓婁紶瀹屾瘯鐨勪慨鏀瑰彇鏍风姸鎬�
                 if (notice.Status != "4")
                 {
-                    var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
+                    var noticeDetail = await Db.Queryable<BllArrivalNoticeDetail>().FirstAsync(m => m.IsDel == "0" && m.ASNNo == inspecd.ASNNo && m.SkuNo == inspecd.SkuNo && m.LotNo == inspecd.LotNo);
                     if (noticeDetail.IsSampling == "0")
                     {
                         noticeDetail.IsSampling = "1";
 
-                        Db.Updateable(noticeDetail).ExecuteCommand();
+                        await Db.Updateable(noticeDetail).ExecuteCommandAsync();
                     }
 
                 }
@@ -4131,9 +4030,9 @@
                 {
                     inspecd.Status = "3";
                 }
-                Db.Updateable(inspecd).ExecuteCommand();
+                await Db.Updateable(inspecd).ExecuteCommandAsync();
                 #endregion
-                 
+
 
 
                 //娣诲姞鎿嶄綔鏃ュ織璁板綍
@@ -4143,7 +4042,6 @@
             catch (Exception e)
             {
                 Db.RollbackTran();
-                throw new Exception(e.Message);
             }
         }
 
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/BllSoServer/ExportNoticeServer.cs b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
index e746979..230ca96 100644
--- a/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
+++ b/Wms/WMS.BLL/BllSoServer/ExportNoticeServer.cs
@@ -4319,8 +4319,10 @@
                 foreach (var item in noticeDetail)
                 {
                     //楠岃瘉鍏堣繘鍏堝嚭鍘熷垯
-                    
-                    var forData = data.Where(m => m.SkuNo == item.SkuNo && m.LotNo != item.LotNo && (m.Qty - m.FrozenQty - m.LockQty) > 0 && dataDetail.Contains(m.LotNo)).Select(m=>m.LotNo).ToList(); //鑾峰彇褰撳墠鐗╂枡鐨勬墍鏈夋壒娆′俊鎭�(鎺掗櫎鍗曟嵁鐨勬壒娆★紝闃叉鍗曟嵁鎵�鍦ㄦ壒娆¢攣瀹氭暟閲忓悗楠岃瘉灏忎簬绛変簬0)
+                    //鑾峰彇褰撳墠鐗╂枡鐨勬墍鏈夋壒娆′俊鎭�(鎺掗櫎鍗曟嵁鐨勬壒娆★紝闃叉鍗曟嵁鎵�鍦ㄦ壒娆¢攣瀹氭暟閲忓悗楠岃瘉灏忎簬绛変簬0)
+                    var forData = data.Where(m => m.SkuNo == item.SkuNo 
+                    && m.LotNo != item.LotNo && (m.Qty - m.FrozenQty - m.LockQty) > 0 
+                    && dataDetail.Contains(m.LotNo)).Select(m=>m.LotNo).ToList(); 
 
                     forData.Add(item.LotNo);  //闆嗗悎娣诲姞鍗曟嵁鐨勬壒娆�
                     //鑾峰彇鎺掑簭鍚庣殑绗竴涓壒娆�
@@ -4333,15 +4335,37 @@
 
                     //楠岃瘉鏁堟湡浼樺厛鍘熷垯
                     var forDataBox = dataBoxInfo.Where(m => m.SkuNo == item.SkuNo && m.LotNo != item.LotNo && m.Qty > 0).ToList();
-                    var expirationTime = dataBoxInfo.Where(m => m.SkuNo == item.SkuNo && m.LotNo == item.LotNo && m.Qty > 0).OrderBy(m=>m.ExpirationTime).Select(m=>m.ExpirationTime).First();  //鑾峰彇褰撳墠鍗曟嵁鎵规鐨勬渶杩戞晥鏈�
-                    var num = forDataBox.Count(m => m.ExpirationTime > expirationTime); //鑾峰彇搴撳瓨涓叾瀹冩壒娆℃晥鏈熷ぇ浜庡綋鍓嶅崟鎹壒娆$殑鏁堟湡鏁伴噺
-                    //鍒ゆ柇鏄惁澶т簬0
-                    if (num>0)
+                    //鑾峰彇褰撳墠鍗曟嵁鎵规鐨勬渶杩戞晥鏈�
+                    var expirationTimedt = dataBoxInfo.Where(m => m.SkuNo == item.SkuNo
+                    && m.LotNo == item.LotNo && m.Qty > 0).ToList();
+                    if (expirationTimedt.Count > 0)
                     {
-                        bl = false;
-                        break;
+                        var expirationTime = expirationTimedt.OrderBy(m => m.ExpirationTime).Select(m => m.ExpirationTime).First();
+                        //鑾峰彇搴撳瓨涓叾瀹冩壒娆℃晥鏈熷ぇ浜庡綋鍓嶅崟鎹壒娆$殑鏁堟湡鏁伴噺
+                        var num = forDataBox.Count(m => m.ExpirationTime > expirationTime);
+                        //鍒ゆ柇鏄惁澶т簬0
+                        if (num > 0)
+                        {
+                            bl = false;
+                            break;
+                        }
                     }
+                    else 
+                    {
+                        var dataDetailtime = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.InspectStatus == "1").
+                            Where(m => m.SkuNo == item.SkuNo
+                            && m.LotNo == item.LotNo && m.Qty > 0)
+                            .OrderBy(m => m.ExpirationTime)
+                            .Select(m => m.ExpirationTime).First();
 
+                        var num = forDataBox.Count(m => m.ExpirationTime > dataDetailtime);
+                        //鍒ゆ柇鏄惁澶т簬0
+                        if (num > 0)
+                        {
+                            bl = false;
+                            break;
+                        }
+                    }
                 }
 
 
@@ -4380,7 +4404,6 @@
 
                 var exAllotList = new List<BllExportAllot>();
                 var assign = new AllotSku();
-                var specialSku = new List<string>();//鐗规畩鐗╂枡闆嗗悎锛屾棤闇�鎵樼洏涓婂叏閮ㄥ垎閰嶇殑
                 Db.BeginTran();
                 try
                 {
@@ -4428,12 +4451,6 @@
                         {
                             stockDetail = stockDetail.Where(m => m.InspectStatus == "2").ToList();
                         }
-                        if (notice.Type == "1" && !specialSku.Contains(detail.SkuNo))
-                        {
-                            //鍒嗛厤鏁翠釜鎵樼洏涓婄殑鐗╂枡 鍙煡璇㈡湭鍒嗛厤鐨勬墭鐩�
-                            stockDetail = stockDetail.Where(m => m.Status == "0").ToList();
-                           
-                        }
                         if (stockDetail.Sum(m=>m.Qty-m.LockQty) < needQty)
                         {
                             throw new Exception("搴撳瓨鏄庣粏鏁伴噺涓嶈冻");
@@ -4451,16 +4468,7 @@
                         Dictionary<int, decimal> stockQtyDic = new Dictionary<int, decimal>();//鎵樺嚭搴撶墿鍝佹暟
                         var qty = 0m;
                         //鍒嗛厤璐х墿
-                        if (notice.Type == "1" && !specialSku.Contains(detail.SkuNo))//鍒ゆ柇鏄惁鏈鏂欏嚭搴�
-                        {
-                            //鍒嗛厤鍥涙ゼ澶囨枡鎶曟枡鐨勭墿鏂�
-                            qty += assign.LingLiaoAllotPallets(stockDetail, needQty, pNum, bNum, stockQtyDic);
-                        }
-                        else
-                        {
-                            qty += assign.AllotPallets(stockDetail, needQty, pNum, bNum, stockQtyDic);
-                        }
-                        
+                        qty += assign.AllotPallets(stockDetail, needQty, pNum, bNum, stockQtyDic, detail.LotNo, detail.IsMixBox);
                         foreach (var sc in stockQtyDic)
                         {
                             var s = stockDetail.FirstOrDefault(m => m.Id == sc.Key);
@@ -4518,7 +4526,9 @@
                         if (qty > detail.Qty)
                         {
                             //搴撳瓨鎬昏〃
-                            var stock = Db.Queryable<DataStock>().First(d => d.IsDel == "0" && d.SkuNo == detail.SkuNo && d.LotNo == detail.LotNo);
+                            var stock = Db.Queryable<DataStock>().First(d => d.IsDel == "0" 
+                            && d.SkuNo == detail.SkuNo 
+                            && d.LotNo == detail.LotNo);
                             stock.LockQty += qty-detail.Qty;
                             Db.Updateable(stock).ExecuteCommand();
 
@@ -4579,7 +4589,8 @@
                     var zd = Db.Updateable(notice).ExecuteCommand();
 
                     //娣诲姞鎿嶄綔鏃ュ織璁板綍
-                    var k = new OperationSOServer().AddLogOperationSo("鍑哄簱浣滀笟", "鍑哄簱鍗曟嵁", notice.SONo, "鍒嗛厤", $"鑷姩鍒嗛厤浜嗗崟鎹彿涓簕notice.SONo}鐨勫崟鎹俊鎭�", userId);
+                    var k = new OperationSOServer().AddLogOperationSo("鍑哄簱浣滀笟", "鍑哄簱鍗曟嵁", 
+                        notice.SONo, "鍒嗛厤", $"鑷姩鍒嗛厤浜嗗崟鎹彿涓簕notice.SONo}鐨勫崟鎹俊鎭�", userId);
 
                     if (zd > 0 && mx > 0 && fp > 0 && k)
                     {
diff --git a/Wms/WMS.BLL/BllSoServer/WaveMageServer.cs b/Wms/WMS.BLL/BllSoServer/WaveMageServer.cs
index 88419dd..393fd6d 100644
--- a/Wms/WMS.BLL/BllSoServer/WaveMageServer.cs
+++ b/Wms/WMS.BLL/BllSoServer/WaveMageServer.cs
@@ -480,7 +480,7 @@
                         Dictionary<string, int> zxQtyDic = new Dictionary<string, int>();//鎵樺嚭鏁寸鏁�
                         //鍒嗛厤璐х墿
                         //assign.AllocatePallets(stocks, pNum, bNum, needQty, stockQtyDic, zxQtyDic);
-                        var qty = assign.AllotPallets(stockDetail, decimal.Parse(needQty.ToString()), pNum, bNum, stockQtyDic);
+                        var qty = assign.AllotPallets(stockDetail, decimal.Parse(needQty.ToString()), pNum, bNum, stockQtyDic, detail.LotNo, detail.IsMixBox);
                        
                         foreach (var sc in stockQtyDic)
                         {
diff --git a/Wms/WMS.BLL/Logic/AllotSku.cs b/Wms/WMS.BLL/Logic/AllotSku.cs
index a995732..03ae06d 100644
--- a/Wms/WMS.BLL/Logic/AllotSku.cs
+++ b/Wms/WMS.BLL/Logic/AllotSku.cs
@@ -20,8 +20,10 @@
         /// <param name="fullPalletQty">婊℃墭鏁伴噺</param>
         /// <param name="fullBoxQty">婊$鏁伴噺</param>
         /// <param name="stockQtyDic">鎵樺嚭搴撶墿鍝佹暟 key:搴撳瓨鎵樼洏琛ㄧ殑ID銆乿al:鎵樼洏涓婄殑鏁伴噺</param>
+        /// <param name="lotNo">鎵规</param>
+        /// <param name="isMixBox">鏄惁鎺ュ彈鎷肩 0锛氬惁  1锛氭槸</param>
         /// <returns></returns>
-        public decimal AllotPallets(List<DataStockDetail> palletList, decimal needQty, int fullPalletQty, int fullBoxQty, Dictionary<int, decimal> stockQtyDic)
+        public decimal AllotPallets(List<DataStockDetail> palletList, decimal needQty, int fullPalletQty, int fullBoxQty, Dictionary<int, decimal> stockQtyDic,string lotNo,string isMixBox)
         {
             //浼樺厛鍏堣繘鍏堝嚭锛堝揩杩囨湡鐨勫厛鍑猴級
             //浼樺厛闆剁銆侀浂鎵橈紙鍑哄畬闆剁鍑烘暣绠憋級
@@ -84,8 +86,6 @@
                 {
                     var ztNum = needQty / fullPalletQty;//闇�瑕佹暣鎵樻暟
 
-                   
-
                     var zps = list.Where(s => s.Qty >= fullPalletQty).ToList();//鏁存墭
                     var sps = list.Where(s => s.Qty < fullPalletQty).ToList();//鏁f墭(鏈夊彲鑳芥槸琚攣瀹氫簡鏁伴噺鐨�) 
 
@@ -96,7 +96,14 @@
                                                                                                                           //鏁f墭
                         foreach (var s in st)
                         {
-                            var detailQty = decimal.Parse((s.Qty - s.LockQty - s.FrozenQty).ToString());
+                            decimal otherLotQty = 0;//娣风涓叾浠栨壒娆℃暟閲�
+                            //涓嶆帴鍙楁嫾绠�
+                            if (isMixBox == "0")
+                            {
+                                //鏌ユ壘鍑烘贩绠遍泦鍚�
+                                otherLotQty = GetMixBoxQty(s.Id, lotNo);
+                            }
+                            var detailQty = decimal.Parse((s.Qty - s.LockQty - s.FrozenQty - otherLotQty).ToString());
                             if (needQty - qty < detailQty)
                             {
                                 var num = needQty - qty;
@@ -119,7 +126,14 @@
                             var zt = zps.OrderBy(s => s.ExpirationTime).ToList();//鎵�鏈夋湭浣跨敤鐨勬墭鐩橈紙鏈鍒嗛厤鐨勶級
                             foreach (var ss in zt)
                             {
-                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty).ToString());
+                                decimal otherLotQty = 0;//娣风涓叾浠栨壒娆℃暟閲�
+                                //涓嶆帴鍙楁嫾绠�
+                                if (isMixBox == "0")
+                                {
+                                    //鏌ユ壘鍑烘贩绠遍泦鍚�
+                                    otherLotQty = GetMixBoxQty(ss.Id, lotNo);
+                                }
+                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty - otherLotQty).ToString());
                                 if (needQty - qty < detailQty)
                                 {
                                     var num = needQty - qty;
@@ -135,10 +149,7 @@
                                     break;
                                 }
                             }
-
-
                         }
-
                     }
                     else if (allotSet == 1)//浼樺厛鏁存墭锛堝垎閰嶅悎閫傜殑鏁存墭鏁伴噺锛�
                     {
@@ -153,7 +164,14 @@
                             var zt = zps.OrderBy(s => s.ExpirationTime).ToList();//鎵�鏈夋湭浣跨敤鐨勬墭鐩橈紙鏈鍒嗛厤鐨勶級
                             foreach (var ss in zt)
                             {
-                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty).ToString());
+                                decimal otherLotQty = 0;//娣风涓叾浠栨壒娆℃暟閲�
+                                //涓嶆帴鍙楁嫾绠�
+                                if (isMixBox == "0")
+                                {
+                                    //鏌ユ壘鍑烘贩绠遍泦鍚�
+                                    otherLotQty = GetMixBoxQty(ss.Id, lotNo);
+                                }
+                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty - otherLotQty).ToString());
                                 if (needQty - qty < detailQty)
                                 {
                                     break;
@@ -174,7 +192,14 @@
 
                             foreach (var ss in zt)
                             {
-                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty).ToString());
+                                decimal otherLotQty = 0;//娣风涓叾浠栨壒娆℃暟閲�
+                                //涓嶆帴鍙楁嫾绠�
+                                if (isMixBox == "0")
+                                {
+                                    //鏌ユ壘鍑烘贩绠遍泦鍚�
+                                    otherLotQty = GetMixBoxQty(ss.Id, lotNo);
+                                }
+                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty - otherLotQty).ToString());
                                 if (needQty - qty < detailQty)
                                 {
                                     var num = needQty - qty;
@@ -197,7 +222,14 @@
                             var zt = zps.Where(s => !sIds.Contains(s.Id)).OrderBy(s => s.ExpirationTime).ThenBy(m => m.Qty - m.LockQty - m.FrozenQty).ToList();//鎵�鏈夋湭浣跨敤锛堟湭琚垎閰嶇殑锛�
                             foreach (var ss in zt)
                             {
-                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty).ToString());
+                                decimal otherLotQty = 0;//娣风涓叾浠栨壒娆℃暟閲�
+                                //涓嶆帴鍙楁嫾绠�
+                                if (isMixBox == "0")
+                                {
+                                    //鏌ユ壘鍑烘贩绠遍泦鍚�
+                                    otherLotQty = GetMixBoxQty(ss.Id, lotNo);
+                                }
+                                var detailQty = decimal.Parse((ss.Qty - ss.LockQty - ss.FrozenQty - otherLotQty).ToString());
                                 if (needQty - qty < detailQty)
                                 {
                                     var num = needQty - qty;
@@ -213,7 +245,6 @@
                                 }
                             }
                         }
-
                     }
                 }
                 
@@ -229,6 +260,28 @@
                 throw new Exception("鍒嗛厤鍑哄簱鐗╂枡澶辫触锛�" + e.Message);
             }
 
+        }
+        /// <summary>
+        /// 鏌ユ壘鍑烘贩绠变腑鍏朵粬鎵规鎬绘暟閲�
+        /// </summary>
+        /// <param name="stockDetailId"></param>
+        /// <param name="lotNo"></param>
+        /// <returns></returns>
+        private decimal GetMixBoxQty(int stockDetailId,string lotNo)
+        {
+            var contextDb = DataContext.Db;
+            //鏌ユ壘鍑烘贩绠遍泦鍚�
+            List<string> mixBoxList = contextDb.Queryable<DataBoxInfo>()
+                .Where(w => w.IsDel == "0" && w.StockDetailId == stockDetailId)
+                .GroupBy(g => g.LotNo)
+                .Having(h => SqlFunc.AggregateCount(h.LotNo) > 1)
+                .Select(s => s.BoxNo).ToList();
+
+            decimal otherLotQty = contextDb.Queryable<DataBoxInfo>()
+                .Where(w => w.IsDel == "0" && w.StockDetailId == stockDetailId && mixBoxList.Contains(w.BoxNo) && w.LotNo != lotNo)
+                .Sum(s => s.Qty);
+
+            return otherLotQty;
         }
 
         /// <summary>
@@ -869,12 +922,13 @@
                 //绔嬪簱鍐呮墭鐩�
                 var detail3 = list.Where(m => m.WareHouseNo == "W01").ToList();
 
-                foreach (var item in detail2)
-                {
-                    var dept = item.LocatNo.Substring(5,2);
+                // 骞冲簱鍌ㄤ綅缂栫爜瑙勫垯纭鍚庯紝鏍规嵁瀹為檯瑙勫垯鍙栨繁搴�
+                //foreach (var item in detail2)
+                //{
+                //    var dept = item.LocatNo.Substring(5,2);
 
-                    item.Dept = int.Parse(dept);
-                }
+                //    item.Dept = int.Parse(dept);
+                //}
                 foreach (var item in detail3)
                 {
                     var dept = item.LocatNo.Substring(6, 2);
@@ -882,27 +936,27 @@
                     item.Dept = int.Parse(dept);
                 }
                 //骞冲簱
-                var locate1 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W02");
-                var data2 = new List<StockDetailDto>();
-                foreach (var pingku in detail2.OrderByDescending(a => a.PalletTags).ThenBy(m => m.Dept).ToList())
-                {
-                    if (data2.Contains(pingku))
-                    {
-                        continue;
-                    }
+                //var locate1 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W02");
+                //var data2 = new List<StockDetailDto>();
+                //foreach (var pingku in detail2.OrderByDescending(a => a.PalletTags).ThenBy(m => m.Dept).ToList())
+                //{
+                //    if (data2.Contains(pingku))
+                //    {
+                //        continue;
+                //    }
                     
-                    var currentLocate = locate1.First(m => m.LocatNo == pingku.LocatNo);
-                    var locateAfter = locate1.Where(m => m.AreaNo == currentLocate.AreaNo && m.Layer == currentLocate.Layer && m.Row == currentLocate.Row && int.Parse(m.Depth) < int.Parse(currentLocate.Depth)).OrderBy(m => m.Depth).ToList();
-                    foreach (var locat in locateAfter)
-                    {
-                        if (detail2.Any(m => m.LocatNo == locat.LocatNo) && !data2.Contains(detail2.First(m => m.LocatNo == locat.LocatNo)))
-                        {
-                            data2.Add(detail2.First(m => m.LocatNo == locat.LocatNo));
-                        }
+                //    var currentLocate = locate1.First(m => m.LocatNo == pingku.LocatNo);
+                //    var locateAfter = locate1.Where(m => m.AreaNo == currentLocate.AreaNo && m.Layer == currentLocate.Layer && m.Row == currentLocate.Row && int.Parse(m.Depth) < int.Parse(currentLocate.Depth)).OrderBy(m => m.Depth).ToList();
+                //    foreach (var locat in locateAfter)
+                //    {
+                //        if (detail2.Any(m => m.LocatNo == locat.LocatNo) && !data2.Contains(detail2.First(m => m.LocatNo == locat.LocatNo)))
+                //        {
+                //            data2.Add(detail2.First(m => m.LocatNo == locat.LocatNo));
+                //        }
 
-                    }
-                    data2.Add(pingku);
-                }
+                //    }
+                //    data2.Add(pingku);
+                //}
 
                 //绔嬪簱
                 var locate2 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W01").ToList();
@@ -928,9 +982,9 @@
                 }
 
 
-                data.AddRange(detail1);
-                data.AddRange(data2);
-                data.AddRange(data3);
+                data.AddRange(detail1);             // 搴撳
+                data.AddRange(detail2);             // 骞冲簱
+                data.AddRange(data3);               // 绔嬪簱
 
                 return data;
             }
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.DAL/SysInfrastructure/StorageLocatRepository.cs b/Wms/WMS.DAL/SysInfrastructure/StorageLocatRepository.cs
index 54503c3..92fb59a 100644
--- a/Wms/WMS.DAL/SysInfrastructure/StorageLocatRepository.cs
+++ b/Wms/WMS.DAL/SysInfrastructure/StorageLocatRepository.cs
@@ -93,23 +93,23 @@
                     outDtoList.Add(locatEntry2);
 
                     // 姝e紡杩愯绋嬪簭鏀惧紑
-                    var jsonData = JsonConvert.SerializeObject(outDtoList);
-                    string response = "";
+                    //var jsonData = JsonConvert.SerializeObject(outDtoList);
+                    //string response = "";
 
-                    try
-                    {
-                        response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍚屾鍌ㄤ綅淇℃伅", "WCS");
-                        //瑙f瀽杩斿洖鏁版嵁 
-                        var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
-                        if (wcsModel.StatusCode == -1)
-                        {
-                            throw new Exception(wcsModel.Msg);
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        throw new Exception(ex.Message);
-                    }
+                    //try
+                    //{
+                    //    response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍚屾鍌ㄤ綅淇℃伅", "WCS");
+                    //    //瑙f瀽杩斿洖鏁版嵁 
+                    //    var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
+                    //    if (wcsModel.StatusCode == -1)
+                    //    {
+                    //        throw new Exception(wcsModel.Msg);
+                    //    }
+                    //}
+                    //catch (Exception ex)
+                    //{
+                    //    throw new Exception(ex.Message);
+                    //}
                 }
 
                 Db.CommitTran();
@@ -195,23 +195,23 @@
                 if (i > 0)
                 {
                     // 姝e紡杩愯绋嬪簭鏀惧紑
-                    var jsonData = JsonConvert.SerializeObject(outDtoList);
-                    string response = "";
+                    //var jsonData = JsonConvert.SerializeObject(outDtoList);
+                    //string response = "";
 
-                    try
-                    {
-                        response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
-                        //瑙f瀽杩斿洖鏁版嵁 
-                        var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
-                        if (wcsModel.StatusCode == -1)
-                        {
-                            throw new Exception(wcsModel.Msg);
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        throw new Exception(ex.Message);
-                    }
+                    //try
+                    //{
+                    //    response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橶CS鍑哄簱鍛戒护", "WCS");
+                    //    //瑙f瀽杩斿洖鏁版嵁 
+                    //    var wcsModel = JsonConvert.DeserializeObject<WcsModel>(response);
+                    //    if (wcsModel.StatusCode == -1)
+                    //    {
+                    //        throw new Exception(wcsModel.Msg);
+                    //    }
+                    //}
+                    //catch (Exception ex)
+                    //{
+                    //    throw new Exception(ex.Message);
+                    //}
                 }
                 Db.CommitTran();
                 return i > 0;
diff --git a/Wms/WMS.Entity/BllAsnEntity/BllPalletUpShelf.cs b/Wms/WMS.Entity/BllAsnEntity/BllPalletUpShelf.cs
new file mode 100644
index 0000000..bb7459c
--- /dev/null
+++ b/Wms/WMS.Entity/BllAsnEntity/BllPalletUpShelf.cs
@@ -0,0 +1,63 @@
+锘縰sing SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace WMS.Entity.BllAsnEntity
+{
+    /// <summary>
+    /// 鎵樼洏涓婃灦璁板綍
+    /// </summary>
+    [SugarTable("BllPalletUpShelf")]
+    public class BllPalletUpShelf:BaseEntity
+    {
+        /// <summary>
+        /// 杩芥函鍙�  --鍏ュ簱鍗曞彿
+        /// </summary>
+        public string TraceNo { get; set; }
+
+        /// <summary>
+        /// 浠诲姟鍙�
+        /// </summary>
+        public string TaskNo { get; set; }
+        /// <summary>
+        /// 鎵樼洏鍙�
+        /// </summary>
+        public string PalletNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡缂栫爜
+        /// </summary>
+        public string SkuNo { get; set; }
+        /// <summary>
+        /// 鐗╂枡鍚嶇О
+        /// </summary>
+        public string SkuName { get; set; }
+        /// <summary>
+        /// 鎵规鍙�
+        /// </summary>
+        public string LotNo { get; set; }
+        /// <summary>
+        /// 鐘舵��
+        /// </summary>
+        public string Status { get; set; }
+
+        /// <summary>
+        /// 浠撳簱
+        /// </summary>
+        public string WareHouseNo { get; set; }
+        /// <summary>
+        /// 宸烽亾
+        /// </summary>
+        public string RoadwayNo { get; set; }
+        /// <summary>
+        /// 鍖哄煙
+        /// </summary>
+        public string AreaNo { get; set; }
+        /// <summary>
+        /// 鍌ㄤ綅
+        /// </summary>
+        public string LocatNo { get; set; }
+
+    }
+}
diff --git a/Wms/WMS.IBLL/IBllAsnServer/IPalletUpShelfServer.cs b/Wms/WMS.IBLL/IBllAsnServer/IPalletUpShelfServer.cs
new file mode 100644
index 0000000..8a96940
--- /dev/null
+++ b/Wms/WMS.IBLL/IBllAsnServer/IPalletUpShelfServer.cs
@@ -0,0 +1,41 @@
+锘縰sing Model.ModelDto;
+using Model.ModelDto.BllAsnDto;
+using Model.ModelDto.SysDto;
+using Model.ModelVm;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using System.Threading.Tasks;
+using WMS.Entity.BllAsnEntity;
+
+namespace WMS.IBLL.IBllAsnServer
+{
+    public interface IPalletUpShelfServer
+    {
+        /// <summary>
+        /// 鑾峰彇涓婃灦浠诲姟璁板綍淇℃伅
+        /// </summary>
+        /// <param name="traceNo">杩芥函鍙�--鍏ュ簱鍗曞彿</param>
+        /// <param name="taskNo">浠诲姟鍙�</param>
+        /// <param name="palletNo">鎵樼洏鍙�</param>
+        /// <param name="skuNo">鐗╂枡鍙�</param>
+        /// <param name="skuName"></param>
+        /// <param name="lotNo"></param>
+        /// <param name="status"></param>
+        /// <param name="page"></param>
+        /// <param name="limit"></param>
+        /// <param name="count"></param>
+        /// <returns></returns>
+        Task<List<PalletUpShelfDto>> GetPalletUpShelfList(string traceNo, string taskNo, string palletNo, string skuNo, string skuName,string lotNo,string status, int page, int limit, RefAsync<int> count);
+        
+
+
+
+
+
+
+
+    }
+}
diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
index a032bf4..702e76c 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
@@ -51,7 +51,21 @@
         void BindPalletByJc23(PdaPalletBindVm model, int userId, string origin);
 
         //JC23缁戝畾鐗╂枡鎵樼洏鍗冲鍔犲簱瀛�
-        public void BindPalletStock(PdaPalletBindVm model, int userId, string origin);
+        void BindPalletStock(PdaPalletBindVm model, int userId, string origin);
+
+        ///// <summary>
+        ///// JC26缁戝畾鎵樼洏 璐存爣鐗╂枡
+        ///// </summary>
+        ///// <param name="model"></param>
+        ///// <param name="userId"></param>
+        void BindPalletPasteCode(PdaPalletBindVm model, int userId);
+
+        /// <summary>
+        /// JC26缁戝畾鎵樼洏 涓嶈创鏍囩墿鏂�
+        /// </summary>
+        /// <param name="model"></param>
+        /// <param name="userId"></param>
+        void BindPalletNoPasteCode(PdaPalletBindVm model, int userId);
 
         // 缁戝畾绌烘墭鐩�
         string BindNullPallet(PalletBindVm model);
diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
index 572ea51..2a0e958 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaCrServer.cs
@@ -1,6 +1,7 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Text;
+using System.Threading.Tasks;
 using Model.ModelDto.BllCheckDto;
 using Model.ModelDto.PdaDto;
 using WMS.Entity.DataEntity;
@@ -17,7 +18,7 @@
         /// </summary>
         /// <param name="palletNo">鎵樼洏鐮�</param>
         /// <returns></returns>
-        List<string> GetStockCheckNoList(string palletNo);
+        Task<List<string>> GetStockCheckNoList(string palletNo);
 
         /// <summary>
         /// 鑾峰彇鐩樼偣鏄庣粏
@@ -25,7 +26,7 @@
         /// <param name="crNo">鍗曟嵁鍙�</param>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
-        List<StockCheckDetailDto> GetStockCheckDetailList(string crNo,string palletNo);
+        Task<List<StockCheckDetailDto>> GetStockCheckDetailList(string crNo,string palletNo);
 
         /// <summary>
         /// 鑾峰彇瑕佺洏鐐圭殑绠辩爜淇℃伅锛堢洏鐐硅褰曚腑鏁版嵁锛�
@@ -36,7 +37,7 @@
         /// <param name="boxNo">绠辩爜鍙�</param>
         /// <param name="isContinue">鏄惁鏁伴噺鐩樼偣</param>
         /// <returns></returns>
-        List<StockCheckLogDto> GetStockCheckLogList(string crNo, string crDetail,string palletNo,string boxNo,string isContinue);
+        Task<List<StockCheckLogDto>> GetStockCheckLogList(string crNo, string crDetail,string palletNo,string boxNo,string isContinue);
 
         /// <summary>
         /// 鐩樼偣搴撳瓨
@@ -50,7 +51,7 @@
         /// <param name="qty">鏁伴噺</param>
         /// <param name="isContinue">鏄惁鏁伴噺鐩樼偣</param>
         /// <param name="userId"></param>
-        void CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo,string boxNo3,string result, decimal? qty,string isContinue, int userId);
+        Task CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo,string boxNo3,string result, decimal? qty,string isContinue, int userId);
 
         #endregion
 
@@ -62,7 +63,7 @@
         /// <param name="locatNo">鍌ㄤ綅缂栧彿</param>
         /// <param name="palletNo">鎵樼洏鍙�</param> 
         /// <returns></returns>
-        List<DataStockDetail> GetStockQueryList(string locatNo, string palletNo);
+        Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo);
 
         #endregion
 
@@ -73,14 +74,14 @@
         /// </summary>
         /// <param name="palletNo">鍘熸墭鐩�</param>
         /// <returns></returns>
-        List<PdaPalletNoCheckDto> GetDataDetailList(string palletNo);
+        Task<List<PdaPalletNoCheckDto>> GetDataDetailList(string palletNo);
 
         /// <summary>
         /// 鏍规嵁绠辩爜鑾峰彇鐗╂枡銆佹壒娆°�佹暟閲忕瓑淇℃伅
         /// </summary>
         /// <param name="boxNo">绠辩爜</param>
         /// <returns></returns>
-        PdaPalletNoCheckDto GetBoxInfoByBox(string boxNo);
+        Task<PdaPalletNoCheckDto> GetBoxInfoByBox(string boxNo);
 
         /// <summary>
         /// 瑙g粦鍘熸墭鐩樼粦瀹氭柊鎵樼洏
@@ -89,7 +90,7 @@
         /// <param name="boxNo">绠辩爜</param>
         /// <param name="palletNoNew">鏂版墭鐩�</param>
         /// <param name="userId">鎿嶄綔浜�</param>
-        void SaveUnbind(string palletNo, string boxNo, string palletNoNew, int userId);
+        Task SaveUnbind(string palletNo, string boxNo, string palletNoNew, int userId);
 
         #endregion
 
@@ -99,37 +100,37 @@
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        string GetPalletLocatNo(string palletNo);
+        Task<string> GetPalletLocatNo(string palletNo);
         /// <summary>
         /// 鑾峰彇鎵樼洏鎵�鍦ㄦゼ灞傛墍鏈夊尯鍩�
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        List<SysStorageArea> GetStorageArea(string palletNo);
+        Task<List<SysStorageArea>> GetStorageArea(string palletNo);
         /// <summary>
         /// 鑾峰彇宸插垎閰嶇殑鍑哄簱鍗曟嵁
         /// </summary>
         /// <returns></returns>
-        List<string> GetRunSoNoticeList();
+        Task<List<string>> GetRunSoNoticeList();
         /// <summary>
         /// 鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樹笂鐗╂枡淇℃伅
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns></returns>
-        List<DataStockDetail> GetSkuInfoByPalletNo(string palletNo);
+        Task<List<DataStockDetail>> GetSkuInfoByPalletNo(string palletNo);
         /// <summary>
         /// 鏍规嵁鍑哄簱鍗曞彿鑾峰彇鍒嗛厤鐨勬墭鐩樹俊鎭�
         /// </summary>
         /// <param name="soNo"></param>
         /// <returns></returns>
-        List<string> GetPalletNoListBySoNo(string soNo);
+        Task<List<string>> GetPalletNoListBySoNo(string soNo);
         /// <summary>
         /// agv杞繍鍛煎彨灏忚溅
         /// </summary>
         /// <param name="palletNo"></param>
         /// <param name="areaNo"></param>
         /// <param name="ruku"></param>
-        void AgvTransport(string palletNo, string areaNo, string ruku, int userId);
+        Task AgvTransport(string palletNo, string areaNo, string ruku, int userId);
         /// <summary>
         ///  agv杞繍鍛煎彨灏忚溅鍙栬揣
         /// </summary>
@@ -137,7 +138,17 @@
         /// <param name="palletNo"></param>
         /// <param name="areaNo"></param>
         /// <param name="userId"></param>
-        void AgvTransport2(string soNo, string palletNo, string areaNo, int userId);
+        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.IBLL/IPdaServer/IPdaSoServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaSoServer.cs
index 4de44c9..7d2dfe1 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaSoServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaSoServer.cs
@@ -1,8 +1,9 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Text;
+using System.Threading.Tasks;
 using Model.InterFaceModel;
-using Model.ModelDto; 
+using Model.ModelDto;
 using Model.ModelVm.PdaVm;
 
 namespace WMS.IBLL.IPdaServer
@@ -14,7 +15,7 @@
         /// </summary>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns>"":鍙娇鐢� -1:涓嶅彲浣跨敤锛堝師鍥�)</returns>
-        string IsEnableOkPalletNo(string palletNo);
+        Task<string> IsEnableOkPalletNo(string palletNo);
 
         /// <summary>
         /// 鑾峰彇鎵ц涓殑鍑哄簱鍗�(鏍规嵁鎵樼洏鐮�)
@@ -22,15 +23,15 @@
         /// <param name="palletNo">鎵樼洏鐮�</param>
         /// <param name="type">绫诲瀷 鍖哄垎鏄惁鏄钩搴撳嚭搴撹幏鍙栧崟鎹�</param>
         /// <returns></returns>
-        List<string> GetRunSoNoticeList(string palletNo, string type);
-        
+        Task<List<string>> GetRunSoNoticeList(string palletNo, string type);
+
         /// <summary>
         /// 鑾峰彇鍑哄簱鎵樼洏涓婄殑鐗╂枡鎵规(鏍规嵁鎵樼洏鐮�)
         /// </summary>
         /// <param name="palletNo">鎵樼洏鐮�</param>
         /// <param name="soNo">鍗曟嵁鍙�</param>
         /// <returns></returns>
-        List<DetailIdSkuLotNo> GetSoSkuLotNoListByPallet(string palletNo,string soNo);
+        Task<List<DetailIdSkuLotNo>> GetSoSkuLotNoListByPallet(string palletNo, string soNo);
 
         /// <summary>
         /// 鑾峰彇鍑哄簱鍙c�佽鏍笺�佸緟鎷e強宸叉嫞鏁伴噺锛堟牴鎹嚭搴撳崟鏄庣粏ID銆佹墭鐩樺彿锛�
@@ -38,14 +39,14 @@
         /// <param name="soDetailId">鍑哄簱鍗曟槑缁咺D</param>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
-        OutPdaInfo GetOutlets(string soDetailId, string palletNo);
+        Task<OutPdaInfo> GetOutlets(string soDetailId, string palletNo);
 
         /// <summary>
         /// 鑾峰彇鍑哄簱鍗曠殑璁″垝鏁伴噺鍜屽畬鎴�
         /// </summary>
         /// <param name="soDetailId">鍑哄簱鍗曟槑缁咺D</param>
         /// <returns></returns>
-        OutPdaInfo GetPlanAndFinishQty(string soDetailId);
+        Task<OutPdaInfo> GetPlanAndFinishQty(string soDetailId);
 
         /// <summary>
         /// 鑾峰彇绠辩爜淇℃伅锛堟牴鎹鐮佸湪搴撳瓨绠辩爜鏄庣粏涓煡璇級
@@ -55,7 +56,7 @@
         /// <param name="boxNo">绠辩爜</param>
         /// <param name="boxNo3">鏀�/琚嬬爜</param>
         /// <returns></returns>
-        List<BoxInfo> GetDataComBoxInfo(string soDetailId,string palletNo, string boxNo, string boxNo3);
+        Task<List<BoxInfo>> GetDataComBoxInfo(string soDetailId, string palletNo, string boxNo, string boxNo3);
 
         /// <summary>
         /// 鑾峰彇搴撳唴鏃犵鐮佺殑鎵樼洏鍒嗛厤淇℃伅
@@ -63,7 +64,7 @@
         /// <param name="soDetailId">鍑哄簱鍗曟槑缁咺D</param>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
-        List<BoxInfo> GetAllotPlnInfo(string soDetailId,string palletNo);
+        Task<List<BoxInfo>> GetAllotPlnInfo(string soDetailId, string palletNo);
 
         /// <summary>
         /// 鍑哄簱pda鎷h揣
@@ -75,7 +76,7 @@
         /// <param name="boxNo2">鐩掔爜</param>
         /// <param name="boxNo3">鏀�/琚嬬爜</param>
         /// <param name="userId">鎿嶄綔浜�</param>
-        void SoSetPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string PickQty, int userId);
+        Task SoSetPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string PickQty, int userId);
 
         /// <summary>
         /// 鍑哄簱pda鎷h揣
@@ -85,7 +86,7 @@
         /// <param name="palletNo">鎵樼洏鍙�</param> 
         /// <param name="PickQty">鎷h揣鏁伴噺</param>
         /// <param name="userId">鎿嶄綔浜�</param>
-        void SoSetQtyPick(string soNo, string soDetailId, string palletNo, string PickQty, int userId);
+        Task SoSetQtyPick(string soNo, string soDetailId, string palletNo, string PickQty, int userId);
 
         /// <summary>
         /// 涓嬪彂绌烘墭鍑哄簱
@@ -94,7 +95,7 @@
         /// <param name="userId">鍑哄簱鍙�</param>
         /// <param name="url">涓嬪彂璺緞</param>
         /// <returns></returns>
-        string IssuePlnOutHouse(OutModePalletVm model, int userId,string url);
+        Task<string> IssuePlnOutHouse(OutModePalletVm model, int userId, string url);
 
 
         /// <summary>
@@ -103,7 +104,7 @@
         /// <param name="soNo">鍑哄簱鍗曞彿</param>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
-        List<BoxInfo> GetPingKuInfoByPallet(string soNo, string palletNo);
+        Task<List<BoxInfo>> GetPingKuInfoByPallet(string soNo, string palletNo);
 
         /// <summary>
         /// 骞冲簱鍑哄簱瀹屾垚
@@ -113,21 +114,21 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <param name="userId">鎿嶄綔浜�</param>
         /// <returns></returns>
-        void PlaneExportSuccess(string soNo, string palletNo,int userId);
+        Task PlaneExportSuccess(string soNo, string palletNo, int userId);
 
         /// <summary>
         /// 鏍规嵁鎵樼洏鍙疯幏鍙栧彇鏍风被鍨� 
         /// </summary>
         /// <param name="palletNo"></param>
         /// <returns>0锛氬簱鍐呭彇鏍枫��1锛氬簱鍓嶅彇鏍�</returns>
-        string GetSampleType(string palletNo);
+        Task<string> GetSampleType(string palletNo);
 
         /// <summary>
         /// 鏍规嵁鎵樼洏鍙疯幏鍙栧叆搴撳崟鎹�(搴撳墠鍙栨牱鍑哄簱涓氬姟)
         /// </summary>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns>鍗曟嵁闆嗗悎</returns>
-        List<string> GetAsnNoByPallet(string palletNo);
+        Task<List<string>> GetAsnNoByPallet(string palletNo);
 
         /// <summary>
         /// 鍙栨牱鍑哄簱鎷h揣(鏍囩)
@@ -141,7 +142,7 @@
         /// <param name="pickQty1">鎷h揣鏁伴噺</param>
         /// <param name="asnNo">鍏ュ簱鍗�</param>
         /// <param name="userId">鎿嶄綔浜篒D</param>
-        void SampleSoSetPick(string soType, string soNo, string soDetailId, string palletNo, string boxNo,
+        Task SampleSoSetPick(string soType, string soNo, string soDetailId, string palletNo, string boxNo,
             string boxNo3, string pickQty1, string asnNo, int userId);
 
 
@@ -156,7 +157,7 @@
         /// <param name="boxNo3">鏀�/琚嬬爜</param>
         /// <param name="palletNo">鏂版墭鐩樺彿</param> 
         /// <param name="userId">鎿嶄綔浜�</param>
-        void SoSetPinPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string PickQty,string palletNoNew, int userId);
+        Task SoSetPinPick(string soNo, string soDetailId, string palletNo, string boxNo, string boxNo3, string PickQty, string palletNoNew, int userId);
         /// <summary>
         /// 鎷兼墭鍑哄簱pda鎷h揣-鏁伴噺
         /// </summary>
@@ -166,7 +167,7 @@
         /// <param name="PickQty"></param>
         /// <param name="palletNoNew"></param>
         /// <param name="userId"></param>
-        void SoSetQtyPinPick(string soNo, string soDetailId, string palletNo, string PickQty, string palletNoNew, int userId);
+        Task SoSetQtyPinPick(string soNo, string soDetailId, string palletNo, string PickQty, string palletNoNew, int userId);
         /// <summary>
         ///  鍙栨牱鍑哄簱鎷h揣(鏃犳爣绛�)
         /// </summary>
@@ -177,7 +178,7 @@
         /// <param name="PickQty">鎷h揣鏁伴噺</param>
         /// <param name="asnNo">鍏ュ簱鍗�</param>
         /// <param name="userId">鎿嶄綔浜篒D</param>
-        void SampleSoSetQtyPick(string soType, string soNo, string soDetailId, string palletNo, string PickQty,
+        Task SampleSoSetQtyPick(string soType, string soNo, string soDetailId, string palletNo, string PickQty,
             string asnNo, int userId);
 
 
@@ -188,18 +189,18 @@
         /// </summary>
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns>0:鏍囩鍙栨牱  1锛氭暟閲忓彇鏍�</returns>
-        string GetSampleType2(string palletNo);
+        Task<string> GetSampleType2(string palletNo);
         /// <summary>
         /// 鑾峰彇寰呭嚭搴撴垨寰呭彇鏍风殑璇烽獙鍗�
         /// </summary>
         /// <returns></returns>
-        List<string> GetInspectionNo();
+        Task<List<string>> GetInspectionNo();
         /// <summary>
         /// 鑾峰彇璇烽獙鍗曠浉鍏充俊鎭�
         /// </summary>
         /// <param name="qcNo">璇烽獙鍗�</param>
         /// <returns></returns>
-        InspectionRequestDto GetInspectionRequestInfo(string qcNo);
+        Task<InspectionRequestDto> GetInspectionRequestInfo(string qcNo);
 
         /// <summary>
         /// 鍙栨牱鍑哄簱鎷h揣(鏍囩)
@@ -210,7 +211,7 @@
         /// <param name="boxNo3">鏀爜</param>
         /// <param name="pickQty">鎷h揣鏁伴噺</param>
         /// <param name="userId"></param>
-        void SampleSetPick(string qcNo, string palletNo, string boxNo, string boxNo3, string pickQty, int userId);
+        Task SampleSetPick(string qcNo, string palletNo, string boxNo, string boxNo3, string pickQty, int userId);
 
         /// <summary>
         /// 鍙栨牱鍑哄簱鎷h揣(鏁伴噺)
@@ -219,7 +220,7 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <param name="pickQty">鎷h揣鏁伴噺</param>
         /// <param name="userId"></param>
-        void SampleSetQtyPick(string qcNo, string palletNo, string pickQty, int userId);
+        Task SampleSetQtyPick(string qcNo, string palletNo, string pickQty, int userId);
 
         #endregion
 
diff --git a/Wms/Wms/Controllers/BasisController.cs b/Wms/Wms/Controllers/BasisController.cs
index de100a9..0a43b54 100644
--- a/Wms/Wms/Controllers/BasisController.cs
+++ b/Wms/Wms/Controllers/BasisController.cs
@@ -325,7 +325,6 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        [ServiceFilter(typeof(ApiResponseActionFilter))]
         public async Task<List<FunctionMenuDto>> GetRBACLists(int id)
         {
             return await _rBACServer.GetMenuByroleIdNew(id);
@@ -1221,7 +1220,6 @@
         /// </summary>
         /// <returns></returns>
         [HttpPost]
-        [ServiceFilter(typeof(ApiResponseActionFilter))]
         public async Task<SqlSugarPagedList> GetSysOperationList(GetOperationVm model)
         {
             return await _operation.GetSysOperationList(model);
@@ -1233,7 +1231,6 @@
         /// <param name="dicName">瀛楀吀鍚嶇О</param>
         /// <returns></returns>
         [HttpGet]
-        [ServiceFilter(typeof(ApiResponseActionFilter))]
         public async Task<List<SysDictionary>> GetDicTypeList(string dicName)
         {
             return await _operation.GetDicTypeList(dicName);
diff --git a/Wms/Wms/Controllers/BllAsnController.cs b/Wms/Wms/Controllers/BllAsnController.cs
index d92a29a..c921231 100644
--- a/Wms/Wms/Controllers/BllAsnController.cs
+++ b/Wms/Wms/Controllers/BllAsnController.cs
@@ -14,13 +14,14 @@
 using System.Threading.Tasks;
 using SqlSugar;
 using System.Diagnostics;
+using Model.ModelDto.SysDto;
+using static System.Reflection.Metadata.BlobBuilder;
 
 namespace Wms.Controllers
 {
     [Route("api/[controller]/[action]")]
     [ApiController]
     [Authorize]
-
     public class BllAsnController : ControllerBase
     {
         #region 渚濊禆娉ㄥ叆
@@ -33,10 +34,11 @@
         private readonly IAuditLogServer _auditLog;                                 // 瀹℃牳璁板綍
         private readonly IBllLabelBoxNoServer _labelBox;                            // 绠辩爜鏍囩
         private readonly IProcurePlanServer _procurePlanSvc;                            // 绠辩爜鏍囩
+        private readonly IPalletUpShelfServer _palletUpShelfSvc;                            // 涓婃灦璁板綍
         #endregion
 
         #region 鏋勯�犲嚱鏁�
-        public BllAsnController(IArrivalNoticeServer arrivalNoticeSvc, IPalletBindServer palletBindSvc, IBllBoxInfoServer bllBoxInfoSvc, ITaskServer taskSvc, IOperationASNServer logSvc, IPalletUnbindServer palletUnbind, IAuditLogServer auditLog, IBllLabelBoxNoServer labelBox, IProcurePlanServer procurePlanSvc)
+        public BllAsnController(IArrivalNoticeServer arrivalNoticeSvc, IPalletBindServer palletBindSvc, IBllBoxInfoServer bllBoxInfoSvc, ITaskServer taskSvc, IOperationASNServer logSvc, IPalletUnbindServer palletUnbind, IAuditLogServer auditLog, IBllLabelBoxNoServer labelBox, IProcurePlanServer procurePlanSvc, IPalletUpShelfServer palletUpShelfSvc)
         {
             _arrivalNoticeSvc = arrivalNoticeSvc;
             _PalletBindSvc = palletBindSvc;
@@ -47,6 +49,7 @@
             _auditLog = auditLog;
             _labelBox = labelBox;
             _procurePlanSvc = procurePlanSvc;
+            _palletUpShelfSvc = palletUpShelfSvc;
         }
         #endregion
 
@@ -1257,6 +1260,23 @@
             }
         }
         #endregion
+
+        #region 涓婃灦浠诲姟璁板綍
+
+        /// <summary>
+        /// 鑾峰彇涓婃灦浠诲姟璁板綍淇℃伅鍒嗛〉闆嗗悎
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<SqlSugarPagedList> GetPalletUpShelfList(PalletUpShelfVm model)
+        {
+            RefAsync<int> count = new RefAsync<int>();
+            var data = await _palletUpShelfSvc.GetPalletUpShelfList(model.TraceNo, model.TaskNo,model.PalletNo,model.SkuNo,model.SkuName,model.LotNo,model.Status,model.Page,model.Limit, count);
+            return new SqlSugarPagedList() { Items = data, Total = count };
+        }
+        #endregion
     }
 
 }
diff --git a/Wms/Wms/Controllers/BllCheckController.cs b/Wms/Wms/Controllers/BllCheckController.cs
index 5ac84ab..0954035 100644
--- a/Wms/Wms/Controllers/BllCheckController.cs
+++ b/Wms/Wms/Controllers/BllCheckController.cs
@@ -197,7 +197,7 @@
         {
             try
             {
-                var type = new List<string>() { "2", "3", "4" };
+                var type = new List<string>() { "2", "3", "4", "6" };
                 RefAsync<int> count = new RefAsync<int>();
                 var bolls = await _taskSvc.GetTaskList(type, model.Type, model.Status, model.TaskNo, model.IsSuccess, model.PalletNo, model.Msg, model.Page, model.Limit, count);
 
diff --git a/Wms/Wms/Controllers/DownApiController.cs b/Wms/Wms/Controllers/DownApiController.cs
index d8da14f..2c35f9c 100644
--- a/Wms/Wms/Controllers/DownApiController.cs
+++ b/Wms/Wms/Controllers/DownApiController.cs
@@ -18,6 +18,7 @@
 using Model.ModelVm.BllTaskVm;
 using Utility;
 using System.Threading.Tasks;
+using Model.ModelVm.BllCheckVm;
 
 namespace Wms.Controllers
 {
diff --git a/Wms/Wms/Controllers/PdaAsnController.cs b/Wms/Wms/Controllers/PdaAsnController.cs
index 1eb2b37..d896832 100644
--- a/Wms/Wms/Controllers/PdaAsnController.cs
+++ b/Wms/Wms/Controllers/PdaAsnController.cs
@@ -6,6 +6,7 @@
 using Model.ModelVm.PdaVm;
 using System;
 using System.Security.Claims;
+using Utility;
 using WMS.Entity.BllAsnEntity;
 using WMS.IBLL.IPdaServer;
 
@@ -569,10 +570,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
+        [UnitOfWork]
         public IActionResult BindPallet(PdaPalletBindVm model)
         {
-            try
-            {
                 var claimsIdentity = this.User.Identity as ClaimsIdentity;
                 if (claimsIdentity == null)
                 {
@@ -583,15 +583,17 @@
                 {
                     throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
                 }
-                _PdaAsnSvc.BindPalletStock(model, int.Parse(UserId), model.Origin);
+                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 = "缁戝畾鎴愬姛!" });
 
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
         }
         #endregion
 
diff --git a/Wms/Wms/Controllers/PdaCrController.cs b/Wms/Wms/Controllers/PdaCrController.cs
index b4f542b..86c1d5e 100644
--- a/Wms/Wms/Controllers/PdaCrController.cs
+++ b/Wms/Wms/Controllers/PdaCrController.cs
@@ -10,6 +10,11 @@
 using WMS.IBLL.IPdaServer;
 using WMS.Entity.DataEntity;
 using WMS.Entity.SysEntity;
+using Utility;
+using Model.ModelDto.BllCheckDto;
+using Model.ModelDto.PdaDto;
+using Microsoft.AspNetCore.Identity;
+using System.Security.Cryptography;
 
 namespace Wms.Controllers
 {
@@ -19,10 +24,12 @@
     public class PdaCrController : ControllerBase
     {
         private readonly IPdaCrServer _pdaCrSvc;
+        private readonly UserManager _userManager;
 
-        public PdaCrController(IPdaCrServer pdaCrSvc)
+        public PdaCrController(IPdaCrServer pdaCrSvc, UserManager userManager)
         {
             _pdaCrSvc = pdaCrSvc;
+            _userManager = userManager;
         }
 
         #region 鐩樼偣
@@ -33,18 +40,10 @@
         /// <param name="model">PalletNo:鎵樼洏鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetStockCheckNoList(PdaCrVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<string>> GetStockCheckNoList(PdaCrVm model)
         {
-            try
-            {
-                var list = _pdaCrSvc.GetStockCheckNoList(model.PalletNo);
-
-                return Ok(new { code = 0, msg = "鐩樼偣鍗曚俊鎭�", data = list });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaCrSvc.GetStockCheckNoList(model.PalletNo);
         }
 
         /// <summary>
@@ -53,18 +52,10 @@
         /// <param name="model">CrNo:鐩樼偣鍗曘�丳alletNo:鎵樼洏鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetStockCheckDetailList(PdaCrVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<StockCheckDetailDto>> GetStockCheckDetailList(PdaCrVm model)
         {
-            try
-            {
-                var list = _pdaCrSvc.GetStockCheckDetailList(model.CrNo, model.PalletNo);
-
-                return Ok(new { code = 0, msg = "鐩樼偣鍗曟槑缁嗙墿鏂欐壒娆′俊鎭�", data = list });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaCrSvc.GetStockCheckDetailList(model.CrNo, model.PalletNo);
         }
 
         /// <summary>
@@ -73,18 +64,10 @@
         /// <param name="model"></param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetStockCheckLogList(PdaCrVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<StockCheckLogDto>> GetStockCheckLogList(PdaCrVm model)
         {
-            try
-            {
-                var list = _pdaCrSvc.GetStockCheckLogList(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo,model.isContinue);
-
-                return Ok(new { code = 0, msg = "瑕佺洏鐐圭殑绠辩爜淇℃伅", data = list });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaCrSvc.GetStockCheckLogList(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.isContinue);
         }
 
         /// <summary>
@@ -93,6 +76,8 @@
         /// <param name="model"></param> 
         /// <returns></returns>
         [HttpPost]
+        [UnitOfWork]
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
         public IActionResult CrSetCheck(PdaCrVm model)
         {
             try
@@ -109,7 +94,7 @@
                     return Ok(new { code = 1, msg = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
                 }
 
-                _pdaCrSvc.CrSetCheck(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.BoxNo3, model.Result, model.Qty,model.isContinue, int.Parse(userId));
+                _pdaCrSvc.CrSetCheck(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.BoxNo3, model.Result, model.Qty, model.isContinue, int.Parse(userId));
 
                 return Ok(new { code = 0, msg = "鐩樼偣瀹屾垚", data = "" });
             }
@@ -131,22 +116,10 @@
         /// <param name="skuName">鐗╂枡鍚嶇О</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetStockQueryList(string locatNo, string palletNo  )
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
         {
-            try
-            {
-                List<DataStockDetail> stockList = _pdaCrSvc.GetStockQueryList(locatNo, palletNo);
-                if (stockList.Count==0)
-                {
-                    return Ok(new { data = stockList, code = 1, msg = "鏃犳暟鎹�" });
-                }
-                return Ok(new { data = stockList, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-            
+            return await _pdaCrSvc.GetStockQueryList(locatNo, palletNo);
         }
 
         #endregion
@@ -159,21 +132,10 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetDataDetailList(string palletNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<PdaPalletNoCheckDto>> GetDataDetailList(string palletNo)
         {
-            try
-            {
-                var list = _pdaCrSvc.GetDataDetailList(palletNo);
-                if (list.Count == 0)
-                {
-                    return Ok(new { data = list, code = 1, msg = "鏃犳暟鎹�" });
-                }
-                return Ok(new { data = list, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
+            return await _pdaCrSvc.GetDataDetailList(palletNo);
 
         }
 
@@ -183,22 +145,10 @@
         /// <param name="boxNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetBoxInfoByBox(string boxNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<PdaPalletNoCheckDto> GetBoxInfoByBox(string boxNo)
         {
-            try
-            {
-                var list = _pdaCrSvc.GetBoxInfoByBox(boxNo);
-                if (list == null)
-                {
-                    return Ok(new { data = list, code = 1, msg = "鏃犳暟鎹�" });
-                }
-                return Ok(new { data = list, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetBoxInfoByBox(boxNo);
         }
 
         /// <summary>
@@ -207,32 +157,11 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SaveUnbind(PdaPalletCheckVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task SaveUnbind(PdaPalletCheckVm 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.SaveUnbind(model.PalletNo, model.BoxNo, model.PalletNoNew, uId);
-                
-                return Ok(new { data = "", code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            await _pdaCrSvc.SaveUnbind(model.PalletNo, model.BoxNo, model.PalletNoNew, _userManager.UserId);
         }
 
         #endregion
@@ -244,19 +173,10 @@
         /// <param name="palletNo"></param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetPalletLocatNo(string palletNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<string> GetPalletLocatNo(string palletNo)
         {
-            try
-            {
-                string result = _pdaCrSvc.GetPalletLocatNo(palletNo);
-
-                return Ok(new { data = result, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetPalletLocatNo(palletNo);
         }
         /// <summary>
         /// 鑾峰彇鎵樼洏鎵�鍦ㄦゼ灞傛墍鏈夊尯鍩�
@@ -264,38 +184,20 @@
         /// <param name="palletNo"></param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetStorageArea(string palletNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<SysStorageArea>> GetStorageArea(string palletNo)
         {
-            try
-            {
-                List<SysStorageArea> result = _pdaCrSvc.GetStorageArea(palletNo);
-
-                return Ok(new { data = result, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetStorageArea(palletNo);
         }
         /// <summary>
         /// 鑾峰彇鎵樼洏鎵�鍦ㄦゼ灞傛墍鏈夊尯鍩�
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetRunSoNoticeList()
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<string>> GetRunSoNoticeList()
         {
-            try
-            {
-                List<string> result = _pdaCrSvc.GetRunSoNoticeList();
-
-                return Ok(new { data = result, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetRunSoNoticeList();
         }
         /// <summary>
         /// 鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樹笂鐗╂枡淇℃伅
@@ -303,19 +205,10 @@
         /// <param name="palletNo"></param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetSkuInfoByPalletNo(string palletNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<DataStockDetail>> GetSkuInfoByPalletNo(string palletNo)
         {
-            try
-            {
-                List<DataStockDetail> result = _pdaCrSvc.GetSkuInfoByPalletNo(palletNo);
-
-                return Ok(new { data = result, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetSkuInfoByPalletNo(palletNo);
         }
         /// <summary>
         /// 鏍规嵁鍑哄簱鍗曞彿鑾峰彇鍒嗛厤鐨勬墭鐩樹俊鎭�
@@ -323,19 +216,10 @@
         /// <param name="soNo"></param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetPalletNoListBySoNo(string soNo)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        public async Task<List<string>> GetPalletNoListBySoNo(string soNo)
         {
-            try
-            {
-                List<string> result = _pdaCrSvc.GetPalletNoListBySoNo(soNo);
-
-                return Ok(new { data = result, code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
-
+            return await _pdaCrSvc.GetPalletNoListBySoNo(soNo);
         }
         /// <summary>
         /// agv杞繍鍛煎彨灏忚溅
@@ -343,31 +227,11 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult AgvTransport(PdaAgvTransportVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task AgvTransport(PdaAgvTransportVm 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.AgvTransport(model.PalletNo, model.AreaNo, model.Ruku, uId);
-
-                return Ok(new { data = "", code = 0, msg = "鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = $"寮傚父锛歿e.Message}" });
-            }
+            await _pdaCrSvc.AgvTransport(model.PalletNo, model.AreaNo, model.Ruku, _userManager.UserId);
         }
         /// <summary>
         /// agv杞繍鍛煎彨灏忚溅鍙栬揣
@@ -375,7 +239,23 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult AgvTransport2(PdaAgvTransportVm model)
+        [ServiceFilter(typeof(ApiResponseActionFilter))]
+        [UnitOfWork]
+        public async Task AgvTransport2(PdaAgvTransportVm model)
+        {
+            await _pdaCrSvc.AgvTransport2(model.SoNo, model.PalletNo, model.AreaNo, _userManager.UserId);
+        }
+
+        #endregion
+
+        #region 闆剁瑙g粦
+        /// <summary>
+        /// 闆剁瑙g粦
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult LingxingUnbind(PdaPalletUnBindVm model)
         {
             try
             {
@@ -392,7 +272,7 @@
                 }
 
                 var uId = int.Parse(userId);
-                _pdaCrSvc.AgvTransport2(model.SoNo,model.PalletNo, model.AreaNo, uId);
+                _pdaCrSvc.LingxingUnbind(model.PalletNo, model.BoxNo, uId);
 
                 return Ok(new { data = "", code = 0, msg = "鎴愬姛" });
             }
@@ -402,6 +282,5 @@
             }
         }
         #endregion
-
     }
 }
diff --git a/Wms/Wms/Controllers/PdaSoController.cs b/Wms/Wms/Controllers/PdaSoController.cs
index b918daa..3c63851 100644
--- a/Wms/Wms/Controllers/PdaSoController.cs
+++ b/Wms/Wms/Controllers/PdaSoController.cs
@@ -10,27 +10,30 @@
 using Model.ModelVm.PdaVm;
 using WMS.IBLL.IPdaServer;
 using Model.ModelDto;
-using Model.ModelVm;
 using Wms.Tools;
+using Utility;
+using System.Security.Cryptography;
 
 namespace Wms.Controllers
 {
     [Route("api/[controller]/[action]")]
     [ApiController]
     [Authorize]
+    [ServiceFilter(typeof(ApiResponseActionFilter))]
     public class PdaSoController : ControllerBase
     {
         #region 渚濊禆娉ㄥ叆
         private readonly ApiUrlConfig _config; //鎺ュ彛浜や簰璺緞
         private readonly IPdaSoServer _pdaSoSvc;
+        private readonly UserManager _userManager;
 
-        public PdaSoController(IOptions<ApiUrlConfig> setting,IPdaSoServer pdaSoSvc)
+        public PdaSoController(IOptions<ApiUrlConfig> setting, IPdaSoServer pdaSoSvc, UserManager userManager)
         {
             _config = setting.Value;
             _pdaSoSvc = pdaSoSvc;
+            _userManager = userManager;
         }
         #endregion
-
 
 
         /// <summary>
@@ -39,25 +42,9 @@
         /// <param name="model">PalletNo锛氭墭鐩樻潯鐮�</param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult IsEnableOkPalletNo(PdaSoVm model)
+        public async Task IsEnableOkPalletNo(PdaSoVm model)
         {
-            try
-            {
-                var strMsg = _pdaSoSvc.IsEnableOkPalletNo(model.PalletNo);
-
-                if (strMsg == "")
-                {
-                    return Ok(new { code = 0, msg = "鎵樼洏鍙敤!" });
-                }
-                else
-                {
-                    return Ok(new { code = 1, msg = strMsg });
-                }
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            await _pdaSoSvc.IsEnableOkPalletNo(model.PalletNo);
         }
 
         /// <summary>
@@ -66,18 +53,9 @@
         /// <param name="model">PalletNo:鎵樼洏鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetRunSoNoticeList(PdaSoVm model)
+        public async Task<List<string>> GetRunSoNoticeList(PdaSoVm model)
         {
-            try
-            {
-                var list = _pdaSoSvc.GetRunSoNoticeList(model.PalletNo,model.Type);
-
-                return Ok(new { code = 0, msg = "鍑哄簱鍗曚俊鎭�", data = list });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaSoSvc.GetRunSoNoticeList(model.PalletNo, model.Type);
         }
 
         /// <summary>
@@ -86,18 +64,9 @@
         /// <param name="model">PalletNo:鎵樼洏鐮併�丼oNo:鍗曟嵁鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetSoSkuLotNoListByPallet(PdaSoVm model)
+        public async Task<List<DetailIdSkuLotNo>> GetSoSkuLotNoListByPallet(PdaSoVm model)
         {
-            try
-            {
-                var models = _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
-
-                return Ok(new { code = 0, msg = "鐗╂枡-鎵规淇℃伅", data = models });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+           return await _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
         }
 
         /// <summary>
@@ -106,18 +75,9 @@
         /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D銆丳alletNo:鎵樼洏鐮�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetOutlets(PdaSoVm model)
+        public async Task<OutPdaInfo> GetOutlets(PdaSoVm model)
         {
-            try
-            {
-                var models = _pdaSoSvc.GetOutlets(model.SoDetailId, model.PalletNo);
-
-                return Ok(new { code = 0, msg = "鎵樼洏涓婄墿鏂欑瓑淇℃伅", data = models });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaSoSvc.GetOutlets(model.SoDetailId, model.PalletNo);
         }
 
         /// <summary>
@@ -126,38 +86,22 @@
         /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetPlanAndFinishQty(PdaSoVm model)
+        public async Task<OutPdaInfo> GetPlanAndFinishQty(PdaSoVm model)
         {
-            try
-            {
-                var models = _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
-
-                return Ok(new { code = 0, msg = "鍑哄簱鍗曟槑缁嗘暟閲忎俊鎭�", data = models });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            var data = await _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
+            return data;
         }
 
         /// <summary>
         /// 鑾峰彇绠辩爜淇℃伅锛堟牴鎹鐮佸湪搴撳瓨绠辩爜鏄庣粏涓煡璇級
         /// </summary>
-        /// <param name="model">BoxNo:绠辩爜鍙�</param> 
+        /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetDataComBoxInfo(PdaSoVm model)
+        public async Task<List<BoxInfo>> GetDataComBoxInfo(PdaSoVm model)
         {
-            try
-            {
-                var models = _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId,model.PalletNo, model.BoxNo, model.BoxNo3);
-
-                return Ok(new { code = 0, msg = "绠辩爜淇℃伅", data = models });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            var data = await _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3);
+            return data;
         }
 
         /// <summary>
@@ -166,51 +110,9 @@
         /// <param name="model">BoxNo:绠辩爜鍙�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult GetAllotPlnInfo(PdaSoVm model)
+        public async Task<List<BoxInfo>> GetAllotPlnInfo(PdaSoVm model)
         {
-            try
-            {
-                var models = _pdaSoSvc.GetAllotPlnInfo(model.SoDetailId, model.PalletNo);
-
-                return Ok(new { code = 0, msg = "绠辩爜淇℃伅", data = models });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
-        }
-
-
-        /// <summary>
-        /// 鍑哄簱pda鎷h揣
-        /// </summary>
-        /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D銆丳alletNo:鎵樼洏鐮�</param> 
-        /// <returns></returns>
-        [HttpPost]
-        public IActionResult SoSetPick(PdaSoVm 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-
-                _pdaSoSvc.SoSetPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3,model.PickQty ,int.Parse(userId));
-
-                return Ok(new { code = 0, msg = "鎷h揣瀹屾垚", data = "" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaSoSvc.GetAllotPlnInfo(model.SoDetailId, model.PalletNo);
         }
 
         /// <summary>
@@ -219,30 +121,20 @@
         /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D銆丳alletNo:鎵樼洏鐮�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SoSetQtyPick(PdaSoVm model)
+        public async Task SoSetPick(PdaSoVm 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
+            await _pdaSoSvc.SoSetPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, _userManager.UserId);
+        }
 
-                _pdaSoSvc.SoSetQtyPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty,  int.Parse(userId));
-
-                return Ok(new { code = 0, msg = "鎷h揣瀹屾垚", data = "" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+        /// <summary>
+        /// 鍑哄簱pda鎷h揣
+        /// </summary>
+        /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D銆丳alletNo:鎵樼洏鐮�</param> 
+        /// <returns></returns>
+        [HttpPost]
+        public async Task SoSetQtyPick(PdaSoVm model)
+        {
+            await _pdaSoSvc.SoSetQtyPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, _userManager.UserId);
         }
 
 
@@ -252,36 +144,9 @@
         /// <param name="model">绌烘墭鐩樺嚭搴�</param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult IssuePlnOutHouse(OutModePalletVm model)
+        public async Task<string> IssuePlnOutHouse(OutModePalletVm model)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-
-                var strMsg = _pdaSoSvc.IssuePlnOutHouse(model, int.Parse(UserId), _config.WcsHost + _config.IssueComApiUrl);
-
-                if (strMsg == "")
-                {
-                    return Ok(new { code = 0, msg = "绌烘墭鐩樺嚭搴撴垚鍔�!" });
-                }
-                else
-                {
-                    return Ok(new { code = 1, msg = strMsg });
-                }
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            return await _pdaSoSvc.IssuePlnOutHouse(model, _userManager.UserId, _config.WcsHost + _config.IssueComApiUrl);
         }
 
 
@@ -293,17 +158,9 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetPingKuInfoByPallet(string soNo, string palletNo)
+        public async Task<List<BoxInfo>> GetPingKuInfoByPallet(string soNo, string palletNo)
         {
-            try
-            {
-                var list = _pdaSoSvc.GetPingKuInfoByPallet(soNo,palletNo); 
-                return Ok(new { data = list, code = 0, msg = "鑾峰彇骞冲簱鎵樼洏淇℃伅鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鑾峰彇骞冲簱鎵樼洏淇℃伅閿欒锛�" + e.Message });
-            }
+            return await _pdaSoSvc.GetPingKuInfoByPallet(soNo, palletNo);
         }
 
         /// <summary>
@@ -313,31 +170,9 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult PlaneExportSuccess(string soNo, string palletNo)
+        public async Task PlaneExportSuccess(string soNo, string palletNo)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                int uid = Convert.ToInt32(UserId);
-
-                _pdaSoSvc.PlaneExportSuccess(soNo, palletNo, uid);
-
-                return Ok(new { data = "", code = 0, msg = "骞冲簱鍑哄簱鎴愬姛" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "骞冲簱鍑哄簱閿欒锛�"+e.Message });
-            }
-           
+            await _pdaSoSvc.PlaneExportSuccess(soNo, palletNo, _userManager.UserId);
         }
 
 
@@ -347,30 +182,9 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetSampleType(string palletNo)
+        public async Task<string> GetSampleType(string palletNo)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                } 
-
-                var type = _pdaSoSvc.GetSampleType(palletNo);
-
-                return Ok(new { data = type, code = 0, msg = "鑾峰彇鍙栨牱绫诲瀷" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鑾峰彇鍙栨牱绫诲瀷閿欒锛�" + e.Message });
-            }
-
+            return await _pdaSoSvc.GetSampleType(palletNo);
         }
 
         /// <summary>
@@ -379,19 +193,9 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetAsnNoByPallet(string palletNo)
+        public async Task<List<string>> GetAsnNoByPallet(string palletNo)
         {
-            try
-            {
-                var type = _pdaSoSvc.GetAsnNoByPallet(palletNo);
-
-                return Ok(new { data = type, code = 0, msg = "鑾峰彇鍏ュ簱鍗曟嵁" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鑾峰彇鍏ュ簱鍗曟嵁閿欒锛�" + e.Message });
-            }
-
+            return await _pdaSoSvc.GetAsnNoByPallet(palletNo);
         }
         /// <summary>
         /// 鍙栨牱鍑哄簱鎷h揣(鏍囩)
@@ -399,31 +203,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SampleSoSetPick(PdaSoVm model)
+        public async Task SampleSoSetPick(PdaSoVm model)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                int uid = Convert.ToInt32(UserId);
-
-                _pdaSoSvc.SampleSoSetPick(model.Type,model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.AsnNo, uid);
-
-                return Ok(new { data = "", code = 0, msg = "(鏍囩)鍙栨牱鍑哄簱鎷h揣" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "(鏍囩)鍙栨牱鍑哄簱鎷h揣閿欒锛�" + e.Message });
-            }
-
+            await _pdaSoSvc.SampleSoSetPick(model.Type, model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.AsnNo, _userManager.UserId);
         }
         /// <summary>
         /// 鍙栨牱鍑哄簱鎷h揣(鏃犳爣绛�)
@@ -431,30 +213,9 @@
         /// <param name="model">SoDetailId:鍑哄簱鍗曟槑缁咺D銆丳alletNo:鎵樼洏鐮�</param> 
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SampleSoSetQtyPick(PdaSoVm model)
+        public async Task SampleSoSetQtyPick(PdaSoVm 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-
-                _pdaSoSvc.SampleSoSetQtyPick(model.Type, model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, model.AsnNo, int.Parse(userId));
-
-                return Ok(new { data = "", code = 0, msg = "(鏃犳爣绛�)鍙栨牱鍑哄簱鎷h揣" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "(鏃犳爣绛�)鍙栨牱鍑哄簱鎷h揣閿欒锛�" + e.Message });
-            }
+            await _pdaSoSvc.SampleSoSetQtyPick(model.Type, model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, model.AsnNo, _userManager.UserId);
         }
         #region 鎷h揣鎷兼墭
         /// <summary>
@@ -463,29 +224,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SoSetPinPick(PdaSoVm model)
+        public async Task SoSetPinPick(PdaSoVm 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-
-                _pdaSoSvc.SoSetPinPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.PalletNoNew, int.Parse(userId));
-                return Ok(new { code = 0, msg = "鎷h揣瀹屾垚", data = "" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            await _pdaSoSvc.SoSetPinPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.PalletNoNew, _userManager.UserId);
         }
         /// <summary>
         /// 鎷兼墭鍑哄簱pda鎷h揣-鏁伴噺
@@ -493,30 +234,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SoSetQtyPinPick(PdaSoVm model)
+        public async Task SoSetQtyPinPick(PdaSoVm 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 = "鏈幏鍙栧埌褰撳墠鎿嶄綔浜轰俊鎭�" });
-                }
-
-                _pdaSoSvc.SoSetQtyPinPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, model.PalletNoNew, int.Parse(userId));
-
-                return Ok(new { code = 0, msg = "鎷h揣瀹屾垚", data = "" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { code = 1, msg = e.Message });
-            }
+            await _pdaSoSvc.SoSetQtyPinPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, model.PalletNoNew, _userManager.UserId);
         }
         #endregion
 
@@ -529,19 +249,9 @@
         /// <param name="palletNo">鎵樼洏鍙�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetSampleType2(string palletNo)
+        public async Task<string> GetSampleType2(string palletNo)
         {
-            try
-            {
-                var type = _pdaSoSvc.GetSampleType2(palletNo);
-
-                return Ok(new { data = type, code = 0, msg = "鏍规嵁鎵樼洏鍙疯幏鍙栧彇鏍风被鍨�" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鏍规嵁鎵樼洏鍙疯幏鍙栧彇鏍风被鍨嬶細" + e.Message });
-            }
-
+            return await _pdaSoSvc.GetSampleType2(palletNo);
         }
 
         /// <summary>
@@ -549,19 +259,9 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetInspectionNo()
+        public async Task<List<string>> GetInspectionNo()
         {
-            try
-            {
-                var qcNoStr = _pdaSoSvc.GetInspectionNo();
-
-                return Ok(new { data = qcNoStr, code = 0, msg = "鑾峰彇寰呭嚭搴撴垨寰呭彇鏍风殑璇烽獙鍗�" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鑾峰彇寰呭嚭搴撴垨寰呭彇鏍风殑璇烽獙鍗曪細" + e.Message });
-            }
-
+            return await _pdaSoSvc.GetInspectionNo();
         }
 
         /// <summary>
@@ -570,19 +270,9 @@
         /// <param name="qcNo">璇烽獙鍗�</param>
         /// <returns></returns>
         [HttpGet]
-        public IActionResult GetInspectionRequestInfo(string qcNo)
+        public async Task<InspectionRequestDto> GetInspectionRequestInfo(string qcNo)
         {
-            try
-            {
-                var info = _pdaSoSvc.GetInspectionRequestInfo(qcNo);
-
-                return Ok(new { data = info, code = 0, msg = "鑾峰彇璇烽獙鍗曠浉鍏充俊鎭�" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "鑾峰彇璇烽獙鍗曠浉鍏充俊鎭細" + e.Message });
-            }
-
+            return await _pdaSoSvc.GetInspectionRequestInfo(qcNo);
         }
 
         /// <summary>
@@ -591,31 +281,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SampleSetPick(SampleSoVm model)
+        public async Task SampleSetPick(SampleSoVm model)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                int uid = Convert.ToInt32(UserId);
-
-                _pdaSoSvc.SampleSetPick(model.QcNo, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, uid);
-
-                return Ok(new { data = "", code = 0, msg = "(鏍囩)鍙栨牱鍑哄簱鎷h揣" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "(鏍囩)鍙栨牱鍑哄簱鎷h揣閿欒锛�" + e.Message });
-            }
-
+            await _pdaSoSvc.SampleSetPick(model.QcNo, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, _userManager.UserId);
         }
 
         /// <summary>
@@ -624,31 +292,9 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost]
-        public IActionResult SampleSetQtyPick(SampleSoVm model)
+        public async Task SampleSetQtyPick(SampleSoVm model)
         {
-            try
-            {
-                var claimsIdentity = this.User.Identity as ClaimsIdentity;
-                if (claimsIdentity == null)
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
-                if (string.IsNullOrWhiteSpace(UserId))
-                {
-                    throw new Exception("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
-                }
-                int uid = Convert.ToInt32(UserId);
-
-                _pdaSoSvc.SampleSetQtyPick(model.QcNo, model.PalletNo, model.PickQty, uid);
-
-                return Ok(new { data = "", code = 0, msg = "(鏁伴噺)鍙栨牱鍑哄簱鎷h揣" });
-            }
-            catch (Exception e)
-            {
-                return Ok(new { data = "", code = 1, msg = "(鏁伴噺)鍙栨牱鍑哄簱鎷h揣閿欒锛�" + e.Message });
-            }
-
+            await _pdaSoSvc.SampleSetQtyPick(model.QcNo, model.PalletNo, model.PickQty, _userManager.UserId);
         }
 
         #endregion
diff --git a/Wms/Wms/Controllers/WeatherForecastController.cs b/Wms/Wms/Controllers/WeatherForecastController.cs
index 2ef1ab4..a46ab50 100644
--- a/Wms/Wms/Controllers/WeatherForecastController.cs
+++ b/Wms/Wms/Controllers/WeatherForecastController.cs
@@ -1,19 +1,12 @@
 锘縰sing Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Logging;
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Security.Claims;
 using System.Threading.Tasks;
-using Microsoft.AspNetCore.Authorization;
 using Model.ModelVm;
-using Newtonsoft.Json;
-using Utility.Tools;
 using WMS.Entity.Context;
 using WMS.IBLL.ISysServer;
 using Wms.Tools;
 using Utility;
-
 
 namespace Wms.Controllers
 {
diff --git a/Wms/Wms/appsettings.json b/Wms/Wms/appsettings.json
index bf36940..72dd5a9 100644
--- a/Wms/Wms/appsettings.json
+++ b/Wms/Wms/appsettings.json
@@ -11,6 +11,7 @@
     //"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_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