diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.cshtml index 5914e4a10..96b8ee1a4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.cshtml @@ -15,5 +15,9 @@
学期*
+
+
同步内容*
+
+
@Html.AppendJsFile("/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.js index 687edd9ed..ade8a43ea 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/ArrangeLessonTerm/SyncByConditionForm.js @@ -30,6 +30,12 @@ var bootstrap = function ($, learun) { value: 'value', text: 'text' }); + $('#SyncType').lrselect({ + placeholder: "请选择同步内容", + data: [{ text: "课表", value: "1" }, { text: "开课计划", value: "2" }], + value: 'value', + text: 'text' + }); }, initData: function () { //if (!!selectedRow) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs index b0fe45dbe..c119ffef3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermEntity.cs @@ -152,6 +152,10 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration [NotMapped] public string coefficient { get; set; } [NotMapped] public string SyncBasicTable { get; set; } + /// + /// 同步内容1课表2开课计划 + /// + [NotMapped] public string SyncType { get; set; } #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs index c38935487..8cefc6d44 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/ArrangeLessonTerm/ArrangeLessonTermService.cs @@ -659,11 +659,7 @@ WHERE (AcademicYearNo = '" + strAcademicYear + "') and semester='" + strSemest } return result; } - - - private string stringSchoolId; - private string stringAcademicYear; - private string stringSemester; + /// /// 按条件同步排课数据 /// @@ -673,31 +669,87 @@ WHERE (AcademicYearNo = '" + strAcademicYear + "') and semester='" + strSemest bool result = false; try { - HttpContent httpContent = new StringContent("{\"school\":\"" + entity.F_SchoolId + "\",\"year\":\"" + entity.AcademicYearNo + "\",\"number\":\"" + entity.Semester + "\"}"); - httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); - string apiData = await Client.PostAsync(Config.GetValue("ArrangeLessonAPI"), httpContent).Result.Content.ReadAsStringAsync(); - - if (!string.IsNullOrEmpty(apiData)) + var lessonData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var classData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var classroomData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + if (entity.SyncType == "1") { - var data = JsonConvert.DeserializeObject(apiData); - var dataList = data.entity.list; - if (dataList.Any()) + HttpContent httpContent = new StringContent("{\"school\":\"" + entity.F_SchoolId + "\",\"year\":\"" + entity.AcademicYearNo + "\",\"number\":\"" + entity.Semester + "\"}"); + httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + string apiData = await Client.PostAsync(Config.GetValue("ArrangeLessonAPI"), httpContent).Result.Content.ReadAsStringAsync(); + + if (!string.IsNullOrEmpty(apiData)) { - var oldArrangeLessonTermList = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var insertDataList = new List(); - var lessonData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var classData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var classroomData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - foreach (var item in dataList) + var data = JsonConvert.DeserializeObject(apiData); + var dataList = data.entity.list; + if (dataList.Any()) { - var classinfo = classData.FirstOrDefault(m => m.ClassId == item.clazzSid); - - var timesArr = item.timeText.Substring(0, item.timeText.Length - 1).Split(','); - foreach (var timesItem in timesArr) + var oldArrangeLessonTermList = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var insertDataList = new List(); + + foreach (var item in dataList) { - if (item.section.Contains(",")) + var classinfo = classData.FirstOrDefault(m => m.ClassId == item.clazzSid); + + var timesArr = item.timeText.Substring(0, item.timeText.Length - 1).Split(','); + foreach (var timesItem in timesArr) { - foreach (var sec in item.section.Split(',')) + if (item.section.Contains(",")) + { + foreach (var sec in item.section.Split(',')) + { + var insertData = new ArrangeLessonTermEntity + { + ALTId = Guid.NewGuid().ToString(), + LessonDate = DateTime.Parse(timesItem), + AcademicYearNo = item.year, + Semester = item.number, + DeptNo = classinfo?.DeptNo, + MajorNo = classinfo?.MajorNo, + LessonNo = item.curriculunNumber, + LessonName = item.curriculunName, + TeachClassNo = item.curriculunName + classinfo?.ClassNo, + EmpNo = item.teacherNumber, + EmpName = item.teacherName, + LessonSortNo = lessonData.FirstOrDefault(m => m.LessonId == item.curriculunSid)?.LessonSortNo, + ClassroomNo = classroomData.FirstOrDefault(m => m.ClassroomId == item.classRoomSid)?.ClassroomNo, + LessonTime = item.week + sec, + CheckMark = "1", + F_SchoolId = item.schoolSid + }; + if (oldArrangeLessonTermList.Count(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester + && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate + && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo + && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo + && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime + && m.F_SchoolId == insertData.F_SchoolId) == 0 + && insertDataList.Count(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester + && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate + && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo + && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo + && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime + && m.F_SchoolId == insertData.F_SchoolId) == 0) + { + insertDataList.Add(insertData); + } + //if (!oldArrangeLessonTermList.Any(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester + // && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate + // && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo + // && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo + // && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime + // && m.F_SchoolId == insertData.F_SchoolId) + // && !insertDataList.Any(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester + // && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate + // && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo + // && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo + // && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime + // && m.F_SchoolId == insertData.F_SchoolId)) + //{ + // insertDataList.Add(insertData); + //} + } + } + else { var insertData = new ArrangeLessonTermEntity { @@ -714,13 +766,10 @@ WHERE (AcademicYearNo = '" + strAcademicYear + "') and semester='" + strSemest EmpName = item.teacherName, LessonSortNo = lessonData.FirstOrDefault(m => m.LessonId == item.curriculunSid)?.LessonSortNo, ClassroomNo = classroomData.FirstOrDefault(m => m.ClassroomId == item.classRoomSid)?.ClassroomNo, - LessonTime = item.week + sec, + LessonTime = item.week + item.section, CheckMark = "1", F_SchoolId = item.schoolSid }; - stringSchoolId = insertData.F_SchoolId; - stringAcademicYear = insertData.AcademicYearNo; - stringSemester = insertData.Semester; if (oldArrangeLessonTermList.Count(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo @@ -736,121 +785,126 @@ WHERE (AcademicYearNo = '" + strAcademicYear + "') and semester='" + strSemest { insertDataList.Add(insertData); } - //if (!oldArrangeLessonTermList.Any(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester - // && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate - // && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo - // && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo - // && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime - // && m.F_SchoolId == insertData.F_SchoolId) - // && !insertDataList.Any(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester - // && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate - // && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo - // && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo - // && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime - // && m.F_SchoolId == insertData.F_SchoolId)) - //{ - // insertDataList.Add(insertData); - //} - } - } - else - { - var insertData = new ArrangeLessonTermEntity - { - ALTId = Guid.NewGuid().ToString(), - LessonDate = DateTime.Parse(timesItem), - AcademicYearNo = item.year, - Semester = item.number, - DeptNo = classinfo?.DeptNo, - MajorNo = classinfo?.MajorNo, - LessonNo = item.curriculunNumber, - LessonName = item.curriculunName, - TeachClassNo = item.curriculunName + classinfo?.ClassNo, - EmpNo = item.teacherNumber, - EmpName = item.teacherName, - LessonSortNo = lessonData.FirstOrDefault(m => m.LessonId == item.curriculunSid)?.LessonSortNo, - ClassroomNo = classroomData.FirstOrDefault(m => m.ClassroomId == item.classRoomSid)?.ClassroomNo, - LessonTime = item.week + item.section, - CheckMark = "1", - F_SchoolId = item.schoolSid - }; - stringSchoolId = insertData.F_SchoolId; - stringAcademicYear = insertData.AcademicYearNo; - stringSemester = insertData.Semester; - if (oldArrangeLessonTermList.Count(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester - && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate - && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo - && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo - && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime - && m.F_SchoolId == insertData.F_SchoolId) == 0 - && insertDataList.Count(m => m.AcademicYearNo == insertData.AcademicYearNo && m.Semester == insertData.Semester - && m.LessonNo == insertData.LessonNo && m.LessonDate == insertData.LessonDate - && m.DeptNo == insertData.DeptNo && m.MajorNo == insertData.MajorNo - && m.TeachClassNo == insertData.TeachClassNo && m.EmpNo == insertData.EmpNo - && m.ClassroomNo == insertData.ClassroomNo && m.LessonTime == insertData.LessonTime - && m.F_SchoolId == insertData.F_SchoolId) == 0) - { - insertDataList.Add(insertData); } } } - } - var insertResult = await BaseRepository("CollegeMIS").InsertAsync(insertDataList); + await BaseRepository("CollegeMIS").InsertAsync(insertDataList); + + //TeachClass数据处理 + // var arrangeLessonTermData = (await BaseRepository("CollegeMIS").FindListAsync(@"select F_SchoolId,AcademicYearNo,Semester,DeptNo,majorno,lessonno,replace(teachclassno,lessonname,'') as teachclassno,empno from [dbo].[ArrangeLessonTerm] + //where (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + stringSemester + "' and F_SchoolId = '" + stringSchoolId + @"' + //group by F_SchoolId,AcademicYearNo,Semester,DeptNo,majorno,lessonno,replace(teachclassno,lessonname,'') ,empno ")).ToList(); + // var TeachClassData = (await BaseRepository("CollegeMIS").FindListAsync(@"SELECT * + //FROM TeachClass + //WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + stringSemester + "' and F_SchoolId='" + stringSchoolId + "' ")).ToList(); + // var insertTeachClassDataList = new List(); + // if (arrangeLessonTermData.Any()) + // { + // foreach (var altitem in arrangeLessonTermData) + // { + // var insertTeachClassData = new TeachClassEntity() + // { + // AcademicYearNo = altitem.AcademicYearNo, + // Semester = altitem.Semester, + // DeptNo = altitem.DeptNo, + // MajorNo = altitem.MajorNo, + // LessonNo = altitem.LessonNo, + // Grade = classData.FirstOrDefault(m => m.ClassNo == altitem.TeachClassNo)?.Grade, + // LessonSortNo ="1", + // TeachClassNo = altitem.TeachClassNo, + // EmpNo = altitem.EmpNo, + // F_SchoolId = altitem.F_SchoolId + // }; + // //非空判断 + // if (TeachClassData.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && + // m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && + // m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && + // m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && + // m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && + // m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0 + // && insertTeachClassDataList.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && + // m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && + // m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && + // m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && + // m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && + // m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0) + // { + // insertTeachClassDataList.Add(insertTeachClassData); + // } + + // } + // await BaseRepository("CollegeMIS").InsertAsync(insertTeachClassDataList); + // } - //TeachClass数据处理 - var arrangeLessonTermData = (await BaseRepository("CollegeMIS").FindListAsync(@"select F_SchoolId,AcademicYearNo,Semester,DeptNo,majorno,lessonno,replace(teachclassno,lessonname,'') as teachclassno,empno from [dbo].[ArrangeLessonTerm] -where (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + stringSemester + "' and F_SchoolId = '" + stringSchoolId + @"' -group by F_SchoolId,AcademicYearNo,Semester,DeptNo,majorno,lessonno,replace(teachclassno,lessonname,'') ,empno ")).ToList(); - var TeachClassData = (await BaseRepository("CollegeMIS").FindListAsync(@"SELECT * -FROM TeachClass -WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + stringSemester + "' and F_SchoolId='" + stringSchoolId + "' ")).ToList(); - var insertTeachClassDataList = new List(); - if (arrangeLessonTermData.Any()) - { - foreach (var altitem in arrangeLessonTermData) - { - var insertTeachClassData = new TeachClassEntity() - { - AcademicYearNo = altitem.AcademicYearNo, - Semester = altitem.Semester, - DeptNo = altitem.DeptNo, - MajorNo = altitem.MajorNo, - LessonNo = altitem.LessonNo, - Grade = classData.FirstOrDefault(m => m.ClassNo == altitem.TeachClassNo)?.Grade, - LessonSortNo ="1", - TeachClassNo = altitem.TeachClassNo, - EmpNo = altitem.EmpNo, - F_SchoolId = altitem.F_SchoolId - }; - //非空判断 - if (TeachClassData.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && - m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && - m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && - m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && - m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && - m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0 - && insertTeachClassDataList.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && - m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && - m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && - m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && - m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && - m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0) - { - insertTeachClassDataList.Add(insertTeachClassData); - } - - } - await BaseRepository("CollegeMIS").InsertAsync(insertTeachClassDataList); } - //继续openlessonplan同步 - await AsyncOpenLessonPlanDataByCondition(entity); - if (insertResult > 0) + } + } + else + { + //TeachClass数据处理 20211214改为直接读取mysql库 + var teachclasslist = BaseRepository("paikeDbString").FindList(@"SELECT clazz.name AS 'clazzname', + clazz.number AS 'TeachClassNo', + curriculum.name AS 'curriculumname', + curriculum.number AS 'LessonNo', + semester.year AS 'AcademicYearNo', + semester.number AS 'Semester', + a.jointclass AS 'jointclass', + a.type AS 'LessonSortNo', + a.classhour AS 'classhour', + room.name AS 'roomname', + room.number AS 'roomnumber', + teacher.name AS 'teachername', + teacher.number AS 'EmpNo' + FROM tb_class_plan a + LEFT JOIN tb_clazz clazz ON clazz.id = a.clazzid + LEFT JOIN tb_semester semester ON semester.id = clazz.semester + LEFT JOIN tb_curriculum curriculum ON curriculum.id = a.curriculum + LEFT JOIN tb_classroom room ON room.id = a.classroom + LEFT JOIN tb_teacher teacher ON teacher.id = a.teacher + WHERE semester.year = '" + entity.AcademicYearNo + "' AND semester.number = '" + entity.Semester + "'"); + var TeachClassData = (await BaseRepository("CollegeMIS").FindListAsync(@"SELECT * + FROM TeachClass + WHERE (AcademicYearNo = '" + entity.AcademicYearNo + "') and semester='" + entity.Semester + "' and F_SchoolId='" + entity.F_SchoolId + "' ")).ToList(); + //待插入数据 + var insertTeachClassDataList = new List(); + foreach (var teachClassEntity in teachclasslist) + { + var classitemEntity = classData.FirstOrDefault(m => m.ClassNo == teachClassEntity.TeachClassNo); + var insertTeachClassData = new TeachClassEntity() { - result = true; + AcademicYearNo = teachClassEntity.AcademicYearNo, + Semester = teachClassEntity.Semester, + DeptNo = classitemEntity?.DeptNo, + MajorNo = classitemEntity?.MajorNo, + LessonNo = teachClassEntity.LessonNo, + Grade = classitemEntity?.Grade, + LessonSortNo = teachClassEntity.LessonSortNo, + TeachClassNo = teachClassEntity.TeachClassNo, + EmpNo = teachClassEntity.EmpNo, + F_SchoolId = entity.F_SchoolId + }; + //非空判断 + if (TeachClassData.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && + m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && + m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && + m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && + m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && + m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0 + && insertTeachClassDataList.Count(m => m.AcademicYearNo == insertTeachClassData.AcademicYearNo && + m.Semester == insertTeachClassData.Semester && m.DeptNo == insertTeachClassData.DeptNo && + m.MajorNo == insertTeachClassData.MajorNo && m.LessonNo == insertTeachClassData.LessonNo && + m.Grade == insertTeachClassData.Grade && m.LessonSortNo == insertTeachClassData.LessonSortNo && + m.TeachClassNo == insertTeachClassData.TeachClassNo && m.EmpNo == insertTeachClassData.EmpNo && + m.F_SchoolId == insertTeachClassData.F_SchoolId) == 0) + { + insertTeachClassDataList.Add(insertTeachClassData); } } + await BaseRepository("CollegeMIS").InsertAsync(insertTeachClassDataList); + //继续openlessonplan同步 + await AsyncOpenLessonPlanDataByCondition(entity); } - + result = true; } catch (Exception ex) { @@ -872,13 +926,13 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string /// public async Task AsyncOpenLessonPlanDataByCondition(ArrangeLessonTermEntity entity) { - bool result = false; try { HttpContent httpContent = new StringContent("{\"school\":\"" + entity.F_SchoolId + "\",\"year\":\"" + entity.AcademicYearNo + "\",\"number\":\"" + entity.Semester + "\"}"); httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); string apiData = await Client.PostAsync(Config.GetValue("OpenLessonPlanAPI"), httpContent).Result.Content.ReadAsStringAsync(); - + var majorData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var lessonData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); if (!string.IsNullOrEmpty(apiData)) { var data = JsonConvert.DeserializeObject(apiData); @@ -887,8 +941,7 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string if (dataList.Any()) { var insertDataList = new List(); - var majorData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var lessonData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var now = DateTime.Now; foreach (var item in dataList) { @@ -940,91 +993,84 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string insertDataList.Add(insertData); } } - var insertResult = await BaseRepository("CollegeMIS").InsertAsync(insertDataList); - //学生选课数据 - - var TeachClassData = (await BaseRepository("CollegeMIS").FindListAsync(@"SELECT * + await BaseRepository("CollegeMIS").InsertAsync(insertDataList); + } + } + //学生选课数据 + var TeachClassData = (await BaseRepository("CollegeMIS").FindListAsync(@"SELECT * FROM TeachClass -WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + stringSemester + "' and F_SchoolId='" + stringSchoolId + "' ")).ToList(); - var stuinfobasicData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var stuSelectLessonListEntityData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); - var insertStuSelectLessonListDataList = new List(); - if (TeachClassData.Any()) +WHERE (AcademicYearNo = '" + entity.AcademicYearNo + "') and semester='" + entity.Semester + "' and F_SchoolId='" + entity.F_SchoolId + "' ")).ToList(); + var stuinfobasicData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var stuSelectLessonListEntityData = (await BaseRepository("CollegeMIS").FindListAsync()).ToList(); + var insertStuSelectLessonListDataList = new List(); + if (TeachClassData.Any()) + { + foreach (var itemteachclass in TeachClassData) + { + var classstulist = stuinfobasicData.Where(m => m.ClassNo == itemteachclass.TeachClassNo) + .ToList(); + foreach (var stu in classstulist) { - foreach (var itemteachclass in TeachClassData) + var insertDatastuselect = new StuSelectLessonListEntity(); + insertDatastuselect.NoticeBookNo = stu.NoticeNo; + insertDatastuselect.StuNo = stu.StuNo; + insertDatastuselect.DeptNo = stu.DeptNo; + insertDatastuselect.ClassNo = stu.ClassNo; + insertDatastuselect.MajorNo = stu.MajorNo; + insertDatastuselect.StuName = stu.StuName; + insertDatastuselect.GenderNo = stu.GenderNo != null && stu.GenderNo.Value ? "1" : "0"; + insertDatastuselect.AcademicYearNo = itemteachclass.AcademicYearNo; + insertDatastuselect.Semester = itemteachclass.Semester; + insertDatastuselect.OpenLessonDeptNo = itemteachclass.DeptNo; + insertDatastuselect.OpenLessonMajorNo = itemteachclass.MajorNo; + insertDatastuselect.LessonNo = itemteachclass.LessonNo; + insertDatastuselect.LessonName = lessonData.FirstOrDefault(m => m.LessonNo == itemteachclass.LessonNo)?.LessonName; + insertDatastuselect.PartCode = ""; + insertDatastuselect.OrdinaryScoreScale = 1; + insertDatastuselect.TermInScoreScale = 1; + insertDatastuselect.TermEndScoreScale = 1; + insertDatastuselect.OtherScoreScale = 1; + insertDatastuselect.TeachClassNo = stu.ClassNo; + insertDatastuselect.LessonSortNo = lessonData.FirstOrDefault(m => m.LessonNo == itemteachclass.LessonNo)?.LessonSortNo; + insertDatastuselect.StuSortNo = "02"; + insertDatastuselect.Grade = stu.Grade; + insertDatastuselect.StudyScore = 0; + insertDatastuselect.TotalStudyHour = 0; + insertDatastuselect.IsInEffect = "1"; + insertDatastuselect.EmpNo = itemteachclass.EmpNo; + insertDatastuselect.IsPitchOn = "1"; + insertDatastuselect.CheckMark = "1"; + insertDatastuselect.InsertTime = DateTime.Now; + insertDatastuselect.F_SchoolId = itemteachclass.F_SchoolId; + if (stuSelectLessonListEntityData.Count(m => m.StuNo == insertDatastuselect.StuNo && + m.AcademicYearNo == insertDatastuselect.AcademicYearNo && + m.Semester == insertDatastuselect.Semester && + m.DeptNo == insertDatastuselect.DeptNo && + m.MajorNo == insertDatastuselect.MajorNo && + m.LessonNo == insertDatastuselect.LessonNo && + m.Grade == insertDatastuselect.Grade && + m.OpenLessonDeptNo == insertDatastuselect.OpenLessonDeptNo && + m.OpenLessonMajorNo == insertDatastuselect.OpenLessonMajorNo && + m.EmpNo == insertDatastuselect.EmpNo && m.ClassNo == insertDatastuselect.ClassNo && + m.F_SchoolId == insertDatastuselect.F_SchoolId) == 0 && + insertStuSelectLessonListDataList.Count(m => m.StuNo == insertDatastuselect.StuNo && + m.AcademicYearNo == insertDatastuselect.AcademicYearNo && + m.Semester == insertDatastuselect.Semester && + m.DeptNo == insertDatastuselect.DeptNo && + m.MajorNo == insertDatastuselect.MajorNo && + m.LessonNo == insertDatastuselect.LessonNo && + m.Grade == insertDatastuselect.Grade && + m.OpenLessonDeptNo == insertDatastuselect.OpenLessonDeptNo && + m.OpenLessonMajorNo == insertDatastuselect.OpenLessonMajorNo && + m.EmpNo == insertDatastuselect.EmpNo && m.ClassNo == insertDatastuselect.ClassNo && + m.F_SchoolId == insertDatastuselect.F_SchoolId) == 0) { - var classstulist = stuinfobasicData.Where(m => m.ClassNo == itemteachclass.TeachClassNo) - .ToList(); - foreach (var stu in classstulist) - { - var insertDatastuselect = new StuSelectLessonListEntity(); - insertDatastuselect.NoticeBookNo = stu.NoticeNo; - insertDatastuselect.StuNo = stu.StuNo; - insertDatastuselect.DeptNo = stu.DeptNo; - insertDatastuselect.ClassNo = stu.ClassNo; - insertDatastuselect.MajorNo = stu.MajorNo; - insertDatastuselect.StuName = stu.StuName; - insertDatastuselect.GenderNo = stu.GenderNo != null && stu.GenderNo.Value ? "1" : "0"; - insertDatastuselect.AcademicYearNo = itemteachclass.AcademicYearNo; - insertDatastuselect.Semester = itemteachclass.Semester; - insertDatastuselect.OpenLessonDeptNo = itemteachclass.DeptNo; - insertDatastuselect.OpenLessonMajorNo = itemteachclass.MajorNo; - insertDatastuselect.LessonNo = itemteachclass.LessonNo; - insertDatastuselect.LessonName = lessonData.FirstOrDefault(m => m.LessonNo == itemteachclass.LessonNo)?.LessonName; - insertDatastuselect.PartCode = ""; - insertDatastuselect.OrdinaryScoreScale = 1; - insertDatastuselect.TermInScoreScale = 1; - insertDatastuselect.TermEndScoreScale = 1; - insertDatastuselect.OtherScoreScale = 1; - insertDatastuselect.TeachClassNo = stu.ClassNo; - insertDatastuselect.LessonSortNo = lessonData.FirstOrDefault(m => m.LessonNo == itemteachclass.LessonNo)?.LessonSortNo; - insertDatastuselect.StuSortNo = "02"; - insertDatastuselect.Grade = stu.Grade; - insertDatastuselect.StudyScore = 0; - insertDatastuselect.TotalStudyHour = 0; - insertDatastuselect.IsInEffect = "1"; - insertDatastuselect.EmpNo = itemteachclass.EmpNo; - insertDatastuselect.IsPitchOn = "1"; - insertDatastuselect.CheckMark = "1"; - insertDatastuselect.InsertTime = DateTime.Now; - insertDatastuselect.F_SchoolId = itemteachclass.F_SchoolId; - if (stuSelectLessonListEntityData.Count(m => m.StuNo == insertDatastuselect.StuNo && - m.AcademicYearNo == insertDatastuselect.AcademicYearNo && - m.Semester == insertDatastuselect.Semester && - m.DeptNo == insertDatastuselect.DeptNo && - m.MajorNo == insertDatastuselect.MajorNo && - m.LessonNo == insertDatastuselect.LessonNo && - m.Grade == insertDatastuselect.Grade && - m.OpenLessonDeptNo == insertDatastuselect.OpenLessonDeptNo && - m.OpenLessonMajorNo == insertDatastuselect.OpenLessonMajorNo && - m.EmpNo == insertDatastuselect.EmpNo && m.ClassNo == insertDatastuselect.ClassNo && - m.F_SchoolId == insertDatastuselect.F_SchoolId) == 0 && - insertStuSelectLessonListDataList.Count(m => m.StuNo == insertDatastuselect.StuNo && - m.AcademicYearNo == insertDatastuselect.AcademicYearNo && - m.Semester == insertDatastuselect.Semester && - m.DeptNo == insertDatastuselect.DeptNo && - m.MajorNo == insertDatastuselect.MajorNo && - m.LessonNo == insertDatastuselect.LessonNo && - m.Grade == insertDatastuselect.Grade && - m.OpenLessonDeptNo == insertDatastuselect.OpenLessonDeptNo && - m.OpenLessonMajorNo == insertDatastuselect.OpenLessonMajorNo && - m.EmpNo == insertDatastuselect.EmpNo && m.ClassNo == insertDatastuselect.ClassNo && - m.F_SchoolId == insertDatastuselect.F_SchoolId) == 0) - { - insertStuSelectLessonListDataList.Add(insertDatastuselect); - } - } + insertStuSelectLessonListDataList.Add(insertDatastuselect); } - await BaseRepository("CollegeMIS").InsertAsync(insertStuSelectLessonListDataList); - } - if (insertResult > 0) - { - result = true; } - } + await BaseRepository("CollegeMIS").InsertAsync(insertStuSelectLessonListDataList); } - } catch (Exception ex) { @@ -1037,7 +1083,7 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string throw ExceptionEx.ThrowServiceException(ex); } } - return result; + return true; } /// @@ -1520,13 +1566,13 @@ WHERE (AcademicYearNo = '" + stringAcademicYear + "') and semester='" + string try { //var data = BaseRepository("CollegeMIS").FindList(@"select a.StuId,a.StuNo,a.DeptNo,a.MajorNo,a.Grade,a.ClassNo,a.StuName,a.GenderNo,a.Birthday,b.F_Password,b.F_Secretkey from dbo.StuInfoBasic a left join adms7ultimate2.dbo.LR_Base_User b on a.StuNo=b.F_EnCode where a.CheckMark='1'"); - + //数据 var db = BaseRepository("CollegeMIS"); var dbbase = BaseRepository(); db.BeginTrans(); var data = db.FindList("select a.*,b.F_Password,b.F_Secretkey from dbo.StuInfoBasic a left join " + dbbase.getDbConnection().Database + ".dbo.LR_Base_User b on a.StuNo=b.F_EnCode where a.CheckMark=1 and a.StuId not in (select STableId from ArrangeLessonSync where AcademicYearNo='" + academicYearNo + "' and Semester='" + semester + "' )"); - + db.Commit(); return data; } @@ -2653,8 +2699,8 @@ group by AcademicYearNo,Semester,DeptNo,MajorNo,LessonNo,TeachClassNo,EmpNo,Les /// 开课计划 /// public CourseOfPlanByCondition course { get; set; } - public int classhour { get; set; } - public int credit { get; set; } + public int? classhour { get; set; } + public int? credit { get; set; } public string grade { get; set; } }