fix 501单独处理不走主流程
This commit is contained in:
@@ -31,7 +31,11 @@ public class AppointmentService : IAppointmentService
|
||||
|
||||
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
||||
{
|
||||
await ReSendTo501Async(request);
|
||||
if (request.Factory == "501")
|
||||
{
|
||||
await ReSendTo501Async(request);
|
||||
return;
|
||||
}
|
||||
|
||||
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||
exists.ThrowIfTrue("已经存在申请");
|
||||
@@ -203,75 +207,58 @@ public class AppointmentService : IAppointmentService
|
||||
|
||||
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
|
||||
{
|
||||
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();
|
||||
ga.No,
|
||||
ga.Name,
|
||||
ga.Phone,
|
||||
DeptName = dept.Name
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
gainfo.ThrowIfNull("501被访人工号不存在");
|
||||
gainfo.ThrowIfNull("501被访人工号不存在");
|
||||
|
||||
//501厂区发送访客预约
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
//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();
|
||||
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)
|
||||
foreach (var dto in list)
|
||||
{
|
||||
_logger.LogError(e, "发送到501访客预约失败");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user