fix 中文工号禁止导入,过滤已导入人员

This commit is contained in:
2024-10-21 15:28:10 +08:00
parent b0c97fb9bb
commit d400b33ea9
2 changed files with 30 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;
using Dlhis.Basic.Organization.Dto; using Dlhis.Basic.Organization.Dto;
using Dlhis.Entity.Basic.Enums; using Dlhis.Entity.Basic.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Organization.Request; namespace Dlhis.Basic.Organization.Request;
@@ -76,5 +78,14 @@ public class GainfoOutsourceRequest : IValidatableObject
{ {
yield return new ValidationResult("工号和对接人工号不可相同", new[] { nameof(Code) }); yield return new ValidationResult("工号和对接人工号不可相同", new[] { nameof(Code) });
} }
const string containChineseRule = "[\u4e00-\u9fa5]";
if (Code.IsPresent())
{
if (Regex.IsMatch(Code, containChineseRule))
{
yield return new ValidationResult($"工号[{Code}]不能包含中文", new[] { nameof(Code) });
}
}
} }
} }

View File

@@ -35,24 +35,27 @@ public class GainfoOutsourceService : IGainfoOutsourceService
if (!request.Id.HasValue) if (!request.Id.HasValue)
{ {
var entity = request.Adapt<GainfoEntity>(); if (!await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == request.IdNo).AnyAsync())
entity.No = Guid.NewGuid().ToString();
entity.Type = GainfoUserTypeEnumType.Outsource;
entity.Code = request.Code.IsPresent()
? request.Code
: await GetOutSourceCodeAsync();
await _dbContext.InsertAsync(entity);
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
{ {
await _dbContext.InsertAsync(new OutsourceEntity var entity = request.Adapt<GainfoEntity>();
entity.No = Guid.NewGuid().ToString();
entity.Type = GainfoUserTypeEnumType.Outsource;
entity.Code = request.Code.IsPresent()
? request.Code
: await GetOutSourceCodeAsync();
await _dbContext.InsertAsync(entity);
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
{ {
Code = entity.Code, await _dbContext.InsertAsync(new OutsourceEntity
Supplier = request.ExternalInfo.Supplier, {
SapCode = request.ExternalInfo.SapCode, Code = entity.Code,
SapPhone = request.ExternalInfo.SapPhone Supplier = request.ExternalInfo.Supplier,
}); SapCode = request.ExternalInfo.SapCode,
SapPhone = request.ExternalInfo.SapPhone
});
}
} }
} }
else else