|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
using Mapster; |
|
|
|
|
using Serilog; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -315,4 +317,69 @@ FROM Ghre_Request A |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 牛尾培训需求同步 |
|
|
|
|
public async Task Ushio_Sync() |
|
|
|
|
{ |
|
|
|
|
Log.Information($"【牛尾培训需求同步】开始同步"); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string sql = @"SELECT *, TrainStaffId TrainStaffId1
|
|
|
|
|
FROM [120.26.205.42].[GhrUshio].[dbo].Ghrz_Ushio_TrainRequestApply_GHR50_V |
|
|
|
|
WHERE RequestNo NOT IN (SELECT RequestNo FROM Ghre_Request)";
|
|
|
|
|
|
|
|
|
|
var dt = await Db.Ado.GetDataTableAsync(sql); |
|
|
|
|
|
|
|
|
|
var list = Db.Utilities.DataTableToList<Ghre_RequestDto>(dt); |
|
|
|
|
|
|
|
|
|
Log.Information($"【牛尾培训需求同步】查询到待同步{list.Count}条数据"); |
|
|
|
|
for (int i = 0; i < list.Count; i++) |
|
|
|
|
{ |
|
|
|
|
Log.Information($"【牛尾培训需求同步】同步队列{i + 1}/{list.Count}"); |
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(list[i]).ToANew<InsertGhre_RequestInput>(); |
|
|
|
|
|
|
|
|
|
if (await base.AnyAsync(x => x.RequestNo == insert.RequestNo)) |
|
|
|
|
continue; |
|
|
|
|
if (list[i].DeptNo.IsNotEmptyOrNull()) |
|
|
|
|
insert.DeptId = (await Db.Queryable<Ghro_Dept>().Where(x => x.DeptNo == list[i].DeptNo).FirstAsync())?.DeptID; |
|
|
|
|
|
|
|
|
|
if (list[i].SponsorNo.IsNotEmptyOrNull()) |
|
|
|
|
insert.SponsorId = (await Db.Queryable<Ghra_Staff>().Where(x => x.StaffNo == list[i].SponsorNo).FirstAsync())?.StaffID; |
|
|
|
|
if (list[i].TrainStaffId1.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
var staffNos = list[i].TrainStaffId1.Split(',').ToList(); |
|
|
|
|
|
|
|
|
|
if (staffNos.Any()) |
|
|
|
|
{ |
|
|
|
|
var staffIds = await Db.Queryable<Ghra_Staff>().Where(x => staffNos.Contains(x.StaffNo)).Select(x => x.StaffID).ToListAsync(); |
|
|
|
|
insert.TrainStaffId = JsonHelper.ObjToJson(staffIds); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
insert.WorkNo = insert.RequestNo; |
|
|
|
|
|
|
|
|
|
if (insert.CourseId == 0) insert.CourseId = null; |
|
|
|
|
|
|
|
|
|
#region 根据参数 处理数据默认状态 |
|
|
|
|
var config = await Db.Queryable<Ghre_Config>().FirstAsync(x => x.ConfigCode == "ESS_Request_Apply_Status"); |
|
|
|
|
if (config != null) |
|
|
|
|
insert.Status = config.ConfigValue; |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
await base.Add(insert); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception E) |
|
|
|
|
{ |
|
|
|
|
Log.Information($"【牛尾培训需求同步】发生错误:{E.Message}"); |
|
|
|
|
Log.Information($"【牛尾培训需求同步】发生错误行:{E.StackTrace}"); |
|
|
|
|
} |
|
|
|
|
Log.Information($"【牛尾培训需求同步】结束同步"); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
} |