From 9382e8326714a25e04661150d0f11ad47ca0fcac Mon Sep 17 00:00:00 2001 From: yangle <admin@YINMOU> Date: 星期二, 15 四月 2025 14:10:36 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs | 694 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 692 insertions(+), 2 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs index f993172..434a27f 100644 --- a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs @@ -6,6 +6,8 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using System.IO; +using System.Web; using System.Web.Http; using WebAPI.Models; using WebAPI.Service; @@ -14,12 +16,14 @@ { public class Gy_EmployeeController : ApiController { + //鑾峰彇绯荤粺鍙傛暟 + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; - + string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; /// <summary> /// 杩斿洖鑱屽憳鍒楄〃 @@ -34,7 +38,7 @@ { List<object> columnNameList = new List<object>(); //缂栬緫鏉冮檺 - if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee", 1, false, user)) + if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Query", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; @@ -263,6 +267,8 @@ // return objJsonResult; // } //} + + /// <summary> /// 淇濆瓨鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -575,6 +581,8 @@ return objJsonResult; } } + + ///// <summary> ///// 淇濆瓨鑱屽憳 ///// </summary> @@ -852,6 +860,8 @@ return objJsonResult; } oCN.BeginTran();//寮�濮嬩簨鍔� + string HNumber = ""; + string HName = ""; ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HItemID, "Gy_Employee"); if (ds == null || ds.Tables[0].Rows.Count == 0) { @@ -860,7 +870,21 @@ objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; objJsonResult.data = null; return objJsonResult; ; + }else 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; ; } + else + { + HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString(); + HName = ds.Tables[0].Rows[0]["HName"].ToString(); + } + + var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]); if (HStopflag) { @@ -873,6 +897,24 @@ } oCN.RunProc("delete from Gy_Employee where HItemID=" + HItemID); + + + + //鍐欏叆鏃ュ織 + string Operation = "鍒犻櫎"; //鎿嶄綔 + string ComputerName = System.Net.Dns.GetHostName(); //璁惧鍚嶇О + string WorkList = Operation + "鑱屽憳锛岃亴鍛樹唬鐮侊細" + HNumber + "锛涜亴鍛樺悕绉帮細" + HName ; //鎿嶄綔璇︽儏 + string MvarReportTitle = "鑱屽憳鍒楄〃"; //鎿嶄綔妯″潡 + string SystemName = "LMES-" + MvarReportTitle + "妯″潡"; //鎿嶄綔妯″潡 + string IPAddress = ""; + //string IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString(); //IP鍦板潃 + //string IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress; + + oCN.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + + "(getdate(),'" + user + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','" + Operation + "')" + ); + + oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -891,7 +933,655 @@ } } + #region 鑱屽憳瀹℃牳銆佸弽瀹℃牳 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Employee/AuditGy_Employee")] + [HttpGet] + public object AuditGy_Employee(int HInterID, int IsAudit, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Check", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + var ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HInterID, "Gy_Employee"); + if (ds.Tables[0].Rows.Count > 0) + { + if (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + if (ds.Tables[0].Rows[0]["HCheckEmp"].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 (IsAudit == 0) //瀹℃牳鍒ゆ柇 + { + oCN.RunProc("update Gy_Employee set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛"; + objJsonResult.data = null; + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + oCN.RunProc("update Gy_Employee set HCheckEmp='',HCheckTime=null 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 + + #region 鑱屽憳绂佺敤銆佸弽绂佺敤 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Gy_Employee/StopGy_Employee")] + [HttpGet] + public object StopGy_Employee(int HInterID, int IsStop, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Stop", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HInterID, "Gy_Employee"); + 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_Employee set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "绂佺敤鎴愬姛"; + objJsonResult.data = null; + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + oCN.RunProc("update Gy_Employee set HStopEmp='',HStopTime=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 + + + #region 鑱屽憳 閲戣澏鍚屾 + [Route("Gy_Employee/SaveGy_EmployeeListApi")] + [HttpPost] + public object SaveGy_EmployeeListApi([FromBody] JObject msg) + { + try + { + var _value = msg["model"].ToString(); + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + ListModels oListModels = new ListModels(); + List<Model.ClsGy_Employee_Model> lsmain = new List<Model.ClsGy_Employee_Model>(); + lsmain = oListModels.getObjectByJson_Gy_Employee(_value); + string sql = string.Empty; + //淇濆瓨 + oCN.BeginTran(); + sql = $"delete Gy_Employee where HItemID = {lsmain[0].HItemID}"; + oCN.RunProc(sql); + sql = "set identity_insert Gy_Employee on"; + oCN.RunProc(sql); + + oCN.RunProc($@"insert into Gy_Employee(HItemID,HNumber, HName, HShortNumber, HEmpRate, HExamRate + ,HLevel,HParentID,HEndflag,HHighestPay,HOverPayRate + ,HStopflag,HRemark,HHelpCode,HInsuranceSubsidy + ,HBirthday,HGradDate,HInsuranceDate,HContractBDate,HContractEDate + ,HJobCardEDate,HCheckCardEDate,HStayCardEDate,HHealthCardEDate + ,HAge,HSalaryLev,HContractYear,HInsuranceStatus,HSignStatus + ,HSex,HMarr,HBlighty,HNation,HBlightyType + ,HGovStatus,HBloodType,HStature,HAvoird,HKnowLev + ,HProTitleID,HGradSchool,HEngLev,HCompLev,HSpec + ,HEmail,HNowAdd,HHomeAdd,HIDCard,HLinkPhone,HMobilePhone,HFax + ,HOldCompany,HInsuranceNo,HJobCardNo,HArchivesNo,HWorkType,HDimissionReason + ,HDimissionDate,HInComDate,HSignDate,HRelDate + ,HPostID,HDormID,HDutyID,HLeftMoneyRate + ,HEmpType,HPayType,HOverType,HNoBrushFlag,HShiftFlag,HStopwagesFlag + ,HPostalCode,HBank,HBasePay,HExamLevPostMoney,HBSTDeptID + ,HOtherDeduct3,HInsurance,HMedicare,HDrydock + ,HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress) + values({lsmain[0].HItemID},'{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HShortNumber}',{lsmain[0].HEmpRate},{lsmain[0].HExamRate},{lsmain[0].HLevel},{lsmain[0].HParentID},{Convert.ToString(lsmain[0].HEndFlag ? 1 : 0)},{lsmain[0].HHighestPay},{lsmain[0].HOverPayRate},{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[0].HRemark}','{lsmain[0].HHelpCode}',{lsmain[0].HInsuranceSubsidy},'{lsmain[0].HBirthDay}','{lsmain[0].HGradDate}','{lsmain[0].HInsuranceDate}','{lsmain[0].HContractBDate}','{lsmain[0].HContractEDate}','{lsmain[0].HJobCardEDate}','{lsmain[0].HCheckCardEDate}','{lsmain[0].HStayCardEDate}','{lsmain[0].HHealthCardEDate}',{lsmain[0].HAge},'{lsmain[0].HSalaryLev}',{lsmain[0].HContractYear},{lsmain[0].HInsuranceStatus},{lsmain[0].HSignStatus},'{lsmain[0].HSex}','{lsmain[0].HMarr}','{lsmain[0].HBlighty}','{lsmain[0].HNation}','{lsmain[0].HBlightyType}','{lsmain[0].HGovStatus}','{lsmain[0].HBloodType}','{lsmain[0].HStature}','{lsmain[0].HAvoird}','{lsmain[0].HKnowLev}','{lsmain[0].HProTitleID}','{lsmain[0].HGradSchool}','{lsmain[0].HEngLev}','{lsmain[0].HCompLev}','{lsmain[0].HSpec}','{lsmain[0].HEmail}','{lsmain[0].HNowAdd}','{lsmain[0].HHomeAdd}','{lsmain[0].HIDCard}','{lsmain[0].HLinkPhone}','{lsmain[0].HMobilePhone}','{lsmain[0].HFax}','{lsmain[0].HOldCompany}','{lsmain[0].HInsuranceNo}','{lsmain[0].HJobCardNo}','{lsmain[0].HArchivesNo}','{lsmain[0].HWorkType}','{lsmain[0].HDimissionReason}','{lsmain[0].HDimissionDate}','{lsmain[0].HInComDate}','{lsmain[0].HSignDate}','{lsmain[0].HRelDate}',{lsmain[0].HPostID},{lsmain[0].HDormID},{lsmain[0].HDutyID},{lsmain[0].HLeftMoneyRate},'{lsmain[0].HEmpType}','{lsmain[0].HPayType}','{lsmain[0].HOverType}',{lsmain[0].HNoBrushFlag},{lsmain[0].HShiftFlag},{lsmain[0].HStopwagesFlag},'{lsmain[0].HPostalCode}','{lsmain[0].HBank}',{lsmain[0].HBasePay},{lsmain[0].HExamLevPostMoney},{lsmain[0].HBSTDeptID},{lsmain[0].HOtherDeduct3},{lsmain[0].HInsurance},{lsmain[0].HMedicare},{lsmain[0].HDrydock},'{lsmain[0].HBankAccount}',{lsmain[0].HGroupID},{lsmain[0].HDeptID},{lsmain[0].HWorkTypeID},{lsmain[0].HCTPrjID},{lsmain[0].HUSEORGID},'{lsmain[0].HAddress}')", ref DBUtility.ClsPub.sExeReturnInfo); + //淇敼涓婄骇涓洪潪鏈骇浠g爜 + sql = "set identity_insert Gy_Employee 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; + } + } + #endregion + + #region [鍚屾鍩虹璧勬枡] + [Route("Gy_Employee/Gy_EmployeeViewApi")] + [HttpGet] + public json Gy_EmployeeViewApi(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_Empinfo", 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_Employee where HNumber = '" + Number + "'", "Gy_Employee"); + 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"]["PersonId_Id"], + HERPItemID = _saveObj["Result"]["Result"]["PersonId_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瀵煎叆", + HDeptID = 0, + HGroupID = 0, + HUseFlag = "宸蹭娇鐢�", + HMakeTime = _saveObj["Result"]["Result"]["CreateDate"], + HCREATEORGID = _saveObj["Result"]["Result"]["CreateOrgId_Id"], + HUSEORGID = _saveObj["Result"]["Result"]["UseOrgId_Id"], + }; + #endregion + // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁 + sql = $"delete from Gy_Employee where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'"; + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Employee on"; + oCN.RunProc(sql); + + //鎻掑叆琛� + sql = $@" + insert into Gy_Employee + (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID + ,HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HGroupID,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID + ) + values + ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}', + '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}',{jsonData.HDeptID},{jsonData.HGroupID},'{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID})"; + + oCN.RunProc(sql); + + sql = "set identity_insert Gy_Employee 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> + /// <returns></returns> + [Route("Gy_EmployeeController/GetEmpInfoByGroup_Json")] + [HttpGet] + public object GetEmpInfoByGroup_Json(Int64 HGroupID) + { + try + { + //杩斿洖鍒楄〃淇℃伅 + ds = oCN.RunProcReturn("exec h_p_Pay_GetEmployeeByGroup " + HGroupID.ToString(), "h_p_Pay_GetEmployeeByGroup"); + //ds = oCN.RunProcReturn("select * from h_v_IF_EmployeeList where 绂佺敤鏍囪='' and HGroupID=" + HGroupID + " order by 鑱屽憳浠g爜", "h_v_IF_EmployeeList"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鎵�閫夌彮缁勬棤瀵瑰簲鑱屽憳淇℃伅锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + 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 鑱屽憳闄勪欢涓婁紶 + /// <summary> + /// 鏂囦欢涓婁紶 + /// </summary> + /// <returns></returns> + [Route("Gy_Employee_UploadFile")] + [HttpPost] + public object Gy_Employee_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/Gy_Employee/" + 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/Gy_Employee/" + 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/Gy_Employee/" + 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("Gy_Employee_Filelist")] + [HttpGet] + public object Gy_Employee_Filelist(string HBillNo) + { + var url = fileip + "/files/Gy_Employee/" + 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("Gy_Employee_DeleteFilelist")] + [HttpGet] + public object Gy_Employee_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 } } \ No newline at end of file -- Gitblit v1.9.1