From 1650f3fe1467d21074b597042861c46f3a8c4447 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期二, 01 四月 2025 10:11:24 +0800
Subject: [PATCH] 问题修改

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |   95 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 83 insertions(+), 12 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 3ff3e48..491e79b 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -1950,6 +1950,14 @@
         {
             try
             {
+                if (levelType == "0")
+                {
+                    throw new Exception("鏈壘鍒拌鐗╂枡鐨勭鍖呰绾у埆");
+                }
+                if (levelType == "3")
+                {
+                    throw new Exception("鏈皟璇曡绾у埆鍖呰锛�");
+                }
                 var list = new List<BllBoxInfo>();
 
                 var data = new { BoxNo = boxNo };
@@ -2019,7 +2027,7 @@
                 #region 姝e紡鐗堟湰
                 var token = new Token().GetFuMaToken(fuMaTokenUrl);
                 var getParentVal = levelType == "1" ? "true" : "false";
-                var getChildrenVal = levelType == "3" ? "true" : "false";
+                var getChildrenVal = levelType == "2" ? "true" : "false";
                 Dictionary<string, string> paramDic = new Dictionary<string, string>
                 {
                     { "Token", token }, //鍒嗛厤鐨勪护鐗岋紙鍙橀噺锛�
@@ -2043,9 +2051,9 @@
                         throw new Exception("浜у搧淇℃伅鎴栫鏀俊鎭负绌�");
                     }
 
-                    foreach (var item in fuMaModel.Barcodes)
+                    if (levelType == "1")
                     {
-                        if (item.Barcode != boxNo)
+                        if (fuMaModel.Barcodes.First().Barcode != boxNo)
                         {
                             throw new Exception("鑾峰彇淇℃伅涓嶄竴鑷�");
                         }
@@ -2061,23 +2069,21 @@
                             //ASNDetailNo = 0,
                             OrderCode = "",
                             //BindNo = 0,
-                            BoxNo = item.Barcode,
-                            BoxNo2 = item.Barcode,
-                            BoxNo3 = item.Barcode,
+                            BoxNo = fuMaModel.Barcodes.First().Barcode,
                             PalletNo = "",
-                            Qty = item.BoxItemQty,
+                            Qty = fuMaModel.Barcodes.First().BoxItemQty,
                             FullQty = fuMaModel.BoxItemQty,
                             Status = "0",
                             SkuNo = sku.SkuNo,
                             SkuName = sku.SkuName,
-                            LotNo = item.BatchNo,
+                            LotNo = fuMaModel.Barcodes.First().BatchNo,
                             //LotText = "",
                             //SupplierLot = item.SupplierLot,
-                            ProductionTime = DateTime.Parse(item.ProductionDate),
-                            ExpirationTime = DateTime.Parse(item.ExpirationDate),
+                            ProductionTime = DateTime.Parse(fuMaModel.Barcodes.First().ProductionDate),
+                            ExpirationTime = DateTime.Parse(fuMaModel.Barcodes.First().ExpirationDate),
                             //CompleteTime = comTime,
                             InspectMark = "0",
-                            BitBoxMark = item.Status == "闆剁"? "1":"0",
+                            BitBoxMark = fuMaModel.Barcodes.First().Status == "闆剁" ? "1" : "0",
                             InspectStatus = "0",
                             Origin = "璧嬬爜",
                             Standard = fuMaModel.Product.Spec,
@@ -2090,6 +2096,56 @@
                         };
                         list.Add(boxInfo);
                     }
+                    else
+                    {
+                        foreach (var item in fuMaModel.Barcodes)
+                        {
+                            if (item.Barcode == boxNo)
+                            {
+                                continue; //鑾峰彇鏀爜鏃剁涓�涓爜涓虹埗鐮�
+                            }
+
+                            var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.MaterialNum);
+                            if (sku == null)
+                            {
+                                throw new Exception("鏈煡璇㈠埌绠辩爜涓拰璧嬬爜鎻愪緵鐨勭墿鏂欎俊鎭竴鑷寸殑鏁版嵁");
+                            }
+                            var boxInfo = new BllBoxInfo()
+                            {
+                                ASNNo = "",
+                                //ASNDetailNo = 0,
+                                OrderCode = "",
+                                //BindNo = 0,
+                                BoxNo = item.ParentBarcode,
+                                BoxNo3 = item.Barcode,
+                                PalletNo = "",
+                                Qty = item.MinLevelCount,
+                                FullQty = fuMaModel.BoxItemQty,
+                                Status = "0",
+                                SkuNo = sku.SkuNo,
+                                SkuName = sku.SkuName,
+                                LotNo = item.BatchNo,
+                                //LotText = "",
+                                //SupplierLot = item.SupplierLot,
+                                ProductionTime = DateTime.Parse(item.ProductionDate),
+                                ExpirationTime = DateTime.Parse(item.ExpirationDate),
+                                //CompleteTime = comTime,
+                                InspectMark = "0",
+                                BitBoxMark = item.Status == "闆剁" ? "1" : "0",
+                                InspectStatus = "0",
+                                Origin = "璧嬬爜",
+                                Standard = fuMaModel.Product.AuthorizedNo,
+                                PackageStandard = fuMaModel.Product.PackageSpec,
+                                //StoreTime = item.StoreTime,
+                                //QtyOrd = item.QtyOrd,
+                                QtyCount = (int)fuMaModel.BoxItemQty,
+                                CreateUser = 0,
+                                CreateTime = comTime,
+                            };
+                            list.Add(boxInfo);
+                        }
+                    }
+                   
                     Db.Insertable(list).ExecuteCommand();
                 }
                 else
@@ -2131,7 +2187,22 @@
                             var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
                             if (count == 0)
                             {
-                                GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl,"1"); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
+                                //鑾峰彇鐗╂枡鍖呰绾у埆
+                                string level = "0";
+                                var levelType = Db.Queryable<SysPackag>().First(w => w.IsDel == "0" && w.PackagNo == detail.SkuNo);
+                                if (levelType.L1Name == "绠�")
+                                {
+                                    level = "1";
+                                }
+                                if (levelType.L2Name == "绠�")
+                                {
+                                    level = "2";
+                                }
+                                if (levelType.L3Name == "绠�")
+                                {
+                                    level = "3";
+                                }
+                                GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl, level); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
                             }
                         }
                     }

--
Gitblit v1.8.0