From d400b33ea98059e30ef4415d86298c7e2c818846 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 21 Oct 2024 15:28:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=B8=AD=E6=96=87=E5=B7=A5=E5=8F=B7?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=AF=BC=E5=85=A5,=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=B7=B2=E5=AF=BC=E5=85=A5=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Request/GainfoOutsourceRequest.cs | 11 ++++++ .../Implements/GainfoOutsourceService.cs | 35 ++++++++++--------- 2 files changed, 30 insertions(+), 16 deletions(-) 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