From 01685f3ab68f64b51b83eee40af90f4030866691 Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期二, 03 六月 2025 18:18:21 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs | 371 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 354 insertions(+), 17 deletions(-) diff --git a/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs b/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs index a317d9a..f2030dd 100644 --- a/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs +++ b/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.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.Data; using System.Data.SqlClient; using System.IO; +using System.Threading.Tasks; using System.Web; using System.Web.Http; using WebAPI.Models; @@ -332,7 +334,7 @@ return objJsonResult; } else - { + { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "鍗曟嵁鍙凤細"+ oBill.omodel.HBillNo+ " 瀹℃牳鎴愬姛锛�"; @@ -462,23 +464,47 @@ objJsonResult.data = null; return objJsonResult; } - //鍏抽棴鍗曟嵁 - if (!oBill.CloseBill(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) + + string sql = ""; + //鍏抽棴鍓嶆帶鍒�===============================================Begin=================================================================== + sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; + ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍏抽棴鍓嶆帶鍒�===============================================End=================================================================== + + //鍏抽棴鎻愪氦 + if (oBill.CloseBill(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴鎴愬姛"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍏抽棴鎴愬姛锛�"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; - return objJsonResult; ; - } + return objJsonResult; + } } else { @@ -490,23 +516,47 @@ objJsonResult.data = null; return objJsonResult; } - //鍙嶅叧闂崟鎹� - if (!oBill.CancelClose(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) + + string sql = ""; + //鍙嶅叧闂墠鎺у埗===============================================Begin=================================================================== + sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; + ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅叧闂墠鎺у埗===============================================End=================================================================== + + //鍙嶅叧闂彁浜� + if (oBill.CancelClose(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterUnCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂垚鍔�"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍗曟嵁鍙凤細" + oBill.omodel.HBillNo + " 鍙嶅叧闂垚鍔燂紒"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; - return objJsonResult; ; - } + return objJsonResult; + } } } else @@ -698,6 +748,179 @@ } #endregion + #region 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄦā鍧� 浠庡垪琛ㄩ�変腑鎵撳紑鍗曟嵁锛岃繑鍥炲崟鎹俊鎭椂璋冪敤 + /// <summary> + /// 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄦā鍧� 浠庡垪琛ㄩ�変腑鎵撳紑鍗曟嵁锛岃繑鍥炲崟鎹俊鎭椂璋冪敤 + /// </summary> + /// <param name="HInterID">涓婚敭ID</param> + /// <param name="HMaker">鍒跺崟浜�</param> + /// <param name="sWhere">绛涢�夋潯浠�</param> + /// <returns>杩斿洖绗﹀悎鏉′欢鐨勬潯鐩暟鍜屽綋鍓嶄富閿搴旂殑鏉$洰鍦ㄨ〃涓殑浣嶇疆</returns> + [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Position")] + [HttpGet] + public object GetSB_EquipICMOTechParamBill_Position(Int64 HInterID, string HMaker, string sWhere) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql = "exec h_p_SB_EquipCMOTechParamBillListEdit_GetCurrRecord @HInterID = N'" + HInterID + + "', @sWhere = N'" + sWhere + "'"; + + //杩斿洖鍒楄〃淇℃伅 + ds = oCn.RunProcReturn(sql, "h_p_SB_EquipCMOTechParamBillListEdit_GetCurrRecord"); + + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + 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="HMaker">鍒跺崟浜�</param> + /// <param name="sWhere">绛涢�夋潯浠�</param> + /// <param name="current">鏉$洰鍦ㄦ暟鎹〃涓殑浣嶇疆</param> + /// <returns>鍗曟嵁淇℃伅鍜屼綅缃�</returns> + [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_ByPosition")] + [HttpGet] + public object GetSB_EquipICMOTechParamBill_ByPosition(string HMaker, string sWhere, int current) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql = "EXEC [dbo].[h_p_SB_EquipICMOTechParamBill_Edit_WithPosition]" + + " @Postition = N'"+ current +"'" + + " ,@sWhere = N'"+ sWhere +"'"; + //杩斿洖鍒楄〃淇℃伅 + ds = oCn.RunProcReturn(sql, "h_p_SB_EquipICMOTechParamBill_Edit_WithPosition"); + + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈煡璇㈠埌璇ヨ澶囧伐鑹哄弬鏁拌鍗曠偣妫�琛紝璇峰埛鏂版暟鎹悗閲嶆柊閫夋嫨锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄤ俊鎭け璐ワ紒" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄦā鍧� 浠庡垪琛ㄩ�変腑鎵撳紑鍗曟嵁锛岃繑鍥炲崟鎹俊鎭椂璋冪敤 + /// <summary> + /// 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄧ紪杈戞椂锛屾牴鎹崟鎹甀D鑾峰彇鍗曟嵁淇℃伅 + /// </summary> + /// <returns></returns> + [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_QueryHistoryRecord")] + [HttpGet] + public object GetSB_EquipICMOTechParamBill_QueryHistoryRecord(Int64 HInterID, string HMaker, string HProcID, String HSourceID) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡缂栬緫鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒"; + objJsonResult.data = null; + return objJsonResult; + } + + string sql = "exec h_p_SB_EquipICMOTechParamBill_Edit_QueryHistoryRecord " + + "@HInterID = N'" + HInterID + "'" + + ", @HProcID = N'" + HProcID + "'" + + ", @HSourceID = N'" + HSourceID + "'"; + LogService.Write(sql); + //杩斿洖鍒楄〃淇℃伅 + ds = oCn.RunProcReturn(sql + , "h_p_SB_EquipICMOTechParamBill_Edit_QueryHistoryRecord"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏈煡璇㈠埌璇ヨ澶囧伐鑹哄弬鏁拌鍗曠偣妫�琛紝璇峰埛鏂版暟鎹悗閲嶆柊閫夋嫨锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄤ俊鎭け璐ワ紒" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #region 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄤ繚瀛� /// <summary> /// 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄤ繚瀛� @@ -826,6 +1049,31 @@ if (bResult) { + + //鑷姩瀹℃牳璁剧疆 + if (OperationType == "1") + { + objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D + //绯荤粺鍙傛暟 鑷姩瀹℃牳 + string sReturn = ""; + if (oSystemParameter.ShowBill(ref sReturn) == true) + { + if (oSystemParameter.omodel.SB_EquipICMOTechParamBill_Check == "Y") //绯荤粺鍙傛暟 鑷姩瀹℃牳 + { + objJsonResult.Verify = "Y"; + } + else + { + objJsonResult.Verify = "N"; + } + } + } + else + { + objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D + objJsonResult.Verify = "N"; + } + objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //鎴愬姛锛� @@ -1080,9 +1328,98 @@ return objJsonResult; } } - #endregion + #endregion + + # region 鎵嬪伐鐐规琛ㄥ嚭鐜癗G鍙戦�佷俊鎭� + [Route("SB_EquipICMOTechParamBillController/HSendDDMeg")] + [HttpGet] + + public async Task<object> HSendDDMeg(string HInterID) + { + try + { + //鏌ヨ瀛愯〃鏄惁鏈塏G鍊� + ds = oCn.RunProcReturn("select * from SB_EquipICMOTechParamBillMain a inner join SB_EquipICMOTechParamBillSub b on a.HInterID=b.HInterID where b.HResult='NG' and a.HInterID=" + HInterID, "SB_EquipICMOTechParamBillMain"); + if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count != 0) + { + //鏌ヨ骞跺悎骞跺紓甯稿伐鑹哄弬鏁板�� + string sql = @"SELECT 鐢熶骇杞﹂棿, STUFF((SELECT ', ' + CAST(hsubid AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable WHERE InnerTable.鐢熶骇杞﹂棿 = OuterTable.鐢熶骇杞﹂棿 AND InnerTable.妫�娴嬬粨鏋� = 'NG' AND InnerTable.hmainid ='"+HInterID+"' FOR XML PATH('')), 1, 2, '') AS hsubid,STUFF(( SELECT '; ' + 璁惧缂栫爜 + ' - ' + 宸ヨ壓鍙傛暟 + ' - 宸ヨ壓鍙傛暟鍊�: ' + CAST(宸ヨ壓鍙傛暟鍊� AS VARCHAR(10)) + ' - 鏍囧噯鍊�: ' + CAST(鏍囧噯鍊� AS VARCHAR(10)) + ' - 涓婇檺: ' + CAST(涓婇檺 AS VARCHAR(10)) + ' - 涓嬮檺: ' + CAST(涓嬮檺 AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable WHERE InnerTable.鐢熶骇杞﹂棿 = OuterTable.鐢熶骇杞﹂棿 AND InnerTable.妫�娴嬬粨鏋� = 'NG' FOR XML PATH('') ), 1, 2, '') AS 鍐呭 FROM h_v_SB_EquipICMOTechParamBillList_Detail AS OuterTable where OuterTable.hmainid = '" + HInterID + "' GROUP BY 鐢熶骇杞﹂棿"; + ds = oCn.RunProcReturn(sql, "h_v_SB_EquipICMOTechParamBillList_Detail"); + var HDeptName = ds.Tables[0].Rows[0]["鐢熶骇杞﹂棿"].ToString(); + var HDescription = ds.Tables[0].Rows[0]["鍐呭"].ToString(); + var HSubID = ds.Tables[0].Rows[0]["hsubid"].ToString(); + //鏌ヨ鎺ユ敹浜� + string newSql1 = @"select a.HDingDingUserID 閽夐拤id,a.Czymc 鎺ユ敹浜� 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 = '" + HDeptName + "宸ヨ壓寮傚父棰勮鎺ユ敹浜�'"; + DataSet dt = oCn.RunProcReturn(newSql1, "Gy_Czygl"); + if (dt.Tables[0].Rows.Count > 0) + { + + 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"; + } + + } + + //鑾峰彇浼佷笟鐨刟ccess_token鐨勫�� + string response = msg.GetAccessToken(appKey, appSecret); + JObject responseJson = JObject.Parse(response); + // 鑾峰彇access_token鐨勫�� + string accessToken = responseJson["accessToken"].ToString(); + string HName = ""; // 鐢ㄤ簬瀛樺偍鎷兼帴鍚庣殑閽夐拤ID + List<string> dingDingIds = new List<string>(); // 鐢ㄦ潵瀛樺偍閽夐拤ID鐨勯泦鍚� + // 鎷兼帴閽夐拤ID + for (int i = 0; i < dt.Tables[0].Rows.Count; i++) + { + dingDingIds.Add(dt.Tables[0].Rows[i]["閽夐拤id"].ToString()); // 灏嗘瘡涓拤閽塈D娣诲姞鍒板垪琛ㄤ腑 + } + + // 浣跨敤閫楀彿灏嗛拤閽塈D鎷兼帴鎴愪竴涓瓧绗︿覆 + HName = string.Join(",", dingDingIds); + //鏇存柊涓篘G鐨勫瓙琛ㄥ瓧娈� 鏈� 宸插彂閫� 1 + oCn.RunProc("update SB_EquipICMOTechParamBillSub set HSendFlag =1 where HInterID='" + HInterID + "' and HEntryID in(" + HSubID + ")"); + response = await msg.SendTextMessage(accessToken, agentIds, HName, "0", "false", HDescription); + return response; + } + } + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鏃燦G宸ヨ壓鍙傛暟锛�"; + objJsonResult.data = null; + return objJsonResult; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙戦�佸け璐ワ紒" + e.Message; + objJsonResult.data = null; + return objJsonResult; + } + + } + #endregion } } \ No newline at end of file -- Gitblit v1.9.1