diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoOutsourceRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoOutsourceRequest.cs index c2b33a89..4cce07ed 100644 --- a/Src/Dlhis.Basic/Organization/Request/GainfoOutsourceRequest.cs +++ b/Src/Dlhis.Basic/Organization/Request/GainfoOutsourceRequest.cs @@ -1,6 +1,8 @@ using System.ComponentModel.DataAnnotations; +using System.Text.RegularExpressions; using Dlhis.Basic.Organization.Dto; using Dlhis.Entity.Basic.Enums; +using Kurisu.AspNetCore.Utils.Extensions; namespace Dlhis.Basic.Organization.Request; @@ -76,5 +78,14 @@ public class GainfoOutsourceRequest : IValidatableObject { 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) }); + } + } } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs index db1866e6..f48d64df 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoOutsourceService.cs @@ -35,24 +35,27 @@ public class GainfoOutsourceService : IGainfoOutsourceService if (!request.Id.HasValue) { - var entity = request.Adapt(); - 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().Where(x => x.Code == entity.Code).AnyAsync()) + if (!await _dbContext.Queryable().Where(x => x.IdNo == request.IdNo).AnyAsync()) { - await _dbContext.InsertAsync(new OutsourceEntity + var entity = request.Adapt(); + 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().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