From 38aea9bbc56f376c974d7b90d05c09cf56a5d293 Mon Sep 17 00:00:00 2001 From: yhw0507 Date: Thu, 21 Dec 2023 14:28:47 +0800 Subject: [PATCH] =?UTF-8?q?20231221=E8=8E=B7=E5=8F=96=E9=97=A8=E7=A6=81?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=85=A7=E7=89=87=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoorProject/uploadController.cs | 53 ++++++++++++++++--- SGGL/WebAPI/WebAPI.csproj | 2 +- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs index 65f47951..a3886a51 100644 --- a/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs +++ b/SGGL/WebAPI/Controllers/DoorProject/uploadController.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Web.Http; using BLL; +using Model; using WebAPI.Filter; namespace WebAPI.Controllers @@ -235,7 +236,15 @@ namespace WebAPI.Controllers newPerson.AuditorDate = DateTime.Now; } newPerson.OutTime = Funs.GetNewDateTime(person.OutTime); - if (person.headImage != null) + if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl)) + { + var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl); + if (getS != null) + { + person.headImage = getS.ToString(); + } + } + if (person.headImage.Length > 0) { var image = Convert.FromBase64String(person.headImage); newPerson.HeadImage = image; @@ -257,15 +266,47 @@ namespace WebAPI.Controllers } else { - if (!string.IsNullOrEmpty(person.OutTime)) + if (string.IsNullOrEmpty(getPerson.PhotoUrl) && (person.headImage.Length > 0 || !string.IsNullOrEmpty(person.PhotoUrl))) { - var outTime = Funs.GetNewDateTimeOrNow(person.OutTime); - PersonService.PersonOut(getPerson.PersonId, outTime); - responeData.message = "更新出场时间"; + if (person.headImage.Length == 0 && !string.IsNullOrEmpty(person.PhotoUrl)) + { + var getS = AttachFileService.SetImageToByteArray(person.PhotoUrl); + if (getS != null) + { + person.headImage = getS.ToString(); + } + } + if (person.headImage.Length > 0) + { + var image = Convert.FromBase64String(person.headImage); + getPerson.HeadImage = image; + string rootPath = ConfigurationManager.AppSettings["localRoot"]; + string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/"; + string fileUrl = (rootPath + path).Replace('/', '\\'); + string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg"; + if (!Directory.Exists(fileUrl)) + { + Directory.CreateDirectory(fileUrl); + } + getPerson.PhotoUrl = path + flieName; + System.IO.File.WriteAllBytes((fileUrl + flieName), image); + //AttachFileService.Base64ToImage(person.headImage, path, person.PersonName); + } + db.SubmitChanges(); + responeData.message = "更新照片!"; } else { - responeData.message = "该身份证号码人员已存在!"; + if (!string.IsNullOrEmpty(person.OutTime)) + { + var outTime = Funs.GetNewDateTimeOrNow(person.OutTime); + PersonService.PersonOut(getPerson.PersonId, outTime); + responeData.message = "更新出场时间"; + } + else + { + responeData.message = "该身份证号码人员已存在!"; + } } } } diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj index 1da74a06..baa3a8a3 100644 --- a/SGGL/WebAPI/WebAPI.csproj +++ b/SGGL/WebAPI/WebAPI.csproj @@ -324,7 +324,7 @@ True 0 / - http://localhost:10684/ + http://localhost:14957/ False False