ExecutablePlanServices.cs 131 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Utility;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.EducationManagement;
  13. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  14. namespace EMIS.ExtensionLogic.CommonLogic.EducationManage
  15. {
  16. public class ExecutablePlanServices : EMIS.CommonLogic.EducationManage.ExecutablePlanServices
  17. {
  18. /// <summary>
  19. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  20. /// 注:关联对应的专业计划、刷新相关的教学任务信息
  21. /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息)
  22. /// 注:此为成教版本(入学学年学期、专业信息)
  23. /// 注:此版本学生人数小于等于0时,不可提交,但由于有异动的情况,需进一步优化逻辑(对教学任务班学生名单进行判断)
  24. /// </summary>
  25. /// <param name="executablePlanView"></param>
  26. public override void ExecutablePlanEdit(ExecutablePlanView executablePlanView)
  27. {
  28. try
  29. {
  30. //查询对应的课程信息
  31. var coursematerial = ExecutablePlanDAL.CoursematerialRepository.GetList(x => x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault();
  32. if (coursematerial == null)
  33. {
  34. throw new Exception("课程信息不存在,请检查。");
  35. }
  36. //查询对应的年级专业信息
  37. var grademajor = ExecutablePlanDAL.GrademajorRepository
  38. .GetList(x => x.GrademajorID == executablePlanView.GrademajorID).SingleOrDefault();
  39. if (grademajor == null)
  40. {
  41. throw new Exception("年级专业信息不存在,请检查。");
  42. }
  43. //查询年级专业对应的专业信息
  44. var specialty = ExecutablePlanDAL.GetSpecialtyQueryable(x => x.GrademajorID == executablePlanView.GrademajorID).SingleOrDefault();
  45. if (specialty == null)
  46. {
  47. throw new Exception("年级专业对应的专业信息不存在,请检查。");
  48. }
  49. //查询年级专业对应的入学学年学期信息
  50. var startSchoolyear = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
  51. if (startSchoolyear == null)
  52. {
  53. throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。");
  54. }
  55. //查询年级专业对应的毕业学年学期信息
  56. var graduatingSemester = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  57. if (graduatingSemester == null)
  58. {
  59. throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。");
  60. }
  61. //查询对应的学年学期信息
  62. var schoolyear = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == executablePlanView.SchoolyearID).SingleOrDefault();
  63. if (schoolyear == null)
  64. {
  65. throw new Exception("学年学期信息不存在,请检查。");
  66. }
  67. if (schoolyear.Value < startSchoolyear.Value)
  68. {
  69. throw new Exception("学年学期小于入学学年学期,请检查。");
  70. }
  71. if (schoolyear.Value > graduatingSemester.Value)
  72. {
  73. throw new Exception("学年学期大于毕业学年学期,请检查。");
  74. }
  75. //查询数据库进行验证
  76. var executablePlanVerify = ExecutablePlanDAL.ExecutablePlanRepository
  77. .GetList(x => x.ExecutablePlanID != executablePlanView.ExecutablePlanID
  78. && x.SchoolyearID == executablePlanView.SchoolyearID
  79. && x.GrademajorID == executablePlanView.GrademajorID
  80. && x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault();
  81. if (executablePlanVerify == null)
  82. {
  83. if (executablePlanView.TeachingModeIDList == null || executablePlanView.TeachingModeIDList.Count() <= 0)
  84. {
  85. throw new Exception("请选择至少一种授课方式,请检查。");
  86. }
  87. //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID)
  88. var specialtyPlan = ExecutablePlanDAL.SpecialtyPlanRepository
  89. .GetList(x => x.SchoolyearID == executablePlanView.SchoolyearID
  90. && x.StartSchoolyearID == startSchoolyear.SchoolyearID
  91. && x.SpecialtyID == specialty.SpecialtyID
  92. && x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault();
  93. List<EM_ExecutablePlan> newExecutablePlanInList = new List<EM_ExecutablePlan>();
  94. List<EM_ExecutablePlan> newExecutablePlanUpList = new List<EM_ExecutablePlan>();
  95. List<EM_ExecutablePlanProfile> newProfileInList = new List<EM_ExecutablePlanProfile>();
  96. List<EM_ExecutablePlanProfile> newProfileUpList = new List<EM_ExecutablePlanProfile>();
  97. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingInList = new List<EM_ExecutablePlanTeachingSetting>();
  98. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingUpList = new List<EM_ExecutablePlanTeachingSetting>();
  99. List<EM_ExecutablePlanTeachingModeType> newEPTeachingModeTypeInList = new List<EM_ExecutablePlanTeachingModeType>();
  100. List<EM_ExecutablePlanTeachingPlace> newEPTeachingPlaceInList = new List<EM_ExecutablePlanTeachingPlace>();
  101. List<Guid?> executablePlanTMDelList = new List<Guid?>();
  102. List<Guid?> executablePlanTPDelList = new List<Guid?>();
  103. List<EM_EducationMission> newEducationMissionInList = new List<EM_EducationMission>();
  104. List<EM_EducationMission> newEducationMissionUpList = new List<EM_EducationMission>();
  105. List<EM_EducationMissionClass> newEducationMissionClassInList = new List<EM_EducationMissionClass>();
  106. List<EM_EducationMissionClass> newEducationMissionClassUpList = new List<EM_EducationMissionClass>();
  107. List<EM_EducationMissionClassTeachingSetting> newEduTeachingSettingInList = new List<EM_EducationMissionClassTeachingSetting>();
  108. List<EM_EducationMissionClassTeachingSetting> newEduTeachingSettingUpList = new List<EM_EducationMissionClassTeachingSetting>();
  109. List<EM_EducationSchedulingClass> newEducationSchedulingClassInList = new List<EM_EducationSchedulingClass>();
  110. List<EM_EducationMissionClassSettings> newEduSettingsInList = new List<EM_EducationMissionClassSettings>();
  111. List<EM_CourseProcess> newCourseProcessInList = new List<EM_CourseProcess>();
  112. //数据有误验证
  113. if (executablePlanView.ExecutablePlanID != Guid.Empty)
  114. {
  115. var executablePlan = ExecutablePlanDAL.ExecutablePlanRepository
  116. .GetList(x => x.ExecutablePlanID == executablePlanView.ExecutablePlanID,
  117. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault();
  118. if (executablePlan == null)
  119. {
  120. throw new Exception("数据有误,请核查。");
  121. }
  122. else
  123. {
  124. //表示修改
  125. executablePlan.SourceTypeID = executablePlanView.SourceTypeID;
  126. executablePlan.DefaultClassName = coursematerial.CourseName + "-" + grademajor.Name;
  127. if (specialtyPlan == null)
  128. {
  129. executablePlan.SpecialtyPlanID = null;
  130. }
  131. else
  132. {
  133. executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  134. }
  135. executablePlan.SchoolyearID = executablePlanView.SchoolyearID;
  136. executablePlan.GrademajorID = executablePlanView.GrademajorID;
  137. executablePlan.CoursematerialID = executablePlanView.CoursematerialID;
  138. executablePlan.CourseStructureID = executablePlanView.CourseStructureID;
  139. executablePlan.CourseCategoryID = executablePlanView.CourseCategoryID;
  140. executablePlan.CourseTypeID = executablePlanView.CourseTypeID;
  141. executablePlan.CourseQualityID = executablePlanView.CourseQualityID;
  142. executablePlan.DepartmentID = executablePlanView.DepartmentID;
  143. if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside)
  144. {
  145. executablePlan.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  146. }
  147. executablePlan.ResultTypeID = executablePlanView.ResultTypeID;
  148. executablePlan.HandleModeID = executablePlanView.HandleModeID;
  149. SetModifyStatus(executablePlan);
  150. newExecutablePlanUpList.Add(executablePlan);
  151. if (executablePlan.EM_ExecutablePlanProfile == null)
  152. {
  153. var newProfile = new EM_ExecutablePlanProfile();
  154. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  155. newProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore;
  156. newProfile.IsCooperation = executablePlanView.IsCooperation;
  157. newProfile.IsRequired = executablePlanView.IsRequired;
  158. newProfile.IsElective = executablePlanView.IsElective;
  159. newProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse;
  160. newProfile.IsMainCourse = executablePlanView.IsMainCourse;
  161. newProfile.CourseFineID = executablePlanView.CourseFineID;
  162. newProfile.PracticeTypeID = executablePlanView.PracticeTypeID;
  163. newProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  164. newProfile.ExaminationModeID = executablePlanView.ExaminationModeID;
  165. SetNewStatus(newProfile);
  166. newProfileInList.Add(newProfile);
  167. }
  168. else
  169. {
  170. if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside)
  171. {
  172. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore;
  173. executablePlan.EM_ExecutablePlanProfile.IsCooperation = executablePlanView.IsCooperation;
  174. executablePlan.EM_ExecutablePlanProfile.IsRequired = executablePlanView.IsRequired;
  175. executablePlan.EM_ExecutablePlanProfile.IsElective = executablePlanView.IsElective;
  176. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse;
  177. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = executablePlanView.IsMainCourse;
  178. executablePlan.EM_ExecutablePlanProfile.CourseFineID = executablePlanView.CourseFineID;
  179. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = executablePlanView.PracticeTypeID;
  180. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  181. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = executablePlanView.ExaminationModeID;
  182. }
  183. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  184. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  185. }
  186. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  187. {
  188. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  189. newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  190. newEPTeachingSetting.Credit = executablePlanView.Credit;
  191. newEPTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  192. newEPTeachingSetting.Practicehours = executablePlanView.Practicehours;
  193. newEPTeachingSetting.Trialhours = executablePlanView.Trialhours;
  194. newEPTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  195. newEPTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  196. newEPTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  197. newEPTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  198. newEPTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  199. newEPTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  200. newEPTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  201. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  202. }
  203. else
  204. {
  205. if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside)
  206. {
  207. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = executablePlanView.Credit;
  208. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  209. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = executablePlanView.Practicehours;
  210. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = executablePlanView.Trialhours;
  211. }
  212. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  213. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  214. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  215. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  216. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  217. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  218. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  219. newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  220. }
  221. if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0)
  222. {
  223. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  224. foreach (var newModeType in executablePlanView.TeachingModeIDList.ToList())
  225. {
  226. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  227. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  228. newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  229. newEPTeachingModeType.TeachingModeID = newModeType;
  230. this.SetNewStatus(newEPTeachingModeType);
  231. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  232. }
  233. }
  234. else
  235. {
  236. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  237. }
  238. if (executablePlanView.TeachingPlaceIDList != null && executablePlanView.TeachingPlaceIDList.Count() > 0)
  239. {
  240. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  241. foreach (var newPlace in executablePlanView.TeachingPlaceIDList.ToList())
  242. {
  243. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  244. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  245. newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  246. newEPTeachingPlace.TeachingPlace = newPlace;
  247. this.SetNewStatus(newEPTeachingPlace);
  248. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  249. }
  250. }
  251. else
  252. {
  253. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  254. }
  255. //对应的教学任务信息更新(根据业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID)
  256. //注:由于相关业务主键冗余,目前不允许修改相关业务主键
  257. //教学任务班生成规则如下:
  258. //1、对应的授课方式为必选项且可多选;
  259. //2、课程信息对应的上课类型为空时,默认只生成一种类型的教学任务班(授课方式为最小Value授课方式);
  260. //3、以上课类型为标准,匹配对应的授课方式来生成教学任务班;
  261. //4、根据授课方式与上课类型查询是否分班情况,存在分班情况,则生成对应的教学任务班;
  262. //5、对应的授课方式存在分班情况时,默认生成成绩合并录入形式的教学任务班(同一条教学任务);
  263. //6、年级专业对应的计划范围不于等于0时,不生成对应的教学任务班(无法生成);
  264. //7、年级专业对应的学生人数小于等于0时,不生成对应的教学任务班(成教版本有此逻辑);
  265. //8、如对应的年级专业有多个班级,都生成对应的教学任务班(只取在校状态为在校的学生信息);
  266. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.Submited)
  267. {
  268. //年级专业
  269. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  270. expGrademajor = expGrademajor.And(x => x.GrademajorID == executablePlanView.GrademajorID);
  271. //查询对应的班级范围信息classmajorList
  272. var classmajorList = ExecutablePlanDAL.GetClassmajorRangeQueryable(expGrademajor).ToList();
  273. //执行计划对应的计划范围判断
  274. if (classmajorList != null && classmajorList.Count() > 0)
  275. {
  276. //查询对应的学生范围信息studentList
  277. var studentList = ExecutablePlanDAL.GetStudentRangeQueryable(expGrademajor).ToList();
  278. //执行计划对应的学生范围判断
  279. if (studentList != null && studentList.Count() > 0)
  280. {
  281. //查询对应在校状态IDList
  282. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  283. //查询对应的课程信息中授课方式分班信息List
  284. var separateModeTypeList = ExecutablePlanDAL.GetSeparateModeTypeQueryble(x => x.CoursematerialID == executablePlanView.CoursematerialID).ToList();
  285. //查询授课方式teachingModeList
  286. var teachingModeList = DictionaryHelper.GetDictionaryValue(EMIS.ViewModel.DictionaryItem.CF_TeachingMode).ToList();
  287. //查询执行计划中授课方式及对应的上课类型中的授课方式(匹配上课类型)
  288. var minTeachingModeID = executablePlanView.TeachingModeIDList
  289. .Where(x => !separateModeTypeList.Contains(x)).OrderBy(x => x).FirstOrDefault();
  290. List<int?> teachingModeIDList = new List<int?>();
  291. if (minTeachingModeID != null)
  292. {
  293. teachingModeIDList.Add(minTeachingModeID);
  294. teachingModeIDList = teachingModeIDList.Concat(executablePlanView.TeachingModeIDList
  295. .Where(x => separateModeTypeList.Contains(x))).GroupBy(x => x).Select(x => x.Key).ToList();
  296. }
  297. else
  298. {
  299. teachingModeIDList = executablePlanView.TeachingModeIDList
  300. .Where(x => separateModeTypeList.Contains(x)).GroupBy(x => x).Select(x => x.Key).ToList();
  301. }
  302. //查询对应的授课方式信息List(匹配上课类型)
  303. var epTeachingModeList = teachingModeList.Where(x => teachingModeIDList.Contains(x.Value)).ToList();
  304. //执行计划
  305. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  306. expExecutablePlan = expExecutablePlan.And(x => x.ExecutablePlanID == executablePlanView.ExecutablePlanID);
  307. //查询对应的教学任务班信息(业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID)
  308. var educationMissionClassList = ExecutablePlanDAL.GetEducationMissionClassQueryable(expExecutablePlan).ToList();
  309. foreach (var classmajor in classmajorList)
  310. {
  311. //查询班级信息对应的教学任务班信息List
  312. var educlList = educationMissionClassList.Where(x => x.CF_Classmajor
  313. .Any(w => w.ClassmajorID == classmajor.ClassmajorID)).ToList();
  314. if (educlList != null && educlList.Count() > 0)
  315. {
  316. //表示存在对应的教学任务班
  317. //根据教学任务ID对educlList进行分组
  318. var edugrList = educlList.GroupBy(x => x.EducationMissionID).ToList();
  319. //根据授课方式对educlList进行分组
  320. var tmgrList = educlList.GroupBy(x => x.TeachingModeID).ToList();
  321. if (edugrList.Count() > 1 && tmgrList.Count() > 1)
  322. {
  323. //表示对应的教学任务班存在分班且成绩分开录入、授课方式多种情况
  324. //目前此种数据有误,在生成期末设定时有问题(这里暂不处理)
  325. throw new Exception("对应的教学任务班中存在分班且成绩分开录入、授课方式多种的信息(请删除后,再保存),请核查。");
  326. }
  327. else if (edugrList.Count() > 1 && epTeachingModeList.Count() > 1)
  328. {
  329. //表示对应的教学任务班存在分班且成绩分开录入、授课方式只有一种情况,不可再生成多种授课方式的教学任务班信息
  330. //目前此种数据有误,在生成期末设定时有问题
  331. throw new Exception("对应的教学任务班中存在分班且成绩分开录入的信息,不可再生成多种授课方式的教学任务班信息(请删除后,再保存),请核查。");
  332. }
  333. else if (tmgrList.Count() == 1 && epTeachingModeList.Count() == 1)
  334. {
  335. //表示对应的教学任务班只存在一种授课方式信息(含分班且成绩合并或分开录入)
  336. //同时生成的教学任务班信息授课方式只有一种的情况(直接修改)
  337. foreach (var educl in educlList)
  338. {
  339. if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID))
  340. {
  341. educl.EM_EducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name;
  342. educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  343. educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID;
  344. educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID;
  345. SetModifyStatus(educl.EM_EducationMission);
  346. newEducationMissionUpList.Add(educl.EM_EducationMission);
  347. }
  348. if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  349. {
  350. educl.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  351. educl.CoursematerialID = executablePlanView.CoursematerialID;
  352. educl.CourseStructureID = executablePlanView.CourseStructureID;
  353. educl.CourseCategoryID = executablePlanView.CourseCategoryID;
  354. educl.CourseTypeID = executablePlanView.CourseTypeID;
  355. educl.CourseQualityID = executablePlanView.CourseQualityID;
  356. educl.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  357. educl.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  358. educl.ExaminationModeID = executablePlanView.ExaminationModeID;
  359. educl.ResultTypeID = executablePlanView.ResultTypeID;
  360. educl.HandleModeID = executablePlanView.HandleModeID;
  361. educl.TeachingModeID = epTeachingModeList[0].Value;
  362. SetModifyStatus(educl);
  363. newEducationMissionClassUpList.Add(educl);
  364. }
  365. if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  366. {
  367. educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit;
  368. educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  369. educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours;
  370. educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours;
  371. //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled)
  372. //{
  373. // //暂不考虑
  374. // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  375. // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  376. // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  377. // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  378. // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  379. // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  380. // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  381. //}
  382. newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting);
  383. }
  384. }
  385. }
  386. else
  387. {
  388. //表示无论分班与否,成绩都是合并录入的情况(同一个教学任务ID)
  389. //表示可根据执行计划中匹配上课类型后的授课方式进行增加、修改对应的教学任务班信息
  390. foreach (var educl in educlList)
  391. {
  392. //修改
  393. if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID))
  394. {
  395. educl.EM_EducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name;
  396. educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  397. educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID;
  398. educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID;
  399. SetModifyStatus(educl.EM_EducationMission);
  400. newEducationMissionUpList.Add(educl.EM_EducationMission);
  401. }
  402. if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  403. {
  404. educl.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  405. educl.CoursematerialID = executablePlanView.CoursematerialID;
  406. educl.CourseStructureID = executablePlanView.CourseStructureID;
  407. educl.CourseCategoryID = executablePlanView.CourseCategoryID;
  408. educl.CourseTypeID = executablePlanView.CourseTypeID;
  409. educl.CourseQualityID = executablePlanView.CourseQualityID;
  410. educl.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  411. educl.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  412. educl.ExaminationModeID = executablePlanView.ExaminationModeID;
  413. educl.ResultTypeID = executablePlanView.ResultTypeID;
  414. educl.HandleModeID = executablePlanView.HandleModeID;
  415. SetModifyStatus(educl);
  416. newEducationMissionClassUpList.Add(educl);
  417. }
  418. if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  419. {
  420. educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit;
  421. educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  422. educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours;
  423. educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours;
  424. //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled)
  425. //{
  426. // //暂不考虑
  427. // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  428. // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  429. // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  430. // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  431. // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  432. // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  433. // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  434. //}
  435. newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting);
  436. }
  437. }
  438. //将执行计划中匹配上课类型后的授课方式与对应的教学任务班的授课方式进行对比
  439. var educltmList = tmgrList.Select(x => x.Key).ToList();
  440. var newTeachingModeList = epTeachingModeList.Where(x => !educltmList.Contains(x.Value)).ToList();
  441. foreach (var newTeachingMode in newTeachingModeList)
  442. {
  443. //新增
  444. var newEducationMissionClass = new EM_EducationMissionClass();
  445. newEducationMissionClass.EducationMissionClassID = Guid.NewGuid();
  446. newEducationMissionClass.EducationMissionID = edugrList[0].Key;
  447. newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID;
  448. newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  449. newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1;
  450. newEducationMissionClass.Name = coursematerial.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")";
  451. newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID;
  452. newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID;
  453. newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID;
  454. newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID;
  455. newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID;
  456. newEducationMissionClass.ClassroomTypeID = null;
  457. newEducationMissionClass.ClassroomID = null;
  458. newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  459. newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  460. newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID;
  461. newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID;
  462. newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID;
  463. newEducationMissionClass.TeachingModeID = newTeachingMode.Value;
  464. newEducationMissionClass.Remark = coursematerial.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")";
  465. SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted);
  466. newEducationMissionClassInList.Add(newEducationMissionClass);
  467. var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting();
  468. newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  469. newEduTeachingSetting.Credit = executablePlanView.Credit;
  470. newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  471. newEduTeachingSetting.Practicehours = executablePlanView.Practicehours;
  472. newEduTeachingSetting.Trialhours = executablePlanView.Trialhours;
  473. newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  474. newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  475. newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  476. newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  477. newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  478. newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  479. newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  480. newEduTeachingSettingInList.Add(newEduTeachingSetting);
  481. newEducationMissionClass.CF_Classmajor = new HashSet<CF_Classmajor>();
  482. newEducationMissionClass.CF_Classmajor.Add(classmajor);
  483. var newEducationSchedulingClass = new EM_EducationSchedulingClass();
  484. newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
  485. newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  486. newEducationSchedulingClass.TaskGroupName = "1组";
  487. newEducationSchedulingClass.Remark = classmajor.Name;
  488. SetNewStatus(newEducationSchedulingClass);
  489. newEducationSchedulingClassInList.Add(newEducationSchedulingClass);
  490. newEducationSchedulingClass.CF_Student = new HashSet<CF_Student>();
  491. var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID
  492. && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList();
  493. newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x));
  494. for (int i = 0; i < executablePlanView.EndWeeklyNum; i++)
  495. {
  496. var newEduSettings = new EM_EducationMissionClassSettings();
  497. newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid();
  498. newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  499. newEduSettings.WeeklyNum = i + 1;
  500. SetNewStatus(newEduSettings);
  501. newEduSettingsInList.Add(newEduSettings);
  502. var newCourseProcess = new EM_CourseProcess();
  503. newCourseProcess.CourseProcessID = Guid.NewGuid();
  504. newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  505. newCourseProcess.Week = i + 1;
  506. newCourseProcess.Times = executablePlanView.WeeklyHours;
  507. newCourseProcessInList.Add(newCourseProcess);
  508. }
  509. }
  510. }
  511. }
  512. else
  513. {
  514. //表示不存在对应的教学任务班(新增)
  515. var newEducationMission = new EM_EducationMission();
  516. newEducationMission.EducationMissionID = Guid.NewGuid();
  517. newEducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name;
  518. newEducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  519. newEducationMission.CollegeID = executablePlanView.CollegeID;
  520. newEducationMission.DepartmentID = executablePlanView.DepartmentID;
  521. SetNewStatus(newEducationMission);
  522. newEducationMissionInList.Add(newEducationMission);
  523. foreach (var epTeachingMode in epTeachingModeList)
  524. {
  525. var newEducationMissionClass = new EM_EducationMissionClass();
  526. newEducationMissionClass.EducationMissionClassID = Guid.NewGuid();
  527. newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID;
  528. newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID;
  529. newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  530. newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1;
  531. newEducationMissionClass.Name = coursematerial.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")";
  532. newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID;
  533. newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID;
  534. newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID;
  535. newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID;
  536. newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID;
  537. newEducationMissionClass.ClassroomTypeID = null;
  538. newEducationMissionClass.ClassroomID = null;
  539. newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  540. newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  541. newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID;
  542. newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID;
  543. newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID;
  544. newEducationMissionClass.TeachingModeID = epTeachingMode.Value;
  545. newEducationMissionClass.Remark = coursematerial.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")";
  546. SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted);
  547. newEducationMissionClassInList.Add(newEducationMissionClass);
  548. var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting();
  549. newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  550. newEduTeachingSetting.Credit = executablePlanView.Credit;
  551. newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  552. newEduTeachingSetting.Practicehours = executablePlanView.Practicehours;
  553. newEduTeachingSetting.Trialhours = executablePlanView.Trialhours;
  554. newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  555. newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  556. newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  557. newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  558. newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  559. newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  560. newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  561. newEduTeachingSettingInList.Add(newEduTeachingSetting);
  562. newEducationMissionClass.CF_Classmajor = new HashSet<CF_Classmajor>();
  563. newEducationMissionClass.CF_Classmajor.Add(classmajor);
  564. var newEducationSchedulingClass = new EM_EducationSchedulingClass();
  565. newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
  566. newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  567. newEducationSchedulingClass.TaskGroupName = "1组";
  568. newEducationSchedulingClass.Remark = classmajor.Name;
  569. SetNewStatus(newEducationSchedulingClass);
  570. newEducationSchedulingClassInList.Add(newEducationSchedulingClass);
  571. newEducationSchedulingClass.CF_Student = new HashSet<CF_Student>();
  572. var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID
  573. && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList();
  574. newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x));
  575. for (int i = 0; i < executablePlanView.EndWeeklyNum; i++)
  576. {
  577. var newEduSettings = new EM_EducationMissionClassSettings();
  578. newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid();
  579. newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  580. newEduSettings.WeeklyNum = i + 1;
  581. SetNewStatus(newEduSettings);
  582. newEduSettingsInList.Add(newEduSettings);
  583. var newCourseProcess = new EM_CourseProcess();
  584. newCourseProcess.CourseProcessID = Guid.NewGuid();
  585. newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  586. newCourseProcess.Week = i + 1;
  587. newCourseProcess.Times = executablePlanView.WeeklyHours;
  588. newCourseProcessInList.Add(newCourseProcess);
  589. }
  590. }
  591. }
  592. }
  593. }
  594. else
  595. {
  596. //表示执行计划对应的学生范围不存在(小于等于0)
  597. //throw new Exception("执行计划对应的学生范围不存在(小于等于0),请核查。");
  598. }
  599. }
  600. else
  601. {
  602. //表示执行计划对应的计划范围不存在(小于等于0)
  603. //throw new Exception("执行计划对应的计划范围不存在(小于等于0),请核查。");
  604. }
  605. }
  606. else
  607. {
  608. //表示未提交
  609. //暂不考虑对相关教学任务信息的处理
  610. }
  611. }
  612. }
  613. else
  614. {
  615. //表示新增
  616. var newExecutablePlan = new EM_ExecutablePlan();
  617. newExecutablePlan.ExecutablePlanID = Guid.NewGuid();
  618. newExecutablePlan.SourceTypeID = executablePlanView.SourceTypeID;
  619. newExecutablePlan.DefaultClassName = coursematerial.CourseName + "-" + grademajor.Name;
  620. if (specialtyPlan == null)
  621. {
  622. newExecutablePlan.SpecialtyPlanID = null;
  623. }
  624. else
  625. {
  626. newExecutablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  627. }
  628. newExecutablePlan.SchoolyearID = executablePlanView.SchoolyearID;
  629. newExecutablePlan.GrademajorID = executablePlanView.GrademajorID;
  630. newExecutablePlan.CoursematerialID = executablePlanView.CoursematerialID;
  631. newExecutablePlan.CourseStructureID = executablePlanView.CourseStructureID;
  632. newExecutablePlan.CourseCategoryID = executablePlanView.CourseCategoryID;
  633. newExecutablePlan.CourseTypeID = executablePlanView.CourseTypeID;
  634. newExecutablePlan.CourseQualityID = executablePlanView.CourseQualityID;
  635. newExecutablePlan.DepartmentID = executablePlanView.DepartmentID;
  636. newExecutablePlan.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  637. newExecutablePlan.ResultTypeID = executablePlanView.ResultTypeID;
  638. newExecutablePlan.HandleModeID = executablePlanView.HandleModeID;
  639. newExecutablePlan.Remark = executablePlanView.Remark;
  640. SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited);
  641. newExecutablePlanInList.Add(newExecutablePlan);
  642. var newProfile = new EM_ExecutablePlanProfile();
  643. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  644. newProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore;
  645. newProfile.IsCooperation = executablePlanView.IsCooperation;
  646. newProfile.IsRequired = executablePlanView.IsRequired;
  647. newProfile.IsElective = executablePlanView.IsElective;
  648. newProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse;
  649. newProfile.IsMainCourse = executablePlanView.IsMainCourse;
  650. newProfile.CourseFineID = executablePlanView.CourseFineID;
  651. newProfile.PracticeTypeID = executablePlanView.PracticeTypeID;
  652. newProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  653. newProfile.ExaminationModeID = executablePlanView.ExaminationModeID;
  654. SetNewStatus(newProfile);
  655. newProfileInList.Add(newProfile);
  656. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  657. newEPTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  658. newEPTeachingSetting.Credit = executablePlanView.Credit;
  659. newEPTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  660. newEPTeachingSetting.Practicehours = executablePlanView.Practicehours;
  661. newEPTeachingSetting.Trialhours = executablePlanView.Trialhours;
  662. newEPTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  663. newEPTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  664. newEPTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  665. newEPTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  666. newEPTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  667. newEPTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  668. newEPTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  669. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  670. if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0)
  671. {
  672. foreach (var newModeType in executablePlanView.TeachingModeIDList.ToList())
  673. {
  674. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  675. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  676. newEPTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  677. newEPTeachingModeType.TeachingModeID = newModeType;
  678. this.SetNewStatus(newEPTeachingModeType);
  679. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  680. }
  681. }
  682. if (executablePlanView.TeachingPlaceIDList != null && executablePlanView.TeachingPlaceIDList.Count() > 0)
  683. {
  684. foreach (var newPlace in executablePlanView.TeachingPlaceIDList.ToList())
  685. {
  686. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  687. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  688. newEPTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  689. newEPTeachingPlace.TeachingPlace = newPlace;
  690. this.SetNewStatus(newEPTeachingPlace);
  691. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  692. }
  693. }
  694. //对应的教学任务信息更新(根据业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID)
  695. //注:由于相关业务主键冗余,目前不允许修改相关业务主键
  696. //暂不考虑对相关教学任务信息的处理
  697. }
  698. //事务提交
  699. //UnitOfWork.Commit();
  700. using (TransactionScope ts = new TransactionScope())
  701. {
  702. //删除
  703. UnitOfWork.Delete<EM_ExecutablePlanTeachingPlace>(x => executablePlanTPDelList.Contains(x.ExecutablePlanID));
  704. UnitOfWork.Delete<EM_ExecutablePlanTeachingModeType>(x => executablePlanTMDelList.Contains(x.ExecutablePlanID));
  705. //批量插入
  706. UnitOfWork.BulkInsert(newExecutablePlanInList);
  707. UnitOfWork.BulkInsert(newProfileInList);
  708. UnitOfWork.BulkInsert(newEPTeachingSettingInList);
  709. UnitOfWork.BulkInsert(newEPTeachingModeTypeInList);
  710. UnitOfWork.BulkInsert(newEPTeachingPlaceInList);
  711. //批量统一提交更新
  712. if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0)
  713. {
  714. UnitOfWork.BatchUpdate(newExecutablePlanUpList);
  715. }
  716. //批量统一提交更新
  717. if (newProfileUpList != null && newProfileUpList.Count() > 0)
  718. {
  719. UnitOfWork.BatchUpdate(newProfileUpList);
  720. }
  721. //批量统一提交更新
  722. if (newEPTeachingSettingUpList != null && newEPTeachingSettingUpList.Count() > 0)
  723. {
  724. UnitOfWork.BatchUpdate(newEPTeachingSettingUpList);
  725. }
  726. //批量插入
  727. UnitOfWork.BulkInsert(newEducationMissionInList);
  728. UnitOfWork.BulkInsert(newEducationMissionClassInList);
  729. UnitOfWork.BulkInsert(newEduTeachingSettingInList);
  730. UnitOfWork.BulkInsert(newEducationMissionClassInList, (x => x.CF_Classmajor));
  731. UnitOfWork.BulkInsert(newEducationSchedulingClassInList);
  732. UnitOfWork.BulkInsert(newEducationSchedulingClassInList, (x => x.CF_Student));
  733. UnitOfWork.BulkInsert(newEduSettingsInList);
  734. UnitOfWork.BulkInsert(newCourseProcessInList);
  735. //批量统一提交更新
  736. if (newEducationMissionUpList != null && newEducationMissionUpList.Count() > 0)
  737. {
  738. UnitOfWork.BatchUpdate(newEducationMissionUpList);
  739. }
  740. //批量统一提交更新
  741. if (newEducationMissionClassUpList != null && newEducationMissionClassUpList.Count() > 0)
  742. {
  743. UnitOfWork.BatchUpdate(newEducationMissionClassUpList);
  744. }
  745. //批量统一提交更新
  746. if (newEduTeachingSettingUpList != null && newEduTeachingSettingUpList.Count() > 0)
  747. {
  748. UnitOfWork.BatchUpdate(newEduTeachingSettingUpList);
  749. }
  750. ts.Complete();
  751. }
  752. }
  753. else
  754. {
  755. throw new Exception("已存在相同的执行计划信息(学年学期、年级专业、课程信息唯一),请核查。");
  756. }
  757. }
  758. catch (Exception ex)
  759. {
  760. throw new Exception(ex.Message);
  761. }
  762. }
  763. /// <summary>
  764. /// 根据专业计划信息批量新增
  765. /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息)
  766. /// 注:此为成教版本(入学学年学期、专业信息)
  767. /// 注:此版本学生人数小于等于0时,不可生成对应的执行计划
  768. /// </summary>
  769. /// <param name="specialtyPlanViewList"></param>
  770. /// <param name="executablePlanView"></param>
  771. /// <returns></returns>
  772. public override string ExecutablePlanBatchAdd(List<SpecialtyPlanView> specialtyPlanViewList, ExecutablePlanView executablePlanView)
  773. {
  774. try
  775. {
  776. //查询专业计划对应的年级专业grademajorIDList
  777. var grademajorIDList = specialtyPlanViewList.Select(x => x.GrademajorID).Distinct().ToList();
  778. //查询对应的执行计划信息executablePlanList(暂时只匹配年级专业ID)
  779. var executablePlanList = ExecutablePlanDAL.ExecutablePlanRepository
  780. .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_ExecutablePlanTeachingSetting)).ToList();
  781. int success = 0; //成功
  782. int fail = 0; //失败
  783. string tipMessage = null; //提示消息
  784. List<EM_ExecutablePlan> newExecutablePlanInList = new List<EM_ExecutablePlan>();
  785. List<EM_ExecutablePlanProfile> newProfileInList = new List<EM_ExecutablePlanProfile>();
  786. List<EM_ExecutablePlanTeachingSetting> newTeachingSettingInList = new List<EM_ExecutablePlanTeachingSetting>();
  787. List<EM_ExecutablePlanTeachingModeType> newTeachingModeTypeInList = new List<EM_ExecutablePlanTeachingModeType>();
  788. List<EM_ExecutablePlanTeachingPlace> newTeachingPlaceInList = new List<EM_ExecutablePlanTeachingPlace>();
  789. foreach (var specialtyPlanView in specialtyPlanViewList)
  790. {
  791. //判断对应的学年学期信息
  792. if (specialtyPlanView.Value < specialtyPlanView.StartValue)
  793. {
  794. //表示学年学期小于入学学年学期
  795. fail++;
  796. }
  797. else
  798. {
  799. if (specialtyPlanView.Value > specialtyPlanView.GraduatingSemesterValue)
  800. {
  801. //表示学年学期大于毕业学年学期
  802. fail++;
  803. }
  804. else
  805. {
  806. //判断对应的学生人数
  807. if (specialtyPlanView.StudentCount <= 0)
  808. {
  809. //表示学生人数小于等于0
  810. fail++;
  811. }
  812. else
  813. {
  814. //查询对应的执行计划信息(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  815. var executablePlan = executablePlanList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  816. && x.GrademajorID == specialtyPlanView.GrademajorID
  817. && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault();
  818. if (executablePlan == null)
  819. {
  820. //表示新增
  821. var newExecutablePlan = new EM_ExecutablePlan();
  822. newExecutablePlan.ExecutablePlanID = Guid.NewGuid();
  823. //来源专业计划默认为必修课
  824. newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  825. newExecutablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + specialtyPlanView.GrademajorName;
  826. newExecutablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID;
  827. newExecutablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  828. newExecutablePlan.GrademajorID = specialtyPlanView.GrademajorID;
  829. newExecutablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  830. newExecutablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  831. newExecutablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  832. newExecutablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  833. newExecutablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  834. newExecutablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  835. newExecutablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  836. newExecutablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  837. newExecutablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  838. newExecutablePlan.Remark = specialtyPlanView.Remark;
  839. SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited);
  840. newExecutablePlanInList.Add(newExecutablePlan);
  841. var newProfile = new EM_ExecutablePlanProfile();
  842. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  843. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  844. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  845. newProfile.IsRequired = specialtyPlanView.IsRequired;
  846. newProfile.IsElective = specialtyPlanView.IsElective;
  847. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  848. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  849. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  850. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  851. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  852. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  853. SetNewStatus(newProfile);
  854. newProfileInList.Add(newProfile);
  855. var newTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  856. newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  857. newTeachingSetting.Credit = specialtyPlanView.Credit;
  858. newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  859. newTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  860. newTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  861. newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  862. newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  863. newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  864. newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  865. newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  866. newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  867. newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  868. newTeachingSettingInList.Add(newTeachingSetting);
  869. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  870. {
  871. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  872. {
  873. var newTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  874. newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  875. newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  876. newTeachingModeType.TeachingModeID = newModeType;
  877. this.SetNewStatus(newTeachingModeType);
  878. newTeachingModeTypeInList.Add(newTeachingModeType);
  879. }
  880. }
  881. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  882. {
  883. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  884. {
  885. var newTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  886. newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  887. newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  888. newTeachingPlace.TeachingPlace = newPlace;
  889. this.SetNewStatus(newTeachingPlace);
  890. newTeachingPlaceInList.Add(newTeachingPlace);
  891. }
  892. }
  893. success++;
  894. }
  895. else
  896. {
  897. //表示已存在相同的执行计划信息
  898. fail++;
  899. }
  900. }
  901. }
  902. }
  903. }
  904. //事务提交
  905. using (TransactionScope ts = new TransactionScope())
  906. {
  907. //批量插入
  908. UnitOfWork.BulkInsert(newExecutablePlanInList);
  909. UnitOfWork.BulkInsert(newProfileInList);
  910. UnitOfWork.BulkInsert(newTeachingSettingInList);
  911. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  912. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  913. ts.Complete();
  914. }
  915. if (success > 0 && fail <= 0)
  916. {
  917. tipMessage = success + "条";
  918. }
  919. else
  920. {
  921. tipMessage = success + "条,失败" + fail + "条,原因:学生人数等于0、学年学期小于入学学年学期、学年学期大于毕业学年学期或已存在相同的执行计划信息,请检查";
  922. }
  923. return tipMessage;
  924. }
  925. catch (Exception ex)
  926. {
  927. throw new Exception(ex.Message);
  928. }
  929. }
  930. /// <summary>
  931. /// 查询对应的未新增专业计划信息SpecialtyPlanView
  932. /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息)
  933. /// 注:此为成教版本(入学学年学期、专业信息)
  934. /// </summary>
  935. /// <param name="configuretView"></param>
  936. /// <param name="schoolyearID"></param>
  937. /// <param name="campusID"></param>
  938. /// <param name="collegeID"></param>
  939. /// <param name="yearID"></param>
  940. /// <param name="standardID"></param>
  941. /// <param name="educationID"></param>
  942. /// <param name="learningformID"></param>
  943. /// <param name="learnSystem"></param>
  944. /// <param name="grademajorID"></param>
  945. /// <param name="coursematerialID"></param>
  946. /// <param name="teachingModeID"></param>
  947. /// <param name="handleModeID"></param>
  948. /// <param name="pageIndex"></param>
  949. /// <param name="pageSize"></param>
  950. /// <returns></returns>
  951. public override IGridResultSet<SpecialtyPlanView> GetSpecialtyPlanViewNoAddGrid(ConfiguretView configuretView, Guid? schoolyearID,
  952. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  953. Guid? grademajorID, Guid? coursematerialID, int? teachingModeID, int? handleModeID, int pageIndex, int pageSize)
  954. {
  955. //年级专业
  956. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  957. if (yearID.HasValue)
  958. {
  959. expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
  960. }
  961. if (grademajorID.HasValue)
  962. {
  963. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  964. }
  965. //专业计划
  966. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  967. if (schoolyearID.HasValue)
  968. {
  969. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID);
  970. }
  971. if (coursematerialID.HasValue)
  972. {
  973. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  974. }
  975. if (handleModeID.HasValue)
  976. {
  977. expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID);
  978. }
  979. //学生信息
  980. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  981. //执行计划
  982. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  983. if (schoolyearID.HasValue)
  984. {
  985. expExecutablePlan = expExecutablePlan.And(x => x.SchoolyearID == schoolyearID);
  986. }
  987. if (grademajorID.HasValue)
  988. {
  989. expExecutablePlan = expExecutablePlan.And(x => x.GrademajorID == grademajorID);
  990. }
  991. if (coursematerialID.HasValue)
  992. {
  993. expExecutablePlan = expExecutablePlan.And(x => x.CoursematerialID == coursematerialID);
  994. }
  995. var query = ExecutablePlanDAL.GetAdultSpecialtyPlanViewNoAddQueryable(expGrademajor, expSpecialtyPlan, expStudent, expExecutablePlan);
  996. if (campusID.HasValue)
  997. {
  998. query = query.Where(x => x.CampusID == campusID);
  999. }
  1000. if (collegeID.HasValue)
  1001. {
  1002. query = query.Where(x => x.CollegeID == collegeID);
  1003. }
  1004. if (standardID.HasValue)
  1005. {
  1006. query = query.Where(x => x.StandardID == standardID);
  1007. }
  1008. if (educationID.HasValue)
  1009. {
  1010. query = query.Where(x => x.EducationID == educationID);
  1011. }
  1012. if (learningformID.HasValue)
  1013. {
  1014. query = query.Where(x => x.LearningformID == learningformID);
  1015. }
  1016. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1017. {
  1018. var LearnSystems = Convert.ToDecimal(learnSystem);
  1019. query = query.Where(x => x.LearnSystem == LearnSystems);
  1020. }
  1021. if (teachingModeID.HasValue)
  1022. {
  1023. //授课方式
  1024. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  1025. }
  1026. //查询条件
  1027. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1028. {
  1029. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1030. }
  1031. return this.GetQueryByDataRangeByCollege(query)
  1032. .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
  1033. .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
  1034. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  1035. .ToGridResultSet<SpecialtyPlanView>(pageIndex, pageSize);
  1036. }
  1037. /// <summary>
  1038. /// 查询对应的未新增专业计划信息List
  1039. /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息)
  1040. /// 注:此为成教版本(入学学年学期、专业信息)
  1041. /// </summary>
  1042. /// <param name="configuretView"></param>
  1043. /// <param name="schoolyearID"></param>
  1044. /// <param name="campusID"></param>
  1045. /// <param name="collegeID"></param>
  1046. /// <param name="yearID"></param>
  1047. /// <param name="standardID"></param>
  1048. /// <param name="educationID"></param>
  1049. /// <param name="learningformID"></param>
  1050. /// <param name="learnSystem"></param>
  1051. /// <param name="grademajorID"></param>
  1052. /// <param name="coursematerialID"></param>
  1053. /// <param name="teachingModeID"></param>
  1054. /// <param name="handleModeID"></param>
  1055. /// <returns></returns>
  1056. public override IList<SpecialtyPlanView> GetSpecialtyPlanViewNoAddList(ConfiguretView configuretView, Guid? schoolyearID,
  1057. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  1058. Guid? grademajorID, Guid? coursematerialID, int? teachingModeID, int? handleModeID)
  1059. {
  1060. //年级专业
  1061. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1062. if (yearID.HasValue)
  1063. {
  1064. expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
  1065. }
  1066. if (grademajorID.HasValue)
  1067. {
  1068. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  1069. }
  1070. //专业计划
  1071. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1072. if (schoolyearID.HasValue)
  1073. {
  1074. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID);
  1075. }
  1076. if (coursematerialID.HasValue)
  1077. {
  1078. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  1079. }
  1080. if (handleModeID.HasValue)
  1081. {
  1082. expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID);
  1083. }
  1084. //学生信息
  1085. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1086. //执行计划
  1087. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1088. if (schoolyearID.HasValue)
  1089. {
  1090. expExecutablePlan = expExecutablePlan.And(x => x.SchoolyearID == schoolyearID);
  1091. }
  1092. if (grademajorID.HasValue)
  1093. {
  1094. expExecutablePlan = expExecutablePlan.And(x => x.GrademajorID == grademajorID);
  1095. }
  1096. if (coursematerialID.HasValue)
  1097. {
  1098. expExecutablePlan = expExecutablePlan.And(x => x.CoursematerialID == coursematerialID);
  1099. }
  1100. var query = ExecutablePlanDAL.GetAdultSpecialtyPlanViewNoAddQueryable(expGrademajor, expSpecialtyPlan, expStudent, expExecutablePlan);
  1101. if (campusID.HasValue)
  1102. {
  1103. query = query.Where(x => x.CampusID == campusID);
  1104. }
  1105. if (collegeID.HasValue)
  1106. {
  1107. query = query.Where(x => x.CollegeID == collegeID);
  1108. }
  1109. if (standardID.HasValue)
  1110. {
  1111. query = query.Where(x => x.StandardID == standardID);
  1112. }
  1113. if (educationID.HasValue)
  1114. {
  1115. query = query.Where(x => x.EducationID == educationID);
  1116. }
  1117. if (learningformID.HasValue)
  1118. {
  1119. query = query.Where(x => x.LearningformID == learningformID);
  1120. }
  1121. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1122. {
  1123. var LearnSystems = Convert.ToDecimal(learnSystem);
  1124. query = query.Where(x => x.LearnSystem == LearnSystems);
  1125. }
  1126. if (teachingModeID.HasValue)
  1127. {
  1128. //授课方式
  1129. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  1130. }
  1131. //查询条件
  1132. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1133. {
  1134. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1135. }
  1136. return this.GetQueryByDataRangeByCollege(query)
  1137. .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
  1138. .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
  1139. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList();
  1140. }
  1141. /// <summary>
  1142. /// 执行计划提交
  1143. /// 注:刷新相关的教学任务信息
  1144. /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息)
  1145. /// 注:此为成教版本(入学学年学期、专业信息)
  1146. /// 注:此版本学生人数小于等于0时,不可提交,但由于有异动的情况,需进一步优化逻辑(对教学任务班学生名单进行判断)
  1147. /// </summary>
  1148. /// <param name="executablePlanIDList"></param>
  1149. /// <returns></returns>
  1150. public override string ExecutablePlanSubmit(List<Guid?> executablePlanIDList)
  1151. {
  1152. try
  1153. {
  1154. //教学任务班生成规则如下:
  1155. //1、对应的授课方式为必选项且可多选;
  1156. //2、课程信息对应的上课类型为空时,默认只生成一种类型的教学任务班(授课方式为最小Value授课方式);
  1157. //3、以上课类型为标准,匹配对应的授课方式来生成教学任务班;
  1158. //4、根据授课方式与上课类型查询是否分班情况,存在分班情况,则生成对应的教学任务班;
  1159. //5、对应的授课方式存在分班情况时,默认生成成绩合并录入形式的教学任务班(同一条教学任务);
  1160. //6、年级专业对应的计划范围不于等于0时,不生成对应的教学任务班(无法生成);
  1161. //7、年级专业对应的学生人数小于等于0时,不生成对应的教学任务班(成教版本有此逻辑);
  1162. //8、如对应的年级专业有多个班级,都生成对应的教学任务班(只取在校状态为在校的学生信息);
  1163. //查询对应的执行计划信息executablePlanViewList
  1164. var executablePlanViewList = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => executablePlanIDList.Contains(x.ExecutablePlanID)).ToList();
  1165. //查询对应的年级专业IDList
  1166. var grademajorIDList = executablePlanViewList.Select(x => x.GrademajorID).Distinct().ToList();
  1167. //查询对应的班级范围信息classmajorList
  1168. var classmajorList = ExecutablePlanDAL.GetClassmajorRangeQueryable(x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  1169. //查询对应的学生范围信息studentList
  1170. var studentList = ExecutablePlanDAL.GetStudentRangeQueryable(x => grademajorIDList.Contains(x.GrademajorID)).ToList();
  1171. //查询对应在校状态IDList
  1172. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  1173. //查询对应的教学任务班信息(业务主键:学年学期ID、课程信息ID、班级信息ID、教学任务班ID或排课任务班ID)
  1174. var educationMissionClassList = ExecutablePlanDAL.GetEducationMissionClassQueryable(x => executablePlanIDList.Contains(x.ExecutablePlanID)).ToList();
  1175. //查询授课方式teachingModeList
  1176. var teachingModeList = DictionaryHelper.GetDictionaryValue(EMIS.ViewModel.DictionaryItem.CF_TeachingMode).ToList();
  1177. int success = 0; //成功
  1178. int fail = 0; //失败
  1179. bool isEpPass = true; //提交成功判断标识
  1180. string tipMessage = null; //提示消息
  1181. List<EM_EducationMission> newEducationMissionInList = new List<EM_EducationMission>();
  1182. List<EM_EducationMission> newEducationMissionUpList = new List<EM_EducationMission>();
  1183. List<EM_EducationMissionClass> newEducationMissionClassInList = new List<EM_EducationMissionClass>();
  1184. List<EM_EducationMissionClass> newEducationMissionClassUpList = new List<EM_EducationMissionClass>();
  1185. List<EM_EducationMissionClassTeachingSetting> newEduTeachingSettingInList = new List<EM_EducationMissionClassTeachingSetting>();
  1186. List<EM_EducationMissionClassTeachingSetting> newEduTeachingSettingUpList = new List<EM_EducationMissionClassTeachingSetting>();
  1187. List<EM_EducationSchedulingClass> newEducationSchedulingClassInList = new List<EM_EducationSchedulingClass>();
  1188. List<EM_EducationMissionClassSettings> newEduSettingsInList = new List<EM_EducationMissionClassSettings>();
  1189. List<EM_CourseProcess> newCourseProcessInList = new List<EM_CourseProcess>();
  1190. List<Guid?> executablePlanIDUpList = new List<Guid?>();
  1191. foreach (var executablePlanView in executablePlanViewList)
  1192. {
  1193. //执行计划对应的授课方式判断
  1194. if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0)
  1195. {
  1196. //查询对应的班级范围信息epClassmajorList
  1197. var epClassmajorList = classmajorList.Where(x => x.GrademajorID == executablePlanView.GrademajorID).ToList();
  1198. //执行计划对应的计划范围判断
  1199. if (epClassmajorList != null && epClassmajorList.Count() > 0)
  1200. {
  1201. //查询对应的班级信息epClassmajorIDList
  1202. var epClassmajorIDList = epClassmajorList.Select(x => x.ClassmajorID).ToList();
  1203. //查询对应的学生范围信息studentList
  1204. var epStudentList = studentList.Where(x => epClassmajorIDList.Contains(x.ClassmajorID.Value)).ToList();
  1205. //执行计划对应的学生范围判断
  1206. if (epStudentList != null && epStudentList.Count() > 0)
  1207. {
  1208. //查询对应的课程信息中授课方式分班信息List
  1209. var separateModeTypeList = ExecutablePlanDAL.GetSeparateModeTypeQueryble(x => x.CoursematerialID == executablePlanView.CoursematerialID).ToList();
  1210. //查询执行计划中授课方式及对应的上课类型中的授课方式(匹配上课类型)
  1211. var minTeachingModeID = executablePlanView.TeachingModeIDList
  1212. .Where(x => !separateModeTypeList.Contains(x)).OrderBy(x => x).FirstOrDefault();
  1213. List<int?> teachingModeIDList = new List<int?>();
  1214. if (minTeachingModeID != null)
  1215. {
  1216. teachingModeIDList.Add(minTeachingModeID);
  1217. teachingModeIDList = teachingModeIDList.Concat(executablePlanView.TeachingModeIDList
  1218. .Where(x => separateModeTypeList.Contains(x))).GroupBy(x => x).Select(x => x.Key).ToList();
  1219. }
  1220. else
  1221. {
  1222. teachingModeIDList = executablePlanView.TeachingModeIDList
  1223. .Where(x => separateModeTypeList.Contains(x)).GroupBy(x => x).Select(x => x.Key).ToList();
  1224. }
  1225. //查询对应的授课方式信息List(匹配上课类型)
  1226. var epTeachingModeList = teachingModeList.Where(x => teachingModeIDList.Contains(x.Value)).ToList();
  1227. //查询对应的教学任务信息(业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID)
  1228. var epEducationMissionClassList = educationMissionClassList
  1229. .Where(x => x.EM_EducationMission.SchoolyearID == executablePlanView.SchoolyearID
  1230. && x.CoursematerialID == executablePlanView.CoursematerialID
  1231. && x.CF_Classmajor.Any(w => epClassmajorIDList.Contains(w.ClassmajorID))).ToList();
  1232. foreach (var classmajor in epClassmajorList)
  1233. {
  1234. //查询班级信息对应的教学任务班信息List
  1235. var educlList = epEducationMissionClassList.Where(x => x.CF_Classmajor
  1236. .Any(w => w.ClassmajorID == classmajor.ClassmajorID)).ToList();
  1237. if (educlList != null && educlList.Count() > 0)
  1238. {
  1239. //表示存在对应的教学任务班
  1240. //根据教学任务ID对educlList进行分组
  1241. var edugrList = educlList.GroupBy(x => x.EducationMissionID).ToList();
  1242. //根据授课方式对educlList进行分组
  1243. var tmgrList = educlList.GroupBy(x => x.TeachingModeID).ToList();
  1244. if (edugrList.Count() > 1 && tmgrList.Count() > 1)
  1245. {
  1246. //表示对应的教学任务班存在分班且成绩分开录入、授课方式多种情况
  1247. //目前此种数据有误,在生成期末设定时有问题(这里暂不处理)
  1248. isEpPass = false;
  1249. //终止此循环,提交下一个执行计划信息
  1250. break;
  1251. }
  1252. else if (edugrList.Count() > 1 && epTeachingModeList.Count() > 1)
  1253. {
  1254. //表示对应的教学任务班存在分班且成绩分开录入、授课方式只有一种情况,不可再生成多种授课方式的教学任务班信息
  1255. //目前此种数据有误,在生成期末设定时有问题
  1256. isEpPass = false;
  1257. //终止此循环,提交下一个执行计划信息
  1258. break;
  1259. }
  1260. else if (tmgrList.Count() == 1 && epTeachingModeList.Count() == 1)
  1261. {
  1262. //表示对应的教学任务班只存在一种授课方式信息(含分班且成绩合并或分开录入)
  1263. //同时生成的教学任务班信息授课方式只有一种的情况(直接修改)
  1264. foreach (var educl in educlList)
  1265. {
  1266. if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID))
  1267. {
  1268. educl.EM_EducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name;
  1269. educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  1270. educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID;
  1271. educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID;
  1272. SetModifyStatus(educl.EM_EducationMission);
  1273. newEducationMissionUpList.Add(educl.EM_EducationMission);
  1274. }
  1275. if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  1276. {
  1277. educl.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  1278. educl.CoursematerialID = executablePlanView.CoursematerialID;
  1279. educl.CourseStructureID = executablePlanView.CourseStructureID;
  1280. educl.CourseCategoryID = executablePlanView.CourseCategoryID;
  1281. educl.CourseTypeID = executablePlanView.CourseTypeID;
  1282. educl.CourseQualityID = executablePlanView.CourseQualityID;
  1283. educl.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  1284. educl.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  1285. educl.ExaminationModeID = executablePlanView.ExaminationModeID;
  1286. educl.ResultTypeID = executablePlanView.ResultTypeID;
  1287. educl.HandleModeID = executablePlanView.HandleModeID;
  1288. educl.TeachingModeID = epTeachingModeList[0].Value;
  1289. SetModifyStatus(educl);
  1290. newEducationMissionClassUpList.Add(educl);
  1291. }
  1292. if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  1293. {
  1294. educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit;
  1295. educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  1296. educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours;
  1297. educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours;
  1298. //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled)
  1299. //{
  1300. // //暂不考虑
  1301. // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  1302. // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  1303. // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  1304. // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  1305. // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  1306. // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  1307. // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  1308. //}
  1309. newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting);
  1310. }
  1311. }
  1312. }
  1313. else
  1314. {
  1315. //表示无论分班与否,成绩都是合并录入的情况(同一个教学任务ID)
  1316. //表示可根据执行计划中匹配上课类型后的授课方式进行增加、修改对应的教学任务班信息
  1317. foreach (var educl in educlList)
  1318. {
  1319. //修改
  1320. if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID))
  1321. {
  1322. educl.EM_EducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name;
  1323. educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  1324. educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID;
  1325. educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID;
  1326. SetModifyStatus(educl.EM_EducationMission);
  1327. newEducationMissionUpList.Add(educl.EM_EducationMission);
  1328. }
  1329. if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  1330. {
  1331. educl.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  1332. educl.CoursematerialID = executablePlanView.CoursematerialID;
  1333. educl.CourseStructureID = executablePlanView.CourseStructureID;
  1334. educl.CourseCategoryID = executablePlanView.CourseCategoryID;
  1335. educl.CourseTypeID = executablePlanView.CourseTypeID;
  1336. educl.CourseQualityID = executablePlanView.CourseQualityID;
  1337. educl.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  1338. educl.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  1339. educl.ExaminationModeID = executablePlanView.ExaminationModeID;
  1340. educl.ResultTypeID = executablePlanView.ResultTypeID;
  1341. educl.HandleModeID = executablePlanView.HandleModeID;
  1342. SetModifyStatus(educl);
  1343. newEducationMissionClassUpList.Add(educl);
  1344. }
  1345. if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID))
  1346. {
  1347. educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit;
  1348. educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  1349. educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours;
  1350. educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours;
  1351. //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled)
  1352. //{
  1353. // //暂不考虑
  1354. // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  1355. // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  1356. // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  1357. // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  1358. // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  1359. // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  1360. // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  1361. //}
  1362. newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting);
  1363. }
  1364. }
  1365. //将执行计划中匹配上课类型后的授课方式与对应的教学任务班的授课方式进行对比
  1366. var educltmList = tmgrList.Select(x => x.Key).ToList();
  1367. var newTeachingModeList = epTeachingModeList.Where(x => !educltmList.Contains(x.Value)).ToList();
  1368. foreach (var newTeachingMode in newTeachingModeList)
  1369. {
  1370. //新增
  1371. var newEducationMissionClass = new EM_EducationMissionClass();
  1372. newEducationMissionClass.EducationMissionClassID = Guid.NewGuid();
  1373. newEducationMissionClass.EducationMissionID = edugrList[0].Key;
  1374. newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID;
  1375. newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  1376. newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1;
  1377. newEducationMissionClass.Name = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")";
  1378. newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID;
  1379. newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID;
  1380. newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID;
  1381. newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID;
  1382. newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID;
  1383. newEducationMissionClass.ClassroomTypeID = null;
  1384. newEducationMissionClass.ClassroomID = null;
  1385. newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  1386. newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  1387. newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID;
  1388. newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID;
  1389. newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID;
  1390. newEducationMissionClass.TeachingModeID = newTeachingMode.Value;
  1391. newEducationMissionClass.Remark = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")";
  1392. SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted);
  1393. newEducationMissionClassInList.Add(newEducationMissionClass);
  1394. var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting();
  1395. newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1396. newEduTeachingSetting.Credit = executablePlanView.Credit;
  1397. newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  1398. newEduTeachingSetting.Practicehours = executablePlanView.Practicehours;
  1399. newEduTeachingSetting.Trialhours = executablePlanView.Trialhours;
  1400. newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  1401. newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  1402. newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  1403. newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  1404. newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  1405. newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  1406. newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  1407. newEduTeachingSettingInList.Add(newEduTeachingSetting);
  1408. newEducationMissionClass.CF_Classmajor = new HashSet<CF_Classmajor>();
  1409. newEducationMissionClass.CF_Classmajor.Add(classmajor);
  1410. var newEducationSchedulingClass = new EM_EducationSchedulingClass();
  1411. newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
  1412. newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1413. newEducationSchedulingClass.TaskGroupName = "1组";
  1414. newEducationSchedulingClass.Remark = classmajor.Name;
  1415. SetNewStatus(newEducationSchedulingClass);
  1416. newEducationSchedulingClassInList.Add(newEducationSchedulingClass);
  1417. newEducationSchedulingClass.CF_Student = new HashSet<CF_Student>();
  1418. var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID
  1419. && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList();
  1420. newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x));
  1421. for (int i = 0; i < executablePlanView.EndWeeklyNum; i++)
  1422. {
  1423. var newEduSettings = new EM_EducationMissionClassSettings();
  1424. newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid();
  1425. newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1426. newEduSettings.WeeklyNum = i + 1;
  1427. SetNewStatus(newEduSettings);
  1428. newEduSettingsInList.Add(newEduSettings);
  1429. var newCourseProcess = new EM_CourseProcess();
  1430. newCourseProcess.CourseProcessID = Guid.NewGuid();
  1431. newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1432. newCourseProcess.Week = i + 1;
  1433. newCourseProcess.Times = executablePlanView.WeeklyHours;
  1434. newCourseProcessInList.Add(newCourseProcess);
  1435. }
  1436. }
  1437. }
  1438. }
  1439. else
  1440. {
  1441. //表示不存在对应的教学任务班(新增)
  1442. var newEducationMission = new EM_EducationMission();
  1443. newEducationMission.EducationMissionID = Guid.NewGuid();
  1444. newEducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name;
  1445. newEducationMission.SchoolyearID = executablePlanView.SchoolyearID;
  1446. newEducationMission.CollegeID = executablePlanView.CollegeID;
  1447. newEducationMission.DepartmentID = executablePlanView.DepartmentID;
  1448. SetNewStatus(newEducationMission);
  1449. newEducationMissionInList.Add(newEducationMission);
  1450. foreach (var epTeachingMode in epTeachingModeList)
  1451. {
  1452. var newEducationMissionClass = new EM_EducationMissionClass();
  1453. newEducationMissionClass.EducationMissionClassID = Guid.NewGuid();
  1454. newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID;
  1455. newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID;
  1456. newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID;
  1457. newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1;
  1458. newEducationMissionClass.Name = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")";
  1459. newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID;
  1460. newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID;
  1461. newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID;
  1462. newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID;
  1463. newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID;
  1464. newEducationMissionClass.ClassroomTypeID = null;
  1465. newEducationMissionClass.ClassroomID = null;
  1466. newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial;
  1467. newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID;
  1468. newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID;
  1469. newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID;
  1470. newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID;
  1471. newEducationMissionClass.TeachingModeID = epTeachingMode.Value;
  1472. newEducationMissionClass.Remark = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")";
  1473. SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted);
  1474. newEducationMissionClassInList.Add(newEducationMissionClass);
  1475. var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting();
  1476. newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1477. newEduTeachingSetting.Credit = executablePlanView.Credit;
  1478. newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse;
  1479. newEduTeachingSetting.Practicehours = executablePlanView.Practicehours;
  1480. newEduTeachingSetting.Trialhours = executablePlanView.Trialhours;
  1481. newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum;
  1482. newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum;
  1483. newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum;
  1484. newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours;
  1485. newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum;
  1486. newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum;
  1487. newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum;
  1488. newEduTeachingSettingInList.Add(newEduTeachingSetting);
  1489. newEducationMissionClass.CF_Classmajor = new HashSet<CF_Classmajor>();
  1490. newEducationMissionClass.CF_Classmajor.Add(classmajor);
  1491. var newEducationSchedulingClass = new EM_EducationSchedulingClass();
  1492. newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid();
  1493. newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1494. newEducationSchedulingClass.TaskGroupName = "1组";
  1495. newEducationSchedulingClass.Remark = classmajor.Name;
  1496. SetNewStatus(newEducationSchedulingClass);
  1497. newEducationSchedulingClassInList.Add(newEducationSchedulingClass);
  1498. newEducationSchedulingClass.CF_Student = new HashSet<CF_Student>();
  1499. var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID
  1500. && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList();
  1501. newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x));
  1502. for (int i = 0; i < executablePlanView.EndWeeklyNum; i++)
  1503. {
  1504. var newEduSettings = new EM_EducationMissionClassSettings();
  1505. newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid();
  1506. newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1507. newEduSettings.WeeklyNum = i + 1;
  1508. SetNewStatus(newEduSettings);
  1509. newEduSettingsInList.Add(newEduSettings);
  1510. var newCourseProcess = new EM_CourseProcess();
  1511. newCourseProcess.CourseProcessID = Guid.NewGuid();
  1512. newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID;
  1513. newCourseProcess.Week = i + 1;
  1514. newCourseProcess.Times = executablePlanView.WeeklyHours;
  1515. newCourseProcessInList.Add(newCourseProcess);
  1516. }
  1517. }
  1518. }
  1519. }
  1520. }
  1521. else
  1522. {
  1523. //表示执行计划对应的学生范围不存在(小于等于0)
  1524. isEpPass = false;
  1525. }
  1526. }
  1527. else
  1528. {
  1529. //表示执行计划对应的计划范围不存在(小于等于0)
  1530. isEpPass = false;
  1531. }
  1532. }
  1533. else
  1534. {
  1535. //表示执行计划对应的授课方式为空
  1536. isEpPass = false;
  1537. }
  1538. if (isEpPass)
  1539. {
  1540. //表示提交成功
  1541. executablePlanIDUpList.Add(executablePlanView.ExecutablePlanID);
  1542. success++;
  1543. }
  1544. else
  1545. {
  1546. //表示提交失败
  1547. fail++;
  1548. isEpPass = true;
  1549. }
  1550. }
  1551. //更新提交成功的执行计划的状态
  1552. var newExecutablePlanUpList = ExecutablePlanDAL.ExecutablePlanRepository
  1553. .GetList(x => executablePlanIDUpList.Contains(x.ExecutablePlanID)).ToList();
  1554. newExecutablePlanUpList.ForEach(x =>
  1555. {
  1556. x.RecordStatus = (int)EM_ExecuteStatus.Submited;
  1557. SetModifyStatus(x);
  1558. });
  1559. using (TransactionScope ts = new TransactionScope())
  1560. {
  1561. //批量插入
  1562. UnitOfWork.BulkInsert(newEducationMissionInList);
  1563. UnitOfWork.BulkInsert(newEducationMissionClassInList);
  1564. UnitOfWork.BulkInsert(newEduTeachingSettingInList);
  1565. UnitOfWork.BulkInsert(newEducationMissionClassInList, (x => x.CF_Classmajor));
  1566. UnitOfWork.BulkInsert(newEducationSchedulingClassInList);
  1567. UnitOfWork.BulkInsert(newEducationSchedulingClassInList, (x => x.CF_Student));
  1568. UnitOfWork.BulkInsert(newEduSettingsInList);
  1569. UnitOfWork.BulkInsert(newCourseProcessInList);
  1570. //批量统一提交更新
  1571. if (newEducationMissionUpList != null && newEducationMissionUpList.Count() > 0)
  1572. {
  1573. UnitOfWork.BatchUpdate(newEducationMissionUpList);
  1574. }
  1575. //批量统一提交更新
  1576. if (newEducationMissionClassUpList != null && newEducationMissionClassUpList.Count() > 0)
  1577. {
  1578. UnitOfWork.BatchUpdate(newEducationMissionClassUpList);
  1579. }
  1580. //批量统一提交更新
  1581. if (newEduTeachingSettingUpList != null && newEduTeachingSettingUpList.Count() > 0)
  1582. {
  1583. UnitOfWork.BatchUpdate(newEduTeachingSettingUpList);
  1584. }
  1585. //批量统一提交更新
  1586. if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0)
  1587. {
  1588. UnitOfWork.BatchUpdate(newExecutablePlanUpList);
  1589. }
  1590. ts.Complete();
  1591. }
  1592. if (success > 0 && fail <= 0)
  1593. {
  1594. tipMessage = success + "条";
  1595. }
  1596. else
  1597. {
  1598. //暂时不提示此消息(存在分班且成绩分开录入同时授课方式多种或存在分班且成绩分开录入同时生成多种授课方式的教学任务班信息(请删除后,再提交))
  1599. tipMessage = success + "条,失败" + fail + "条,原因:数据有误,请检查(授课方式为空、执行计划范围为0或学生人数为0)";
  1600. }
  1601. return tipMessage;
  1602. }
  1603. catch (Exception ex)
  1604. {
  1605. throw new Exception(ex.Message);
  1606. }
  1607. }
  1608. }
  1609. }