From 87110c04df904eb4947587a34f3fc5a1eb45eb7e Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 12 十月 2025 16:21:11 +0800
Subject: [PATCH] 入库单据开发导入入库单功能;

---
 HTML/js/public.js                                  |    2 
 Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs |    2 
 Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs    |   72 +++++++++++++-
 Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs      |    7 +
 Wms/Wms/Controllers/BllAsnController.cs            |   38 +++++++
 HTML/views/ASNSetting/ArrivalNotice.html           |  130 +++++++++++++++++++++++++
 6 files changed, 244 insertions(+), 7 deletions(-)

diff --git a/HTML/js/public.js b/HTML/js/public.js
index 8cca1df..ff31e00 100644
--- a/HTML/js/public.js
+++ b/HTML/js/public.js
@@ -2,7 +2,7 @@
 // var IP = "http://172.16.71.101:8082/";//鎺ュ彛IP
 //var IP = "http://localhost:13243/api";
 //var IP = "http://localhost:50515/api";  //鏈湴
-var IP="https://localhost:5001/api";
+var IP="https://localhost:44363/api";
 // var IP = "http://localhost:44318/api";
 //var IP = "http://192.168.1.6:8017";
 //var IP = "http://192.168.1.226:8086";  
diff --git a/HTML/views/ASNSetting/ArrivalNotice.html b/HTML/views/ASNSetting/ArrivalNotice.html
index 51e5c5a..da7278e 100644
--- a/HTML/views/ASNSetting/ArrivalNotice.html
+++ b/HTML/views/ASNSetting/ArrivalNotice.html
@@ -291,6 +291,9 @@
 						<button style="margin-right: 5px;" class="layui-btn layui-btn-sm layuiadmin-btn-list addClass" lay-event="add" >
 							<i class="layui-icon">&#xe654;</i>娣诲姞
 						</button>
+						<button style="margin-right: 5px;" id="daoru" class="layui-btn layui-btn-sm layuiadmin-btn-list DaoRuClass" lay-event="import" >
+							<i class="layui-icon">&#xe654;</i>瀵煎叆
+						</button>
 					</script>
 					
 					<script type="text/html" id="toolbarDemoList">
@@ -399,11 +402,14 @@
 
 	<script>
 		var uid = $.cookie('userId');
+		layui.extend({
+			excel: '../../layuiadmin/layui/layui_exts/excel' // {/}鐨勬剰鎬濆嵆浠h〃閲囩敤鑷湁璺緞锛屽嵆涓嶈窡闅� base 璺緞
+		})
 		layui.config({
 			base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
 		}).extend({
 			index: 'lib/index' //涓诲叆鍙fā鍧�
-		}).use(['index', 'form', 'table', 'laypage', 'layer', 'laydate'], function () {
+		}).use(['index', 'form', 'table', 'laypage', 'layer', 'laydate', 'upload', 'excel'], function () {
 
 			var doing = true;
 
@@ -411,6 +417,8 @@
 				form = layui.form,
 				laypage = layui.laypage,
 				layer = layui.layer;
+
+			var upload = layui.upload;
 
 			laydate = layui.laydate;
 
@@ -591,10 +599,130 @@
 						},
 						cols: colsJson2
 					});
+
+					//缁戝畾瀵煎叆
+					upload.render({
+						elem: '#daoru' //缁戝畾鍏冪礌
+						, url: '' //涓婁紶鎺ュ彛
+						, auto: false  //鏄惁閫夊畬鏂囦欢鍚庤嚜鍔ㄤ笂浼犮�傚鏋滆瀹� false锛岄偅涔堥渶瑕佽缃� bindAction 鍙傛暟鏉ユ寚鍚戜竴涓叾瀹冩寜閽彁浜や笂浼�
+						, exts: 'slx|excel|xlsx'  //鍏佽涓婁紶鐨勬枃浠跺悗缂� 
+						, accept: 'file' //鎸囧畾鍏佽涓婁紶鏃舵牎楠岀殑鏂囦欢绫诲瀷
+						//, bindAction: '#daoru' //鎸囧悜涓�涓寜閽Е鍙戜笂浼�
+						, choose: function (obj) {// 閫夋嫨鏂囦欢鍥炶皟
+							console.log(obj);
+							var files = obj.pushFile(); //灏嗘瘡娆¢�夋嫨鐨勬枃浠惰拷鍔犲埌鏂囦欢闃熷垪
+							var fileArr = Object.values(files);// 娉ㄦ剰杩欓噷鐨勬暟鎹渶瑕佹槸鏁扮粍锛屾墍浠ラ渶瑕佽浆鎹竴涓�
+							console.log(fileArr)
+							// 鐢ㄥ畬灏辨竻鐞嗘帀锛岄伩鍏嶅娆¢�変腑鐩稿悓鏂囦欢鏃跺嚭鐜伴棶棰�
+							for (var index in files) {
+								console.log(index);
+								if (files.hasOwnProperty(index)) {
+									delete files[index];
+								}
+							}
+							console.log("abs");
+							uploadExcel(fileArr); // 濡傛灉鍙渶瑕佹渶鏂伴�夋嫨鐨勬枃浠讹紝鍙互杩欐牱鍐欙細 uploadExcel([files.pop()])
+						}
+						, done: function (res) {
+							console.log(res);
+							//涓婁紶瀹屾瘯鍥炶皟
+						}
+						, error: function (res) {
+							console.log(res);
+							//璇锋眰寮傚父鍥炶皟
+						}
+					});
 				});
 				//#endregion
 			}
 
+			// 瀵煎叆鍏ュ簱鍗曟嵁
+			function uploadExcel(files) {
+				var noticeList = [];
+				try {
+					var excel = layui.excel;
+					excel.importExcel(files, {
+						// 璇诲彇鏁版嵁鐨勫悓鏃舵⒊鐞嗘暟鎹�
+						fields: {
+							'SkuNo': 'A', //鐗╂枡鍙�
+							'SkuName': 'B', //鐗╂枡鍚嶇О
+							'Qty': 'C', //鏁伴噺
+							'LotNo': 'D', //鎵规
+							'LotText': 'E', //鎵规鎻忚堪
+							'SupplierLot': 'F',  //渚涜揣鎵规
+							'Lot1': 'G', //鐢熶骇鏃ユ湡
+							'Lot2': 'H', //杩囨湡鏃ユ湡
+							'CustomerNo': 'I', //渚涘簲鍟嗙紪鐮�
+							'CustomerName': 'J', //渚涘簲鍟嗗悕绉�
+							}
+						},
+						function (data) {
+							console.log(data);
+							// var arr = new Array();
+							//excel绗竴琛屼笉璇诲彇銆佽缃负鏍囬
+							for (i = 1; i < data[0].Sheet1.length; i++) {
+								var noticeDetailList = [];
+								var Qty = 0;
+								if (data[0].Sheet1[i].Qty) {
+									Qty = parseFloat(data[0].Sheet1[i].Qty);
+								}
+								var noticeDetail={
+									SkuNo: data[0].Sheet1[i].SkuNo.toString(),
+									SkuName: data[0].Sheet1[i].SkuName.toString(),
+									Qty: Qty,									
+									LotNo: data[0].Sheet1[i].LotNo.toString(),
+									LotText: data[0].Sheet1[i].LotText,
+									SupplierLot: data[0].Sheet1[i].SupplierLot.toString(),
+									Lot1: data[0].Sheet1[i].Lot1,
+									Lot2: data[0].Sheet1[i].Lot2,
+									
+								};
+								noticeDetailList.push(noticeDetail);
+								var notice = {
+									Type:'1',
+									CustomerNo: data[0].Sheet1[i].CustomerNo.toString(),
+									CustomerName: data[0].Sheet1[i].CustomerName.toString(),
+									AsnDetail:noticeDetailList
+								};
+								noticeList.push(notice);
+							}
+							var param = {
+								"ListArrivalNotice": noticeList,
+							}
+							console.log('param:'+param)
+							layer.load();//鎵撳紑loading
+							sendData(IP + "/BllAsn/ImportArrivalNotice", param, 'post', function (res) {
+								console.log(res);
+								layer.closeAll(); //鍏抽棴loading
+								if (res.code == 0) { //鎴愬姛
+									layer.msg(res.msg, {
+										icon: 1,
+										time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+									}, function () {
+										refreshTable();
+										doing = true
+									});
+								} else { //涓嶆垚鍔�
+									if (res.msg == undefined) {
+										layer.msg("瀵煎叆鏁版嵁鏍煎紡鏈夎锛�", {
+											icon: 2,
+											time: 3000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+										}, function () { refreshTable(); doing = true });
+									} else {
+										layer.msg(res.msg, {
+											icon: 2,
+											time: 2000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級
+										}, function () { refreshTable(); doing = true });
+									}
+								}
+							});
+						});
+				} catch (e) {
+					layer.alert(e.message);
+				}
+
+			}
+
 			function setRight() {
 				$(function () {
 					$(".addClass").hide();
diff --git a/Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs b/Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs
index d4638b1..f0a7cfd 100644
--- a/Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs
+++ b/Wms/Model/ModelVm/BllAsnVm/ArrivalNoticeVm.cs
@@ -108,4 +108,11 @@
 
         public int? CreateUser { get; set; }
     }
+
+    public class ArrivalNoticeVms
+    {
+        public int? CreateUser { get; set; }
+
+        public List<ArrivalNoticeVm> ListArrivalNotice { get; set; }
+    }
 }
diff --git a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
index 8ff0456..2c91721 100644
--- a/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/ArrivalNoticeServer.cs
@@ -275,7 +275,7 @@
 
             try
             {
-                if (model.Origin == "褰曞叆")
+                if (model.Origin == "褰曞叆" || model.Origin == "瀵煎叆")
                 {
                     model.ASNNo = new Common().GetMaxNo("ASN");
                 }
@@ -290,6 +290,7 @@
                         throw new Exception("鍗曟嵁绫诲瀷涓嶅彲涓虹┖!");
                     }
                 }
+
                 
                 lock (AsnLock)
                 {
@@ -422,12 +423,16 @@
                             {
                                 throw new Exception("涓嶅厤妫�鐗╂枡杩囨湡鏃ユ湡杞崲澶辫触");
                             }
-                            lot1 = lot12.ToString();
-                            lot2 = lot22.ToString();
+                            lot1 = lot12.ToString("yyyy-MM-dd");
+                            lot2 = lot22.ToString("yyyy-MM-dd");
                         }
                         if (string.IsNullOrWhiteSpace(detailModel.PackagNo))
                         {
-                            throw new Exception("鍖呰涓嶈兘涓虹┖");
+                            detailModel.PackagNo = sku.PackagNo;
+                            if (string.IsNullOrWhiteSpace(detailModel.PackagNo))
+                            {
+                                throw new Exception("鍖呰涓嶈兘涓虹┖");
+                            }
                         }
                         // 璁$畻鍑烘�婚噾棰�
                         detailModel.Money = detailModel.Price * detailModel.Qty;
@@ -436,7 +441,7 @@
                             ASNNo = model.ASNNo,
                             SkuNo = detailModel.SkuNo,
                             SkuName = detailModel.SkuName,
-                            Standard = detailModel.Standard,
+                            Standard = sku.Standard,
                             LotNo = detailModel.LotNo == null ? "" : detailModel.LotNo.Trim(),
                             LotText = detailModel.LotText,
                             Qty = (decimal)detailModel.Qty,
@@ -500,6 +505,63 @@
             }
         }
 
+        //瀵煎叆鍏ュ簱鍗曟嵁
+        public string ImportArrivalNotice(ArrivalNoticeVms models)
+        {
+            string strMessage = "";
+            try
+            {
+                if (models.ListArrivalNotice.Count <= 0)
+                {
+                    strMessage = "-1:鏂囦欢鍐呮棤鏁版嵁璇锋牳瀹�!";
+                }
+                var num = 0;
+                int CreateUser = Convert.ToInt32(models.CreateUser);
+                List<string> noticeList = new List<string>();
+                foreach (ArrivalNoticeVm model in models.ListArrivalNotice)
+                {
+                    try
+                    {
+                        model.CreateUser = models.CreateUser;
+                        model.Origin = "瀵煎叆";
+                        var msg = AddArrivalNotice(model);
+                        strMessage += msg;
+                        if (msg == "")
+                        {
+                            num += 1;
+                            var hasBoxItem = noticeList.Exists(x => x == model.ASNNo);
+                            if (!hasBoxItem)
+                            {
+                                noticeList.Add(model.ASNNo);
+                            }
+                        }
+                    }
+                    catch
+                    {
+                        // ignored
+                    }
+                }
+                if (num > 0)
+                {
+                    new OperationASNServer().AddLogOperationAsn("鍏ュ簱浣滀笟", "鍏ュ簱鍗曟嵁", $"鍏卞鍏ヤ簡{noticeList.Count}鏉″崟鎹�", "瀵煎叆", $"鍏卞鍏ヤ簡{noticeList.Count}鏉″崟鎹�", CreateUser);
+                }
+                if (strMessage.Contains("-1") && num > 0)
+                {
+                    return "閮ㄥ垎瀵煎叆鎴愬姛" + strMessage;
+                }
+                if (num > 0)
+                {
+                    return "瀵煎叆鎴愬姛" + strMessage;
+                }
+
+                return strMessage;
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+        }
+
         /// <summary>
         /// 缂栬緫鍏ュ簱鍗曟嵁
         /// </summary>
diff --git a/Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs b/Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs
index 70af5d0..128a6e4 100644
--- a/Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs
+++ b/Wms/WMS.IBLL/IBllAsnServer/IArrivalNoticeServer.cs
@@ -49,6 +49,8 @@
         /// <param name="model"></param>
         /// <returns></returns>
         string AddArrivalNotice(ArrivalNoticeVm model);
+        //瀵煎叆鍏ュ簱鍗曟嵁
+        string ImportArrivalNotice(ArrivalNoticeVms models);
         /// <summary>
         /// 缂栬緫鍏ュ簱鍗�
         /// </summary>
diff --git a/Wms/Wms/Controllers/BllAsnController.cs b/Wms/Wms/Controllers/BllAsnController.cs
index d505a8f..f9aa4a9 100644
--- a/Wms/Wms/Controllers/BllAsnController.cs
+++ b/Wms/Wms/Controllers/BllAsnController.cs
@@ -162,6 +162,44 @@
                 return Ok(new { code = 1, msg = e.Message });
             }
         }
+        /// <summary>
+        /// 鍏ュ簱鍗曟嵁瀵煎叆
+        /// </summary>
+        /// <param name="models"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult ImportArrivalNotice(ArrivalNoticeVms models)
+        {
+            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("鏈幏鍙栧埌鐢ㄦ埛淇℃伅");
+                }
+
+                models.CreateUser = int.Parse(UserId);
+                string strMessage = _arrivalNoticeSvc.ImportArrivalNotice(models);
+
+                if (strMessage.Contains("-1"))
+                {
+                    return Ok(new { code = 1, msg = strMessage });
+                }
+                else
+                {
+                    return Ok(new { code = 0, msg = strMessage });
+                }
+            }
+            catch (Exception e)
+            {
+                return Ok(new { code = 1, msg = e.Message });
+            }
+        }
 
         [HttpPost]
         public IActionResult EditArrivalNotice(ArrivalNoticeVm model)

--
Gitblit v1.8.0