From 6768e9f5d677e53e6d788d49e1ca5b9755236ca4 Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期二, 22 十月 2024 13:56:24 +0800 Subject: [PATCH] 工艺路线关闭其它功能,分页异常bug修复 --- WebAPI/Controllers/BaseSet/Gy_UnitController.cs | 484 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 477 insertions(+), 7 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_UnitController.cs b/WebAPI/Controllers/BaseSet/Gy_UnitController.cs index 8dca7aa..bfffd0d 100644 --- a/WebAPI/Controllers/BaseSet/Gy_UnitController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_UnitController.cs @@ -1,5 +1,7 @@ -锘縰sing Newtonsoft.Json; +锘縰sing Model; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using NPOI.SS.Formula.Functions; using Pub_Class; using System; using System.Collections; @@ -7,6 +9,7 @@ using System.Data; using System.Data.SqlClient; using System.Web.Http; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; using WebAPI.Models; using WebAPI.Service; @@ -14,8 +17,10 @@ { public class Gy_UnitController : ApiController { + //鑾峰彇绯荤粺鍙傛暟 + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DBUtility.ClsPub.Enum_BillStatus BillStatus; - + public DAL.ClsGy_Unit_Ctl BillOld = new DAL.ClsGy_Unit_Ctl(); private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; @@ -28,7 +33,7 @@ /// </summary> [Route("Gy_Unit/list1")] [HttpGet] - public object list(string sWhere,string user,string Organization) + public object list(string sWhere, string user, string Organization) { try { @@ -43,7 +48,7 @@ return objJsonResult; } - string sql1 = string.Format(@"select * from h_v_Gy_UnitList where 绂佺敤鏍囪='' and 缁勭粐鍚嶇О='" + Organization + "'"); + string sql1 = string.Format(@"select * from h_v_Gy_UnitList where 缁勭粐鍚嶇О='" + Organization + "'"); if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn(sql1 + sWhere + "order by 璁¢噺鍗曚綅浠g爜 ", "h_v_Gy_UnitList"); @@ -79,6 +84,159 @@ } } + [Route("Gy_Unit/AuditGy_Unit")] + [HttpGet] + public object AuditGy_Unit(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log("Gy_Unit_Check", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬鏍�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 瀹℃牳 2 鍙嶅鏍� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 + DataSet ds; + string sql = "select * from Gy_Unit where HItemID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0].Rows[0]["HCheckEmp"] != null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //瀹℃牳鍗曟嵁 + if (!BillOld.AuditByID(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� + DataSet ds; + string sql = "select * from Gy_Unit where HItemID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HCheckEmp"] == null || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅鏍稿崟鎹� + if (!BillOld.DeAuditByID(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + } + + oCN.Commit();//鎻愪氦浜嬪姟 + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鎵ц鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + [Route("Gy_Unit/JY_Json")] + [HttpGet] + public object JY_Json(long HItemID) + { + try + { + ds = oCN.RunProcReturn("update Gy_Unit set HStopFlag = 1 where HItemID = " + HItemID, "Gy_Unit"); + + 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; + } + } + + /// <summary> + /// 閮ㄩ棬鍒楄〃鍙嶇鐢ㄦ寜閽� + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Gy_Unit/FJY_Json")] + [HttpGet] + public object FJY_Json(long HItemID) + { + try + { + ds = oCN.RunProcReturn("update Gy_Unit set HStopFlag = 0 where HItemID = " + HItemID, "Gy_Unit"); + + 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; + } + } [Route("Gy_Unit/LoadTree")] [HttpGet] @@ -86,7 +244,7 @@ { SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN(); //ds = oCN.RunProcReturn("select * from h_v_IF_GroupList " + sWhere, "h_v_IF_GroupList"); - ds = oCN.RunProcReturn("select * from h_v_UnitLoadTree", "h_v_UnitLoadTree"); + ds = oCN.RunProcReturn("select * from h_v_Gy_UnitList", "h_v_Gy_UnitList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; @@ -122,6 +280,7 @@ string msg1 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg_HUSEORGID = sArray[2].ToString(); + Single msg_HRate = float.Parse(sArray[3]); Int64 HItemID = 0; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); @@ -267,7 +426,7 @@ oItem.HShortNumber = sShortNumber;//鐭唬鐮� oItem.HEndFlag = true;//鏈骇鏍囧織 oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 - oItem.HRate= DBUtility.ClsPub.GetLevel(oItem.HRate.ToString().Trim());//鎹㈢畻姣斾緥 + oItem.HRate = msg_HRate;//鎹㈢畻姣斾緥 oBill.oModel = oItem; } @@ -311,6 +470,59 @@ } } + [Route("Gy_Unit/SaveGy_UnitListApi")] + [HttpPost] + public object SaveGy_UnitListApi([FromBody] JObject msg) + { + try + { + LogService.Write("鍗曚綅锛�" + msg.ToString()); + var _value = msg["model"].ToString(); + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + ListModels oListModels = new ListModels(); + List<Model.ClsGy_Unit_Model> lsmain = new List<Model.ClsGy_Unit_Model>(); + lsmain = oListModels.getObjectByJson_Gy_Unit(_value); + string sql = string.Empty; + //淇濆瓨 + oCN.BeginTran(); + sql = $"delete Gy_Unit where HItemID = {lsmain[0].HItemID}"; + oCN.RunProc(sql); + sql = "set identity_insert Gy_Unit on"; + oCN.RunProc(sql); + + LogService.Write("鍗曚綅锛�" + "Insert into Gy_Unit" + + " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HRate,HStandard,HUSEORGID,HCREATEORGID) " + + " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID.ToString() + + "," + lsmain[0].HLevel.ToString() + "," + Convert.ToString(lsmain[0].HEndFlag ? 1 : 0) + "," + Convert.ToString(lsmain[0].HStopflag ? 1 : 0) + ",'" + lsmain[0].HRemark + + "'," + lsmain[0].HRate.ToString() + "," + DBUtility.ClsPub.BoolToString(lsmain[0].HStandard) + "," + lsmain[0].HUSEORGID + "," + lsmain[0].HCREATEORGID + ")"); + + oCN.RunProc("Insert into Gy_Unit" + + " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HRate,HStandard,HUSEORGID,HCREATEORGID,HERPItemID) " + + " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID.ToString() + + "," + lsmain[0].HLevel.ToString() + "," + Convert.ToString(lsmain[0].HEndFlag ? 1 : 0) + "," + Convert.ToString(lsmain[0].HStopflag ? 1 : 0) + ",'" + lsmain[0].HRemark + + "'," + lsmain[0].HRate.ToString() + "," + DBUtility.ClsPub.BoolToString(lsmain[0].HStandard) + "," + lsmain[0].HUSEORGID + "," + lsmain[0].HCREATEORGID + "," + lsmain[0].HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo); + //淇敼涓婄骇涓洪潪鏈骇浠g爜 + sql = "set identity_insert Gy_Unit off"; + oCN.RunProc(sql); + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } /// <summary> /// 璁¢噺鍗曚綅鑾峰彇淇℃伅 /// </summary> @@ -329,7 +541,7 @@ /// <returns></returns> [Route("DeltetGy_Unit")] [HttpGet] - public object DeltetGy_Unit(string HItemID,string user) + public object DeltetGy_Unit(string HItemID, string user) { DataSet ds; //string ModRightNameCheck = "Sc_ProcessReport_check"; @@ -394,7 +606,265 @@ } } + #region [鍚屾鍩虹璧勬枡] + [Route("Gy_Unit/Gy_UnitViewApi")] + [HttpGet] + public json Gy_UnitViewApi(string Number, string Type) + { + string sql = string.Empty; + string sReturn = ""; + if (oSystemParameter.ShowBill(ref sReturn) == true) + { + //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡 + if (oSystemParameter.omodel.WMS_CloudMode == "Y") + { + #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩 + try + { + oCN.BeginTran(); + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPBasicInfoToLocal '" + Number + "','" + Type + "'", "h_p_WMS_ERPBasicInfoToLocal"); + if (DS == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍩虹璧勬枡鍚屾澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ERP涓笉瀛樺湪璇ヤ唬鐮�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + 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 + } + else + { + #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩 + var json = new + { + CreateOrgId = 0, + Number = Number, + Id = "" + }; + #region [閲戣澏閮ㄥ垎] + //鐧诲綍閲戣澏 + var loginRet = InvokeHelper.Login(); + var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); + //鍒ゆ柇鏄惁鐧诲綍鎴愬姛 + if (isSuccess < 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = loginRet; + objJsonResult.data = null; + return objJsonResult; + } + //鏌ョ湅 鑾峰彇鏁版嵁 + var _result = InvokeHelper.View("BD_UNIT", JsonConvert.SerializeObject(json)); + var _saveObj = JObject.Parse(_result); + //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛 + if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "閲戣澏璁¢噺鍗曚綅鍚屾澶辫触jsonRoot锛�" + _result; + objJsonResult.data = null; + return objJsonResult; + } + + #endregion + //鑾峰彇鏁版嵁 + DataSet Ds; + Ds = oCN.RunProcReturn("select * from Gy_Unit where HNumber = '" + Number + "'", "Gy_Unit"); + if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"].ToString()) != 0) + { + + } + + #region [琛ㄦ暟鎹祴鍊糫 + var jsonData = new + { + HItemID = _saveObj["Result"]["Result"]["Id"], + HERPItemID = _saveObj["Result"]["Result"]["Id"], + HNumber = _saveObj["Result"]["Result"]["Number"], + HName = _saveObj["Result"]["Result"]["Name"][0]["Value"], + HShortNumber = _saveObj["Result"]["Result"]["Number"], + HParentID = 0, + HLevel = 1, + HEndFlag = 1, + HStopflag = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1, + HRemark = "CLD-ERP瀵煎叆", + HUseFlag = "鏈娴�", + HRate = "1", + HMakeTime = _saveObj["Result"]["Result"]["CreateDate"], + HStandard = 1, + HCREATEORGID = _saveObj["Result"]["Result"]["CreatorId_Id"], + HUSEORGID = 0, + }; + #endregion + // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁 + sql = $"delete from Gy_Unit where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'"; + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Unit on"; + oCN.RunProc(sql); + + //鎻掑叆琛� + sql = $@" + insert into Gy_Unit + (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID + ,HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HRate,HMakeTime,HStandard,HCREATEORGID,HUSEORGID + ) + values + ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}', + '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HRate}','{jsonData.HMakeTime}',{jsonData.HStandard},{jsonData.HCREATEORGID},{jsonData.HUSEORGID})"; + + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Unit off"; + oCN.RunProc(sql); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "璁¢噺鍗曚綅鍚屾鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + + #endregion + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍩虹璧勬枡璇诲彇澶辫触锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + + #region 绂佺敤銆佸弽绂佺敤 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Unit/StopGy_Unit")] + [HttpGet] + public object StopGy_MaterType(int HInterID, int IsStop, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Unit_Stop", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Unit where HItemID=" + HInterID, "Gy_Unit"); + if (ds.Tables[0].Rows.Count > 0) + { + if (IsStop == 0) //绂佺敤鍒ゆ柇 + { + if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + + oCN.BeginTran(); + + if (IsStop == 0) //绂佺敤鍒ゆ柇 + { + oCN.RunProc("update Gy_Unit set HStopEmp='" + CurUserName + "',HStopDate=getdate(),HStopflag=1 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "绂佺敤鎴愬姛"; + objJsonResult.data = null; + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + oCN.RunProc("update Gy_Unit set HStopEmp='',HStopDate=null,HStopflag=0 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�"; + objJsonResult.data = null; + } + oCN.Commit(); + + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion } } \ No newline at end of file -- Gitblit v1.9.1