PlanApplicationServices.cs 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.CultureplanManage;
  12. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  15. namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
  16. {
  17. public class PlanApplicationServices : BaseWorkflowServices<EM_PlanApplication>, IPlanApplicationServices
  18. {
  19. public PlanApplicationDAL PlanApplicationDAL { get; set; }
  20. /// <summary>
  21. /// 查询对应的计划申请信息PlanApplicationView
  22. /// 注:普教版本(年级专业)
  23. /// </summary>
  24. /// <param name="configuretView"></param>
  25. /// <param name="schoolyearID"></param>
  26. /// <param name="campusID"></param>
  27. /// <param name="collegeID"></param>
  28. /// <param name="yearID"></param>
  29. /// <param name="standardID"></param>
  30. /// <param name="educationID"></param>
  31. /// <param name="learningformID"></param>
  32. /// <param name="learnSystem"></param>
  33. /// <param name="grademajorID"></param>
  34. /// <param name="coursematerialID"></param>
  35. /// <param name="handleModeID"></param>
  36. /// <param name="approvalStatus"></param>
  37. /// <param name="pageIndex"></param>
  38. /// <param name="pageSize"></param>
  39. /// <returns></returns>
  40. public IGridResultSet<PlanApplicationView> GetPlanApplicationViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
  41. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID,
  42. Guid? coursematerialID, int? handleModeID, int? approvalStatus, int pageIndex, int pageSize)
  43. {
  44. //结束流程环节ID
  45. var endStatusID = this.GetCorrectEndStatus();
  46. //审核流程状态IDList
  47. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  48. var applyStatusList = this.GetStatusViewList();
  49. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  50. .Select(x => x.ID).ToList();
  51. //计划申请
  52. Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  53. expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus));
  54. if (schoolyearID.HasValue)
  55. {
  56. expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
  57. }
  58. if (grademajorID.HasValue)
  59. {
  60. expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
  61. }
  62. if (coursematerialID.HasValue)
  63. {
  64. expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
  65. }
  66. if (handleModeID.HasValue)
  67. {
  68. expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
  69. }
  70. if (approvalStatus.HasValue)
  71. {
  72. expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
  73. }
  74. var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
  75. if (campusID.HasValue)
  76. {
  77. query = query.Where(x => x.CampusID == campusID);
  78. }
  79. if (collegeID.HasValue)
  80. {
  81. query = query.Where(x => x.CollegeID == collegeID);
  82. }
  83. if (yearID.HasValue)
  84. {
  85. query = query.Where(x => x.GradeID == yearID);
  86. }
  87. if (standardID.HasValue)
  88. {
  89. query = query.Where(x => x.StandardID == standardID);
  90. }
  91. if (educationID.HasValue)
  92. {
  93. query = query.Where(x => x.EducationID == educationID);
  94. }
  95. if (learningformID.HasValue)
  96. {
  97. query = query.Where(x => x.LearningformID == learningformID);
  98. }
  99. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  100. {
  101. var LearnSystems = Convert.ToDecimal(learnSystem);
  102. query = query.Where(x => x.LearnSystem == LearnSystems);
  103. }
  104. //查询条件
  105. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  106. {
  107. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  108. }
  109. var result = this.GetQueryByDataRangeByCollege(query)
  110. .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
  111. .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
  112. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  113. .ThenByDescending(x => x.CreateTime).ToGridResultSet<PlanApplicationView>(pageIndex, pageSize);
  114. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  115. return result;
  116. }
  117. /// <summary>
  118. /// 查询对应的计划申请信息List
  119. /// 注:普教版本(年级专业)
  120. /// </summary>
  121. /// <param name="configuretView"></param>
  122. /// <param name="schoolyearID"></param>
  123. /// <param name="campusID"></param>
  124. /// <param name="collegeID"></param>
  125. /// <param name="yearID"></param>
  126. /// <param name="standardID"></param>
  127. /// <param name="educationID"></param>
  128. /// <param name="learningformID"></param>
  129. /// <param name="learnSystem"></param>
  130. /// <param name="grademajorID"></param>
  131. /// <param name="coursematerialID"></param>
  132. /// <param name="handleModeID"></param>
  133. /// <param name="approvalStatus"></param>
  134. /// <returns></returns>
  135. public IList<PlanApplicationView> GetPlanApplicationViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID,
  136. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID,
  137. Guid? coursematerialID, int? handleModeID, int? approvalStatus)
  138. {
  139. //结束流程环节ID
  140. var endStatusID = this.GetCorrectEndStatus();
  141. //审核流程状态IDList
  142. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  143. var applyStatusList = this.GetStatusViewList();
  144. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  145. .Select(x => x.ID).ToList();
  146. //计划申请
  147. Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  148. expPlanApplication = expPlanApplication.And(x => applyStatusIDList.Contains(x.RecordStatus));
  149. if (schoolyearID.HasValue)
  150. {
  151. expPlanApplication = expPlanApplication.And(x => x.SchoolyearID == schoolyearID);
  152. }
  153. if (grademajorID.HasValue)
  154. {
  155. expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
  156. }
  157. if (coursematerialID.HasValue)
  158. {
  159. expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
  160. }
  161. if (handleModeID.HasValue)
  162. {
  163. expPlanApplication = expPlanApplication.And(x => x.HandleModeID == handleModeID);
  164. }
  165. if (approvalStatus.HasValue)
  166. {
  167. expPlanApplication = expPlanApplication.And(x => x.RecordStatus == approvalStatus);
  168. }
  169. var query = PlanApplicationDAL.GetPlanApplicationViewQueryable(expPlanApplication);
  170. if (campusID.HasValue)
  171. {
  172. query = query.Where(x => x.CampusID == campusID);
  173. }
  174. if (collegeID.HasValue)
  175. {
  176. query = query.Where(x => x.CollegeID == collegeID);
  177. }
  178. if (yearID.HasValue)
  179. {
  180. query = query.Where(x => x.GradeID == yearID);
  181. }
  182. if (standardID.HasValue)
  183. {
  184. query = query.Where(x => x.StandardID == standardID);
  185. }
  186. if (educationID.HasValue)
  187. {
  188. query = query.Where(x => x.EducationID == educationID);
  189. }
  190. if (learningformID.HasValue)
  191. {
  192. query = query.Where(x => x.LearningformID == learningformID);
  193. }
  194. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  195. {
  196. var LearnSystems = Convert.ToDecimal(learnSystem);
  197. query = query.Where(x => x.LearnSystem == LearnSystems);
  198. }
  199. //查询条件
  200. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  201. {
  202. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  203. }
  204. var result = this.GetQueryByDataRangeByCollege(query)
  205. .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode)
  206. .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID)
  207. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  208. .ThenByDescending(x => x.CreateTime).ToList();
  209. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  210. return result;
  211. }
  212. /// <summary>
  213. /// 查询对应的计划申请信息PlanApplicationView(根据计划申请ID)
  214. /// </summary>
  215. /// <param name="planApplicationID"></param>
  216. /// <returns></returns>
  217. public PlanApplicationView GetPlanApplicationView(Guid? planApplicationID)
  218. {
  219. try
  220. {
  221. var planApplicationView = PlanApplicationDAL.GetPlanApplicationViewQueryable(x => x.PlanApplicationID == planApplicationID).SingleOrDefault();
  222. return planApplicationView;
  223. }
  224. catch (Exception ex)
  225. {
  226. throw new Exception(ex.Message);
  227. }
  228. }
  229. /// <summary>
  230. /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID)
  231. /// </summary>
  232. /// <param name="planApplicationView"></param>
  233. public void PlanApplicationEdit(PlanApplicationView planApplicationView)
  234. {
  235. try
  236. {
  237. //查询对应的工作流程环节状态信息View
  238. var approveStatusList = this.GetStatusViewList();
  239. if (approveStatusList == null || approveStatusList.Count() <= 0)
  240. {
  241. throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
  242. }
  243. //查询工作流程开始环节状态
  244. var startStatusID = this.GetStartStatus();
  245. if (startStatusID == null)
  246. {
  247. throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。");
  248. }
  249. //结束流程环节ID
  250. var endStatusID = this.GetCorrectEndStatus();
  251. if (endStatusID == null)
  252. {
  253. throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。");
  254. }
  255. //审核流程状态IDList
  256. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  257. var applyStatusIDList = approveStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  258. .Select(x => x.ID).ToList();
  259. //查询数据库进行验证
  260. var planApplicationVerify = PlanApplicationDAL.PlanApplicationRepository
  261. .GetList(x => x.PlanApplicationID != planApplicationView.PlanApplicationID
  262. && x.SchoolyearID == planApplicationView.SchoolyearID
  263. && x.GrademajorID == planApplicationView.GrademajorID
  264. && x.CoursematerialID == planApplicationView.CoursematerialID).SingleOrDefault();
  265. if (planApplicationVerify == null)
  266. {
  267. //查询对应的年级专业信息
  268. var grademajor = PlanApplicationDAL.GrademajorRepository
  269. .GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault();
  270. if (grademajor == null)
  271. {
  272. throw new Exception("年级专业信息不存在,请检查。");
  273. }
  274. //查询年级专业对应的入学学年学期信息
  275. var startSchoolyear = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID
  276. && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
  277. if (startSchoolyear == null)
  278. {
  279. throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。");
  280. }
  281. //查询年级专业对应的毕业学年学期信息
  282. var graduatingSemester = PlanApplicationDAL.SchoolyearRepository
  283. .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  284. if (graduatingSemester == null)
  285. {
  286. throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。");
  287. }
  288. //查询对应的学年学期信息
  289. var schoolyear = PlanApplicationDAL.SchoolyearRepository
  290. .GetList(x => x.SchoolyearID == planApplicationView.SchoolyearID).SingleOrDefault();
  291. if (schoolyear == null)
  292. {
  293. throw new Exception("学年学期信息不存在,请检查。");
  294. }
  295. if (schoolyear.Value < startSchoolyear.Value)
  296. {
  297. throw new Exception("学年学期小于入学学年学期,请检查。");
  298. }
  299. if (schoolyear.Value > graduatingSemester.Value)
  300. {
  301. throw new Exception("学年学期大于毕业学年学期,请检查。");
  302. }
  303. List<EM_PlanApplication> newPlanApplicationInList = new List<EM_PlanApplication>();
  304. List<EM_PlanApplication> newPlanApplicationUpList = new List<EM_PlanApplication>();
  305. List<EM_PlanApplicationTeachingSetting> newTeachingSettingInList = new List<EM_PlanApplicationTeachingSetting>();
  306. List<EM_PlanApplicationTeachingSetting> newTeachingSettingUpList = new List<EM_PlanApplicationTeachingSetting>();
  307. List<EM_PlanApplicationTeachingModeType> newTeachingModeTypeInList = new List<EM_PlanApplicationTeachingModeType>();
  308. List<EM_PlanApplicationTeachingPlace> newTeachingPlaceInList = new List<EM_PlanApplicationTeachingPlace>();
  309. List<Guid?> planApplicationTMDelList = new List<Guid?>();
  310. List<Guid?> planApplicationTPDelList = new List<Guid?>();
  311. //数据有误验证
  312. if (planApplicationView.PlanApplicationID != Guid.Empty)
  313. {
  314. var planApplication = PlanApplicationDAL.PlanApplicationRepository
  315. .GetList(x => x.PlanApplicationID == planApplicationView.PlanApplicationID,
  316. (x => x.EM_PlanApplicationTeachingSetting)).SingleOrDefault();
  317. if (planApplication == null)
  318. {
  319. throw new Exception("数据有误,请核查。");
  320. }
  321. else
  322. {
  323. //表示修改
  324. if (applyStatusIDList.Any(x => x == planApplication.RecordStatus))
  325. {
  326. planApplication.SchoolyearID = planApplicationView.SchoolyearID;
  327. planApplication.GrademajorID = planApplicationView.GrademajorID;
  328. planApplication.CoursematerialID = planApplicationView.CoursematerialID;
  329. planApplication.CourseStructureID = planApplicationView.CourseStructureID;
  330. planApplication.CourseCategoryID = planApplicationView.CourseCategoryID;
  331. planApplication.CourseTypeID = planApplicationView.CourseTypeID;
  332. planApplication.CourseQualityID = planApplicationView.CourseQualityID;
  333. planApplication.DepartmentID = planApplicationView.DepartmentID;
  334. planApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore;
  335. planApplication.IsCooperation = planApplicationView.IsCooperation;
  336. planApplication.IsRequired = planApplicationView.IsRequired;
  337. planApplication.IsElective = planApplicationView.IsElective;
  338. planApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse;
  339. planApplication.IsMainCourse = planApplicationView.IsMainCourse;
  340. planApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial;
  341. planApplication.CourseFineID = planApplicationView.CourseFineID;
  342. planApplication.PracticeTypeID = planApplicationView.PracticeTypeID;
  343. planApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID;
  344. planApplication.ExaminationModeID = planApplicationView.ExaminationModeID;
  345. planApplication.ResultTypeID = planApplicationView.ResultTypeID;
  346. planApplication.HandleModeID = planApplicationView.HandleModeID;
  347. planApplication.Remark = planApplicationView.Remark;
  348. SetModifyStatus(planApplication);
  349. newPlanApplicationUpList.Add(planApplication);
  350. if (planApplication.EM_PlanApplicationTeachingSetting == null)
  351. {
  352. var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
  353. newTeachingSetting.PlanApplicationID = planApplication.PlanApplicationID;
  354. newTeachingSetting.Credit = planApplicationView.Credit;
  355. newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
  356. newTeachingSetting.Practicehours = planApplicationView.Practicehours;
  357. newTeachingSetting.Trialhours = planApplicationView.Trialhours;
  358. newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
  359. newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
  360. newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
  361. newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
  362. newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
  363. newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
  364. newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
  365. newTeachingSettingInList.Add(newTeachingSetting);
  366. }
  367. else
  368. {
  369. planApplication.EM_PlanApplicationTeachingSetting.Credit = planApplicationView.Credit;
  370. planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
  371. planApplication.EM_PlanApplicationTeachingSetting.Practicehours = planApplicationView.Practicehours;
  372. planApplication.EM_PlanApplicationTeachingSetting.Trialhours = planApplicationView.Trialhours;
  373. planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
  374. planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
  375. planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
  376. planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
  377. planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
  378. planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
  379. planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
  380. newTeachingSettingUpList.Add(planApplication.EM_PlanApplicationTeachingSetting);
  381. }
  382. if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0)
  383. {
  384. planApplicationTMDelList.Add(planApplication.PlanApplicationID);
  385. foreach (var teachingModeID in planApplicationView.TeachingModeIDList)
  386. {
  387. var newTeachingMode = new EM_PlanApplicationTeachingModeType();
  388. newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
  389. newTeachingMode.PlanApplicationID = planApplication.PlanApplicationID;
  390. newTeachingMode.TeachingModeID = teachingModeID;
  391. SetNewStatus(newTeachingMode);
  392. newTeachingModeTypeInList.Add(newTeachingMode);
  393. }
  394. }
  395. else
  396. {
  397. planApplicationTMDelList.Add(planApplication.PlanApplicationID);
  398. }
  399. if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0)
  400. {
  401. planApplicationTPDelList.Add(planApplication.PlanApplicationID);
  402. foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList)
  403. {
  404. var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
  405. newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
  406. newTeachingPlace.PlanApplicationID = planApplication.PlanApplicationID;
  407. newTeachingPlace.TeachingPlace = teachingPlaceID;
  408. SetNewStatus(newTeachingPlace);
  409. newTeachingPlaceInList.Add(newTeachingPlace);
  410. }
  411. }
  412. else
  413. {
  414. planApplicationTPDelList.Add(planApplication.PlanApplicationID);
  415. }
  416. }
  417. else
  418. {
  419. throw new Exception("数据有误,请核查(只能修改未提交、已退回状态的信息)。");
  420. }
  421. }
  422. }
  423. else
  424. {
  425. //表示新增
  426. var newPlanApplication = new EM_PlanApplication();
  427. newPlanApplication.PlanApplicationID = Guid.NewGuid();
  428. newPlanApplication.SchoolyearID = planApplicationView.SchoolyearID;
  429. newPlanApplication.GrademajorID = planApplicationView.GrademajorID;
  430. newPlanApplication.CoursematerialID = planApplicationView.CoursematerialID;
  431. newPlanApplication.CourseStructureID = planApplicationView.CourseStructureID;
  432. newPlanApplication.CourseCategoryID = planApplicationView.CourseCategoryID;
  433. newPlanApplication.CourseTypeID = planApplicationView.CourseTypeID;
  434. newPlanApplication.CourseQualityID = planApplicationView.CourseQualityID;
  435. newPlanApplication.DepartmentID = planApplicationView.DepartmentID;
  436. newPlanApplication.IsSpecialtycore = planApplicationView.IsSpecialtycore;
  437. newPlanApplication.IsCooperation = planApplicationView.IsCooperation;
  438. newPlanApplication.IsRequired = planApplicationView.IsRequired;
  439. newPlanApplication.IsElective = planApplicationView.IsElective;
  440. newPlanApplication.IsNetworkCourse = planApplicationView.IsNetworkCourse;
  441. newPlanApplication.IsMainCourse = planApplicationView.IsMainCourse;
  442. newPlanApplication.IsNeedMaterial = planApplicationView.IsNeedMaterial;
  443. newPlanApplication.CourseFineID = planApplicationView.CourseFineID;
  444. newPlanApplication.PracticeTypeID = planApplicationView.PracticeTypeID;
  445. newPlanApplication.TeachinglanguageID = planApplicationView.TeachinglanguageID;
  446. newPlanApplication.ExaminationModeID = planApplicationView.ExaminationModeID;
  447. newPlanApplication.ResultTypeID = planApplicationView.ResultTypeID;
  448. newPlanApplication.HandleModeID = planApplicationView.HandleModeID;
  449. newPlanApplication.Remark = planApplicationView.Remark;
  450. SetNewStatus(newPlanApplication, startStatusID.Value);
  451. newPlanApplicationInList.Add(newPlanApplication);
  452. var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
  453. newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID;
  454. newTeachingSetting.Credit = planApplicationView.Credit;
  455. newTeachingSetting.TheoryCourse = planApplicationView.TheoryCourse;
  456. newTeachingSetting.Practicehours = planApplicationView.Practicehours;
  457. newTeachingSetting.Trialhours = planApplicationView.Trialhours;
  458. newTeachingSetting.TheoryWeeklyNum = planApplicationView.TheoryWeeklyNum;
  459. newTeachingSetting.PracticeWeeklyNum = planApplicationView.PracticeWeeklyNum;
  460. newTeachingSetting.TrialWeeklyNum = planApplicationView.TrialWeeklyNum;
  461. newTeachingSetting.WeeklyHours = planApplicationView.WeeklyHours;
  462. newTeachingSetting.WeeklyNum = planApplicationView.WeeklyNum;
  463. newTeachingSetting.StartWeeklyNum = planApplicationView.StartWeeklyNum;
  464. newTeachingSetting.EndWeeklyNum = planApplicationView.EndWeeklyNum;
  465. newTeachingSettingInList.Add(newTeachingSetting);
  466. if (planApplicationView.TeachingModeIDList != null && planApplicationView.TeachingModeIDList.Count() > 0)
  467. {
  468. foreach (var teachingModeID in planApplicationView.TeachingModeIDList)
  469. {
  470. var newTeachingMode = new EM_PlanApplicationTeachingModeType();
  471. newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
  472. newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID;
  473. newTeachingMode.TeachingModeID = teachingModeID;
  474. SetNewStatus(newTeachingMode);
  475. newTeachingModeTypeInList.Add(newTeachingMode);
  476. }
  477. }
  478. if (planApplicationView.TeachingPlaceIDList != null && planApplicationView.TeachingPlaceIDList.Count() > 0)
  479. {
  480. foreach (var teachingPlaceID in planApplicationView.TeachingPlaceIDList)
  481. {
  482. var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
  483. newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
  484. newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID;
  485. newTeachingPlace.TeachingPlace = teachingPlaceID;
  486. SetNewStatus(newTeachingPlace);
  487. newTeachingPlaceInList.Add(newTeachingPlace);
  488. }
  489. }
  490. }
  491. //事务提交
  492. //UnitOfWork.Commit();
  493. using (TransactionScope ts = new TransactionScope())
  494. {
  495. //删除
  496. UnitOfWork.Delete<EM_PlanApplicationTeachingPlace>(x => planApplicationTPDelList.Contains(x.PlanApplicationID));
  497. UnitOfWork.Delete<EM_PlanApplicationTeachingModeType>(x => planApplicationTMDelList.Contains(x.PlanApplicationID));
  498. //批量插入
  499. UnitOfWork.BulkInsert(newPlanApplicationInList);
  500. UnitOfWork.BulkInsert(newTeachingSettingInList);
  501. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  502. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  503. //批量统一提交更新
  504. if (newPlanApplicationUpList != null && newPlanApplicationUpList.Count() > 0)
  505. {
  506. UnitOfWork.BatchUpdate(newPlanApplicationUpList);
  507. }
  508. //批量统一提交更新
  509. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  510. {
  511. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  512. }
  513. ts.Complete();
  514. }
  515. }
  516. else
  517. {
  518. throw new Exception("已存在相同的计划申请信息(学年学期、年级专业、课程信息唯一),请核查。");
  519. }
  520. }
  521. catch (Exception ex)
  522. {
  523. throw new Exception(ex.Message);
  524. }
  525. }
  526. /// <summary>
  527. /// 专业课程模版批量新增
  528. /// </summary>
  529. /// <param name="specialtyCourseViewList"></param>
  530. /// <param name="planApplicationView"></param>
  531. /// <returns></returns>
  532. public string PlanApplicationBatchAdd(List<SpecialtyCourseView> specialtyCourseViewList, PlanApplicationView planApplicationView)
  533. {
  534. try
  535. {
  536. //查询对应的工作流程环节状态信息View
  537. var approveStatusList = this.GetStatusViewList();
  538. if (approveStatusList == null || approveStatusList.Count() <= 0)
  539. {
  540. throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
  541. }
  542. //查询工作流程开始环节状态
  543. var startStatusID = this.GetStartStatus();
  544. if (startStatusID == null)
  545. {
  546. throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。");
  547. }
  548. //查询对应的年级专业信息
  549. var grademajor = PlanApplicationDAL.GrademajorRepository.GetList(x => x.GrademajorID == planApplicationView.GrademajorID).SingleOrDefault();
  550. if (grademajor == null)
  551. {
  552. throw new Exception("选择申请的年级专业不存在,请检查。");
  553. }
  554. //查询学年学期信息schoolyearList
  555. var schoolyearList = PlanApplicationDAL.SchoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  556. //查询年级专业对应的入学学年学期信息
  557. var startSchoolyear = schoolyearList.Where(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault();
  558. if (startSchoolyear == null)
  559. {
  560. throw new Exception("选择申请的年级专业对应的入学学年学期不存在,请检查。");
  561. }
  562. //查询年级专业对应的毕业学年学期信息
  563. var graduatingSemester = schoolyearList.Where(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  564. if (graduatingSemester == null)
  565. {
  566. throw new Exception("选择申请的年级专业对应的毕业学年学期信息不存在,请检查。");
  567. }
  568. //查询计划申请信息planApplicationList
  569. var planApplicationList = PlanApplicationDAL.PlanApplicationRepository.GetList(x => x.GrademajorID == grademajor.GrademajorID, (x => x.EM_PlanApplicationTeachingSetting)).ToList();
  570. int success = 0; //成功
  571. int fail = 0; //失败
  572. string tipMessage = null; //提示消息
  573. List<EM_PlanApplication> newPlanApplicationInList = new List<EM_PlanApplication>();
  574. List<EM_PlanApplicationTeachingSetting> newTeachingSettingInList = new List<EM_PlanApplicationTeachingSetting>();
  575. List<EM_PlanApplicationTeachingModeType> newTeachingModeTypeInList = new List<EM_PlanApplicationTeachingModeType>();
  576. List<EM_PlanApplicationTeachingPlace> newTeachingPlaceInList = new List<EM_PlanApplicationTeachingPlace>();
  577. foreach (var specialtyCourseView in specialtyCourseViewList)
  578. {
  579. //判断对应的学年学期信息
  580. var value = startSchoolyear.Value + specialtyCourseView.StarttermID - 1;
  581. if (value < startSchoolyear.Value)
  582. {
  583. //表示学年学期小于入学学年学期
  584. fail++;
  585. }
  586. else
  587. {
  588. if (value > graduatingSemester.Value)
  589. {
  590. //表示学年学期大于毕业学年学期
  591. fail++;
  592. }
  593. else
  594. {
  595. var schoolyear = schoolyearList.Where(x => x.Value == value).SingleOrDefault();
  596. if (schoolyear == null)
  597. {
  598. //表示对应的学年学期信息不存在
  599. fail++;
  600. }
  601. else
  602. {
  603. //查询对应的计划申请信息(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  604. var planApplication = planApplicationList.Where(x => x.SchoolyearID == schoolyear.SchoolyearID
  605. && x.GrademajorID == grademajor.GrademajorID
  606. && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault();
  607. if (planApplication == null)
  608. {
  609. //表示新增
  610. var newPlanApplication = new EM_PlanApplication();
  611. newPlanApplication.PlanApplicationID = Guid.NewGuid();
  612. newPlanApplication.SchoolyearID = schoolyear.SchoolyearID;
  613. newPlanApplication.GrademajorID = grademajor.GrademajorID;
  614. newPlanApplication.CoursematerialID = specialtyCourseView.CoursematerialID;
  615. newPlanApplication.CourseStructureID = specialtyCourseView.CourseStructureID;
  616. newPlanApplication.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  617. newPlanApplication.CourseTypeID = specialtyCourseView.CourseTypeID;
  618. newPlanApplication.CourseQualityID = specialtyCourseView.CourseQualityID;
  619. newPlanApplication.DepartmentID = specialtyCourseView.DepartmentID;
  620. newPlanApplication.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  621. newPlanApplication.IsCooperation = specialtyCourseView.IsCooperation;
  622. newPlanApplication.IsRequired = specialtyCourseView.IsRequired;
  623. newPlanApplication.IsElective = specialtyCourseView.IsElective;
  624. newPlanApplication.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  625. newPlanApplication.IsMainCourse = specialtyCourseView.IsMainCourse;
  626. newPlanApplication.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  627. newPlanApplication.CourseFineID = specialtyCourseView.CourseFineID;
  628. newPlanApplication.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  629. newPlanApplication.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  630. newPlanApplication.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  631. newPlanApplication.ResultTypeID = specialtyCourseView.ResultTypeID;
  632. newPlanApplication.HandleModeID = specialtyCourseView.HandleModeID;
  633. newPlanApplication.Remark = planApplicationView.Remark;
  634. SetNewStatus(newPlanApplication, startStatusID.Value);
  635. newPlanApplicationInList.Add(newPlanApplication);
  636. var newTeachingSetting = new EM_PlanApplicationTeachingSetting();
  637. newTeachingSetting.PlanApplicationID = newPlanApplication.PlanApplicationID;
  638. newTeachingSetting.Credit = specialtyCourseView.Credit;
  639. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  640. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  641. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  642. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  643. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  644. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  645. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  646. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  647. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  648. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  649. newTeachingSettingInList.Add(newTeachingSetting);
  650. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  651. {
  652. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  653. {
  654. var newTeachingMode = new EM_PlanApplicationTeachingModeType();
  655. newTeachingMode.PlanApplicationTeachingModeTypeID = Guid.NewGuid();
  656. newTeachingMode.PlanApplicationID = newPlanApplication.PlanApplicationID;
  657. newTeachingMode.TeachingModeID = teachingModeID;
  658. SetNewStatus(newTeachingMode);
  659. newTeachingModeTypeInList.Add(newTeachingMode);
  660. }
  661. }
  662. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  663. {
  664. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  665. {
  666. var newTeachingPlace = new EM_PlanApplicationTeachingPlace();
  667. newTeachingPlace.PlanApplicationTeachingPlaceID = Guid.NewGuid();
  668. newTeachingPlace.PlanApplicationID = newPlanApplication.PlanApplicationID;
  669. newTeachingPlace.TeachingPlace = teachingPlaceID;
  670. SetNewStatus(newTeachingPlace);
  671. newTeachingPlaceInList.Add(newTeachingPlace);
  672. }
  673. }
  674. success++;
  675. }
  676. else
  677. {
  678. //表示已存在相同的计划申请信息
  679. fail++;
  680. }
  681. }
  682. }
  683. }
  684. }
  685. //事务提交
  686. using (TransactionScope ts = new TransactionScope())
  687. {
  688. //批量插入
  689. UnitOfWork.BulkInsert(newPlanApplicationInList);
  690. UnitOfWork.BulkInsert(newTeachingSettingInList);
  691. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  692. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  693. ts.Complete();
  694. }
  695. if (success > 0 && fail <= 0)
  696. {
  697. tipMessage = success + "条";
  698. }
  699. else
  700. {
  701. tipMessage = success + "条,失败" + fail + "条,原因:学年学期小于入学学年学期、学年学期大于毕业学年学期、对应的学年学期不存在或已存在相同的计划申请信息,请检查";
  702. }
  703. return tipMessage;
  704. }
  705. catch (Exception ex)
  706. {
  707. throw new Exception(ex.Message);
  708. }
  709. }
  710. /// <summary>
  711. /// 查询对应的未申请专业课程信息SpecialtyCourseView
  712. /// </summary>
  713. /// <param name="configuretView"></param>
  714. /// <param name="departmentID"></param>
  715. /// <param name="standardID"></param>
  716. /// <param name="educationID"></param>
  717. /// <param name="learningformID"></param>
  718. /// <param name="learnSystem"></param>
  719. /// <param name="coursematerialID"></param>
  720. /// <param name="starttermID"></param>
  721. /// <param name="handleModeID"></param>
  722. /// <param name="yearID"></param>
  723. /// <param name="grademajorID"></param>
  724. /// <param name="pageIndex"></param>
  725. /// <param name="pageSize"></param>
  726. /// <returns></returns>
  727. public IGridResultSet<SpecialtyCourseView> GetSpecialtyCourseViewNoApplyGrid(ConfiguretView configuretView, Guid? departmentID,
  728. int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
  729. int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID, int pageIndex, int pageSize)
  730. {
  731. //结束流程环节ID
  732. var endStatusID = this.GetCorrectEndStatus();
  733. //专业课程
  734. Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  735. expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
  736. if (departmentID.HasValue)
  737. {
  738. expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
  739. }
  740. if (coursematerialID.HasValue)
  741. {
  742. expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
  743. }
  744. if (starttermID.HasValue)
  745. {
  746. expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
  747. }
  748. if (handleModeID.HasValue)
  749. {
  750. expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
  751. }
  752. //年级专业
  753. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  754. if (yearID.HasValue)
  755. {
  756. expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
  757. }
  758. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  759. //计划申请
  760. Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  761. //注:需排除审核通过状态的计划申请信息
  762. expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID);
  763. if (coursematerialID.HasValue)
  764. {
  765. expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
  766. }
  767. if (grademajorID.HasValue)
  768. {
  769. expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
  770. }
  771. //专业计划
  772. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  773. if (coursematerialID.HasValue)
  774. {
  775. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  776. }
  777. if (grademajorID.HasValue)
  778. {
  779. expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID);
  780. }
  781. var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan);
  782. if (standardID.HasValue)
  783. {
  784. query = query.Where(x => x.StandardID == standardID);
  785. }
  786. if (educationID.HasValue)
  787. {
  788. query = query.Where(x => x.EducationID == educationID);
  789. }
  790. if (learningformID.HasValue)
  791. {
  792. query = query.Where(x => x.LearningformID == learningformID);
  793. }
  794. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  795. {
  796. var LearnSystems = Convert.ToDecimal(learnSystem);
  797. query = query.Where(x => x.LearnSystem == LearnSystems);
  798. }
  799. //查询条件
  800. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  801. {
  802. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  803. }
  804. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  805. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  806. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  807. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  808. .ToGridResultSet<SpecialtyCourseView>(pageIndex, pageSize);
  809. }
  810. /// <summary>
  811. /// 查询对应的未申请专业课程信息List
  812. /// </summary>
  813. /// <param name="configuretView"></param>
  814. /// <param name="departmentID"></param>
  815. /// <param name="standardID"></param>
  816. /// <param name="educationID"></param>
  817. /// <param name="learningformID"></param>
  818. /// <param name="learnSystem"></param>
  819. /// <param name="coursematerialID"></param>
  820. /// <param name="starttermID"></param>
  821. /// <param name="handleModeID"></param>
  822. /// <param name="yearID"></param>
  823. /// <param name="grademajorID"></param>
  824. /// <returns></returns>
  825. public IList<SpecialtyCourseView> GetSpecialtyCourseViewNoApplyList(ConfiguretView configuretView, Guid? departmentID,
  826. int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
  827. int? starttermID, int? handleModeID, int? yearID, Guid? grademajorID)
  828. {
  829. //结束流程环节ID
  830. var endStatusID = this.GetCorrectEndStatus();
  831. //专业课程
  832. Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  833. expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
  834. if (departmentID.HasValue)
  835. {
  836. expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
  837. }
  838. if (coursematerialID.HasValue)
  839. {
  840. expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
  841. }
  842. if (starttermID.HasValue)
  843. {
  844. expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
  845. }
  846. if (handleModeID.HasValue)
  847. {
  848. expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
  849. }
  850. //年级专业
  851. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  852. if (yearID.HasValue)
  853. {
  854. expGrademajor = expGrademajor.And(x => x.GradeID == yearID);
  855. }
  856. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  857. //计划申请
  858. Expression<Func<EM_PlanApplication, bool>> expPlanApplication = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  859. //注:需排除审核通过状态的计划申请信息
  860. expPlanApplication = expPlanApplication.And(x => x.RecordStatus != endStatusID);
  861. if (coursematerialID.HasValue)
  862. {
  863. expPlanApplication = expPlanApplication.And(x => x.CoursematerialID == coursematerialID);
  864. }
  865. if (grademajorID.HasValue)
  866. {
  867. expPlanApplication = expPlanApplication.And(x => x.GrademajorID == grademajorID);
  868. }
  869. //专业计划
  870. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  871. if (coursematerialID.HasValue)
  872. {
  873. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  874. }
  875. if (grademajorID.HasValue)
  876. {
  877. expSpecialtyPlan = expSpecialtyPlan.And(x => x.GrademajorID == grademajorID);
  878. }
  879. var query = PlanApplicationDAL.GetSpecialtyCourseViewNoApplyQueryable(expSpecialtyCourse, expGrademajor, expPlanApplication, expSpecialtyPlan);
  880. if (standardID.HasValue)
  881. {
  882. query = query.Where(x => x.StandardID == standardID);
  883. }
  884. if (educationID.HasValue)
  885. {
  886. query = query.Where(x => x.EducationID == educationID);
  887. }
  888. if (learningformID.HasValue)
  889. {
  890. query = query.Where(x => x.LearningformID == learningformID);
  891. }
  892. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  893. {
  894. var LearnSystems = Convert.ToDecimal(learnSystem);
  895. query = query.Where(x => x.LearnSystem == LearnSystems);
  896. }
  897. //查询条件
  898. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  899. {
  900. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  901. }
  902. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  903. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  904. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  905. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList();
  906. }
  907. /// <summary>
  908. /// 删除
  909. /// </summary>
  910. /// <param name="planApplicationIDs"></param>
  911. /// <returns></returns>
  912. public bool PlanApplicationDelete(List<Guid?> planApplicationIDs)
  913. {
  914. try
  915. {
  916. using (TransactionScope ts = new TransactionScope())
  917. {
  918. UnitOfWork.Delete<EM_PlanApplicationTeachingPlace>(x => planApplicationIDs.Contains(x.PlanApplicationID));
  919. UnitOfWork.Delete<EM_PlanApplicationTeachingModeType>(x => planApplicationIDs.Contains(x.PlanApplicationID));
  920. UnitOfWork.Delete<EM_PlanApplicationTeachingSetting>(x => planApplicationIDs.Contains(x.PlanApplicationID));
  921. UnitOfWork.Delete<EM_PlanApplication>(x => planApplicationIDs.Contains(x.PlanApplicationID));
  922. ts.Complete();
  923. return true;
  924. }
  925. }
  926. catch (Exception)
  927. {
  928. throw;
  929. }
  930. }
  931. /// <summary>
  932. /// 提交
  933. /// </summary>
  934. /// <param name="planApplicationIDs"></param>
  935. /// <param name="userID"></param>
  936. /// <param name="comment"></param>
  937. /// <returns></returns>
  938. public string PlanApplicationSubmit(List<Guid> planApplicationIDs, Guid userID, string comment = "")
  939. {
  940. try
  941. {
  942. //查询对应的工作流程环节状态信息View
  943. var approveStatusList = this.GetStatusViewList();
  944. if (approveStatusList == null || approveStatusList.Count() <= 0)
  945. {
  946. throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
  947. }
  948. //查询工作流程开始环节状态
  949. var startStatusID = this.GetStartStatus();
  950. if (startStatusID == null)
  951. {
  952. throw new Exception("工作流平台中,专业计划流程开始环节未配置,请核查。");
  953. }
  954. //查询对应的计划申请信息List
  955. var planApplicationList = PlanApplicationDAL.PlanApplicationRepository
  956. .GetList(x => planApplicationIDs.Contains(x.PlanApplicationID), (x => x.EM_PlanApplicationTeachingSetting)).ToList();
  957. //计划申请信息对应的grademajorIDList
  958. var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString()))
  959. .Select(x => x.GrademajorID).ToList();
  960. //查询对应的专业计划信息
  961. var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository
  962. .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
  963. int success = 0; //成功
  964. int fail = 0; //失败
  965. string tipMessage = null; //提示消息
  966. var submitIDList = new List<Guid>();
  967. var approveIDList = new List<Guid>();
  968. foreach (var planApplication in planApplicationList)
  969. {
  970. //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  971. var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID
  972. && x.GrademajorID == planApplication.GrademajorID
  973. && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault();
  974. if (specialtyPlan == null)
  975. {
  976. if (planApplication.RecordStatus == startStatusID)
  977. {
  978. submitIDList.Add(planApplication.PlanApplicationID);
  979. }
  980. else
  981. {
  982. approveIDList.Add(planApplication.PlanApplicationID);
  983. }
  984. success++;
  985. }
  986. else
  987. {
  988. fail++;
  989. }
  990. }
  991. if (submitIDList.Count > 0)
  992. {
  993. this.StartUp(submitIDList, userID, comment);
  994. }
  995. if (approveIDList.Count > 0)
  996. {
  997. this.Approve(approveIDList, userID, Guid.Empty, comment);
  998. }
  999. if (success > 0 && fail <= 0)
  1000. {
  1001. tipMessage = success + "条";
  1002. }
  1003. else
  1004. {
  1005. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业计划信息,请检查。";
  1006. }
  1007. return tipMessage;
  1008. }
  1009. catch (Exception ex)
  1010. {
  1011. throw new Exception(ex.Message);
  1012. }
  1013. }
  1014. /// <summary>
  1015. /// 查询计划申请对应的授课方式List
  1016. /// </summary>
  1017. /// <param name="planApplicationID"></param>
  1018. /// <returns></returns>
  1019. public List<string> GetTeachingModeTypeList(Guid? planApplicationID)
  1020. {
  1021. //计划申请
  1022. Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1023. exp = exp.And(x => x.PlanApplicationID == planApplicationID);
  1024. var query = PlanApplicationDAL.GetTeachingModeTypeQueryble(exp);
  1025. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  1026. }
  1027. /// <summary>
  1028. /// 查询计划申请对应的授课地点List
  1029. /// </summary>
  1030. /// <param name="planApplicationID"></param>
  1031. /// <returns></returns>
  1032. public List<string> GetTeachingPlaceList(Guid? planApplicationID)
  1033. {
  1034. //计划申请
  1035. Expression<Func<EM_PlanApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1036. exp = exp.And(x => x.PlanApplicationID == planApplicationID);
  1037. var query = PlanApplicationDAL.GetTeachingPlaceQueryble(exp);
  1038. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  1039. }
  1040. /// <summary>
  1041. /// 流程结束跳转函数(工作流平台中配置)
  1042. /// 注:此为普教版本(年级专业)
  1043. /// 注:根据不同的版本配置(区分普教、成教版本-工作流跳转函数)
  1044. /// </summary>
  1045. /// <param name="planApplicationIDList"></param>
  1046. /// <param name="userID"></param>
  1047. public void OnApproveEnd(List<Guid> planApplicationIDList, Guid? userID)
  1048. {
  1049. try
  1050. {
  1051. //查询对应的工作流程环节状态信息View
  1052. var approveStatusList = this.GetStatusViewList();
  1053. if (approveStatusList == null || approveStatusList.Count() <= 0)
  1054. {
  1055. throw new Exception("工作流平台中,专业计划流程未配置,请核查。");
  1056. }
  1057. //查询工作流程结束环节状态
  1058. var endStatusID = this.GetCorrectEndStatus();
  1059. if (endStatusID == null)
  1060. {
  1061. throw new Exception("工作流平台中,专业计划流程结束环节未配置,请核查。");
  1062. }
  1063. //查询对应的计划申请信息List
  1064. var planApplicationList = PlanApplicationDAL.PlanApplicationRepository
  1065. .GetList(x => planApplicationIDList.Contains(x.PlanApplicationID),
  1066. (x => x.EM_PlanApplicationTeachingSetting), (x => x.EM_PlanApplicationTeachingModeType),
  1067. (x => x.EM_PlanApplicationTeachingPlace)).ToList();
  1068. //计划申请信息对应的grademajorIDList
  1069. var grademajorIDList = planApplicationList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList();
  1070. //查询对应的专业计划信息
  1071. var specialtyPlanList = PlanApplicationDAL.SpecialtyPlanRepository
  1072. .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
  1073. List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
  1074. List<EM_SpecialtyPlan> newSpecialtyPlanUpList = new List<EM_SpecialtyPlan>();
  1075. List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
  1076. List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyPlanTeachingSetting>();
  1077. List<EM_SpecialtyPlanTeachingModeType> newTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
  1078. List<EM_SpecialtyPlanTeachingPlace> newTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
  1079. List<Guid?> specialtyPlanTMDelList = new List<Guid?>();
  1080. List<Guid?> specialtyPlanTPDelList = new List<Guid?>();
  1081. foreach (var planApplication in planApplicationList)
  1082. {
  1083. //查询对应的专业计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  1084. var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == planApplication.SchoolyearID
  1085. && x.GrademajorID == planApplication.GrademajorID
  1086. && x.CoursematerialID == planApplication.CoursematerialID).SingleOrDefault();
  1087. if (specialtyPlan == null)
  1088. {
  1089. //新增
  1090. var newSpecialtyPlan = new EM_SpecialtyPlan();
  1091. newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
  1092. newSpecialtyPlan.PlanApplicationID = planApplication.PlanApplicationID;
  1093. newSpecialtyPlan.SchoolyearID = planApplication.SchoolyearID;
  1094. newSpecialtyPlan.GrademajorID = planApplication.GrademajorID;
  1095. newSpecialtyPlan.CoursematerialID = planApplication.CoursematerialID;
  1096. newSpecialtyPlan.CourseStructureID = planApplication.CourseStructureID;
  1097. newSpecialtyPlan.CourseCategoryID = planApplication.CourseCategoryID;
  1098. newSpecialtyPlan.CourseTypeID = planApplication.CourseTypeID;
  1099. newSpecialtyPlan.CourseQualityID = planApplication.CourseQualityID;
  1100. newSpecialtyPlan.DepartmentID = planApplication.DepartmentID;
  1101. newSpecialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore;
  1102. newSpecialtyPlan.IsCooperation = planApplication.IsCooperation;
  1103. newSpecialtyPlan.IsRequired = planApplication.IsRequired;
  1104. newSpecialtyPlan.IsElective = planApplication.IsElective;
  1105. newSpecialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse;
  1106. newSpecialtyPlan.IsMainCourse = planApplication.IsMainCourse;
  1107. newSpecialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial;
  1108. newSpecialtyPlan.CourseFineID = planApplication.CourseFineID;
  1109. newSpecialtyPlan.PracticeTypeID = planApplication.PracticeTypeID;
  1110. newSpecialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID;
  1111. newSpecialtyPlan.ExaminationModeID = planApplication.ExaminationModeID;
  1112. newSpecialtyPlan.ResultTypeID = planApplication.ResultTypeID;
  1113. newSpecialtyPlan.HandleModeID = planApplication.HandleModeID;
  1114. newSpecialtyPlan.Remark = planApplication.Remark;
  1115. SetNewStatus(newSpecialtyPlan);
  1116. newSpecialtyPlanInList.Add(newSpecialtyPlan);
  1117. var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  1118. newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1119. if (planApplication.EM_PlanApplicationTeachingSetting != null)
  1120. {
  1121. newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
  1122. newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
  1123. newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
  1124. newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
  1125. newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
  1126. newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
  1127. newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
  1128. newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
  1129. newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
  1130. newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
  1131. newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
  1132. }
  1133. else
  1134. {
  1135. newTeachingSetting.Credit = 0;
  1136. newTeachingSetting.TheoryCourse = 0;
  1137. newTeachingSetting.Practicehours = 0;
  1138. newTeachingSetting.Trialhours = 0;
  1139. newTeachingSetting.TheoryWeeklyNum = 0;
  1140. newTeachingSetting.PracticeWeeklyNum = 0;
  1141. newTeachingSetting.TrialWeeklyNum = 0;
  1142. newTeachingSetting.WeeklyHours = 0;
  1143. newTeachingSetting.WeeklyNum = 0;
  1144. newTeachingSetting.StartWeeklyNum = 1;
  1145. newTeachingSetting.EndWeeklyNum = 16;
  1146. }
  1147. newTeachingSettingInList.Add(newTeachingSetting);
  1148. if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0)
  1149. {
  1150. foreach (var teachingMode in planApplication.EM_PlanApplicationTeachingModeType.ToList())
  1151. {
  1152. var newTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  1153. newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  1154. newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1155. newTeachingMode.TeachingModeID = teachingMode.TeachingModeID;
  1156. SetNewStatus(newTeachingMode);
  1157. newTeachingModeTypeInList.Add(newTeachingMode);
  1158. }
  1159. }
  1160. else
  1161. {
  1162. var newTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  1163. newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  1164. newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1165. newTeachingMode.TeachingModeID = (int)CF_TeachingMode.Theory;
  1166. SetNewStatus(newTeachingMode);
  1167. newTeachingModeTypeInList.Add(newTeachingMode);
  1168. }
  1169. if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0)
  1170. {
  1171. foreach (var teachingPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList())
  1172. {
  1173. var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  1174. newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  1175. newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1176. newTeachingPlace.TeachingPlace = teachingPlace.TeachingPlace;
  1177. SetNewStatus(newTeachingPlace);
  1178. newTeachingPlaceInList.Add(newTeachingPlace);
  1179. }
  1180. }
  1181. }
  1182. else
  1183. {
  1184. //修改
  1185. specialtyPlan.CourseStructureID = planApplication.CourseStructureID;
  1186. specialtyPlan.CourseCategoryID = planApplication.CourseCategoryID;
  1187. specialtyPlan.CourseTypeID = planApplication.CourseTypeID;
  1188. specialtyPlan.CourseQualityID = planApplication.CourseQualityID;
  1189. specialtyPlan.DepartmentID = planApplication.DepartmentID;
  1190. specialtyPlan.IsSpecialtycore = planApplication.IsSpecialtycore;
  1191. specialtyPlan.IsCooperation = planApplication.IsCooperation;
  1192. specialtyPlan.IsRequired = planApplication.IsRequired;
  1193. specialtyPlan.IsElective = planApplication.IsElective;
  1194. specialtyPlan.IsNetworkCourse = planApplication.IsNetworkCourse;
  1195. specialtyPlan.IsMainCourse = planApplication.IsMainCourse;
  1196. specialtyPlan.IsNeedMaterial = planApplication.IsNeedMaterial;
  1197. specialtyPlan.CourseFineID = planApplication.CourseFineID;
  1198. specialtyPlan.PracticeTypeID = planApplication.PracticeTypeID;
  1199. specialtyPlan.TeachinglanguageID = planApplication.TeachinglanguageID;
  1200. specialtyPlan.ExaminationModeID = planApplication.ExaminationModeID;
  1201. specialtyPlan.ResultTypeID = planApplication.ResultTypeID;
  1202. specialtyPlan.HandleModeID = planApplication.HandleModeID;
  1203. specialtyPlan.Remark = planApplication.Remark;
  1204. SetModifyStatus(specialtyPlan);
  1205. newSpecialtyPlanUpList.Add(specialtyPlan);
  1206. if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null)
  1207. {
  1208. var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  1209. newTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  1210. if (planApplication.EM_PlanApplicationTeachingSetting == null)
  1211. {
  1212. newTeachingSetting.Credit = 0;
  1213. newTeachingSetting.TheoryCourse = 0;
  1214. newTeachingSetting.Practicehours = 0;
  1215. newTeachingSetting.Trialhours = 0;
  1216. newTeachingSetting.TheoryWeeklyNum = 0;
  1217. newTeachingSetting.PracticeWeeklyNum = 0;
  1218. newTeachingSetting.TrialWeeklyNum = 0;
  1219. newTeachingSetting.WeeklyHours = 0;
  1220. newTeachingSetting.WeeklyNum = 0;
  1221. newTeachingSetting.StartWeeklyNum = 1;
  1222. newTeachingSetting.EndWeeklyNum = 16;
  1223. }
  1224. else
  1225. {
  1226. newTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
  1227. newTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
  1228. newTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
  1229. newTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
  1230. newTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
  1231. newTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
  1232. newTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
  1233. newTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
  1234. newTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
  1235. newTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
  1236. newTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
  1237. }
  1238. newTeachingSettingInList.Add(newTeachingSetting);
  1239. }
  1240. else
  1241. {
  1242. if (planApplication.EM_PlanApplicationTeachingSetting != null)
  1243. {
  1244. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = planApplication.EM_PlanApplicationTeachingSetting.Credit;
  1245. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = planApplication.EM_PlanApplicationTeachingSetting.TheoryCourse;
  1246. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = planApplication.EM_PlanApplicationTeachingSetting.Practicehours;
  1247. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = planApplication.EM_PlanApplicationTeachingSetting.Trialhours;
  1248. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TheoryWeeklyNum;
  1249. specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.PracticeWeeklyNum;
  1250. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.TrialWeeklyNum;
  1251. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = planApplication.EM_PlanApplicationTeachingSetting.WeeklyHours;
  1252. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.WeeklyNum;
  1253. specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.StartWeeklyNum;
  1254. specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = planApplication.EM_PlanApplicationTeachingSetting.EndWeeklyNum;
  1255. }
  1256. newTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting);
  1257. }
  1258. if (planApplication.EM_PlanApplicationTeachingModeType != null && planApplication.EM_PlanApplicationTeachingModeType.Count() > 0)
  1259. {
  1260. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  1261. foreach (var newModeType in planApplication.EM_PlanApplicationTeachingModeType.ToList())
  1262. {
  1263. var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType();
  1264. newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  1265. newTeachingModeType.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  1266. newTeachingModeType.TeachingModeID = newModeType.TeachingModeID;
  1267. this.SetNewStatus(newTeachingModeType);
  1268. newTeachingModeTypeInList.Add(newTeachingModeType);
  1269. }
  1270. }
  1271. else
  1272. {
  1273. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  1274. }
  1275. if (planApplication.EM_PlanApplicationTeachingPlace != null && planApplication.EM_PlanApplicationTeachingPlace.Count() > 0)
  1276. {
  1277. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  1278. foreach (var newPlace in planApplication.EM_PlanApplicationTeachingPlace.ToList())
  1279. {
  1280. var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  1281. newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  1282. newTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  1283. newTeachingPlace.TeachingPlace = newPlace.TeachingPlace;
  1284. this.SetNewStatus(newTeachingPlace);
  1285. newTeachingPlaceInList.Add(newTeachingPlace);
  1286. }
  1287. }
  1288. else
  1289. {
  1290. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  1291. }
  1292. }
  1293. }
  1294. using (TransactionScope ts = new TransactionScope())
  1295. {
  1296. //删除
  1297. UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID));
  1298. UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID));
  1299. //批量插入
  1300. UnitOfWork.BulkInsert(newSpecialtyPlanInList);
  1301. UnitOfWork.BulkInsert(newTeachingSettingInList);
  1302. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  1303. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  1304. //批量统一提交更新
  1305. if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0)
  1306. {
  1307. UnitOfWork.BatchUpdate(newSpecialtyPlanUpList);
  1308. }
  1309. //批量统一提交更新
  1310. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  1311. {
  1312. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  1313. }
  1314. ts.Complete();
  1315. }
  1316. }
  1317. catch (Exception)
  1318. {
  1319. throw;
  1320. }
  1321. }
  1322. }
  1323. }