diff --git a/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs b/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs index 84fd7c5..5a58a25 100644 --- a/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs +++ b/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs @@ -92,8 +92,6 @@ namespace Shentun.Peis.RegisterCheckPictures public async Task UpdateRegisterCheckPictureStatusManyAsync(List input) { - // - if (!input.Any()) { throw new UserFriendlyException("请求参数有误"); @@ -107,7 +105,6 @@ namespace Shentun.Peis.RegisterCheckPictures foreach (var item in input) { - //修改 var ent = await _registerCheckPictureRepository.FirstOrDefaultAsync(m => m.Id == item.RegisterCheckPictureId); if (ent != null) { @@ -160,9 +157,7 @@ namespace Shentun.Peis.RegisterCheckPictures { throw new UserFriendlyException("体检人员不存在"); } - - // string PicName = DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(1000, 9999); - + List entlist_insert = new List(); @@ -183,24 +178,33 @@ namespace Shentun.Peis.RegisterCheckPictures throw new UserFriendlyException("图片数据有误"); } - var ent = new RegisterCheckPicture - { - DisplayOrder = input.PictureBaseStrs.IndexOf(item) + 1, - IsPrint = 'N', - PictureFilename = PictureUrl, - RegisterCheckId = input.RegisterCheckId - }; + var ent = await _registerCheckPictureRepository.FirstOrDefaultAsync(m => m.RegisterCheckId == input.RegisterCheckId + && m.PictureFilename == PictureUrl); - entlist_insert.Add(ent); + if (ent != null) + { + ent.PictureFilename = PictureUrl; + await _registerCheckPictureRepository.UpdateAsync(ent); + } + else + { + ent = new RegisterCheckPicture + { + DisplayOrder = input.PictureBaseStrs.IndexOf(item) + 1, + IsPrint = 'N', + PictureFilename = PictureUrl, + RegisterCheckId = input.RegisterCheckId + }; + + await _registerCheckPictureRepository.InsertAsync(ent); + } + msg.Add(PictureUrl); } - if (entlist_insert.Any()) - { - await _registerCheckPictureRepository.InsertManyAsync(entlist_insert); - } + return msg; }