From 2be1922b035c182c3c516427aa68be54badd6938 Mon Sep 17 00:00:00 2001
From: IPC-610 <IPC-610@DESKTOP-6LEOOS3>
Date: 星期四, 26 九月 2024 15:15:52 +0800
Subject: [PATCH] 登录页修改

---
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs |  174 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 156 insertions(+), 18 deletions(-)

diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 81ab6c3..d8ef676 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -18,6 +18,10 @@
 using Dm;
 using Model.InterFaceModel;
 using WMS.Entity.BllQualityEntity;
+using Newtonsoft.Json;
+using Utility.Tools;
+using System.Reflection;
+using System.IO;
 
 namespace WMS.BLL.BllPdaServer
 {
@@ -26,16 +30,33 @@
         private static readonly SqlSugarScope Db = DataContext.Db;
 
         // 鑾峰彇鍗曟嵁鍒楄〃
-        public List<ArrivalNoticeDto> GetArrivalNotices(ArrivalNoticeVm model)
+        public List<string> GetArrivalNotices(ArrivalNoticeVm model)
         {
             string sqlString = string.Empty;
             try
             {
                 // 鏈叧鍗曠殑鍗曟嵁
-                sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and Status != '4'  and IsDel='0' order by CreateTime;";
-                var modelList = Db.Ado.SqlQuery<ArrivalNoticeDto>(sqlString);
+                //sqlString = $"select * from BllArrivalNotice where Type in ({model.Type}) and Status != '3' and Status != '4'  and IsDel='0' order by CreateTime;";
+                //var modelList = Db.Ado.SqlQuery<ArrivalNoticeDto>(sqlString);
 
-                return modelList;
+                //model.Type锛氬崟鎹被鍨� 鍦ㄨ繖閲屼唬琛ㄥ墠绔〉绛剧被鍨嬶細鍗虫爣绛鹃〉绛撅細璐存爣鐗╂枡锛� 鏁伴噺椤电锛氫笉璐磋〃鐗╂枡锛屽師鍥狅細鎳掑緱鍔犲弬鏁�
+                var data = Db.Queryable<BllArrivalNotice>().Where(m => m.IsDel == "0" && m.Status != "3" && m.Status != "4").Select(m=>m.ASNNo).ToList();
+                var list = new List<string>();
+                if (model.Type == "0")//0璐存爣
+                {
+                    list = Db.Queryable<BllArrivalNoticeDetail>().Where(m =>m.IsDel == "0" && data.Contains(m.ASNNo) && !string.IsNullOrWhiteSpace(m.PackagNo)).Select(m => m.ASNNo).Distinct().ToList();
+                }
+                else if(model.Type == "1")//1涓嶈创鏍�
+                {
+                    list = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && data.Contains(m.ASNNo) && string.IsNullOrWhiteSpace(m.PackagNo)).Select(m=>m.ASNNo).Distinct().ToList();
+                }
+                else
+                {
+                    throw new Exception("椤电绫诲瀷鍙傛暟閿欒");
+                }
+                
+
+                return list;
             }
             catch (Exception ex)
             {
@@ -415,7 +436,7 @@
                     UpbindPalletNo = upBindPalletNo,
                     PalletNo2 = bindVms[0].PalletNo2,
                     PalletNo3 = bindVms[0].PalletNo3,
-                    Qty = (int)bindVms[0].Qty,
+                    Qty = bindVms[0].Qty,
                     LotNo = bindVms[0].LotNo,
                     LotText = bindVms[0].LotText,
                     SupplierLot = bindVms[0].SupplierLot,
@@ -801,7 +822,7 @@
                             return strMsg;
                         }
                         #endregion
-                        var pallQty = 0;//鎵樼洏涓婃暟閲�
+                        decimal pallQty = 0;//鎵樼洏涓婃暟閲�
                         var boxinfo2 = boxinfo.Where(w => w.SkuNo == noticeItem.SkuNo && w.LotNo == noticeItem.LotNo && w.PalletNo == model.PalletNo).ToList();
                         if (boxinfo2.Count <= 0)
                         {
@@ -1402,7 +1423,7 @@
                 {
                     throw new Exception("-1:绠辩爜淇℃伅涓嶅瓨鍦紝璇锋牳鏌�!");
                 }
-                var bNum = 0;//鏁伴噺
+                decimal bNum = 0;//鏁伴噺
                 //楠岃瘉绠辩爜鏄惁宸茬粦瀹氭墭鐩�
                 foreach (var item in boxinfo)
                 {
@@ -1685,6 +1706,104 @@
         }
 
         #region 浜у搧缁勬墭
+
+        public void GetBoxInfoByFuMa(string boxNo,string url)
+        {
+            try
+            {
+                var list = new List<BllBoxInfo>();
+
+                var data = new { BoxNo = boxNo };
+                var jsonData = JsonConvert.SerializeObject(data);
+
+                #region 娴嬭瘯鐗堟湰
+
+                //璇诲彇json鏂囦欢锛屾坊鍔犳暟鎹�
+                var ss = AppDomain.CurrentDomain.BaseDirectory;
+                string filePath = Path.Combine(ss, "CreateBoxInfo.json");
+                string json = File.ReadAllText(filePath);
+                var person = JsonConvert.DeserializeObject<List<BllBoxInfo>>(json);
+
+                var comTime = DateTime.Now;
+                //娣诲姞绠辩爜淇℃伅琛ㄤ腑  //鏆傛椂杩欎簺鍐�--娣诲姞鏁版嵁锛屽悗缁渶瑕佸拰璧嬬爜绯荤粺瀵规帴鍚� 鏍规嵁鏄庣‘杩斿洖鐨勬暟鎹牸寮忔洿鏀�
+                foreach (var item in person)
+                {
+                    if (item.BoxNo!= boxNo)
+                    {
+                        continue;
+                    }
+
+                    var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel =="0" && m.SkuNo == item.SkuNo);
+                    if (sku == null)
+                    {
+                        continue;
+                    }
+                    var boxInfo = new BllBoxInfo()
+                    {
+                        ASNNo = "",
+                        //ASNDetailNo = 0,
+                        OrderCode = "",
+                        //BindNo = 0,
+                        BoxNo = item.BoxNo,
+                        BoxNo2 = item.BoxNo2,
+                        BoxNo3 = item.BoxNo3,
+                        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();
+
+                #endregion
+
+                #region 姝e紡鐗堟湰
+
+
+                ////绋嬪簭姝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<FuMaModel>(response);
+                //if (fuMaModel.Success == 0)
+                //{
+
+                //}
+                //if (fuMaModel.Success == -1)
+                //{
+                //    throw new Exception($"璧嬬爜绯荤粺杩斿洖鐘舵�佸紓甯革細{fuMaModel.Message}");
+                //}
+                #endregion
+
+            }
+            catch (Exception e)
+            {
+                throw new Exception(e.Message);
+            }
+        }
+
         /// <summary>
         /// 鏍规嵁绠辩爜鑾峰彇鏍囩绠辩爜淇℃伅
         /// </summary>
@@ -1697,6 +1816,19 @@
                 if (string.IsNullOrEmpty(model.BoxNo))
                 {
                     throw new Exception("璇锋壂鎻忓绠辨潯鐮�!");
+                }
+                if (!string.IsNullOrWhiteSpace(model.ASNNo))
+                {
+                    var asnData = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == model.ASNNo);
+                    if (asnData != null && (asnData.Type == "0" || asnData.Type == "3"))
+                    {
+                        var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo);
+                        if (count == 0)
+                        {
+                            GetBoxInfoByFuMa(model.BoxNo, ""); //浠庤祴鐮佺郴缁熻幏鍙栫鐮佷俊鎭�
+                        }
+                    }
+                    
                 }
                 string sqlString = $@"SELECT 
                                         ASNNo,
@@ -1711,7 +1843,7 @@
                                         AND BoxNo = '{model.BoxNo}'
                                       GROUP BY ASNNo,BoxNo,SkuNo,SkuName,LotNo; ";
                 var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
-                if (models == null)
+                if (models.Count == 0)
                 {
                     throw new Exception("绠辩爜淇℃伅涓嶅瓨鍦�!");
                 }
@@ -2090,7 +2222,7 @@
                     var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
                     foreach (var g in boxGroup)
                     {
-                        var boxFullQty = 0;//绠卞唴鎬绘暟閲�
+                        decimal boxFullQty = 0;//绠卞唴鎬绘暟閲�
                         foreach (var box in g)
                         {
                             if (box.BindNo != null && box.BindNo != 0)
@@ -2196,10 +2328,10 @@
             try
             {
                 #region 楠岃瘉淇℃伅
-                if (string.IsNullOrEmpty(model.ASNNo))
-                {
-                    throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!");
-                }
+                //if (string.IsNullOrEmpty(model.ASNNo))
+                //{
+                //    throw new Exception("鍏ュ簱鍗曚笉鑳戒负绌�!");
+                //}
                 if (string.IsNullOrEmpty(model.PalletNo))
                 {
                     throw new Exception("鎵樼洏鏉$爜涓嶈兘涓虹┖!");
@@ -2466,7 +2598,7 @@
                         SendDate = serverTime,  //鍙戦�佹椂闂�
                         BackDate = serverTime,  //杩斿洖鏃堕棿
                         StartLocat = "",//璧峰浣嶇疆
-                        EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆
+                        EndLocat = model.LocatNo,//鐩爣浣嶇疆
                         PalletNo = bindInfo.PalletNo,//鎵樼洏鐮�
                         IsSend = 0,//鏄惁鍙啀娆′笅鍙�
                         IsCancel = 0,//鏄惁鍙彇娑�
@@ -2584,14 +2716,14 @@
                         SendDate = DateTime.Now,  //鍙戦�佹椂闂�
                         BackDate = DateTime.Now,  //杩斿洖鏃堕棿
                         StartLocat = "",//璧峰浣嶇疆
-                        EndLocat = "鍔涜骞冲簱",//鐩爣浣嶇疆
+                        EndLocat = model.LocatNo,//鐩爣浣嶇疆
                         PalletNo = model.PalletNo,//鎵樼洏鐮�
                         IsSend = 0,//鏄惁鍙啀娆′笅鍙�
                         IsCancel = 0,//鏄惁鍙彇娑�
                         IsFinish = 0,//鏄惁鍙畬鎴�
                         Type = "0",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟  2 绉诲簱浠诲姟
                         Status = "2",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
-                        OrderType = "0",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
+                        OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗�  2 鐩樼偣鍗�  3 绉诲簱鍗�
                         Msg = "鍔涜骞冲簱鐨勫洖搴撲换鍔�",
                     };
                     Db.Insertable(exTask).ExecuteCommand();
@@ -2603,8 +2735,14 @@
                 //淇敼鍌ㄤ綅淇℃伅                                        
                 Db.Updateable(storageLocat).ExecuteCommand();
 
-                new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser);
-
+                if (iscount == 1)
+                {
+                    new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愭墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳洖娴佸叆搴撴搷浣�", (int)model.CreateUser);
+                }
+                else
+                {
+                    new OperationASNServer().AddLogOperationAsn("PDA妯″潡", "骞冲簱鍏ュ簱", model.PalletNo, "瀹屾垚", $"鍦≒DA涓婂畬鎴愬崟鎹彿涓猴細{model.ASNNo}鐨勬墭鐩樼爜涓猴細{model.PalletNo}鐨勫钩搴撳叆搴撴搷浣�", (int)model.CreateUser);
+                }
                 Db.CommitTran();
             }
             catch (Exception ex)

--
Gitblit v1.8.0