From 25c2291ded30737b07fb7c93e5e231cc64733d2a Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 19 八月 2025 16:15:29 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Sc_GroupOrderBillController.cs |  374 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 346 insertions(+), 28 deletions(-)

diff --git a/WebAPI/Controllers/Sc_GroupOrderBillController.cs b/WebAPI/Controllers/Sc_GroupOrderBillController.cs
index 1422d69..1bd4f32 100644
--- a/WebAPI/Controllers/Sc_GroupOrderBillController.cs
+++ b/WebAPI/Controllers/Sc_GroupOrderBillController.cs
@@ -21,28 +21,169 @@
         string HBillType = "2601";
 
         /// <summary>
+        /// 鎵绠辩爜鏂规硶
+        /// </summary>
+        /// <param name="HInterID">缁勬墭鍗旾D</param>
+        /// <param name="HBillNo">缁勬墭鍗昇o</param>
+        /// <param name="HBillTyp">缁勬墭鍗曠被鍨�</param>
+        /// <param name="HMaker">缁勬墭鍗曞埗鍗曚汉</param>
+        /// <param name="HBarCode_Pack">瑁呯鍗曟潯鐮�</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/GetPackBarCode")]
+        [HttpGet]
+        public object GetPackBarCode(int HInterID, string HBillNo, string HBillTyp, string HMaker, string HBarCode_Pack,string HOrgID)
+        {
+            try
+            {
+                if (HBarCode_Pack == null || HBarCode_Pack.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[3783-2-003]璇疯緭鍏ヨ绠辩爜锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    //鍒ゆ柇鏄惁宸叉壂鐮侊紝骞跺瓨鍏ョ紦瀛樿〃锛堣嫢鏈壂鐮侊級
+                    ds = oCN.RunProcReturn("exec h_p_PackToTemp " + HInterID + ",'" + HBillNo + "','" + HBillTyp + "','" + HMaker + "','" + HBarCode_Pack + "','"+ HOrgID + "'", "h_p_PackToTemp");
+                    if (ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-1-038]" + ds.Tables[0].Rows[0][1].ToString();//璇ヨ绠卞崟宸叉壂鐮侊紒
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //else
+                    //{
+                    //    //杩斿洖瑁呯鍗曟暟鎹�(宸插悎骞跺埌瀛樺偍杩囩▼鈥榟_p_PackToTemp鈥欎腑)
+                    //    ds = oCN.RunProcReturn("exec h_p_GroupOrderBill_GetPackBarCode '" + HBarCode_Pack + "'", "h_p_GroupOrderBill_GetPackBarCode");
+                    //}
+                }
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[3783-2-004]false锛佹棤鏁版嵁锛岃纭瑁呯鐮佹槸鍚﹀瓨鍦紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "[0000-1-037]Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-038]Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        /// </summary>
+        /// <param name="oMain">缁勬墭鍗曞疄渚嬪璞�</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/AddBill")]
+        [HttpPost]
+        public object AddBill([FromBody] JObject oMain)
+        {
+            var _value = oMain["oMain"].ToString();
+            string msg1 = _value.ToString();
+            try
+            {
+
+                //缁勬墭鍗曞弽搴忓垪鍖�
+                msg1 = "[" + msg1.ToString() + "]";
+                List<GroupOrderBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupOrderBill>>(msg1);
+                //鑾峰彇骞存湀鏃ュ苟鎷兼帴鎴愬瓧绗︿覆
+                string year = DateTime.Now.Year.ToString();
+                //string month = DateTime.Now.Month.ToString();
+                //string day = DateTime.Now.Day.ToString();
+                string nowDate = DateTime.Now.ToString("yyyyMMdd");
+                string HBillType = this.HBillType;//缁勬墭鍗曠被鍨�
+                long HInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                string HBillNo = list[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹甆o
+                string HMaker = list[0].HMaker;//鍒跺崟浜�
+                string HBatchNo = list[0].HBatchNo;//鍏ュ簱鎵规
+                string HBarCode_Cus = list[0].HBarCode_Cus;//瀹㈡埛鏍囩锛堥粦鏍囧彿锛�
+                long HOrgID = list[0].HOrgID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                //鏍¢獙榛戞爣鍙峰敮涓�鎬�
+                ds = oCN.RunProcReturn($"select * from Sc_PackUnionBillMain where HBarCode_Cus ='{HBarCode_Cus}'", "Sc_PackUnionBillMain");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"[3783-2-007]榛戞爣鍙穥HBarCode_Cus}宸插瓨鍦�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鐢熸垚鍞竴鏉$爜
+                ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + nowDate + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                oCN.RunProc("exec h_p_WMS_SetMaxNo '" + nowDate + "'");
+                string LSH = ClsPub.isStrNull(ds.Tables[0].Rows[0][0]);
+                string HBarCode_Pack = nowDate + LSH;
+                oCN.BeginTran();
+                //鎻掑叆涓昏〃
+                oCN.RunProc(
+                    "insert into Sc_PackUnionBillMain " +
+                    "(" +
+                        "HYear, HBillType, HInterID, HBillNo, HMaker" +
+                        ", HMakeDate, HPeriod, HDate, HRemark, HICMOInterID" +
+                        ", HICMOBillNo, HBarCode_Pack, HMaterID, HUnitID,HBatchNo,HBarCode_Cus,HProdOrgID" +
+                    ")" +
+                    "values" +
+                    "(" +
+                        "'" + year + "', '" + HBillType + "'," + HInterID + ", '" + HBillNo + "', '" + HMaker + "'" +
+                        ",GETDATE(),0,GETDATE(),' ',0" +
+                        ",' ','" + HBarCode_Pack + "',0,0,'" + HBatchNo + "','" + HBarCode_Cus + "','" + HOrgID +
+                    "')"
+                );
+                //鎻掑叆瀛愯〃
+                oCN.RunProc("exec h_p_SaveGroupOrder " + HInterID + "");
+                //鏍规嵁瀛愯〃姹囨�荤敓鎴怱c_PackUnionBillSub_Sum琛ㄨ褰�
+                oCN.RunProc("exec h_p_Sc_PackUnionBill_SumSubBill " + HInterID + ",'','',''");
+                //鎻掑叆鏉$爜妗f琛�
+                oCN.RunProc("exec h_p_SaveGroupOrderCodeToGy_BarCodeBill " + HInterID + "");
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-050]鏂板鍗曟嵁鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                //oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-051]Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
         /// 杩斿洖鍒楄〃
-        /// 浜х嚎缁勬墭鍗曞垪琛�
         /// </summary>
         /// <param name="sWhere">鎷兼帴鐨凷QL</param>
         /// <returns>object</returns>
         [Route("GroupOrderBill/List")]
         [HttpGet]
-        public object List(string sWhere,string user)
+        public object List(string sWhere)
         {
             DataSet ds;
             try
             {
-                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
-                //if (!DBUtility.ClsPub.Security_Log("Sc_GroupOrderBillList_Query", 1, false, user))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
-
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sWhere == null || sWhere.Equals(""))
                 {
@@ -56,23 +197,75 @@
                     sql += sql2;
                     ds = oCN.RunProcReturn(sql, "h_v_GroupOrderBillList");
                 }
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-045]鏃犳暟鎹紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "[0000-1-037]Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
 
-                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
-                //{
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = ds.Tables[0];
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-010]Exception锛�" + e.ToString();
+                objJsonResult.data = null;
                 return objJsonResult;
-                //}
-                //else
-                //{
-                //objJsonResult.code = "0";
-                //objJsonResult.count = 0;
-                //objJsonResult.Message = "鏃犳暟鎹�";
-                //objJsonResult.data = null;
-                //return objJsonResult;
-                //}
+            }
+        }
+
+        /// <summary>
+        /// 杩斿洖缂撳瓨鍒楄〃
+        /// </summary>
+        /// <param name="sWhere">鎷兼帴鐨凷QL</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/CacheList")]
+        [HttpGet]
+        public object CacheList(string sWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select top 1000 * from h_v_GroupOrderBillCacheList order by 鎵爜鏃堕棿 desc", "h_v_GroupOrderBillCacheList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_GroupOrderBillCacheList where 1 = 1 ";
+                    string sql = sql1 + sWhere;
+                    string sql2 = " order by 鎵爜鏃堕棿 desc";
+                    sql += sql2;
+                    ds = oCN.RunProcReturn(sql, "h_v_GroupOrderBillCacheList");
+                }
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳暟鎹紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
 
             }
             catch (Exception e)
@@ -85,7 +278,132 @@
             }
         }
 
+        /// <summary>
+        /// 鏍规嵁ID鍒犻櫎缂撳瓨琛ㄤ腑鎵爜璁板綍
+        /// </summary>
+        /// <param name="sHitemID">缂撳瓨琛↖D</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/DelCacheList")]
+        [HttpGet]
+        public object DelCacheList(long sHitemID)
+        {
+            try
+            {
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                oCn.RunProc("Delete from KF_PonderationBillMain_Temp where HitemID = " + sHitemID);
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�";
+                objJsonResult.data = e.ToString();
+                return objJsonResult;
+            }
+        }
 
-        //
+        /// <summary>
+        /// 鏍规嵁鍞竴鏉$爜鍒犻櫎缂撳瓨琛ㄤ腑鎵爜璁板綍
+        /// </summary>
+        /// <param name="BarCode">鍞竴鏉$爜</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/DelCacheListByBarCode")]
+        [HttpGet]
+        public object DelCacheListByBarCode(string BarCode)
+        {
+            try
+            {
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                oCn.RunProc("Delete from KF_PonderationBillMain_Temp where HBarCode = '" + BarCode + "' and HBillType = '2601'");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-008]鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-007]鍒犻櫎澶辫触锛�";
+                objJsonResult.data = e.ToString();
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁缁勬墭鍗曚富ID鍜屽瓙ID鍒犻櫎鍒楄〃涓璁板綍
+        /// </summary>
+        /// <param name="HInterID">缁勬墭鍗曚富ID</param>
+        /// <param name="HEntryID">缁勬墭鍗曞瓙ID</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/DelListRow")]
+        [HttpGet]
+        public object DelListRow(long HInterID, long HEntryID)
+        {
+            try
+            {
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                oCN.BeginTran();
+                oCn.RunProc("Delete from Sc_PackUnionBillMain where HInterID = " + HInterID);
+                oCn.RunProc("Delete from Sc_PackUnionBillSub where HInterID = " + HInterID + " and HEntryID = " + HEntryID);
+                //閲嶆柊鍒锋柊鏇存柊 姹囨�诲瓙琛� 鐨勮褰曞拰鏉$爜妗f
+                oCn.RunProc("Delete from Sc_PackUnionBillSub_Sum where HInterID = " + HInterID);
+                oCn.RunProc("Delete from Gy_BarCodeBill where HInterID = " + HInterID + " and HSourceBillType = '3772'");
+                //鏍规嵁瀛愯〃姹囨�荤敓鎴怱c_PackUnionBillSub_Sum琛ㄨ褰�
+                oCN.RunProc("exec h_p_Sc_PackUnionBill_SumSubBill " + HInterID + ",'','',''");
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�";
+                objJsonResult.data = e.ToString();
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁缁勬墭鍗曚富ID鍜屽瓙ID淇敼鍒楄〃涓璁板綍鐨勯粦鏍囧彿
+        /// </summary>
+        /// <param name="HInterID">缁勬墭鍗曚富ID</param>
+        /// <param name="HBarCode_Cus">榛戞爣鍙�</param>
+        /// <returns>object</returns>
+        [Route("GroupOrderBill/editListRowHBarCode_Cus")]
+        [HttpGet]
+        public object editListRowHBarCode_Cus(long HInterID, string HBarCode_Cus)
+        {
+            try
+            {
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                oCn.RunProc("update Sc_PackUnionBillMain set HBarCode_Cus = '" + HBarCode_Cus + "' where HInterID = " + HInterID);
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[[0000-1-067]]淇敼鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-066]淇敼澶辫触锛�";
+                objJsonResult.data = e.ToString();
+                return objJsonResult;
+            }
+        }
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1