feat 处理501独立的访客预约
This commit is contained in:
@@ -46,6 +46,7 @@ public class IdentityUserSyncService : IIdentityUserSyncService
|
|||||||
await AddUserClaim(_identityDbContext, id, "name", name);
|
await AddUserClaim(_identityDbContext, id, "name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.LockoutEnd = null;
|
||||||
|
|
||||||
//todo 考虑角色?
|
//todo 考虑角色?
|
||||||
var userTenants = await _identityDbContext.Queryable<UserTenantEntity>().Where(x => x.UserId == user.Id).ToListAsync();
|
var userTenants = await _identityDbContext.Queryable<UserTenantEntity>().Where(x => x.UserId == user.Id).ToListAsync();
|
||||||
|
|||||||
@@ -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.Basic.Enums;
|
||||||
using Dlhis.Entity.Visitor.Entity;
|
using Dlhis.Entity.Visitor.Entity;
|
||||||
using Dlhis.Entity.Visitor.Enums;
|
using Dlhis.Entity.Visitor.Enums;
|
||||||
@@ -14,15 +15,24 @@ public class AppointmentService : IAppointmentService
|
|||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly RedisCache _redisCache;
|
private readonly RedisCache _redisCache;
|
||||||
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
|
private readonly ILogger<AppointmentService> _logger;
|
||||||
|
|
||||||
public AppointmentService(IDbContext dbContext, RedisCache redisCache)
|
public AppointmentService(IDbContext dbContext,
|
||||||
|
RedisCache redisCache,
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
ILogger<AppointmentService> logger)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_redisCache = redisCache;
|
_redisCache = redisCache;
|
||||||
|
_httpClientFactory = httpClientFactory;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
||||||
{
|
{
|
||||||
|
await ReSendTo501Async(request);
|
||||||
|
|
||||||
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||||
exists.ThrowIfTrue("已经存在申请");
|
exists.ThrowIfTrue("已经存在申请");
|
||||||
|
|
||||||
@@ -189,4 +199,79 @@ public class AppointmentService : IAppointmentService
|
|||||||
|
|
||||||
return "EXT" + code.ToString().PadLeft(6, '0');
|
return "EXT" + code.ToString().PadLeft(6, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task ReSendTo501Async(VisitorAppointmentReceiveRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (request.Factory == "501")
|
||||||
|
{
|
||||||
|
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||||
|
.LeftJoin<DepartmentEntity>((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<AppointmentAreaEntity>().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访客预约失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user