From 5cdcde592ae19de697c4bf16dce08838065987e3 Mon Sep 17 00:00:00 2001 From: yangle <admin@YINMOU> Date: 星期二, 22 八月 2023 16:01:23 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/SRM-WEBAPI --- WebAPI/Controllers/WebAPIController.cs | 245 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 210 insertions(+), 35 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index 1ecfa5b..c4fde65 100644 --- a/WebAPI/Controllers/WebAPIController.cs +++ b/WebAPI/Controllers/WebAPIController.cs @@ -1,15 +1,21 @@ 锘縰sing DAL; +using DBUtility; +using Microsoft.AspNet.SignalR; using Model; +using Newtonsoft.Json.Linq; using SQLHelper; using System; using System.Collections.Generic; using System.Data; +using System.Data.SqlClient; using System.Linq; using System.Net; using System.Net.Http; +using System.Web; using System.Web.Http; using WebAPI.BLL; using WebAPI.Models; +using WebAPI.Utility; namespace WebAPI.Controllers { @@ -17,7 +23,7 @@ { private JsonResult objJsonResult = new JsonResult(); private json objjson = new json(); - // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); + // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); public string sWhere = ""; public WebServer webserver = new WebServer(); public DataSet ds = new DataSet(); @@ -40,25 +46,25 @@ public static bool Add_Log(string WorkList, string CurUserName, string State) { - DBUtility.ClsPub.SetIPAddress(); - string IPAddress; - string ComputerName; - IPAddress = DBUtility.ClsPub.IPAddress; - ComputerName = DBUtility.ClsPub.ComputerName; - ClsCNSRM oCnLoc = new ClsCNSRM(); - try - { - oCnLoc.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + - "(getdate(),'" + CurUserName + "','" + ComputerName + "','" + WorkList + "','SRM绯荤粺','" + IPAddress + "','" + State + "')" - ); + DBUtility.ClsPub.SetIPAddress(); + string IPAddress; + string ComputerName; + IPAddress = DBUtility.ClsPub.IPAddress; + ComputerName = DBUtility.ClsPub.ComputerName; + ClsCNSRM oCnLoc = new ClsCNSRM(); + try + { + oCnLoc.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + + "(getdate(),'" + CurUserName + "','" + ComputerName + "','" + WorkList + "','SRM绯荤粺','" + IPAddress + "','" + State + "')" + ); - return true; - } - catch (Exception e) - { - return false; + return true; + } + catch (Exception e) + { + return false; - } + } } /// <summary> @@ -131,6 +137,38 @@ } } + + /// <summary> + /// 鑾峰彇鐧诲綍椤电粍缁囧垪 + /// </summary> + /// <returns></returns> + [Route("GetOrganizations")] + [HttpGet] + public object GetOrganizations() + { + try + { + ClsCN oCn = new ClsCN(); + DataSet oDs = new DataSet(); + //========== + oDs = oCn.RunProcReturn("select HItemID ID,Hname Name,HStopflag Stopflag from Xt_ORGANIZATIONS", "Xt_ORGANIZATIONS"); + objjson.code = "1"; + objjson.count = 1; + objjson.Message = "鑾峰彇鎴愬姛锛�"; + objjson.data = oDs.Tables[0]; + return objjson; ; + } + catch (Exception e) + { + + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鑾峰彇澶辫触锛佸紓甯�" + e.ToString(); + objjson.data = null; + return objjson; ; + } + } + /// <summary> /// 鐧诲綍 /// </summary> @@ -146,7 +184,17 @@ DataSet ds = null; ClsCNSRM oCnLoc = new ClsCNSRM(); DAL.ClsUser oUser = new DAL.ClsUser(); - ds = oUser.CheckCzymc(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim())); + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); + //LogService.Write("娴嬭瘯1锛�"+ DBUtility.ClsPub.sExeReturnInfo); + string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo); + LogService.Write(FCusName); + LogService.Write("DBUtility.ClsPub.StrToPsd(PassWord.Trim()):" + DBUtility.ClsPub.StrToPsd(PassWord.Trim())); + //if (FCusName == "澶忓疂鐢靛櫒") + // ds = CheckMainID(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim())); + //else + // ds = CheckCzymc(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim())); + + ds = CheckMainID(UserName.Trim(), DBUtility.ClsPub.StrToPsd(PassWord.Trim())); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; @@ -165,16 +213,44 @@ return objJsonResult; } } - catch (Exception) + catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鐧诲綍寮傚父锛�"; + objJsonResult.Message = "鐧诲綍寮傚父锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; ; } } + public DataSet CheckMainID(string MainID, string sPsd) + { + DataSet DS; + try + { + SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); + DS = oCn.RunProcReturn("select * from Gy_Czygl where Czybm='" + MainID + "' and Czmm='" + sPsd + "' ", "Gy_Czygl"); + if (DS.Tables[0].Rows.Count == 0) + return null; + else + { + return DS; + } + } + catch (Exception e) + { + throw (e); + } + } + public DataSet CheckCzymc(string sUser, string sPsd) + { + SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); + SqlParameter[] prams ={oCn.MakeInParam("@Czymc",SqlDbType.VarChar,100,sUser ), + oCn.MakeInParam("@Czmm",SqlDbType.VarChar ,100,sPsd ), + }; + return oCn.RunProcReturn("select * from Gy_Czygl where Czymc='" + sUser + "' and Czmm='" + sPsd + "' ", prams, "Gy_Czygl"); + } + /// <summary> /// 淇敼瀵嗙爜 /// </summary> @@ -199,18 +275,19 @@ return objJsonResult; ; } //=========== - oDs = oCn.RunProcReturn("select Czmm from Gy_Czygl where Czybm='" + UserName + "'", "Gy_Czygl"); + //LogService.Write("select Czmm from Gy_Czygl where Czymc='" + UserName + "' and Czmm = '" + DBUtility.ClsPub.StrToPsd(oldPassword.Trim()) + "'"); + oDs = oCn.RunProcReturn("select Czmm from Gy_Czygl where Czymc='" + UserName + "' and Czmm = '" + DBUtility.ClsPub.StrToPsd(oldPassword.Trim()) + "'", "Gy_Czygl"); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁杩欎釜鐢ㄦ埛锛屼笉鑳戒慨鏀瑰瘑鐮侊紒"; + objJsonResult.Message = "鍘熷瘑鐮侀敊璇紒"; objJsonResult.data = null; return objJsonResult; ; } else { - oCn.RunProc("update Gy_Czygl set Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' where Czybm='" + UserName.Trim() + "'"); + oCn.RunProc("update Gy_Czygl set Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' where Czymc='" + UserName.Trim() + "'"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "* 瀵嗙爜淇敼鎴愬姛锛�"; @@ -334,13 +411,13 @@ try { - oCn.BeginTran(); - oCn.RunProc("Insert into SRM_OpenTmp " + - " (HNumber,HModel,HName) " + - " Values('" + HNumber + "','" + HName + "','" + HName + "')", ref DBUtility.ClsPub.sExeReturnInfo); - //淇敼涓婄骇涓洪潪鏈骇浠g爜 - //oCn.RunProc("Update Gy_OpenTmp set HEndflag=0 where HItemID=" + oModel.HParentID, ref ClsPub.sExeReturnInfo); - oCn.Commit(); + //oCn.BeginTran(); + //oCn.RunProc("Insert into SRM_OpenTmp " + + // " (HNumber,HModel,HName) " + + // " Values('" + HNumber + "','" + HName + "','" + HName + "')", ref DBUtility.ClsPub.sExeReturnInfo); + ////淇敼涓婄骇涓洪潪鏈骇浠g爜 + ////oCn.RunProc("Update Gy_OpenTmp set HEndflag=0 where HItemID=" + oModel.HParentID, ref ClsPub.sExeReturnInfo); + //oCn.Commit(); objjson.code = "0"; objjson.count = 1; objjson.Message = "淇濆瓨鎴愬姛!"; @@ -370,9 +447,9 @@ ClsCNSRM oCn = new ClsCNSRM(); try { - oCn.BeginTran(); - oCn.RunProc("Delete from SRM_OpenTmp where HItemID='" + DBUtility.ClsPub.isLong(HItemID) + "'", ref DBUtility.ClsPub.sExeReturnInfo); - oCn.Commit(); + //oCn.BeginTran(); + //oCn.RunProc("Delete from SRM_OpenTmp where HItemID='" + DBUtility.ClsPub.isLong(HItemID) + "'", ref DBUtility.ClsPub.sExeReturnInfo); + //oCn.Commit(); objjson.code = "0"; objjson.count = 1; objjson.Message = "鍒犻櫎鎴愬姛!"; @@ -695,6 +772,104 @@ #endregion - + /// <summary> + /// 瑙﹀彂hub鐨刟pi + /// </summary> + /// <param name="request">request</param> + /// <returns>message</returns> + [AllowAnonymous] + [Route("show/hub"), HttpGet] + public HttpResponseMessage GetMessage(HttpRequestMessage request) + { + var hub = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); + //娉ㄦ剰杩欓噷鐨剆howMessage 灏辨槸瀵筊epairHub涓嬪畾涔夌殑showMessage鏂规硶璋冪敤,鍚屾牱鍓嶇涔熸槸璋冪敤杩欎釜鏂规硶 + string aa = hub.Clients.All.showMessage("杩欓噷闈㈠彲浠ユ斁鍏ヤ换鎰忓璞�,鍓嶅彴鍙互鏀跺埌姝ゅ唴瀹�"); + return request.CreateResponse(HttpStatusCode.OK, aa); + } + + [Route("Message/MsgCount")] + [HttpPost] + public object MsgCount() + { + ClsCNSRM oCn = new ClsCNSRM(); + DataSet oDs = new DataSet(); + oDs = oCn.RunProcReturn("select * from Gy_Message", "Gy_Message"); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖鏁版嵁"; + objJsonResult.data = oDs; + return objJsonResult; ; + } + + + #region [鍏憡鏁版嵁鏌ヨ] + [Route("MsgData")] + [HttpGet] + public object MsgData(string sWhere) + { + ClsCNSRM oCn = new ClsCNSRM(); + DataSet oDs = new DataSet(); + var sql = "select A.HInterID,b.HEntryID,A.HContext,A.HDeptID,D.HName HDeptName, A.HSendMan, B.HReceiveMan,A.HLevel,A.HDescription,case when B.HReadFlag=0 then '鏈槄' when B.HReadFlag=1 then '宸查槄' end HReadFlag,A.HDate" + + " from OA_InformBillMain A inner join OA_InformBillSub B on A.HInterID=B.HInterID left join Gy_Department D on A.HDeptID=D.HItemID where 1=1 " + sWhere; + oDs = oCn.RunProcReturn(sql, "OA_InformBillMain"); + if (oDs.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "杩斿洖鏁版嵁鎴愬姛锛�"; + objJsonResult.data = oDs; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "杩斿洖鏁版嵁澶辫触锛�"; + objJsonResult.data = oDs; + } + return objJsonResult; ; + } + #endregion + + #region[鏇存敼鍏憡鐘舵�乚 + [Route("UpdateMessage")] + [HttpGet] + public object UpdateMessage(string UserName, string HInterID, string HEntryID) + { + ClsCNSRM oCn = new ClsCNSRM(); + oCn.BeginTran(); + oCn.RunProc("Update OA_InformBillSub set HReadFlag=1 HUpDater='" + UserName + "',HUpDateDate=getdate() where HInterID='" + HInterID + "' and HEntryID='" + HEntryID + "'", ref ClsPub.sExeReturnInfo); + oCn.Commit(); + objjson.code = "1"; + objjson.count = 1; + objjson.Message = ClsPub.sExeReturnInfo; + objjson.data = null; + return objjson; ; + } + #endregion + #region[鎵撳嵃idSession] + [Route("linteridSession")] + [HttpPost] + public object linteridSession([FromBody] JObject linterid) + { + var _linterid = linterid["linterid"].ToString(); + var _huserName = linterid["HUserName"].ToString(); + var postMesseege = _linterid + ";" + _huserName; + //HttpHelper.PostData("http://localhost:8082/ZYMES/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); + HttpHelper.PostData("http://60.191.21.115:9090/layuiAdmin.std-v1.2.1/src/views/SRM/Api/SRM_Web_PoBarCodeBillApi.ashx", postMesseege); + SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM(); + string sql = $"Update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0) + 1 where HItemID in ({_linterid})"; + oCn.RunProc(sql); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = ""; + objJsonResult.data = 1; + return objJsonResult; + + //HttpContext.Current.Session["linterid"]; + + } + #endregion + + } } -- Gitblit v1.9.1