diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs index 24e3ad8cf..144b80a81 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs @@ -8,6 +8,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Linq; +using System.IO; +using Learun.Application.Base.SystemModule; namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers { @@ -21,6 +23,7 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers public class AccommodationController : MvcControllerBase { private AccommodationIBLL accommodationIBLL = new AccommodationBLL(); + private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); #region 视图功能 @@ -208,6 +211,25 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers return View(); } + /// + /// 分类管理 + /// + /// + [HttpGet] + public ActionResult ClearForm() + { + return View(); + } + + /// + /// 导入宿舍 + /// + /// + [HttpGet] + public ActionResult IndexImport() + { + return View(); + } #endregion @@ -521,6 +543,67 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers return Success("同步成功"); } + /// + /// 按条件清空 + /// + /// + public ActionResult StudentClear(string Grade) + { + accommodationIBLL.ClearEntity(Grade); + return Success("清空成功"); + } + + /// + /// 宿舍信息导入模板 + /// + /// + public ActionResult DownTemplate() + { + FileStreamResult result = null; + try + { + var path = Server.MapPath("~/Content/excel/"); + var pathoffull = path + "AccommodationImport.xls"; + FileStream fsread = fsread = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.ReadWrite); + result = File(fsread, "application/ms-excel", "宿舍信息导入.xls"); + + return result; + } + catch (Exception ex) + { + return null; + } + } + + + /// + /// 宿舍信息excel文件导入 + /// + /// + /// + /// + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult ExecuteImportExcel(string fileGuid, int chunks) + { + string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get()); + if (!string.IsNullOrEmpty(path)) + { + DataTable dt = ExcelHelper.ExcelImport(path); + var res = accommodationIBLL.ExecuteImportExcel(dt, fileGuid); + var data = new + { + Success = res.snum, + Fail = res.failDt.Rows.Count + }; + return Success(data); + } + else + { + return Fail("导入数据失败!"); + } + } + #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.cshtml index 100ee31f8..5e7a175f9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.cshtml @@ -11,17 +11,25 @@
推送人*
-
+
推送班主任*
-
+
+
+
+
推送辅导员*
+
+
+
+
推送保卫处*
+
+
+
+
启用*
+
推送时间点*
-
-
启用*
-
-
@Html.AppendJsFile("/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.js index 2dab9f792..4dcf7d09e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Form.js @@ -27,6 +27,15 @@ var bootstrap = function ($, learun) { type: 'radio', code: 'YesOrNoInt', }); + $('#CoachTeach').lrRadioCheckbox({ + type: 'radio', + code: 'YesOrNoInt', + }); + $('#Defend').lrRadioCheckbox({ + type: 'radio', + code: 'YesOrNoInt', + }); + }, initData: function () { if (!!keyValue) { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Index.js index 4b81ce7c9..0a1045d87 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_DormitoryRule/Index.js @@ -71,7 +71,7 @@ var bootstrap = function ($, learun) { headData: [ { label: "晚归时间", name: "LateReturnTime", width: 100, align: "left" }, { - label: "推送人", name: "PushUser", width: 200, align: "left", + label: "推送人", name: "PushUser", width: 400, align: "left", formatterAsync: function (callback, value, row, op, $cell) { if (value.indexOf(',') != -1) { var content = ''; @@ -83,7 +83,7 @@ var bootstrap = function ($, learun) { key: timearr[i], keyId: 'f_userid', callback: function (_data) { - content += _data['f_realname']; + content += _data['f_realname'] + ","; } }); } @@ -113,6 +113,30 @@ var bootstrap = function ($, learun) { }); } }, + { + label: "推送辅导员", name: "CoachTeach", width: 100, align: "left", + formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('dataItem', { + key: value, + code: 'YesOrNoInt', + callback: function (_data) { + callback(_data.text); + } + }); + } + }, + { + label: "推送保卫处", name: "Defend", width: 100, align: "left", + formatterAsync: function (callback, value, row, op, $cell) { + learun.clientdata.getAsync('dataItem', { + key: value, + code: 'YesOrNoInt', + callback: function (_data) { + callback(_data.text); + } + }); + } + }, { label: "推送时间点", name: "PushHour", width: 100, align: "left" }, { label: "启用", name: "IsEnable", width: 100, align: "left", diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_Punishment/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_Punishment/Index.js index 0192b5074..22fe3aa2a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_Punishment/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Acc_Punishment/Index.js @@ -148,9 +148,9 @@ var bootstrap = function ($, learun) { }); } }, - { label: "奖励", name: "RewardContent", width: 100, align: "left" }, - { label: "奖励时间", name: "RTime", width: 100, align: "left" }, - { label: "奖励原因", name: "RReason", width: 100, align: "left" }, + { label: "惩罚", name: "RewardContent", width: 100, align: "left" }, + { label: "惩罚时间", name: "RTime", width: 100, align: "left" }, + { label: "惩罚原因", name: "RReason", width: 100, align: "left" }, ], mainId: 'ID', isPage: true diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.cshtml new file mode 100644 index 000000000..100f49f0c --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.cshtml @@ -0,0 +1,11 @@ +@{ + ViewBag.Title = "开课计划"; + Layout = "~/Views/Shared/_Form.cshtml"; +} +
+
+
年级*
+
+
+
+@Html.AppendJsFile("/Areas/LogisticsManagement/Views/Accommodation/ClearForm.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.js new file mode 100644 index 000000000..d8e83ff7d --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/ClearForm.js @@ -0,0 +1,37 @@ +/* * 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架(http://www.learun.cn) + * Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 + * 创建人:超级管理员 + * 日 期:2021-11-29 11:43 + * 描 述:开课计划 + */ +var acceptClick; +var keyValue = request('keyValue'); +var bootstrap = function ($, learun) { + "use strict"; + var page = { + init: function () { + $('.lr-form-wrap').lrscroll(); + page.bind(); + }, + bind: function () { + $('#Grade').lrselect({ + url: top.$.rootUrl + '/EducationalAdministration/ClassInfo/GenerateNearByYear', + value: 'value', + text: 'text', + allowSearch: true + }); + } + }; + // 保存数据 + acceptClick = function (callBack) { + if (!$('body').lrValidform()) { + return false; + } + var postData = $('#form').lrGetFormData(); + var Grade = postData.Grade; + learun.postForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/StudentClear', { Grade: Grade }, function () { + learun.frameTab.currentIframe().refreshGirdData() + }); + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Corridor.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Corridor.cshtml index 1b54c106e..a6de56ca7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Corridor.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Corridor.cshtml @@ -45,11 +45,6 @@ left: 0px; width: 228px } - .indSec1T > a { - width: fit-content; - padding-left: 6px; - padding-right: 6px; - } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Dormitory.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Dormitory.cshtml index 45a61029c..2af49c720 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Dormitory.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Dormitory.cshtml @@ -103,7 +103,7 @@
独卫
-
+
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Floor.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Floor.cshtml index 99ada60d1..06d008f5d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Floor.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Floor.cshtml @@ -168,12 +168,7 @@ key: value, keyId: 'f_companyid', callback: function (_data) { - if (!_data.f_fullname || _data.f_fullname == '' || _data.f_fullname == 'undefined') { - result = ''; - } - else { - result = _data.f_fullname; - } + result = _data.f_fullname; } }); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Form.js index fdda26390..38b25fdd2 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Form.js @@ -97,19 +97,16 @@ var bootstrap = function ($, learun) { initData: function () { if (!!keyValue) { - $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + keyValue, - function(data) { - for (var id in data) { - if (!!data[id].length && data[id].length > 0) { - $('#' + id).jfGridSet('refreshdata', data[id]); - } else { - $('[data-table="' + id + '"]').lrSetFormData(data[id]); - } + $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + keyValue, function (data) { + for (var id in data) { + if (!!data[id].length && data[id].length > 0) { + $('#' + id).jfGridSet('refreshdata', data[id]); } - }); - } else { - $('#BuildType').lrselectSet('4'); - $('#BuildType').attr('readonly', 'readonly'); + else { + $('[data-table="' + id + '"]').lrSetFormData(data[id]); + } + } + }); } }, initSelect: function () { @@ -125,7 +122,6 @@ var bootstrap = function ($, learun) { param: { parentId: '0' }, } $('#Campus').lrselect(dfop); - $('#Campus').lrselectSet(learun.clientdata.get(['userinfo']).companyId); } }; diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClass.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClass.js index 4a3fd0578..ab7e16d53 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClass.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClass.js @@ -19,12 +19,14 @@ var bootstrap = function ($, learun) { $('#Class').lrselect({ value: "classno", - text: "classname" + text: "classname", + allowSearch: true }); $('#Major').lrselect({ value: "majorno", text: "majorname", + allowSearch: true, url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', param: { code: "CdMajorInfo", strWhere: "DeptNo='" + Dept + "'" }, select: function (item) { @@ -50,7 +52,8 @@ var bootstrap = function ($, learun) { }, initData: function () { if (!!keyValue) { - $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + keyValue, function (data) { + var kv = keyValue.split(',')[0]; + $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + kv, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClassify.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClassify.js index c530fc983..878fe4fc5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClassify.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormClassify.js @@ -25,7 +25,7 @@ var bootstrap = function ($, learun) { allowSearch: true, maxHeight: 225, select: function (item) { - if (item && item.id != '-1') { + if (item&&item.id!='-1') { $('#BuildType').lrselectSet(item.title); $('#BuildType').attr('readonly', 'readonly'); } else { @@ -43,7 +43,7 @@ var bootstrap = function ($, learun) { type: 'radio', code: 'HasToilet', }) - + //$('#StudentID').lrDataSourceSelect({ code: 'StuInfoBasic', value: 'stuid', text: 'stuname' }); //$('#StudentID').lrDataSourceSelect({ code: 'StuInfoTwo', value: 'stuid', text: 'stuname' }); $('#StudentID').lrselect({ @@ -51,7 +51,7 @@ var bootstrap = function ($, learun) { text: "stuname", url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable?code=StuInfoBasic' }); - + $('#Class').lrselect({ value: "classno", text: "classname" @@ -115,7 +115,7 @@ var bootstrap = function ($, learun) { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + keyValue, - function (data) { + function(data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); @@ -126,7 +126,6 @@ var bootstrap = function ($, learun) { }); } else { $('#ParentID').lrselectSet(ParentID); - $('#ParentID').attr('readonly', 'readonly'); } }, initSelect: function () { @@ -142,7 +141,7 @@ var bootstrap = function ($, learun) { param: { parentId: '0' }, } $('#Campus').lrselect(dfop); - $('#Campus').lrselectSet(learun.clientdata.get(['userinfo']).companyId); + } }; // 保存数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormDept.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormDept.js index f945452d6..1daa1164a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormDept.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormDept.js @@ -24,7 +24,8 @@ var bootstrap = function ($, learun) { }, initData: function () { if (!!keyValue) { - $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + keyValue, function (data) { + var kv = keyValue.split(',')[0]; + $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetFormData?keyValue=' + kv, function (data) { for (var id in data) { if (!!data[id].length && data[id].length > 0) { $('#' + id).jfGridSet('refreshdata', data[id]); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml index d4664f16f..49bced24d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml @@ -67,7 +67,7 @@  批量添加宿舍  床位管理 - @* 自动分配宿舍 + @* 自动分配宿舍  同步宿舍信息*@
@@ -79,6 +79,9 @@
 分类管理
+
+  导入 +
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.js index ff87bf30a..6df688c8f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.js @@ -280,6 +280,22 @@ var bootstrap = function ($, learun) { } }); }); + + //导入 + $("#lr_importBed").on("click", function () { + learun.layerForm({ + id: 'indexImport', + title: "导入宿舍信息", + url: top.$.rootUrl + '/LogisticsManagement/Accommodation/IndexImport', + width: 600, + height: 400, + maxmin: true, + btn: null, + end: function () { + refreshGirdData(); + } + }); + }); }, //初始化左侧树 initTree: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.cshtml index 2b92a19cb..262f931ab 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.cshtml @@ -80,6 +80,7 @@  分配系  分配专业班级  分配宿舍 +  按年级清空  打印 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js index 71a969a6d..94c88de0f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js @@ -271,7 +271,7 @@ var bootstrap = function ($, learun) { if (arrDept.some(function (value, index) { return value != arrDept[0]; })) { - return learun.alert.warning("选中记录包含多种专业的数据,不可批量分配班级!"); + return learun.alert.warning("选中记录包含多种系的数据,不可批量分配班级!"); } } learun.layerForm({ @@ -308,14 +308,26 @@ var bootstrap = function ($, learun) { id: 'formRoom', title: '分配宿舍--' + Name, url: top.$.rootUrl + '/LogisticsManagement/Accommodation/FormRoom?keyValue=' + keyValue + '&Class=' + Class + '&Sex=' + Sex, - width: 600, - height: 400, + width: 800, + height: 600, callBack: function (id) { return top[id].acceptClick(refreshGirdData); } }); }); - + //清空 + $("#lr_Clear").on("click", function () { + learun.layerForm({ + id: 'form', + title: '按年级清空', + url: top.$.rootUrl + '/LogisticsManagement/Accommodation/ClearForm', + width: 400, + height: 300, + callBack: function (id) { + return top[id].acceptClick(); + } + }); + }); }, //初始化左侧树 initTree: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.cshtml new file mode 100644 index 000000000..ea6c5f2f7 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.cshtml @@ -0,0 +1,26 @@ +@{ + ViewBag.Title = "Form"; + Layout = "~/Views/Shared/_Form.cshtml"; +} + + +@Html.AppendCssFile("/Areas/LR_SystemModule/Views/ExcelImport/ImportForm.css") + +
+
+
上传文件
+
下载模板
+
+
+
+
+ +
+
+

试试将电脑里的文件拖拽到此上传

+
+
+
+
+ +@Html.AppendJsFile("/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js new file mode 100644 index 000000000..8795c6ee4 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js @@ -0,0 +1,180 @@ +/* + * 描 述:附件上传管理 + */ +var CLId = request('CLId'); + +var bootstrap = function ($, learun) { + "use strict"; + var fileInfo = {}; + + // 触发合并文件碎片 + var mergeFileChunks = function (file) { + var param = {}; + param['__RequestVerificationToken'] = $.lrToken; + //param['CLId'] = CLId; + param['fileGuid'] = fileInfo[file.id].fileGuid; + param['fileName'] = fileInfo[file.id].name; + param['chunks'] = fileInfo[file.id].chunks; + learun.httpAsyncPost(top.$.rootUrl + "/LogisticsManagement/Accommodation/ExecuteImportExcel", param, function (res) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress').remove(); + + if (res.code == learun.httpCode.success) { + if (res.data.Success != '0') { + learun.alert.success('导入成功' + res.data.Success + '条'); + } + // 文件保存成功后 + $fileItem.append('
' + res.data.Success + '/' + res.data.Fail + '
'); + // 如果有失败 + if (res.data.Fail != '0') + { + learun.download({ url: top.$.rootUrl + '/LR_SystemModule/ExcelImport/DownImportErrorFile', param: { fileId: fileInfo[file.id].fileGuid, fileName: fileInfo[file.id].name, __RequestVerificationToken: $.lrToken }, method: 'POST' }); + } + + // 文件保存成功后 + //$fileItem.append('
'); + //$fileItem.append('
'); + + // $fileItem.find('.lr-tool-bar .fa-minus-circle').on('click', function () { + // var fileId = $(this).attr('data-value'); + // DeleteFile(fileId); + // }); + // learun.alert.success(res.data.info); + } + else { + learun.alert.error(res.info); + $fileItem.append('
'); + } + }); + } + // 触发清楚文件碎片 + var reomveFileChunks = function (file) { + var param = {}; + param['__RequestVerificationToken'] = $.lrToken; + param['fileGuid'] = fileInfo[file.id].fileGuid; + param['chunks'] = fileInfo[file.id].chunks; + learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/Annexes/MergeAnnexesFile", param, function (res) { }); + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress').remove(); + $fileItem.append('
'); + } + // 删除文件 + var DeleteFile = function (fileId) { + var param = {}; + param['__RequestVerificationToken'] = $.lrToken; + param['fileId'] = fileInfo[fileId].fileGuid; + learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/Annexes/DeleteAnnexesFile", param, function (res) { }); + var file = page.uploader.getFile(fileId); + if (!!file) { + page.uploader.removeFile(file); + } + delete fileInfo[fileId]; + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + fileId); + $fileItem.remove(); + if ($('#lr_form_file_queue_list>div').length == 0) { + $('#lr_form_file_queue .lr-form-file-queue-bg').show(); + } + } + + var page = { + uploader: null, + init: function () { + if (!WebUploader.Uploader.support()) { + alert('Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器'); + throw new Error('WebUploader does not support the browser you are using.'); + } + /*模板下载*/ + $('#lr_down_file_btn').on('click', function () { + location.href = top.$.rootUrl + "/LogisticsManagement/Accommodation/DownTemplate"; + }); + + page.uploader = WebUploader.create({ + auto: true, + swf: top.$.rootUrl + '/Content/webuploader/Uploader.swf', + // 文件接收服务端。 + server: top.$.rootUrl + "/LR_SystemModule/Annexes/UploadAnnexesFileChunk", + // 选择文件的按钮。可选。 + // 内部根据当前运行是创建,可能是input元素,也可能是flash. + pick: '#lr_add_file_btn', + dnd: '#lr_form_file_queue', + paste: 'document.body', + disableGlobalDnd: true, + accept: { + extensions: "xls,xlsx" + }, + multiple: false, + // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传! + resize: false, + // 文件分片上传 + chunked: true, + chunkRetry: 3, + prepareNextFile: true, + chunkSize: '1048576', + // 上传参数 + formData: { + __RequestVerificationToken: $.lrToken + } + }); + page.uploader.on('fileQueued', page.fileQueued); + page.uploader.on('uploadStart', page.uploadStart); + page.uploader.on('uploadBeforeSend', page.uploadBeforeSend); + page.uploader.on('uploadProgress', page.uploadProgress); + page.uploader.on('uploadSuccess', page.uploadSuccess); + page.uploader.on('uploadError', page.uploadError); + page.uploader.on('uploadComplete', page.uploadComplete); + page.uploader.on('error', page.error); + + + $('#lr_form_file_queue').mCustomScrollbar({ // 优化滚动条 + theme: "minimal-dark" + }); + + }, + fileQueued: function (file) {// 文件加载到队列 + fileInfo[file.id] = { name: file.name }; + $('#lr_form_file_queue .lr-form-file-queue-bg').hide(); + // 添加一条文件记录 + var $item = $('
'); + $item.append('
'); + $item.append('' + file.name + '(' + learun.countFileSize(file.size) + ')'); + + $('#lr_form_file_queue_list').append($item); + }, + uploadStart: function (file) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.append('
'); + }, + uploadBeforeSend: function (object, data, headers) { + data.chunk = data.chunk || 0; + data.chunks = data.chunks || 1; + fileInfo[data.id].fileGuid = fileInfo[data.id].fileGuid || WebUploader.Base.guid(); + data.fileGuid = fileInfo[data.id].fileGuid; + fileInfo[data.id].chunks = data.chunks; + }, + uploadProgress: function (file, percentage) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress-bar').css('width', (percentage * 100 + '%')); + }, + uploadSuccess: function (file, res) { + if (res.code == 200) {// 上传成功 + mergeFileChunks(file); + } + else {// 上传失败 + reomveFileChunks(file); + } + }, + uploadError: function (file, code) { + reomveFileChunks(file); + }, + uploadComplete: function (file) { + }, + error: function (type) { + switch (type) { + case 'Q_TYPE_DENIED': + learun.alert.error('当前文件类型不允许上传'); + break; + }; + } + }; + page.init(); +} diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Room.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Room.cshtml index f120a829f..1683921af 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Room.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Room.cshtml @@ -45,11 +45,6 @@ left: -60px; width: 273px; } - .indSec1T > a { - width: fit-content; - padding-left: 6px; - padding-right: 6px; - } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Unit.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Unit.cshtml index 78802bccc..3e3925d18 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Unit.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Unit.cshtml @@ -45,11 +45,6 @@ left: 0px; width: 225px } - .indSec1T > a { - width: fit-content; - padding-left: 6px; - padding-right: 6px; - } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/DormitoryReturn/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/DormitoryReturn/Index.cshtml index c71a2bed5..8f5361aab 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/DormitoryReturn/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/DormitoryReturn/Index.cshtml @@ -36,7 +36,7 @@
 学生出宿  学生归宿 -  编辑 + @* 编辑*@  删除  打印
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls new file mode 100644 index 000000000..27b3b570d Binary files /dev/null and b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls differ 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 8784c354d..9c8aee1fc 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 @@ -1322,6 +1322,7 @@ + @@ -1332,6 +1333,7 @@ + @@ -7900,6 +7902,9 @@ + + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleEntity.cs index 351f0e912..d7cd70906 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleEntity.cs @@ -11,7 +11,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// 日 期:2022-03-14 12:05 /// 描 述:宿舍晚归规则 /// - public class Acc_DormitoryRuleEntity + public class Acc_DormitoryRuleEntity { #region 实体成员 /// @@ -64,6 +64,22 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// [Column("UPDATEUSERID")] public string UpdateUserId { get; set; } + /// + /// + /// + [Column("COACHTEACH")] + public int? CoachTeach { get; set; } + /// + /// + /// + [Column("DEFEND")] + public int? Defend { get; set; } + /// + /// + /// + [Column("DEFENDID")] + public string DefendId { get; set; } + #endregion #region 扩展操作 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleService.cs index 751c2f837..e5148edfb 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Acc_DormitoryRule/Acc_DormitoryRuleService.cs @@ -1,4 +1,5 @@ using Dapper; +using Learun.Application.Organization; using Learun.DataBase.Repository; using Learun.Util; using System; @@ -138,14 +139,24 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement { try { + var loInfo = LoginUserInfo.Get(); if (!string.IsNullOrEmpty(keyValue)) { + entity.UpdateTime = DateTime.Now; + entity.UpdateUserId = loInfo.account; entity.Modify(keyValue); this.BaseRepository("CollegeMIS").Update(entity); } else { entity.Create(); + entity.CreateTime = DateTime.Now; + entity.CreateUserId = loInfo.account; + var NewID = this.BaseRepository().FindEntity(x => x.F_FullName == "保卫处").F_DepartmentId; + if (NewID != null && entity.Defend == 1) + { + entity.DefendId = NewID; + } this.BaseRepository("CollegeMIS").Insert(entity); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs index 41bda8acd..1b18261e9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs @@ -311,11 +311,66 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } + //public List GetDept() + //{ + // try + // { + // return accommodationService.GetSelectData("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList(); + // } + // catch (Exception ex) + // { + // if (ex is ExceptionEx) + // { + // throw; + // } + // else + // { + // throw ExceptionEx.ThrowBusinessException(ex); + // } + // } + //} + //public List GetMajor(string strWhere) + //{ + // try + // { + // return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList(); + // } + // catch (Exception ex) + // { + // if (ex is ExceptionEx) + // { + // throw; + // } + // else + // { + // throw ExceptionEx.ThrowBusinessException(ex); + // } + // } + //} + //public List GetClass(string strWhere) + //{ + // try + // { + // return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList(); + // } + // catch (Exception ex) + // { + // if (ex is ExceptionEx) + // { + // throw; + // } + // else + // { + // throw ExceptionEx.ThrowBusinessException(ex); + // } + // } + //} + public List GetDept() { try { - return accommodationService.GetSelectData("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList(); + return accommodationService.GetDeptOrMajorOrClass("").Select(x => new Acc_DormitoryBuildEntity { Dept = x.Dept, DeptName = x.DeptName }).Distinct().ToList(); } catch (Exception ex) { @@ -333,7 +388,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement { try { - return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList(); + return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Major = x.Major, MajorName = x.MajorName }).Distinct().ToList(); } catch (Exception ex) { @@ -351,7 +406,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement { try { - return accommodationService.GetSelectData(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList(); + return accommodationService.GetDeptOrMajorOrClass(strWhere).Select(x => new Acc_DormitoryBuildEntity { Class = x.Class, ClassName = x.ClassName }).Distinct().ToList(); } catch (Exception ex) { @@ -365,7 +420,6 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } } - /// /// 获取左侧树形数据 /// @@ -830,6 +884,53 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } + + + /// + /// 清空实体数据 + /// 主键 + /// + /// + public void ClearEntity(string Grade) + { + try + { + accommodationService.ClearEntity(Grade); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + + + public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid) + { + try + { + return accommodationService.ExecuteImportExcel(dt, fileGuid); + + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs index 2050f1292..9d68bf9cc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs @@ -106,6 +106,10 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement object GetFloorList(string parentID); object GetRoomList(string parentID); object GetBedList(string parentID); + + void ClearEntity(string Grade); + (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid); + #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs index ade272d6d..960cdd883 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs @@ -1,5 +1,7 @@ using Dapper; using Learun.Application.TwoDevelopment.EducationalAdministration; +using Learun.Cache.Base; +using Learun.Cache.Factory; using Learun.DataBase.Repository; using Learun.Util; using System; @@ -19,6 +21,10 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// public class AccommodationService : RepositoryFactory { + #region 缓存定义 + private ICache cache = CacheFactory.CaChe(); + private string cacheKey = "Learun_adms_excelError_"; // +公司主键 + #endregion #region 获取数据 /// @@ -1709,6 +1715,7 @@ select parentid from [dbo].[Acc_DormitoryBuild] where BuildType='5' and (student { var parentEntity = db.FindEntity(ParentID); entity.Create(); + entity.DNo = entity.Name.Substring(0,entity.Name.Length-1); entity.ApartmentId = parentEntity.ApartmentId; entity.UnitId = parentEntity.UnitId; entity.FloorId = parentEntity.FloorId; @@ -1866,6 +1873,354 @@ where ID='{ParentID}' } } + /// + /// 按年级清空 + /// + public void ClearEntity(string Grade) + { + try + { + BaseRepository("CollegeMIS").ExecuteBySql($"delete from Acc_DormitoryBuild where StudentID in(select StuNo from StuInfoBasic where Grade ='{Grade}')"); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + + + public List GetDeptOrMajorOrClass(string strWhere) + { + try + { + string sql1 = " select distinct dept,d.DeptName from Acc_DormitoryBuild t join CdDept d on t.dept=d.deptno"; + string sql2 = " select distinct major,m.MajorName from Acc_DormitoryBuild t join CdMajor m on t.major=m.majorno"; + string sql3 = " select distinct class,c.ClassName from Acc_DormitoryBuild t join ClassInfo c on t.class=c.classno"; + string sql = @" where t.ID in ( + select parentid from[dbo].[Acc_DormitoryBuild] where BuildType = '5' and(studentid is not null and len(studentid) > 0) + )"; + if (string.IsNullOrEmpty(strWhere)) + { + sql = sql1 + sql; + } + else if (strWhere.Contains("deptno")) + { + sql = sql2 + sql + " and " + strWhere; + } + else if (strWhere.Contains("majorno")) + { + sql = sql3 + sql + " and " + strWhere; + } + return this.BaseRepository("CollegeMIS").FindList(sql).ToList(); + + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + + /// + /// 导入宿舍信息 + /// + /// + /// + public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid) + { + int snum = 0; + int fnum = 0; + var db = this.BaseRepository("CollegeMIS"); + var msg = ""; + try + { + db.BeginTrans(); + var dormitoryBuildList = db.FindList().ToList(); + + //系 专业 班级 + var deptList = db.FindList(); + var majorList = db.FindList(x => x.CheckMark == true); + var classList = db.FindList(x => x.CheckMark == true); + //学生 + var stuinfobasic = db.FindList(); + // 创建一个datatable容器用于保存导入失败的数据 + DataTable failDt = new DataTable(); + foreach (DataColumn dc in dt.Columns) + { + failDt.Columns.Add(dc.ColumnName, dc.DataType); + } + failDt.Columns.Add("导入错误", typeof(string)); + dt.Columns.Add("导入错误", typeof(string)); + //寝室Id + var dormitoryIds = new List(); + + var user = LoginUserInfo.Get(); + foreach (DataRow dr in dt.Rows) + { + try + { + if (!string.IsNullOrEmpty(dr["宿舍楼"].ToString().Trim())) + { + + //系 专业 班级 + var DeptNo = deptList.Where(x => x.DeptName == dr["系部"].ToString().Trim()).FirstOrDefault()?.DeptNo; + var MajorNo = majorList.Where(x => x.MajorName == dr["专业"].ToString().Trim() && x.DeptNo == DeptNo) + .FirstOrDefault()?.MajorNo; + var ClassNo = classList.Where(x => x.ClassName == dr["班级"].ToString()).FirstOrDefault()?.ClassNo; + if (string.IsNullOrEmpty(DeptNo)) + { + fnum++; + dr["导入错误"] = "系部导入错误"; + failDt.Rows.Add(dr.ItemArray); + continue; + } + if (string.IsNullOrEmpty(MajorNo)) + { + fnum++; + dr["导入错误"] = "专业导入错误"; + failDt.Rows.Add(dr.ItemArray); + continue; + } + if (string.IsNullOrEmpty(ClassNo)) + { + fnum++; + dr["导入错误"] = "班级导入错误"; + failDt.Rows.Add(dr.ItemArray); + continue; + } + + var leaderno = ""; + if (!string.IsNullOrEmpty(dr["舍长学号"].ToString())) + { + //leaderno = stuinfobasic.Where(x => x.StuNo == dr["舍长学号"].ToString() && x.ClassNo == ClassNo).FirstOrDefault()?.StuNo; + leaderno = stuinfobasic.Where(x => x.StuNo == dr["舍长学号"].ToString()).FirstOrDefault()?.StuNo; + if (string.IsNullOrEmpty(leaderno)) + { + fnum++; + dr["导入错误"] = dr["舍长学号"] + "导入错误"; + failDt.Rows.Add(dr.ItemArray); + continue; + } + } + + var stuno = ""; + if (!string.IsNullOrEmpty(dr["学生学号"].ToString())) + { + stuno = stuinfobasic.Where(x => x.StuNo == dr["学生学号"].ToString() && x.ClassNo == ClassNo).FirstOrDefault()?.StuNo; + if (string.IsNullOrEmpty(stuno)) + { + fnum++; + dr["导入错误"] = dr["学生学号"] + "导入错误"; + failDt.Rows.Add(dr.ItemArray); + continue; + } + } + + var parent = dormitoryBuildList.Where(x => x.Name == "数字化智慧校园").FirstOrDefault(); + if (parent == null) + { + parent = new Acc_DormitoryBuildEntity(); + parent.Create(); + parent.DNo = ""; + parent.Name = "数字化智慧校园"; + //parent.BuildType = "1"; + parent.CreateBy = user.realName; + parent.CreateTime = DateTime.Now; + parent.Campus = user.companyId; + db.Insert(parent); + + dormitoryBuildList.Add(parent); + } + + //宿舍楼 + var apartmentName = dr["宿舍楼"].ToString().Trim(); + var apartmentCode = dr["宿舍楼编号"].ToString(); + var apartment = dormitoryBuildList.Where(x => x.Name == apartmentName && x.BuildType == "1") + .FirstOrDefault(); + if (apartment == null) + { + //添加宿舍楼 + apartment = new Acc_DormitoryBuildEntity(); + apartment.Create(); + apartment.ParentID = parent.ID; + apartment.DNo = apartmentCode; + apartment.Name = apartmentName; + apartment.BuildType = "1"; + apartment.CreateBy = user.realName; + apartment.CreateTime = DateTime.Now; + apartment.Campus = user.companyId; + db.Insert(apartment); + + dormitoryBuildList.Add(apartment); + } + //单元 + var unitName = dr["单元"].ToString().Trim(); + var unitCode = dr["单元编号"].ToString(); + var unit = dormitoryBuildList.Where(x => x.Name == unitName && x.BuildType == "2" && x.ParentID == apartment.ID) + .FirstOrDefault(); + if (unit == null) + { + //添加单元 + unit = new Acc_DormitoryBuildEntity(); + unit.Create(); + unit.ParentID = apartment.ID; + unit.ApartmentId = apartment.ID; + unit.DNo = unitCode; + unit.Name = unitName; + unit.BuildType = "2"; + unit.CreateBy = user.realName; + unit.CreateTime = DateTime.Now; + unit.Campus = user.companyId; + db.Insert(unit); + + dormitoryBuildList.Add(unit); + } + //楼层 + var floorName = dr["楼层"].ToString().Trim(); + var floorCode = dr["楼层编号"].ToString(); + var floor = dormitoryBuildList.Where(x => x.Name == floorName && x.DNo == floorCode && x.BuildType == "3" && x.ParentID == unit.ID) + .FirstOrDefault(); + if (floor == null) + { + //添加楼层 + floor = new Acc_DormitoryBuildEntity(); + floor.Create(); + floor.ParentID = unit.ID; + floor.ApartmentId = apartment.ID; + floor.UnitId = unit.ID; + floor.DNo = floorCode; + floor.Name = floorName; + floor.BuildType = "3"; + floor.CreateBy = user.realName; + floor.CreateTime = DateTime.Now; + floor.Campus = user.companyId; + db.Insert(floor); + + dormitoryBuildList.Add(floor); + } + //寝室 + var dormitoryName = dr["寝室名称"].ToString().Trim(); + var dormitoryCode = dr["寝室编号"].ToString().Trim(); + var dormitory = dormitoryBuildList.Where(x => x.Name == dormitoryName && x.DNo == dormitoryCode && x.BuildType == "4" && x.ParentID == floor.ID) + .FirstOrDefault(); + if (dormitory == null && !string.IsNullOrEmpty(dormitoryName) && !string.IsNullOrEmpty(dormitoryCode)) + { + //添加 + dormitory = new Acc_DormitoryBuildEntity(); + dormitory.Create(); + dormitory.Dept = DeptNo; + dormitory.Major = MajorNo; + dormitory.Class = ClassNo; + dormitory.ParentID = floor.ID; + dormitory.ApartmentId = apartment.ID; + dormitory.UnitId = unit.ID; + dormitory.FloorId = floor.ID; + dormitory.DNo = dormitoryCode; + dormitory.Name = dormitoryName; + dormitory.Sex = dr["性别"].ToString() == "女" ? "0" : "1"; + dormitory.BuildType = "4"; + dormitory.RoomType = Convert.ToInt32(dr["几人寝"].ToString()); + dormitory.Leader = leaderno; + dormitory.Starred = "3"; + dormitory.CreateBy = user.realName; + dormitory.CreateTime = DateTime.Now; + dormitory.Campus = user.companyId; + db.Insert(dormitory); + + dormitoryBuildList.Add(dormitory); + } + dormitoryIds.Add(dormitory.ID); + + //床位 + var bedName = dr["床位"].ToString().Trim(); + var bedCode = bedName.Replace("床", "").Replace("号", ""); + var bed = dormitoryBuildList.Where(x => x.Name == bedName && x.DNo == bedCode && x.BuildType == "5" && x.ParentID == dormitory?.ID) + .FirstOrDefault(); + if (bed == null && !string.IsNullOrEmpty(bedName) && !string.IsNullOrEmpty(bedCode)) + { + bed = new Acc_DormitoryBuildEntity(); + bed.Create(); + bed.ParentID = dormitory.ID; + bed.ApartmentId = apartment.ID; + bed.UnitId = unit.ID; + bed.FloorId = floor.ID; + bed.DNo = bedCode; + bed.Name = bedName; + bed.Dept = DeptNo; + bed.Major = MajorNo; + bed.Class = ClassNo; + bed.StudentID = stuno; + bed.Leader = leaderno; + bed.BuildType = "5"; + bed.CreateBy = user.realName; + bed.CreateTime = DateTime.Now; + bed.Campus = user.companyId; + db.Insert(bed); + + dormitoryBuildList.Add(bed); + snum++; + } + + } + else + { + break; + } + } + catch (Exception e) + { + fnum++; + dr["导入错误"] = "出现异常:" + e.Message; + failDt.Rows.Add(dr.ItemArray); + continue; + } + } + + + db.Commit(); + + //更新寝室入住人数字段 + var ids = string.Join("','", dormitoryIds); + var sql = $@" update a set a.CheckInStu=b.num +from Acc_DormitoryBuild a join (select parentid,count(1) as num from Acc_DormitoryBuild where buildtype='5' and studentid is not null and len(studentid)>0 and parentid in ('{ids}') group by parentid) b + on a.id=b.parentid + where a.id in ('{ids}') and a.buildtype='4'"; + this.BaseRepository("CollegeMIS").ExecuteBySql(sql); + // 写入缓存如果有未导入的数据 + if (failDt.Rows.Count > 0) + { + string errordt = failDt.ToJson(); + + cache.Write(cacheKey + fileGuid, errordt, CacheId.excel); + } + return (failDt, snum, fnum); + } + catch (Exception ex) + { + db.Rollback(); + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion 提交数据 } } \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/DormitoryReturn/DormitoryReturnService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/DormitoryReturn/DormitoryReturnService.cs index 94249c21b..83b251047 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/DormitoryReturn/DormitoryReturnService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/DormitoryReturn/DormitoryReturnService.cs @@ -83,7 +83,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement { string sql = @"select (case t.isreturn when 1 then 1 else 0 end) as isreturn,a.Dept,a.Major,a.class from ( -select parentid,isreturn from [dbo].[Acc_DormitoryBuild] where BuildType='5' and (studentid is not null and len(studentid)>0) +select parentid,isreturn from [dbo].[Acc_DormitoryBuild] where BuildType='5' and (studentid is not null and len(studentid)>0) and (IsReturn is not null and len(IsReturn)>0) ) t join Acc_DormitoryBuild a on a.ID=t.parentid where 1=1 ";