|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using Serilog; |
|
|
|
|
using Tiobon.Core.Common.Https.HttpPolly; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
@ -11,9 +12,11 @@ public class Ghre_TeacherServices : BaseServices<Ghre_Teacher, Ghre_TeacherDto, |
|
|
|
|
private readonly IBaseRepository<Ghre_Teacher> _dal; |
|
|
|
|
private IGhre_AttachmentServices _ghre_AttachmentServices; |
|
|
|
|
private IGhre_TeacherAttachmentServices _ghre_TeacherAttachmentServices; |
|
|
|
|
private readonly IHttpPollyHelper _httpPollyHelper; |
|
|
|
|
public Ghre_TeacherServices(ICaching caching, |
|
|
|
|
IGhre_AttachmentServices ghre_AttachmentServices, |
|
|
|
|
IGhre_TeacherAttachmentServices ghre_TeacherAttachmentServices, |
|
|
|
|
IHttpPollyHelper httpPollyHelper, |
|
|
|
|
IBaseRepository<Ghre_Teacher> dal) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
@ -21,6 +24,7 @@ public class Ghre_TeacherServices : BaseServices<Ghre_Teacher, Ghre_TeacherDto, |
|
|
|
|
base._caching = caching; |
|
|
|
|
_ghre_AttachmentServices = ghre_AttachmentServices; |
|
|
|
|
_ghre_TeacherAttachmentServices = ghre_TeacherAttachmentServices; |
|
|
|
|
_httpPollyHelper = httpPollyHelper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_TeacherDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
@ -611,14 +615,14 @@ FROM (SELECT A.*, |
|
|
|
|
A.Price, |
|
|
|
|
A.SkillPoints, |
|
|
|
|
A.ApplyReason, |
|
|
|
|
C.StaffId SponsorId,A.WorkNo |
|
|
|
|
C.StaffId SponsorId,A.WorkNo,A.WorkID |
|
|
|
|
FROM [120.26.205.42].[GhrUshio].[dbo].Ushio_TrainTeacher A |
|
|
|
|
LEFT JOIN Ghro_Dept B ON A.DeptNo = B.DeptNo |
|
|
|
|
LEFT JOIN Ghra_Staff C ON A.TeacherNo = C.StaffNo |
|
|
|
|
LEFT JOIN Ghra_Staff D ON A.ApplyStaffNo = D.StaffNo |
|
|
|
|
WHERE WorkNo NOT IN (SELECT WorkNo |
|
|
|
|
FROM Ghre_Teacher |
|
|
|
|
WHERE WorkNo IS NOT NULL)";
|
|
|
|
|
WHERE WorkNo IS NOT NULL AND IsEnable=1)";
|
|
|
|
|
|
|
|
|
|
var dt = await Db.Ado.GetDataTableAsync(sql); |
|
|
|
|
|
|
|
|
@ -633,15 +637,95 @@ FROM (SELECT A.*, |
|
|
|
|
|
|
|
|
|
if (await base.AnyAsync(x => x.WorkNo == insert.WorkNo)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
//Advanced |
|
|
|
|
if (insert.SchoolId == 0) insert.SchoolId = null; |
|
|
|
|
var photoUrl = $"/files/upload/{DateTimeHelper.ConvertToSecondString1(DateTime.Now)}.png"; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
await _httpPollyHelper.DownLoad("http://120.26.205.42:3002" + insert.PhotoUrl, photoUrl); |
|
|
|
|
} |
|
|
|
|
catch (Exception) |
|
|
|
|
{ |
|
|
|
|
photoUrl = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var workId = insert.WorkID; |
|
|
|
|
|
|
|
|
|
insert.PhotoUrl = "/Advanced" + photoUrl; |
|
|
|
|
insert.Status = "Wait"; |
|
|
|
|
insert.WorkID = null; |
|
|
|
|
var id = await base.Add(insert); |
|
|
|
|
|
|
|
|
|
sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_Teacher WHERE Id !='{id}'"; |
|
|
|
|
var id1 = await Db.Ado.GetLongAsync(sql); |
|
|
|
|
sql = $"UPDATE Ghre_Teacher SET Id={id1} WHERE Id ='{id}'"; |
|
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
|
|
|
|
|
#region 同步证件 |
|
|
|
|
sql = $@"SELECT CertificateNo,
|
|
|
|
|
CertificateName, |
|
|
|
|
EffectiveDate, |
|
|
|
|
ExpirationDate, |
|
|
|
|
TeacherAttachmentID |
|
|
|
|
FROM [120.26.205.42].[GhrUshio].[dbo].Ushio_TeacherAttachment |
|
|
|
|
WHERE WorkID = {workId}";
|
|
|
|
|
dt = await Db.Ado.GetDataTableAsync(sql); |
|
|
|
|
var attachments = Db.Utilities.DataTableToList<InsertGhre_TeacherAttachmentInput>(dt); |
|
|
|
|
Log.Information($"【牛尾培训讲师同步】查询到【{attachments.Count}】笔证件数据"); |
|
|
|
|
|
|
|
|
|
if (attachments.Any()) |
|
|
|
|
{ |
|
|
|
|
for (int j = 0; j < attachments.Count; j++) |
|
|
|
|
{ |
|
|
|
|
attachments[j].TeacherId = id1; |
|
|
|
|
var attachmentId = await _ghre_TeacherAttachmentServices.Add(attachments[j]); |
|
|
|
|
|
|
|
|
|
sql = @$"SELECT AttachmentNo,
|
|
|
|
|
AttachmentName, |
|
|
|
|
AttachmentName AttachFileName, |
|
|
|
|
AttachFileSize, |
|
|
|
|
FileUrl PhysicsPath, |
|
|
|
|
AttachFileExtension |
|
|
|
|
FROM [120.26.205.42].[GhrUshio].[dbo].Ghrs_Attachment |
|
|
|
|
WHERE EnableYN = 'Y' |
|
|
|
|
AND Reverse1 = 'Ghre_TeacherAttachment' |
|
|
|
|
AND ReverseN1 = {attachments[j].TeacherAttachmentID}";
|
|
|
|
|
|
|
|
|
|
dt = await Db.Ado.GetDataTableAsync(sql); |
|
|
|
|
var attachments1 = Db.Utilities.DataTableToList<InsertGhre_AttachmentInput>(dt); |
|
|
|
|
if (attachments1.Any()) |
|
|
|
|
{ |
|
|
|
|
for (int m = 0; m < attachments1.Count; m++) |
|
|
|
|
{ |
|
|
|
|
attachments1[m].TableName = attachmentId.ObjToString(); |
|
|
|
|
|
|
|
|
|
photoUrl = $"/files/upload/{DateTimeHelper.ConvertToSecondString1(DateTime.Now)}.png"; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
await _httpPollyHelper.DownLoad(attachments1[m].PhysicsPath, photoUrl); |
|
|
|
|
attachments1[m].PhysicsPath = photoUrl; |
|
|
|
|
attachments1[m].RelativePath = photoUrl; |
|
|
|
|
attachments1[m].ThumbnailPath = photoUrl; |
|
|
|
|
attachments1[m].FileURL = photoUrl; |
|
|
|
|
await _ghre_AttachmentServices.Add(attachments1); |
|
|
|
|
} |
|
|
|
|
catch (Exception) |
|
|
|
|
{ |
|
|
|
|
photoUrl = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception E) |
|
|
|
|