Просмотр исходного кода

Merge branch '长阳分支中职' of 123.57.209.16:bjquanjiang/DigitalScholl into 长阳分支中职

临城职教中职
liangkun 2 лет назад
Родитель
Сommit
a9ac10be97
11 измененных файлов: 595 добавлений и 7 удалений
  1. +66
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs
  2. +4
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml
  3. +18
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.js
  4. +26
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.cshtml
  5. +180
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js
  6. Двоичные данные
      Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls
  7. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  8. +21
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs
  9. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs
  10. +266
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs
  11. +10
    -5
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/.hbuilderx/launch.json

+ 66
- 1
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();
}

/// <summary>
/// 导入宿舍
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult IndexImport()
{
return View();
}

#endregion

@@ -526,6 +540,57 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers
return Success("同步成功");
}

/// <summary>
/// 宿舍信息导入模板
/// </summary>
/// <returns></returns>
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;
}
}


/// <summary>
/// 宿舍信息excel文件导入
/// </summary>
/// <param name="templateId"></param>
/// <param name="Filedata"></param>
/// <returns></returns>
[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

}


+ 4
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/Index.cshtml Просмотреть файл

@@ -67,7 +67,7 @@
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
<a id="lr_dormitoryAdd" class="btn btn-default"><i class="fa fa-pencil-square"></i>&nbsp;批量添加宿舍</a>
<a id="lr_bedManage" class="btn btn-default"><i class="fa fa-pencil-square"></i>&nbsp;床位管理</a>
@*<a id="lr_allocation" class="btn btn-default"><i class="fa fa-pencil-square"></i>&nbsp;自动分配宿舍</a>
@*<a id="lr_allocation" class="btn btn-default"><i class="fa fa-pencil-square"></i>&nbsp;自动分配宿舍</a>
<a id="lr_syncdata" class="btn btn-default"><i class="fa fa-pencil-square"></i>&nbsp;同步宿舍信息</a>*@
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
@@ -79,6 +79,9 @@
<div class=" btn-group btn-group-sm" learun-authorize="yes">
<a id="lr_Classify" class="btn btn-default"><i class="fa fa-tags"></i>&nbsp;<span class="lrlt">分类管理</span></a>
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
<a id="lr_importBed" class="btn btn-default"><i class="fa fa-sign-in"></i>&nbsp;<span class="lrlt">导入</span></a>
</div>
</div>
</div>
<div class="lr-layout-body" id="gridtable"></div>


+ 18
- 0
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 () {


+ 26
- 0
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";
}
<link href="~/Content/webuploader/webuploader.css" rel="stylesheet" />
<script src="~/Content/webuploader/webuploader.nolog.min.js"></script>
@Html.AppendCssFile("/Areas/LR_SystemModule/Views/ExcelImport/ImportForm.css")

<div class="lr-form-layout lr-form-layout-top-bottom">
<div class="lr-form-layout-header">
<div id="lr_add_file_btn"><i class="fa fa-cloud-upload"></i><span class="lrlt">上传文件</span></div>
<div class="webuploader-pick" id="lr_down_file_btn"><i class="fa fa-download"></i><span class="lrlt">下载模板</span></div>
</div>
<div class="lr-form-layout-body">
<div class="lr-form-file-queue-wrap" id="lr_form_file_queue">
<div class="lr-form-file-queue" id="lr_form_file_queue_list">

</div>
<div class="lr-form-file-queue-bg">
<h1><span class="lrlt">试试将电脑里的文件拖拽到此上传</span></h1>
</div>
</div>
</div>
</div>

@Html.AppendJsFile("/Areas/LogisticsManagement/Views/Accommodation/IndexImport.js")

+ 180
- 0
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('<div class="lr-msg2"><span>' + res.data.Success + '</span><span>/</span><span style="color:#b94a48;" >' + res.data.Fail + '</span></div>');
// 如果有失败
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('<div class="lr-msg"><i class="fa fa-check-circle"></i></div>');
//$fileItem.append('<div class="lr-tool-bar"><i class="fa fa-minus-circle" title="删除" data-value="' + file.id + '" ></i></div>');

// $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('<div class="lr-msg"><i class="fa fa-exclamation-circle"></i></div>');
}
});
}
// 触发清楚文件碎片
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('<div class="lr-msg"><i class="fa fa-exclamation-circle"></i></div>');
}
// 删除文件
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 = $('<div class="lr-form-file-queue-item" id="lr_filequeue_' + file.id + '" ></div>');
$item.append('<div class="lr-file-image"><img src="' + top.$.rootUrl + '/Content/images/filetype/' + file.ext + '.png"></div>');
$item.append('<span class="lr-file-name">' + file.name + '(' + learun.countFileSize(file.size) + ')</span>');

$('#lr_form_file_queue_list').append($item);
},
uploadStart: function (file) {
var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id);
$fileItem.append('<div class="lr-uploader-progress"><div class="lr-uploader-progress-bar" style="width:0%;"></div></div>');
},
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();
}

Двоичные данные
Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/AccommodationImport.xls Просмотреть файл


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj Просмотреть файл

@@ -1352,6 +1352,7 @@
<Content Include="Areas\LogisticsManagement\Views\Accommodation\FormDept.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\FormRoom.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\Index.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\IndexImport.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\IndexBed.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\IndexClassify.js" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\IndexDistribution.js" />
@@ -7691,6 +7692,7 @@
<Content Include="Areas\EducationalAdministration\Views\StuScoreNotPassTwo\IndexUnpassTwo.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\StuScore\AllStuScoreQueryIndex.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\TextBookSolSub\StatisticsIndex.cshtml" />
<Content Include="Areas\LogisticsManagement\Views\Accommodation\IndexImport.cshtml" />
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<Content Include="Views\Login\Default-beifen.cshtml" />


+ 21
- 0
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

}


+ 2
- 0
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

}


+ 266
- 0
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
/// </summary>
public class AccommodationService : RepositoryFactory
{
#region 缓存定义
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "Learun_adms_excelError_"; // +公司主键
#endregion
#region 获取数据

/// <summary>
@@ -1908,6 +1914,266 @@ where ID='{ParentID}'
}
}

/// <summary>
/// 导入宿舍信息
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
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<Acc_DormitoryBuildEntity>().ToList();

//系 专业 班级
var deptList = db.FindList<CdDeptEntity>();
var majorList = db.FindList<CdMajorEntity>(x => x.CheckMark == true);
var classList = db.FindList<ClassInfoEntity>(x => x.CheckMark == true);
//学生
var stuinfobasic = db.FindList<StuInfoBasicEntity>();
// 创建一个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<string>();

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<string>(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 提交数据
}
}

+ 10
- 5
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"
}
]
}

Загрузка…
Отмена
Сохранить