From 8a829f00d0582a32c7bef960cab5c6fd855c5ea5 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期四, 31 十月 2024 11:05:23 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs |  836 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 717 insertions(+), 119 deletions(-)

diff --git a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
index c556479..898371b 100644
--- a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
+++ b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
@@ -8,7 +8,10 @@
 using System.Net.Http;
 using System.Web.Http;
 using WebAPI.Models;
-
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
 namespace WebAPI.Controllers.SBGL
 {
     public class Gy_EquipTypeController : ApiController
@@ -17,34 +20,34 @@
         private json objJsonResult = new json();
         public DataSet ds = new DataSet();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        public DLL.ClsGy_EquipTypeBill BillNew0 = new DLL.ClsGy_EquipTypeBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
-        public DLL.ClsGy_EquipTypeBill BillOld0 = new DLL.ClsGy_EquipTypeBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
+        public DLL.ClsGy_EquipTypeBill BillNew0 = new DLL.ClsGy_EquipTypeBill();   
+        public DLL.ClsGy_EquipTypeBill BillOld0 = new DLL.ClsGy_EquipTypeBill();
+        public DAL.ClsGy_EquipTypeBill BillOld = new DAL.ClsGy_EquipTypeBill();
 
         #region 璁惧鍒嗙被鍒楄〃
 
         [Route("Gy_EquipType/GetList")]
         [HttpGet]
-        public object GetList(string sWhere)
+        public object GetList(string sWhere,string user)
         {
             try
             {
-                ds = Sc_GetEquipTypeList(sWhere);
-                if (ds == null)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+                //if (!DBUtility.ClsPub.Security_Log("Gy_EquipTypeList", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+                ds = oCN.RunProcReturn("select HItemID,HParentID,HNumber,HName,HLevel, case when HEndFlag<>0 then 'Y'else ' 'end HEndFlag,case when HStopFlag <> 0 then 'Y'else ' 'end HStopFlag, HRemark, HUseFlag,HMakeEmp,HMakeTime,HCheckEmp,HCheckTime,HModifyEmp,HModifyTime,HCloseEmp,HCloseTime from Gy_EquipFileType where 1=1 " + sWhere+ " order by HItemID ", "Gy_EquipFileType");
+
+               
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
             }
             catch (Exception ex)
             {
@@ -56,28 +59,22 @@
             }
         }
 
-        public static DataSet Sc_GetEquipTypeList(string sWhere)
-        {
-            string sql1 = string.Format(@"select * from h_v_Gy_EquipTypeList");
-            if (sWhere == null || sWhere.Equals(""))
-            {
-                return new SQLHelper.ClsCN().RunProcReturn(sql1 + sWhere + " order by HItemID desc", "h_v_Gy_EquipTypeList");
-            }
-            else
-            {
-                string sql = sql1 + sWhere + " order by HItemID desc";
-                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Gy_EquipTypeList");
-            }
-
-        }
-
         #endregion
 
         #region [璁惧鍒嗙被鍒犻櫎鍔熻兘]
         [Route("Gy_EquipType/Delete_EquipType")]
         [HttpGet]
-        public object Delete_EquipType(string HItemID)
+        public object Delete_EquipType(string HItemID,string user)
         {
+            if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Delete", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
             string s = "";
             Int64 lngBillKey = 0;
             lngBillKey = DBUtility.ClsPub.isLong(HItemID);
@@ -90,25 +87,24 @@
                 return objJsonResult;
             }
             DLL.ClsGy_EquipTypeBill oBill = new DLL.ClsGy_EquipTypeBill();
-            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+            ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HItemID, "Gy_EquipFileType");
+            if (ds.Tables[0].Rows.Count > 0)
             {
-                bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
-                if (IsDete)
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                else
+                if (ds.Tables[0].Rows[0]["HCloseEmp"].ToString() != "" || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵�侊紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                oCN.RunProc("Delete From Gy_EquipFileType  where HItemID=" + lngBillKey);
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛";
+                objJsonResult.data = null;
+                return objJsonResult;
             }
             else
             {
@@ -122,91 +118,185 @@
 
         #endregion
 
-        #region 璁惧鍒嗙被淇濆瓨/缂栬緫
-        [Route("Gy_EquipType/SaveEquipTypeList")]
+        #region 妯℃不鍏峰垎绫绘柊澧炰繚瀛�
+        /// <summary>
+        /// 妯℃不鍏峰垎绫�-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Gy_EquipType/AddBill")]
         [HttpPost]
-        public object SaveEquipTypeList([FromBody] JObject msg)
+        public object AddBill([FromBody] JObject oMain)
         {
-            var _value = msg["msg"].ToString();
-            string msg1 = _value.ToString();
-            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
-            string msg2 = sArray[0].ToString();
-            string refSav = sArray[1].ToString();
-
-            ListModels oListModels = new ListModels();
             try
             {
-                DLL.ClsGy_EquipTypeBill oBill = new DLL.ClsGy_EquipTypeBill();
-                List<Models.ClsGy_EquipFileType> lsmain = new List<Models.ClsGy_EquipFileType>();
-                msg2 = msg2.Replace("\\", "");
-                msg2 = msg2.Replace("\n", "");  //\n
-                lsmain = oListModels.getObjectByJson_Gy_EquipFileType(msg2);
+                var _value = oMain["oMain"].ToString();
+                string msg1 = _value.ToString();
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msg2 = sArray[0].ToString();
+                string msg4 = sArray[1].ToString();
 
-                long HItemID = lsmain[0].HItemID;
-                string HNumber = lsmain[0].HNumber;
-                string HName = lsmain[0].HName;
-                string HShortNumber = lsmain[0].HNumber;
-                long HParentID = lsmain[0].HParentID;
-                long HLevel = lsmain[0].HLevel;
-                string HHelpCode = lsmain[0].HHelpCode;
-                string HRemark = lsmain[0].HRemark;
-                bool HStopflag = lsmain[0].HStopflag;
-                string HUseFlag = lsmain[0].HUseFlag;
-                bool HEndFlag = lsmain[0].HEndFlag;
+                if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
 
-                if (refSav == "Add")
+                List<Models.ClsGy_EquipFileType> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsGy_EquipFileType>>(msg2);
+
+                string HNumber = list[0].HNumber;
+                string HName = list[0].HName;
+                string HShortNumber = list[0].HNumber;
+                long HParentID = list[0].HParentID;
+                long HLevel = list[0].HLevel;
+                string HHelpCode = list[0].HHelpCode;
+                string HRemark = list[0].HRemark;
+                bool HStopflag = list[0].HStopflag;
+                string HUseFlag = list[0].HUseFlag;
+                bool HEndFlag = list[0].HEndFlag;
+
+
+                if (!DBUtility.ClsPub.AllowNumber(HNumber))
                 {
-                        //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
-                        oCN.BeginTran();
-                        //涓昏〃
-                        oCN.RunProc("Insert into Gy_EquipFileType " +
-                           " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
-                           ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime) " +
-                           " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID +
-                           "," + HLevel + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
-                        //淇敼涓婄骇涓洪潪鏈骇浠g爜
-                        oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
-                        oCN.Commit();
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "鏂板鎴愬姛锛�";
-                        //objJsonResult.data = null;
-                        return objJsonResult;
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
                 }
-                if (refSav == "Update")
-                {
-                        oCN.BeginTran();
-                        //涓昏〃
-                        oCN.RunProc("Update Gy_EquipFileType set " +
-                            " HNumber='" + HNumber + "'" +
-                            ",HName='" + HName + "'" +
-                            ",HShortNumber='" +HShortNumber + "'" +
-                            ",HHelpCode='" + HHelpCode + "'" +
-                            ",HParentID=" + HParentID +
-                            ",HStopflag='" + HStopflag + "'" +
-                            ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
-                        //淇敼瀛愰」鐩唬鐮�
-                        //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
-                        //灏嗕笂绾� 涓洪潪鏈骇
-                        oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
-                        //
-                        oCN.Commit();
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
-                        objJsonResult.Message = "淇敼鎴愬姛锛�";
-                        //objJsonResult.data = null;
-                        return objJsonResult;
-                }
+
+
+
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCN.BeginTran();
+                //涓昏〃
+                oCN.RunProc("Insert into Gy_EquipFileType " +
+                   " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+                   ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HMakeEmp) " +
+                   " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID +
+                   "," + HLevel + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',getdate(),'" + msg4 + "')", ref DBUtility.ClsPub.sExeReturnInfo);
+                //淇敼涓婄骇涓洪潪鏈骇浠g爜
+                oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, 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 = "淇濆瓨澶辫触锛�" + e.ToString();
-                objJsonResult.data = 1;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
                 return objJsonResult;
             }
-            return false;
+        }
+        #endregion
+
+        #region 妯℃不鍏峰垎绫讳慨鏀逛繚瀛�
+        /// <summary>
+        /// 淇敼鍗曟嵁-淇濆瓨鎸夐挳
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Gy_EquipType/EditBill")]
+        [HttpPost]
+        public object EditBill([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();
+
+                if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
+                List<Models.ClsGy_EquipFileType> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsGy_EquipFileType>>(msg2);
+
+                long HItemID = int.Parse(msg3);
+                string HNumber = list[0].HNumber;
+                string HName = list[0].HName;
+                string HShortNumber = list[0].HNumber;
+                long HParentID = list[0].HParentID.ToString() == "" ? 0 : list[0].HParentID;
+                string HHelpCode = list[0].HHelpCode;
+                string HRemark = list[0].HRemark;
+                bool HStopflag = list[0].HStopflag;
+                string HUseFlag = list[0].HUseFlag;
+
+                if (!DBUtility.ClsPub.AllowNumber(HNumber))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet DS = oCN.RunProcReturn("Select * from Gy_EquipFileType Where HStopflag=0 and HNumber='" + HItemID + "' and HItemID<>" + HNumber, "Gy_EquipFileType", ref Pub_Class.ClsPub.sExeReturnInfo);
+                if (DS.Tables[0].Rows.Count != 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浠g爜閲嶅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+                oCN.BeginTran();
+                //涓昏〃
+                oCN.RunProc("Update Gy_EquipFileType set " +
+                    " HNumber='" + HNumber + "'" +
+                    ",HName='" + HName + "'" +
+                    ",HShortNumber='" + HShortNumber + "'" +
+                    ",HHelpCode='" + HHelpCode + "'" +
+                    ",HParentID=" + HParentID +
+                    ",HModifyTime=getdate()" +
+                    ",HModifyEmp='" + msg4 + "'" +
+                    ",HStopflag='" + HStopflag + "'" +
+                    ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
+                //淇敼瀛愰」鐩唬鐮�
+                //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo);
+                //灏嗕笂绾� 涓洪潪鏈骇
+                oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, 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;
+            }
         }
         #endregion
 
@@ -235,5 +325,513 @@
             }
         }
         #endregion
+
+        #region 璁惧鍒嗙被瀹℃牳/鍙嶅鏍稿姛鑳�
+        [Route("Gy_EquipTypeBill/CheckGy_EquipTypeBill")]
+        [HttpGet]
+        public object CheckGy_EquipTypeBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    if (!BillOld.AuditByID2(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (BillOld.DeAuditByID2(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();                       
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璁惧鍒嗙被鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("Gy_EquipTypeBill/CloseGy_EquipTypeBill")]
+        [HttpGet]
+        public object CloseGy_EquipTypeBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Close", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
+                {
+                    if (!BillOld.CloseByID2(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (!BillOld.DeCloseByID2(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                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_EquipTypeBill/StopGy_EquipTypeBill")]
+        [HttpGet]
+        public object StopGy_EquipTypeBill(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_MaterType_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HInterID, "Gy_EquipFileType");
+                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_EquipFileType 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_EquipFileType 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 璁惧鍒嗙被 鏂囦欢瀵煎叆淇濆瓨
+        #region 璁惧鍒嗙被 鏂囦欢涓婁紶
+        [Route("Gy_EquipType/Gy_EquipType_Excel")]
+        [HttpPost]
+        public object Gy_EquipType_Excel()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+
+                var error = "";
+
+                //鏌ヨ娌℃湁鐨勫垪
+                if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("璁惧鍒嗙被"))
+                    error += "娌℃湁鎵惧埌銆愯澶囧垎绫诲悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("璁惧鍒嗙被浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愯澶囧垎绫讳唬鐮併�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("澶囨敞"))
+                    error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+                if (!tb2.Columns.Contains("鍔╄鐮�"))
+                    error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HProcessName = "";
+                    string HProcessNum = "";
+                    string HORGNumber = "";
+                    string HORGName = "";
+
+
+                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被"].ToString());
+                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被浠g爜"].ToString());
+                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+
+                    //妫�鏌ョ墿鏂�
+                    int index = i + 1;
+
+                    if (HORGNumber != "")
+                    {
+
+                        //鏌ヨ缁勭粐
+                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
+
+                        //璁惧鍒嗙被鍚嶇О
+                        if (HProcessName == "")
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //璁惧鍒嗙被浠g爜
+                        if (HProcessNum == "")
+                        {
+                            objJsonResult.code = CodeConstant.FAIL;
+                            objJsonResult.count = CountConstant.FAIL;
+                            objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被浠g爜涓嶈兘涓虹┖锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = CountConstant.SUCCEED;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璁惧鍒嗙被椤圭洰 瀵煎叆(淇濆瓨)
+        [Route("Gy_EquipType/Gy_EquipType_btnSave")]
+        [HttpPost]
+        public object Gy_EquipType_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_ErrType_Edit", 1, false, user))
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+                    string HName = item["璁惧鍒嗙被"].ToString();
+                    string HNumber = item["璁惧鍒嗙被浠g爜"].ToString();
+                    string HRemark = item["澶囨敞"].ToString();
+                    string HHelpCode = item["鍔╄鐮�"].ToString();
+                    string sShortNumber;
+                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+                    if (sShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    int HEndFlag = 1;//鏈骇鏍囧織
+                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+
+
+                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HNumber='" + HNumber + "'", "Gy_EquipType");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        oCN.RunProc("Insert into Gy_EquipFileType " +
+                   " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+                   ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HMakeEmp) " +
+                   " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 +
+                   "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "',getdate(),'" + user + "')");
+                    }
+                    else
+                    {
+                        oCN.RunProc("update  Gy_EquipFileType set HHelpCode='" + HHelpCode + "',HRemark='" + HRemark + "'  where HNumber='" + HNumber + "'");
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = CountConstant.SUCCEED;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #endregion
+
     }
 }

--
Gitblit v1.9.1