From e151d121daf9bd63dff9ca33e5375e2a81f7a1de Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 15 Sep 2025 15:57:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=20501=E5=8D=95=E7=8B=AC=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=B8=8D=E8=B5=B0=E4=B8=BB=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/AppointmentService.cs | 115 ++++++++---------- 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs index b2bb8988..2ee1133c 100644 --- a/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.External/Appointment/Services/Implements/AppointmentService.cs @@ -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().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() + .LeftJoin((ga, dept) => ga.DepartmentNo == dept.No) + .Where((ga, dept) => ga.Code == request.Code) + .Select((ga, dept) => new { - 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(); + 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().Where(x => x.TenantId == request.Factory).ToListAsync(); + 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) + 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); } } } \ No newline at end of file