From f2bc08e28dda7022202f07217f6a3c150f818af7 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期一, 20 一月 2025 08:32:16 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/liudongl/jc24-wms

---
 Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs |  146 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 125 insertions(+), 21 deletions(-)

diff --git a/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs b/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
index 8c1d696..386cd35 100644
--- a/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
+++ b/Wms/WMS.BLL/BllQualityServer/QualityInspectServer.cs
@@ -1,10 +1,12 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Data;
+using System.Linq;
 using System.Text;
 using Model.ModelDto.BllQualityDto;
 using Model.ModelVm;
 using SqlSugar;
+using Utility.Tools;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
 using WMS.Entity.BllQualityEntity;
@@ -31,7 +33,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))
@@ -105,15 +107,15 @@
             {
                 throw new Exception("鎵规鍙蜂笉鍙负绌猴紝璇锋牳鏌ワ紒");
             }
-            //int isTui = 0;
+            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");
+                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("鍙湁鍏ュ簱鍗曟嵁涓洪��璐у叆搴撳崟鍙緭鍏� 鍏ュ簱鍗曞彿锛岃鏍告煡锛�");
+                    throw new Exception("鍙湁鍏ュ簱鍗曟嵁涓洪��璐у叆搴撳崟鍙緭鍏ュ叆搴撳崟鍙凤紝璇锋牳鏌ワ紒");
                 }
 
                 //鑾峰彇鍏ュ簱鍗曟槑缁�
@@ -122,7 +124,7 @@
                 {
                     throw new Exception("杈撳叆鐨勬壒娆℃垨鐗╂枡淇℃伅涓庡叆搴撳崟鎹笉绗︼紝璇锋牳鏌ワ紒");
                 }
-                //isTui = 1;
+                isTui = 1;
             }
 
             //鏌ユ壘璐ㄦ淇℃伅涓槸鍚﹀瓨鍦ㄥ悓鎵规璐ㄦ褰曞叆璁板綍
@@ -130,34 +132,136 @@
 
             //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.ASNNo == model.ASNNo && m.SkuNo == model.SkuNo && m.LotNo == model.LotNo).ToList();
+            //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="id"></param>
+        /// <param name="userNo"></param>
+        /// <param name="password"></param>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public int FinshQuality(int id,string userNo, string password, int userId)
+        {
+            var loginPwd = Md5Tools.CalcMd5(password);
+            var date = Db.Queryable<SysUserInfor>().First(m => m.IsDel == "0" && m.UserName == userNo && m.PassWord == loginPwd);
+
+            if (date == null) //璐﹀彿瀵嗙爜鏄惁姝g‘
+            {
+                throw new Exception("璐﹀彿瀵嗙爜涓嶆纭垨娌℃湁姝よ处鍙�");
+            }
+            if (date.Status != "0") //褰撳墠璐﹀彿鏄惁姝e父鍚敤
+            {
+                throw new Exception("褰撳墠璐﹀彿闈炲惎鐢ㄧ姸鎬�");
+            }
+           
+            var model = Db.Queryable<BllQualityInspect>().First(m=>m.IsDel == "0" && m.Id == id);
+            if (model == null)
+            {
+                throw new Exception("鏈煡璇㈠埌璐ㄦ淇℃伅");
+            }
+            if (date.Id == model.CreateUser)
+            {
+                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 = "1"; //瑙勬牸
+            model.UpdateTime = DateTime.Now;
+            model.UpdateUser = userId;
+            //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<BllBoxInfo> box = Db.Queryable<BllBoxInfo>().Where(a => a.IsDel == "0" && a.ASNNo == model.ASNNo && a.SkuNo == model.SkuNo && a.LotNo == model.LotNo).ToList();
+                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")
                 {
@@ -167,7 +271,7 @@
                     item.InspectStatus = "1"; //1鍚堟牸
                     foreach (var b1 in box)
                     {
-                        b1.InspectMark = "1"; //1鍚堟牸
+                        b1.InspectStatus = "1"; //1鍚堟牸
                     }
                 }
                 else //涓嶅悎鏍�
@@ -177,13 +281,13 @@
                     item.InspectStatus = "2"; //2涓嶅悎鏍�
                     foreach (var b1 in box)
                     {
-                        b1.InspectMark = "2"; //2涓嶅悎鏍�
+                        b1.InspectStatus = "2"; //2涓嶅悎鏍�
                     }
                 }
                 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