@@ -3,6 +3,7 @@ using System.Data; | |||
using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement; | |||
using System.Web.Mvc; | |||
using System.Collections.Generic; | |||
using Learun.Application.Base.SystemModule; | |||
namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers | |||
{ | |||
@@ -16,6 +17,7 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers | |||
public class FinaChargeStuYearItemController : MvcControllerBase | |||
{ | |||
private FinaChargeStuYearItemIBLL finaChargeStuYearItemIBLL = new FinaChargeStuYearItemBLL(); | |||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||
#region 视图功能 | |||
@@ -37,6 +39,12 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers | |||
{ | |||
return View(); | |||
} | |||
[HttpGet] | |||
public ActionResult Import() | |||
{ | |||
return View(); | |||
} | |||
#endregion | |||
#region 获取数据 | |||
@@ -118,6 +126,36 @@ namespace Learun.Application.Web.Areas.ReceiveSendFeeManagement.Controllers | |||
} | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 导入 | |||
/// </summary> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="chunks"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
[HttpPost] | |||
[ValidateAntiForgeryToken] | |||
public ActionResult ExecuteImportExcel(string fileGuid, int chunks, string queryJson) | |||
{ | |||
string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get()); | |||
if (!string.IsNullOrEmpty(path)) | |||
{ | |||
DataTable dt = ExcelHelper.ExcelImport(path); | |||
(DataTable failDt, int snum, int fnum) res; | |||
res = finaChargeStuYearItemIBLL.ExecuteImportExcel(dt, fileGuid, queryJson); | |||
var data = new | |||
{ | |||
Success =10, | |||
Fail = 0 | |||
}; | |||
return Success(data); | |||
} | |||
else | |||
{ | |||
return Fail("导入数据失败!"); | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -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/ReceiveSendFeeManagement/Views/FinaChargeStuYearItem/Import.js") |
@@ -0,0 +1,175 @@ | |||
/* | |||
* 描 述:附件上传管理 | |||
*/ | |||
var gridId = request('gridtable'); | |||
var bootstrap = function ($, learun) { | |||
"use strict"; | |||
var fileInfo = {}; | |||
// 触发合并文件碎片 | |||
var mergeFileChunks = function (file) { | |||
var param = {}; | |||
param['__RequestVerificationToken'] = $.lrToken; | |||
param['fileGuid'] = fileInfo[file.id].fileGuid; | |||
param['fileName'] = fileInfo[file.id].name; | |||
param['chunks'] = fileInfo[file.id].chunks; | |||
var queryJson = JSON.stringify(learun.frameTab.currentIframe().queryJson); | |||
param['queryJson'] = queryJson; | |||
learun.httpAsyncPost(top.$.rootUrl + "/ReceiveSendFeeManagement/FinaChargeStuYearItem/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' }); | |||
} | |||
} | |||
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 () { | |||
learun.download({ | |||
method: "get", | |||
url: '/Content/excel/缴费明细.xls' | |||
}); | |||
}); | |||
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(); | |||
} |
@@ -55,7 +55,7 @@ | |||
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a> | |||
</div> | |||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | |||
<a id="lr_add" class="btn btn-default"><i class="fa fa-plus"></i> 新增</a> | |||
<a id="lr_add" class="btn btn-default"><i class="fa fa-plus"></i> 导入</a> | |||
<a id="lr_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 恢复</a> | |||
<a id="lr_delete" class="btn btn-default"><i class="fa fa-trash-o"></i> 作废</a> | |||
</div> | |||
@@ -36,16 +36,18 @@ var bootstrap = function ($, learun) { | |||
$('#lr_refresh').on('click', function () { | |||
location.reload(); | |||
}); | |||
// 新增 | |||
// 导入 | |||
$('#lr_add').on('click', function () { | |||
learun.layerForm({ | |||
id: 'form', | |||
title: '新增', | |||
url: top.$.rootUrl + '/ReceiveSendFeeManagement/FinaChargeStuYearItem/Form', | |||
id: 'indexImport', | |||
title: "导入收费", | |||
url: top.$.rootUrl + '/ReceiveSendFeeManagement/FinaChargeStuYearItem/Import', | |||
width: 600, | |||
height: 400, | |||
callBack: function (id) { | |||
return top[id].acceptClick(refreshGirdData); | |||
maxmin: true, | |||
btn: null, | |||
end: function () { | |||
refreshGirdData(); | |||
} | |||
}); | |||
}); | |||
@@ -1630,6 +1630,7 @@ | |||
<Content Include="Areas\PersonnelManagement\Views\WorkStudyPositionApply\Form.js" /> | |||
<Content Include="Areas\PersonnelManagement\Views\WorkStudyPositionApply\FormView.js" /> | |||
<Content Include="Areas\PersonnelManagement\Views\WorkStudyPositionApply\Index.js" /> | |||
<Content Include="Areas\ReceiveSendFeeManagement\Views\FinaChargeStuYearItem\Import.js" /> | |||
<Content Include="Areas\ReceiveSendFeeManagement\Views\FinaChargeStuYear\GenerateByConditionForm.js" /> | |||
<Content Include="Areas\StudentWork\Views\SW_Ask_Main\AnswerIndex.js" /> | |||
<Content Include="Areas\StudentWork\Views\SW_Ask_Main\AnswerQuery.js" /> | |||
@@ -7964,6 +7965,8 @@ | |||
<Content Include="Content\excel\OrderDetail.xls" /> | |||
<Content Include="Areas\StuPayManage\Views\web.config" /> | |||
<Content Include="Areas\ReceiveSendFeeManagement\Views\FinaChargeStuYear\GenerateByConditionForm.cshtml" /> | |||
<Content Include="Areas\ReceiveSendFeeManagement\Views\FinaChargeStuYearItem\Import.cshtml" /> | |||
<Content Include="Content\excel\缴费明细.xls" /> | |||
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" /> | |||
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" /> | |||
<Content Include="Views\Login\Default-beifen.cshtml" /> | |||
@@ -137,6 +137,25 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
} | |||
} | |||
} | |||
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson) | |||
{ | |||
try | |||
{ | |||
return FinaChargeStuYearItemService.ExecuteImportExcel(dt, fileGuid, queryJson); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
@@ -45,5 +45,6 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
#endregion | |||
void UnDeleteEntity(string keyValue); | |||
(DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson); | |||
} | |||
} |
@@ -5,6 +5,8 @@ using System; | |||
using System.Collections.Generic; | |||
using System.Data; | |||
using System.Text; | |||
using Learun.Cache.Base; | |||
using Learun.Cache.Factory; | |||
namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
{ | |||
@@ -17,6 +19,8 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
/// </summary> | |||
public class FinaChargeStuYearItemService : RepositoryFactory | |||
{ | |||
private ICache cache = CacheFactory.CaChe(); | |||
private string cacheKey = "Learun_adms_excelError_"; | |||
#region 获取数据 | |||
/// <summary> | |||
@@ -71,7 +75,7 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
dp.Add("ChargeItemType", "" + queryParam["ChargeItemType"].ToString() + "", DbType.String); | |||
strSql.Append(" AND t.ChargeItemType = @ChargeItemType "); | |||
} | |||
return this.BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>(strSql.ToString(),dp, pagination); | |||
return this.BaseRepository("CollegeMIS").FindList<FinaChargeStuYearItemEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -216,5 +220,82 @@ namespace Learun.Application.TwoDevelopment.ReceiveSendFeeManagement | |||
#endregion | |||
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson) | |||
{ | |||
var db = this.BaseRepository("CollegeMIS").BeginTrans(); | |||
try | |||
{ | |||
int snum = 0; | |||
int fnum = 0; | |||
if (dt.Rows.Count > 0) | |||
{ | |||
//获取缴费学生 | |||
var stulist = db.FindList<FinaChargeStudentEntity>(m => m.F_CheckMark == true); | |||
DataTable failDt = new DataTable(); | |||
dt.Columns.Add("导入错误", typeof(string)); | |||
foreach (DataColumn dc in dt.Columns) | |||
{ | |||
failDt.Columns.Add(dc.ColumnName, dc.DataType); | |||
} | |||
// 循环遍历导入 | |||
foreach (DataRow dr in dt.Rows) | |||
{ | |||
//检测是否有空值 | |||
if (dr[0].ToString() == "" || dr[1].ToString() == "" || dr[2].ToString() == "" || dr[3].ToString() == "" || dr[4].ToString() == "" || dr[5].ToString() == ""||dr[6].ToString() == "") | |||
{ | |||
throw (new Exception("行内数据有空值,不能为空!")); | |||
} | |||
//检测缴费年度是否为数字 | |||
decimal payyearresult = 0; | |||
bool parsepayyearresult = decimal.TryParse(dr[0].ToString(), out payyearresult); | |||
if (!parsepayyearresult || dr[0].ToString().Length != 4) | |||
{ | |||
throw (new Exception("【缴费年度】格式不正确,必须为四位数字年份!")); | |||
} | |||
//首先校验金额是否为数字 | |||
//第六列是金额 | |||
decimal dresult = 0; | |||
bool parseresult = decimal.TryParse(dr[5].ToString(), out dresult); | |||
if (!parseresult) | |||
{ | |||
throw (new Exception("【金额】转换失败,必须为数字!")); | |||
} | |||
//金额不能小于等于零 | |||
if (dresult <= 0) | |||
{ | |||
throw (new Exception("【金额】不能为零或小于零,必须为正数!")); | |||
} | |||
//筛选不在标准代码表内的数据 | |||
//第五列是项目编码 | |||
if (typecodelist.Count(m => m.ProjectCode == dr[4].ToString()) == 0) | |||
{ | |||
throw (new Exception("【缴费项目编码】不存在,请核对!")); | |||
} | |||
} | |||
//获取已有年度学生缴费记录 | |||
var oldFinaChargeStuYearList = db.FindList<FinaChargeStuYearEntity>(m => m.FSYear == entity.FSYear); | |||
//获取已有年度学生缴费明细记录 | |||
var oldFinaChargeStuYearItemList = db.FindList<FinaChargeStuYearItemEntity>(m => m.FSYear == entity.FSYear); | |||
//获取收费标准 | |||
var finaChargesStandardList = db.FindList<FinaChargesStandardEntity>("select a.Grade,a.DeptNo,a.MajorNo,a.Standard,a.SYear,b.ChargeItemName,b.ChargeItemCode,b.ChargeItemType from [dbo].[FinaChargesStandard] a left join [dbo].[FinaChargeItem] b on a.ChargeItemID=b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0"); | |||
var finaChargesStandardListGroup = db.FindList<FinaChargesStandardEntity>(@"select a.Grade,a.DeptNo,a.MajorNo,sum(isnull(a.Standard,0)) as YJAmount,a.SYear | |||
from[dbo].[FinaChargesStandard] a left join[dbo].[FinaChargeItem] b on a.ChargeItemID = b.[ChargeItemID] where b.ChargeItemType=1 and a.SYear='" + entity.FSYear + "' and a.F_DeleteMark=0 and a.CheckMark=1 and b.CheckMark=1 and b.F_DeleteMark=0 group by a.Grade, a.DeptNo, a.MajorNo, a.SYear"); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
db.Rollback(); | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
} | |||
} |