From a5d691a24ef8fdb7155ecc9f6dd1bef843020f03 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期二, 20 二月 2024 13:28:10 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/BaseSet/Gy_CustomerController.cs |  352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 347 insertions(+), 5 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
index b811a22..29c81c0 100644
--- a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
@@ -42,7 +42,22 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                string sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'");
+                string sql1 = "";
+                //瀹㈡埛鍒跺畾
+                string sErr = "";
+                if (oSystemParameter.ShowBill(ref sErr))
+                {
+                    if (oSystemParameter.omodel.WMS_CampanyName == "涔斾竴")
+                    {
+                         sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 1=1");
+                    }
+                    else
+                    {
+                         sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 缁勭粐鍚嶇О='" + Organization + "'");
+                    }
+                }
+
+             
                 if (sWhere == null || sWhere.Equals(""))
                 {
                     ds = oCN.RunProcReturn(sql1 + sWhere + " order by 瀹㈡埛浠g爜 ", "h_v_Gy_CustomerList");
@@ -77,6 +92,49 @@
                 return objJsonResult;
             }
         }
+
+        #region 瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛] 鏌ヨ
+        /// <summary>
+        /// 杩斿洖瀹㈡埛瀛愯〃[鍏宠仈鐢ㄦ埛]鍒楄〃
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Gy_Customer/RelationUserlist")]
+        [HttpGet]
+        public object RelationUserlist(Int64 HCusID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select * from h_v_Gy_Customer_RelationUsers_Query where HCusID = " + HCusID + " order by 鐢ㄦ埛缂栫爜 asc";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_Customer_RelationUsers_Query");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
         /// <summary>
         /// 瀹㈡埛鍒楄〃淇敼鎸夐挳鏂规硶
@@ -115,6 +173,45 @@
                 return objJsonResult;
             }
         }
+
+
+        #region 鑾峰彇褰撳墠鏈�澶х殑瀹㈡埛浠g爜
+        [Route("Gy_Customer/getMaxCusNumber")]
+        [HttpGet]
+        public object getMaxCusNumber()
+        {
+            try
+            {
+                string sql = "select top(1) * from Gy_Customer order by HNumber desc";
+                ds = oCN.RunProcReturn(sql, "Gy_Customer");
+
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "灏氭湭瀛樺湪瀹㈡埛锛岃鑷富缁存姢瀹㈡埛浠g爜!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "";
+                    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
 
         /// <summary>
         /// 鑾峰彇鏈�澶у熀纭�璧勬枡ID
@@ -285,9 +382,9 @@
                     ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" +
                     ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" +
                     ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" +
-                    ",HCusTypeID) " +
+                    ",HCusTypeID,HCREATEORGID,HUSEORGID) " +
                     " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID +
-                    ", " + HLevel + ",0,'" + HStopflag + "','" + HRemark + "'" +
+                    ", " + HLevel + ",1,'" + HStopflag + "','" + HRemark + "'" +
                     ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" +
                     ",'" + HFax + "','" + HPostalCode + "','" + HEmail + "','" + HBank + "','" + HBankAccount + "'" +
                     ",'" + HTaxNum + "'," + HTaxRate + ",'" + HCountry + "','" + HCorMan + "','" + HEnglishName + "'" +
@@ -295,9 +392,25 @@
                     "," + HEmpID + "," + HCreditDate + "," + HCreditRatingDate + "," + HMaxCredRatingDate +
                     "," + HMonthUseQty + "," + HForecastCreditRating + "," + HCreditLevelID + "," + HCountAccrualRating +
                     "," + HSubsidyAccrualRating + "," + HCreditRating + "," + HMaxCreditRating +
-                    ", " + HCusTypeID + ")");
+                    ", " + HCusTypeID + ","+ HCreateOrgID + ","+ HUseOrgID + ")");
                 //淇敼涓婄骇涓洪潪鏈骇浠g爜
                 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+                //淇濆瓨鍚庢帶鍒�
+                string sql = "select * from Gy_Customer where HNumber = '" + HNumber + "' and HName = '" + HName + "' and HUSEORGID = " + HUseOrgID;
+                ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                HItemID = Int64.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());
+                ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl");
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString();
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 oCN.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -326,10 +439,12 @@
             {
                 var model = oMain["model"].ToString();
                 var custLocationModel = oMain["model"]["HCustLocationEntry"].ToString();
+                var custContactModel = oMain["model"]["HCustContactEntry"].ToString();
                 //鍙嶅簭鍒楀寲
                 model = "[" + model + "]";
                 List<Customer> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Customer>>(model);
                 List<Model.ClsGy_CustLocation_Model> custLocationls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_CustLocation_Model>>(custLocationModel);
+                List<Model.ClsGy_COMMONCONTACT_Model> custContactls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_COMMONCONTACT_Model>>(custContactModel);
                 string sql = string.Empty;
                 oCN.BeginTran();
                 sql = $"delete gy_Customer where HItemID = {lsmain[0].HItemID}";
@@ -379,10 +494,30 @@
                 }
                 sql = "set identity_insert Gy_CustLocation off";
                 oCN.RunProc(sql);
+
+                //瀹㈡埛_鏀惰揣鏂硅仈绯讳汉
+                sql = $"delete Gy_COMMONCONTACT where HCUSTID = {lsmain[0].HItemID}";
+                oCN.RunProc(sql);
+                sql = "set identity_insert Gy_COMMONCONTACT on";
+                oCN.RunProc(sql);
+                foreach (var item in custContactls)
+                {
+                    sql = $@"insert into Gy_COMMONCONTACT(HItemID,HCUSTID,HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag,
+                    HRemark,HHelpCode,HUseFlag,HMakeTime,HMakeEmp,HCheckEmp,HCheckTime,HModifyEmp,HModifyTime,HStopEmp,HStopTime,
+                    HUSEORGID,HCREATEORGID)
+                  values({item.HItemID},{item.HCUSTID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel}
+           ,{Convert.ToString(item.HEndFlag ? 1 : 0)},{Convert.ToString(item.HStopflag ? 1 : 0) },'{item.HRemark}','{item.HHelpCode}','{item.HUseFlag}'
+            ,'{item.HMakeTime}','{item.HMakeEmp}','{item.HCheckEmp}','{item.HCheckTime}','{item.HModifyEmp}'
+            ,'{item.HModifyTime}','{item.HStopEmp}','{item.HStopTime}',{item.HUSEORGID},{item.HCREATEORGID})";
+                    oCN.RunProc(sql);
+                }
+                sql = "set identity_insert Gy_COMMONCONTACT off";
+                oCN.RunProc(sql);
+
                 oCN.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+                objJsonResult.Message = "鏂板鍩虹璧勬枡鎴愬姛锛�";
                 //objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -536,6 +671,21 @@
                 //灏嗕笂绾� 涓洪潪鏈骇
                 oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                 //
+
+                //淇濆瓨鍚庢帶鍒�
+                ds = oCN.RunProcReturn("exec h_p_Gy_Customer_AfterSaveCtrl " + HItemID, "h_p_Gy_Customer_AfterSaveCtrl");
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "Exception锛�" + ds.Tables[0].Rows[0]["HBackRemark"].ToString();
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+
                 oCN.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -635,6 +785,198 @@
             }
         }
 
+
+        #region 瀹㈡埛瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Customer/AuditGy_Customer")]
+        [HttpGet]
+        public object AuditGy_Customer(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Customer");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    oCN.RunProc("update Gy_Customer set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    oCN.RunProc("update Gy_Customer set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹㈡埛绂佺敤銆佸弽绂佺敤
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Customer/StopGy_Customer")]
+        [HttpGet]
+        public object StopGy_Customer(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Customer_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Customer where HItemID=" + HInterID, "Gy_Material");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                {
+                    oCN.RunProc("update Gy_Customer set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    oCN.RunProc("update Gy_Customer set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
         #region [鍚屾鍩虹璧勬枡]
         [Route("Gy_Customer/Gy_CustomerViewApi")]
         [HttpGet]

--
Gitblit v1.9.1