Browse Source

课表导入

黑艺新账号
ndbs 1 year ago
parent
commit
ecf0bcea8b
13 changed files with 703 additions and 15 deletions
  1. +30
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs
  2. +33
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/TimeTableController.cs
  3. +24
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.cshtml
  4. +136
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.css
  5. +241
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.js
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.cshtml
  7. +11
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.js
  8. BIN
      Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/ArrangeLessonTermImport.xls
  9. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  10. +26
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs
  11. +13
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs
  12. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs
  13. +182
    -13
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs

+ 30
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs View File

@@ -24,6 +24,7 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private Ass_FixAssetsIBLL ass_FixAssetsIBLL = new Ass_FixAssetsBLL();
private ArrangeLessonTermIBLL arrangeLessonTermIBLL = new ArrangeLessonTermBLL();

#region 视图功能
/// <summary>
@@ -353,7 +354,35 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
return Fail("导入数据失败!");
}
}

/// <summary>
///
/// </summary>
/// <param name="fileId"></param>
/// <param name="chunks"></param>
/// <param name="ext"></param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ArrangeLessonTermImport(string fileId, int chunks, string ext)
{
UserInfo userInfo = LoginUserInfo.Get();
string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo);
if (!string.IsNullOrEmpty(path))
{
DataTable dt = ExcelHelper.ExcelImport(path);
var res = arrangeLessonTermIBLL.ArrangeLessonTermImport(dt, fileId);
var data = new
{
Success = res.Split('|')[0],
Fail = res.Split('|')[1]
};
return JsonResult(data);
}
else
{
return Fail("导入数据失败!");
}
}
/// <summary>
/// 下载文件(导入文件未被导入的数据)
/// </summary>


+ 33
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/TimeTableController.cs View File

@@ -8,6 +8,7 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;

namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
{
@@ -74,6 +75,16 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
return View();
}

/// <summary>
/// 导入页面
/// <summary>
/// <returns></returns>
[HttpGet]
public ActionResult ImportForm()
{
return View();
}


/// <summary>
/// 课程表【教务】
@@ -689,5 +700,27 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
#endregion


/// <summary>
/// 导入数据
/// </summary>
/// <returns></returns>
public ActionResult DownTemplate()
{
FileStreamResult result = null;
try
{
var path = Server.MapPath("~/Content/excel/");
var pathoffull = path + "ArrangeLessonTermImport.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;
}
}

}
}

+ 24
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.cshtml View File

@@ -0,0 +1,24 @@
@{
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/PersonnelManagement/Views/TimeTable/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/PersonnelManagement/Views/TimeTable/ImportForm.js")

+ 136
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.css View File

@@ -0,0 +1,136 @@
.lr-form-layout-body {
padding:0 5px 5px 5px;
}
.lr-form-file-queue-wrap {
position:relative;
width:100%;
height:100%;
border:1px solid #ddd;
border-radius:4px;
}
.lr-form-file-queue {
position:relative;
}
.lr-form-file-queue {
position:relative;
}
.lr-form-file-queue-item {
position:relative;
width:100%;
height:50px;
border-bottom:1px solid #ddd;
padding-left:60px;

}
.lr-file-image {
position:absolute;
top:5px;
left:5px;
}
.lr-file-image img {
width:40px;
height:40px;
}
.lr-file-name{
line-height:50px;

}
.lr-msg {
position:absolute;
top:0;
right:5px;
font-size: 25px;
line-height:50px;
}
.lr-msg .fa-check-circle{
color: #5cb85c;
}
.lr-msg .fa-exclamation-circle {
color: #b94a48;
}
.lr-msg2 {
position:absolute;
top:0;
right:5px;
line-height:50px;
}
.lr-msg2 span {
color:#333;
font-size:14px;
margin-right:5px;
}

.lr-tool-bar {
position:absolute;
top:0;
right:35px;
font-size: 25px;
line-height:50px;
color:#666;
cursor:pointer;
}
.lr-tool-bar > i {
margin-left:8px;
}

.lr-tool-bar .fa-minus-circle {
color: #b94a48;
}
.lr-tool-bar .fa-cloud-download {
color: #3498db;
}

.lr-uploader-progress {
position:absolute;
bottom:2px;
left:60px;
height:4px;
width:500px;
width:calc(100% - 90px);
}
.lr-uploader-progress-bar {
position:relative;
height:100%;
background-color:#039cfd;
border-radius:4px;
}


.lr-form-file-queue-bg {
position:absolute;
top:50%;
left:50%;
width:300px;
height:30px;
line-height:30px;
margin:-15px 0 0 -150px;
}
.lr-form-file-queue-bg h1 {
color: #666;
font-size: 20px;
font-family: Microsoft Yahei;
padding-bottom: 2px;
margin: 0;
}
#lr_down_file_btn {
position:absolute;
right:5px;
background:#fff;
border:1px solid #ddd;
color:#333;
}
#lr_down_file_btn:hover {
color:#337ab7;
}
/*对百度插件的样式重写*/
.webuploader-container {
position:absolute;
}
.webuploader-pick {
padding:8px 15px;
background-color:#039cfd;
}
.webuploader-pick-hover {
background-color:#027dcb;
}

+ 241
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/ImportForm.js View File

@@ -0,0 +1,241 @@
/*
* 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
* Copyright (c) 2013-2018 北京泉江科技有限公司
* 创建人:陈彬彬
* 日 期:2023.03.01
* 描 述:导入班级学籍信息
*/
var id = request('id');

var keyVaule = '';

var bootstrap = function ($, learun) {
"use strict";

var page1 = {
init: function () {
page.bind();
page.initData();
},
bind: function () {
$('#lr_add_format').on('click', function () {
currentColRow = null;
learun.layerForm({
id: 'FormatForm',
title: '添加',
url: top.$.rootUrl + '/LR_SystemModule/CodeRule/FormatForm',
width: 450,
height: 310,
callBack: function (id) {
return top[id].acceptClick(function (data) {
$('#gridtable').jfGridSet('addRow', { row: data });
});
}
});
});
$('#lr_edit_format').on('click', function () {
currentColRow = $('#gridtable').jfGridGet('rowdata');
var _id = currentColRow ? currentColRow.itemTypeName : '';
if (learun.checkrow(_id)) {
learun.layerForm({
id: 'FormatForm',
title: '修改',
url: top.$.rootUrl + '/LR_SystemModule/CodeRule/FormatForm',
width: 450,
height: 310,
callBack: function (id) {
return top[id].acceptClick(function (data) {
$('#gridtable').jfGridSet('updateRow', { row: data });
});
}
});
}

});
$('#lr_delete_format').on('click', function () {
currentColRow = null;
var row = $('#gridtable').jfGridGet('rowdata');
var _id = row ? row.itemTypeName : '';
if (learun.checkrow(_id)) {
learun.layerConfirm('是否确认删除该项!', function (res, index) {
if (res) {
$('#gridtable').jfGridSet('removeRow');
top.layer.close(index); //再执行关闭
}
});
}
});

$('#gridtable').jfGrid({
headData: [
{ label: "前缀", name: "itemTypeName", width: 120, align: "left" },
{ label: "格式", name: "formatStr", width: 120, align: "left" },
{ label: "步长", name: "stepValue", width: 100, align: "left" },
{ label: "初始值", name: "initValue", width: 120, align: "left" },
{ label: "说明", name: "description", width: 180, align: "left" }
]
});

/*检测重复项*/
$('#F_EnCode').on('blur', function () {
$.lrExistField(keyValue, 'F_EnCode', top.$.rootUrl + '/LR_SystemModule/CodeRule/ExistEnCode');
});
$('#F_FullName').on('blur', function () {
$.lrExistField(keyValue, 'F_FullName', top.$.rootUrl + '/LR_SystemModule/CodeRule/ExistFullName');
});
},
initData: function () {
if (!!selectedRow) {
keyValue = selectedRow.F_RuleId;
$('#form').lrSetFormData(selectedRow);
var formatdata = JSON.parse(selectedRow.F_RuleFormatJson);
$('#gridtable').jfGridSet('refreshdata', formatdata);
}
}
};

var fileInfo = {};

// 触发合并文件碎片
var mergeFileChunks = function (file) {

var param = {};
param['__RequestVerificationToken'] = $.lrToken;
param['fileId'] = fileInfo[file.id].fileGuid;
param['chunks'] = fileInfo[file.id].chunks;
param['ext'] = file.ext;
param['templateId'] = id;
console.log(111)
learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/ExcelImport/ArrangeLessonTermImport", 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' });
}
}
else {
$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 page = {
uploader: null,
init: function () {
/*模板下载*/
$('#lr_down_file_btn').on('click', function () {
learun.download({ url: top.$.rootUrl + '/PersonnelManagement/TimeTable/DownTemplate', param: { keyValue: id, __RequestVerificationToken: $.lrToken }, method: 'POST' });
});
if (!WebUploader.Uploader.support()) {
alert('Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器');
throw new Error('WebUploader does not support the browser you are using.');
}

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: true,
// 不压缩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').lrscroll();

},
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();

}

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.cshtml View File

@@ -135,6 +135,7 @@
<div class=" btn-group btn-group-sm">
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a>
<a id="perBtn" class="btn btn-default"><i class="fa fa-print"></i>&nbsp;打印课程表</a>
<a id="lr_import" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;导入</a>
</div>
<div class=" btn-group btn-group-sm" learun-authorize="yes">
<a id="emptyByCondition" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;按条件清空排课数据</a>


+ 11
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/IndexInEducation.js View File

@@ -105,6 +105,17 @@ var bootstrap = function ($, learun) {
$('#lr_refresh').on('click', function () {
location.reload();
});
//导入弹窗
$('#lr_import').on('click', function () {
learun.layerForm({
id: 'form_import',
title: '导入数据',
url: top.$.rootUrl + '/PersonnelManagement/TimeTable/ImportForm',
width: 600,
height: 400,
btn: null
});
});
//$('#datesearch').lrdate({
// dfdata: [
// {


BIN
Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/ArrangeLessonTermImport.xls View File


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj View File

@@ -1784,6 +1784,8 @@
<Content Include="Areas\PersonnelManagement\Views\TeacherLeaveManagement\FormView.js" />
<Content Include="Areas\PersonnelManagement\Views\TeacherOvertimeManagement\FormView.js" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\ClassIndexInEducation.js" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\ImportForm.css" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\ImportForm.js" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\IndexInEducationSelect_.js" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\SchoolLesson.js" />
<Content Include="Areas\PersonnelManagement\Views\WorkStudyPositionApply\CheckIndex.js" />
@@ -8338,6 +8340,8 @@
<Content Include="Areas\EducationalAdministration\Views\StuFellowship\FormOfStudent.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\SchoolLevelScholarship\FormOfStudent.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\SchoolLevelScholarship\IndexInStuScoreOfStudent.cshtml" />
<Content Include="Content\excel\ArrangeLessonTermImport.xls" />
<Content Include="Areas\PersonnelManagement\Views\TimeTable\ImportForm.cshtml" />
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<Content Include="Views\Login\Default-beifen.cshtml" />


+ 26
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs View File

@@ -617,5 +617,31 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
var data = arrangeLessonTermService.InitAsyncDataByCondition(entity);
return data;
}


/// <summary>
/// 导入
/// </summary>
/// <param name="dt"></param>
/// <param name="fileId"></param>
/// <returns></returns>
public string ArrangeLessonTermImport(DataTable dt, string fileId)
{
try
{
return arrangeLessonTermService.ArrangeLessonTermImport(dt, fileId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
}
}

+ 13
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs View File

@@ -11,7 +11,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// 日 期:2019-02-27 11:05
/// 描 述:排课
/// </summary>
public class ArrangeLessonTermEntity
public class ArrangeLessonTermEntity
{

#region 实体成员
@@ -158,6 +158,18 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// <returns></returns>
[Column("F_SCHOOLID")]
public string F_SchoolId { get; set; }
/// <summary>
/// 插入时间
/// </summary>
/// <returns></returns>
[Column("INSERTDATE")]
public DateTime? InsertDate { get; set; }
/// <summary>
/// 导入标识
/// </summary>
/// <returns></returns>
[Column("ISIMPORT")]
public bool? IsImport { get; set; }

[NotMapped] public string lessoncount { get; set; }
[NotMapped] public string coefficient { get; set; }


+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs View File

@@ -158,5 +158,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration

IEnumerable<TimeTable> GetAllClassLesson(string academicYearNo, string semester);
bool InitAsyncDataByCondition(ArrangeLessonTermEntity entity);

string ArrangeLessonTermImport(DataTable dt, string fileId);
}
}

+ 182
- 13
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs View File

@@ -1,18 +1,17 @@
using Dapper;
using Learun.Application.Organization;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.DataBase.Repository;
using Learun.Util;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Newtonsoft.Json;
using static Learun.Application.TwoDevelopment.EducationalAdministration.ArrangeExamTermService;

namespace Learun.Application.TwoDevelopment.EducationalAdministration
@@ -27,6 +26,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
public class ArrangeLessonTermService : RepositoryFactory
{

#region 缓存定义
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "Learun_adms_excelError_";
#endregion

private static readonly HttpClient Client;
static ArrangeLessonTermService()
{
@@ -2221,15 +2225,15 @@ group by AcademicYearNo,Semester,DeptNo,MajorNo,LessonNo,TeachClassNo,EmpNo,Les
{
var strSql = new StringBuilder();
var queryParam = queryJson.ToJObject();
int month = queryParam["month"] == null ? DateTime.Now.Month : queryParam["month"].ToInt() ;
string starttime = DateTime.Now.Year.ToString()+"-" + month + "-1 00:00:00";
string endtime = DateTime.Now.Year.ToString() + "-" + month + "-"+ DateTime.DaysInMonth(DateTime.Now.Year, month) +" 23:59:59";
strSql.Append("select a.*,b.jobrank as zhiwu,b.F_DepartmentId as dept,b.feestandard,b.Weekcourses,ta.actcourses as monthactcourses,ta.actcourses-(b.Weekcourses*"+ (queryParam["weeks"]==null?4: queryParam["weeks"]) + ") as zhesuan_monthactcourses, ");
strSql.Append(" case when b.jobrank in('5') then (ta.actcourses-" + (queryParam["weeks"]==null ? 4 : queryParam["weeks"]) + "*b.Weekcourses)*b.feestandard/2 ");
strSql.Append(" when b.jobrank in('6') then (ta.actcourses-" + (queryParam["weeks"]==null ? 4 : queryParam["weeks"]) + "*b.Weekcourses)*b.feestandard ");
strSql.Append("when b.jobrank in(1,2,3,4) then (case when ta.actcourses<=(" + (queryParam["weeks"]==null ? 4 : queryParam["weeks"]) + "*b.weekcourses)/2 then ta.actcourses*b.feestandard else " + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + "*b.weekcourses*b.feestandard/2 end) end as actfeestandard ");
int month = queryParam["month"] == null ? DateTime.Now.Month : queryParam["month"].ToInt();
string starttime = DateTime.Now.Year.ToString() + "-" + month + "-1 00:00:00";
string endtime = DateTime.Now.Year.ToString() + "-" + month + "-" + DateTime.DaysInMonth(DateTime.Now.Year, month) + " 23:59:59";
strSql.Append("select a.*,b.jobrank as zhiwu,b.F_DepartmentId as dept,b.feestandard,b.Weekcourses,ta.actcourses as monthactcourses,ta.actcourses-(b.Weekcourses*" + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + ") as zhesuan_monthactcourses, ");
strSql.Append(" case when b.jobrank in('5') then (ta.actcourses-" + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + "*b.Weekcourses)*b.feestandard/2 ");
strSql.Append(" when b.jobrank in('6') then (ta.actcourses-" + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + "*b.Weekcourses)*b.feestandard ");
strSql.Append("when b.jobrank in(1,2,3,4) then (case when ta.actcourses<=(" + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + "*b.weekcourses)/2 then ta.actcourses*b.feestandard else " + (queryParam["weeks"] == null ? 4 : queryParam["weeks"]) + "*b.weekcourses*b.feestandard/2 end) end as actfeestandard ");
strSql.Append("from ");
strSql.Append("(select count(*) as courses,a.empno,a.empname from ArrangeLessonTerm a where lessondate between '"+ starttime + "' and '" + endtime + "' group by a.empno,a.empname ) a ");
strSql.Append("(select count(*) as courses,a.empno,a.empname from ArrangeLessonTerm a where lessondate between '" + starttime + "' and '" + endtime + "' group by a.empno,a.empname ) a ");
strSql.Append("left join (select count(*) as actcourses,empno from Teach_attendance where clocktime between '" + starttime + "' and '" + endtime + "' group by empno) ta on ta.empno=a.empno ");
strSql.Append("left join empinfo b on a.empno=b.empno ");
strSql.Append("where a.empno is not null ");
@@ -2247,6 +2251,171 @@ group by AcademicYearNo,Semester,DeptNo,MajorNo,LessonNo,TeachClassNo,EmpNo,Les
}
}
}


/// <summary>
/// 导入
/// </summary>
/// <param name="dt"></param>
/// <param name="fileId"></param>
/// <returns></returns>
public string ArrangeLessonTermImport(DataTable dt, string fileId)
{
try
{
int snum = 0;
int fnum = 0;
if (dt.Rows.Count > 0)
{
DataTable failDt = new DataTable();
dt.Columns.Add("导入错误", typeof(string));
foreach (DataColumn dc in dt.Columns)
{
failDt.Columns.Add(dc.ColumnName, dc.DataType);
}
var db = this.BaseRepository().BeginTrans();

IEnumerable<ArrangeLessonTermEntity> ArrangeLessonTermHistory = db.FindList<ArrangeLessonTermEntity>("select * from ArrangeLessonTerm");
var ArrangeLessonTerminsert = new List<ArrangeLessonTermEntity>();

// 循环遍历导入
foreach (DataRow dr in dt.Rows)
{
try
{
#region 必填项空验证
if (dr["上课日期"].ToString().IsEmpty())
{
throw (new Exception("资上课日期不能为空"));
}
if (dr["开始时间"].ToString().IsEmpty())
{
throw (new Exception("开始时间不能为空"));
}
if (dr["结束时间"].ToString().IsEmpty())
{
throw (new Exception("结束时间不能为空"));
}
if (dr["学年"].ToString().IsEmpty())
{
throw (new Exception("学年不能为空"));
}
if (dr["学期"].ToString().IsEmpty())
{
throw (new Exception("学期入账日期不能为空"));
}
if (dr["班级"].ToString().IsEmpty())
{
throw (new Exception("班级类型不能为空"));
}
if (dr["课程"].ToString().IsEmpty())
{
throw (new Exception("课程不能为空"));
}
if (dr["教师姓名"].ToString().IsEmpty())
{
throw (new Exception("教师姓名不能为空"));
}
if (dr["上课时间"].ToString().IsEmpty())
{
throw (new Exception("上课时间不能为空"));
}
if (dr["是否必修课"].ToString().IsEmpty())
{
throw (new Exception("是否必修课不能为空"));
}
#endregion
//插入时间
var Insertdate = DateTime.Now;
var LessonName = dr["课程"].ToString();
var ClassName = dr["班级"].ToString();
var ClassroomName = dr["教室"].ToString();
var EmpName = dr["教师姓名"].ToString();
//基础数据
var lessonEntity = BaseRepository("CollegeMIS").FindEntity<LessonInfoEntity>(x => x.LessonName == LessonName);
var classEntity = BaseRepository("CollegeMIS").FindEntity<ClassInfoEntity>(x => x.ClassName == ClassName);
var classroomEntity = BaseRepository("CollegeMIS").FindEntity<ClassroomInfoEntity>(x => x.ClassroomName == ClassroomName);
var CompanyEntity = BaseRepository("CollegeMIS").FindList<CompanyEntity>().FirstOrDefault();
var empinfoEntity = BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpName == EmpName);

//写入要导入替换的数据
ArrangeLessonTermEntity arrangeLessonTermEntity = new ArrangeLessonTermEntity
{
ALTId = Guid.NewGuid().ToString(),
LessonDate = dr["上课日期"].ToDate(),
StartTime = dr["开始时间"].ToString(),
EndTime = dr["结束时间"].ToString(),
AcademicYearNo = dr["学年"].ToString(),
Semester = dr["学期"].ToString(),
DeptNo = classEntity.DeptNo,
MajorNo = classEntity.MajorNo,
LessonNo = lessonEntity.LessonNo,
LessonName = lessonEntity.LessonName,
TeachClassNo = lessonEntity.LessonName + classEntity.ClassNo,
EmpNo = empinfoEntity.EmpNo,
EmpName = empinfoEntity.EmpName,
ClassroomNo = classroomEntity.ClassroomNo,
LessonTime = dr["上课时间"].ToString(),
LessonSortNo = dr["是否必修课"].ToString() == "是" ? "1" : "0",
//默认数据
CheckMark = "1",
InsertDate = Insertdate,
IsImport = true,
F_SchoolId = CompanyEntity.F_CompanyId,

};

#region 判断是否重复
if (ArrangeLessonTermHistory.Count(m => m.AcademicYearNo == arrangeLessonTermEntity.AcademicYearNo && m.Semester == arrangeLessonTermEntity.Semester
&& m.LessonNo == arrangeLessonTermEntity.LessonNo && m.LessonDate.Value.Date == arrangeLessonTermEntity.LessonDate.Value.Date
&& m.DeptNo == arrangeLessonTermEntity.DeptNo && m.MajorNo == arrangeLessonTermEntity.MajorNo
&& m.TeachClassNo == arrangeLessonTermEntity.TeachClassNo && m.EmpNo == arrangeLessonTermEntity.EmpNo
&& m.ClassroomNo == arrangeLessonTermEntity.ClassroomNo && m.LessonTime == arrangeLessonTermEntity.LessonTime
&& m.F_SchoolId == arrangeLessonTermEntity.F_SchoolId) == 0
&& ArrangeLessonTerminsert.Count(m => m.AcademicYearNo == arrangeLessonTermEntity.AcademicYearNo && m.Semester == arrangeLessonTermEntity.Semester
&& m.LessonNo == arrangeLessonTermEntity.LessonNo && m.LessonDate.Value.Date == arrangeLessonTermEntity.LessonDate.Value.Date
&& m.DeptNo == arrangeLessonTermEntity.DeptNo && m.MajorNo == arrangeLessonTermEntity.MajorNo
&& m.TeachClassNo == arrangeLessonTermEntity.TeachClassNo && m.EmpNo == arrangeLessonTermEntity.EmpNo
&& m.ClassroomNo == arrangeLessonTermEntity.ClassroomNo && m.LessonTime == arrangeLessonTermEntity.LessonTime
&& m.F_SchoolId == arrangeLessonTermEntity.F_SchoolId) == 0)
{
ArrangeLessonTerminsert.Add(arrangeLessonTermEntity);
snum++;
}
#endregion
}
catch (Exception ex)
{
fnum++;
dr["导入错误"] = ex.Message;
failDt.Rows.Add(dr.ItemArray);
}
}
//执行导入
db.Insert(ArrangeLessonTerminsert);
db.Commit();
if (failDt.Rows.Count > 0)
{
string errordt = failDt.ToJson();
cache.Write<string>(cacheKey + fileId, errordt, CacheId.excel);
}
}
return snum + "|" + fnum;
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}


}




Loading…
Cancel
Save