From 84f084b5b5a4593d4e4e30d2c95b91ca0e0e3384 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 29 三月 2022 13:23:18 +0800
Subject: [PATCH] 查询过滤 仓库发料 拣料配送列表上查 页面优化

---
 WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 166 insertions(+), 0 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
index 07f34a6..7ce0f36 100644
--- a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
@@ -98,6 +98,17 @@
                     return objJsonResult;
                 }
 
+                ds = oCN.RunProcReturn($"select HISCheck from JIT_SendGoodsBillMain where HMainSourceInterID={HInterID} ", "JIT_SendGoodsBillMain");
+
+                if (ds.Tables[0].Rows.Count>0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "褰撳墠鍗曟嵁宸查厤閫�,涓嶈兘鍒犻櫎!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 oCN.RunProc($"exec Del_ComplementGoodsBillInfo {HInterID},{HEntryID},{HOrgID}");
 
                 objJsonResult.code = "1";
@@ -188,5 +199,160 @@
             }
         }
         #endregion
+
+        #region 浠撳簱鍙戞枡
+        //鍙傛暟
+        public class SendGoodsBill {
+            public int? 鏈嫞鏂欐暟閲� = 0;
+            public int? 鏈�澶ф嫞鏂欐暟閲� = 0;
+            public int? 鏈鎷f枡鏁伴噺 = 0;
+            public int? HEntryID = 0;
+            public int? HMaterID = 0;
+            public int? HWHID = 0;
+            public int? HSPID = 0;
+        }
+
+        [Route("Sc_ComplementGoods/JIT_SendGoodsBill")]
+        [HttpPost]
+        public object JIT_SendGoodsBill([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string[] sArray = _value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string SourceInterID = sArray[2].ToString();
+            string SourceBillNo = sArray[3].ToString();
+            try
+            {
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");
+
+                List<SendGoodsBill> listCa = new List<SendGoodsBill>();
+                //鑾峰彇琛ㄦ牸鏁版嵁闆嗗悎
+                listCa = JsonConvert.DeserializeObject<List<SendGoodsBill>>(msg2.ToString());
+
+                for (int i = 0; i < listCa.Count; i++)
+                {
+                    if (listCa[i].鏈鎷f枡鏁伴噺 > listCa[i].鏈�澶ф嫞鏂欐暟閲�)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鏈鎷f枡鏁伴噺瓒呰繃鏈�澶ф嫞鏂欐暟閲�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (listCa[i].鏈鎷f枡鏁伴噺 > listCa[i].鏈嫞鏂欐暟閲�)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鏈鎷f枡鏁伴噺瓒呰繃鏈嫞鏂欐暟閲�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                bool flag = false;
+                flag = AddSendGoodsBill(listCa, SourceInterID, SourceBillNo, user, ref DBUtility.ClsPub.sExeReturnInfo);
+
+
+                if (flag)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "閰嶉�佹垚鍔�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "閰嶉�佸け璐�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        //鏂板
+        public bool AddSendGoodsBill(List<SendGoodsBill> listCa, string SourceInterID, string SourceBillNo, string user, ref string sReturn)
+        {
+            try
+            {
+                oCN.BeginTran();
+
+                oCN.RunProc($"delete from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}'");
+
+                oCN.RunProc($"delete from JIT_SendGoodsBillSub where HInterID in (select HInterID from JIT_SendGoodsBillMain where HMainSourceInterID={SourceInterID} and HMainSourceBillNo='{SourceBillNo}')");
+
+                for (int i = 0; i < listCa.Count; i++)
+                {
+                    long InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo);
+                    string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true);
+
+                    //娣诲姞涓昏〃鏁版嵁
+                    oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" +
+                        ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" +
+                        ", HMainSourceBillNo, HMainSourceBillType)" +
+                       $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," +
+                       $" 0,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')");
+
+                    //娣诲姞瀛愯〃鏁版嵁
+                    oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" +
+                        ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate)" +
+                        $"values({InterID},'{HBillNo}',{i}, {listCa[i].HMaterID},{listCa[i].鏈鎷f枡鏁伴噺}," +
+                        $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE())");
+
+                    //淇敼璋冩嫧鏁伴噺
+                    oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY={listCa[i].鏈鎷f枡鏁伴噺} where HMaterID={listCa[i].HMaterID} " +
+                        $" and HSourceInterID=(select top 1 HSourceInterID from JIT_ComplementGoodsBillSub_LK " +
+                        $"where HMaterID={listCa[i].HMaterID} order by HSourceInterID ) and HInterID={SourceInterID}");
+                }
+
+                sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
+                oCN.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+        #endregion
+
+        #region 涓婃煡
+        [Route("Sc_ComplementGoods/ComplementGoodsList_Sc")]
+        [HttpGet]
+        public object ComplementGoodsList_Sc(string HInterID,string HEntryID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HEntryID}", "h_p_JIT_ComplementGoodsBillList_UpQuery");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1