From 5b10fd870f7ce41c53ee6b356dc9cec5ad2ea11e Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 15 四月 2025 14:51:18 +0800
Subject: [PATCH] 增加设备工艺参数订单点检保存后自动审核  根据子表NG参数发送信息,优化PDA工序流转卡页面查询

---
 WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs | 3477 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 3,423 insertions(+), 54 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs b/WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs
index 351bd0e..0e564eb 100644
--- a/WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_MESTransFerWorkBillController.cs
@@ -1,4 +1,6 @@
-锘縰sing DBUtility;
+锘縰sing DAL;
+using DBUtility;
+using DLL;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using System;
@@ -7,8 +9,12 @@
 using System.Linq;
 using System.Net;
 using System.Net.Http;
+using System.Timers;
+using System.Threading.Tasks;
 using System.Web.Http;
 using WebAPI.Models;
+using System.Threading;
+using SyntacticSugar.constant;
 
 namespace WebAPI.Controllers.SCGL
 {
@@ -28,6 +34,12 @@
         public DLL.ClsOA_ErrMsgBackBill BillNew = new DLL.ClsOA_ErrMsgBackBill();   //瀵瑰簲鍗曟嵁绫�
         public DLL.ClsOA_ErrMsgBackBill BillOld = new DLL.ClsOA_ErrMsgBackBill();   //瀵瑰簲鍗曟嵁绫�
 
+        public DAL.ClsOA_AndengFlowRuleBill BillOld1 = new DAL.ClsOA_AndengFlowRuleBill();   //瀵瑰簲鍗曟嵁绫�  瀹夌伅閫愮骇鍛煎彨瑙勫垯
+        public DAL.ClsOA_AndengFlowRuleBill BillNew1 = new DAL.ClsOA_AndengFlowRuleBill();   //瀵瑰簲鍗曟嵁绫�  瀹夌伅閫愮骇鍛煎彨瑙勫垯
+
+        public DAL.ClsOA_WorkLinkBill BillOld2 = new DAL.ClsOA_WorkLinkBill();   //瀵瑰簲鍗曟嵁绫�  宸ヤ綔鑱旂郴鍗�
+        public DAL.ClsOA_WorkLinkBill BillNew2 = new DAL.ClsOA_WorkLinkBill();   //瀵瑰簲鍗曟嵁绫�  宸ヤ綔鑱旂郴鍗�
+
 
         #region 鎶ュ伐骞冲彴寮傚父鍙嶉鍗曚繚瀛�/缂栬緫
         /// <summary>
@@ -37,7 +49,7 @@
         /// <returns></returns>
         [Route("Sc_MESTransFerWorkBill/SaveGetMESTransFerWorkFrom")]
         [HttpPost]
-        public object SaveGetMESTransFerWorkFrom([FromBody] JObject msg)
+        public object SaveGetMESTransFerWorkFromAsync([FromBody] JObject msg)
         {
 
             var _value = msg["msg"].ToString();
@@ -145,10 +157,19 @@
                         objJsonResult.data = 1;
                         return objJsonResult;
                     }
-                    
+
                     //string[] arrStr = oItem.HSendMan.Split(','); //鍙戦�佷汉
                     //arrStr = oItem.HReceiveMan.Split(',');  //鎺ユ敹浜�
-                    string[] arrStr = oItem.HCopyMan.Split(',');  //鎶勯�佷汉
+                    string[] arrStr;
+
+                    if (string.IsNullOrEmpty(oItem.HCopyMan))
+                    {
+                        arrStr = new string[0];  // 濡傛灉 oItem.HCopyMan 涓虹┖锛屽垯璧嬪�间负绌烘暟缁�
+                    }
+                    else
+                    {
+                        arrStr = oItem.HCopyMan.Split(',');  // 鍚﹀垯锛屼娇鐢� Split(',') 鏂规硶鎷嗗垎瀛楃涓�
+                    }
                     List<string> b = new List<string>(arrStr);
                     b.Add(oItem.HSendMan);
                     b.Add(oItem.HReceiveMan);
@@ -159,12 +180,13 @@
                         Models.ClsOA_ErrMsgBackBillSub2 sb = new Models.ClsOA_ErrMsgBackBillSub2();
                         sb.HEntryID = i;
                         sb.HReceiveMan = arrStr[i - 1];
-                        if (arrStr[i-1].ToString() == oItem.HSendMan)
+                        if (arrStr[i - 1].ToString() == oItem.HSendMan)
                         {
                             sb.HReadFlag = true;
                         }
                         oBill.DetailColl2.Add(sb);
                     }
+
                     oBill.omodel = oItem;
                 }
                
@@ -174,7 +196,7 @@
                 bool bResult;
                 if (refSav == "Add")
                 {
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);                  
                     if (bResult)
                     {
                         objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //杩斿洖涓籌D
@@ -190,8 +212,8 @@
                             {
                                 objJsonResult.Verify = "N";
                             }
-                        }
-                    }
+                        }                       
+                    }                    
 
                 }
                 else
@@ -228,14 +250,7 @@
         }
         #endregion
 
-        #region [鎶ュ伐鍙板紓甯稿弽棣堝崟瀹℃牳銆佸弽瀹℃牳]
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="HInterID">鍗曟嵁ID</param>
-        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
-        /// <param name="CurUserName">瀹℃牳浜�</param>
-        /// <returns></returns>
+        #region [鎶ュ伐鍙板紓甯稿弽棣堝崟瀹℃牳銆佸弽瀹℃牳]      
         [Route("Sc_MESTransFerWorkBill/AuditTransFerReportList")]
         [HttpGet]
         public object AuditTransFerReportList(int HInterID, int IsAudit, string CurUserName)
@@ -316,8 +331,31 @@
                 }
                 if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackBill_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;                     
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;            
+                        return objJsonResult;
+                    }
+                    //==================================================================================  
+
                     //瀹℃牳鎻愪氦
-                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CheckBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -336,8 +374,30 @@
                 }
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_OA_ErrMsgBackBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackBill_BeforeUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //===========================================================     
+
                     //鍙嶅鏍告彁浜bandonCheck
-                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.AbandonCheck(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -367,6 +427,188 @@
         }
         #endregion
 
+        #region 寮傚父鍙嶉鍗� 鍏抽棴/鍙嶅叧闂姛鑳�
+        [Route("Sc_MESTransFerWorkBill/CloseOA_ErrMsgBackBill")]
+        [HttpGet]
+        public object CloseOA_ErrMsgBackBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackBill_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;
+                }
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+                ClsPub.CurUserName = user;
+                DLL.ClsOA_ErrMsgBackBill oBill = new DLL.ClsOA_ErrMsgBackBill();          //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (Type == 1)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (Type == 2) //鍙嶅叧闂垽鏂�
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (Type == 1) //鍏抽棴鎻愪氦
+                {
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackBill_AfterCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (Type == 2) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackBill_AfterUnCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 寮傚父鍙嶉鍒楄〃
 
         [Route("Sc_MESTransFerWorkBill/Get_TransFerBillList")]
@@ -390,7 +632,7 @@
                 if (sWhere == null || sWhere.Equals(""))
                 {
                     string sql = "select * from h_v_OA_ErrMsgBackBillList order by 鍗曟嵁鍙� desc";
-                    ds = oCN.RunProcReturn(sql, "p_v_OA_ErrMsgBackBillList");
+                    ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackBillList");
                 }
                 else
                 {
@@ -426,8 +668,7 @@
 
         public static DataSet Get_TransFerBillList(string sWhere)
         {
-            //var sql = "select A.HInterID,b.HEntryID,A.HBillNo,A.HContext,A.HDeptID,D.HName HDeptName, A.HSendMan, B.HReceiveMan,A.HLevel,A.HDescription,case when B.HReadFlag=0 then '鏈槄' when B.HReadFlag=1 then '宸查槄' end HReadFlag, A.HMaker,A.HMakeDate,A.HUpDater,A.HUpDateDate" +
-            //   " from OA_InformBillMain A inner join  OA_InformBillSub B on A.HInterID=B.HInterID left join Gy_Department D on A.HDeptID=D.HItemID where 1=1 " + sWhere;
+          
             var sql = string.Format(@"select A.HInterID,b.HEntryID,A.HBillStatus,A.HBillNo,A.HDate,A.HContext,A.HDescription,A.HRemark,A.HQty,case when A.HSendType=0 then '鍏叡' when B.HReadFlag=1 then '涓汉' end HSendType,
                                       A.HDeptID,D.HName HDeptName, A.HSendMan, 
                                       A.HReceiveMan,B.HReceiveMan HCopyMan,A.HHasten, case when A.HLevel=0 then '鏅��' when B.HReadFlag=1 then '绱ф��' end HLevel,A.HMaterName,A.HMaterModel,
@@ -439,6 +680,61 @@
             return new SQLHelper.ClsCN().RunProcReturn(sql, "OA_ErrMsgBackBillMain");
         }
 
+        #endregion
+
+        #region 寮傚父鍙嶉鍗� 鍒嗛〉鍒楄〃
+        [Route("Sc_MESTransFerWorkBill/Get_TransFerBillListPage")]
+        [HttpGet]
+        public json Get_TransFerBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sc_WorkBeginDotCheckBillMain_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackBillList " + page + "," + size + ",''", "h_p_OA_ErrMsgBackBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_OA_ErrMsgBackBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
         #endregion
 
         #region 寮傚父鍙嶉鍒楄〃PDA
@@ -506,17 +802,7 @@
             if (string.IsNullOrEmpty(HID))
                 return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
             SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-            string sql =string.Format(@"select A.HInterID,b.HEntryID,A.HBillStatus,A.HBillNo,A.HDate,A.HContext,A.HDescription,A.HRemark,
-                                        A.HQty,A.HSendType,
-                                        A.HDeptID,D.HName HDeptName, A.HSendMan, 
-                                        A.HReceiveMan,A.HCopyMan,A.HHasten,
-                                        A.HLevel,A.HMaterName,A.HMaterModel,
-                                        B.HReadFlag, A.HMaker,A.HMakeDate,A.HUpDater,A.HUpDateDate,A.HChecker,A.HCheckDate,A.HCloseMan,A.HCloseDate,A.HDeleteMan,A.HDeleteDate,
-                                        A.HSourceInterID,A.HSourceEntryID,A.HSourceBillNo,A.HSourceBillType
-                                        from OA_ErrMsgBackBillMain A 
-                                        inner join  OA_ErrMsgBackBillSub2 B on A.HInterID=B.HInterID 
-                                        left join Gy_Department D on A.HDeptID=D.HItemID
-                                        where A.HInterID='" + HID + "' and b.HEntryID='" + HEntryID + "'");
+            string sql =string.Format(@"select * from h_v_OA_ErrMsgBackBillEdit  where HInterID='" + HID + "' and HEntryID='" + HEntryID + "'");
             var dataSet = oCN.RunProcReturn(sql, "OA_ErrMsgBackBillMain");
             if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
                 return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄥ崟鍙�" };
@@ -541,11 +827,8 @@
         }
         #endregion
 
-        #region [妯″叿鏀瑰埗鐢宠鍗曞垹闄ゅ姛鑳絔
-        /// <summary>
-        /// 妯″叿鏀瑰埗鐢宠鍗曞垹闄ゅ姛鑳�
-        /// </summary>
-        /// <returns></returns>
+        #region [寮傚父鍙嶉鍗曞垹闄ゅ姛鑳絔
+      
         [Route("Sc_MESTransFerWorkBill/Get_DeleteTransFerBill")]
         [HttpGet]
         public object Get_DeleteTransFerBill(string HInterID,string HEntryID, string user)
@@ -599,7 +882,30 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                    bool IsDete = oBill.DeleteBill(lngBillKey, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+                    //鍒犻櫎鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackBill_BeforeDelCtrl  " + BillOld1.omodel.HInterID + ",'" + BillOld1.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackBill_BeforeDelCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================  
+
+                    bool IsDete = oBill.DeleteBill(lngBillKey, HEntryID, "h_p_OA_ErrMsgBackBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
                     if (IsDete)
                     {
                         objJsonResult.code = "1";
@@ -1004,6 +1310,7 @@
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    _ = SendDingDingAsync(oBill.omodel.HSendMan, oBill.omodel.HHandleEmpID,oBill.omodel.HDescription,"");
                 }
                 else if (refSav == "Update")
                 {
@@ -1051,8 +1358,8 @@
             {
                 List<object> columnNameList = new List<object>();
 
-                string sql = "select * from h_v_OA_ErrMsgBackReceiveBillMainList where hmainid='"+HID+"'";
-                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillMainList");
+                string sql = "select * from h_v_OA_ErrMsgBackReceiveBillMainEdit where hmainid='" + HID+"'";
+                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillMainEdit");
 
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -1134,6 +1441,61 @@
                 objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 寮傚父鍙嶉鎺ユ敹鍗曞垪琛� 鍒嗛〉鍒楄〃
+        [Route("Sc_MESTransFerWorkBill/Get_OA_ErrMsgBackReceiveBillListPage")]
+        [HttpGet]
+        public json Get_OA_ErrMsgBackReceiveBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackReceiveBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackReceiveBillList " + page + "," + size + ",''", "h_p_OA_ErrMsgBackReceiveBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackReceiveBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_OA_ErrMsgBackReceiveBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
             }
         }
         #endregion
@@ -1617,8 +1979,30 @@
                 //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
                 if (IsAudit == 0) //鍏抽棴鎻愪氦
                 {
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackReceiveBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackReceiveBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================   
+
                     //鍏抽棴鎻愪氦
-                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackReceiveBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -1637,8 +2021,31 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
+
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackReceiveBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackReceiveBill_BeforeUnCloseCtrl    ");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
                     //鍙嶅叧闂彁浜�
-                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackReceiveBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -1805,6 +2212,84 @@
         }
         #endregion
 
+        #region 寮傚父鍙嶉鎺ユ敹鍗曞垪琛�(寮傚父鍙嶉鍒峰崱绛惧埌)
+
+        [Route("OA_ErrMsgBackSignBill_BrushCard/ErrMsgBackReceive")]
+        [HttpGet]
+        public object ErrMsgBackReceive(string sWhere,string num, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackReceiveBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (num=="2")       //鎶ュ伐鍙拌幏鍙栧埛鍗$鍒版暟鎹�
+                {
+                    if (sWhere == null || sWhere.Equals(""))
+                    {
+                        string sql = "select * from h_v_SingOA_ErrMsgBackList_BrushCard order by 鍗曟嵁鍙� desc";
+                        ds = oCN.RunProcReturn(sql, "h_v_SingOA_ErrMsgBackList_BrushCard");
+                    }
+                    else
+                    {
+                        string sql1 = "select * from h_v_SingOA_ErrMsgBackList_BrushCard where 1 = 1 ";
+                        string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                        ds = oCN.RunProcReturn(sql, "h_v_SingOA_ErrMsgBackList_BrushCard");
+                    }
+                }
+                else   //鍘熸湁鐨勫埛鍗$鍒拌幏鍙栨暟鎹�
+                {
+                    {
+                        if (sWhere == null || sWhere.Equals(""))
+                        {
+                            string sql = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard order by 鍗曟嵁鍙� desc";
+                            ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
+                        }
+                        else
+                        {
+                            string sql1 = "select * from h_v_OA_ErrMsgBackReceiveBillList_BrushCard where 1 = 1 ";
+                            string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                            ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackReceiveBillList_BrushCard");
+                        }
+                    }
+                }
+                
+               
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #endregion
 
         #region  寮傚父鍙嶉绛惧埌鍗�
@@ -1920,6 +2405,7 @@
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    _ = SendDingDingAsync(oBill.omodel.HSendMan, 1, oBill.omodel.HDescription, oBill.omodel.HReceiveMan);
                 }
                 else if (refSav == "Update")
                 {
@@ -1931,6 +2417,31 @@
                 }
                 if (bResult)
                 {
+                    //鑷姩瀹℃牳璁剧疆
+                    if (refSav == "Add")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        //绯荤粺鍙傛暟  鑷姩瀹℃牳
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
+                        {
+                            if (oSystemParameter.omodel.OA_ErrMsgBackSignBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                            {
+                                objJsonResult.Verify = "Y";
+                            }
+                            else
+                            {
+                                objJsonResult.Verify = "N";
+                            }
+                        }
+                    }
+                    else
+                    if (refSav == "Update")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        objJsonResult.Verify = "N";
+                    }
+
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -1967,8 +2478,8 @@
             {
                 List<object> columnNameList = new List<object>();
 
-                string sql = "select * from h_v_OA_ErrMsgBackSignBillMainList where hmainid='" + HID + "'";
-                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackSignBillMainList");
+                string sql = "select * from h_v_OA_ErrMsgBackSignBillMainEdit where hmainid='" + HID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackSignBillMainEdit");
 
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -2050,6 +2561,61 @@
                 objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 寮傚父鍙嶉绛惧埌鍗曞垪琛� 鍒嗛〉鍒楄〃
+        [Route("Sc_MESTransFerWorkBill/Get_OA_ErrMsgBackSignBillListPage")]
+        [HttpGet]
+        public json Get_OA_ErrMsgBackSignBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackSignBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackSignBillList " + page + "," + size + ",''", "h_p_OA_ErrMsgBackSignBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackSignBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_OA_ErrMsgBackSignBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
             }
         }
         #endregion
@@ -2533,8 +3099,31 @@
                 //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
                 if (IsAudit == 0) //鍏抽棴鎻愪氦
                 {
+
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackSignBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackSignBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================    
+
                     //鍏抽棴鎻愪氦
-                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackSignBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -2553,8 +3142,32 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
+
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackSignBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackSignBill_BeforeUnCloseCtrl    ");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
                     //鍙嶅叧闂彁浜�
-                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackSignBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -2836,6 +3449,7 @@
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    _ = SendDingDingAsync(oBill.omodel.HSendMan, 2, oBill.omodel.HDescription, oBill.omodel.HReceiveMan);
                 }
                 else if (refSav == "Update")
                 {
@@ -2847,6 +3461,32 @@
                 }
                 if (bResult)
                 {
+
+                    //鑷姩瀹℃牳璁剧疆
+                    if (refSav == "Add")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        //绯荤粺鍙傛暟  鑷姩瀹℃牳
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
+                        {
+                            if (oSystemParameter.omodel.OA_ErrMsgBackHandleBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                            {
+                                objJsonResult.Verify = "Y";
+                            }
+                            else
+                            {
+                                objJsonResult.Verify = "N";
+                            }
+                        }
+                    }
+                    else
+                    if (refSav == "Update")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        objJsonResult.Verify = "N";
+                    }
+
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -2883,8 +3523,8 @@
             {
                 List<object> columnNameList = new List<object>();
 
-                string sql = "select * from h_v_OA_ErrMsgBackHandleBillMainList where hmainid='" + HID + "'";
-                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackHandleBillMainList");
+                string sql = "select * from h_v_OA_ErrMsgBackHandleBillMainEdit where hmainid='" + HID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackHandleBillMainEdit");
 
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -2969,6 +3609,63 @@
             }
         }
         #endregion
+
+        #region 寮傚父鍙嶉澶勭悊鍗� 鍒嗛〉鍒楄〃
+        [Route("Sc_MESTransFerWorkBill/Get_OA_ErrMsgBackHandleBillListPage")]
+        [HttpGet]
+        public json Get_OA_ErrMsgBackHandleBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackHandleBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackHandleBillList " + page + "," + size + ",''", "h_p_OA_ErrMsgBackHandleBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackHandleBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_OA_ErrMsgBackHandleBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
+        #endregion
+
+
         #region 寮傚父鍙嶉澶勭悊鍗曞垪琛≒DA
 
         [Route("Sc_MESTransFerWorkBill/Get_OA_ErrMsgBackHandleBillList_PDA")]
@@ -3446,8 +4143,31 @@
                 //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
                 if (IsAudit == 0) //鍏抽棴鎻愪氦
                 {
+
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackHandleBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackHandleBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
                     //鍏抽棴鎻愪氦
-                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackHandleBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -3466,8 +4186,31 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
+
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackHandleBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackHandleBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================
+
                     //鍙嶅叧闂彁浜�
-                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackHandleBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -3749,6 +4492,7 @@
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    _ = SendDingDingAsync(oBill.omodel.HReceiveMan, 0, oBill.omodel.HDescription, oBill.omodel.HCopyMan);
                 }
                 else if (refSav == "Update")
                 {
@@ -3760,6 +4504,32 @@
                 }
                 if (bResult)
                 {
+
+                    //鑷姩瀹℃牳璁剧疆
+                    if (refSav == "Add")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        //绯荤粺鍙傛暟  鑷姩瀹℃牳
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
+                        {
+                            if (oSystemParameter.omodel.OA_ErrMsgBackCheckBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                            {
+                                objJsonResult.Verify = "Y";
+                            }
+                            else
+                            {
+                                objJsonResult.Verify = "N";
+                            }
+                        }
+                    }
+                    else
+                    if (refSav == "Update")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        objJsonResult.Verify = "N";
+                    }
+
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -3796,8 +4566,8 @@
             {
                 List<object> columnNameList = new List<object>();
 
-                string sql = "select * from h_v_OA_ErrMsgBackCheckBillMainList where hmainid='" + HID + "'";
-                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackCheckBillMainList");
+                string sql = "select * from h_v_OA_ErrMsgBackCheckBillMainEdit where hmainid='" + HID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_OA_ErrMsgBackCheckBillMainEdit");
 
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -3879,6 +4649,61 @@
                 objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 寮傚父鍙嶉楠屾敹鍗� 鍒嗛〉鍒楄〃
+        [Route("Sc_MESTransFerWorkBill/Get_OA_ErrMsgBackCheckBillListPage")]
+        [HttpGet]
+        public json Get_OA_ErrMsgBackCheckBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackCheckBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackCheckBillList " + page + "," + size + ",''", "h_p_OA_ErrMsgBackCheckBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackCheckBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_OA_ErrMsgBackCheckBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
             }
         }
         #endregion
@@ -4359,8 +5184,30 @@
                 //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
                 if (IsAudit == 0) //鍏抽棴鎻愪氦
                 {
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackCheckBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackCheckBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================    
+
                     //鍏抽棴鎻愪氦
-                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackCheckBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -4379,8 +5226,32 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
+
+
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_OA_ErrMsgBackCheckBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_ErrMsgBackCheckBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
                     //鍙嶅叧闂彁浜�
-                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_OA_ErrMsgBackCheckBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -4548,5 +5419,2503 @@
         #endregion
 
         #endregion
+
+        #region  瀹夌伅閫愮骇鍛煎彨瑙勫垯
+
+        #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯 鏂板/缂栬緫      
+        [Route("Sc_MESTransFerWorkBill/SaveOA_AndengFlowRuleBill")]
+        [HttpPost]
+        public object SaveOA_AndengFlowRuleBill([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString(); //瀛愯〃
+            string refSav = sArray[2].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗
+            string msg4 = sArray[3].ToString();//鐢ㄦ埛鍚�
+
+            DBUtility.ClsPub.CurUserName = msg4;
+
+            string UserName = "";
+            string s = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("OA_AndengFlowRuleBillMain_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                // OA_AndengFlowRuleBill
+                DAL.ClsOA_AndengFlowRuleBill oBill = new DAL.ClsOA_AndengFlowRuleBill();
+                List<Model.ClsOA_AndengFlowRuleBillMain> lsmain = new List<Model.ClsOA_AndengFlowRuleBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_OA_AndengFlowRuleBill(msg2);
+                foreach (Model.ClsOA_AndengFlowRuleBillMain oItem in lsmain)
+                {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillNew1.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld1.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld1.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld1.omodel.HChecker != "" && oBill.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld1.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "4533";
+                    oItem.HBillSubType = "4533";
+
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                // 琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                List<Model.ClsOA_AndengFlowRuleBillSub> ls = new List<Model.ClsOA_AndengFlowRuleBillSub>();
+                ls = oListModels.getObjectByJson_OA_AndengFlowRuleBillSub(msg3);
+                int i = 0;
+                foreach (Model.ClsOA_AndengFlowRuleBillSub oItemSub in ls)
+                {
+                    i++;
+                    oItemSub.HEntryID = i;
+
+
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (refSav == "Add")
+                {
+
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else if (refSav == "Update")
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = false;
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯 缂栬緫鍥炴樉鍒楄〃
+
+        [Route("Sc_MESTransFerWorkBill/Edit_OA_AndengFlowRuleBill")]
+        [HttpGet]
+        public object Edit_OA_AndengFlowRuleBill(string HID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select * from h_v_OA_AndengFlowRuleBillMainEdit where hmainid='" + HID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_OA_AndengFlowRuleBillMainEdit");
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯鍒楄〃
+
+        [Route("Sc_MESTransFerWorkBill/Get_OA_AndengFlowRuleBillList")]
+        [HttpGet]
+        public object Get_OA_AndengFlowRuleBillList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_AndengFlowRuleBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    string sql = "select * from h_v_OA_AndengFlowRuleBillMainList order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_OA_AndengFlowRuleBillMainList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_OA_AndengFlowRuleBillMainList where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_OA_AndengFlowRuleBillMainList");
+                }
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Sc_MESTransFerWorkBill/DeleteOA_AndengFlowRuleBill")]
+        [HttpGet]
+        public object DeleteOA_AndengFlowRuleBill(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+                DAL.ClsOA_AndengFlowRuleBill BillOld = new DAL.ClsOA_AndengFlowRuleBill();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_AndengFlowRuleBillMain_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙垹闄�
+                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_OA_AndengFlowRuleBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_OA_AndengFlowRuleBill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================  
+
+
+
+                oCN.BeginTran();
+
+                oCN.RunProc("delete from OA_AndengFlowRuleBillMain where HInterID = " + HInterID);
+                oCN.RunProc("delete from OA_AndengFlowRuleBillSub where HInterID= " + HInterID);
+
+                //鍒犻櫎鍚庢帶鍒�==================================================================================      
+                string sql2 = "exec h_p_OA_AndengFlowRuleBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_OA_AndengFlowRuleBill_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    s = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //==============================================================================================
+
+                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.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯 瀹℃牳/鍙嶅鏍�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/AuditOA_AndengFlowRuleBill")]
+        [HttpGet]
+        public object AuditOA_AndengFlowRuleBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_AndengFlowRuleBillMain_Check";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_AndengFlowRuleBill oBill = new DAL.ClsOA_AndengFlowRuleBill();               //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (oBill.omodel.HChecker.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
+                {
+                    oCN.BeginTran();
+
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_AndengFlowRuleBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_AndengFlowRuleBill_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_OA_AndengFlowRuleBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        oCN.Commit();
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
+                {
+
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_OA_AndengFlowRuleBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_AndengFlowRuleBill_BeforeUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //===========================================================          
+
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_OA_AndengFlowRuleBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                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="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param>
+        /// <param name="CurUserName">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/CloseOA_AndengFlowRuleBill")]
+        [HttpGet]
+        public object CloseOA_AndengFlowRuleBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_AndengFlowRuleBillMain_Close";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_AndengFlowRuleBill oBill = new DAL.ClsOA_AndengFlowRuleBill();             //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅叧闂垽鏂�
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (IsAudit == 0) //鍏抽棴鎻愪氦
+                {
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                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="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param>
+        /// <param name="CurUserName">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/DeleteOA_AndengFlowRuleBill")]
+        [HttpGet]
+        public object DeleteOA_AndengFlowRuleBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_AndengFlowRuleBillMain_Drop";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_AndengFlowRuleBill oBill = new DAL.ClsOA_AndengFlowRuleBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HChecker.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //浣滃簾鍒ゆ柇
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶄綔搴熷垽鏂�
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣�
+                if (IsAudit == 0) //浣滃簾鎻愪氦
+                {
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_OA_AndengFlowRuleBill_BeforeDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_AndengFlowRuleBill_BeforeDropCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.Cancelltion(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_OA_AndengFlowRuleBill_AfterDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶄綔搴熸彁浜�
+                {
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_OA_AndengFlowRuleBill_BeforeUnDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_OA_AndengFlowRuleBill_BeforeUnDropCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //===========================================================          
+
+                    //鍙嶄綔搴熸彁浜�
+                    if (oBill.AbandonCancelltion(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_MouldMaintainRuleBill_AfterUnDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熸垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗�
+
+        #region 宸ヤ綔鑱旂郴鍗曚繚瀛�/缂栬緫
+        /// <summary>
+        /// 宸ヤ綔鑱旂郴鍗�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/SaveOA_WorkLinkBill")]
+        [HttpPost]
+        public object SaveOA_WorkLinkBill([FromBody] JObject msg)
+        {
+
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();//涓昏〃鍐呭
+            string UserName = sArray[1].ToString();
+            string refSav = sArray[2].ToString();
+            DBUtility.ClsPub.CurUserName = UserName;
+
+            //淇濆瓨鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("OA_WorkLinkBill_Edit", 1, false, DBUtility.ClsPub.CurUserName))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+            string s = "";
+            //int sYear = 0;
+            //int sPeriod = 0;
+            //if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DateTime.Now, ref sYear, ref sPeriod, ref s) == false)
+            //{
+            //    objJsonResult.code = "0";
+            //    objJsonResult.count = 0;
+            //    objJsonResult.Message = s;
+            //    objJsonResult.data = null;
+            //    return objJsonResult;
+            //}
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();
+                List<Model.ClsOA_WorkLinkBillMain> lsmain = new List<Model.ClsOA_WorkLinkBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                var jsonString = "[" + msg2.ToString() + "]";
+                lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsOA_WorkLinkBillMain>>(jsonString);
+                foreach (Model.ClsOA_WorkLinkBillMain oItem in lsmain)
+                {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillNew2.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld2.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld2.omodel.HChecker != "" && BillOld2.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld2.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld2, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+
+                    DBUtility.ClsPub.CurUserName = oItem.HMaker;
+                    oItem.HBillType = "4501";
+                    oItem.HBillSubType = "4501";
+                    oItem.HBillStatus = 1;   //鍗曟嵁鐘舵�侊紙1鏈锛�2瀹℃牳閫氳繃锛�3鍏抽棴锛�4浣滃簾锛�5瀹℃牳閫�鍥�,6瀹℃牳涓�,7宸查槄锛�8宸插洖澶嶏紝9缁撴锛�10楠岃瘉,11涓嬭揪锛�12寮�宸�,13鐢宠瀹℃壒,15鐢宠妫�楠岋紝16 鍒ゅ畾鍚堟牸锛�17鍒ゅ畾涓嶅悎鏍硷級     
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    //string[] arrStr = oItem.HSendMan.Split(','); //鍙戦�佷汉
+                    //arrStr = oItem.HReceiveMan.Split(',');  //鎺ユ敹浜�
+                    string[] arrStr = oItem.HCopyMan.Split(',');  //鎶勯�佷汉
+                    if (!string.IsNullOrEmpty(oItem.HCopyMan))
+                    {
+                        arrStr = oItem.HCopyMan.Split(',');  // 鎶勯�佷汉
+                        List<string> b = new List<string>(arrStr);
+                        b.Add(oItem.HReceiveMan);
+                        arrStr = b.ToArray();
+                    }
+                    else
+                    {
+                        arrStr = oItem.HReceiveMan.Split(',');//鎺ユ敹浜�
+                    }
+                    //鎶勯�佷汉琛ㄤ綋鏁版嵁
+                    for (int i = 1; i <= arrStr.Length; i++)
+                    {
+                        Model.ClsOA_WorkLinkBillSub2 sb = new Model.ClsOA_WorkLinkBillSub2();
+                        sb.HEntryID = i;
+                        sb.HReceiveMan = arrStr[i - 1];
+                        if (arrStr[i - 1].ToString() == oItem.HSendMan)
+                        {
+                            sb.HReadFlag = true;
+                        }
+                        oBill.DetailColl2.Add(sb);
+                    }
+                    oBill.omodel = oItem;
+                }
+
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (refSav == "Add")
+                {
+                    bResult = oBill.AddBillNew(ref DBUtility.ClsPub.sExeReturnInfo);
+
+                }
+                else
+                {
+                    bResult = oBill.ModifyBillNew(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.Message;
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曞垪琛�
+        [Route("Sc_MESTransFerWorkBill/GetOA_WorkLinkBillList")]
+        [HttpGet]
+        public object GetOA_WorkLinkBillList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_WorkLinkBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    string sql = "select * from h_v_OA_WorkLinkBillAllList order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_OA_WorkLinkBillAllList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_OA_WorkLinkBillAllList where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_OA_WorkLinkBillAllList");
+                }
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曠紪杈戣幏鍙栨暟鎹�
+        [Route("Sc_MESTransFerWorkBill/GetOA_WorkLinkBillListCheckDetai")]
+        [HttpGet]
+        public object GetOA_WorkLinkBillListCheckDetai(string HID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = string.Format(@"select A.*,D.HName HDeptName,e.HName HEvaluateStatusName
+                                        from OA_WorkLinkBillMain A 
+                                        left join Gy_Department D on A.HDeptID=D.HItemID
+                                        left join Gy_EvaluateStatus AS e ON A.HEvaluateStatusID = e.HItemID
+                                        where A.HInterID='" + HID + "'" ); ;
+                ds = oCN.RunProcReturn(sql, "OA_WorkLinkBillMain");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+        #endregion
+
+        #region[鏇存敼宸ヤ綔鑱旂郴鍗曢槄璇荤姸鎬乚
+        [Route("Sc_MESTransFerWorkBill/UpdateOA_WorkLinkBillFlagMessage")]
+        [HttpGet]
+        public object UpdateOA_WorkLinkBillFlagMessage(string HInterID, string HEntryID)
+        {
+            oCN.BeginTran();
+            oCN.RunProc("Update OA_WorkLinkBillSub2 set HReadFlag=1 where HInterID='" + HInterID + "' and HEntryID='" + HEntryID + "'", ref ClsPub.sExeReturnInfo);
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = ClsPub.sExeReturnInfo;
+            objJsonResult.data = null;
+            return objJsonResult; ;
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曞垹闄�
+        /// <summary>
+        ///鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/DeltetOA_WorkLinkBill")]
+        [HttpGet]
+        public object DeltetOA_WorkLinkBill(string HInterID, string user)
+        {
+            try
+            {
+
+                string s = "";
+                DAL.ClsOA_WorkLinkBill BillOld = new DAL.ClsOA_WorkLinkBill();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("OA_WorkLinkBill_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙垹闄�
+                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();
+                oCN.RunProc("Delete From OA_WorkLinkBillMain where HInterID = " + HInterID);
+                oCN.RunProc("Delete From OA_WorkLinkBillSub2 where HInterID = " + HInterID);
+                oCN.RunProc("Delete From OA_WorkLinkBillSub where HInterID = " + HInterID);
+                oCN.Commit();
+
+                
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗� 瀹℃牳/鍙嶅鏍�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/AuditOA_WorkLinkBill")]
+        [HttpGet]
+        public object AuditOA_WorkLinkBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_WorkLinkBill_Check";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();               //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (oBill.omodel.HChecker.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();
+
+                //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
+                if (IsAudit == 0) //瀹℃牳鎻愪氦
+                {
+                    //瀹℃牳鍗曟嵁
+                    if (!oBill.CheckBill(HInterID, ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅鏍告彁浜�
+                {
+                    //鍙嶅鏍稿崟鎹�
+                    if (!oBill.AbandonCheck(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="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param>
+        /// <param name="CurUserName">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/CloseOA_WorkLinkBill")]
+        [HttpGet]
+        public object CloseOA_WorkLinkBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_WorkLinkBill_Close";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();             //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅叧闂垽鏂�
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (IsAudit == 0) //鍏抽棴鎻愪氦
+                {
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                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="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param>
+        /// <param name="CurUserName">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/DropOA_WorkLinkBill")]
+        [HttpGet]
+        public object DropOA_WorkLinkBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "OA_WorkLinkBill_Delete";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HChecker.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 0)  //浣滃簾鍒ゆ柇
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶄綔搴熷垽鏂�
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣�
+                if (IsAudit == 0) //浣滃簾鎻愪氦
+                {
+                    //浣滃簾鎻愪氦
+                    if (oBill.Cancelltion(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.AbandonCancelltion(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熸垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                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="msg"></param>
+        /// <returns></returns>
+        [Route("Sc_MESTransFerWorkBill/ReplyOA_WorkLinkBill")]
+        [HttpPost]
+        public object ReplyOA_WorkLinkBill([FromBody] JObject msg)
+        {
+
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString(); 
+            string UserName = sArray[1].ToString();
+            //string refSav = sArray[2].ToString();
+            DBUtility.ClsPub.CurUserName = UserName;
+
+            //淇濆瓨鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("OA_WorkLinkBill_Edit", 1, false, DBUtility.ClsPub.CurUserName))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+            string s = "";
+            //int sYear = 0;
+            //int sPeriod = 0;
+            //if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DateTime.Now, ref sYear, ref sPeriod, ref s) == false)
+            //{
+            //    objJsonResult.code = "0";
+            //    objJsonResult.count = 0;
+            //    objJsonResult.Message = s;
+            //    objJsonResult.data = null;
+            //    return objJsonResult;
+            //}
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();
+                List<Model.ClsOA_WorkLinkBillSub> lsmain = new List<Model.ClsOA_WorkLinkBillSub>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+
+                var jsonString = "[" + msg2.ToString() + "]";
+                lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsOA_WorkLinkBillSub>>(jsonString);
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                if (lsmain[0].HInterID != 0)
+                {
+
+                    oCN.BeginTran();
+
+                    DataSet Ds = oCN.RunProcReturn("select count(HInterID) as num from OA_WorkLinkBillSub where HInterID = " + lsmain[0].HInterID + " group by HInterID ", "OA_WorkLinkBillSub");
+
+                    Int64 num = 0;
+
+                    if (Ds.Tables[0].Rows.Count == 0)
+                    {
+                        num = 1;
+                    }
+                    else
+                    {
+                        num = Convert.ToInt64(Ds.Tables[0].Rows[0]["num"]) + 1;
+                    }
+
+                    //涓昏〃
+                    oCN.RunProc("Insert Into OA_WorkLinkBillSub   " +
+                    "(HInterID,HEntryID,HRemark,HSendStatus,HSendMan" +
+                    ",HDescription,HDate" +
+                    ",HCloseMan,HEntryCloseDate,HCloseType,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                    ") " +
+                    " values(" + lsmain[0].HInterID + "," + num + ",'" + lsmain[0].HRemark + "'," + 1 + ",'" + lsmain[0].HSendMan + "'" +
+                    ",'" + lsmain[0].HDescription + "','" + lsmain[0].HDate + "','" + lsmain[0].HCloseMan + "','" + "" + "'" +
+                    "," + 0 + "," + lsmain[0].HSourceInterID + "," + lsmain[0].HSourceEntryID + ",'" + lsmain[0].HSourceBillNo + "'" +
+                    ",'" + lsmain[0].HSourceBillType + "'," + lsmain[0].HRelationQty + "," + lsmain[0].HRelationMoney +
+                    ") ");
+
+                    oCN.Commit();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍥炲鎴愬姛锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍥炲澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = e.Message;
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曞洖澶嶈幏鍙栨暟鎹�
+        [Route("Sc_MESTransFerWorkBill/GetOA_WorkLinkBillSub")]
+        [HttpGet]
+        public object GetOA_WorkLinkBillSub(string HInterID, string user)
+        {
+            try
+            {
+
+                string sql = "select * from OA_WorkLinkBillSub where HInterID = '" + HInterID + "'order by HDate desc";
+                ds = oCN.RunProcReturn(sql, "OA_WorkLinkBillSub");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曞洖澶嶆洿鏀圭姸鎬�
+        [Route("Sc_MESTransFerWorkBill/UpdateOA_WorkLinkBillSubStatus")]
+        [HttpGet]
+        public object UpdateOA_WorkLinkBillSubStatus(Int64 HInterID, string HEntryID, Int64 Type)
+        {
+            try
+            {
+                string sql = "";
+                switch (Type)
+                {
+                    case 9:
+                        sql = "update OA_WorkLinkBillSub set HSendStatus = 9 where HInterID = " + HInterID + " and HEntryID in (" + HEntryID + ")";
+                        break;
+                    case 10:
+                        sql = "update OA_WorkLinkBillSub set HSendStatus = 10 where HInterID = " + HInterID + " and HEntryID in (" + HEntryID + ")";
+                        break;
+                }
+
+                oCN.RunProc(sql);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曞偓淇�
+        [Route("Sc_MESTransFerWorkBill/UpdateOA_WorkLinkBillHHasten")]
+        [HttpGet]
+        public object UpdateOA_WorkLinkBillHHasten(Int64 HInterID,string CurUserName)
+        {
+            try
+            {
+                //鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("OA_WorkLinkBill_Edit", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+                DAL.ClsOA_WorkLinkBill oBill = new DAL.ClsOA_WorkLinkBill();               //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HCloseMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍌績锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍌績锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                string sql = "update OA_WorkLinkBillMain set HHasten = HHasten + 1 where HInterID = " + HInterID ;
+
+                oCN.RunProc(sql);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 宸ヤ綔鑱旂郴鍗曟牴鎹簮鍗旾D鏌ョ湅鏄惁鏈夊搴旇仈绯诲崟
+        [Route("Sc_MESTransFerWorkBill/GetOA_WorkLinkBillListBySourceID")]
+        [HttpGet]
+        public object GetOA_WorkLinkBillListBySourceID(string HRelationInterID, string HRelationEntryID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = string.Format(@"select A.*,D.HName HDeptName,e.HName HEvaluateStatusName
+                                        from OA_WorkLinkBillMain A 
+                                        left join Gy_Department D on A.HDeptID=D.HItemID
+                                        left join Gy_EvaluateStatus AS e ON A.HEvaluateStatusID = e.HItemID
+                                        where A.HRelationInterID='" + HRelationInterID + "' and A.HRelationEntryID= '"+ HRelationEntryID+"'"); ;
+                ds = oCN.RunProcReturn(sql, "OA_WorkLinkBillMain");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+        #endregion
+
+        #endregion
+
+
+        #region 寮傚父鍙嶉 鎺ユ敹,澶勭悊,楠屾敹鍗曚繚瀛樺彂閫佹秷鎭�
+        /// <summary>
+        /// 寮傚父鍙嶉 鎺ユ敹,澶勭悊,楠屾敹鍗曚繚瀛樺彂閫佹秷鎭�
+        /// </summary>
+        /// <param name="HSendMan"></param>
+        /// <param name="HHandleEmpID"></param>
+        /// <param name="HDescription"></param>
+        /// <param name="HCopyMan"></param>
+        /// <returns></returns>
+        public async Task<object> SendDingDingAsync(string HSendMan, int HHandleEmpID,string HDescription,string HCopyMan)
+        {
+            
+            string concatenatedNames = "";
+            string appKey = "";
+            string appSecret = "";
+            string sReturn = "";
+            string agentIds = "";
+            Cls_DDMsg msg = new Cls_DDMsg();
+            if (oSystemParameter.ShowBill(ref sReturn) == true)
+            {
+                //绯荤粺鍙傛暟鏄惁 N涓烘湰鍦帮紝Y涓烘柉鑾皵
+                if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "N")
+                {
+                    appKey = "dingrsrzhdyn3mlaof95";
+                     appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq";
+                    agentIds = "3118119317";
+                }
+                else if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "Y")
+                {
+                    appKey = "dingkdddbhdcssk7jduw";
+                    appSecret = "iv07c-GLfJPnzfJaNAAOfJDl3Z-eODvDAhlInMZCZhGorkle5Evbaxx3ImylvdjQ";
+                    agentIds = "3151454458";
+                }
+
+            }
+
+            if (HHandleEmpID==0) // 
+            {
+                string HReceiveMan = HSendMan;
+                string[] names = HCopyMan.Split(',');
+                string sqlNames = "";
+                foreach (string name in names)
+                {                   
+                    sqlNames += "'" + name.Trim() + "',";
+                }
+                sqlNames = sqlNames.TrimEnd(',');
+                //鑾峰彇鎸囨淳澶勭悊浜�,鍙戦�佷汉鐨勯拤閽塱d
+                string sql1 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HReceiveMan + "'," + sqlNames + ")";
+                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
+                List<string> HNames = new List<string>();
+                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                {
+                    string HName = ds.Tables[0].Rows[i]["閽夐拤id"].ToString();
+                    HNames.Add(HName);
+
+                }
+                concatenatedNames = string.Join(",", HNames);
+                HDescription = HDescription + "--宸查獙鏀�";
+            }
+            else if (HHandleEmpID==1)//寮傚父鍙嶉澶勭悊鍗�  灏嗘秷鎭� 鍙戦�佺粰 鍙戦�佷汉锛屾帴鏀朵汉
+            {
+                //鑾峰彇鍙戦�佷汉  鎺ユ敹浜�
+                string HReceiveMan = HCopyMan;
+                string sql1 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HReceiveMan + "')";
+                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");                   
+                List<string> HNames = new List<string>();
+                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                {
+                    string HName = ds.Tables[0].Rows[i]["閽夐拤id"].ToString();
+                    HNames.Add(HName);
+
+                }
+                concatenatedNames = string.Join(",", HNames);
+                HDescription = HDescription + "--宸茬鍒�";
+            }
+            else if (HHandleEmpID == 2)//寮傚父鍙嶉澶勭悊鍗�  灏嗘秷鎭� 鍙戦�佺粰 鍙戦�佷汉锛屾帴鏀朵汉
+            {
+                //鑾峰彇鍙戦�佷汉  鎺ユ敹浜�
+                string HReceiveMan = HCopyMan;
+                string sql1 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HReceiveMan + "')";
+                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
+                List<string> HNames = new List<string>();
+                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                {
+                    string HName = ds.Tables[0].Rows[i]["閽夐拤id"].ToString();
+                    HNames.Add(HName);
+
+                }
+                concatenatedNames = string.Join(",", HNames);
+                HDescription = HDescription + "--宸插鐞�";
+            }
+            else
+            {
+                //鏌ヨ鎸囨淳澶勭悊浜�
+                string sql = "select HName from Gy_Employee where HItemID='" + HHandleEmpID + "'";
+                ds = oCN.RunProcReturn(sql, "Gy_Employee");
+                string HHandleEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
+                //鑾峰彇鎸囨淳澶勭悊浜�,鍙戦�佷汉鐨勯拤閽塱d
+                string sql1 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HSendMan + "','" + HHandleEmpName + "')";
+                ds = oCN.RunProcReturn(sql1, "Gy_Czygl");
+                List<string> HNames = new List<string>();
+                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                {
+                    string HName = ds.Tables[0].Rows[i]["閽夐拤id"].ToString();
+                    HNames.Add(HName);
+
+                }
+                concatenatedNames = string.Join(",", HNames);
+                HDescription = HDescription + "--宸叉帴鏀�";
+            }
+          
+            //鑾峰彇浼佷笟鐨刟ccess_token鐨勫��
+            string response = msg.GetAccessToken(appKey, appSecret);
+            JObject responseJson = JObject.Parse(response);
+            // 鑾峰彇access_token鐨勫��
+            string accessToken = responseJson["accessToken"].ToString();
+
+            //璋冪敤鏂规硶鍙戦�佹秷鎭�           
+            string agentId = agentIds;//閽夐拤鍚庡彴寤虹珛鐨勫皬绋嬪簭id
+            string userIdList = concatenatedNames;//閽夐拤浜哄憳鐨刬d
+            string deptIdList = "0"; // 绌哄瓧绗︿覆琛ㄧず涓嶆寚瀹氶儴闂�
+            string toAllUser = "false";
+            string message = HDescription;
+            response = await msg.SendTextMessage(accessToken, agentId, userIdList, deptIdList, toAllUser, message);
+            Console.WriteLine(response);
+            return response;
+        }
+        #endregion
+
+        #region  寮傚父鍙嶉鍗曟煡璇紙鎺ユ敹鐨勶紝鍙戦�佺殑锛屾妱閫佺殑锛�
+
+        [Route("Sc_MESTransFerWorkBill/GetSc_MESTransFerWorkBillQuery")]
+        [HttpGet]
+        public object GetSc_MESTransFerWorkBillQuery(string sWhere, string user)
+        {
+            try
+            {
+                Dictionary<object, object> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<object, object>>(sWhere);
+
+
+                string HStatus = dic["HStatus"].ToString();//鏃堕棿鐘舵��
+                string HBeginDate = dic["HBeginDate"].ToString();//寮�濮嬫棩鏈�
+                string HEndDate = dic["HEndDate"].ToString();//缁撴潫鏃ユ湡
+                string HSourceID = dic["HSourceID"].ToString();//鐢熶骇璧勬簮
+
+                List<object> columnNameList = new List<object>();
+
+                ds = oCN.RunProcReturn("exec h_p_OA_ErrMsgBackSelfQuery  '" + HStatus + "','" + HBeginDate + "','" + HEndDate + "','" + HSourceID + "','" + user + "'"  , "h_p_OA_ErrMsgBackSelfQuery");
+
+                if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                {
+                    //娣诲姞鍒楀悕
+                    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;
+                    objJsonResult.list = columnNameList;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    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
+
+        #region 鎶ュ伐鍙拌烦杞紓甯稿弽棣堝崟 寮圭獥鑾峰彇鐢熶骇鐘舵�佷复鏃惰〃鐨� 鐗╂枡 鏁伴噺 淇℃伅 
+
+        [Route("Sc_MESTransFerWorkBill/Get_Sc_ICMOBillStatus")]
+        [HttpGet]
+        public object Get_Sc_ICMOBillStatus(string HSourceBill)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select a.HSourceBillNo 娴佽浆鍗″彿,a.HSourceBillType 娴佽浆鍗$被鍨�,a.HSourceInterID 娴佽浆鍗′富鍐呯爜,a.HSourceEntryID 娴佽浆鍗″瓙鍐呯爜,b.HNumber 鐗╂枡浠g爜,b.HName 鐗╂枡鍚嶇О,b.HModel 瑙勬牸鍨嬪彿,a.HDatePlanQty 璁″垝鏁伴噺,a.HSourceID,c.HName 鐢熶骇璧勬簮 from Sc_ICMOBillStatus_Tmp a " +
+                    "left join Gy_Material b on a.HMaterID=b.HItemID  left join Gy_Source c on a.HSourceID=c.HItemID where HSourceBillNo='" + HSourceBill + "' and a.HICMOStatus=1";
+                ds = oCN.RunProcReturn(sql, "Sc_ICMOBillStatus_Tmp");
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎶ュ伐鍙拌烦杞紓甯稿弽棣堝崟 寮圭獥鑾峰彇 寮傚父绫诲瀷
+
+        [Route("Sc_MESTransFerWorkBill/Get_ErrMsgBackType")]
+        [HttpGet]
+        public object Get_ErrMsgBackType(string TypeName)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select HItemID,HName from Gy_ErrMsgBackType where HName='" + TypeName + "'";
+                ds = oCN.RunProcReturn(sql, "Gy_ErrMsgBackType");
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎶ュ伐鍙拌烦杞紓甯稿弽棣堝崟 寮圭獥鑾峰彇 褰撳墠浜虹殑涓婄骇
+
+        [Route("Sc_MESTransFerWorkBill/Get_UserSuperiors")]
+        [HttpGet]
+        public object Get_UserSuperiors(string HName)
+        {
+            try
+            {
+                //string sReturn = "";
+                List<object> columnNameList = new List<object>();
+                //鏍规嵁褰撳墠浜鸿幏鍙栬亴鍔�
+                string sql = "select a.Czymc 鐢ㄦ埛鍚嶇О,c.GroupName 鑱屽姟 from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId left join System_UserGroup c on b.GroupId = c.GroupID  where a.Czymc = '"+HName+"'";
+                ds = oCN.RunProcReturn(sql, "Gy_ErrMsgBackType");
+                string Job = ds.Tables[0].Rows[0]["鑱屽姟"].ToString();
+
+                //鏍规嵁鑱屽姟鎵惧埌浠栫殑涓婄骇,缁欏彂閫佷汉榛樿涓哄綋鍓嶇櫥褰曚汉
+                string sql1 = "select * from Gy_Duty where HItemID =(select HParentID from Gy_Duty group by HParentID, HName having HName = '" + Job + "' and count(*) = 1))";
+                ds = oCN.RunProcReturn(sql1, "Gy_Duty");
+
+                string Job1= ds.Tables[0].Rows[0]["HName"].ToString(); 
+
+                //鐢ㄨ亴鍔℃壘鍒扮敤鎴�
+                string sql3 = "select a.Czymc 鐢ㄦ埛鍚嶇О,c.GroupName 鑱屽姟  from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId left join System_UserGroup c on b.GroupId = c.GroupID  where c.GroupName = '" + Job1+"'";
+                ds = oCN.RunProcReturn(sql3, "Gy_Czygl");
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎶ュ伐鍙拌烦杞紓甯稿弽棣堝崟 寮圭獥鑾峰彇 璁惧缂栫爜
+
+        [Route("Sc_MESTransFerWorkBill/set_EquipFile")]
+        [HttpGet]
+        public object set_EquipFile(string HSourceName)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select a.HEquipFileNumber 璁惧缂栫爜 ,a.HName 璁惧鍚嶇О from Gy_EquipFileBillMain a left join Gy_Source b on a.HSourceID = b.HItemID where b.HName ='" + HSourceName   + "'";
+                ds = oCN.RunProcReturn(sql, "Gy_ErrMsgBackType");
+
+                //娣诲姞鍒楀悕
+                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 ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鏁版嵁寮傚父锛岃涓庣鐞嗗憳鑱旂郴锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 寮傚父鍙嶉鍗� 璺熻釜鏌ヨ
+        [Route("Sc_MESTransFerWorkBill/GetErrMsgBackResumeList")]
+        [HttpGet]
+        public object GetErrMsgBackResumeList(string HInterID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn($@"select a.HInterID,a.HDate '鏃ユ湡',a.HBillType,x.HName 鍗曟嵁绫诲瀷,a.HBillNo as '鍗曟嵁鍙�',
+                CASE WHEN a.HBillStatus <= 1 THEN '鍒涘缓' WHEN a.HBillStatus = 2 THEN '宸插鏍�' WHEN a.HBillStatus = 3 AND 
+                a.HCloseType = 0 THEN '鑷姩鍏抽棴' WHEN a.HBillStatus = 3 AND 
+                a.HCloseType = 1 THEN '鎵嬪姩鍏抽棴' WHEN a.HBillStatus = 4 THEN '宸蹭綔搴�' ELSE '鍏跺畠鐘舵��' END AS 鍗曟嵁鐘舵��,
+                a.HSendMan AS 鍙戦�佷汉,a.HReceiveMan AS 鎺ユ敹浜�,a.HCopyMan AS 鎶勯�佷汉,a.HLevel AS 绱ф�ョ▼搴�,a.HContext AS 涓婚,a.HDescription AS 鍐呭,a.HErrMsgBackTypeID,b.HName AS 寮傚父绫诲瀷,
+                a.HMaker AS 鍒跺崟浜�, a.HMakeDate AS 鍒跺崟鏃ユ湡,a.HChecker AS 瀹℃牳浜�, a.HCheckDate AS 瀹℃牳鏃ユ湡, a.HUpDater AS 淇敼浜�, a.HUpDateDate AS 淇敼鏃ユ湡, 
+                a.HCloseMan AS 鍏抽棴浜�, a.HCloseDate AS 鍏抽棴鏃ユ湡, a.HDeleteMan AS 浣滃簾浜�, a.HDeleteDate AS 浣滃簾鏃ユ湡
+                from (
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID  from OA_ErrMsgBackBillMain where HInterID = {HInterID} UNION ALL 
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackReceiveBillMain where HMainSourceInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackSignBillMain where HErrMsgBackInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackHandleBillMain  where HErrMsgBackInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackCheckBillMain where HErrMsgBackInterID = {HInterID}
+                )as a,Xt_BillType as x,Gy_ErrMsgBackType as b
+                where a.HBillType = x.HNumber and a.HErrMsgBackTypeID = b.HItemID
+                ORDER BY '鏃ユ湡' ASC;", "OA_ErrMsgBackBillResume");
+
+                //娣诲姞鍔ㄦ�佸垪淇℃伅
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 寮傚父鍙嶉鍗� 璺熻釜鏉′欢鏌ヨ
+        [Route("Sc_MESTransFerWorkBill/GetErrMsgBackResumeList")]
+        [HttpGet]
+        public object GetErrMsgBackResumeList(string HInterID,string sWhere,string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("OA_ErrMsgBackBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ds = oCN.RunProcReturn($@"select * from
+               (select a.HInterID,a.HDate '鏃ユ湡',a.HBillType,x.HName 鍗曟嵁绫诲瀷,a.HBillNo as '鍗曟嵁鍙�',
+                CASE WHEN a.HBillStatus <= 1 THEN '鍒涘缓' WHEN a.HBillStatus = 2 THEN '宸插鏍�' WHEN a.HBillStatus = 3 AND 
+                a.HCloseType = 0 THEN '鑷姩鍏抽棴' WHEN a.HBillStatus = 3 AND 
+                a.HCloseType = 1 THEN '鎵嬪姩鍏抽棴' WHEN a.HBillStatus = 4 THEN '宸蹭綔搴�' ELSE '鍏跺畠鐘舵��' END AS 鍗曟嵁鐘舵��,
+                a.HSendMan AS 鍙戦�佷汉,a.HReceiveMan AS 鎺ユ敹浜�,a.HCopyMan AS 鎶勯�佷汉,a.HLevel AS 绱ф�ョ▼搴�,a.HContext AS 涓婚,a.HDescription AS 鍐呭,a.HErrMsgBackTypeID,b.HName AS 寮傚父绫诲瀷,
+                a.HMaker AS 鍒跺崟浜�, a.HMakeDate AS 鍒跺崟鏃ユ湡,a.HChecker AS 瀹℃牳浜�, a.HCheckDate AS 瀹℃牳鏃ユ湡, a.HUpDater AS 淇敼浜�, a.HUpDateDate AS 淇敼鏃ユ湡, 
+                a.HCloseMan AS 鍏抽棴浜�, a.HCloseDate AS 鍏抽棴鏃ユ湡, a.HDeleteMan AS 浣滃簾浜�, a.HDeleteDate AS 浣滃簾鏃ユ湡
+                from (
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID  from OA_ErrMsgBackBillMain where HInterID = {HInterID} UNION ALL 
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackReceiveBillMain where HMainSourceInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackSignBillMain where HErrMsgBackInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackHandleBillMain  where HErrMsgBackInterID = {HInterID} UNION ALL
+                select HInterID,HDate,HBillType,HBillNo,HBillStatus,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate,HCloseMan,HCloseDate,HDeleteMan,HDeleteDate,HCloseType,HSendMan,HReceiveMan,HCopyMan,HLevel,HContext,HDescription,HErrMsgBackTypeID from OA_ErrMsgBackCheckBillMain where HErrMsgBackInterID = {HInterID}
+                )as a,Xt_BillType as x,Gy_ErrMsgBackType as b
+                where a.HBillType = x.HNumber and a.HErrMsgBackTypeID = b.HItemID ) AS a where 1=1 " + sWhere + 
+                @" ORDER BY 鏃ユ湡 ASC;", "OA_ErrMsgBackBillResume");
+
+                //娣诲姞鍔ㄦ�佸垪淇℃伅
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1