using Cksoft.Data; using Cksoft.Data.Repository; using DllUfpEntity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DllUfpDal { /// /// 欧非人资系统员工同步 /// public class OfRzDataSyncDal { /// /// 将EAP系统中已离职的员工置为离职状态 /// /// public async Task Sync() { IDatabase eapDb = null; IDatabase rzDb = null; string errorinfo = string.Empty; try { eapDb = DbFactory.Base("ufp"); rzDb = DbFactory.Base("OfilmRZ"); var staffs = await eapDb.FindListForConditionAsync($" and a.isSa=-1", ref errorinfo); var disables = new List(); if (staffs != null && staffs.Count() > 0) { foreach (var item in staffs) { var sql = "select name as staffName,psn_code as StaffCode from OFNCHR.hr_hrpsndoc_ccmon " + $"where SUBSTR(PSN_CODE, 3, LENGTH(PSN_CODE)-2)='{item.FCode}' "; var rzs = await rzDb.FindListAsync(sql, null); if (rzs == null || rzs.Count() <= 0) { disables.Add(item); } } } if (disables.Count > 0) { var updateSql = $"Update Staff set FStastus = -1 where id in ({string.Join(",", disables.Select(c => $"'{c.ID}'"))})"; eapDb.ExecuteBySql(updateSql); } } catch (Exception e) { throw e; } finally { if (eapDb != null) eapDb.Close(); if (rzDb != null) rzDb.Close(); } } } public class OfilmRzEmployee { public string StaffCode { get; set; } public string StaffName { get; set; } } }