Merge branch 'master' into development
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Dlhis.Basic.Appointment.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 预约区域
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class AppointmentAreasController : ControllerBase
|
||||
{
|
||||
private readonly IAppointmentAreaService _appointmentAreaService;
|
||||
|
||||
public AppointmentAreasController(IAppointmentAreaService appointmentAreaService )
|
||||
{
|
||||
_appointmentAreaService = appointmentAreaService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
public async Task SaveAsync(AppointmentAreaSaveRequest request)
|
||||
{
|
||||
await _appointmentAreaService.SaveAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预约区域分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<AppointmentAreaPageResponse>> GetPageAsync([FromQuery] AppointmentAreaPageRequest request)
|
||||
{
|
||||
return await _appointmentAreaService.GetPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分配设备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assign")]
|
||||
[Transactional]
|
||||
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
||||
{
|
||||
await _appointmentAreaService.AssignAsync(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Dlhis.Basic.Appointment.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 预约
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AppointmentsController : ControllerBase
|
||||
{
|
||||
private readonly IAppointmentService _appointmentService;
|
||||
|
||||
public AppointmentsController(IAppointmentService appointmentService)
|
||||
{
|
||||
_appointmentService = appointmentService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预约申请分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<AppointmentPageResponse>> GetPageAsync([FromQuery] AppointmentPageRequest request)
|
||||
{
|
||||
return await _appointmentService.GetPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确认到达
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("confirm")]
|
||||
[Transactional]
|
||||
public async Task ConfirmAsync(AppointmentConfirmRequest request)
|
||||
{
|
||||
await _appointmentService.ConfirmAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据身份证获取当天预约信息
|
||||
/// </summary>
|
||||
/// <param name="idNo"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("today")]
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(
|
||||
[FromQuery] [StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")] [Required(ErrorMessage = "身份证有误")]
|
||||
string idNo)
|
||||
{
|
||||
return await _appointmentService.GetTodayByIdNoAsync(idNo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据身份证获取预约信息分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("idno/page")]
|
||||
public async Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
|
||||
{
|
||||
return await _appointmentService.GetRecordPageByIdNoAsync(request);
|
||||
}
|
||||
}
|
||||
31
Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs
Normal file
31
Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Dto;
|
||||
|
||||
public class AppointmentReceiveItemDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "姓名必填")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手机号
|
||||
/// </summary>
|
||||
[StringLength(11, MinimumLength = 11)]
|
||||
[Required(ErrorMessage = "手机号必填")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 身份证
|
||||
/// </summary>
|
||||
[StringLength(18, MinimumLength = 18)]
|
||||
[Required(ErrorMessage = "身份证必填")]
|
||||
public string IdNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentAreaAssignRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 预约区域编码
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组
|
||||
/// </summary>
|
||||
public List<Guid> DeviceCodes { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentAreaPageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 区域类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(AppointmentAreaEnumType))]
|
||||
public AppointmentAreaEnumType? Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentAreaSaveRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据id
|
||||
/// </summary>
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域 AppointmentAreaEnumType
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(AppointmentAreaEnumType))]
|
||||
public AppointmentAreaEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "编码不能为空")]
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentConfirmRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 预约明细id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentIdNoPageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 身份证
|
||||
/// </summary>
|
||||
[StringLength(18, MinimumLength = 18, ErrorMessage = "身份证错误")]
|
||||
[Required(ErrorMessage = "身份证不可为空")]
|
||||
public string IdNo { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentPageRequest : PageDto , IValidatableObject
|
||||
{
|
||||
public DateTimePeriod SearchDateTimePeriod { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (SearchDateTimePeriod.HasValue())
|
||||
{
|
||||
SearchDateTimePeriod.End = SearchDateTimePeriod.End!.Value.AddDays(1).AddSeconds(-1);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Basic.Appointment.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Request;
|
||||
|
||||
public class AppointmentReceiveRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "流水号必填")]
|
||||
public string FlowId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "标题必填")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对接人工号
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "对接人工号必填")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对接人姓名
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "对接人姓名必填")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请时间
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "申请时间必填")]
|
||||
public DateTime ApplyTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预约区域
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "申请预约区域必填")]
|
||||
public string ApplyArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来源公司
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "来源公司")]
|
||||
public string Company { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来访时间
|
||||
/// </summary>
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 离开时间
|
||||
/// </summary>
|
||||
public DateTime End { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 厂区
|
||||
/// </summary>
|
||||
public string Factory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
[MinLength(1, ErrorMessage = "明细必填")]
|
||||
public List<AppointmentReceiveItemDto> Items { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (Start >= End)
|
||||
{
|
||||
yield return new ValidationResult("来访时间不能大于等于离开时间", new[] { nameof(Start), nameof(End) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Response;
|
||||
|
||||
public class AppointmentAreaPageResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域类型
|
||||
/// </summary>
|
||||
public AppointmentAreaEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域类型
|
||||
/// </summary>
|
||||
public string TypeDesc => Type.GetDescription();
|
||||
|
||||
/// <summary>
|
||||
/// 自定义编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Response;
|
||||
|
||||
public class AppointmentDetailResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
/// </summary>
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// no
|
||||
/// </summary>
|
||||
public string UserNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 证件类型
|
||||
/// </summary>
|
||||
public string IdType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 证件号
|
||||
/// </summary>
|
||||
public string IdNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访客名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手机号
|
||||
/// </summary>
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车牌
|
||||
/// </summary>
|
||||
public string LicensePlate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进入门岗
|
||||
/// </summary>
|
||||
public bool IsEnterDoorArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预约门禁区域
|
||||
/// </summary>
|
||||
public string ApplyDoorArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访客开始
|
||||
/// </summary>
|
||||
public DateTime DoorStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问结束
|
||||
/// </summary>
|
||||
public DateTime DoorEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否进入车间
|
||||
/// </summary>
|
||||
public bool IsEnterWorkplace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请车间区域
|
||||
/// </summary>
|
||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问开始
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问结束
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 社保照片url
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 门禁状态
|
||||
/// </summary>
|
||||
public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间状态
|
||||
/// </summary>
|
||||
public VisitorAppointmentDetailStatusEnumType WorkplaceStatus { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace Dlhis.Basic.Appointment.Response;
|
||||
|
||||
public class AppointmentPageResponse
|
||||
{
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对接人工号
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来访人来源/公司
|
||||
/// </summary>
|
||||
public string Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请时间
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预约厂区
|
||||
/// </summary>
|
||||
public string Factory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请事由
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Services;
|
||||
|
||||
public interface IAppointmentAreaService : IScopeDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 区域分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task<Pagination<AppointmentAreaPageResponse>> GetPageAsync(AppointmentAreaPageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 保存区域
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task SaveAsync(AppointmentAreaSaveRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 分配设备组到区域
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task AssignAsync(AppointmentAreaAssignRequest request);
|
||||
}
|
||||
40
Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs
Normal file
40
Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Services;
|
||||
|
||||
public interface IAppointmentService : IScopeDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 预约分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task<Pagination<AppointmentPageResponse>> GetPageAsync(AppointmentPageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 查看明细
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<AppointmentDetailResponse>> GetAppointmentDetailsByIdAsync(string no);
|
||||
|
||||
/// <summary>
|
||||
/// 确认到达
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task ConfirmAsync(AppointmentConfirmRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据身份证获取最新访客预约
|
||||
/// </summary>
|
||||
/// <param name="idNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo);
|
||||
|
||||
|
||||
Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request);
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Services.Implements;
|
||||
|
||||
public class AppointmentAreaService : IAppointmentAreaService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public AppointmentAreaService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(AppointmentAreaSaveRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<AppointmentAreaEntity>();
|
||||
entity.CustomCode = request.CustomCode;
|
||||
entity.Type = request.Type;
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||
entity.ThrowIfNull("预约区域不存在");
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Pagination<AppointmentAreaPageResponse>> GetPageAsync(AppointmentAreaPageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<AppointmentAreaEntity>()
|
||||
.WhereIF(request.Type.HasValue, x => x.Type == request.Type)
|
||||
.WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search))
|
||||
.Select<AppointmentAreaPageResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
||||
{
|
||||
(await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.CustomCode == request.CustomCode).AnyAsync())
|
||||
.ThrowIfFalse("区域不存在");
|
||||
|
||||
var userBeforePermissions = await GetMyPermissionsAsync(request.CustomCode);
|
||||
var userNos = userBeforePermissions.Select(x => x.Key).ToList();
|
||||
|
||||
//删除原来的配置
|
||||
await _dbContext.Client.Deleteable<AppointmentAreaAssignmentEntity>()
|
||||
.Where(x => x.CustomCode == request.CustomCode)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//添加当前区域的设置
|
||||
var data = request.DeviceCodes.Select(x => new AppointmentAreaAssignmentEntity
|
||||
{
|
||||
CustomCode = request.CustomCode,
|
||||
DeviceCode = x
|
||||
}).ToList();
|
||||
|
||||
await _dbContext.InsertAsync(data);
|
||||
|
||||
var userCurrentPermissions = await GetMyPermissionsAsync(request.CustomCode);
|
||||
|
||||
var allDeviceCodes = userCurrentPermissions.SelectMany(x => x.Value);
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => allDeviceCodes.Contains(x.Code)).ToListAsync();
|
||||
|
||||
var tasks = new List<DeviceTaskEntity>();
|
||||
foreach (var userNo in userNos)
|
||||
{
|
||||
var before = userBeforePermissions[userNo];
|
||||
var current = userCurrentPermissions[userNo];
|
||||
|
||||
//被删除
|
||||
var deletedItems = before.Where(x => !current.Contains(x)).ToList();
|
||||
//新增
|
||||
var addItems = current.Where(x => !before.Contains(x)).ToList();
|
||||
|
||||
if (!deletedItems.Any() && !addItems.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
tasks.AddRange(deletedItems.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
Type = DeviceTaskEnumType.Delete,
|
||||
DeviceType = DeviceTypeEnumType.Door,
|
||||
UserNo = userNo,
|
||||
DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
Version = 0,
|
||||
CancellationId = 0,
|
||||
Source = DeviceTaskSourceEnumType.Appointment,
|
||||
Priority = 99
|
||||
}));
|
||||
|
||||
tasks.AddRange(addItems.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
Type = DeviceTaskEnumType.Add,
|
||||
DeviceType = DeviceTypeEnumType.Door,
|
||||
UserNo = userNo,
|
||||
DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
Version = 0,
|
||||
CancellationId = 0,
|
||||
Source = DeviceTaskSourceEnumType.Appointment,
|
||||
Priority = 99
|
||||
}));
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(tasks);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************* help methods ***************************************************************
|
||||
|
||||
|
||||
private async Task<Dictionary<string, List<Guid>>> GetMyPermissionsAsync(string areaCode)
|
||||
{
|
||||
//获取已经到达的数据
|
||||
var arrivedInfos = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived || x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
|
||||
.Select(x => new
|
||||
{
|
||||
x.UserNo,
|
||||
x.DoorStatus,
|
||||
x.WorkplaceStatus,
|
||||
x.IsEnterDoorArea,
|
||||
x.ApplyDoorArea,
|
||||
x.IsEnterWorkplace,
|
||||
x.ApplyWorkplaceAreas
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var userAreaCodes = arrivedInfos.GroupBy(x => x.UserNo).ToDictionary(p => p.Key, ls =>
|
||||
{
|
||||
return ls.SelectMany(x =>
|
||||
{
|
||||
var list = new List<string>();
|
||||
if (x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
|
||||
{
|
||||
list.Add(x.ApplyDoorArea);
|
||||
}
|
||||
|
||||
if (x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
|
||||
{
|
||||
list.AddRange(x.ApplyWorkplaceAreas);
|
||||
}
|
||||
|
||||
return list;
|
||||
});
|
||||
});
|
||||
|
||||
userAreaCodes = userAreaCodes.Where(x => x.Value.Contains(areaCode)).ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
var userBeforePermissions = new Dictionary<string, List<Guid>>(userAreaCodes.Count);
|
||||
foreach ((string currentUserNo, IEnumerable<string> currentUseAreaCode) in userAreaCodes)
|
||||
{
|
||||
var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||
.Where(x => currentUseAreaCode.Contains(x.CustomCode))
|
||||
.Select(x => x.DeviceCode)
|
||||
.ToListAsync();
|
||||
|
||||
userBeforePermissions.Add(currentUserNo, deviceCodes);
|
||||
}
|
||||
|
||||
return userBeforePermissions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using Dlhis.Basic.Appointment.Request;
|
||||
using Dlhis.Basic.Appointment.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Appointment.Services.Implements;
|
||||
|
||||
public class AppointmentService : IAppointmentService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IDataProtectionProvider _dataProtectionProvider;
|
||||
|
||||
public AppointmentService(IDbContext dbContext, IDataProtectionProvider dataProtectionProvider)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_dataProtectionProvider = dataProtectionProvider;
|
||||
}
|
||||
|
||||
public async Task<Pagination<AppointmentPageResponse>> GetPageAsync(AppointmentPageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<VisitorAppointmentEntity>()
|
||||
.WhereIF(request.SearchDateTimePeriod.HasValue(),
|
||||
x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End)
|
||||
.WhereIF(request.Search.IsPresent(), x => x.Code == request.Search)
|
||||
.Select<AppointmentPageResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task<List<AppointmentDetailResponse>> GetAppointmentDetailsByIdAsync(string no)
|
||||
{
|
||||
return await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => x.No == no)
|
||||
.Select<AppointmentDetailResponse>()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task ConfirmAsync(AppointmentConfirmRequest request)
|
||||
{
|
||||
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||
detail.ThrowIfNull("预约信息不存在");
|
||||
|
||||
var areaCodes = GetValidAreaCodes(detail);
|
||||
var existsAreaCodes = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync();
|
||||
|
||||
//当前分配的设备codes
|
||||
var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||
.Where(x => existsAreaCodes.Contains(x.CustomCode))
|
||||
.Select(x => x.DeviceCode)
|
||||
.ToListAsync();
|
||||
|
||||
var deviceUniqueNos = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).Select(x => new { x.UniqueNo, x.TenantId }).ToListAsync();
|
||||
|
||||
await _dbContext.InsertAsync(deviceUniqueNos.Select(x => new DeviceTaskEntity
|
||||
{
|
||||
DeviceType = DeviceTypeEnumType.Door,
|
||||
DeviceUniqueNo = x.UniqueNo,
|
||||
Status = DeviceTaskStatusEnumType.Wait,
|
||||
UserNo = detail.UserNo,
|
||||
Type = DeviceTaskEnumType.Add,
|
||||
Priority = 100,
|
||||
TenantId = x.TenantId,
|
||||
Source = DeviceTaskSourceEnumType.Appointment,
|
||||
Version = 0,
|
||||
}).ToList());
|
||||
|
||||
detail.DoorStatus = VisitorAppointmentDetailStatusEnumType.Arrived;
|
||||
detail.WorkplaceStatus = VisitorAppointmentDetailStatusEnumType.Arrived;
|
||||
detail.ArrivedTime = DateTime.Now;
|
||||
await _dbContext.UpdateAsync(detail);
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerable<string> GetValidAreaCodes(VisitorAppointmentDetailEntity detail)
|
||||
{
|
||||
if (detail.IsEnterDoorArea)
|
||||
{
|
||||
yield return detail.ApplyDoorArea;
|
||||
}
|
||||
|
||||
if (detail.IsEnterWorkplace)
|
||||
{
|
||||
foreach (var item in detail.ApplyWorkplaceAreas)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************** 用户操作 *******************************************************************
|
||||
|
||||
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo)
|
||||
{
|
||||
var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
|
||||
try
|
||||
{
|
||||
idNo = protector.Unprotect(idNo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new UserFriendlyException("凭证有误");
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
return await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => ga.IdNo == idNo)
|
||||
.Where((x, ga) => ga.IdNo == idNo)
|
||||
.Where(x => (x.IsEnterDoorArea && SqlFunc.DateIsSame(x.DoorStart, now)) || (x.IsEnterWorkplace && SqlFunc.DateIsSame(x.WorkplaceStart, now)))
|
||||
.Select<AppointmentDetailResponse>()
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
public async Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
|
||||
{
|
||||
var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
|
||||
try
|
||||
{
|
||||
request.IdNo = protector.Unprotect(request.IdNo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new UserFriendlyException("凭证有误");
|
||||
}
|
||||
|
||||
var page = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
|
||||
.Where((x, ga) => ga.IdNo == request.IdNo)
|
||||
.OrderBy(x => x.CreateTime)
|
||||
.Select<AppointmentDetailResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
@@ -30,12 +30,6 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
businessPlace.ThrowIfNull("营业点不存在");
|
||||
|
||||
var device = await GetEnableDeviceAsync(request.UniqueNo, false, request.DeployPlace, businessPlace.TenantId);
|
||||
if (device.DeployPlace.Equals("AUTO", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
device.DeployPlace = businessPlace.Name;
|
||||
await _dbContext.UpdateAsync(device);
|
||||
}
|
||||
|
||||
var registry = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => x.DeviceUniqueNo == request.UniqueNo).SingleAsync();
|
||||
|
||||
if (registry != null)
|
||||
@@ -45,20 +39,28 @@ public class DeviceConnectService : IDeviceConnectService
|
||||
registry.BusinessPlaceCode = businessPlace.Code;
|
||||
|
||||
await _dbContext.UpdateAsync(registry);
|
||||
|
||||
return "请勿重复注册设备";
|
||||
}
|
||||
else
|
||||
{
|
||||
registry = new DeviceRegistryEntity
|
||||
{
|
||||
DeviceUniqueNo = request.UniqueNo,
|
||||
LastHeartbeatTime = DateTime.Now,
|
||||
RegisterTime = DateTime.Now,
|
||||
BusinessPlaceCode = businessPlace.Code,
|
||||
TenantId = device.TenantId
|
||||
};
|
||||
|
||||
await _dbContext.InsertAsync(registry);
|
||||
}
|
||||
|
||||
registry = new DeviceRegistryEntity
|
||||
{
|
||||
DeviceUniqueNo = request.UniqueNo,
|
||||
LastHeartbeatTime = DateTime.Now,
|
||||
RegisterTime = DateTime.Now,
|
||||
BusinessPlaceCode = businessPlace.Code,
|
||||
TenantId = device.TenantId
|
||||
};
|
||||
if (request.DeployPlace.Equals("AUTO", StringComparison.OrdinalIgnoreCase))
|
||||
device.DeployPlace = businessPlace.Name;
|
||||
else
|
||||
device.DeployPlace = request.DeployPlace.IsPresent() ? request.DeployPlace : businessPlace.Name;
|
||||
|
||||
await _dbContext.UpdateAsync(device);
|
||||
|
||||
await _dbContext.InsertAsync(registry);
|
||||
return "设备注册成功";
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class DeviceService : IDeviceService
|
||||
.Where((dgr, dg) => dgr.DeviceCode == entity.Code)
|
||||
.AnyAsync();
|
||||
|
||||
existsG.ThrowIfTrue("存在设备分组,不可修改设备分类");
|
||||
existsG.ThrowIfTrue("存在设备分组,不可修改设备类型");
|
||||
}
|
||||
|
||||
request.Adapt(entity);
|
||||
|
||||
@@ -11,7 +11,7 @@ public class GainfoMealPageRequest : PageDto
|
||||
public DateTimePeriod SearchDateTimePeriod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否离职
|
||||
/// 是否查询离职
|
||||
/// </summary>
|
||||
public bool IsLeave { get; set; }
|
||||
}
|
||||
@@ -89,12 +89,14 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
.ToListAsync();
|
||||
await _dbContext.DeleteAsync(relations);
|
||||
|
||||
request.UserNos = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code))
|
||||
var userNos = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code)) //NO和工号匹配
|
||||
.Select(x => x.No)
|
||||
.ToListAsync();
|
||||
|
||||
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
|
||||
(userNos.Count != request.UserNos.Count).ThrowIfTrue("存在权限外人员,无法添加");
|
||||
|
||||
var entities = userNos.Select(x => new GainfoGroupRelationshipEntity
|
||||
{
|
||||
GroupCode = request.GroupCode,
|
||||
UserNo = x
|
||||
|
||||
@@ -43,13 +43,17 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
||||
: await GetOutSourceCodeAsync();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
await _dbContext.InsertAsync(new OutsourceEntity
|
||||
|
||||
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
|
||||
{
|
||||
Code = entity.Code,
|
||||
Supplier = request.ExternalInfo.Supplier,
|
||||
SapCode = request.ExternalInfo.SapCode,
|
||||
SapPhone = request.ExternalInfo.SapPhone
|
||||
});
|
||||
await _dbContext.InsertAsync(new OutsourceEntity
|
||||
{
|
||||
Code = entity.Code,
|
||||
Supplier = request.ExternalInfo.Supplier,
|
||||
SapCode = request.ExternalInfo.SapCode,
|
||||
SapPhone = request.ExternalInfo.SapPhone
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Api;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
@@ -28,7 +27,6 @@ public class GainfoService : IGainfoService
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IHangfireApi _hangfireApi;
|
||||
private readonly IHainingApi _hainingApi;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||
private readonly ILogger<GainfoService> _logger;
|
||||
@@ -39,7 +37,6 @@ public class GainfoService : IGainfoService
|
||||
ICurrentUser currentUser,
|
||||
ITenantApi tenantApi,
|
||||
IHangfireApi hangfireApi,
|
||||
IHainingApi hainingApi,
|
||||
IDevicePermissionService devicePermissionService,
|
||||
IGainfoPermissionService gainfoPermissionService,
|
||||
ILogger<GainfoService> logger)
|
||||
@@ -50,7 +47,6 @@ public class GainfoService : IGainfoService
|
||||
_currentUser = currentUser;
|
||||
_tenantApi = tenantApi;
|
||||
_hangfireApi = hangfireApi;
|
||||
_hainingApi = hainingApi;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_gainfoPermissionService = gainfoPermissionService;
|
||||
_logger = logger;
|
||||
@@ -68,6 +64,11 @@ public class GainfoService : IGainfoService
|
||||
//根据组织架构搜索档案
|
||||
var where = LinqExpressionExtensions.False<GainfoEntity>();
|
||||
var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList();
|
||||
|
||||
var role = _currentUser.GetRole();
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var isAll = role is "admin" or "tenant-admin";
|
||||
|
||||
if (request.DepartmentSelections.Any())
|
||||
{
|
||||
foreach (var item in request.DepartmentSelections)
|
||||
@@ -91,11 +92,15 @@ public class GainfoService : IGainfoService
|
||||
where = Expressionable.Create<GainfoEntity>()
|
||||
.And(where)
|
||||
.Or(gainfo => SqlFunc.Subqueryable<BusinessTripEntity>()
|
||||
.Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today))
|
||||
.Any())
|
||||
.Where(p => p.Code == gainfo.Code
|
||||
&& factories.Contains(p.Destination)
|
||||
&& SqlFunc.DateIsSame(p.BeginDate, today))
|
||||
.Any()
|
||||
)
|
||||
.ToExpression();
|
||||
}
|
||||
|
||||
|
||||
ISugarQueryable<GainfoPageResponse> queryable = request.IsSearchAll
|
||||
? _dbContext.Queryable<GainfoEntity>().AS("GainfoEntity", "gainfo")
|
||||
.Where(where)
|
||||
@@ -117,7 +122,12 @@ public class GainfoService : IGainfoService
|
||||
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
|
||||
.WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory))
|
||||
.WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == gainfo.Code).NotAny())
|
||||
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == gainfo.Code).Any()) //&& today >= gainfo.EntryDate && today <= gainfo.ResignationDate
|
||||
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo =>
|
||||
SqlFunc.Subqueryable<OutsourceEntity>()
|
||||
.Where(p => p.Code == gainfo.Code)
|
||||
.WhereIF(!isAll, p => p.SapCode == jinkoCode)
|
||||
.Any()
|
||||
)
|
||||
.WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo =>
|
||||
SqlFunc.Subqueryable<BusinessTripEntity>().Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)).Any())
|
||||
.WhereIF(request.Search.IsPresent(), gainfo =>
|
||||
@@ -132,14 +142,16 @@ public class GainfoService : IGainfoService
|
||||
CardTypeName = type.Display
|
||||
}, true);
|
||||
|
||||
_logger.LogInformation(queryable.ToSqlString());
|
||||
var page = await queryable.ToPageListAsync(request);
|
||||
|
||||
//外包人员部门号处理
|
||||
if (request.SearchType == GainfoSearchEnumType.Outsource)
|
||||
{
|
||||
var codes = page.Data.Select(x => x.Code).ToList();
|
||||
var outsourceInfos = await _dbContext.Queryable<OutsourceEntity>().Where(x => codes.Contains(x.Code)).Select(x => new { x.Code, x.Supplier }).ToListAsync();
|
||||
var outsourceInfos = await _dbContext.Queryable<OutsourceEntity>()
|
||||
.Where(x => codes.Contains(x.Code))
|
||||
.Select(x => new { x.Code, x.Supplier })
|
||||
.ToListAsync();
|
||||
|
||||
page.Data.ForEach(item => { item.DepartmentName = outsourceInfos.FirstOrDefault(x => x.Code == item.Code)?.Supplier; });
|
||||
}
|
||||
@@ -227,8 +239,7 @@ public class GainfoService : IGainfoService
|
||||
|
||||
public async Task<object> CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request)
|
||||
{
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
|
||||
|
||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).SingleAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
|
||||
gainfo.ThrowIfNull("验证失败!");
|
||||
|
||||
var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
|
||||
|
||||
Reference in New Issue
Block a user