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 | 656 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 638 insertions(+), 18 deletions(-) diff --git a/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs b/WebAPI/Controllers/SBGL/SB_EquipICMOTechParamBillController.cs index 0ae4bd1..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; @@ -6,6 +7,9 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using System.IO; +using System.Threading.Tasks; +using System.Web; using System.Web.Http; using WebAPI.Models; @@ -29,7 +33,7 @@ private json objJsonResult = new json(); SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); public DAL.ClsSB_EquipICMOTechParamBill oBill = new DAL.ClsSB_EquipICMOTechParamBill(); - + string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; #region 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄥ垪琛ㄤ俊鎭� /// <summary> @@ -83,6 +87,59 @@ } } #endregion + + #region 璁惧宸ヨ壓鍙傛暟鍒嗛〉鏌ヨ + [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBillList_Page")] + [HttpGet] + public object GetSB_EquipICMOTechParamBillList_Page(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second(ModRightNameList, 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_EquipICMOTechParamBillListPage " + page + "," + size + ",''", "h_p_SB_EquipICMOTechParamBillListPage"); + } + else + { + ds = oCn.RunProcReturn("exec h_p_SB_EquipICMOTechParamBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_SB_EquipICMOTechParamBillListPage"); + } + + //娣诲姞鍒楀悕 + 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> @@ -277,7 +334,7 @@ return objJsonResult; } else - { + { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "鍗曟嵁鍙凤細"+ oBill.omodel.HBillNo+ " 瀹℃牳鎴愬姛锛�"; @@ -407,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 { @@ -435,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 @@ -643,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> /// 璁惧宸ヨ壓鍙傛暟璁㈠崟鐐规琛ㄤ繚瀛� @@ -665,7 +943,7 @@ { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; //鍒ゆ柇鏂板鏉冮檺 - if (!DBUtility.ClsPub.Security_Log(ModRightName, 1, false, HMaker)) + if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -771,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; //鎴愬姛锛� @@ -798,8 +1101,325 @@ #endregion + #region 寮傚父宸ヨ壓鍙傛暟棰勮鍒楄〃淇℃伅 + /// <summary> + /// 寮傚父宸ヨ壓鍙傛暟棰勮鍒楄〃淇℃伅 + /// </summary> + /// <returns></returns> + [Route("SB_EquipICMOTechParamBillController/GetSb_EquipMentCollectionTechParam_ERR")] + [HttpGet] + public object GetSb_EquipMentCollectionTechParam_ERR(string sWhere, string HMaker) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎮ㄦ病鏈夎妯″潡鏉冮檺,璇蜂笌绠$悊鍛樿仈绯伙紒"; + objJsonResult.data = null; + return objJsonResult; + } + + //杩斿洖鍒楄〃淇℃伅 + ds = oCn.RunProcReturn("select * from h_v_Sb_EquipMentCollectionTechParam_ERRList where 1=1 " + sWhere + " order by 鍙戠幇寮傚父鏃堕棿 desc", "h_v_Sb_EquipMentCollectionTechParam_ERRList"); + List<object> columnNameList = new List<object>(); + //娣诲姞鍒楀悕 + 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 = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎴愬姛锛�"; + objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏌ヨ鍒楄〃淇℃伅澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 璁惧鐐规璁板綍鎷嶇収涓婁紶 + [Route("SB_EquipICMOTechParamBillController/UploadFile")] + [HttpPost] + public object UploadFile() + { + + string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //鍗曟嵁鍙� + string HRemark = HttpContext.Current.Request.Params["HRemark"]; //澶囨敞 + string HUserName = HttpContext.Current.Request.Params["HUserName"]; //鍒涘缓浜� + HttpPostedFile files = HttpContext.Current.Request.Files["file"]; + string path = HttpContext.Current.Server.MapPath("~/../Files/EquipTechParamFolder/" + HBillNo); + //string path = @"D:\\Files\\"+ HBillNo; + dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); + if (dyResult != null && dyResult.result == 1) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "涓婁紶鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = dyResult.returnval; + objJsonResult.data = null; + return objJsonResult; + } + + } + + public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) + { + dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" }; + string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞 + string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚� + string filename = files.FileName;//鏂囦欢鍚� + string fileSavePath = path;// 涓婁紶淇濆瓨璺緞 + int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte + int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M + try + { + if (files == null || files.ContentLength <= 0) + { + Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" }; + return Result_Ob; + } + if (filesize >= Maxsize) + { + Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" }; + return Result_Ob; + } + + string fileurl = Path.Combine(fileSavePath, filename); + if (Directory.Exists(fileurl) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀� + { + Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" }; + return Result_Ob; + } + //鍒犻櫎鏁版嵁琛ㄦ暟鎹� + ds = oCn.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); + if (Directory.Exists(path)) + { + File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢 + files.SaveAs(fileurl); + string StrPath = "/files/EquipTechParamFolder/" + HBillNo + "/" + filename; + if (File.Exists(fileurl)) + { + //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱 + //鍐欏叆鏁版嵁琛� + oCn.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + + ",HFileClsID,HSourceBillNo" + + ") values('" + + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + + "','" + 0 + "','" + HBillNo + + "') "); + } + else + { + Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" }; + } + } + else + { + Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶� + files.SaveAs(fileurl); + string StrPath = "/files/EquipTechParamFolder/" + HBillNo + "/" + filename; + if (File.Exists(fileurl)) + { + //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱 + //鍐欏叆鏁版嵁琛� + oCn.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + + ",HFileClsID,HSourceBillNo" + + ") values('" + + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + + "','" + 0 + "','" + HBillNo + + "') "); + } + else + { + Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" }; + } + } + + } + catch (Exception e) + { + Result_Ob = new { result = 0, returnval = e.Message }; + } + return Result_Ob; + } + + /// <summary> + /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛� + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("SB_EquipICMOTechParamBillController/Filelist")] + [HttpGet] + public object Filelist(string HBillNo) + { + var url = fileip + "/files/EquipTechParamFolder/" + HBillNo + "/"; + //@"C:\\files\\" + try + { + ds = oCn.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); + 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; + } + } + + /// <summary> + /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢 + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("SB_EquipICMOTechParamBillController/DeleteFilelist")] + [HttpGet] + public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) + { + try + { + + oCn.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); + string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipTechParamFolder/" + HSourceBillNo), HFileName); + File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢 + objJsonResult.code = "1"; + objJsonResult.count = 1; + 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 鎵嬪伐鐐规琛ㄥ嚭鐜癗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