fix 提交已经问题处理

This commit is contained in:
2024-08-29 18:28:16 +08:00
parent 275e6e333d
commit 5b55ac01dd
21 changed files with 129 additions and 502 deletions

View File

@@ -39,8 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen", "Src\Dlhis.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen.Api", "Src\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj", "{D4043506-7247-4DDC-9751-927403515669}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen.Api", "Src\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj", "{D4043506-7247-4DDC-9751-927403515669}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Visitor", "Src\Dlhis.Visitor\Dlhis.Visitor.csproj", "{69E8A91A-5D05-4327-BC24-038523C7628C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Message", "Message", "{65E76F97-E78A-4C95-B788-4091236B1A79}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Message", "Message", "{65E76F97-E78A-4C95-B788-4091236B1A79}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Message", "Src\Dlhis.Message\Dlhis.Message.csproj", "{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Message", "Src\Dlhis.Message\Dlhis.Message.csproj", "{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}"
@@ -111,10 +109,6 @@ Global
{D4043506-7247-4DDC-9751-927403515669}.Debug|Any CPU.Build.0 = Debug|Any CPU {D4043506-7247-4DDC-9751-927403515669}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4043506-7247-4DDC-9751-927403515669}.Release|Any CPU.ActiveCfg = Release|Any CPU {D4043506-7247-4DDC-9751-927403515669}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4043506-7247-4DDC-9751-927403515669}.Release|Any CPU.Build.0 = Release|Any CPU {D4043506-7247-4DDC-9751-927403515669}.Release|Any CPU.Build.0 = Release|Any CPU
{69E8A91A-5D05-4327-BC24-038523C7628C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69E8A91A-5D05-4327-BC24-038523C7628C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69E8A91A-5D05-4327-BC24-038523C7628C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69E8A91A-5D05-4327-BC24-038523C7628C}.Release|Any CPU.Build.0 = Release|Any CPU
{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {053BF7B2-B1A0-435F-9C77-2EF5622CC5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -151,7 +145,6 @@ Global
{9EA85FB2-F320-4F97-B278-00652CF35BD8} = {AA987BDF-EF63-467B-AD04-59F9B10D9000} {9EA85FB2-F320-4F97-B278-00652CF35BD8} = {AA987BDF-EF63-467B-AD04-59F9B10D9000}
{A54426E2-1CA0-48AB-BBA6-07CDE2807E35} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B} {A54426E2-1CA0-48AB-BBA6-07CDE2807E35} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
{D4043506-7247-4DDC-9751-927403515669} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B} {D4043506-7247-4DDC-9751-927403515669} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
{69E8A91A-5D05-4327-BC24-038523C7628C} = {489252FB-A44B-46EE-B065-21CDCB724441}
{053BF7B2-B1A0-435F-9C77-2EF5622CC5C5} = {65E76F97-E78A-4C95-B788-4091236B1A79} {053BF7B2-B1A0-435F-9C77-2EF5622CC5C5} = {65E76F97-E78A-4C95-B788-4091236B1A79}
{4D656761-8CE7-4316-A3DF-8C1722D69CCE} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {4D656761-8CE7-4316-A3DF-8C1722D69CCE} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
{A501D16E-638F-4156-989C-2BACCC2FAC2B} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {A501D16E-638F-4156-989C-2BACCC2FAC2B} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}

View File

@@ -1,6 +1,7 @@
using Dlhis.Entity.Basic.Enums; using Dlhis.Entity.Basic.Enums;
using Kurisu.AspNetCore.DataAccess.SqlSugar; using Kurisu.AspNetCore.DataAccess.SqlSugar;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes; using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
using Mapster;
using SqlSugar; using SqlSugar;
using SqlSugar.DbConvert; using SqlSugar.DbConvert;
@@ -19,17 +20,24 @@ public class GainfoEntity : SugarBaseEntity
public string No { get; set; } public string No { get; set; }
/// <summary> /// <summary>
/// SAP内部编号 /// 内部编号
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "SAP内部编号")] [SugarColumn(IsNullable = true, ColumnDescription = "内部编号")]
public string SapNo { get; set; } public string InternalNo { get; set; }
/// <summary> /// <summary>
/// 员类型 /// 人员类型
/// </summary> /// </summary>
[AdaptIgnore(MemberSide.Destination)]
[SugarColumn(ColumnDescription = "人员类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] [SugarColumn(ColumnDescription = "人员类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public GainfoUserTypeEnumType Type { get; set; } public GainfoUserTypeEnumType Type { get; set; }
/// <summary>
/// 人员来源
/// </summary>
[SugarColumn(ColumnDescription = "人员来源", IsNullable = true)]
public string Source { get; set; }
/// <summary> /// <summary>
/// 姓名 /// 姓名
/// </summary> /// </summary>
@@ -84,12 +92,6 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "身份证地址")] [SugarColumn(ColumnDescription = "身份证地址")]
public string Address { get; set; } public string Address { get; set; }
///// <summary>
///// 已婚/未婚
///// </summary>
//[SugarColumn(ColumnDescription = "已婚/未婚")]
//public string Marital { get; set; }
/// <summary> /// <summary>
/// 部门编码 /// 部门编码
/// </summary> /// </summary>
@@ -187,7 +189,9 @@ public class GainfoEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "身份认证用户Id", IsNullable = true)] [SugarColumn(ColumnDescription = "身份认证用户Id", IsNullable = true)]
public int IdentityUserId { get; set; } public int IdentityUserId { get; set; }
/// <summary>
/// 卡类型
/// </summary>
[SugarColumn(ColumnDescription = "卡类型", IsNullable = true)] [SugarColumn(ColumnDescription = "卡类型", IsNullable = true)]
public int? CardType { get; set; } public int? CardType { get; set; }
} }
@@ -199,16 +203,3 @@ public class GainfoEntity : SugarBaseEntity
public class GainfoLeaveEntity : GainfoEntity public class GainfoLeaveEntity : GainfoEntity
{ {
} }
/// <summary>
/// 外部人员档案表
/// </summary>
[SugarTable(TableName = "GainfoExternal", TableDescription = "外部人员档案表")]
public class GainfoExternalEntity : GainfoEntity
{
/// <summary>
/// 公司
/// </summary>
[SugarColumn(ColumnDescription = "公司", IsNullable = false)]
public string Company { get; set; }
}

View File

@@ -15,7 +15,19 @@ public enum GainfoUserTypeEnumType
Normal = 1, Normal = 1,
/// <summary> /// <summary>
/// 安检白名单 /// 外包人员
/// </summary>
[Description("外包人员")]
Outsource = 2,
/// <summary>
/// 外部人员
/// </summary>
[Description("外部人员")]
External = 3,
/// <summary>
/// 安检白名单(也属于普通人员)
/// </summary> /// </summary>
[Description("安检白名单")] [Description("安检白名单")]
SecurityWhite = 99 SecurityWhite = 99

View File

@@ -19,7 +19,7 @@ public class AppointmentAreaEntity : SugarBaseEntity, ITenantId, ISoftDeleted
[AdaptIgnore(MemberSide.Destination)] [AdaptIgnore(MemberSide.Destination)]
[SugarColumn(IsNullable = false, ColumnDescription = "区域类型", ColumnDataType = "varchar(50)", [SugarColumn(IsNullable = false, ColumnDescription = "区域类型", ColumnDataType = "varchar(50)",
SqlParameterDbType = typeof(EnumToStringConvert), SqlParameterDbType = typeof(EnumToStringConvert),
UniqueGroupNameList = new[] { "idx_ApponintmentArea_t_cc_tid" })] UniqueGroupNameList = new[] { "idx_AppointmentArea_t_cc_tid" })]
public AppointmentAreaEnumType Type { get; set; } public AppointmentAreaEnumType Type { get; set; }
/// <summary> /// <summary>
@@ -27,7 +27,7 @@ public class AppointmentAreaEntity : SugarBaseEntity, ITenantId, ISoftDeleted
/// </summary> /// </summary>
[AdaptIgnore(MemberSide.Destination)] [AdaptIgnore(MemberSide.Destination)]
[SugarColumn(IsNullable = false, ColumnDescription = "自定义编码", [SugarColumn(IsNullable = false, ColumnDescription = "自定义编码",
UniqueGroupNameList = new[] { "idx_ApponintmentArea_t_cc_tid" })] UniqueGroupNameList = new[] { "idx_AppointmentArea_t_cc_tid" })]
public string CustomCode { get; set; } public string CustomCode { get; set; }
/// <summary> /// <summary>
@@ -46,7 +46,7 @@ public class AppointmentAreaEntity : SugarBaseEntity, ITenantId, ISoftDeleted
/// 基地/租户 /// 基地/租户
/// </summary> /// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = " 基地/租户", [SugarColumn(IsNullable = false, ColumnDescription = " 基地/租户",
UniqueGroupNameList = new[] { "idx_ApponintmentArea_t_cc_tid" })] UniqueGroupNameList = new[] { "idx_AppointmentArea_t_cc_tid" })]
public string TenantId { get; set; } public string TenantId { get; set; }

View File

@@ -11,7 +11,7 @@ namespace Dlhis.Entity.Visitor.Entity;
[SugarTable(TableName = "VisitorAppointmentDetail", TableDescription = "访客预约")] [SugarTable(TableName = "VisitorAppointmentDetail", TableDescription = "访客预约")]
public class VisitorAppointmentDetailEntity : SugarBaseEntity public class VisitorAppointmentDetailEntity : SugarBaseEntity
{ {
[SugarColumn(IsNullable = false, ColumnDescription = "父id")] [SugarColumn(IsNullable = false, ColumnDescription = "pid")]
public long AppointmentId { get; set; } public long AppointmentId { get; set; }
/// <summary> /// <summary>
@@ -20,12 +20,6 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
[SugarColumn(IsNullable = false, ColumnDescription = "流水号")] [SugarColumn(IsNullable = false, ColumnDescription = "流水号")]
public string No { get; set; } public string No { get; set; }
/// <summary>
/// 是否外部人员
/// </summary>
[SugarColumn(IsNullable = false, ColumnDataType = "bit")]
public bool IsExternal { get; set; }
/// <summary> /// <summary>
/// no /// no
/// </summary> /// </summary>
@@ -44,16 +38,6 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
[SugarColumn(IsNullable = false, ColumnDescription = "手机号")] [SugarColumn(IsNullable = false, ColumnDescription = "手机号")]
public string Phone { get; set; } public string Phone { get; set; }
/// <summary>
/// 身份证
/// </summary>
/// <remarks>
/// 使用身份证字段作为申请人唯一标识
/// </remarks>
[SugarColumn(IsNullable = false, ColumnDescription = "身份证")]
public string IdNo { get; set; }
/// <summary> /// <summary>
/// 车牌 /// 车牌
/// </summary> /// </summary>

View File

@@ -18,5 +18,5 @@ public enum AppointmentAreaEnumType
/// 车间 /// 车间
/// </summary> /// </summary>
[Description("车间")] [Description("车间")]
Workshop = 2, Workplace = 2
} }

View File

@@ -18,10 +18,9 @@ public class AppointmentReceiveItemDto
public string Phone { get; set; } public string Phone { get; set; }
/// <summary> /// <summary>
/// 身份证 /// 证件号/工号
/// </summary> /// </summary>
[StringLength(18, MinimumLength = 18)] [Required(ErrorMessage = "证件号/工号")]
[Required(ErrorMessage = "身份证必填")]
public string IdNo { get; set; } public string IdNo { get; set; }
/// <summary> /// <summary>

View File

@@ -73,23 +73,19 @@ public class AppointmentReceiveRequest : IValidatableObject
/// </summary> /// </summary>
public bool IsEnterWorkplace { get; set; } public bool IsEnterWorkplace { get; set; }
/// <summary>
/// 车间区域
/// </summary>
public string WorkplaceArea { get; set; }
/// <summary> /// <summary>
/// 明细 /// 明细
/// </summary> /// </summary>
[MinLength(1, ErrorMessage = "明细必填")] [MinLength(1, ErrorMessage = "明细必填")]
public List<AppointmentReceiveItemDto> Items { get; set; } public List<AppointmentReceiveItemDto> Items { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{ {
if (IsEnterWorkplace)
{
if (Items.Any(x => x.ImageUrl.IsEmpty()))
{
yield return new ValidationResult("社保照片不可为空", new[] { "ImageUrl" });
}
}
if (Start >= End) if (Start >= End)
{ {
yield return new ValidationResult("来访时间不能大于等于离开时间", new[] { nameof(Start), nameof(End) }); yield return new ValidationResult("来访时间不能大于等于离开时间", new[] { nameof(Start), nameof(End) });

View File

@@ -1,19 +1,24 @@
using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Entity;
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;
using Dlhis.External.Appointment.Request; using Dlhis.External.Appointment.Request;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Utils;
using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.AspNetCore.Utils.Extensions;
using SqlSugar;
namespace Dlhis.External.Appointment.Services.Implements; namespace Dlhis.External.Appointment.Services.Implements;
public class AppointmentService : IAppointmentService public class AppointmentService : IAppointmentService
{ {
private readonly IDbContext _dbContext; private readonly IDbContext _dbContext;
private readonly RedisCache _redisCache;
public AppointmentService(IDbContext dbContext) public AppointmentService(IDbContext dbContext, RedisCache redisCache)
{ {
_dbContext = dbContext; _dbContext = dbContext;
_redisCache = redisCache;
} }
public async Task ReceiveAsync(AppointmentReceiveRequest request) public async Task ReceiveAsync(AppointmentReceiveRequest request)
@@ -23,6 +28,11 @@ public class AppointmentService : IAppointmentService
var id = await _dbContext.InsertReturnIdentityAsync(new VisitorAppointmentEntity var id = await _dbContext.InsertReturnIdentityAsync(new VisitorAppointmentEntity
{ {
Id = 0,
CreatedBy = 0,
CreateTime = default,
ModifiedBy = 0,
ModifiedTime = default,
No = request.No, No = request.No,
Title = request.Title, Title = request.Title,
Code = request.Code, Code = request.Code,
@@ -34,55 +44,76 @@ public class AppointmentService : IAppointmentService
Start = request.Start, Start = request.Start,
End = request.End, End = request.End,
Remark = request.Remark, Remark = request.Remark,
IsEnterWorkplace = request.IsEnterWorkplace IsEnterWorkplace = request.IsEnterWorkplace,
}); });
foreach (var item in request.Items) foreach (var item in request.Items)
{ {
var no = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.IdNo).Select(x => x.No).SingleAsync(); var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.IdNo || x.Code == item.IdNo).SingleAsync();
var isExternal = no.IsEmpty(); //外部人员
if (isExternal) if (gainfo == null)
{ {
var gainfoExternal = await _dbContext.Queryable<GainfoExternalEntity>().Where(x => x.IdNo == item.IdNo).FirstAsync(); gainfo = new GainfoEntity
if (gainfoExternal == null)
{
gainfoExternal = new GainfoExternalEntity
{ {
No = Guid.NewGuid().ToString(), No = Guid.NewGuid().ToString(),
Code = item.IdNo, Code = await GetExternalCodeAsync(),
Type = GainfoUserTypeEnumType.External,
IdNo = item.IdNo, IdNo = item.IdNo,
Name = item.Name, Name = item.Name,
Company = request.Company, Source = request.Company,
Phone = item.Phone Phone = item.Phone
}; };
await _dbContext.InsertAsync(gainfoExternal); await _dbContext.InsertAsync(gainfo);
} }
else else
{ {
gainfoExternal.Phone = item.Phone; if (gainfo.Type == GainfoUserTypeEnumType.External)
gainfoExternal.Company = request.Company; {
gainfo.Source = request.Company;
gainfo.Phone = item.Phone;
await _dbContext.UpdateAsync(gainfoExternal); await _dbContext.UpdateAsync(gainfo);
}
} }
no = gainfoExternal.No; (gainfo.Type == GainfoUserTypeEnumType.External && request.IsEnterWorkplace && item.ImageUrl.IsEmpty()).ThrowIfTrue($"{item.Name}的社保照片不可为空");
}
var detail = new VisitorAppointmentDetailEntity var detail = new VisitorAppointmentDetailEntity
{ {
UserNo = no, UserNo = gainfo.No,
AppointmentId = id, AppointmentId = id,
No = request.No, No = request.No,
IdNo = item.IdNo,
Name = item.Name, Name = item.Name,
Phone = item.Phone, Phone = item.Phone,
Remark = item.Remark, Remark = item.Remark,
Status = AppointmentDetailEnumType.Wait, Status = AppointmentDetailEnumType.Wait,
IsExternal = isExternal,
LicensePlate = item.LicensePlate LicensePlate = item.LicensePlate
}; };
await _dbContext.InsertAsync(detail); await _dbContext.InsertAsync(detail);
} }
} }
private async Task<string> GetExternalCodeAsync()
{
await using var handler = await _redisCache.LockAsync("gainfo:external:code-generate", expiry: TimeSpan.FromSeconds(3), retryInterval: TimeSpan.FromSeconds(1), retryCount: 3);
handler.Acquired.ThrowIfFalse("生成虚拟工号失败");
int code;
var entity = await _dbContext.Queryable<GainfoEntity>()
.Where(x => x.Type == GainfoUserTypeEnumType.External && x.Code.StartsWith("EXT"))
.OrderBy(x => x.Id, OrderByType.Desc)
.FirstAsync();
if (entity == null)
{
code = 1;
}
else
{
code = int.Parse(entity.Code.Replace("EXT", "").TrimStart('0')) + 1;
}
return "EXT" + code.ToString().PadLeft(6, '0');
}
} }

View File

@@ -21,8 +21,6 @@ public class Startup : DefaultStartup
public override void ConfigureServices(IServiceCollection services) public override void ConfigureServices(IServiceCollection services)
{ {
base.ConfigureServices(services); base.ConfigureServices(services);
services.AddSqlSugar();
services.AddRedis(); services.AddRedis();
} }
} }

View File

@@ -243,7 +243,7 @@ public class GainfoUpdateService : IGainfoUpdateService
var info = new GainfoEntity var info = new GainfoEntity
{ {
No = Guid.NewGuid().ToString(), No = Guid.NewGuid().ToString(),
SapNo = item.PERNR, InternalNo = item.PERNR,
Type = GainfoUserTypeEnumType.Normal, Type = GainfoUserTypeEnumType.Normal,
Name = item.gname, Name = item.gname,
Code = item.ename, Code = item.ename,
@@ -311,7 +311,7 @@ public class GainfoUpdateService : IGainfoUpdateService
var factory = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM; var factory = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM;
await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
{ {
SapNo = item.PERNR, InternalNo = item.PERNR,
Name = item.gname, Name = item.gname,
PositionNo = item.STELL, PositionNo = item.STELL,
Grade = item.ZZ_ZD, Grade = item.ZZ_ZD,

View File

@@ -13,7 +13,7 @@ public class JinkoSapHttpClientPack : BaseAppPack
{ {
httpClient.Timeout = TimeSpan.FromMinutes(10); httpClient.Timeout = TimeSpan.FromMinutes(10);
var credentials = string.Format("{0}:{1}", "EHS_USER", "y3R1hd2h*RICAC"); var credentials = $"{"EHS_USER"}:{"y3R1hd2h*RICAC"}";
var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials)); var headerValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(credentials));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", headerValue);
}); });

View File

@@ -251,8 +251,7 @@ public class AssignmentService : IAssignmentService
.LeftJoin<GainfoEntity>((deviceTask, device, deviceTemplate, ga) => deviceTask.UserNo == ga.No) .LeftJoin<GainfoEntity>((deviceTask, device, deviceTemplate, ga) => deviceTask.UserNo == ga.No)
.LeftJoin<GainfoLeaveEntity>((deviceTask, device, deviceTemplate, ga, gaLeave) => deviceTask.UserNo == gaLeave.No) .LeftJoin<GainfoLeaveEntity>((deviceTask, device, deviceTemplate, ga, gaLeave) => deviceTask.UserNo == gaLeave.No)
.LeftJoin<DepartmentEntity>((deviceTask, device, deviceTemplate, ga, gaLeave, department) => department.No == ga.DepartmentNo) .LeftJoin<DepartmentEntity>((deviceTask, device, deviceTemplate, ga, gaLeave, department) => department.No == ga.DepartmentNo)
.LeftJoin<GainfoExternalEntity>((deviceTask, device, deviceTemplate, ga, gaLeave, department, gainfoEx) => deviceTask.UserNo == gainfoEx.No) .LeftJoin<DeviceRegistryEntity>((deviceTask, device, deviceTemplate, ga, gaLeave, department, deviceRegistry) => deviceRegistry.DeviceUniqueNo == deviceTask.DeviceUniqueNo)
.LeftJoin<DeviceRegistryEntity>((deviceTask, device, deviceTemplate, ga, gaLeave, department, gainfoEx, deviceRegistry) => deviceRegistry.DeviceUniqueNo == deviceTask.DeviceUniqueNo)
.Where((deviceTask, device) => device.Enable) .Where((deviceTask, device) => device.Enable)
.WhereIF(!request.IsProcess, deviceTask => deviceTask.Status == DeviceTaskStatusEnumType.Wait) .WhereIF(!request.IsProcess, deviceTask => deviceTask.Status == DeviceTaskStatusEnumType.Wait)
.WhereIF(request.IsProcess, deviceTask => deviceTask.Status == DeviceTaskStatusEnumType.Process .WhereIF(request.IsProcess, deviceTask => deviceTask.Status == DeviceTaskStatusEnumType.Process
@@ -261,14 +260,13 @@ public class AssignmentService : IAssignmentService
.WhereIF(factories.Any(), (deviceTask, device) => factories.Contains(deviceTask.TenantId)) .WhereIF(factories.Any(), (deviceTask, device) => factories.Contains(deviceTask.TenantId))
.WhereIF(request.Types.IsPresent(), deviceTask => request.Types.Contains(deviceTask.Type)) .WhereIF(request.Types.IsPresent(), deviceTask => request.Types.Contains(deviceTask.Type))
.WhereIF(request.Brand.IsPresent(), (deviceTask, device, deviceTemplate) => deviceTemplate.Brand == request.Brand) .WhereIF(request.Brand.IsPresent(), (deviceTask, device, deviceTemplate) => deviceTemplate.Brand == request.Brand)
.Where((deviceTask, device, deviceTemplate, ga, gaLeave, department, deviceRegistry) =>
#if !DEBUG
.Where((deviceTask, device, deviceTemplate, ga, gaLeave, department, gainfoEx, deviceRegistry) =>
device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) > DateTime.Now) device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) > DateTime.Now)
#endif #if !DEBUG
#endif
.OrderBy(deviceTask => new { Priority = SqlFunc.Desc(deviceTask.Priority), deviceTask.CreateTime }) .OrderBy(deviceTask => new { Priority = SqlFunc.Desc(deviceTask.Priority), deviceTask.CreateTime })
.Select((deviceTask, device, deviceTemplate, ga, gaLeave, department, gainfoEx) => new TaskDto .Select((deviceTask, device, deviceTemplate, ga, gaLeave, department) => new TaskDto
{ {
UserId = deviceTask.UserId == 0 || deviceTask.UserId == null UserId = deviceTask.UserId == 0 || deviceTask.UserId == null
? ga.Id == 0 ? ga.Id == 0
@@ -283,8 +281,8 @@ public class AssignmentService : IAssignmentService
Brand = deviceTemplate.Brand, Brand = deviceTemplate.Brand,
FuncStr = device.Funcs.ToString(), FuncStr = device.Funcs.ToString(),
UserNo = deviceTask.UserNo, UserNo = deviceTask.UserNo,
UserCode = SqlFunc.IsNull(SqlFunc.IsNull(ga.Code, gaLeave.Code), gainfoEx.Code), UserCode = SqlFunc.IsNull(ga.Code, gaLeave.Code),
UserName = SqlFunc.IsNull(SqlFunc.IsNull(ga.Name, gaLeave.Name), gainfoEx.Name), UserName = SqlFunc.IsNull(ga.Name, gaLeave.Name),
DepartmentNo = ga.DepartmentNo, DepartmentNo = ga.DepartmentNo,
DepartmentName = department.Name, DepartmentName = department.Name,
CardNo = ga.CardNo, CardNo = ga.CardNo,

View File

@@ -30,8 +30,7 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
.LeftJoin<DeviceEntity>((deviceTask, device) => deviceTask.DeviceUniqueNo == device.UniqueNo) .LeftJoin<DeviceEntity>((deviceTask, device) => deviceTask.DeviceUniqueNo == device.UniqueNo)
.LeftJoin<GainfoEntity>((deviceTask, device, ga) => deviceTask.UserNo == ga.No) .LeftJoin<GainfoEntity>((deviceTask, device, ga) => deviceTask.UserNo == ga.No)
.LeftJoin<GainfoLeaveEntity>((deviceTask, device, ga, gaLeave) => deviceTask.UserNo == gaLeave.No) .LeftJoin<GainfoLeaveEntity>((deviceTask, device, ga, gaLeave) => deviceTask.UserNo == gaLeave.No)
.LeftJoin<GainfoExternalEntity>((deviceTask, device, ga, gaLeave, gaEx) => deviceTask.UserNo == gaEx.No) .LeftJoin<DeviceRegistryEntity>((deviceTask, device, ga, gaLeave, deviceRegistry) => deviceRegistry.DeviceUniqueNo == deviceTask.DeviceUniqueNo)
.LeftJoin<DeviceRegistryEntity>((deviceTask, device, ga, gaLeave, gaEx, deviceRegistry) => deviceRegistry.DeviceUniqueNo == deviceTask.DeviceUniqueNo)
.Where(deviceTask => deviceTask.TenantId == request.Factory) .Where(deviceTask => deviceTask.TenantId == request.Factory)
.WhereIF(request.Type.HasValue, deviceTask => deviceTask.DeviceType == request.Type) .WhereIF(request.Type.HasValue, deviceTask => deviceTask.DeviceType == request.Type)
.WhereIF(request.SearchDateTimePeriod.HasValue(), deviceTask => deviceTask.ModifiedTime >= request.SearchDateTimePeriod.Start && deviceTask.ModifiedTime <= request.SearchDateTimePeriod.End .WhereIF(request.SearchDateTimePeriod.HasValue(), deviceTask => deviceTask.ModifiedTime >= request.SearchDateTimePeriod.Start && deviceTask.ModifiedTime <= request.SearchDateTimePeriod.End
@@ -44,12 +43,12 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
|| ga.Code == request.Search || ga.Code == request.Search
|| deviceTask.DeviceUniqueNo == request.Search || deviceTask.DeviceUniqueNo == request.Search
) )
.WhereIF(request.IsOffline.HasValue && request.IsOffline.Value, (deviceTask, device, ga, gaLeave, gaEx, deviceRegistry) => .WhereIF(request.IsOffline.HasValue && request.IsOffline.Value, (deviceTask, device, ga, gaLeave, deviceRegistry) =>
device.HeartbeatInterval != 0 && SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) < DateTime.Now) device.HeartbeatInterval != 0 && SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) < DateTime.Now)
.WhereIF(request.IsOffline.HasValue && !request.IsOffline.Value, (deviceTask, device, ga, gaLeave, gaEx, deviceRegistry) => .WhereIF(request.IsOffline.HasValue && !request.IsOffline.Value, (deviceTask, device, ga, gaLeave, deviceRegistry) =>
device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) >= DateTime.Now) device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) >= DateTime.Now)
.OrderBy(deviceTask => deviceTask.ModifiedTime, OrderByType.Desc) .OrderBy(deviceTask => deviceTask.ModifiedTime, OrderByType.Desc)
.Select((deviceTask, device, ga, gaLeave, gaEx, deviceRegistry) => new DeviceTaskAssignmentResponse .Select((deviceTask, device, ga, gaLeave, deviceRegistry) => new DeviceTaskAssignmentResponse
{ {
Id = deviceTask.Id, Id = deviceTask.Id,
DeviceUniqueNo = deviceTask.DeviceUniqueNo, DeviceUniqueNo = deviceTask.DeviceUniqueNo,
@@ -57,12 +56,8 @@ public class DeviceTaskAssignmentService : IDeviceTaskAssignmentService
RetryCount = deviceTask.Version, RetryCount = deviceTask.Version,
Status = deviceTask.Status, Status = deviceTask.Status,
UserNo = deviceTask.UserNo, UserNo = deviceTask.UserNo,
UserName = SqlFunc.IsNull(SqlFunc.IsNull(ga.Name, UserName = SqlFunc.IsNull(ga.Name, gaLeave.Name),
gaLeave.Name), UserCode = SqlFunc.IsNull(ga.Code, gaLeave.Code),
gaEx.Name),
UserCode = SqlFunc.IsNull(SqlFunc.IsNull(ga.Code,
gaLeave.Code),
gaEx.Code),
Type = deviceTask.Type, Type = deviceTask.Type,
CreateTime = deviceTask.CreateTime, CreateTime = deviceTask.CreateTime,
LastUpdateTime = deviceTask.ModifiedTime, LastUpdateTime = deviceTask.ModifiedTime,

View File

@@ -1,163 +0,0 @@
// 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 Dlhis.Visitor.Appointment.Request;
// using Dlhis.Visitor.Appointment.Response;
// 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.Visitor.Appointment.Services.Implements;
//
// public class AppointmentAreaService : IAppointmentAreaService
// {
// private readonly IDbContext _dbContext;
//
// public AppointmentAreaService(IDbContext dbContext)
// {
// _dbContext = dbContext;
// }
//
// public async Task<Pagination<ApponintmentAreaPageResponse>> GetPageAsync(PageDto request)
// {
// return await _dbContext.Queryable<AppointmentAreaEntity>()
// .Select<ApponintmentAreaPageResponse>()
// .ToPageListAsync(request);
// }
//
//
// public async Task SaveAsync(AppointmentAreaSaveRequest request)
// {
// await CheckCustomCodeDuplicateAsync(request);
//
// if (!request.Id.HasValue)
// {
// var entity = request.Adapt<AppointmentAreaEntity>();
// entity.Type = request.Type;
// entity.CustomCode = request.CustomCode;
//
// 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 DeleteAsync(long id)
// {
// var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == id).SingleAsync();
// await _dbContext.DeleteAsync(entity);
// }
//
//
// public async Task AssignAsync(AppointmentAreaAssignRequest request)
// {
// var userNos = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
// .LeftJoin<VisitorAppointmentEntity>((x, y) => x.No == y.No)
// .Where(x => x.Status == AppointmentDetailEnumType.Arrived)
// .Where((x, y) => y.AreaCustomCode == request.CustomCode)
// .Select(x => x.UserNo)
// .ToListAsync();
//
// //通过人
// var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
// .Where(x => x.CustomCode == request.CustomCode).Select(x => x.DeviceCode).ToListAsync();
//
// var userPermissions = userNos.ToDictionary(x => x, _ => deviceCodes.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);
//
//
// deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
// .Where(x => x.CustomCode == request.CustomCode).Select(x => x.DeviceCode).ToListAsync();
//
// var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).ToListAsync();
//
// var userCurrentPermissions = userNos.ToDictionary(x => x, _ => deviceCodes.ToList());
//
// var tasks = new List<DeviceTaskEntity>();
// foreach (var userNo in userNos)
// {
// var before = userPermissions[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 ***************************************************************
//
//
// /// <summary>
// /// 检查编码重复
// /// </summary>
// /// <param name="request"></param>
// /// <returns></returns>
// private async Task CheckCustomCodeDuplicateAsync(AppointmentAreaSaveRequest request)
// {
// var exists = await _dbContext.Queryable<AppointmentAreaEntity>()
// .Where(x => x.CustomCode == request.CustomCode)
// .WhereIF(request.Id.HasValue, x => x.Id == request.Id)
// .AnyAsync();
//
// exists.ThrowIfTrue("重复区域编码,请检查");
// }
// }

View File

@@ -1,24 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<Folder Include="Appointment\Response\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,24 +0,0 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Src/Dlhis.Visitor/Dlhis.Visitor.csproj", "Src/Dlhis.Visitor/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
RUN dotnet restore "./Src/Dlhis.Visitor/./Dlhis.Visitor.csproj"
COPY . .
WORKDIR "/src/Src/Dlhis.Visitor"
RUN dotnet build "./Dlhis.Visitor.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Dlhis.Visitor.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Dlhis.Visitor.dll"]

View File

@@ -1,20 +0,0 @@
using Kurisu.AspNetCore.Startup;
using Microsoft.IdentityModel.Logging;
namespace Dlhis.Visitor;
class Program
{
static void Main(string[] args)
{
KurisuHost.Run<Startup>(args);
}
}
public class Startup : DefaultStartup
{
public Startup(IConfiguration configuration) : base(configuration)
{
IdentityModelEventSource.ShowPII = true;
}
}

View File

@@ -1,22 +0,0 @@
{
"profiles": {
"Dlhis.Visitor": {
"commandName": "Project",
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5021"
},
"Docker": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast",
"environmentVariables": {
"ASPNETCORE_URLS": "http://+:80"
},
"publishAllPorts": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json"
}

View File

@@ -1,35 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"InternalRequest": {
"BasicRequestUrl": "http://localhost:5002"
},
"SwaggerOptions": {
"Enable": true,
"Authority": "https://yikatong.isawesome.cn/oauth2",
"ClientId": "4fb184324eac4180",
"ClientSecret": "8ac8f235152f1524",
"Scopes": {
"openid": "openid",
"profile": "profile",
"yikatong": "yikatong"
}
},
"IdentityServerOptions": {
"Authority": "https://yikatong.isawesome.cn/oauth2",
"RequireHttpsMetadata": true,
"Issuer": "identity.isawesome.cn",
"Audience": ""
},
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"SlaveConnectionString": [],
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": true
}
}

View File

@@ -1,82 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"InternalRequest": {
"BasicRequestUrl": "http://basic"
},
"AllowedHosts": "*",
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"SlaveConnectionString": [],
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": false
},
"RedisOptions": {
"ConnectionString": "192.168.199.30:30115,defaultDatabase=1,password=dlhis123"
},
"DataProtectionOptions": {
"Enable": true,
"AppName": "yiliantong"
},
"SwaggerOptions": {
"Enable": true,
"Authority": "http://identity.oauth.svc.cluster.local",
"ClientId": "4fb184324eac4180",
"ClientSecret": "8ac8f235152f1524",
"Scopes": {
"openid": "openid",
"profile": "profile",
"yikatong": "yikatong"
}
},
"IdentityServerOptions": {
"Authority": "http://identity.oauth.svc.cluster.local",
"RequireHttpsMetadata": false,
"Issuer": "identity.isawesome.cn",
"Audience": "",
"Pat": {
"Enable": false,
"Scheme": "token",
"ClientId": "reference",
"ClientSecret": "123456"
}
},
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"System": "Warning",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"WriteTo": [
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "MySQL",
"Args": {
"connectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=logs;charset=utf8mb4;",
"tableName": "Logs",
"autoCreateSqlTable": true
}
}
]
}
}
]
}
}