Browse Source

第三方排课系统数据导入240221

黑艺新账号
北京泉江 9 months ago
parent
commit
2771d1a7ff
6 changed files with 331 additions and 3 deletions
  1. +32
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/TimeTableController.cs
  2. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/PkImportForm.js
  3. +2
    -2
      Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config
  4. +19
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermBLL.cs
  5. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermIBLL.cs
  6. +276
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs

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

@@ -9,6 +9,7 @@ using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.IO;
using Learun.Application.Base.SystemModule;

namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
{
@@ -30,6 +31,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private LessonInfoIBLL lessonInfoIBLL = new LessonInfoBLL();
private Edu_ChangeTeacherLessonIBLL edu_ChangeTeacherLessonIBLL = new Edu_ChangeTeacherLessonBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
#region 视图功能

/// <summary>
@@ -746,5 +748,35 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
return null;
}
}

/// <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.ArrangeLessonTermImportPk(dt, fileId);
var data = new
{
Success = res.Split('|')[0],
Fail = res.Split('|')[1]
};
return JsonResult(data);
}
else
{
return Fail("导入数据失败!");
}
}
}
}

+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Views/TimeTable/PkImportForm.js View File

@@ -107,7 +107,7 @@ var bootstrap = function ($, learun) {
param['ext'] = file.ext;
param['templateId'] = id;
console.log(111)
learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/ExcelImport/ArrangeLessonTermImport", param, function (res) {
learun.httpAsyncPost(top.$.rootUrl + "/PersonnelManagement/TimeTable/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) {


+ 2
- 2
Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/database.config View File

@@ -38,8 +38,8 @@
<!--<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2_塔里木;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=123.57.209.16;Initial Catalog=CollegeMIS_塔里木;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=123.57.209.16;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />-->
<add name="BaseDb" connectionString="Server=123.57.209.16;Initial Catalog=adms7ultimate2_黑龙江艺术;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=123.57.209.16;Initial Catalog=CollegeMIS_黑龙江艺术;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="BaseDb" connectionString="Server=.;Initial Catalog=adms7ultimate2_黑龙江艺术;User ID=sa;Password=1" providerName="System.Data.SqlClient" />
<add name="CollegeMIS" connectionString="Server=.;Initial Catalog=CollegeMIS_黑龙江艺术;User ID=sa;Password=1" providerName="System.Data.SqlClient" />
<add name="hangfireString" connectionString="Server=123.57.209.16;Initial Catalog=Hangfire;User ID=sa;Password=bjqjkj@2014~2015!" providerName="System.Data.SqlClient" />
<add name="paikeDbString" connectionString="Data Source=8.141.155.183;port=23306;Database=cspaike;User ID=root;Password=QJKJ@bjqj@123;" providerName="MySql.Data.MySqlClient" />
<!--塔里木中间库一卡通-->


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

@@ -643,5 +643,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}

public string ArrangeLessonTermImportPk(DataTable dt, string fileId)
{
try
{
return arrangeLessonTermService.ArrangeLessonTermImportPk(dt, fileId);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
}
}

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

@@ -160,5 +160,6 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
bool InitAsyncDataByCondition(ArrangeLessonTermEntity entity);

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

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

@@ -2471,6 +2471,282 @@ group by AcademicYearNo,Semester,DeptNo,MajorNo,LessonNo,TeachClassNo,EmpNo,Les
}
}

public string ArrangeLessonTermImportPk(DataTable dt, string fileId)
{
var db = this.BaseRepository("CollegeMIS").BeginTrans();
try
{
int snum = 0;
int fnum = 0;
//插入时间
var Insertdate = DateTime.Now;
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);
}

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

#region 上课时间
var lessonTimes = new Dictionary<int, Tuple<string, string>>();
lessonTimes.Add(1, new Tuple<string, string>("8:30", "9:15"));
lessonTimes.Add(2, new Tuple<string, string>("9:25", "10:10"));
lessonTimes.Add(3, new Tuple<string, string>("10:20", "11:00"));
lessonTimes.Add(4, new Tuple<string, string>("11:10", "11:50"));
lessonTimes.Add(5, new Tuple<string, string>("13:30", "14:15"));
lessonTimes.Add(6, new Tuple<string, string>("14:25", "15:10"));
lessonTimes.Add(7, new Tuple<string, string>("15:20", "16:00"));
lessonTimes.Add(8, new Tuple<string, string>("16:10", "16:50"));
lessonTimes.Add(9, new Tuple<string, string>("17:00", "17:40"));
lessonTimes.Add(10, new Tuple<string, string>("17:50", "18:30"));
#endregion

var startDate = DateTime.Today;
var endDate = DateTime.Today;

// 循环遍历导入
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("教师名称不能为空"));
}
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

#region 开始时间、结束时间格式判断
//var st = new TimeSpan();
//var stFlag = TimeSpan.TryParse(dr["开始时间"].ToString(), out st);
//if (!stFlag)
//{
// throw (new Exception("开始时间格式有误"));
//}
//var et = new TimeSpan();
//var etFlag = TimeSpan.TryParse(dr["结束时间"].ToString(), out et);
//if (!etFlag)
//{
// throw (new Exception("结束时间格式有误"));
//}

#endregion

#region 基础数据
var lessonEntity = db.FindList<LessonInfoEntity>($"select * from Lessoninfo where LessonName='" + dr["课程名称"].ToString().Trim() + "' and LessonNo='" + dr["课程编号"].ToString().Trim() + "' and CheckMark=1 ");
var classEntity = db.FindList<ClassInfoEntity>($"select * from ClassInfo where ClassName='" + dr["班级名称"].ToString().Trim() + "' and ClassNo='" + dr["班级编号"].ToString().Trim() + "' and CheckMark=1 ");
var classroomEntity = db.FindList<ClassroomInfoEntity>($"select * from ClassroomInfo where ClassroomName='" + dr["教室名称"].ToString().Trim() + "' and ClassroomNo='" + dr["教室编号"].ToString().Trim() + "' and CheckMark=1 ");
var empinfoEntity = db.FindList<EmpInfoEntity>($"select * from EmpInfo where EmpName='" + dr["教师名称"].ToString().Trim() + "' and EmpNo='" + dr["教师编号"].ToString().Trim() + "' and CheckMark=1 ");
var CompanyEntity = BaseRepository().FindList<CompanyEntity>(x => x.F_EnabledMark == 1).ToList().FirstOrDefault();
if (lessonEntity.Count() <= 0)
throw (new Exception("查无此课程"));
if (classEntity.Count() <= 0)
throw (new Exception("查无此班级"));
if (empinfoEntity.Count() <= 0)
throw (new Exception("查无此教师"));
if (classroomEntity.Count() <= 0)
throw (new Exception("查无此教室"));
#endregion
#region 初始化学期时间
startDate = dr["开始日期"].ToDate();
endDate = dr["结束日期"].ToDate();
#endregion
#region 计算课程开始结束 时间
var startWeek = dr["起始周"].ToInt();
var lessonStartDate = startDate.AddDays((startWeek - 1) * 7);
if (lessonStartDate < startDate) lessonStartDate = startDate;
var endWeek = dr["结束周"].ToInt();
var lessonEndDate = startDate.AddDays(endWeek * 7 - 1);
if (lessonEndDate > endDate) lessonEndDate = endDate;
#endregion
#region 计算真正的上课时间
var lessonWeekData = dr["上课周几"].ToInt();
var lessonStartDateWeek = (int)lessonStartDate.DayOfWeek;
if (lessonStartDateWeek == 0) lessonStartDateWeek = 7;
var trueStartDate = lessonStartDate;
if (lessonStartDateWeek <= lessonWeekData)
{
trueStartDate = lessonStartDate.AddDays(lessonWeekData - lessonStartDateWeek);
}
else
{
trueStartDate = lessonStartDate.AddDays(7 - (lessonStartDateWeek - lessonWeekData));
}
#endregion

var intLesson = dr["上课节次"].ToInt();
var lessonTime = lessonTimes[intLesson];
var weekType = dr["课程类型"].ToString();
while (true)
{
//写入要导入替换的数据
ArrangeLessonTermEntity arrangeLessonTermEntity = new ArrangeLessonTermEntity
{
ALTId = Guid.NewGuid().ToString(),
LessonDate = trueStartDate,
StartTime = TimeSpan.Parse(lessonTime.Item1).ToString(@"hh\:mm"),
EndTime = TimeSpan.Parse(lessonTime.Item2).ToString(@"hh\:mm"),
AcademicYearNo = dr["学年"].ToString(),
Semester = dr["学期"].ToString(),
DeptNo = classEntity.FirstOrDefault().DeptNo,
MajorNo = classEntity.FirstOrDefault().MajorNo,
LessonNo = lessonEntity.FirstOrDefault().LessonNo,
LessonName = lessonEntity.FirstOrDefault().LessonName,
TeachClassNo = lessonEntity.FirstOrDefault().LessonName + classEntity.FirstOrDefault().ClassNo,
EmpNo = empinfoEntity.FirstOrDefault().EmpNo,
EmpName = empinfoEntity.FirstOrDefault().EmpName,
ClassroomNo = classroomEntity.FirstOrDefault().ClassroomNo,
LessonTime = $"{dr["上课周几"].ToString()}{dr["上课节次"].ToString()}",
LessonSortNo = lessonEntity.FirstOrDefault().LessonSortNo,
//默认数;
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);
}
else
{
//throw (new Exception("当前数据重复"));
}
#endregion

if (weekType == "全周")
{
trueStartDate = trueStartDate.AddDays(7);
}
else
{
trueStartDate = trueStartDate.AddDays(14);
}

if (trueStartDate > lessonEndDate) break;
}
snum++;

}
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);
}
if (snum > 0)
{
//写入开课计划数据
InsertTeachClassDataInImport(Insertdate);
}
}
return snum + "|" + fnum;
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 课表导入时,写入开课计划数据
/// </summary>


Loading…
Cancel
Save