fix 处理同步gainfo

This commit is contained in:
2024-02-21 19:27:39 +08:00
parent 36824f0f57
commit 322430da70

View File

@@ -6,6 +6,7 @@ using Dlhis.ScheduledTask.SyncSapInfo.Dto;
using Dlhis.ScheduledTask.SyncSapInfo.Comparers;
using Dlhis.ScheduledTask.SyncSapInfo.Services;
using Kurisu.AspNetCore.Scope;
using Dlhis.Entity.Basic.Enums;
namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
@@ -113,34 +114,41 @@ public class SyncPersonJob
private void InsertPerson(IDbContext db, GainfoSapEntity item)
{
//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,
//};
db.Client.Insertable(item).ExecuteCommand();
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,
DepartmentNo = item.appellation,
Nation = item.nation,
Phone = item.phone,
Degree = item.email,
Position = item.web,
Remark = item.remark,
Werks = item.WERKS,
Employed = item.isowner,
};
if (item.isowner == "T")
{
db.Client.Insertable(info).ExecuteCommand();
}
else
{
db.Client.Insertable(info).AS("GainfoLeave").ExecuteCommand();
}
}
private void UpdatePerson(IDbContext db, GainfoSapEntity item)
{
@@ -149,7 +157,6 @@ public class SyncPersonJob
{
PERNR = item.PERNR,
gname = item.gname,
ename = item.ename,
web = item.web,
phone = item.phone,
appellation = item.appellation,
@@ -160,6 +167,29 @@ public class SyncPersonJob
})
.Where(x => x.ename == item.ename)
.ExecuteCommand();
var gainfo = db.Queryable<GainfoEntity>().Where(x => x.Code == item.ename).First();
if (item.isowner == "T")
{
db.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
{
SapNo = item.PERNR,
Name = item.gname,
Position = item.web,
Phone = item.phone,
DepartmentNo = item.appellation,
Remark = item.remark,
Degree = item.email,
Werks = item.WERKS
})
.Where(x => x.Code == item.ename)
.ExecuteCommand();
}
else
{
db.Client.Deleteable(gainfo).ExecuteCommand();
db.Client.Insertable(gainfo).AS("GainfoLeave").ExecuteCommand();
}
}
private List<SapPersonItem> GetModifiedPerson(IDbContext db, List<SapPersonItem> sapList)