From d567d9d6926abb103f3ab73402134daa6a09ef11 Mon Sep 17 00:00:00 2001
From: chengsc <Demo@DESKTOP-CPA90BF>
Date: 星期六, 02 十一月 2024 18:28:13 +0800
Subject: [PATCH] 修改问题

---
 Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs |  113 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 98 insertions(+), 15 deletions(-)

diff --git a/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs b/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
index a446c6b..8c3ef1b 100644
--- a/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
+++ b/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
@@ -32,7 +32,7 @@
         /// <returns></returns>
         public List<BllQualityInspectDto> GetBllQualityList(BllQualityInspect model)
         {
-            string str = "select q.Id Id,q.InspectNo InspectNo,q.ASNNo ASNNo,q.LotNo LotNo,q.SupplierLot SupplierLot,q.SkuNo SkuNo,q.SkuName SkuName,q.Standard Standard,q.PassQty PassQty,q.FailQty FailQty,q.Origin Origin,q.InspectTime InspectTime,q.IsOut IsOut,q.IsQualified IsQualified,q.IsDel IsDel,q.CreateTime CreateTime,u.RealName CreateUserName,q.UpdateTime UpdateTime,q.UpdateUser UpdateUserName from BllQualityInspect q left join SysUserInfor u on q.CreateUser = u.id where q.IsDel = @isdel";
+            string str = "select q.Id Id,q.InspectNo InspectNo,q.ASNNo ASNNo,q.Status Status,q.LotNo LotNo,q.SupplierLot SupplierLot,q.SkuNo SkuNo,q.SkuName SkuName,q.Standard Standard,q.PassQty PassQty,q.FailQty FailQty,q.Origin Origin,q.InspectTime InspectTime,q.IsOut IsOut,q.IsQualified IsQualified,q.IsDel IsDel,q.CreateTime CreateTime,u.RealName CreateUserName,q.UpdateTime UpdateTime,q.UpdateUser UpdateUserName from BllQualityInspect q left join SysUserInfor u on q.CreateUser = u.id where q.IsDel = @isdel";
 
             ////鍒ゆ柇鍏ュ簱鍗曞彿鏄惁涓虹┖
             //if (!string.IsNullOrEmpty(model.ASNNo))
@@ -131,40 +131,123 @@
 
             //if (quality != null)
             //{
-                ////鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
-                //if (isTui == 1)
-                //{
-                //    if (quality.ASNNo == model.ASNNo)
-                //    {
-                //        throw new Exception("褰撳墠閫�璐у叆搴撳崟宸插垱寤鸿川妫�淇℃伅锛岃鍕块噸澶嶅垱寤猴紒");
-                //    }
-                //}
+            ////鍒ゆ柇鏄惁涓洪��璐у叆搴撳崟
+            //if (isTui == 1)
+            //{
+            //    if (quality.ASNNo == model.ASNNo)
+            //    {
+            //        throw new Exception("褰撳墠閫�璐у叆搴撳崟宸插垱寤鸿川妫�淇℃伅锛岃鍕块噸澶嶅垱寤猴紒");
+            //    }
+            //}
             //    throw new Exception("褰撳墠鐗╂枡鍜屾壒娆″凡杩涜璐ㄦ锛岃鏍告煡锛�");
             //}
 
             ////鏌ユ壘鍚屾壒娆� 鍚屽崟鎹� 鍏ュ簱鍗曚俊鎭��
             //BllArrivalNoticeDetail arrivalDetail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.ASNNo == model.ASNNo && m.LotNo == model.LotNo);
-
+            model.Status = "0";//瀹℃牳鐘舵��
             model.Origin = "WMS"; //鏉ユ簮
             model.CreateTime = Db.GetDate(); //鍒涘缓鏃ユ湡
             model.SkuNo = sku.SkuNo; //鐗╂枡鍙�
             model.SkuName = sku.SkuName; //鐗╂枡鍚嶇О
-            model.PassQty = 0; //鍚堟牸鏁伴噺
-            model.FailQty = 0; //涓嶅悎鏍兼暟閲�
+            //model.PassQty = 0; //鍚堟牸鏁伴噺
+            //model.FailQty = 0; //涓嶅悎鏍兼暟閲�
             model.Standard = sku.Standard; //瑙勬牸
+            //model.SupplierLot = arrivalDetail.SupplierLot; //渚涜揣鎵规
+
+            //鏌ユ壘搴撳瓨鏄庣粏淇℃伅
+            //List<DataStockDetail> detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo).ToList();
+            //if (isTui == 1)
+            //{
+            //    detail = detail.Where(m=> m.ASNNo == model.ASNNo).ToList();
+            //}
+            //foreach (var item in detail)
+            //{
+            //    List<DataBoxInfo> box = Db.Queryable<DataBoxInfo>().Where(a => a.IsDel == "0" && a.StockDetailId == item.Id && a.SkuNo == model.SkuNo && a.LotNo == model.LotNo).ToList();
+            //    //鍒ゆ柇鍚堟牸鐘舵�佹槸鍚﹀悎鏍�
+            //    if (model.IsQualified == "1")
+            //    {
+            //        //鍚堟牸 鐩稿悓鎵规搴撳瓨淇℃伅鍏ㄩ儴鏀逛负鍚堟牸鐘舵�� 涓斿悎鏍兼暟閲忓鍔犱负鍚屾壒娆″悓鍗曞彿璇ョ墿鏂欏叏閮ㄦ暟閲忎箣鍜�
+            //        model.PassQty += item.Qty;
+            //        //淇敼搴撳瓨鏄庣粏鍚堟牸鐘舵��
+            //        item.InspectStatus = "1"; //1鍚堟牸
+            //        foreach (var b1 in box)
+            //        {
+            //            b1.InspectStatus = "1"; //1鍚堟牸
+            //        }
+            //    }
+            //    else //涓嶅悎鏍�
+            //    {
+            //        //涓嶅悎鏍� 鐩稿悓鎵规銆佸叆搴撳崟搴撳瓨淇℃伅鍏ㄩ儴鏀逛负涓嶅悎鏍肩墿鏂� 涓斾笉鍚堟牸鏁伴噺澧炲姞涓哄悓鎵规鍚屽崟鍙疯鐗╂枡鍏ㄩ儴鏁伴噺涔嬪拰
+            //        model.FailQty += item.Qty;
+            //        item.InspectStatus = "2"; //2涓嶅悎鏍�
+            //        foreach (var b1 in box)
+            //        {
+            //            b1.InspectStatus = "2"; //2涓嶅悎鏍�
+            //        }
+            //    }
+            //    Db.Updateable(box).ExecuteCommand();
+            //    Db.Updateable(item).ExecuteCommand();
+            //}
+            var isquality = Db.Insertable(model).ExecuteCommand();
+
+            return isquality;
+        }
+
+
+        /// <summary>
+        /// 璐ㄦ澶嶆牳淇℃伅
+        /// </summary>
+        /// <param name="model">璐ㄦ淇℃伅瀹炰綋妯″瀷</param>
+        /// <returns></returns>
+        public int FinshQuality(int id,string type,int userId)
+        {
+            //楠岃瘉璐ㄦ鍙锋槸鍚︿负绌�
+            if (string.IsNullOrEmpty(type))
+            {
+                throw new Exception("鐘舵�佷笉鑳戒负绌猴紒");
+            }
+            var model = Db.Queryable<BllQualityInspect>().First(m=>m.IsDel == "0" && m.Id == id);
+            if (model == null)
+            {
+                throw new Exception("鏈煡璇㈠埌璐ㄦ淇℃伅");
+            }
+            int isTui = 0;
+            //楠岃瘉鍏ュ簱鍗曞彿鏄惁涓虹┖
+            if (!string.IsNullOrEmpty(model.ASNNo))
+            {
+                //鏌ヨ鏄惁涓洪��璐у叆搴撳崟鎹�
+                var Arrival = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.ASNNo && (a.Type == "3" || a.Type == "4"));
+                if (Arrival == null)
+                {
+                    throw new Exception("鍙湁鍏ュ簱鍗曟嵁涓洪��璐у叆搴撳崟鍙緭鍏ュ叆搴撳崟鍙凤紝璇锋牳鏌ワ紒");
+                }
+
+                //鑾峰彇鍏ュ簱鍗曟槑缁�
+                var ArrivalDetail = Db.Queryable<BllArrivalNoticeDetail>().First(a => a.IsDel == "0" && a.ASNNo == model.ASNNo && a.LotNo.Contains(model.LotNo) && a.SkuNo == model.SkuNo);
+                if (ArrivalDetail == null)
+                {
+                    throw new Exception("杈撳叆鐨勬壒娆℃垨鐗╂枡淇℃伅涓庡叆搴撳崟鎹笉绗︼紝璇锋牳鏌ワ紒");
+                }
+                isTui = 1;
+            }
+
+            
+          
+            model.Status = type; //瑙勬牸
+            model.IsQualified = type;
             //model.SupplierLot = arrivalDetail.SupplierLot; //渚涜揣鎵规
 
             //鏌ユ壘搴撳瓨鏄庣粏淇℃伅
             List<DataStockDetail> detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo).ToList();
             if (isTui == 1)
             {
-                detail = detail.Where(m=> m.ASNNo == model.ASNNo).ToList();
+                detail = detail.Where(m => m.ASNNo == model.ASNNo).ToList();
             }
             foreach (var item in detail)
             {
                 List<DataBoxInfo> box = Db.Queryable<DataBoxInfo>().Where(a => a.IsDel == "0" && a.StockDetailId == item.Id && a.SkuNo == model.SkuNo && a.LotNo == model.LotNo).ToList();
                 //鍒ゆ柇鍚堟牸鐘舵�佹槸鍚﹀悎鏍�
-                if (model.IsQualified == "1")
+                if (type == "1")
                 {
                     //鍚堟牸 鐩稿悓鎵规搴撳瓨淇℃伅鍏ㄩ儴鏀逛负鍚堟牸鐘舵�� 涓斿悎鏍兼暟閲忓鍔犱负鍚屾壒娆″悓鍗曞彿璇ョ墿鏂欏叏閮ㄦ暟閲忎箣鍜�
                     model.PassQty += item.Qty;
@@ -188,7 +271,7 @@
                 Db.Updateable(box).ExecuteCommand();
                 Db.Updateable(item).ExecuteCommand();
             }
-            var isquality = Db.Insertable(model).ExecuteCommand();
+            var isquality = Db.Updateable(model).ExecuteCommand();
 
             return isquality;
         }

--
Gitblit v1.8.0