| | |
| | | using Newtonsoft.Json.Linq; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Collections; |
| | |
| | | { |
| | | 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(); |
| | |
| | | /// </summary> |
| | | [Route("Gy_Employee/list")] |
| | | [HttpGet] |
| | | public object list(string sWhere,string Organization) |
| | | public object list(string sWhere,string user,string Organization) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string sql1 = string.Format(@"select * from h_v_IF_EmployeeList where 组织名称='" + Organization + "'"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | |
| | | string sql = sql1 + sWhere + " order by 职员代码"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_IF_EmployeeList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | //string msg3 = sArray[1].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | //string msg4 = sArray[2].ToString(); |
| | | //string msg5 = sArray[3].ToString(); |
| | | |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Edit", 1, false, msg3)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //反序列化 |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<Gy_Employee> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_Employee>>(msg2); |
| | |
| | | long HCTPrjID = list[0].HCTPrjID; |
| | | long HProcID = list[0].HProcID; |
| | | string HBasePay = list[0].HBasePay; |
| | | DateTime HInComDate = list[0].HInComDate; |
| | | DateTime HDimissionDate = list[0].HDimissionDate; |
| | | DateTime HInComDate = list[0].HInComDate; //进厂日期 |
| | | DateTime HDimissionDate = list[0].HDimissionDate; //离职日期 (允许NULL) |
| | | bool HOverType = list[0].HOverType; |
| | | string HEmpType = list[0].HEmpType; |
| | | string HOtherDeduct3 = list[0].HOtherDeduct3; |
| | |
| | | string HMedicare = list[0].HMedicare; |
| | | bool HNoBrushFlag = list[0].HNoBrushFlag; |
| | | bool HShiftFlag = list[0].HShiftFlag; |
| | | DateTime HContactDate = list[0].HContactDate; |
| | | //DateTime HContactDate = list[0].HContactDate; //合同日期 |
| | | bool HStopwagesFlag = list[0].HStopwagesFlag; |
| | | string HDimissionReason = list[0].HDimissionReason; |
| | | long HDormID = list[0].HDormID; |
| | | string HArchivesNo = list[0].HArchivesNo; |
| | | DateTime HStayCardEDate = list[0].HStayCardEDate; |
| | | DateTime HCheckCardEDate = Convert.ToDateTime("1900/1/1"); |
| | | DateTime HStayCardEDate = list[0].HStayCardEDate; //暂住证到期日 |
| | | DateTime HCheckCardEDate = Convert.ToDateTime("1900/1/1"); //审检证到期日 |
| | | string HJobCardNo = list[0].HJobCardNo ?? ""; |
| | | DateTime HJobCardEDate = Convert.ToDateTime("1900/1/1"); |
| | | DateTime HJobCardEDate = Convert.ToDateTime("1900/1/1"); //就业证到期日 |
| | | string HWorkType = list[0].HWorkType; |
| | | long HContractYear = list[0].HContractYear; |
| | | DateTime HContractBDate = list[0].HContractBDate; |
| | | DateTime HContractEDate = list[0].HContractEDate; |
| | | DateTime HContractBDate = list[0].HContractBDate; //合同开始日 |
| | | DateTime HContractEDate = list[0].HContractEDate; //合同到期日 |
| | | string HInsuranceNo = list[0].HInsuranceNo; |
| | | DateTime HInsuranceDate = list[0].HInsuranceDate; |
| | | DateTime HInsuranceDate = list[0].HInsuranceDate; //参保日期 |
| | | bool HInsuranceStatus = list[0].HInsuranceStatus; |
| | | DateTime HSignDate = list[0].HSignDate; |
| | | DateTime HSignDate = Convert.ToDateTime("1900/1/1"); //签约日期 |
| | | bool HSignStatus = list[0].HSignStatus; |
| | | string HOldCompany = list[0].HOldCompany ?? ""; |
| | | string HMarr = list[0].HMarr ?? ""; |
| | |
| | | string HSpec = list[0].HSpec ?? ""; |
| | | string HCompLev = list[0].HCompLev ?? ""; |
| | | string HEngLev = list[0].HEngLev ?? ""; |
| | | DateTime HGradDate = list[0].HGradDate; |
| | | DateTime HGradDate = list[0].HGradDate; //毕业日期 |
| | | string HGradSchool = list[0].HGradSchool ?? ""; |
| | | string HSalaryLev = list[0].HSalaryLev ?? ""; |
| | | long HDutyID = list[0].HDutyID; |
| | |
| | | string HStdDayPay = list[0].HStdDayPay ?? ""; |
| | | string HMinDayPay = list[0].HMinDayPay ?? ""; |
| | | string HMinMonthPay = list[0].HMinMonthPay ?? ""; |
| | | DateTime HMadeDate = list[0].HMadeDate; |
| | | //DateTime HMadeDate = list[0].HMadeDate; //建立日期 |
| | | string HEmpRate = list[0].HEmpRate ?? ""; |
| | | string HExamRate = list[0].HExamRate ?? ""; |
| | | DateTime HHealthCardEDate = Convert.ToDateTime("1900/1/1"); |
| | | DateTime HHealthCardEDate = Convert.ToDateTime("1900/1/1"); //健康证到期日 |
| | | long HUSEORGID = list[0].HUSEORGID; |
| | | |
| | | ////判断权限 |
| | | //if (!ClsPub.Security_Log(msg5, 1, false, msg4)) |
| | |
| | | ",HEmpType,HPayType,HOverType,HNoBrushFlag,HShiftFlag,HStopwagesFlag" + |
| | | ",HPostalCode,HBank,HBasePay,HExamLevPostMoney,HBSTDeptID" + |
| | | ",HOtherDeduct3,HInsurance,HMedicare,HDrydock" + |
| | | ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HAddress" + |
| | | ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress" + |
| | | ") " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HShortNumber + "'," + HEmpRate.ToString() + "," + HExamRate.ToString() + |
| | | "," + HLevel + "," + HParentID + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + HHighestPay.ToString() + "," + HOverPayRate.ToString() + |
| | | "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'" + ",'" + HHelpCode + "'," + HInsuranceSubsidy.ToString() + "" + |
| | | ",'" + HBirthDay + "','" + HGradDate + "','" + HInsuranceDate + "','" + HContractBDate + "','" + HContractEDate + "'" + |
| | | " Values('" + HNumber + "','" + HName + "','" + HShortNumber + "','" + HEmpRate.ToString() + "','" + HExamRate.ToString() + |
| | | "','" + HLevel + "','" + HParentID + "','" + Convert.ToString(HEndFlag ? 1 : 0) + "','" + HHighestPay.ToString() + "','" + HOverPayRate.ToString() + |
| | | "','" + Convert.ToString(HStopflag ? 1 : 0) + "','" + HRemark + "'" + ",'" + HHelpCode + "','" + HInsuranceSubsidy.ToString() + |
| | | "','" + HBirthDay + "','" + HGradDate + "','" + HInsuranceDate + "','" + HContractBDate + "','" + HContractEDate + "'" + |
| | | ",'" + HJobCardEDate + "','" + HCheckCardEDate + "','" + HStayCardEDate + "','" + HHealthCardEDate + "'" + |
| | | "," + HAge.ToString() + ",'" + HSalaryLev + "'," + HContractYear.ToString() + "," + Convert.ToString(HInsuranceStatus ? 1 : 0) + "," + Convert.ToString(HSignStatus ? 1 : 0) + |
| | | ",'" + HSex + "','" + HMarr + "','" + HBlighty + "','" + HNation + "','" + HBlightyType + "'" + |
| | | ",'" + HAge.ToString() + "','" + HSalaryLev + "','" + HContractYear.ToString() + "','" + Convert.ToString(HInsuranceStatus ? 1 : 0) + "','" + Convert.ToString(HSignStatus ? 1 : 0) + |
| | | "','" + 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.ToString() + "," + HDormID.ToString() + "," + HDutyID.ToString() + "," + HLeftMoneyRate.ToString() + |
| | | ",'" + HEmpType + "'" + ",'" + HPayType + "'" + "," + DBUtility.ClsPub.BoolToString(HOverType) + "" + "," + DBUtility.ClsPub.BoolToString(HNoBrushFlag) + "" + "," + DBUtility.ClsPub.BoolToString(HShiftFlag) + "" + "," + DBUtility.ClsPub.BoolToString(HStopwagesFlag) + "" + |
| | | ",'" + HPostalCode + "','" + HBank + "'," + HBasePay.ToString() + "," + HExamLevPostMoney.ToString() + ",'" + HBSTDeptID + "'" + |
| | | "," + HOtherDeduct3.ToString() + "" + "," + HInsurance.ToString() + "" + "," + HMedicare.ToString() + "" + "," + HDrydock.ToString() + "" + |
| | | ",'" + HBankAccount + "'" + "," + HGroupID.ToString() + "" + "," + HDeptID.ToString() + "," + HWorkTypeID.ToString() + "," + HCTPrjID.ToString() + ",'" + HAddress + "'" + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | ",'" + HPostID.ToString() + "','" + HDormID.ToString() + "','" + HDutyID.ToString() + "','" + HLeftMoneyRate.ToString() + |
| | | "','" + HEmpType + "'" + ",'" + HPayType + "'" + ",'" + DBUtility.ClsPub.BoolToString(HOverType) + "','" + DBUtility.ClsPub.BoolToString(HNoBrushFlag) + "','" + DBUtility.ClsPub.BoolToString(HShiftFlag) + "','" + DBUtility.ClsPub.BoolToString(HStopwagesFlag) + |
| | | "','" + HPostalCode + "','" + HBank + "','" + HBasePay.ToString() + "','" + HExamLevPostMoney.ToString() + "','" + HBSTDeptID + "'" + |
| | | ",'" + HOtherDeduct3.ToString() + "','" + HInsurance.ToString() + "','" + HMedicare.ToString() + "','" + HDrydock.ToString() + |
| | | "','" + HBankAccount + "'" + ",'" + HGroupID.ToString() + "','" + HDeptID.ToString() + "','" + HWorkTypeID.ToString() + "','" + HCTPrjID.ToString() + "','" + HUSEORGID + "','" + HAddress + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //修改上级为非末级代码 |
| | | oCN.RunProc("Update Gy_Employee set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | oCN.Commit(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | //oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.Message; |
| | |
| | | /// <returns></returns> |
| | | [Route("DeltetGy_Employee")] |
| | | [HttpGet] |
| | | public object DeltetGy_Employee(string HItemID) |
| | | public object DeltetGy_Employee(string HItemID,string user) |
| | | { |
| | | DataSet ds; |
| | | //string ModRightNameCheck = "Sc_ProcessReport_check"; |
| | | try |
| | | { |
| | | //删除权限 |
| | | //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "审核失败!无权限!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Employee_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (string.IsNullOrWhiteSpace(HItemID)) |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.RunProc("update Gy_Employee set HStopflag=1 where HItemID=" + HItemID); |
| | | oCN.RunProc("delete from Gy_Employee where HItemID=" + HItemID); |
| | | oCN.Commit();//提交事务 |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | #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); |
| | | //修改上级为非末级代码 |
| | | 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为公有云模式,Y为私有云模式 |
| | | 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.HERPItemID},'{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("select * from h_v_IF_EmployeeList where 禁用标记='' and HGroupID=" + HGroupID + " order by 职员代码", "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)); //获取到DataColumn列对象的列名 |
| | | } |
| | | 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 |
| | | |
| | | } |
| | | } |