fix 人员同步,下发任务创建
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Response\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
14
Src/Dlhis.Basic.Api/Dtos/PermissionUsersInfoDto.cs
Normal file
14
Src/Dlhis.Basic.Api/Dtos/PermissionUsersInfoDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Dlhis.Basic.Api.Dtos;
|
||||
|
||||
public class PermissionUsersInfoDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 拥有权限的用户
|
||||
/// </summary>
|
||||
public List<string> UserNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户对应的 [ 厂区--设备Code ]
|
||||
/// </summary>
|
||||
public Dictionary<string, List<UserTenantDeviceCodeDto>> PermissionInfos { get; set; }
|
||||
}
|
||||
14
Src/Dlhis.Basic.Api/Dtos/UserTenantDeviceCodeDto.cs
Normal file
14
Src/Dlhis.Basic.Api/Dtos/UserTenantDeviceCodeDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Dlhis.Basic.Api.Dtos;
|
||||
|
||||
public class UserTenantDeviceCodeDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 租户
|
||||
/// </summary>
|
||||
public string Tenant { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备权限
|
||||
/// </summary>
|
||||
public List<Guid> Codes { get; set; }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Kurisu.Core.Result;
|
||||
using Dlhis.Basic.Api.Dtos;
|
||||
using Kurisu.Core.Result;
|
||||
using Kurisu.RemoteCall.Attributes;
|
||||
|
||||
namespace Dlhis.Basic.Api;
|
||||
@@ -9,4 +10,20 @@ public interface IDevicePermissionApi
|
||||
[Auth]
|
||||
[Get("/api/devicepermissions/canteen/uniqueNos")]
|
||||
Task<DefaultApiResult<List<string>>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有人的权限信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Get("/api/devicepermissions/all-permission")]
|
||||
Task<DefaultApiResult<PermissionUsersInfoDto>> GetPermissionUsersInfoAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 重新生成权限
|
||||
/// </summary>
|
||||
/// <param name="beforeDto"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/api/devicepermissions/re-permission")]
|
||||
Task<DefaultApiResult<int>> RePermissionUsersInfoAsync(PermissionUsersInfoDto beforeDto);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Dtos;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
@@ -57,7 +58,7 @@ public class DevicePermissionsController : ControllerBase
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 就餐设备唯一号权限
|
||||
/// 获取就餐设备唯一号权限
|
||||
/// </summary>
|
||||
/// <param name="userNo"></param>
|
||||
/// <returns></returns>
|
||||
@@ -67,4 +68,20 @@ public class DevicePermissionsController : ControllerBase
|
||||
{
|
||||
return await _devicePermissionService.GetCanteenDeviceUniqueNosByUserNoAsync(userNo);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("all-permission")]
|
||||
[IgnoreTenant]
|
||||
public async Task<PermissionUsersInfoDto> GetPermissionUsersInfoAsync()
|
||||
{
|
||||
return await _devicePermissionService.GetPermissionUsersInfoAsync();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[IgnoreTenant]
|
||||
[HttpPost("re-permission")]
|
||||
public async Task<int> ReGeneratePermissionUsersInfoAsync(PermissionUsersInfoDto beforeDto)
|
||||
{
|
||||
return await _devicePermissionService.ReGeneratePermissionUsersInfoAsync(beforeDto);
|
||||
}
|
||||
}
|
||||
|
||||
15
Src/Dlhis.Basic/Device/Dtos/PermissionUsersInfoDto.cs
Normal file
15
Src/Dlhis.Basic/Device/Dtos/PermissionUsersInfoDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Dlhis.Basic.Device.Dtos
|
||||
{
|
||||
public class PermissionUsersInfoDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 拥有权限的用户
|
||||
/// </summary>
|
||||
public List<string> UserNos { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户对应的 [ 厂区--设备Code ]
|
||||
/// </summary>
|
||||
public Dictionary<string, List<UserTenantDeviceCodeDto>> PermissionInfos { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Dtos;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
@@ -64,4 +65,11 @@ public interface IDevicePermissionService : IScopeDependency
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task<Pagination<AssigmentByCodeResponse>> GetAssigmentByCodeAsync(AssigmentByCodeRequest request);
|
||||
|
||||
|
||||
|
||||
Task<PermissionUsersInfoDto> GetPermissionUsersInfoAsync();
|
||||
|
||||
|
||||
Task<int> ReGeneratePermissionUsersInfoAsync(PermissionUsersInfoDto beforeDto);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,97 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PermissionUsersInfoDto> GetPermissionUsersInfoAsync()
|
||||
{
|
||||
//获取所有人的权限
|
||||
var userNos = await GetPermissionUserNosAsync();
|
||||
var permissions = await GetAssignDeviceCodesInternalAsync(userNos);
|
||||
|
||||
return new PermissionUsersInfoDto
|
||||
{
|
||||
UserNos = userNos,
|
||||
PermissionInfos = permissions
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public async Task<int> ReGeneratePermissionUsersInfoAsync(PermissionUsersInfoDto beforeDto)
|
||||
{
|
||||
var userNos = beforeDto.UserNos;
|
||||
var before = beforeDto.PermissionInfos.ToDictionary(x => x.Key, x => x.Value, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
//获取业务处理后所有人的权限
|
||||
var nextUserNos = await GetPermissionUserNosAsync();
|
||||
if (nextUserNos.Any())
|
||||
userNos = userNos.Concat(nextUserNos).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
||||
|
||||
var current = await GetAssignDeviceCodesInternalAsync(userNos);
|
||||
|
||||
var deivces = await _dbContext.Queryable<DeviceEntity>().ToListAsync();
|
||||
var waitTasks = new List<DeviceTaskEntity>();
|
||||
|
||||
foreach (var userNo in userNos)
|
||||
{
|
||||
before.TryGetValue(userNo, out var beforeTenantDeviceCodes);
|
||||
beforeTenantDeviceCodes ??= new();
|
||||
|
||||
current.TryGetValue(userNo, out var currentTenantDeviceCodes);
|
||||
currentTenantDeviceCodes ??= new();
|
||||
|
||||
var tenants = beforeTenantDeviceCodes.Select(x => x.Tenant).Concat(currentTenantDeviceCodes.Select(x => x.Tenant)).Distinct().ToList();
|
||||
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
var currentCodes = currentTenantDeviceCodes.FirstOrDefault(x => x.Tenant == tenant)?.Codes ?? new();
|
||||
var beforeCodes = beforeTenantDeviceCodes.FirstOrDefault(x => x.Tenant == tenant)?.Codes ?? new();
|
||||
|
||||
//被删除
|
||||
var deletedItems = beforeCodes.Where(x => !currentCodes.Contains(x)).ToList();
|
||||
//新增
|
||||
var addItems = currentCodes.Where(x => !beforeCodes.Contains(x)).ToList();
|
||||
|
||||
if (!deletedItems.Any() && !addItems.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var deviceCodes = deivces.Where(x => deletedItems.Contains(x.Code) || addItems.Contains(x.Code)).Select(x => x.Code).ToList();
|
||||
deletedItems = deletedItems.Where(x => deviceCodes.Contains(x)).ToList();
|
||||
addItems = addItems.Where(x => deviceCodes.Contains(x)).ToList();
|
||||
|
||||
//下发任务创建
|
||||
var toDeleted = deletedItems.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
DeviceUniqueNo = deivces.First(item => item.Code == x).UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
Type = DeviceTaskEnumType.Delete,
|
||||
UserNo = userNo,
|
||||
Version = 0,
|
||||
TenantId = tenant,
|
||||
}).ToList();
|
||||
|
||||
var toAdd = addItems.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
DeviceUniqueNo = deivces.First(item => item.Code == x).UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
Type = DeviceTaskEnumType.Add,
|
||||
UserNo = userNo,
|
||||
Version = 0,
|
||||
TenantId = tenant,
|
||||
}).ToList();
|
||||
|
||||
waitTasks.AddRange(toDeleted.Concat(toAdd).ToList());
|
||||
}
|
||||
}
|
||||
|
||||
if (waitTasks.Any())
|
||||
{
|
||||
await _dbContext.InsertAsync(waitTasks);
|
||||
}
|
||||
|
||||
return waitTasks.Count;
|
||||
}
|
||||
|
||||
public async Task GenerateDeviceTasksAsync(string userNo, DeviceTaskEnumType taskType)
|
||||
{
|
||||
var deviceCodes = await GetAssignDeviceCodesAsync(userNo);
|
||||
@@ -193,7 +284,6 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<string>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo)
|
||||
{
|
||||
var all = await GetAssignDeviceCodesAsync(userNo);
|
||||
@@ -305,40 +395,6 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
return userNos.Concat(userNosByGroup).Concat(userNosByDepartment).Concat(userNosByWerk).Distinct().ToList();
|
||||
}
|
||||
|
||||
|
||||
private static List<Guid> GetAssignmentsInternal(
|
||||
List<DevicePermissionEntity> devicePermissions, List<DeviceGroupEntity> deviceGroups,
|
||||
DeviceAssignmentTypeEnumType uniqueType, AssignTypeEnumType assignType, string assignValue)
|
||||
{
|
||||
var devicePermissionCodes = devicePermissions
|
||||
.Where(x => x.UniqueType == uniqueType)
|
||||
.Where(x => x.AssignType == assignType)
|
||||
.Where(x => x.AssignValue == assignValue)
|
||||
.Select(x => x.UniqueValue).ToList();
|
||||
|
||||
//处理获取设备组的情况,递归到最下级获取设备code
|
||||
if (uniqueType == DeviceAssignmentTypeEnumType.Group)
|
||||
{
|
||||
var tops = deviceGroups.Where(x => !x.PCode.HasValue).ToList();
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
RecursionGetNext(x, deviceGroups, devicePermissionCodes, devicePermissionCodes.Contains(x.Code));
|
||||
});
|
||||
}
|
||||
|
||||
return devicePermissionCodes.Distinct().ToList();
|
||||
|
||||
void RecursionGetNext(DeviceGroupEntity current, List<DeviceGroupEntity> deviceGroups, List<Guid> result, bool add)
|
||||
{
|
||||
var next = deviceGroups.Where(x => x.PCode == current.Code).ToList();
|
||||
foreach (var item in next)
|
||||
{
|
||||
if (add) result.Add(item.Code);
|
||||
RecursionGetNext(item, deviceGroups, result, result.Contains(item.Code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<UserTenantDeviceCodeDto> GetAssignCodesInternal(
|
||||
List<DevicePermissionEntity> devicePermissions, List<DeviceGroupEntity> deviceGroups,
|
||||
DeviceAssignmentTypeEnumType uniqueType, AssignTypeEnumType assignType, string assignValue)
|
||||
@@ -400,7 +456,7 @@ public class DevicePermissionService : IDevicePermissionService
|
||||
var deviceGroups = await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync();
|
||||
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>().ToListAsync();
|
||||
|
||||
var result = new Dictionary<string, List<UserTenantDeviceCodeDto>>(gainfos.Count);
|
||||
var result = new Dictionary<string, List<UserTenantDeviceCodeDto>>(gainfos.Count, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var gainfo in gainfos)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
@@ -17,10 +18,12 @@ namespace Dlhis.ScheduledTask.DeviceUploadLog.Controllers;
|
||||
public class DeviceUploadLogsController : ControllerBase
|
||||
{
|
||||
private readonly IDeviceUploadLogService _deviceUploadLogService;
|
||||
private readonly IDevicePermissionApi _devicePermissionApi;
|
||||
|
||||
public DeviceUploadLogsController(IDeviceUploadLogService deviceUploadLogService)
|
||||
public DeviceUploadLogsController(IDeviceUploadLogService deviceUploadLogService, IDevicePermissionApi devicePermissionApi)
|
||||
{
|
||||
_deviceUploadLogService = deviceUploadLogService;
|
||||
_devicePermissionApi = devicePermissionApi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,4 +60,15 @@ public class DeviceUploadLogsController : ControllerBase
|
||||
{
|
||||
await _deviceUploadLogService.SetUploadLogsBeginDateTimeAsync(requests);
|
||||
}
|
||||
|
||||
//[HttpPost("try")]
|
||||
//public async Task<int> Test()
|
||||
//{
|
||||
// var dtoResult = await _devicePermissionApi.GetPermissionUsersInfoAsync();
|
||||
// var dto = dtoResult.Data;
|
||||
// var rResult = await _devicePermissionApi.RePermissionUsersInfoAsync(dto);
|
||||
// var r = rResult.Data;
|
||||
|
||||
// return r;
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.3" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.7.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -7,6 +7,7 @@ EXPOSE 80
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj", "Src/Dlhis.ScheduledTask/"]
|
||||
COPY ["Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj", "Src/Dlhis.Basic.Api/"]
|
||||
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
|
||||
COPY ["Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj", "Src/Dlhis.Sys.Api/"]
|
||||
RUN dotnet restore "Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj"
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Startup;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using StackExchange.Redis;
|
||||
|
||||
class Program
|
||||
{
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
/// <summary>
|
||||
/// 0离职
|
||||
/// </summary>
|
||||
public int STAT2 { get; set; }
|
||||
public string STAT2 { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Sys.Api;
|
||||
using Dlhis.Sys.Api.Response;
|
||||
using SqlSugar;
|
||||
using Dlhis.Basic.Api;
|
||||
|
||||
namespace Dlhis.ScheduledTask.SyncSapInfo.Job;
|
||||
|
||||
@@ -18,20 +19,27 @@ public class SyncPersonJob
|
||||
private readonly ILogger _logger;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IDevicePermissionApi _devicePermissionApi;
|
||||
private List<PositionEntity> _positions;
|
||||
private List<TenantResponse> _tenants;
|
||||
private List<SapPersonDepartmentStatus> _departmentChanges;
|
||||
private List<SapPersonJobStatus> _jobChanges;
|
||||
|
||||
public SyncPersonJob(ILogger<SyncPersonJob> logger, IJinkoSapService jinkoSapService, ITenantApi tenantApi)
|
||||
public SyncPersonJob(ILogger<SyncPersonJob> logger, IJinkoSapService jinkoSapService,
|
||||
ITenantApi tenantApi, IDevicePermissionApi devicePermissionApi)
|
||||
{
|
||||
_logger = logger;
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_tenantApi = tenantApi;
|
||||
_devicePermissionApi = devicePermissionApi;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var personResp = await _jinkoSapService.GetPersonsAsync();
|
||||
var persons = personResp.Person.Items;
|
||||
_departmentChanges = personResp.DepartmentInfo.Items;
|
||||
_jobChanges = personResp.JobStatusInfo.Items;
|
||||
|
||||
_logger.LogInformation("获取SAP人员数量为:{count}", persons.Count);
|
||||
if (persons.Count > 0)
|
||||
@@ -59,18 +67,20 @@ public class SyncPersonJob
|
||||
var workCodes = persons.Select(x => x.ZWORKCODE).ToList();
|
||||
var chunks = workCodes.Chunk(4000).ToList();
|
||||
|
||||
Scoped.Temp.Value.Create(sp =>
|
||||
await Scoped.Temp.Value.Create(async sp =>
|
||||
{
|
||||
var dbContext = sp.GetService<IDbContext>();
|
||||
|
||||
foreach (var searchCodes in chunks)
|
||||
{
|
||||
_logger.LogInformation("SAP分批处理Chunk数量:{count}", searchCodes.Count());
|
||||
var dtoResult = await _devicePermissionApi.GetPermissionUsersInfoAsync();
|
||||
var dto = dtoResult.Data;
|
||||
|
||||
var existsWorkCodes = dbContext.Queryable<GainfoSapEntity>()
|
||||
.Where(x => searchCodes.Contains(x.ename))
|
||||
.Select(x => x.ename)
|
||||
.ToList();
|
||||
.Where(x => searchCodes.Contains(x.ename))
|
||||
.Select(x => x.ename)
|
||||
.ToList();
|
||||
|
||||
var originUpdates = persons.Where(x => existsWorkCodes.Contains(x.ZWORKCODE)).ToList();
|
||||
var existsUpdateWorkCodes = originUpdates.Select(x => x.ZWORKCODE).ToList();
|
||||
@@ -83,6 +93,7 @@ public class SyncPersonJob
|
||||
_logger.LogInformation("SAP分批更新数:{count}", updates.Count);
|
||||
var inserts = ToGainfoSap(originInserts);
|
||||
_logger.LogInformation("SAP分批新增数:{count}", inserts.Count);
|
||||
|
||||
foreach (var item in inserts)
|
||||
{
|
||||
i++;
|
||||
@@ -114,6 +125,10 @@ public class SyncPersonJob
|
||||
}
|
||||
}
|
||||
|
||||
var rResult = await _devicePermissionApi.RePermissionUsersInfoAsync(dto);
|
||||
var r = rResult.Data;
|
||||
|
||||
_logger.LogInformation("生成下发任务数量:{count}", r);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -127,7 +142,7 @@ public class SyncPersonJob
|
||||
var info = new GainfoEntity
|
||||
{
|
||||
No = Guid.NewGuid().ToString(),
|
||||
SapNo = item.ano,
|
||||
SapNo = item.PERNR,
|
||||
Type = item.@class,
|
||||
Name = item.gname,
|
||||
Code = item.ename,
|
||||
@@ -157,10 +172,9 @@ public class SyncPersonJob
|
||||
{
|
||||
db.Client.Insertable(info).AS("GainfoLeave").ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void UpdatePerson(IDbContext db, GainfoSapEntity item)
|
||||
private static void UpdatePerson(IDbContext db, GainfoSapEntity item)
|
||||
{
|
||||
var gainfoSap = db.Queryable<GainfoSapEntity>().Where(x => x.ename == item.ename).First();
|
||||
db.Updateable<GainfoSapEntity>().SetColumns(g => new GainfoSapEntity
|
||||
@@ -214,12 +228,39 @@ public class SyncPersonJob
|
||||
return sapList;
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
foreach (var item in sapList)
|
||||
{
|
||||
var a = _jobChanges.FirstOrDefault(x => x.ZWORKCODE == item.ZWORKCODE);
|
||||
if (a != null)
|
||||
{
|
||||
if (a.BEGDA >= now && a.ENDDA <= now)
|
||||
{
|
||||
if (a.STAT2 == "0")
|
||||
{
|
||||
item.STAT2 = "0";
|
||||
item.ZSTATUS = "5";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var b = _departmentChanges.FirstOrDefault(x => x.ZWORKCODE == item.ZWORKCODE);
|
||||
if (b != null)
|
||||
{
|
||||
if (b.BEGDA >= now && b.ENDDA <= now)
|
||||
{
|
||||
item.ORGEH = b.ORGEH;
|
||||
item.WERKS = b.WERKS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var needRemove = sapList.Intersect(last, new SapPersonComparer());
|
||||
return sapList.Except(needRemove, new SapPersonComparer()).ToList();
|
||||
}
|
||||
|
||||
|
||||
private List<SapPersonItem> LoadData(IDbContext db)
|
||||
private static List<SapPersonItem> LoadData(IDbContext db)
|
||||
{
|
||||
var gainfo = db.Queryable<GainfoSapEntity>().ToList();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Dlhis.ScheduledTask.SyncSapInfo.Services;
|
||||
|
||||
public interface IJinkoSapService : ISingletonDependency
|
||||
public interface IJinkoSapService : IScopeDependency
|
||||
{
|
||||
Task<SapOrganizationResponse> GetSapOrganizationsAsync();
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
}
|
||||
},
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://localhost:5003"
|
||||
"SysRequestUrl": "http://localhost:5003",
|
||||
"BasicRequestUrl": "http://localhost:5002"
|
||||
},
|
||||
"FaceUrlOptions": {
|
||||
"Url": "http://localhost:5002/api/gainfos/face?token=",
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
}
|
||||
},
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://sys"
|
||||
"SysRequestUrl": "http://sys",
|
||||
"BasicRequestUrl": "http://basic"
|
||||
},
|
||||
"DataProtectionOptions": {
|
||||
"Enable": true,
|
||||
|
||||
Reference in New Issue
Block a user