From 19d0afadbe1c90e227b852db0a97ae413e90691f Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期日, 29 九月 2024 19:13:25 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs | 1111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,100 insertions(+), 11 deletions(-)

diff --git a/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs b/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
index e4c9062..9a4780c 100644
--- a/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
+++ b/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing DLL;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
@@ -7,6 +8,7 @@
 using System.Linq;
 using System.Net;
 using System.Net.Http;
+using System.Threading.Tasks;
 using System.Web.Http;
 using WebAPI.Models;
 
@@ -18,6 +20,8 @@
         public DataSet ds = new DataSet();
         public WebServer webserver = new WebServer();
 
+        //鑾峰彇绯荤粺鍙傛暟
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
@@ -26,6 +30,8 @@
         public DAL.ClsSb_EquipConkBookBill BillOld2 = new DAL.ClsSb_EquipConkBookBill();   //瀵瑰簲鍗曟嵁绫�
         public DAL.ClsSb_EquipRepairWorkBill BillOld3 = new DAL.ClsSb_EquipRepairWorkBill();   //瀵瑰簲鍗曟嵁绫�
         public DAL.ClsSb_EquipRepairCheckBill BillOld4 = new DAL.ClsSb_EquipRepairCheckBill();   //瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsSb_EquipRepairSignBill BillOld5 = new DAL.ClsSb_EquipRepairSignBill();   //瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsSb_EquipRepairSignBill BillOld6 = new DAL.ClsSb_EquipRepairSignBill();   //瀵瑰簲鍗曟嵁绫�
 
 
         #region 璁惧缁翠慨宸ュ崟鍒楄〃
@@ -471,7 +477,9 @@
                 if (oBill.omodel.HInterID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);                  
+                    //閮ㄩ棬,鍙戠幇浜�,璐熻矗浜�,璁惧
+                    _ = SendDingDingAsync(oBill.omodel.HDeptID, oBill.omodel.HEmpID, oBill.omodel.HManagerID, oBill.omodel.HEquipID,2);
                 }
                 else
                 {
@@ -811,7 +819,12 @@
                 if (oBill.omodel.HInterID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);    
+                    //鍙嶅啓缁翠慨璁板綍鍗曞叧闂�
+                    string sql = "Update Sb_EquipRepairWorkBillMain set HCloseMan='鍏宠仈楠屾敹鍗曡嚜鍔ㄥ叧闂�',HCloseDate=GETDATE(),HBillStatus=3,HCloseType = 1 Where HInterID=" + oBill.omodel.HMainSourceInterID.ToString();
+                    ds = oCN.RunProcReturn(sql, "Sb_EquipRepairWorkBillMain");
+                    //閮ㄩ棬,鍙戠幇浜�,璐熻矗浜�,璁惧
+                    _ = SendDingDingAsync(oBill.omodel.HDeptID, oBill.omodel.HEmpID, oBill.omodel.HManagerID, oBill.omodel.HEquipID, 3);
                 }
                 else
                 {
@@ -1099,9 +1112,10 @@
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
                 if (oBill.omodel.HInterID == 0)
-                {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                {                   
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);          
+                    //閮ㄩ棬,鍙戠幇浜�,璐熻矗浜�,璁惧
+                    _ = SendDingDingAsync(oBill.omodel.HDeptID, oBill.omodel.HEmpID, oBill.omodel.HManagerID, oBill.omodel.HEquipID,1);
                 }
                 else
                 {
@@ -1295,8 +1309,6 @@
         }
         #endregion
 
-
-
         #region 璁惧缁翠慨鍗昉DA
 
         #region 鏍规嵁璁惧鏉$爜鏌ユ壘璁惧妗f淇℃伅PDA
@@ -1314,15 +1326,23 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                //寰楀埌淇℃伅
-                ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_EquipFileBillList where HBarCode= '" + HBarCode + "'", "Gy_EquipFileBillMain");
+                //寰楀埌淇℃伅鏈�鏂扮殑
+                ds = oCN.RunProcReturn("select  * from h_v_Gy_EquipFileBillList where HBarCode= '" + HBarCode + "'  order by 鏁呴殰鐧昏鍗旾D desc", "Gy_EquipFileBillMain");
                 //鍐欏叆淇℃伅
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "1.鏈煡璇㈠埌璁惧淇℃伅锛� 2.璁惧娌℃湁缁存姢鏁呴殰鐧昏鍗�";
+                    objJsonResult.Message = "1.鏈煡璇㈠埌璁惧淇℃伅锛� 2.璁惧娌℃湁缁存姢鏁呴殰鐧昏鍗�  3.璁惧鏁呴殰鐧昏鍗曟病鏈夊鏍�";
                     objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if ( ds.Tables[0].Rows.Count > 1)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "璇ヨ澶囧嚭鐜板涓晠闅滅櫥璁板崟,璇锋墜鍔ㄩ�夌潃";
+                    objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
                 }
                 objJsonResult.code = "1";
@@ -2052,5 +2072,1074 @@
         #endregion
 
         #endregion
+
+        #region 璁惧缁翠慨绛惧埌鍗曞垪琛� 鏌ヨ
+        [Route("Sb_CheckEqpRepairWorkBill/Sb_EquipRepairSignBillMainList")]
+        [HttpGet]
+        public object Sb_EquipRepairSignBillMainList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairSignBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_Sb_EquipRepairSignBillList order by 鍗曟嵁鍙� desc", "h_v_Sb_EquipRepairSignBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_Sb_EquipRepairSignBillList where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipRepairSignBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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("Sb_CheckEqpRepairWorkBill/SaveSb_EquipRepairSignBillMain")]
+        [HttpPost]
+        public object SaveSb_EquipRepairSignBillMain([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 refSav = sArray[1].ToString();//鎿嶄綔鏂瑰紡鏁版嵁绫诲瀷 1娣诲姞 3淇敼 2 澶嶅埗
+            string msg4 = sArray[2].ToString();//鐢ㄦ埛鍚�
+
+
+            DBUtility.ClsPub.CurUserName = msg4;
+
+            string UserName = "";
+            string s = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairSignBillMain_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DAL.ClsSb_EquipRepairSignBill oBill = new DAL.ClsSb_EquipRepairSignBill();
+                List<Model.ClsSb_EquipRepairSignBillMain> lsmain = new List<Model.ClsSb_EquipRepairSignBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Sb_EquipRepairSignBillMain(msg2);
+                foreach (Model.ClsSb_EquipRepairSignBillMain oItem in lsmain)
+                {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillOld5.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld5.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld6.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld6.omodel.HChecker != "" && BillOld6.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld6.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld6, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3920";
+                    oItem.HBillSubType = "3920";
+
+                    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;
+                }
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                int sYear = 0;
+                int sPeriod = 0;
+                DateTime HDate = DateTime.Now;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                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("Sb_CheckEqpRepairWorkBill/Sb_EquipRepairSignBillMainEditList")]
+        [HttpGet]
+        public object Sb_EquipRepairSignBillMainEditList(long HInterID)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql = "select * from h_v_Sb_EquipRepairSignBillEdit where hmainid='" + HInterID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipRepairSignBillEdit");
+
+                //娣诲姞鍒楀悕
+                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("Sb_CheckEqpRepairWorkBill/DeleteSb_EquipRepairSignBillMain")]
+        [HttpGet]
+        public object DeleteSb_EquipRepairSignBillMain(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairSignBillMain_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 (BillOld6.ShowBill(long.Parse(HInterID), ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙垹闄�
+                if (BillOld6.omodel.HChecker != "" && BillOld6.omodel.HChecker != null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鏄垱寤虹姸鎬佽繘琛屽垹闄�
+                if (int.Parse(BillOld6.omodel.HBillStatus.ToString()) <= 1)
+                {
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
+                    //鍒犻櫎鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Sb_EquipRepairSignBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipRepairSignBill_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 Sb_EquipRepairSignBillMain where HInterID = " + HInterID);
+                    oCN.RunProc("delete from Sb_EquipRepairSignBillSub where HInterID= " + HInterID);
+
+                    //鍒犻櫎鍚庢帶鍒�==================================================================================      
+                    string sql2 = "exec h_p_Sb_EquipRepairSignBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Sb_EquipRepairSignBill_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;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹笉鏄垱寤虹姸鎬侊紝涓嶅厑璁稿垹闄わ紒";
+                    objJsonResult.data = 1;
+                    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 璁惧缁翠慨绛惧埌鍗� 瀹℃牳/鍙嶅鏍�     
+        [Route("Sb_CheckEqpRepairWorkBill/AuditSb_EquipRepairSignBillMain")]
+        [HttpGet]
+        public object AuditSb_EquipRepairSignBillMain(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sb_EquipRepairSignBillMain_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.ClsSb_EquipRepairSignBill oBill = new DAL.ClsSb_EquipRepairSignBill();                              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                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 == 1)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 2) //鍙嶅鏍稿垽鏂�
+                    {
+                        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 ==1) //瀹℃牳鎻愪氦
+                {
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();
+
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Sb_EquipRepairSignBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipRepairSignBill_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_Sb_EquipRepairSignBill_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 == 2) //鍙嶅鏍告彁浜�
+                {
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_Sb_EquipRepairSignBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipRepairSignBill_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_Sb_EquipRepairSignBill_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 璁惧缁翠慨绛惧埌鍗� 鍏抽棴/鍙嶅叧闂�
+
+        [Route("Sb_CheckEqpRepairWorkBill/CloseSb_EquipRepairSignBill")]
+        [HttpGet]
+        public object CloseSb_EquipRepairSignBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sb_EquipRepairSignBillMain_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.ClsSb_EquipRepairSignBill oBill = new DAL.ClsSb_EquipRepairSignBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                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 == 1)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 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 (IsAudit == 1) //鍏抽棴鎻愪氦
+                {
+                    //鍏抽棴鎻愪氦
+                    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 == 2) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    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 璁惧缁翠慨绛惧埌鍗� 浣滃簾/鍙嶄綔搴�     
+        [Route("Sb_CheckEqpRepairWorkBill/DeleteSb_EquipRepairSignBill")]
+        [HttpGet]
+        public object DeleteSb_EquipRepairSignBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sb_EquipRepairSignBillMain_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.ClsSb_EquipRepairSignBill oBill = new DAL.ClsSb_EquipRepairSignBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                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 == 1)  //浣滃簾鍒ゆ柇
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 2) //鍙嶄綔搴熷垽鏂�
+                    {
+                        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 == 1) //浣滃簾鎻愪氦
+                {
+                    //浣滃簾鎻愪氦
+                    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 == 2) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    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 璁惧绛惧埌鍗曟彁浜DA
+
+        [Route("Sb_CheckEqpRepairWorkBill/SaveSb_EquipRepairSignBill_PDA")]
+        [HttpPost]
+        public object SaveSb_EquipRepairSignBill_PDA([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 UserName = "";
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DLL.ClsSb_EquipRepairSignBill oBill = new DLL.ClsSb_EquipRepairSignBill();
+                List<Models.ClsSb_EquipRepairSignBillMain> lsmain = new List<Models.ClsSb_EquipRepairSignBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  
+                lsmain = oListModels.getObjectByJson_Sb_EquipRepairSignBill_PDA(msg2);
+                foreach (Models.ClsSb_EquipRepairSignBillMain oItem in lsmain)
+                {
+                    //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                    if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                 
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3920";
+                    oItem.HBillSubType = "3920";                  
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    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;
+                }             
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    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 璁惧鏁呴殰 鐧昏/璁板綍/楠屾敹  鍙戦�佹秷鎭�
+        /// <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(long HDeptID, long HEmpID, long HManagerID, long HEquipID,int num)
+        {
+
+            string concatenatedNames = "";
+            string HDescription = "";
+            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";
+                }
+
+            }
+
+            //閮ㄩ棬
+            string sql = "select HName from Gy_Department where HItemID='" + HDeptID + "'";
+            ds = oCN.RunProcReturn(sql, "Gy_Department");
+            string HDeptName = ds.Tables[0].Rows[0]["HName"].ToString();
+
+            //鍙戠幇浜�
+            string sql1 = "select HName from Gy_Employee where HItemID='" + HEmpID + "'";
+            ds = oCN.RunProcReturn(sql1, "Gy_Employee");
+            string HEmpName = ds.Tables[0].Rows[0]["HName"].ToString();
+
+            //璐熻矗浜�
+            string sql2 = "select HName from Gy_Employee where HItemID='" + HManagerID + "'";
+            ds = oCN.RunProcReturn(sql2, "Gy_Employee");
+            string HManagerName = ds.Tables[0].Rows[0]["HName"].ToString();
+
+            //璁惧
+            string sql3 = "select HName from Gy_EquipFileBillMain where HInterID='" + HEquipID + "'";
+            ds = oCN.RunProcReturn(sql3, "Gy_EquipFileBillMain");
+            string HEquipName = ds.Tables[0].Rows[0]["HName"].ToString();
+
+            //鍙戦�佸唴瀹�
+            if (num==1)
+            {
+                HDescription = "鍙戠幇浜�:'" + HEmpName + "',鍦�'" + HDeptName + "',鍙戠幇'" + HEquipName + "',鎹熷潖,璇峰尯鍩熻礋璐d汉:'" + HManagerName + "',灏藉揩鍒扮幇鍦虹淮淇�!!";
+            }
+            else if (num==2)
+            {
+                HDescription = "缁翠慨浜�:'" + HEmpName + "',鍦�'" + HDeptName + "',宸茬淮淇�'" + HEquipName + "',璇峰彂鐜颁汉:'" + HManagerName + "',灏藉揩鍒扮幇鍦虹‘璁ゆ槸鍚︾淮淇畬鎴�!!";
+            }
+            else if (num==3)
+            {
+                HDescription = "楠屾敹浜�:'" + HEmpName + "',鍦�'" + HDeptName + "',宸查獙鏀�'" + HEquipName + "',宸查�氱煡:'" + HManagerName + "',缁翠慨璁惧绗﹀悎楠屾敹!!";
+            }
+             
+
+            //鎺ユ敹浜洪拤閽塱d
+            string sql4 = "select HDingDingUserID 閽夐拤id from Gy_Czygl where Czymc in ('" + HManagerName + "')";
+            ds = oCN.RunProcReturn(sql4, "Gy_Czygl");
+             concatenatedNames = ds.Tables[0].Rows[0]["閽夐拤id"].ToString();
+
+            //鑾峰彇浼佷笟鐨刟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
     }
 }

--
Gitblit v1.9.1