From d1b757d4fb6d5063bf930b72fb38421a468ce8b6 Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Thu, 22 Dec 2022 12:12:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8E=8B=E7=BC=A9=E6=96=87=E4=BB=B6=E5=90=8E=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=85=A7=E7=89=87=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StuInfoBasicController.cs | 35 ++++++++++++++- .../Views/StuInfoBasic/Index.js | 21 +++++++-- .../Views/StuInfoBasic/SynPhotoForm.cshtml | 12 ++++++ .../Views/StuInfoBasic/SynPhotoForm.js | 43 +++++++++++++++++++ .../Learun.Application.Web.csproj | 2 + .../StuInfoBasic/StuInfoBasicService.cs | 37 ++++++++++------ 6 files changed, 132 insertions(+), 18 deletions(-) create mode 100644 Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.cshtml create mode 100644 Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.js diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs index 8dd58a724..480de80cd 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using Learun.Application.Base.SystemModule; using static Learun.Application.TwoDevelopment.EducationalAdministration.StuInfoBasicEntity; +using ZipOneCode.ZipProvider; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { @@ -274,6 +275,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { return View(); } + + /// + /// 压缩包同步照片页面 + /// + /// + [HttpGet] + public ActionResult SynPhotoForm() + { + return View(); + } #endregion @@ -747,10 +758,30 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers /// [HttpGet] [AjaxOnly] - public ActionResult SynPhoto() + public ActionResult SynPhoto(string folderId) { - stuInfoBasicIBLL.SynPhoto(); + //一、服务器中照片直接同步 + //stuInfoBasicIBLL.SynPhoto(); + //return Success("同步成功!"); + + //二、上传压缩文件后同步照片 + //找到附件地址-多个,解压到目标文件夹,解压成功后同步照片,否则提示; + var annexFileList = annexesFileIbll.GetList(folderId); + if (annexFileList.Any()) + { + var targetPath = Config.GetValue("AnnexesFile") + "/UserPhoto"; + foreach (var item in annexFileList) + { + var result = ZipHelper.UnZip(item.F_FilePath, targetPath); + if (!result) + { + return Fail($"{item.F_FileName}文件解压失败,同步中止!"); + } + } + stuInfoBasicIBLL.SynPhoto(); + } return Success("同步成功!"); + } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js index f0a831e5d..541497ffb 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js @@ -322,10 +322,23 @@ var bootstrap = function ($, learun) { }) //同步照片 $('#lr_synPhoto').on('click', function () { - learun.loading(true, '正在同步,请稍后') - learun.httpAsync('get', top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/SynPhoto', {}, function (res) { - learun.loading(false) - }) + //一、服务器中照片直接同步 + //learun.loading(true, '正在同步,请稍后') + //learun.httpAsync('get', top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/SynPhoto', {}, function (res) { + // learun.loading(false) + //}) + //二、上传压缩文件后同步照片 + learun.layerForm({ + id: 'SynPhotoForm', + title: '同步照片', + url: top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/SynPhotoForm', + width: 800, + height: 600, + callBack: function (id) { + return top[id].acceptClick(refreshGirdData); + } + }); + }) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.cshtml new file mode 100644 index 000000000..26cbb5fef --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.cshtml @@ -0,0 +1,12 @@ +@{ + ViewBag.Title = "压缩包同步照片"; + Layout = "~/Views/Shared/_Form.cshtml"; +} +
+
+
照片压缩文件*
+
+
+ +
+@Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.js new file mode 100644 index 000000000..5b1d375eb --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/SynPhotoForm.js @@ -0,0 +1,43 @@ +/* * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) + * Copyright (c) 2013-2018 北京泉江科技有限公司 + * 创建人:超级管理员 + * 日 期:2019-02-21 16:53 + * 描 述:压缩包同步照片 + */ +var acceptClick; +var bootstrap = function ($, learun) { + "use strict"; + var page = { + init: function () { + $('.lr-form-wrap').lrscroll(); + page.bind(); + page.initData(); + }, + bind: function () { + $('#Photo').lrUploader(); + }, + initData: function () { + + } + }; + // 保存数据 + acceptClick = function (callBack) { + if (!$('body').lrValidform()) { + return false; + } + var Photo = $('#Photo').lrUploaderGet(); + console.log(Photo); + + return false; + + + //$.lrSaveForm(top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/SynPhoto?fileId=' + keyValue, postData, function (res) { + // // 保存成功后才回调 + // if (!!callBack) { + // callBack(); + // } + //}); + }; + page.init(); + +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index fd925a48c..494ef5a96 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1216,6 +1216,7 @@ + @@ -1322,6 +1323,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs index 59eacba08..0c66b4c5f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs @@ -13,6 +13,7 @@ using Learun.Application.Base.SystemModule; using Learun.Application.TwoDevelopment.LogisticsManagement; using Learun.Cache.Base; using Learun.Cache.Factory; +using System.IO; namespace Learun.Application.TwoDevelopment.EducationalAdministration { @@ -572,49 +573,61 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration { try { - var stuList = this.BaseRepository("CollegeMIS").FindList() - .ToList(); - var url = AppDomain.CurrentDomain.BaseDirectory; + var stuList = this.BaseRepository("CollegeMIS").FindList().ToList(); + var url = Config.GetValue("AnnexesFile"); + var loginUserInfo = LoginUserInfo.Get(); foreach (var stuInfo in stuList) { //判断要上传的照片在本地服务器中是否存在 - var photoPath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg"; + var photoPath = $"{url}/UserPhoto/{stuInfo.IdentityCardNo}.jpg"; if (System.IO.File.Exists(photoPath)) { //学籍表中照片字段不为空 if (!string.IsNullOrEmpty(stuInfo.Photo)) { - var annex = this.BaseRepository() - .FindEntity(a => a.F_FolderId == stuInfo.Photo); + var annex = this.BaseRepository().FindEntity(a => a.F_FolderId == stuInfo.Photo); if (annex == null) { var annexEntity = new AnnexesFileEntity() { F_Id = Guid.NewGuid().ToString(), + F_FolderId = stuInfo.Photo, F_FileName = stuInfo.IdentityCardNo + ".jpg", - F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg", - F_FolderId = stuInfo.Photo + F_FilePath = photoPath, + F_FileExtensions = ".jpg", + F_FileType = "jpg", + F_CreateUserId = loginUserInfo.userId, + F_CreateUserName = loginUserInfo.realName }; + annexEntity.Create(); this.BaseRepository().Insert(annexEntity); } else { annex.F_FileName = stuInfo.IdentityCardNo + ".jpg"; - annex.F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg"; + annex.F_FilePath = photoPath; + annex.F_CreateDate = DateTime.Now; + annex.F_CreateUserId = loginUserInfo.userId; + annex.F_CreateUserName = loginUserInfo.realName; this.BaseRepository().Update(annex); } } else { + //学籍表 stuInfo.Photo = Guid.NewGuid().ToString(); - + //附件表 var annexEntity = new AnnexesFileEntity() { F_Id = Guid.NewGuid().ToString(), + F_FolderId = stuInfo.Photo, F_FileName = stuInfo.IdentityCardNo + ".jpg", - F_FilePath = $"{url}/Resource/UserPhoto/{stuInfo.IdentityCardNo}.jpg", - F_FolderId = stuInfo.Photo + F_FilePath = photoPath, + F_FileExtensions = ".jpg", + F_FileType = "jpg", + F_CreateUserId = loginUserInfo.userId, + F_CreateUserName = loginUserInfo.realName }; annexEntity.Create(); this.BaseRepository("CollegeMIS").Update(stuInfo);