From 0e934b2d04b9ae46331418d3c8f2276cb91e1df3 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 15 Sep 2025 14:50:46 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=A4=84=E7=90=86501=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E7=9A=84=E8=AE=BF=E5=AE=A2=E9=A2=84=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/IdentityUserSyncService.cs | 1 + .../Services/Implements/AppointmentService.cs | 89 ++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/IdentityUserSyncService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/IdentityUserSyncService.cs index a68e296d..16ffdd0a 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/IdentityUserSyncService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/IdentityUserSyncService.cs @@ -46,6 +46,7 @@ public class IdentityUserSyncService : IIdentityUserSyncService await AddUserClaim(_identityDbContext, id, "name", name); } + user.LockoutEnd = null; //todo 考虑角色? var userTenants = await _identityDbContext.Queryable().Where(x => x.UserId == user.Id).ToListAsync(); diff --git a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs index b36bff27..21b15df9 100644 --- a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs @@ -1,4 +1,5 @@ -using Dlhis.Entity.Basic.Entity; +using System.Text; +using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Enums; using Dlhis.Entity.Visitor.Entity; using Dlhis.Entity.Visitor.Enums; @@ -14,15 +15,24 @@ public class AppointmentService : IAppointmentService { private readonly IDbContext _dbContext; private readonly RedisCache _redisCache; + private readonly IHttpClientFactory _httpClientFactory; + private readonly ILogger _logger; - public AppointmentService(IDbContext dbContext, RedisCache redisCache) + public AppointmentService(IDbContext dbContext, + RedisCache redisCache, + IHttpClientFactory httpClientFactory, + ILogger logger) { _dbContext = dbContext; _redisCache = redisCache; + _httpClientFactory = httpClientFactory; + _logger = logger; } public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request) { + await ReSendTo501Async(request); + var exists = await _dbContext.Queryable().Where(x => x.No == request.No).AnyAsync(); exists.ThrowIfTrue("已经存在申请"); @@ -189,4 +199,79 @@ public class AppointmentService : IAppointmentService return "EXT" + code.ToString().PadLeft(6, '0'); } + + + private async Task ReSendTo501Async(VisitorAppointmentReceiveRequest request) + { + try + { + if (request.Factory == "501") + { + var gainfo = await _dbContext.Queryable() + .LeftJoin((ga, dept) => ga.DepartmentNo == dept.No) + .Where((ga, dept) => ga.Code == request.Code) + .Select((ga, dept) => new + { + ga.No, + ga.Name, + ga.Phone, + DeptName = dept.Name + }) + .SingleAsync(); + + gainfo.ThrowIfNotNull("501被访人工号不存在"); + + //501厂区发送访客预约 + var httpClient = _httpClientFactory.CreateClient(); + + var list = request.Items.Where(x => x.IsEnterDoorArea).ToList(); + var areas = await _dbContext.Queryable().Where(x => x.TenantId == request.Factory).ToListAsync(); + + foreach (var dto in list) + { + try + { + var response = await httpClient.PostAsync("https://pay.aizhuhotel.com/jschuneng", new StringContent(new + { + arr = dto.DoorStart!.Value.ToString("yyyy-MM-dd HH:mm:ss"), // [必填] 到达时间 + dep = dto.DoorEnd!.Value.ToString("yyyy-MM-dd HH:mm:ss"), // 离开时间 + company = request.Source, // 公司 + deptdes = gainfo.DeptName, // 被访人部门 + askName = request.Code, // 被访人姓名 + askPhone = gainfo.Phone, //被访人手机号 + gname = dto.Name, // 访客姓名 + idNo = dto.IdNo, // 访客身份证号 + phone = dto.Phone, // 访客电话 + reason = request.Reason, // 访问原因 + carNo = dto.LicensePlate, // 车牌号 + carDes = "", // 物品描述 + remark = dto.Remark, // 备注 + //logId = null, // 操作员ID,null或空时后台保存为"face" + //logShift = null, // 操作员班别 null或空时后台保存为"1" + //sta = null, //状态 null或空时后台保存为"R" + + newFunc = dto.IsEnterWorkplace ? 1 : 0, // 是否进入车间 + yqgw = dto.IsEnterWorkplace + ? areas.Where(x => x.Type == AppointmentAreaEnumType.Workplace) + .Where(x => dto.ApplyWorkplaceAreas.Contains(x.CustomCode)) + .Select(x => x.Name) + .Distinct().Join(",") + : string.Empty // 门岗名称 + }.ToJson(), Encoding.UTF8, "application/json")); + var responseJson = await response.Content.ReadAsStringAsync(); + + _logger.LogInformation("发送到501访客预约{idNo}--{name} ,返回:{responseJson}", dto.IdNo, dto.Name, responseJson); + } + catch (Exception e) + { + _logger.LogError(e, "发送到501访客预约{idNo}--{name}", dto.IdNo, dto.Name); + } + } + } + } + catch (Exception e) + { + _logger.LogError(e, "发送到501访客预约失败"); + } + } } \ No newline at end of file