Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development
This commit is contained in:
@@ -21,7 +21,8 @@ public class DepartmentService : IDepartmentService
|
||||
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
||||
{
|
||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
||||
var tops = departments.Where(x => x.PNo.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
|
||||
//00001000 一定是这个开头的
|
||||
var tops = departments.Where(x => x.PNo == "00001000").Adapt<List<DepartmentTreeResponse>>();
|
||||
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
@@ -35,7 +36,7 @@ public class DepartmentService : IDepartmentService
|
||||
{
|
||||
var departments = await _dbContext
|
||||
.Queryable<DepartmentEntity>()
|
||||
.WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search) || x.No.Contains(request.Search)).ToListAsync();
|
||||
.WhereIF(!request.Search.IsEmpty(), x => x.Name.Contains(request.Search) || x.No.Contains(request.Search)).ToListAsync();
|
||||
|
||||
var tops = departments.Where(x => x.PNo.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@ public class JobPack : BaseAppPack
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateSyncServerDateTimeJob>("SyncServerDateTime", s => s.RunAsync(), "0 0 0/1 * * ?", new RecurringJobOptions
|
||||
RecurringJob.AddOrUpdate<SyncPersonJob>("SyncPerson", s => s.RunAsync(), "0 0 3 * * ?", new RecurringJobOptions
|
||||
{
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateSyncServerDateTimeJob>("SyncServerDateTime", s => s.RunAsync(), "0 0 0/1 * * ?", new RecurringJobOptions
|
||||
{
|
||||
TimeZone = TimeZoneInfo.Local
|
||||
});
|
||||
|
||||
RecurringJob.AddOrUpdate<CreateGetAttendanceJob>("CreateGetAttendance", s => s.RunAsync(), "0 0/1 * * * ?", new RecurringJobOptions
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SapPositionComparer : IEqualityComparer<SapPositionItem>
|
||||
&& x.ENDDA == y.ENDDA
|
||||
&& x.LANGU == y.LANGU
|
||||
&& x.ZJOBID == y.ZJOBID
|
||||
&& x.ZJOBANME == y.ZJOBANME
|
||||
&& x.ZJOBNAME == y.ZJOBNAME
|
||||
&& x.ZZWID == y.ZZWID
|
||||
&& x.ZDEPID == y.ZDEPID;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class SapPositionComparer : IEqualityComparer<SapPositionItem>
|
||||
{
|
||||
return obj.BEGDA.SafeGetHashCode() ^ obj.ENDDA.SafeGetHashCode()
|
||||
^ obj.LANGU.SafeGetHashCode() ^ obj.ZJOBID.SafeGetHashCode()
|
||||
^ obj.ZJOBANME.SafeGetHashCode() ^ obj.ZZWID.SafeGetHashCode()
|
||||
^ obj.ZJOBNAME.SafeGetHashCode() ^ obj.ZZWID.SafeGetHashCode()
|
||||
^ obj.ZDEPID.SafeGetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SapOrganizationItem
|
||||
/// <summary>
|
||||
/// 语言
|
||||
/// </summary>
|
||||
public int LANGU { get; set; }
|
||||
public string LANGU { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门id
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/// <summary>
|
||||
/// 语言代码
|
||||
/// </summary>
|
||||
public int LANGU { get; set; }
|
||||
public string LANGU { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 岗位编码
|
||||
@@ -25,7 +25,7 @@
|
||||
/// <summary>
|
||||
/// 岗位名称
|
||||
/// </summary>
|
||||
public string ZJOBANME { get; set; }
|
||||
public string ZJOBNAME { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Comparers;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Services;
|
||||
using Hangfire;
|
||||
@@ -12,7 +11,6 @@ namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
|
||||
/// </summary>
|
||||
public class SyncOrganizationJob
|
||||
{
|
||||
private List<SapOrganizationItem> lastUpdatedOrgList = new();
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
|
||||
@@ -28,29 +26,15 @@ public class SyncOrganizationJob
|
||||
|
||||
if (orgResult.Org != null && orgResult.Org.Items.Count > 0)
|
||||
{
|
||||
var modifiedOrgList = GetModifiedOrg(orgResult.Org?.Items);
|
||||
await SaveOrg(modifiedOrgList);
|
||||
await SaveOrg(orgResult.Org.Items);
|
||||
}
|
||||
|
||||
var syncPositionJob = BackgroundJob.ContinueJobWith<SyncPositionJob>("SyncOrganizationJob", job => job.SyncPositionInfo(), JobContinuationOptions.OnlyOnSucceededState);
|
||||
BackgroundJob.ContinueJobWith<SyncPersonJob>(syncPositionJob, job => job.SyncPersonInfo(), JobContinuationOptions.OnlyOnSucceededState);
|
||||
}
|
||||
|
||||
private List<SapOrganizationItem> GetModifiedOrg(List<SapOrganizationItem> sapList)
|
||||
{
|
||||
if (lastUpdatedOrgList.Count <= 0)
|
||||
{
|
||||
return sapList;
|
||||
}
|
||||
|
||||
var needRemove = sapList.Intersect(lastUpdatedOrgList, new SapOrganizationComparer());
|
||||
return sapList.Except(needRemove, new SapOrganizationComparer()).ToList();
|
||||
var syncPositionJob = BackgroundJob.Enqueue<SyncPositionJob>(job => job.SyncPositionInfo());
|
||||
BackgroundJob.ContinueJobWith<SyncPersonJob>(syncPositionJob, job => job.RunAsync(), JobContinuationOptions.OnlyOnSucceededState);
|
||||
}
|
||||
|
||||
private async Task SaveOrg(List<SapOrganizationItem> modifiedOrgList)
|
||||
{
|
||||
if (modifiedOrgList == null || modifiedOrgList.Count == 0) return;
|
||||
|
||||
foreach (SapOrganizationItem item in modifiedOrgList)
|
||||
{
|
||||
var department = await _dbContext.Queryable<DepartmentEntity>().Where(x => x.No == item.OBJID).FirstAsync();
|
||||
|
||||
@@ -14,21 +14,23 @@ public class SyncPersonJob
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private List<PositionEntity> _positions;
|
||||
|
||||
public SyncPersonJob(IDbContext dbContext, ILogger logger, IJinkoSapService jinkoSapService)
|
||||
public SyncPersonJob(IDbContext dbContext, ILogger<SyncPersonJob> logger, IJinkoSapService jinkoSapService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_logger = logger;
|
||||
_jinkoSapService = jinkoSapService;
|
||||
}
|
||||
|
||||
public async Task SyncPersonInfo()
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var personResp = await _jinkoSapService.GetPersonsAsync();
|
||||
var persons = personResp.Person.Items;
|
||||
|
||||
if (persons.Count > 0)
|
||||
{
|
||||
_positions = await _dbContext.Queryable<PositionEntity>().ToListAsync();
|
||||
var modifiedPersons = await GetModifiedPersonAsync(persons.OrderByDescending(x => x.ZSTATUS).ThenBy(x => x.ZRZRQ).ToList());
|
||||
if (modifiedPersons.Count > 0)
|
||||
{
|
||||
@@ -39,173 +41,110 @@ public class SyncPersonJob
|
||||
|
||||
private async Task<int> SavePerson(List<SapPersonItem> persons)
|
||||
{
|
||||
|
||||
var failure = 0;
|
||||
var workCodes = persons.Select(x => x.ZWORKCODE).ToList();
|
||||
|
||||
var index = 1;
|
||||
var count = 4000;
|
||||
var failure = 0;
|
||||
var total = persons.Count;
|
||||
|
||||
var searchCodes = workCodes.Skip((index - 1) * count).Take(count).ToList();
|
||||
while (searchCodes.Count > 0)
|
||||
foreach (var searchCodes in workCodes.Chunk(4000))
|
||||
{
|
||||
var existsWorkCodes = _dbContext.Queryable<GainfoEntity>()
|
||||
var existsWorkCodes = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => searchCodes.Contains(x.Code))
|
||||
.Select(x => x.Code)
|
||||
.ToList();
|
||||
.ToListAsync();
|
||||
|
||||
var originUpdates = persons.Where(x => existsWorkCodes.Contains(x.ZWORKCODE)).ToList();
|
||||
var originInserts = persons.Where(x => searchCodes.Contains(x.ZWORKCODE)).Except(originUpdates, new SapPersonComparer()).ToList();
|
||||
|
||||
int i = 0;
|
||||
if (originUpdates.Count + originInserts.Count <= count)
|
||||
var currentTotal = originUpdates.Count + originInserts.Count;
|
||||
|
||||
var updates = ToGainfoSap(originUpdates);
|
||||
var inserts = ToGainfoSap(originInserts);
|
||||
|
||||
foreach (var item in inserts)
|
||||
{
|
||||
var currentTotal = originUpdates.Count + originInserts.Count;
|
||||
|
||||
var updates = ToGainfoSap(originUpdates);
|
||||
var inserts = ToGainfoSap(originInserts);
|
||||
|
||||
foreach (var item in inserts)
|
||||
i++;
|
||||
try
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
await SavePerson(item);
|
||||
//conn.Execute(SqlGeneration.InsertSql, item);
|
||||
//log.Debug($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
}
|
||||
|
||||
await SavePerson(item);
|
||||
//conn.Execute(SqlGeneration.InsertSql, item);
|
||||
//log.Debug($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行新增{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
}
|
||||
|
||||
foreach (var item in updates)
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
await UpdatePerson(item);
|
||||
//conn.Execute(SqlGeneration.UpdateSql, item);
|
||||
//log.Debug($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
persons = persons.Except(originUpdates).Except(originUpdates).ToList();
|
||||
searchCodes = workCodes.Skip((index - 1) * count).Take(count).ToList();
|
||||
foreach (var item in updates)
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
await UpdatePerson(item);
|
||||
//conn.Execute(SqlGeneration.UpdateSql, item);
|
||||
//log.Debug($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failure++;
|
||||
//log.Error($"执行更新{i}/{currentTotal} name:{item.gname},ename:{item.ename}失败 \r\n{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return failure;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async Task SavePerson(GainfoSapEntity item)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
|
||||
if (gainfo != null)
|
||||
var info = new GainfoEntity
|
||||
{
|
||||
gainfo.No = item.guestno;
|
||||
gainfo.SapNo = item.ano;
|
||||
gainfo.Type = item.@class;
|
||||
gainfo.Name = item.gname;
|
||||
gainfo.Code = item.ename;
|
||||
gainfo.CountryNo = item.country;
|
||||
gainfo.IdClass = item.idcls;
|
||||
gainfo.Native = item.native;
|
||||
gainfo.Gender = item.sex == "F" ? GenderEnumType.Female : GenderEnumType.Male;
|
||||
gainfo.Birthday = (DateTime)item.birthday;
|
||||
gainfo.Address = item.address;
|
||||
gainfo.DepartmentNo = item.appellation;
|
||||
gainfo.Nation = item.nation;
|
||||
gainfo.Phone = item.phone;
|
||||
gainfo.Degree = item.email;
|
||||
gainfo.Position = item.web;
|
||||
gainfo.Remark = item.remark;
|
||||
gainfo.Werks = item.WERKS;
|
||||
gainfo.Employed = item.isowner; //int.Parse(person.ZSTATUS) < 4 ? "T" : "F", 是否离职
|
||||
await _dbContext.UpdateAsync(gainfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = new GainfoEntity
|
||||
{
|
||||
No = item.guestno,
|
||||
SapNo = item.ano,
|
||||
Type = item.@class,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
CountryNo = item.country,
|
||||
IdClass = item.idcls,
|
||||
IdNo = item.idno,
|
||||
Native = item.native,
|
||||
Gender = item.sex == "F" ? GenderEnumType.Female : GenderEnumType.Male,
|
||||
Birthday = (DateTime)item.birthday,
|
||||
Address = item.address,
|
||||
//Marital 已婚未婚
|
||||
//Occuption = item.occuption,
|
||||
DepartmentNo = item.appellation,
|
||||
Nation = item.nation,
|
||||
Phone = item.phone,
|
||||
Degree = item.email,
|
||||
Position = item.web,
|
||||
//CarNo
|
||||
Remark = item.remark,
|
||||
Werks = item.WERKS,
|
||||
Employed = item.isowner,
|
||||
};
|
||||
await _dbContext.InsertAsync(info);
|
||||
}
|
||||
No = item.guestno,
|
||||
SapNo = item.ano,
|
||||
Type = item.@class,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
CountryNo = item.country,
|
||||
IdClass = item.idcls,
|
||||
IdNo = item.idno,
|
||||
Native = item.native,
|
||||
Gender = item.sex == "F" ? GenderEnumType.Female : GenderEnumType.Male,
|
||||
Birthday = (DateTime)item.birthday,
|
||||
Address = item.address,
|
||||
//Marital 已婚未婚
|
||||
//Occuption = item.occuption,
|
||||
DepartmentNo = item.appellation,
|
||||
Nation = item.nation,
|
||||
Phone = item.phone,
|
||||
Degree = item.email,
|
||||
Position = item.web,
|
||||
//CarNo
|
||||
Remark = item.remark,
|
||||
Werks = item.WERKS,
|
||||
Employed = item.isowner,
|
||||
};
|
||||
await _dbContext.InsertAsync(info);
|
||||
}
|
||||
private async Task UpdatePerson(GainfoSapEntity item)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
|
||||
if (gainfo != null)
|
||||
await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
|
||||
{
|
||||
_dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
|
||||
{
|
||||
SapNo = item.PERNR,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
Position = item.web,
|
||||
Phone = item.phone,
|
||||
DepartmentNo = item.appellation,
|
||||
Employed = item.isowner,
|
||||
Remark = item.remark,
|
||||
Degree = item.email,
|
||||
Werks = item.WERKS
|
||||
})
|
||||
.Where(g => g.IdNo == item.idno
|
||||
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && g.SapNo != item.PERNR && g.Employed == "T")
|
||||
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
|
||||
}
|
||||
else
|
||||
{
|
||||
_dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
|
||||
{
|
||||
SapNo = item.PERNR,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
Position = item.web,
|
||||
Phone = item.phone,
|
||||
DepartmentNo = item.appellation,
|
||||
Employed = item.isowner,
|
||||
Remark = item.remark,
|
||||
Degree = item.email,
|
||||
Werks = item.WERKS
|
||||
})
|
||||
.Where(g => g.SapNo == item.PERNR
|
||||
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.Code == item.ename && g.Employed == "T")
|
||||
&& !_dbContext.Queryable<GainfoEntity>().Any(g => g.IdNo == item.idno && int.Parse(g.SapNo) > int.Parse(item.PERNR) && g.Employed == item.isowner));
|
||||
}
|
||||
SapNo = item.PERNR,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
Position = item.web,
|
||||
Phone = item.phone,
|
||||
DepartmentNo = item.appellation,
|
||||
Employed = item.isowner,
|
||||
Remark = item.remark,
|
||||
Degree = item.email,
|
||||
Werks = item.WERKS
|
||||
})
|
||||
.Where(x => x.Code == item.ename)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
private async Task<List<SapPersonItem>> GetModifiedPersonAsync(List<SapPersonItem> sapList)
|
||||
@@ -259,7 +198,7 @@ public class SyncPersonJob
|
||||
GainfoSapEntity o = null;
|
||||
try
|
||||
{
|
||||
var position = string.Empty; //lastUpdatedPositionList.FirstOrDefault(x => x.ZJOBID == person.PLANS);
|
||||
var position = _positions.FirstOrDefault(x => x.No == person.PLANS);
|
||||
|
||||
var rzrq = SafeParseDate(person.ZRZRQ);
|
||||
var lzrq = SafeParseDate(person.ZLZRQ);
|
||||
@@ -302,7 +241,7 @@ public class SyncPersonJob
|
||||
remark = rmk,
|
||||
native = native,
|
||||
sex = sex,
|
||||
//web = SubString(position?.ZJOBANME, 30), todo
|
||||
web = SubString(position?.Name ?? "", 30),
|
||||
logdate = DateTime.Now,
|
||||
isowner = int.Parse(person.ZSTATUS) < 4 ? "T" : "F",
|
||||
@class = "C",
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Comparers;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Dto;
|
||||
using Dlhis.ScheduledTask.SyncSapInfo.Services;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
|
||||
|
||||
@@ -12,7 +10,6 @@ namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
|
||||
/// </summary>
|
||||
public class SyncPositionJob
|
||||
{
|
||||
private List<SapPositionItem> lastUpdatedPositionList = new List<SapPositionItem>();
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
|
||||
@@ -28,28 +25,12 @@ public class SyncPositionJob
|
||||
|
||||
if (positionResult.Position != null && positionResult.Position.Items.Count > 0)
|
||||
{
|
||||
var modifiedOrgList = GetModifiedPosition(positionResult.Position.Items);
|
||||
await SaveOrg(modifiedOrgList);
|
||||
await SaveOrg(positionResult.Position.Items);
|
||||
}
|
||||
}
|
||||
|
||||
private List<SapPositionItem> GetModifiedPosition(List<SapPositionItem> spaList)
|
||||
{
|
||||
if (lastUpdatedPositionList.Count <= 0)
|
||||
{
|
||||
return spaList;
|
||||
}
|
||||
var needRemove = spaList.Intersect(lastUpdatedPositionList, new SapPositionComparer());
|
||||
return spaList.Except(needRemove, new SapPositionComparer()).ToList();
|
||||
}
|
||||
|
||||
private async Task SaveOrg(List<SapPositionItem> modifiedPostList)
|
||||
{
|
||||
if (modifiedPostList == null || modifiedPostList.Count == 0) return;
|
||||
|
||||
var addItems = new List<PositionEntity>();
|
||||
var updateItems = new List<PositionEntity>();
|
||||
|
||||
foreach (var item in modifiedPostList)
|
||||
{
|
||||
var position = await _dbContext.Queryable<PositionEntity>().Where(x => x.No == item.ZJOBID).FirstAsync();
|
||||
@@ -57,25 +38,22 @@ public class SyncPositionJob
|
||||
{
|
||||
position = new PositionEntity
|
||||
{
|
||||
No = item.ZJOBANME,
|
||||
Name = item.ZJOBANME,
|
||||
No = item.ZDEPID,
|
||||
Name = item.ZJOBNAME,
|
||||
DepartmentNo = item.ZDEPID,
|
||||
Grade = item.ZZWID
|
||||
};
|
||||
|
||||
addItems.Add(position);
|
||||
await _dbContext.InsertAsync(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
position.Name = item.ZJOBANME;
|
||||
position.Name = item.ZJOBNAME;
|
||||
position.DepartmentNo = item.ZDEPID;
|
||||
position.Grade = item.ZZWID;
|
||||
|
||||
updateItems.Add(position);
|
||||
await _dbContext.UpdateAsync(position);
|
||||
}
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(addItems);
|
||||
await _dbContext.UpdateAsync(updateItems);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ public class JinkoSapService : IJinkoSapService
|
||||
private HttpClient GetHttpClient()
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient("jinko:sap");
|
||||
//http://sappidap.jinkosolar.cn:51000
|
||||
httpClient.BaseAddress = new Uri("http://sappipap01.jinkosolar.cn:50100");
|
||||
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
||||
|
||||
var credentials = string.Format("{0}:{1}", "EHS_USER", "y3R1hd2h*RICAC");
|
||||
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
|
||||
@@ -87,14 +87,13 @@ public class JinkoSapService : IJinkoSapService
|
||||
T_PERSON = Array.Empty<string>(),
|
||||
T_PNO = Array.Empty<string>(),
|
||||
};
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
var response = await GetHttpClient().PostAsync(apiUrl, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
var personResp = JsonConvert.DeserializeObject<SapPersonResponse>(jsonResponse);
|
||||
if (personResp?.Person?.Items?.Any() == true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user