From 5466e02176f2acf2f08ef1c16315c3185bae903f Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期一, 19 五月 2025 15:53:34 +0800 Subject: [PATCH] 异常反馈单,快捷开工接口调整 --- WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs | 572 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 560 insertions(+), 12 deletions(-) diff --git a/WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs b/WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs index 347d624..8d4ef40 100644 --- a/WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs +++ b/WebAPI/Controllers/CJGL/Gy_MaterPreventErrMouldBillController.cs @@ -10,7 +10,9 @@ using System.Web.Http; using System.Windows.Forms; using WebAPI.Models; - +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; +using System.IO; +using SyntacticSugar.constant; namespace WebAPI.Controllers.CJGL { public class Gy_MaterPreventErrMouldBillController : ApiController @@ -18,6 +20,7 @@ public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛� private json objJsonResult = new json(); public DataSet ds = new DataSet(); + public DataSet ds1 = new DataSet(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); public DAL.ClsGy_MaterPreventErrMouldBillMain OBill = new DAL.ClsGy_MaterPreventErrMouldBillMain(); public DAL.ClsGy_MaterPreventErrMouldBillMain BillOld = new DAL.ClsGy_MaterPreventErrMouldBillMain(); @@ -26,7 +29,7 @@ #region 浜у搧闃查敊楠岃瘉娓呭崟鍒楄〃 鏌ヨ 鍙樉绀轰富琛� [Route("Gy_MaterPreventErrMouldBill/get锘縂y_MaterPreventErrMouldBillMainList_Main")] [HttpGet] - public object Gy_MaterPreventErrMouldBillMainList_Main(string sWhere, string user) + public object get锘縂y_MaterPreventErrMouldBillMainList_Main(string sWhere, string user) { try { @@ -268,7 +271,6 @@ 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) == "") { @@ -372,9 +374,53 @@ oCN.BeginTran(); - oCN.RunProc("delete from Gy_MaterPreventErrMouldBillMain where HInterID = " + HInterID); + //鍒ゆ柇瀛樺湪鎬� + if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo)) + { + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_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; + } + //================================================================================== + + //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級 + if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Gy_MaterPreventErrMouldBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + } oCN.Commit(); + objJsonResult.code = "1"; objJsonResult.count = 1; @@ -427,7 +473,6 @@ if (Type == 1) { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 - DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds == null || ds.Tables[0].Rows.Count == 0) @@ -464,8 +509,32 @@ objJsonResult.data = null; return objJsonResult; } + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeCheckCtrl"); + if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== + //瀹℃牳鍗曟嵁 - if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + if (!BillOld.CheckBill(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -478,7 +547,6 @@ else { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� - DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -507,8 +575,29 @@ objJsonResult.data = null; return objJsonResult; } + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeUnCheckCtrl"); + if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //=========================================================== //鍙嶅鏍稿崟鎹� - if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -720,7 +809,6 @@ if (Type == 1) { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡浣滃簾 - DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds == null || ds.Tables[0].Rows.Count == 0) @@ -749,8 +837,31 @@ objJsonResult.data = null; return objJsonResult; } + //浣滃簾鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeDropCtrl"); + if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== //浣滃簾鍗曟嵁 - if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + if (!BillOld.Cancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -763,7 +874,6 @@ else { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶄綔搴� - DataSet ds; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -784,8 +894,31 @@ objJsonResult.data = null; return objJsonResult; } + //鍙嶄綔搴熷墠鎺у埗========================================= + string sql1 = "exec h_p_Gy_MaterPreventErrMouldBill_BeforeUnDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'"; + ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPreventErrMouldBill_BeforeUnDropCtrl"); + if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:鍙嶄綔搴熷墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + + if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //================================================================================== //鍙嶄綔搴熷崟鎹� - if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_MaterPreventErrMouldBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -816,5 +949,420 @@ } #endregion + + #region 浜у搧闃查敊楠岃瘉娓呭崟 鏂囦欢瀵煎叆淇濆瓨 + #region 浜у搧闃查敊楠岃瘉娓呭崟 鏂囦欢涓婁紶 + [Route("Gy_MaterPreventErrMouldBill/Gy_MaterPreventErrMouldBill_Excel")] + [HttpPost] + public object Gy_MaterPreventErrMouldBill_Excel() + { + try + { + //鑾峰彇鏂囦欢鍚嶇О + var file = HttpContext.Current.Request.Files[0]; + //鑾峰彇鏂囦欢鐗╃悊璺緞 + string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); + //淇濆瓨鏂囦欢 + file.SaveAs(ExcelPath); + + NpoiHelper np = new NpoiHelper(); + DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); + + //鍒犻櫎鏂囦欢 + File.Delete(ExcelPath); + + //鍒涘缓涓存椂琛� + DataTable tb2 = new DataTable("dt2"); + + //娣诲姞鍒楀悕 + for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) + { + tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); + } + + //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁 + tb2.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID + tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID + tb2.Columns.Add("HProcID", typeof(Int32));//宸ュ簭ID + tb2.Columns.Add("HPreventErrMouldID", typeof(Int32));//闃查敊瑁呯疆ID + //娣诲姞鏁版嵁 + for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) + { + DataRow row = tb2.NewRow(); + for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) + { + row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); + } + tb2.Rows.Add(row); + } + + + var error = ""; + + //鏌ヨ娌℃湁鐨勫垪 + if (!tb2.Columns.Contains("缁勭粐浠g爜")) + error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("缁勭粐鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍗曟嵁鍙�")) + error += "娌℃湁鎵惧埌銆愬崟鎹彿銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡浠g爜")) + error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("宸ュ簭浠g爜")) + error += "娌℃湁鎵惧埌銆愬伐搴忎唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("宸ュ簭鍚嶇О")) + error += "娌℃湁鎵惧埌銆愬伐搴忓悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("澶囨敞")) + error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("闃查敊瑁呯疆浠g爜")) + error += "娌℃湁鎵惧埌銆愰槻閿欒缃唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("闃查敊瑁呯疆鍚嶇О")) + error += "娌℃湁鎵惧埌銆愰槻閿欒缃悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("闃查敊鍔熻兘")) + error += "娌℃湁鎵惧埌銆愰槻閿欏姛鑳姐�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("澶辨晥妯″紡")) + error += "娌℃湁鎵惧埌銆愬け鏁堟ā寮忋�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("澶辨晥楠岃瘉鏂规硶")) + error += "娌℃湁鎵惧埌銆愬け鏁堥獙璇佹柟娉曘�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("琛ㄤ綋澶囨敞")) + error += "娌℃湁鎵惧埌銆愯〃浣撳娉ㄣ�戠殑鏍囬,"; + + if (error.Length > 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n"; + objJsonResult.data = null; + return objJsonResult; + } + + for (int i = 0; i <= tb2.Rows.Count - 1; i++) + { + string HBillNo = ""; + string HORGNumber = ""; + string HORGName = ""; + string HMaterName = ""; + string HMaterNumber = ""; + string HProcNumber = ""; + string HProcName = ""; + string HPreventErrMouldName = ""; + string HPreventErrMouldNumber = ""; + + + HBillNo = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍗曟嵁鍙�"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString()); + HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()); + HProcName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭鍚嶇О"].ToString()); + HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭浠g爜"].ToString()); + HPreventErrMouldName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["闃查敊瑁呯疆鍚嶇О"].ToString()); + HPreventErrMouldNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["闃查敊瑁呯疆浠g爜"].ToString()); + + //妫�鏌� + int index = i + 1; + //缁勭粐 + if (HORGNumber != "") + { + //鏌ヨ缁勭粐 + ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + else + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } + //鐗╂枡浠g爜 + if (HMaterNumber != "") + { + //鏌ヨ鐗╂枡 + ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumber + "' and Hname='" + HMaterName + "'", "Gy_Maintain"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡浠g爜涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } + //宸ュ簭浠g爜 + if (HProcNumber != "") + { + //鏌ヨ宸ュ簭 + ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcNumber + "' and Hname='" + HProcName + "'", "Gy_Process"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,宸ュ簭涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + //else + //{ + // objJsonResult.code = CodeConstant.FAIL; + // objJsonResult.count = CountConstant.FAIL; + // objJsonResult.Message = "绗�" + index + "琛�,宸ュ簭浠g爜涓虹┖"; + // objJsonResult.data = null; + // return objJsonResult; + //} + + //闃查敊瑁呯疆 + if (HPreventErrMouldNumber != "") + { + ds = oCN.RunProcReturn("select * from Gy_PreventErrMould where HNumber='" + HPreventErrMouldNumber + "' and Hname='" + HPreventErrMouldName + "'", "Gy_PreventErrMould"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,闃查敊瑁呯疆涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HPreventErrMouldID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,闃查敊瑁呯疆浠g爜涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } + //鍗曟嵁鍙� + if (HBillNo == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鍗曟嵁鍙蜂笉鑳戒负绌猴紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + + objJsonResult.code = CodeConstant.SUCCEED; + objJsonResult.count = CountConstant.SUCCEED; + objJsonResult.Message = error; + objJsonResult.data = tb2; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 浜у搧闃查敊楠岃瘉娓呭崟椤圭洰 瀵煎叆(淇濆瓨) + [Route("Gy_MaterPreventErrMouldBill/Gy_MaterPreventErrMouldBill_btnSave")] + [HttpPost] + public object Gy_MaterPreventErrMouldBill_btnSave([FromBody] JObject sMainSub) + { + var _value = sMainSub["sMainSub"].ToString(); + string msg1 = _value.ToString(); + string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries); + string msg2 = sArray[0].ToString(); + string user = sArray[1].ToString(); + try + { + if (!DBUtility.ClsPub.Security_Log("Gy_MaterPreventErrMouldBillMain_Edit", 1, false, user)) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); + List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); + + foreach (JObject item in Excel) + { + Dictionary<string, string> dic = new Dictionary<string, string>(); + foreach (var itm in item.Properties()) + { + dic.Add(itm.Name, itm.Value.ToString()); + } + list.Add(dic); + } + + oCN.BeginTran(); + int i = 1; + foreach (Dictionary<string, string> item in list) + { + string HBillType = "7516"; + string HMaker = user;//鍒跺崟浜� + DateTime HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --鏃ユ湡 + long HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); + long HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + string HOrgID = item["HOrgID"].ToString();//缁勭粐ID + string HBillNo = item["鍗曟嵁鍙�"].ToString(); + string HMaterID = item["HMaterID"].ToString() == "" ? "0" : item["HMaterID"].ToString(); + string HProcID = item["HProcID"].ToString() == "" ? "0" : item["HProcID"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + //瀛愯〃 + string HPreventErrMouldID = item["HPreventErrMouldID"].ToString() == "" ? "0" : item["HPreventErrMouldID"].ToString(); + string HSubRemark = item["琛ㄤ綋澶囨敞"].ToString(); + string HPreventErrNote = item["闃查敊鍔熻兘"].ToString(); + string HLoseMode = item["澶辨晥妯″紡"].ToString(); + string HLoseCheck = item["澶辨晥楠岃瘉鏂规硶"].ToString(); + + ds = oCN.RunProcReturn("select * from Gy_MaterPreventErrMouldBillMain where HBillNo='" + HBillNo + "'", "Gy_MaterPreventErrMouldBillMain"); + + if (ds.Tables[0].Rows.Count == 0) + { + long HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo); + //鎻掑叆涓昏〃 + oCN.RunProc("insert into Gy_MaterPreventErrMouldBillMain" + + "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HRemark,HMaker,HMakeDate" + + ",HMaterID,HProcID) " + + "values(" + + "" + (HYear.ToString() != "0" ? HYear.ToString() : DateTime.Now.Year.ToString()) + + "," + HPeriod.ToString() + + ",'" + HBillType + + "','" + HBillType + + "'," + HInterID + + ",'" + HDate + + "','" + HBillNo + + "','" + HRemark + + "','" + user + + "'," +"getdate()" + + ",'" + HMaterID + + "','" + HProcID + + "')"); + //鎻掑叆瀛愯〃 + oCN.RunProc("insert into Gy_MaterPreventErrMouldBillSub " + + "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRemark" + + ",HPreventErrMouldID,HPreventErrNote,HLoseMode,HLoseCheck) " + + " values(" + + "" + HInterID.ToString() + + "," + 1 + + "," + 0 + + "," + 0 + + ",'" + "" + + "','" + "" + + "','" + HSubRemark + + "','" + HPreventErrMouldID + + "','" + HPreventErrNote + + "','" + HLoseMode + + "','" + HLoseCheck + + "')"); + } + else + { + long HInterID = long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString()); + //鑾峰彇鏈�澶у瓙id + DataSet ds2 = oCN.RunProcReturn("select max(HEntryID) HEntryID from Gy_MaterPreventErrMouldBillSub where HInterID='" + HInterID + "'", "Gy_MaterPreventErrMouldBillSub"); + long HEntryID = 1; + if (ds2.Tables[0].Rows.Count > 0) + { + HEntryID = long.Parse(ds2.Tables[0].Rows[0]["HEntryID"].ToString()) + 1; + } + //鎻掑叆瀛愯〃 + oCN.RunProc("insert into Gy_MaterPreventErrMouldBillSub " + + "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRemark" + + ",HPreventErrMouldID,HPreventErrNote,HLoseMode,HLoseCheck) " + + " values(" + + "" + HInterID.ToString() + + "," + HEntryID + + "," + 0 + + "," + 0 + + ",'" + "" + + "','" + "" + + "','" + HSubRemark + + "','" + HPreventErrMouldID + + "','" + HPreventErrNote + + "','" + HLoseMode + + "','" + HLoseCheck + + "')"); + } + + i++; + } + + oCN.Commit(); + + objJsonResult.code = CodeConstant.SUCCEED; + objJsonResult.count = CountConstant.SUCCEED; + objJsonResult.Message = "瀵煎叆鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write(e); + oCN.RollBack(); + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #endregion + + } } \ No newline at end of file -- Gitblit v1.9.1