fix trip数据获取入参调整

This commit is contained in:
2024-07-04 15:44:23 +08:00
parent a2cbbdeb47
commit 39a16b8560
6 changed files with 55 additions and 24 deletions

View File

@@ -62,4 +62,6 @@ public class MealSupplementRecordResponse
/// 状态同步
/// </summary>
public bool Sync { get; set; }
}
public DateTime CreateTime { get; set; }
}

View File

@@ -1,11 +1,11 @@
using Dlhis.Canteen.MealSupplementRecord.Request;
using Dlhis.Canteen.MealSupplementRecord.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.Sys.Api;
using Kurisu.AspNetCore.Authentication.Abstractions;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
@@ -36,9 +36,7 @@ public class MealSupplementRecordService : IMealSupplementRecordService
.WhereIF(request.Sync.HasValue, x => x.Sync == request.Sync)
.WhereIF(request.Workplace.IsPresent(), x => x.Workplace == request.Workplace)
.WhereIF(request.Factory.IsPresent(), x => x.Factory == request.Factory)
.WhereIF(request.DateTimePeriod?.Start.HasValue == true
&& request.DateTimePeriod?.End.HasValue == true,
x => x.Date >= request.DateTimePeriod.Start && x.Date <= request.DateTimePeriod.End)
.WhereIF(request.DateTimePeriod.HasValue(), x => x.Date >= request.DateTimePeriod.Start && x.Date <= request.DateTimePeriod.End)
.WhereIF(request.Search.IsPresent(), (x, ga) => x.Code == request.Search || ga.Name == request.Search)
.Select((x, ga) => new MealSupplementRecordResponse
{
@@ -51,9 +49,9 @@ public class MealSupplementRecordService : IMealSupplementRecordService
Sync = x.Sync,
UniqueId = x.UniqueId,
UserName = ga.Name,
Workplace = x.Workplace,
Factory = x.Factory,
CreateTime = x.CreateTime
})
.ToPageListAsync(request);

View File

@@ -15,9 +15,12 @@ public interface IJinkoJIPService : ISingletonDependency
/// </summary>
/// <param name="begin"></param>
/// <param name="end"></param>
/// <param name="departmentNo"></param>
/// <param name="departmentNos"></param>
/// <returns></returns>
Task<SapBusinessTripInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo);
Task<SapBusinessTripInfoResponse> GetTravelInfosByDepartmentsAsync(DateTime begin, DateTime end, List<string> departmentNos);
Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode);
string IssueToken();
}

View File

@@ -27,7 +27,6 @@ public class JinkoJIPService : IJinkoJIPService
{
var httpClient = _httpClientFactory.CreateClient();
httpClient.BaseAddress = new Uri(_configuration.GetSection("JinkoOptions:Jip:BaseUrl").Value);
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", IssueToken());
return httpClient;
@@ -96,13 +95,46 @@ public class JinkoJIPService : IJinkoJIPService
}
public async Task<SapBusinessTripInfoResponse> GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo)
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByDepartmentsAsync(DateTime begin, DateTime end, List<string> departmentNos)
{
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
var beginDay = begin.ToString("yyyyMMdd");
var endDay = end.ToString("yyyyMMdd");
var d = departmentNos.Select(x => new
{
IV_ORGID = x
});
//IV_GONGH IV_ORGID
//IT_2002GH
var obj = new
{
IV_BEGDA = beginDay,
IV_ENDDA = endDay,
IT_2002OR = d
};
var body = obj.ToJson();
var content = new StringContent(body, Encoding.UTF8, "application/json");
var response = await GetHttpClient().PostAsync(apiUrl, content);
response.EnsureSuccessStatusCode();
var jsonResponse = await response.Content.ReadAsStringAsync();
return jsonResponse.ToObject<SapBusinessTripInfoResponse>();
}
public async Task<SapBusinessTripInfoResponse> GetTravelInfosByUserCodeAsync(DateTime begin, DateTime end, string userCode)
{
const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
var beginDay = begin.ToString("yyyyMMdd");
var endDay = end.ToString("yyyyMMdd");
//IV_GONGH IV_ORGID
//IT_2002GH
var obj = new
{
IV_BEGDA = beginDay,
@@ -111,8 +143,7 @@ public class JinkoJIPService : IJinkoJIPService
{
new
{
//IV_GONGH = "" 工号,
IV_ORGID = departmentNo,
IV_GONGH = userCode
}
}
};

View File

@@ -11,7 +11,6 @@ namespace Dlhis.ScheduledTask.Jobs;
[RecurringJob(nameof(CreateSyncServerDateTimeJob), "0 0 0/1 * * ?", Name = "设备时间同步")]
public class CreateSyncServerDateTimeJob : BaseJob
{
public CreateSyncServerDateTimeJob(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
@@ -20,10 +19,10 @@ public class CreateSyncServerDateTimeJob : BaseJob
{
var deviceUniqueNos = await DbContext.Queryable<DeviceTaskEntity>()
.Where(x => x.Status == DeviceTaskStatusEnumType.Wait || x.Status == DeviceTaskStatusEnumType.Process)
.Where(x => x.Type == DeviceTaskEnumType.SyncDateTime)
.Select(x => x.DeviceUniqueNo)
.Distinct()
.ToListAsync();
.Where(x => x.Type == DeviceTaskEnumType.SyncDateTime)
.Select(x => x.DeviceUniqueNo)
.Distinct()
.ToListAsync();
var devices = await DbContext.Queryable<DeviceEntity>()
.Where(x => !deviceUniqueNos.Contains(x.UniqueNo))
@@ -41,10 +40,8 @@ public class CreateSyncServerDateTimeJob : BaseJob
Type = DeviceTaskEnumType.SyncDateTime,
DeviceType = x.Type,
Priority = 49,
}).ToList();
await DbContext.InsertAsync(tasks);
}
}
}

View File

@@ -6,7 +6,7 @@ using Mapster;
namespace Dlhis.ScheduledTask.Jobs;
[RecurringJob(nameof(SyncBusinessTripJob), "0 0 0/1 * * ? ", Name = "SAP同步出差信息")]
[RecurringJob(nameof(SyncBusinessTripJob), "0 0 1 1/1 * ? ", Name = "SAP同步出差信息")]
public class SyncBusinessTripJob : BaseJob
{
/// <inheritdoc />
@@ -25,11 +25,11 @@ public class SyncBusinessTripJob : BaseJob
var validDepartments = tops.ToList();
tops.ForEach(x => RecursionGetNext(x, departments, validDepartments));
foreach (var department in validDepartments)
foreach (var departmentNos in validDepartments.Select(x => x.No).Chunk(100))
{
try
{
var tripResponse = await jipService.GetTravelInfosAsync(today, today, department.No);
var tripResponse = await jipService.GetTravelInfosByDepartmentsAsync(today, today, departmentNos.ToList());
foreach (var tripInfoItem in tripResponse.Items)
{
if (await DbContext.Queryable<BusinessTripEntity>().Where(x => x.Code == tripInfoItem.Code && x.BeginDate == tripInfoItem.BeginDate && x.EndDate == tripInfoItem.EndDate)
@@ -44,7 +44,7 @@ public class SyncBusinessTripJob : BaseJob
}
catch (Exception e)
{
Logger.LogError(e, "获取部门{departmentNo}{departmentName}出差数据执行失败:{message}", department.No, department.Name, e.Message);
Logger.LogError(e, "获取部门出差数据执行失败:{message}", e.Message);
}
}
}