From 871bc633a7daf1893acc98a84c64c93c9a30aaff Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期二, 10 十二月 2024 15:28:13 +0800 Subject: [PATCH] 器具保养规程、器具点检规程、设备点检规程导出添加 --- WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs | 436 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 426 insertions(+), 10 deletions(-) diff --git a/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs b/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs index befbdcc..da2b8e2 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; @@ -17,6 +19,9 @@ private json objJsonResult = new json(); 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(); @@ -77,6 +82,60 @@ } } #endregion + + #region 璁惧缁翠慨宸ュ崟鍒嗛〉鏌ヨ + [Route("Sb_EqpRepairWorkBill/GetEqpRepairWorkBillListPage")] + [HttpGet] + public object GetEqpRepairWorkBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairWorkBillList", 3, 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_Sb_EquipRepairWorkBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairWorkBillListPage"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairWorkBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairWorkBillListPage"); + } + + //娣诲姞鍒楀悕 + 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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 璁惧缁翠慨璁板綍缁熻鍒嗘瀽 /// <summary> @@ -190,6 +249,59 @@ } #endregion + #region 璁惧缁翠慨楠屾敹鍗曞垎椤垫煡璇� + [Route("Sb_EqpRepairWorkBill/GetEqpRepairCheckWorkBillListPage")] + [HttpGet] + public object GetEqpRepairCheckWorkBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairCheckBillList", 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_Sb_EquipRepairCheckBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairCheckBillListPage"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairCheckBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairCheckBillListPage"); + } + + //娣诲姞鍒楀悕 + 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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 璁惧缁翠慨楠屾敹鍗曞垪琛╯ql璇彞 public static DataSet Sb_EquipRepairCheckWorkBill_s(string sWhere) { @@ -206,8 +318,6 @@ } #endregion - - #region 璁惧鏁呴殰鐧昏鍗曞垪琛� /// <summary> @@ -259,6 +369,58 @@ } #endregion + #region 璁惧鏁呴殰鐧昏鍗曞垎椤垫煡璇� + [Route("Sb_EqpRepairWorkBill/GetEqpConkBookBillListPage")] + [HttpGet] + public object GetEqpConkBookBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipConkBookBillList", 3, 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_Sb_EquipConkBookBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipConkBookBillListPage"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipConkBookBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipConkBookBillListPage"); + } + + //娣诲姞鍒楀悕 + 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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 璁惧鏁呴殰璁板綍缁熻鍒嗘瀽 /// <summary> @@ -472,7 +634,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 { @@ -812,7 +976,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 { @@ -1100,9 +1269,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 { @@ -1313,8 +1483,8 @@ 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) { @@ -1322,6 +1492,14 @@ objJsonResult.count = 0; 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"; @@ -2094,6 +2272,59 @@ 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/Sb_EquipRepairSignBillListPage")] + [HttpGet] + public object Sb_EquipRepairSignBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairSignBillMain_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_Sb_EquipRepairSignBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairSignBillListPage"); + } + else + { + ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairSignBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairSignBillListPage"); + } + + //娣诲姞鍒楀悕 + 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) @@ -2935,5 +3166,190 @@ } } #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