| New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Kingdee.BOS.Util; |
| | | using Kingdee.BOS.Core.Metadata.EntityElement; |
| | | using Kingdee.BOS.Core.DynamicForm.PlugIn; |
| | | using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; |
| | | using Kingdee.BOS.Orm.DataEntity; |
| | | using System.ComponentModel; |
| | | using Kingdee.BOS.ServiceHelper; |
| | | using System.Data; |
| | | using Newtonsoft.Json.Linq; |
| | | using ZD.Cloud.WebApi; |
| | | using Newtonsoft.Json; |
| | | using Kingdee.BOS.Core.DynamicForm; |
| | | using System.Linq; |
| | | using RestSharp; |
| | | using zymes_Project.Utility; |
| | | |
| | | namespace zymes_Project.OperationService |
| | | { |
| | | [Description("[职员-审核]服务插件]")] |
| | | [HotUpdate] |
| | | public class zymes_RealessEmp : AbstractOperationServicePlugIn |
| | | { |
| | | //插件挂在跟员工的地方一样 |
| | | Dictionary<string, string> dictionary = new Dictionary<string, string>(); |
| | | public override void OnPrepareOperationServiceOption(OnPrepareOperationServiceEventArgs e) |
| | | { |
| | | base.OnPrepareOperationServiceOption(e); |
| | | |
| | | //为了在BeginOperationTransaction里检查数据抛出异常时 |
| | | //只回滚当前单据的事务,这里设置为不支持批量事务,这样BOS会 |
| | | //循环为每一张单据创建事务调用操作 |
| | | e.SupportTransaction = true; |
| | | //e.SurportBatchTransaction = false; |
| | | } |
| | | public override void OnPreparePropertys(PreparePropertysEventArgs e) |
| | | { |
| | | base.OnPreparePropertys(e); |
| | | e.FieldKeys.Add("FEntity"); |
| | | e.FieldKeys.Add("FEntity_FEntryID"); |
| | | } |
| | | public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e) |
| | | { |
| | | base.AfterExecuteOperationTransaction(e); |
| | | Entity entity = this.BusinessInfo.GetEntity("FEntity");//获取明细信息 |
| | | foreach (var billObj in e.DataEntitys) |
| | | { |
| | | var id = billObj["Id"].ToString(); |
| | | string sql =string.Empty; |
| | | sql = $@" |
| | | /*dialect*/ |
| | | SELECT a.FPERSONID AS HItemID,a.FPERSONID AS HERPItemID, |
| | | a.FNumber AS HNumber,l.FName AS HName,a.FNumber AS HShortNumber,0 AS HParentID, |
| | | 1 AS HLevel,'true' AS HEndFlag,o.FNUMBER as HOrganNumber, |
| | | CASE WHEN a.FFORBIDSTATUS = 'A' THEN 'false' ELSE 'true' END AS HStopflag, |
| | | 'CLD-ERP导入' AS HRemark,0 AS HDeptID,0 AS HGroupID,'已使用' AS HUseFlag, |
| | | GETDATE() AS HMakeTime,ep.FCREATEORGID AS HCREATEORGID,ep.FUSEORGID AS HUSEORGID |
| | | FROM T_BD_PERSON a WITH(NOLOCK) |
| | | INNER JOIN T_BD_PERSON_L l WITH(NOLOCK) ON a.FPERSONID = l.FPERSONID and l.FLOCALEID=2052 |
| | | INNER JOIN T_HR_EMPINFO ep WITH(NOLOCK) ON a.FPERSONID = ep.FPERSONID |
| | | left join T_ORG_Organizations o with(nolock) on ep.FUSEORGID=o.FORGID |
| | | Where a.FID={id} |
| | | "; |
| | | DataTable dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | if (dt.Rows.Count == 0) |
| | | { |
| | | LogService.Write("职员同步异常:" + sql); |
| | | continue; |
| | | } |
| | | |
| | | //获取创建职员的使用组织 |
| | | DataTable dataTable = LogService.Get_DisPlayOrg(Context, dt.Rows[0]["HOrganNumber"].ToString()); |
| | | if (dataTable.Rows.Count == 0) |
| | | continue; |
| | | |
| | | if (dataTable.Rows[0]["FISNEEDPUSH"].ToString() == "0") |
| | | continue; |
| | | |
| | | string http = dataTable.Rows[0]["F_RCZU_MesIp"].ToString(); |
| | | |
| | | DataRow dr = dt.Rows[0]; |
| | | JObject model = new JObject(); |
| | | foreach (DataColumn column in dt.Columns) |
| | | { |
| | | model.Add(column.ColumnName, dr[column.ColumnName].ToString()); |
| | | } |
| | | JObject _jsonRoot = new JObject() |
| | | { |
| | | ["model"] = model |
| | | }; |
| | | |
| | | var client = new RestSharp.RestClient(http); |
| | | var requestPost = new RestRequest("Gy_Employee/SaveGy_EmployeeListApi", Method.POST); |
| | | requestPost.AddParameter("application/json", JsonConvert.SerializeObject(_jsonRoot), ParameterType.RequestBody); |
| | | IRestResponse responsePost = client.Execute(requestPost); |
| | | var contentPost = responsePost.Content; |
| | | if (!contentPost.Contains("成功")) |
| | | { |
| | | LogService.Write("职员同步异常,POST方式获取结果," + billObj["Id"] + "," + responsePost.ErrorMessage); |
| | | LogService.Write("职员同步异常,POST," + "Gy_Employee/SaveGy_EmployeeListApi"); |
| | | LogService.Write("职员同步异常,JsonConvert.SerializeObject(_jsonRoot)," + JsonConvert.SerializeObject(_jsonRoot)); |
| | | } |
| | | }; |
| | | |
| | | foreach (var item in dictionary) |
| | | { |
| | | ResultMessage.dataError(this.OperationResult.OperateResult, item.Key, item.Value); |
| | | } |
| | | } |
| | | public static class ResultMessage |
| | | {/// <summary> |
| | | /// 修改提示信息 |
| | | /// </summary> |
| | | /// <param name="operateResult"></param> |
| | | /// <param name="billno"></param> |
| | | public static void dataError(OperateResultCollection operateResult, string billno, string message) |
| | | { |
| | | OperateResult operate = operateResult.Where(n => n.Number == billno).First(); |
| | | operate.Message = message; |
| | | operate.SuccessStatus = false; |
| | | operate.MessageType = MessageType.FatalError; |
| | | } |
| | | } |
| | | } |
| | | } |