From 1293aeec722e06dc11b657455941abbc1c274090 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期日, 16 二月 2025 11:23:46 +0800
Subject: [PATCH] 修改与小车接口

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |  231 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 205 insertions(+), 26 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 47e501b..b38fcf2 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -24,6 +24,7 @@
 using System.IO;
 using System.Security.Cryptography.X509Certificates;
 using System.Net.WebSockets;
+using WMS.BLL.SysServer;
 
 namespace WMS.BLL.BllPdaServer
 {
@@ -333,6 +334,7 @@
         public string BindNullPallet(PalletBindVm model)
         {
             string strMsg = "";
+            string type = model.BindType == "0" ? "PDA" : "鍙犳墭鏈�";
             try
             {
                 var datetime = Db.GetDate();
@@ -440,7 +442,7 @@
                     LotText = "",
                     SupplierLot = "",
                     InspectStatus = "1",
-                    Origin = "PDA",
+                    Origin = type,
                     BoxNo = "",
                     BoxNo2 = "",
                     BoxNo3 = "",
@@ -461,6 +463,120 @@
 
                 // 鎻掑叆鎿嶄綔鏃ュ織
                 new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "绌烘墭鍏ュ簱", model.PalletNo, "娣诲姞", $"鍦≒DA涓婃坊鍔犱簡绌烘墭鐩樿泛", (int)model.CreateUser);
+
+                return strMsg;
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                throw ex;
+            }
+        }
+
+        // 鍙犳墭鏈虹粦瀹氱┖鎵樼洏
+        public string BindNullPallets(PalletsBind model)
+        {
+            string strMsg = "";
+            string type = model.BindType == "0" ? "PDA" : "鍙犳墭鏈�";
+            try
+            {
+                var datetime = Db.GetDate();
+
+                //鑾峰彇鎵樼洏缁戝畾淇℃伅
+                string str = "select * from BllPalletBind where IsDel = '0' and PalletNo = @palletno and Status = '0' ";
+                List<PalletBindVm> list = Db.Ado.SqlQuery<PalletBindVm>(str, new
+                {
+                    palletno = model.PalletNo //鎵樼洏鍙�
+                });
+                //鍒ゆ柇鏄惁宸茬粦瀹氳鎵樼洏
+                if (list.Count > 0)
+                {
+                    strMsg = "-1:璇ユ墭鐩樺凡琚粦瀹�!";
+                    return strMsg;
+                }
+                if (string.IsNullOrEmpty(model.PalletNo))
+                {
+                    strMsg = "-1:鎵樼洏鍙蜂笉鍙负绌�!";
+                    return strMsg;
+                }
+                if (model.Qty == null || model.Qty == 0)
+                {
+                    strMsg = "-1:绌烘墭鐩樻暟閲忎笉鍙负绌�!";
+                    return strMsg;
+                }
+                //鑾峰彇鎵樼洏淇℃伅
+                var pallet = Db.Queryable<SysPallets>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo);
+
+                if (pallet == null)
+                {
+                    strMsg = "-1:鎵樼洏淇℃伅涓虹┖!";
+                    return strMsg;
+                }
+                if (pallet.Status != "0")
+                {
+                    strMsg = "-1:璇ユ墭鐩樻鍦ㄤ娇鐢�!";
+                    return strMsg;
+                }
+
+                Db.BeginTran();
+
+                // 鎻掑叆鎵樼洏缁戝畾琛�
+                var modelpb = new BllPalletBind
+                {
+                    ASNNo = "",
+                    ASNDetailNo = 0,
+                    TaskNo = "", //浠诲姟鍙�
+                    PalletNo = model.PalletNo,
+                    Qty = (int)model.Qty,
+                    Status = "0", //绛夊緟鎵ц
+                    Type = "1", //0 鐗╂枡鎵� 1 绌烘墭
+                    LotNo = "",
+                    LotText = "",
+                    SupplierLot = "",
+                    InspectMark = "0", //0 鍚� 1 鏄�
+                    BitPalletMark = "0",
+                    IsBale = "0",
+                    IsBelt = "0",
+                    CreateTime = Db.GetDate()
+                };
+                var id = Db.Insertable(modelpb).ExecuteReturnIdentity();
+
+                var modelbb = new BllBoxInfo
+                {
+                    ASNNo = "",
+                    ASNDetailNo = null,
+                    BindNo = id,
+                    PalletNo = model.PalletNo,
+                    Status = "1",
+                    CompleteTime = DateTime.Now,
+                    Qty = (int)model.Qty,
+                    FullQty = null,
+                    SkuNo = "100099",
+                    SkuName = "鎵樼洏",
+                    LotNo = "",
+                    LotText = "",
+                    SupplierLot = "",
+                    InspectStatus = "1",
+                    Origin = type,
+                    BoxNo = "",
+                    BoxNo2 = "",
+                    BoxNo3 = "",
+                    InspectMark = "",
+                    BitBoxMark = "0",
+
+                    CreateTime = datetime
+                };
+                Db.Insertable(modelbb).ExecuteCommand();
+
+
+                // 鏇存敼鎵樼洏浣跨敤鐘舵��
+                string sqlStr = string.Empty;
+                sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{model.PalletNo}';";
+                Db.Ado.ExecuteCommand(sqlStr);
+                Db.CommitTran();
+
+                // 鎻掑叆鎿嶄綔鏃ュ織
+                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "绌烘墭鍏ュ簱", model.PalletNo, "娣诲姞", $"鍦≒DA涓婃坊鍔犱簡绌烘墭鐩樿泛", 1);
 
                 return strMsg;
             }
@@ -1646,8 +1762,8 @@
                     SupplierLot = "",
                     InspectMark = "0",
                     BitPalletMark = "1",
-                    IsBale = "0",
-                    IsBelt = "0",
+                    IsBale = arrivalnotice.IsBale,
+                    IsBelt = arrivalnotice.IsBelt,
                     CreateUser = userId
                 };
                 // 鎻掑叆鎵樼洏缁戝畾琛�
@@ -1720,8 +1836,8 @@
                         BitPalletMark = "1",
                         InspectStatus = sku.IsInspect,// 缁勭洏鐨勬椂鍊欏氨瑕侀粯璁よ瀹氬ソ鏄惁鍚堟牸
                         PackagNo = sku.PackagNo,
-                        IsBale = null,
-                        IsBelt = null,
+                        IsBale = arrivalnotice.IsBale,
+                        IsBelt = arrivalnotice.IsBelt,
                         CreateUser = userId,
                         CreateTime = serverTime
                     };
@@ -1794,7 +1910,7 @@
 
         #region 浜у搧缁勬墭
 
-        public void GetBoxInfoByFuMa(string boxNo,string url)
+        public void GetBoxInfoByFuMa(string boxNo,string url,string fuMaTokenUrl,string levelType)
         {
             try
             {
@@ -1865,23 +1981,86 @@
                 #endregion
 
                 #region 姝e紡鐗堟湰
+                var token = new Token().GetFuMaToken(fuMaTokenUrl);
+                var getParentVal = levelType == "1" ? "true" : "false";
+                var getChildrenVal = levelType == "3" ? "true" : "false";
+                Dictionary<string, string> paramDic = new Dictionary<string, string>
+                {
+                    { "Token", token }, //鍒嗛厤鐨勪护鐗岋紙鍙橀噺锛�
+                    { "Barcode", boxNo },//瑕佹煡璇㈢殑鏉$爜
+                    { "getParent", getParentVal },//鏄惁鏌ヨ鐖剁爜
+                    { "getChildren", getChildrenVal } //鏄惁鏌ヨ瀛愮爜
+                };
 
+                //绋嬪簭姝e紡鍙戝竷鍚庢斁寮�
+                var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
+                var response = HttpHelper.DoGet(url, "璧嬬爜", "鑾峰彇绠辩爜淇℃伅", paramDic);
+                var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
 
-                ////绋嬪簭姝e紡鍙戝竷鍚庢斁寮�
-                //var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
-                //var response = HttpHelper.DoPost(url, jsonData, "鑾峰彇绠辩爜淇℃伅", "璧嬬爜");
-                //var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
+                //瑙f瀽杩斿洖鏁版嵁 
+                var fuMaModel = JsonConvert.DeserializeObject<FuMaGetBoxModel>(response);
+                if (fuMaModel.IsSuccess)
+                {
+                    //璧嬬爜杩斿洖淇℃伅鎴愬姛鐘舵��
+                    if (fuMaModel.Product == null || fuMaModel.Barcodes.Count == 0)
+                    {
+                        throw new Exception("浜у搧淇℃伅鎴栫鏀俊鎭负绌�");
+                    }
 
-                ////瑙f瀽杩斿洖鏁版嵁 
-                //var fuMaModel = JsonConvert.DeserializeObject<FuMaModel>(response);
-                //if (fuMaModel.Success == 0)
-                //{
+                    foreach (var item in fuMaModel.Barcodes)
+                    {
+                        if (item.Barcode != boxNo)
+                        {
+                            throw new Exception("鑾峰彇淇℃伅涓嶄竴鑷�");
+                        }
 
-                //}
-                //if (fuMaModel.Success == -1)
-                //{
-                //    throw new Exception($"璧嬬爜绯荤粺杩斿洖鐘舵�佸紓甯革細{fuMaModel.Message}");
-                //}
+                        var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.Product.ProductCode);
+                        if (sku == null)
+                        {
+                            throw new Exception("鏈煡璇㈠埌绠辩爜涓殑鐗╂枡淇℃伅");
+                        }
+                        var boxInfo = new BllBoxInfo()
+                        {
+                            ASNNo = "",
+                            //ASNDetailNo = 0,
+                            OrderCode = "",
+                            //BindNo = 0,
+                            BoxNo = item.Barcode,
+                            BoxNo2 = item.Barcode,
+                            BoxNo3 = item.Barcode,
+                            PalletNo = "",
+                            Qty = item.BoxItemQty,
+                            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.Spec,
+                            PackageStandard = fuMaModel.Product.PackageSpec,
+                            //StoreTime = item.StoreTime,
+                            //QtyOrd = item.QtyOrd,
+                            //QtyCount = item.QtyCount,
+                            CreateUser = 0,
+                            CreateTime = comTime,
+                        };
+                        list.Add(boxInfo);
+                    }
+                    Db.Insertable(list).ExecuteCommand();
+                }
+                else
+                {
+                    //璧嬬爜杩斿洖淇℃伅澶辫触鐘舵��
+                    throw new Exception($"璧嬬爜绯荤粺杩斿洖鐘舵�佸紓甯革細{fuMaModel.Message}");
+                }
                 #endregion
 
             }
@@ -1896,7 +2075,7 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model)
+        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url, string fuMaTokenUrl)
         {
             try
             {
@@ -1916,7 +2095,7 @@
                             var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
                             if (count == 0)
                             {
-                                GetBoxInfoByFuMa(model.BoxNo, ""); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
+                                GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl,"1"); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
                             }
                         }
                     }
@@ -1953,7 +2132,7 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model)
+        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model, string url, string fuMaTokenUrl)
         {
             try
             {
@@ -2019,8 +2198,8 @@
                                 }
                                 else
                                 {
-                                   // GetBoxInfoByFuMa(model.BoxNo3, ""); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
-                                }                          
+                                    GetBoxInfoByFuMa(model.BoxNo3, url, fuMaTokenUrl,"3"); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
+                                }
                             }
                         }
                     }
@@ -2395,8 +2574,8 @@
                         SupplierLot = detail.SupplierLot,
                         InspectMark = "0",
                         BitPalletMark = "1",
-                        IsBale = "0",
-                        IsBelt = "0",
+                        IsBale = detail.IsBale,
+                        IsBelt = detail.IsBelt,
                         CreateUser = userId,
                         Demo = model.Demo,
 

--
Gitblit v1.8.0