From 6aa034c0c53cc7d49302dea596864fc61c705dda Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期五, 01 十一月 2024 18:56:43 +0800
Subject: [PATCH] 修改问题

---
 Wms/Utility/Tools/HttpHelper.cs          |   16 ++
 Wms/Wms/appsettings.json                 |    2 
 Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs |    4 
 Wms/Wms/Tools/ApiUrlConfig.cs            |    9 +
 Wms/Wms/Controllers/PdaAsnController.cs  |   12 +
 Wms/Model/InterFaceModel/HttpModel.cs    |  165 +++++++++++++++++++++++
 Wms/WMS.BLL/SysServer/Token.cs           |   92 +++++++++++++
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |   74 +++++++++-
 8 files changed, 352 insertions(+), 22 deletions(-)

diff --git a/Wms/Model/InterFaceModel/HttpModel.cs b/Wms/Model/InterFaceModel/HttpModel.cs
index bb9669c..8ae086a 100644
--- a/Wms/Model/InterFaceModel/HttpModel.cs
+++ b/Wms/Model/InterFaceModel/HttpModel.cs
@@ -850,20 +850,181 @@
     #region FuMa-Model
 
     /// <summary>
-    /// 鍙戦�佹帴鏀惰祴鐮佺郴缁熸帴鍙e弬鏁扮殑model
+    /// 鎺ユ敹璧嬬爜绯荤粺鎺ュ彛杩斿洖鐨勫弬鏁� model
     /// </summary>
     public class FuMaModel
     {
         /// <summary>
         /// 鐘舵�佺爜 0 鎴愬姛 -1澶辫触
         /// </summary>
-        public int Success { get; set; }
+        public bool IsSuccess { get; set; }
         /// <summary>
         /// 淇℃伅璇︽儏
         /// </summary>
         public string Message { get; set; }
     }
 
+    /// <summary>
+    /// 鑾峰彇绠辩爜淇℃伅鍙傛暟Model
+    /// </summary>
+    public class FuMaGetBoxModel:FuMaModel
+    {
+        /// <summary>
+        /// 浜у搧淇℃伅
+        /// </summary>
+        public ProductModel Product { get; set; }
+        /// <summary>
+        /// 绠辨敮淇℃伅
+        /// </summary>
+        public List<BarcodesModel> Barcodes { get; set; }
+        /// <summary>
+        /// 鍖呰姣斾緥
+        /// </summary>
+        public string PkgRatio { get; set; }
+        /// <summary>
+        /// 鏁寸灏忓寘瑁呮暟閲�
+        /// </summary>
+        public decimal BoxItemQty { get; set; }
+        /// <summary>
+        /// 鐗╂枡缂栫爜
+        /// </summary>
+        public string MaterialNum { get; set; }
+        /// <summary>
+        /// 鏍囧噯閲嶉噺
+        /// </summary>
+        public decimal StandarWeight { get; set; }
+        /// <summary>
+        /// 浜х嚎鍚嶇О
+        /// </summary>
+        public string LineName { get; set; }
+        /// <summary>
+        /// 杞﹂棿鍚嶇О
+        /// </summary>
+        public string WorkShop { get; set; }
+        /// <summary>
+        /// 璐熻矗浜�
+        /// </summary>
+        public string HeadMan { get; set; }
+
+    }
+    public class ProductModel
+    {
+        /// <summary>
+        /// 浜у搧缂栧彿
+        /// </summary>
+        public string ProductCode { get; set; }
+        /// <summary>
+        /// 浜у搧鍚嶇О
+        /// </summary>
+        public string ProductName { get; set; }
+        public int SubtypeId { get; set; }
+        /// <summary>
+        /// 瀛愮被缂栫爜
+        /// </summary>
+        public string SubType { get; set; }
+        public string Type { get; set; }
+        /// <summary>
+        /// 瑙勬牸
+        /// </summary>
+        public string Spec { get; set; }
+        /// <summary>
+        /// 鍖呰瑙勬牸
+        /// </summary>
+        public string PackageSpec { get; set; }
+        /// <summary>
+        /// 鍖呰鍗曚綅
+        /// </summary>
+        public string PackUnit { get; set; }
+        public string PhysicDetailType { get; set; }
+        public bool IsSpecial { get; set; }
+        public bool Is789 { get; set; }
+        /// <summary>
+        /// 鎵瑰噯鏂囧彿
+        /// </summary>
+        public string AuthorizedNo { get; set; }
+        public List<string> PkgRatio { get; set; }
+
+    }
+
+    public class BarcodesModel
+    {
+        /// <summary>
+        /// 绠卞彿/鏀彿
+        /// </summary>
+        public string Barcode { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public int ScanTaskId { get; set; }
+        /// <summary>
+        /// 鐢熶骇鎵瑰彿
+        /// </summary>
+        public string BatchNo { get; set; }
+
+        /// <summary>
+        /// 鎷肩鍚庣殑鎵瑰彿
+        /// </summary>
+        public string MixedBatchNo { get; set; }
+        /// <summary>
+        /// 鍖呰绾у埆
+        /// </summary>
+        public string Level { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string ParentBarcode { get; set; }
+
+        /// <summary>
+        /// 鐘舵�侊紝鏁寸銆侀浂绠便�佹嫾绠�
+        /// </summary>
+        public string Status { get; set; }
+        /// <summary>
+        /// 绠卞唴灏忓寘瑁呮暟閲�
+        /// </summary>
+        public string BoxItemQty { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string ScanTime { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string MixedScanTime { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string MixedTaskId { get; set; }
+        /// <summary>
+        /// 鐗╂祦鍙�
+        /// </summary>
+        public string LogisticsNum { get; set; }
+        /// <summary>
+        /// 鍖呰浜�
+        /// </summary>
+        public string PackageMan { get; set; }
+        /// <summary>
+        /// 鎵樼洏鐮�
+        /// </summary>
+        public string PalletCode { get; set; }
+        /// <summary>
+        /// 鐢熶骇鏃ユ湡
+        /// </summary>
+        public string ProductionDate { get; set; }
+        /// <summary>
+        /// 鏈夋晥鏈熻嚦
+        /// </summary>
+        public string ExpirationDate { get; set; }
+        /// <summary>
+        /// 瀹為檯閲嶉噺
+        /// </summary>
+        public decimal Weight { get; set; }
+        /// <summary>
+        /// 绠卞唴浠舵暟
+        /// </summary>
+        public int MinLevelCount { get; set; }
+    }
+    
     #endregion
 
 }
diff --git a/Wms/Utility/Tools/HttpHelper.cs b/Wms/Utility/Tools/HttpHelper.cs
index 28bef60..2f7b637 100644
--- a/Wms/Utility/Tools/HttpHelper.cs
+++ b/Wms/Utility/Tools/HttpHelper.cs
@@ -65,17 +65,29 @@
             }
         }
 
-        public static string DoGet(string url, Dictionary<string, string> paramDic = null, Dictionary<string, string> headerDic = null)
+        public static string DoGet(string url, string str, string logStr, Dictionary<string, string> paramDic = null,  Dictionary<string, string> headerDic = null)
         {
             var paramString = GetUrlParamString(paramDic);
             var request = GetHttpWebRequest(url + paramString, headerDic, "GET");
             request.ContentType = "application/json";
+            //log璺緞
+            var logStr2 = $@".\log\{str}\{logStr}" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
             try
             {
-                return GetResponseString(request);
+
+               
+                //璁板綍log
+                LogFile.SaveLogToFile($"{str}锛�( {paramString} ),", logStr2);
+                var requestData = GetResponseString(request);
+                //璁板綍log
+                LogFile.SaveLogToFile($"{str}鍙嶉锛�( {requestData} ),", logStr2);
+                return requestData;
             }
             catch (WebException ex)
             {
+
+                //璁板綍log
+                LogFile.SaveLogToFile($"{str}鍙嶉锛�( {ex.Message} ),", logStr2);
                 throw ex;
             }
         }
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 47e501b..7519147 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -1869,19 +1869,73 @@
 
                 ////绋嬪簭姝e紡鍙戝竷鍚庢斁寮�
                 //var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss")
-                //var response = HttpHelper.DoPost(url, jsonData, "鑾峰彇绠辩爜淇℃伅", "璧嬬爜");
+                ////var response = HttpHelper.DoGet(url, jsonData, "鑾峰彇绠辩爜淇℃伅", "璧嬬爜");
                 //var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss")
 
                 ////瑙f瀽杩斿洖鏁版嵁 
-                //var fuMaModel = JsonConvert.DeserializeObject<FuMaModel>(response);
-                //if (fuMaModel.Success == 0)
+                //var fuMaModel = JsonConvert.DeserializeObject<FuMaGetBoxModel>(response);
+                //if (fuMaModel.IsSuccess)
                 //{
+                //    //璧嬬爜杩斿洖淇℃伅鎴愬姛鐘舵��
+                //    if (fuMaModel.Product == null || fuMaModel.Barcodes.Count == 0)
+                //    {
+                //        throw new Exception("浜у搧淇℃伅鎴栫鏀俊鎭负绌�");
+                //    }
 
+                //    foreach (var item in fuMaModel.Barcodes)
+                //    {
+                //        if (item.Barcode != boxNo)
+                //        {
+                //            throw new Exception("鑾峰彇淇℃伅涓嶄竴鑷�");
+                //        }
+
+                //        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.BoxNo,
+                //        //    BoxNo2 = item.BoxNo2,
+                //        //    BoxNo3 = item.Barcode,
+                //        //    PalletNo = "",
+                //        //    Qty = item.Qty,
+                //        //    FullQty = item.FullQty,
+                //        //    Status = "0",
+                //        //    SkuNo = item.SkuNo,
+                //        //    SkuName = sku.SkuName,
+                //        //    LotNo = item.LotNo,
+                //        //    LotText = item.LotText,
+                //        //    SupplierLot = item.SupplierLot,
+                //        //    ProductionTime = item.ProductionTime,
+                //        //    ExpirationTime = item.ExpirationTime,
+                //        //    //CompleteTime = comTime,
+                //        //    InspectMark = item.InspectMark,
+                //        //    BitBoxMark = item.BitBoxMark,
+                //        //    InspectStatus = item.InspectStatus,
+                //        //    Origin = "璧嬬爜",
+                //        //    Standard = item.Standard,
+                //        //    PackageStandard = item.PackageStandard,
+                //        //    StoreTime = item.StoreTime,
+                //        //    QtyOrd = item.QtyOrd,
+                //        //    QtyCount = item.QtyCount,
+                //        //    CreateUser = 0,
+                //        //    CreateTime = comTime,
+                //        //};
+                //        //list.Add(boxInfo);
+                //    }
+                //    Db.Insertable(list).ExecuteCommand();
                 //}
-                //if (fuMaModel.Success == -1)
+                //else
                 //{
+                //    //璧嬬爜杩斿洖淇℃伅澶辫触鐘舵��
                 //    throw new Exception($"璧嬬爜绯荤粺杩斿洖鐘舵�佸紓甯革細{fuMaModel.Message}");
-                //}
+                //} 
                 #endregion
 
             }
@@ -1896,7 +1950,7 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model)
+        public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url)
         {
             try
             {
@@ -1916,7 +1970,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); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
                             }
                         }
                     }
@@ -1953,7 +2007,7 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model)
+        public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model, string url)
         {
             try
             {
@@ -2019,8 +2073,8 @@
                                 }
                                 else
                                 {
-                                   // GetBoxInfoByFuMa(model.BoxNo3, ""); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
-                                }                          
+                                    GetBoxInfoByFuMa(model.BoxNo3, url); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
+                                }
                             }
                         }
                     }
diff --git a/Wms/WMS.BLL/SysServer/Token.cs b/Wms/WMS.BLL/SysServer/Token.cs
index b73c03f..6f21cf1 100644
--- a/Wms/WMS.BLL/SysServer/Token.cs
+++ b/Wms/WMS.BLL/SysServer/Token.cs
@@ -59,7 +59,7 @@
                 };
                 #endregion
 
-                #region 閫氳繃鎺ュ彛鍙戦�佽嚦erp 鎴� mes
+                #region 閫氳繃鎺ュ彛鍙戦�佽嚦mes
                 //绯荤粺瀵规帴鍚庢斁寮�
                 var jsonData = JsonConvert.SerializeObject(data);
 
@@ -105,5 +105,95 @@
                 return "";
             }
         }
+
+        /// <summary>
+        /// 鑾峰彇璧嬬爜token浠ょ墝
+        /// </summary>
+        /// <param name="url">鑾峰彇璧嬬爜token浠ょ墝</param>
+        /// <returns></returns>
+        public string GetFuMaToken(string url)
+        {
+            try
+            {
+                var str = "";
+
+                //棣栧厛鍒ゆ柇绯荤粺鍐呮槸鍚︽湁token鍊硷紝鏁堟湡鏄惁澶辨晥
+                var sysToken = Db.Queryable<SysToken>().First(m => m.IsDel == "0" && m.SystemName == "FuMa");
+                if (sysToken != null && !string.IsNullOrWhiteSpace(sysToken.Token) && sysToken.ExpireTime > DateTime.Now)
+                {
+                    str = sysToken.Token;
+                    return str;  //杩斿洖token鍊�
+                }
+                return str;
+                //#region 鑾峰彇鏂扮殑浠ょ墝
+                ////瀵规帴鏃舵洿鏀硅矾寰�
+                //var user = MesConfig.MesUser;
+                //var pass = MesConfig.MesPassWord;
+                //var secretKey = Md5Tools.CalcMd5(pass);
+                //var nonce = Guid.NewGuid().ToString("N");
+                //var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
+
+                //var info = new string[] { user, secretKey, nonce, timestamp };
+                //Array.Sort(info, string.CompareOrdinal); //ASCII鎺掑簭
+                //var miyao = string.Join("", info); //鏁扮粍杞崲鎴愬瓧绗︿覆
+                //var sign = Md5Tools.CalcMd5(miyao);  //绛惧悕
+
+                //var data = new
+                //{
+                //    user = user,
+                //    nonce = nonce,
+                //    timestamp = timestamp,
+                //    sign = sign,
+                //    jwt = true,      //鏄惁杩斿洖JWT浠ょ墝
+                //};
+                //#endregion
+
+                //#region 閫氳繃鎺ュ彛鍙戦�佽嚦璧嬬爜
+                ////绯荤粺瀵规帴鍚庢斁寮�
+                //var jsonData = JsonConvert.SerializeObject(data);
+
+                //var response = HttpHelper.DoPost(url, jsonData, "FuMa鐢宠鑾峰彇浠ょ墝", "Fuma");
+
+                //var obj = JsonConvert.DeserializeObject<MesTokenModel>(response);//瑙f瀽杩斿洖鏁版嵁
+
+                //if (obj.status != "success")
+                //{
+                //    throw new Exception("涓婁紶澶辫触" + obj.message);
+                //}
+                //else
+                //{
+                //    var token = obj.Data.token;
+                //    var expireTime = obj.Data.expire_time;
+                //    var time = DateTime.Now.AddMilliseconds(double.Parse(expireTime));
+                //    if (sysToken == null)//娣诲姞
+                //    {
+                //        var addToken = new SysToken()
+                //        {
+                //            SystemName = "MES",
+                //            Token = token,
+                //            ExpireTime = time,
+                //            CreateUser = 0
+                //        };
+                //        Db.Insertable(addToken).ExecuteCommand();
+                //        return token;
+                //    }
+                //    else //淇敼
+                //    {
+                //        sysToken.Token = token;
+                //        sysToken.ExpireTime = time;
+                //        sysToken.UpdateTime = DateTime.Now;
+                //        Db.Updateable(sysToken).ExecuteCommand();
+                //        return token;
+                //    }
+                //}
+
+                //#endregion 
+            }
+            catch (Exception)
+            {
+                return "";
+            }
+        }
+
     }
 }
diff --git a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
index fcc6f1c..2fcd357 100644
--- a/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
+++ b/Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
@@ -77,9 +77,9 @@
         void GetBoxInfoByFuMa(string boxNo, string url);
 
         // 鏍规嵁绠辩爜鑾峰彇鏍囩绠辩爜淇℃伅
-        List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model);
+        List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url);
         // 鏍规嵁绠辩爜鑾峰彇鏍囩鏈�灏忚拷婧爜淇℃伅
-        List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model);
+        List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model,string url);
 
         //鏍规嵁鍗曟嵁鍙疯幏鍙栧崟鎹槑缁嗗垪琛�
         List<ArrivalNoticeDetailDto> GetBindArrivalNoticeDetails(ArrivalNoticeVm model);
diff --git a/Wms/Wms/Controllers/PdaAsnController.cs b/Wms/Wms/Controllers/PdaAsnController.cs
index 44647ca..977d562 100644
--- a/Wms/Wms/Controllers/PdaAsnController.cs
+++ b/Wms/Wms/Controllers/PdaAsnController.cs
@@ -1,10 +1,12 @@
 锘縰sing Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
 using Model.ModelVm;
 using Model.ModelVm.BllAsnVm;
 using Model.ModelVm.PdaVm;
 using System;
 using System.Security.Claims;
+using Wms.Tools;
 using WMS.Entity.BllAsnEntity;
 using WMS.IBLL.IPdaServer;
 
@@ -17,10 +19,12 @@
     {
         #region 渚濊禆娉ㄥ叆
         private readonly IPdaAsnServer _PdaAsnSvc;
+        private readonly ApiUrlConfig _config; //鎺ュ彛浜や簰璺緞
 
-        public PdaAsnController(IPdaAsnServer pdaAsnSvc)
+        public PdaAsnController(IPdaAsnServer pdaAsnSvc, IOptions<ApiUrlConfig> setting)
         {
-            _PdaAsnSvc = pdaAsnSvc;
+            _PdaAsnSvc = pdaAsnSvc; 
+            _config = setting.Value;
         }
         #endregion
 
@@ -524,7 +528,7 @@
         {
             try
             {
-                var models = _PdaAsnSvc.GetBindBoxInfos(model);
+                var models = _PdaAsnSvc.GetBindBoxInfos(model, _config.BoxHost + _config.FuMaGetBoxUrl);
 
                 return Ok(new { code = 0, msg = "鏍囩绠辩爜淇℃伅", data = models });
             }
@@ -544,7 +548,7 @@
         {
             try
             {
-                var models = _PdaAsnSvc.GetBindBoxInfo2s(model);
+                var models = _PdaAsnSvc.GetBindBoxInfo2s(model, _config.BoxHost + _config.FuMaGetBoxUrl);
 
                 return Ok(new { code = 0, msg = "鏍囩绠辩爜淇℃伅", data = models });
             }
diff --git a/Wms/Wms/Tools/ApiUrlConfig.cs b/Wms/Wms/Tools/ApiUrlConfig.cs
index e219376..74d62d2 100644
--- a/Wms/Wms/Tools/ApiUrlConfig.cs
+++ b/Wms/Wms/Tools/ApiUrlConfig.cs
@@ -67,6 +67,15 @@
 
         #endregion
 
+        #region 璧嬬爜绯荤粺
+
+        /// <summary>
+        /// 鑾峰彇绠辩爜淇℃伅
+        /// </summary>
+        public string FuMaGetBoxUrl { get; set; }
+
+        #endregion
+
         #region 涓嬫父绯荤粺
 
         /// <summary>
diff --git a/Wms/Wms/appsettings.json b/Wms/Wms/appsettings.json
index 2f6ab74..653ce2d 100644
--- a/Wms/Wms/appsettings.json
+++ b/Wms/Wms/appsettings.json
@@ -44,7 +44,7 @@
     "MesBeiLiaoUrl": "/port/mes/service/mes/save_morder_feedback", //澶囨枡鍙嶉(鍘熸枡澶囨枡鍒扮敓浜ц溅闂寸紦瀛樺尯)
     "MesGetTokenUrl": "/port/mes/service/system/sign_login", //鑾峰彇浠ょ墝
     // 璧嬬爜
-
+    "FuMaGetBoxUrl": "/port/mes/service/system/sign_login", //鑾峰彇璧嬬爜绠辩爜淇℃伅
 
     // AGV
     "GenAgvSchedulingTask": "http://IP:PORT/rcms/services/rest/hikRpcService/genAgvSchedulingTask", //鐢熸垚浠诲姟鍗曟帴鍙�

--
Gitblit v1.8.0