From 7659bbba43cb690164bbf1fa3bc1d0fe74d883c9 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 16 八月 2024 17:04:05 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/BaseSet/Gy_SupplierController.cs |  706 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 681 insertions(+), 25 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
index 30f1fda..6bf08f4 100644
--- a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -7,10 +8,13 @@
 using System.Data.SqlClient;
 using System.Web.Http;
 using WebAPI.Models;
+using System.Text.RegularExpressions;
 namespace WebAPI.Controllers
 {
     public class Gy_SupplierController : ApiController
     {
+        //鑾峰彇绯荤粺鍙傛暟
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
 
         private json objJsonResult = new json();
@@ -29,6 +33,7 @@
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 //缂栬緫鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user))
                 {
@@ -49,10 +54,19 @@
                     ds = oCN.RunProcReturn(sql, "h_v_Gy_SupplierList");
                 }
 
+                //娣诲姞鍒楀悕
+                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)
@@ -97,6 +111,83 @@
             }
         }
 
+        #region 瀹㈡埛鏍规嵁鍒嗙被鑾峰彇鏈�澶у鎴风紪鐮�
+        [Route("Gy_Supplier/getMaxNum")]
+        [HttpGet]
+        public object getMaxNum(int HSupTypeID, string user, string Organization)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HSupTypeID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁閫夋嫨鍏蜂綋鍒嗙被锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn(@"select * from h_v_Gy_SupplierList where 缁勭粐鍚嶇О='" + Organization + "'" + "and HSupTypeID = '" + HSupTypeID + "'" + " order by 渚涘簲鍟嗕唬鐮� desc", "h_v_Gy_SupplierList");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "娌℃湁鎵惧埌璇ュ垎绫荤殑瀹㈡埛缂栫爜璇蜂娇鐢ㄦ櫘閫氭柊澧�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    string HNumber = ds.Tables[0].Rows[0]["渚涘簲鍟嗕唬鐮�"].ToString();
+                    // 浣跨敤姝e垯琛ㄨ揪寮忔壘鍒版暟瀛楅儴鍒�  (?<=\D)鏄竴涓浂瀹芥柇瑷�锛岃〃绀哄墠闈㈢殑瀛楃涓嶆槸鏁板瓧 (\d+)$琛ㄧず鍚庨潰璺熺潃涓�杩炰覆瀛楃涓茬煡閬撴湯灏�
+                    Match match = Regex.Match(HNumber, @"(?<=\D)(\d+)$");
+                    if (match.Success)
+                    {
+                        string prefix = HNumber.Substring(0, HNumber.Length - match.Length); // 鎻愬彇鍓嶇紑  
+                        int number = int.Parse(match.Value); // 瑙f瀽鏁板瓧  
+                        // 鏁板瓧+1  
+                        number++;
+                        // 鏍煎紡鍖栨暟瀛楋紝淇濇寔鍘熼暱搴�  
+                        string formattedNumber = number.ToString().PadLeft(match.Length, '0');
+                        // 閲嶆柊缁勫悎瀛楃涓�  
+                        string result = prefix + formattedNumber;
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "success";
+                        objJsonResult.data = result;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        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;
+            }
+        }
+        #endregion
+
         /// <summary>
         /// 渚涘簲鍟嗗垪琛ㄤ慨鏀规寜閽柟娉�
         ///鍙傛暟锛歴tring sql銆�
@@ -108,21 +199,27 @@
         {
             try
             {
-                string sql = string.Format(@"select  s.HItemID,s.HNumber 缂栫爜,s.HName 鍚嶇О,s.HHelpCode  鍔╄鐮�,s.HShortName 绠�绉�,s.HAddress 鍦板潃,s.HLinkMan 鑱旂郴浜�,s.HLinkPhone 鑱旂郴鐢佃瘽
-                                            ,s.HMobilePhone 鎵嬫満,s.HFax 浼犵湡,s.HPostalCode 閭紪,s.HEmail 鐢靛瓙閭欢,s.HCorMan 娉曚汉浠h〃,s.HBank 寮�鎴烽摱琛�,s.HBankAccount 閾惰璐﹀彿,
+                string sql = string.Format(@"select  s.HItemID,s.HUSEORGID,o.Hname 浣跨敤缁勭粐,s.HCREATEORGID ,d.Hname 鍒涘缓缁勭粐,s.HNumber 缂栫爜,s.HName 鍚嶇О,s.HHelpCode  鍔╄鐮�,s.HShortName 绠�绉�,s.HAddress 鍦板潃,s.HLinkMan 鑱旂郴浜�,s.HLinkPhone 鑱旂郴鐢佃瘽
+                                            ,s.HMobilePhone 鎵嬫満,s.HFax 浼犵湡,s.HPostalCode 閭紪,s.HEmail 鐢靛瓙閭欢,s.HCorMan 娉曚汉浠h〃,s.HBank 寮�鎴烽摱琛�,s.HBankAccount 閾惰璐﹀彿,s.HPSStyleID 閲囪喘鏂瑰紡ID,f.HName 閲囪喘鏂瑰紡鍚嶇О,
                                            s.HTaxNum 绋庡姟鐧昏鍙�,s.HEnglishName 鑻辨枃鍚嶇О,s.HEngLishAddress 鑻辨枃鍦板潃,s.HCountry 鍥藉,s.HStopflag 绂佺敤鏍囧織
                                            ,s.HRemark 澶囨敞,s.HAreaID 鍦板尯ID,a.HName 鍦板尯鍚嶇О,s.HTaxRate 澧炲�肩◣鐜�,s.HCurID 榛樿璐у竵ID,r.HName 榛樿璐у竵,
-                                           s.HSSID 缁撶畻鏂瑰紡ID,e.HName 缁撶畻鏂瑰紡 from Gy_Supplier s
+                                           s.HSSID 缁撶畻鏂瑰紡ID,e.HName 缁撶畻鏂瑰紡,s.HMaterClass 渚涜揣鏉愭枡绫诲埆  from Gy_Supplier s
                                            left join Gy_AreaSet a on s.HAreaID=a.HItemID
                                            left join Gy_Currency r on s.HCurID=r.HItemID 
                                            left  join Gy_SettleStyle e on s.HSSID=e.HItemID
+                                           left join Xt_ORGANIZATIONS o on s.HUSEORGID=o.HItemID
+										   left join Xt_ORGANIZATIONS d on s.HCREATEORGID=d.HItemID
+										   left join Gy_PoStockStyle f on s.HPSStyleID=f.HItemID
                                            where s.HItemID='" + HInterID + "'");
                 ds = oCN.RunProcReturn(sql, "Gy_Supplier");
-
+                DataSet cs = oCN.RunProcReturn("select * from Gy_Supplier_PayPlan where HSupID = '"+ HInterID + "'", "Gy_Supplier_PayPlan");
+                List<Object> list = new List<object>();
+                list.Add(cs);
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "";
                 objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = list;
                 return objJsonResult;
             }
             catch (Exception e)
@@ -149,15 +246,16 @@
             {
                 var _value = oMain["oMain"].ToString();
                 string msg1 = _value.ToString();
-                //鍙嶅簭鍒楀寲
-                msg1 = "[" + msg1.ToString() + "]";
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
+                string msg3 = sArray[1].ToString(); //瀛愯〃鏁版嵁
+                //涓昏〃鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
 
                 DAL.ClsGy_Supplier_Ctl oDept = new DAL.ClsGy_Supplier_Ctl();
                 DAL.ClsGy_Supplier_View oDeptHlp = new DAL.ClsGy_Supplier_View();
 
-
-
-                List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg1);
+                List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg2);
 
                 long HItemID = list[0].HInterID;
                 string HNumber = list[0].HNumber;
@@ -193,7 +291,8 @@
                 long HCreateOrgID = list[0].HCreateOrgID;
                 long HUseOrgID = list[0].HUseOrgID;
                 string HRemark = list[0].HRemark;
-
+                string HMaterClass = list[0].HMaterClass;
+                long HPSStyleID = list[0].HPSStyleID;
 
                 if (!DBUtility.ClsPub.AllowNumber(HNumber))
                 {
@@ -203,9 +302,6 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
-
-
                 //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
                 oCN.BeginTran();
                 //涓昏〃
@@ -215,16 +311,32 @@
                     ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" +
                     ",HFax,HPostalCode,HEmail,HBank,HBankAccount" +
                     ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" +
-                    ",HEnglishAddress,HCurID,HSSID,HAreaID) " +
+                    ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HUSEORGID,HCREATEORGID,HPSStyleID) " +
                 " 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 + "'" +
-                ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID + 
-              ") ");
+                ",'" + HEnglishAddress + "'," + HCurID + "," + HSSID + "," + HAreaID +" ,'" + HMaterClass + " ','" + HUseOrgID + "' ,'" + HCreateOrgID + "' ,'" + HPSStyleID +
+              "') ");
                 //淇敼涓婄骇涓洪潪鏈骇浠g爜
                 oCN.RunProc("Update Gy_Supplier set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+                //瀛愯〃娣诲姞
+                List<ClsGy_Supplier_PayPlan> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_PayPlan>>(msg3);
+                int i = 0;
+                DataSet Cs;
+                Cs = oCN.RunProcReturn("select MAX(HItemID)HItemID from Gy_Supplier", "Gy_Supplier");
+                string MaxHItemID = Cs.Tables[0].Rows[0]["HItemID"].ToString();
+                //鍒犻櫎瀛愯〃鎿嶄綔 闃叉鍑洪敊
+                oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + MaxHItemID + "'");
+                foreach (ClsGy_Supplier_PayPlan oSub in DetailColl)
+                {
+                    i++;
+                    oCN.RunProc($@"Insert into Gy_Supplier_PayPlan 
+                (HSupID,HSubID,HPayType,HPayRate,HPayTime,HPayRemark) 
+                 values({MaxHItemID},{i} ,'{oSub.HPayType}',{oSub.HPayRate},{oSub.HPayTime},'{oSub.HPayRemark}')");
+                }
+
                 oCN.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -243,6 +355,59 @@
             }
         }
 
+        [Route("Gy_Supplier/SaveGy_SupplierListApi")]
+        [HttpPost]
+        public object SaveGy_SupplierListApi([FromBody] JObject msg)
+        {
+            try
+            {
+                var _value = msg["model"].ToString();
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //鍙嶅簭鍒楀寲
+                _value = "[" + _value.ToString() + "]";
+                List<Supplier> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(_value);
+                string sql = string.Empty;
+                //淇濆瓨
+                oCN.BeginTran();
+                sql = $"delete from Gy_Supplier where HItemID = {lsmain[0].HItemID}";
+                oCN.RunProc(sql);
+                sql = "set identity_insert Gy_Supplier on";
+                oCN.RunProc(sql);
+                oCN.RunProc("Insert Into Gy_Supplier " +
+                 "(HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+                     ",HLevel,HEndFlag,HStopflag,HRemark" +
+                     ",HShortName,HAddress,HLinkMan,HLinkPhone,HMobilePhone" +
+                     ",HFax,HPostalCode,HEmail,HBank,HBankAccount" +
+                     ",HTaxNum,HTaxRate,HCountry,HCorMan,HEnglishName" +
+                     ",HEnglishAddress,HCurID,HSSID,HAreaID,HMaterClass,HERPItemID) " +
+                 " values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "','" + lsmain[0].HParentID + "'" +
+                 "," + lsmain[0].HLevel + ",0,'" + lsmain[0].HStopflag + "','" + lsmain[0].HRemark + "'" +
+                 ",'" + lsmain[0].HShortName + "','" + lsmain[0].HAddress + "','" + lsmain[0].HLinkMan + "','" + lsmain[0].HLinkPhone + "','" + lsmain[0].HMobilePhone + "'" +
+                 ",'" + lsmain[0].HFax + "','" + lsmain[0].HPostalCode + "','" + lsmain[0].HEmail + "','" + lsmain[0].HBank + "','" + lsmain[0].HBankAccount + "'" +
+                 ",'" + lsmain[0].HTaxNum + "','" + lsmain[0].HTaxRate + "','" + lsmain[0].HCountry + "','" + lsmain[0].HCorMan + "','" + lsmain[0].HEnglishName + "'" +
+                 ",'" + lsmain[0].HEnglishAddress + "'," + lsmain[0].HCurID + "," + lsmain[0].HSSID + "," + lsmain[0].HAreaID +",'"+lsmain[0].HMaterClass+ 
+                 "'," + lsmain[0].HItemID +
+                  ") ");
+                //淇敼涓婄骇涓洪潪鏈骇浠g爜
+                sql = "set identity_insert Gy_Supplier off";
+                oCN.RunProc(sql);
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
 
         /// <summary>
         /// 淇敼鍗曟嵁-淇濆瓨鎸夐挳
@@ -263,9 +428,10 @@
                 string msg1 = _value.ToString();
                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                 string msg2 = sArray[0].ToString();   //琛ㄥご鏁版嵁
-                string msg3 = sArray[1].ToString();   //鍒楄〃涓籌D
-                string msg4 = sArray[2].ToString();   //鐧诲綍浜哄憳
-                string msg5 = sArray[3].ToString();   //鏉冮檺妯″潡浠g爜
+                string msg3 = sArray[1].ToString();   //瀛愯〃鏁版嵁
+                string msg4 = sArray[2].ToString();   //鍒楄〃涓籌D
+                string msg5 = sArray[3].ToString();   //鐧诲綍浜哄憳
+                string msg6 = sArray[4].ToString();   //鏉冮檺妯″潡浠g爜
                 //鍙嶅簭鍒楀寲
                 msg2 = "[" + msg2.ToString() + "]";
                 List<Supplier> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Supplier>>(msg2);
@@ -304,10 +470,11 @@
                 long HCreateOrgID = list[0].HCreateOrgID;
                 long HUseOrgID = list[0].HUseOrgID;
                 string HRemark = list[0].HRemark;
-
+                string HMaterClass = list[0].HMaterClass;
+                long HPSStyleID = list[0].HPSStyleID;
 
                 //鍒ゆ柇鏉冮檺
-                if (!ClsPub.Security_Log(msg5, 1, false, msg4))
+                if (!ClsPub.Security_Log(msg6, 1, false, msg5))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -356,7 +523,11 @@
                    ",HEnglishAddress='" + HEnglishAddress + "'" +
                    ",HCurID=" + HCurID.ToString() +
                    ",HSSID=" + HSSID.ToString() +
-                   ",HAreaID=" + HAreaID.ToString() + "Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
+                   ",HMaterClass='" + HMaterClass +
+                   "',HPSStyleID='"+ HPSStyleID.ToString() +
+                   "',HUSEORGID='" + HUseOrgID.ToString() +
+                   "',HCREATEORGID='" + HCreateOrgID.ToString() +
+                   "',HAreaID=" + HAreaID.ToString() + "Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
 
 
                 //淇敼瀛愰」鐩唬鐮�
@@ -364,6 +535,22 @@
                 //灏嗕笂绾� 涓洪潪鏈骇
                 oCN.RunProc("Update Gy_Supplier set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                 //
+
+                //瀛愯〃娣诲姞
+                List<ClsGy_Supplier_PayPlan> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_Supplier_PayPlan>>(msg3);
+                int i = 0;
+                //鍒犻櫎瀛愯〃鎿嶄綔 闃叉鍑洪敊
+                oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + HItemID + "'");
+                foreach (ClsGy_Supplier_PayPlan oSub in DetailColl)
+                {
+                    i++;
+                    oCN.RunProc($@"Insert into Gy_Supplier_PayPlan 
+                (HSupID,HSubID,HPayType,HPayRate,HPayTime,HPayRemark) 
+                 values({HItemID},{i} ,'{oSub.HPayType}',{oSub.HPayRate},{oSub.HPayTime},'{oSub.HPayRemark}')");
+                }
+
+
+
                 oCN.Commit();
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -424,9 +611,13 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
+                    oCN.BeginTran();
                     //
                     if (oGroup.DeleteByID(HItemID))
                     {
+                        //鍒犻櫎瀛愯〃
+                        oCN.RunProc("delete from Gy_Supplier_PayPlan where HSupID='" + HItemID + "'");
+                        oCN.Commit();
                         //鍐欏叆鏃ュ織
                         ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oGroupHlp.omodel.HNumber + ",鍚嶇О锛�" + oGroupHlp.omodel.HName, ClsPub.CurUserName);
                         //鏇存柊涓婄骇涓� 鏈骇
@@ -438,6 +629,7 @@
                     }
                     else
                     {
+                        oCN.Commit();
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍒犻櫎澶辫触";
@@ -462,6 +654,470 @@
                 return objJsonResult;
             }
         }
-        //
+
+
+        #region 渚涘簲鍟嗗鏍搞�佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Supplier/AuditGy_Supplier")]
+        [HttpGet]
+        public object AuditGy_Material(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Supplier where HItemID=" + HInterID, "Gy_Supplier");
+                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_Supplier 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_Supplier 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_Supplier/StopGy_Supplier")]
+        [HttpGet]
+        public object StopGy_Supplier(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Supplier where HItemID=" + HInterID, "Gy_Supplier");
+                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_Supplier 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_Supplier 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_Supplier/Gy_SupplierViewApi")]
+        [HttpGet]
+        public json Gy_SupplierViewApi(string Number, string Type)
+        {
+            string sql = string.Empty;
+            string sReturn = "";
+            if (oSystemParameter.ShowBill(ref sReturn) == true)
+            {
+                //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡
+                if (oSystemParameter.omodel.WMS_CloudMode == "Y")
+                {
+                    #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩
+                    try
+                    {
+                        oCN.BeginTran();
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                        DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPBasicInfoToLocal '" + Number + "','" + Type + "'", "h_p_WMS_ERPBasicInfoToLocal");
+                        if (DS == null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍩虹璧勬枡鍚屾澶辫触";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "ERP涓笉瀛樺湪璇ヤ唬鐮�";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "1";
+                                objJsonResult.count = 1;
+                                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;
+                    }
+                    #endregion
+                }
+                else
+                {
+                    #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩
+                    var json = new
+                    {
+                        CreateOrgId = 0,
+                        Number = Number,
+                        Id = ""
+                    };
+                    #region [閲戣澏閮ㄥ垎]
+                    //鐧诲綍閲戣澏
+                    var loginRet = InvokeHelper.Login();
+                    var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+                    //鍒ゆ柇鏄惁鐧诲綍鎴愬姛
+                    if (isSuccess < 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = loginRet;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鏌ョ湅 鑾峰彇鏁版嵁                    
+                    var _result = InvokeHelper.View("BD_Supplier", JsonConvert.SerializeObject(json));
+                    var _saveObj = JObject.Parse(_result);
+                    //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛
+                    if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "閲戣澏渚涘簲鍟嗗悓姝ュけ璐sonRoot锛�" + _result;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    #endregion
+                    //鑾峰彇鏁版嵁
+                    DataSet Ds;
+                    Ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber = '" + Number + "'", "Gy_Supplier");
+                    if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"].ToString()) != 0)
+                    {
+
+                    }
+
+                    #region [琛ㄦ暟鎹祴鍊糫
+                    var jsonData = new
+                    {
+                        HItemID = _saveObj["Result"]["Result"]["Id"],
+                        HERPItemID = _saveObj["Result"]["Result"]["Id"],
+                        HNumber = _saveObj["Result"]["Result"]["Number"],
+                        HName         = _saveObj["Result"]["Result"]["Name"][0]["Value"],
+                        HShortNumber  = _saveObj["Result"]["Result"]["Number"],
+                        HParentID     = 0,
+                        HLevel        = 1,
+                        HEndFlag      = 1,
+                        HStopflag     = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1,
+                        HRemark       = "CLD-ERP瀵煎叆",
+                        HUseFlag      = "宸蹭娇鐢�",
+                        HMakeTime     = _saveObj["Result"]["Result"]["CreateDate"],
+                        HCREATEORGID  = _saveObj["Result"]["Result"]["CreateOrgId_Id"],
+                        HUSEORGID     = _saveObj["Result"]["Result"]["UseOrgId_Id"],
+                        HPAYCONDITION = _saveObj["Result"]["Result"]["SupplierFinance"][0]["PayCondition_Id"]
+                    };
+                    #endregion
+                    // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁
+                    sql = $"delete from Gy_Supplier where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'";
+                    oCN.RunProc(sql);
+
+                    sql = "set identity_insert Gy_Supplier on";
+                    oCN.RunProc(sql);
+
+                    //鎻掑叆琛�
+                    sql = $@"
+                insert into Gy_Supplier
+                (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID
+	            ,HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID
+	            ,HPAYCONDITION
+                 )
+                values
+                ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}',
+                '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID},{jsonData.HPAYCONDITION})";
+
+                    oCN.RunProc(sql);
+
+                    sql = "set identity_insert Gy_Supplier off";
+                    oCN.RunProc(sql);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "渚涘簲鍟嗗悓姝ユ垚鍔燂紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                    #endregion
+                }
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍩虹璧勬枡璇诲彇澶辫触锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鏍规嵁鐖秈d鍜岀瓑绾ц幏寰楁爲鐘跺浘閫掑綊
+
+        [Route("Gy_BadReason/Gy_SupTypeTreeListByLevel")]
+        [HttpGet]
+        public object Gy_MaterTypeTreeListByLevel()
+        {
+            try
+            {
+                string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_SupType order by hnumber");
+
+                ds = oCN.RunProcReturn(sql1, "Gy_SupType");
+
+                List<TreeModel> treeModels = new List<TreeModel>();
+                TreeModel first = new TreeModel();
+                first.id = "0";
+                first.title = "渚涘簲鍟嗗垎绫昏缃�";
+                treeModels.Add(first);
+
+                foreach (DataRow row in ds.Tables[0].Rows)
+                {
+                    var HLevel = (int)row["hlevel"];
+                    if (HLevel == 1)
+                    {
+                        TreeModel tree = new TreeModel();
+                        tree.id = row["hitemid"].ToString();
+                        tree.title = row["hname"].ToString();
+                        treeModels[0].children.Add(tree);
+                    }
+                }
+                getTreeByLevel(ds.Tables[0], treeModels[0].children, 2);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels);
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public void getTreeByLevel(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var HLevel = (int)dt.Rows[i]["hlevel"];
+                    var HParentID = dt.Rows[i]["hparentid"].ToString();
+                    if (HLevel == num && HParentID == tree[m].id)
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    getTreeByLevel(dt, tree[m].children, num + 1);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+        #endregion
+
+        #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�)
+        public class TreeModel
+        {
+            public string id { get; set; }
+            public string title { get; set; }
+            public List<TreeModel> children = new List<TreeModel>();
+        }
+        /// <summary>
+        /// 閫掑綊鍑芥暟
+        /// </summary>
+        public void digui(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var strLen = dt.Rows[i]["hnumber"].ToString().Split('.');
+                    if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].id + "."))
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                var strLens = tree[m].id.Split('.');
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    digui(dt, tree[m].children, strLens.Length + 2);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1