From 9b2e97ed6a3ba9ba86b3cd2961e1766c711af907 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期五, 12 七月 2024 16:58:30 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/BLL/Xt_BillTypeController.cs |  283 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 265 insertions(+), 18 deletions(-)

diff --git a/WebAPI/Controllers/BLL/Xt_BillTypeController.cs b/WebAPI/Controllers/BLL/Xt_BillTypeController.cs
index da26d8d..7ebf34f 100644
--- a/WebAPI/Controllers/BLL/Xt_BillTypeController.cs
+++ b/WebAPI/Controllers/BLL/Xt_BillTypeController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -29,32 +30,43 @@
         {
             try
             {
+                List<object> columnNameList = new List<object>();
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Xt_BillTypeList " + sWhere, "h_v_Xt_BillTypeList");
+                    ds = oCN.RunProcReturn("select * from h_v_Xt_BillTypeList " + sWhere+ "  order by hitemid desc", "h_v_Xt_BillTypeList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_Xt_BillTypeList where 1 = 1 ";
-                    string sql = sql1 + sWhere;
+                    string sql = sql1 + sWhere+ "  order by hitemid desc";
                     ds = oCN.RunProcReturn(sql, "h_v_Xt_BillTypeList");
                 }
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "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];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -67,7 +79,242 @@
         }
 
 
+        /// <summary>
+        /// 鍗曟嵁绫诲瀷鍒楄〃淇敼鏂规硶
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_BillType/xg")]
+        [HttpGet]
+        public object xg(long HInterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from Xt_BillType where HItemID=" + HInterID, "Xt_BillType");
 
-        //
+                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;
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏈�澶у熀纭�璧勬枡ID
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_BillType/GetMAXBillID")]
+        [HttpGet]
+        public object GetMAXBillID()
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select max(hitemid)+1 hitemid from Xt_BillType", "Xt_BillType");
+
+                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;
+            }
+        }
+
+        /// <summary>
+        /// 淇敼鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_BillType/AddBill1")]
+        [HttpPost]
+        public object AddBill1([FromBody] JObject oMain)
+        {
+
+            try
+            {
+                var _value = oMain["oMain"].ToString();
+                string msg1 = _value.ToString();
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msg2 = sArray[0].ToString();
+                string msg3 = sArray[1].ToString();
+                string msg4 = sArray[2].ToString();
+                string msg5 = sArray[3].ToString();
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
+                List<BillType> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BillType>>(msg2);
+
+                long HItemID = int.Parse(msg3);
+                string HNumber = list[0].HNumber;
+                string HName = list[0].HName;
+                string HTemplate = list[0].HTemplate;
+                string HHeadTable = list[0].HHeadTable;
+                string HEntryTable = list[0].HEntryTable;
+                string HViewName = list[0].HViewName;
+                string HRightName = list[0].HRightName;
+
+
+               
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCN.BeginTran();
+                //涓昏〃
+                oCN.RunProc("Update Xt_BillType set " +
+                    " HNumber='" + HNumber + "'" +
+                    ",HName='" + HName + "'" +
+                    ",HTemplate='" + HTemplate + "'" +
+                    ",HHeadTable='" + HHeadTable + "'" +
+                    ",HEntryTable='" + HEntryTable + "'" +
+                    ",HViewName='" + HViewName + "'" +
+                    ",HRightName= '" + HRightName + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
+                //淇敼瀛愰」鐩唬鐮�
+                //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
+                //灏嗕笂绾� 涓洪潪鏈骇
+                //
+                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 = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        /// <summary>
+        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_BillType/AddBill")]
+        [HttpPost]
+        public object AddBill([FromBody] JObject oMain)
+        {
+            try
+            {
+                var _value = oMain["oMain"].ToString();
+                string msg1 = _value.ToString();
+                //鍙嶅簭鍒楀寲
+                msg1 = "[" + msg1.ToString() + "]";
+
+
+
+                List<BillType> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BillType>>(msg1);
+
+                long HItemID = list[0].HItemID;
+                string HNumber = list[0].HNumber;
+                string HName = list[0].HName;
+                string HTemplate = list[0].HTemplate;
+                string HHeadTable = list[0].HHeadTable;
+                string HEntryTable = list[0].HEntryTable;
+                string HViewName = list[0].HViewName;
+                string HRightName = list[0].HRightName;
+
+
+
+
+
+
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCN.BeginTran();
+                //涓昏〃
+                oCN.RunProc("Insert Into Xt_BillType " +
+                "(HNumber,HName,HTemplate,HHeadTable" +
+                ",HEntryTable,HViewName,HRightName" +
+                ") " +
+                " values('" + HNumber + "','" + HName + "','" + HTemplate + "','" + HHeadTable + "'" +
+                ",'" + HEntryTable + "','" + HViewName + "','" + HRightName + "'" +
+              ") ");
+                //淇敼涓婄骇涓洪潪鏈骇浠g爜
+                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 = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #region 鍗曟嵁绫诲瀷 閲戣澏鍚屾
+        [Route("Xt_BillType/SaveXt_BillTypeListApi")]
+        [HttpPost]
+        public object SaveXt_BillTypeListApi([FromBody] JObject msg)
+        {
+            try
+            {
+                var _value = msg["model"].ToString();
+                LogService.Write("鍗曟嵁绫诲瀷:" + _value);
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                ListModels oListModels = new ListModels();
+                List<Model.ClsXt_BillType_Model> lsmain = new List<Model.ClsXt_BillType_Model>();
+                lsmain = oListModels.getObjectByJson_Xt_BillType(_value);
+                string sql = string.Empty;
+                //淇濆瓨
+                oCN.BeginTran();
+                sql = $"delete Xt_BillType where HItemID = {lsmain[0].HItemID}";
+                oCN.RunProc(sql);
+                //sql = "set identity_insert Xt_BillType on";
+                //oCN.RunProc(sql);
+
+                LogService.Write("鍗曟嵁绫诲瀷:" + $@"insert into Xt_BillType(HBilltypeID,HNumber,HName,HTemplate,HHeadTable,HEntryTable,HViewName,HRightName)
+                  values('{lsmain[0].HBilltypeID}','{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HTemplate}','{lsmain[0].HHeadTable}','{lsmain[0].HEntryTable}','{lsmain[0].HViewName}','{lsmain[0].HRightName}' )");
+
+                oCN.RunProc($@"insert into Xt_BillType(HBilltypeID,HNumber,HName,HTemplate,HHeadTable,HEntryTable,HViewName,HRightName)
+                  values('{lsmain[0].HBilltypeID}','{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HTemplate}','{lsmain[0].HHeadTable}','{lsmain[0].HEntryTable}','{lsmain[0].HViewName}','{lsmain[0].HRightName}' )", ref DBUtility.ClsPub.sExeReturnInfo);
+                //淇敼涓婄骇涓洪潪鏈骇浠g爜
+                sql = "set identity_insert Xt_BillType 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;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1