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 cecc6a18d..8ba4e596e 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,11 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
+using System.IO;
+using NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using Learun.Application.Base.SystemModule;
+using System.Drawing;
namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
{
@@ -21,6 +26,7 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
public class AccommodationController : MvcControllerBase
{
private AccommodationIBLL accommodationIBLL = new AccommodationBLL();
+ private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
#region 视图功能
@@ -207,7 +213,15 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
{
return View();
}
-
+ ///
+ /// 导入宿舍
+ ///
+ ///
+ [HttpGet]
+ public ActionResult IndexImport()
+ {
+ return View();
+ }
#endregion
@@ -526,6 +540,57 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
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/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 @@
批量添加宿舍
床位管理
- @* 自动分配宿舍
+ @* 自动分配宿舍
同步宿舍信息*@
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 162af9682..d88593baa 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,24 @@ 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/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/Content/excel/AccommodationImport.xls b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls
new file mode 100644
index 000000000..ab60347cf
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 78b3fd178..c3d8d2f62 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
@@ -1352,6 +1352,7 @@
+
@@ -7691,6 +7692,7 @@
+
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 e3fb35e6c..12c98a70c 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
@@ -830,6 +830,27 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
}
+
+ 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..9c3541bc6 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,8 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
object GetFloorList(string parentID);
object GetRoomList(string parentID);
object GetBedList(string parentID);
+ (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 0f830c378..38b09417d 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 获取数据
///
@@ -1908,6 +1914,266 @@ where ID='{ParentID}'
}
}
+ ///
+ /// 导入宿舍信息
+ ///
+ ///
+ ///
+ 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() && x.DeptNo == DeptNo && x.MajorNo == MajorNo).FirstOrDefault()?.ClassNo;
+ if (string.IsNullOrEmpty(DeptNo))
+ {
+ fnum++;
+ dr["导入错误"] = dr["系部"] + "导入错误";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (string.IsNullOrEmpty(MajorNo))
+ {
+ fnum++;
+ dr["导入错误"] = dr["专业"] + "导入错误";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (string.IsNullOrEmpty(ClassNo))
+ {
+ fnum++;
+ dr["导入错误"] = dr["班级"] + "导入错误";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ var leaderno = stuinfobasic.Where(x => x.StuNo == dr["舍长学号"].ToString() && x.ClassNo == ClassNo).FirstOrDefault()?.StuNo;
+ var 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;
+ }
+ if (string.IsNullOrEmpty(leaderno))
+ {
+ fnum++;
+ dr["导入错误"] = dr["舍长学号"] + "导入错误";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+
+ //宿舍楼
+ 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.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)
+ {
+ //添加
+ 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)
+ {
+ 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/LearunApp-2.2.0/.hbuilderx/launch.json b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/.hbuilderx/launch.json
index 501e01c82..b9c0a3291 100644
--- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/.hbuilderx/launch.json
+++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/.hbuilderx/launch.json
@@ -2,10 +2,15 @@
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
"version": "0.0",
"configurations": [{
- "type": "uniCloud",
- "default": {
- "launchtype": "remote"
- }
- }
+ "app-plus" :
+ {
+ "launchtype" : "remote"
+ },
+ "default" :
+ {
+ "launchtype" : "remote"
+ },
+ "type" : "uniCloud"
+ }
]
}