GrademajorServices.cs 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.Specialtyclass;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.Specialtyclass;
  8. using EMIS.Entities;
  9. using EMIS.DataLogic.Common.CalendarManage;
  10. using EMIS.ViewModel.Students;
  11. using EMIS.ViewModel;
  12. using System.Linq.Expressions;
  13. using Bowin.Common.Linq;
  14. using EMIS.CommonLogic.Students;
  15. using EMIS.ViewModel.UniversityInformationManage.Specialtyclass;
  16. using Bowin.Common.Utility;
  17. using System.Text.RegularExpressions;
  18. using EMIS.ViewModel.Cache;
  19. namespace EMIS.CommonLogic.Specialtyclass
  20. {
  21. public class GrademajorServices : BaseServices, IGrademajorServices
  22. {
  23. public GrademajorDAL GrademajorDAL { get; set; }
  24. /// <summary>
  25. /// 查询年级专业对应的标准专业信息
  26. /// </summary>
  27. /// <param name="configuretView"></param>
  28. /// <param name="campusID"></param>
  29. /// <param name="collegeID"></param>
  30. /// <param name="schoolyearID"></param>
  31. /// <param name="standardID"></param>
  32. /// <param name="educationID"></param>
  33. /// <param name="learningformID"></param>
  34. /// <param name="learnSystem"></param>
  35. /// <param name="inSchoolStatus"></param>
  36. /// <param name="pageIndex"></param>
  37. /// <param name="pageSize"></param>
  38. /// <returns></returns>
  39. public IGridResultSet<StandardView> GetGradeStandardViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  40. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  41. int? inSchoolStatus, int pageIndex, int pageSize)
  42. {
  43. //年级专业信息
  44. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  45. if (schoolyearID.HasValue)
  46. {
  47. //年级
  48. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  49. }
  50. //学生信息
  51. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  52. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor, expStudent);
  53. if (schoolAreaID.HasValue)
  54. {
  55. //校区
  56. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  57. }
  58. if (collegeID.HasValue)
  59. {
  60. //院系所
  61. query = query.Where(x => x.CollegeID == collegeID);
  62. }
  63. if (standardID.HasValue)
  64. {
  65. //专业ID(Value)
  66. query = query.Where(x => x.StandardID == standardID);
  67. }
  68. if (educationID.HasValue)
  69. {
  70. //培养层次
  71. query = query.Where(x => x.EducationID == educationID);
  72. }
  73. if (learningformID.HasValue)
  74. {
  75. //学习形式
  76. query = query.Where(x => x.LearningformID == learningformID);
  77. }
  78. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  79. {
  80. //学制
  81. var LearnSystems = Convert.ToDecimal(learnSystem);
  82. query = query.Where(x => x.LearnSystem == LearnSystems);
  83. }
  84. //if (inSchoolStatus != null && inSchoolStatus > -1)
  85. //{
  86. // //排除人数为0的信息
  87. // query = query.Where(x => x.StudentCount > 0);
  88. //}
  89. //查询条件
  90. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  91. {
  92. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  93. }
  94. return this.GetQueryByDataRangeByCollege(query)
  95. .GroupBy(x => new
  96. {
  97. x.StandardID
  98. }).Select(x => new StandardView { StandardID = x.Key.StandardID }).OrderBy(x => x.StandardID)
  99. .ToGridResultSet(pageIndex, pageSize);
  100. }
  101. /// <summary>
  102. /// 通过年级专业查询对应的标准专业
  103. /// </summary>
  104. /// <param name="configuretView"></param>
  105. /// <param name="schoolAreaID"></param>
  106. /// <param name="collegeID"></param>
  107. /// <param name="schoolyearID"></param>
  108. /// <param name="standardID"></param>
  109. /// <param name="educationID"></param>
  110. /// <param name="learningformID"></param>
  111. /// <param name="learnSystem"></param>
  112. /// <param name="inSchoolStatus"></param>
  113. /// <param name="pageIndex"></param>
  114. /// <param name="pageSize"></param>
  115. /// <returns></returns>
  116. public IGridResultSet<ExamProjectControlView> GetSchoolyearStandardViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  117. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  118. int? inSchoolStatus, int pageIndex, int pageSize)
  119. {
  120. //年级专业信息
  121. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  122. if (schoolyearID.HasValue)
  123. {
  124. //年级
  125. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  126. }
  127. //学生信息
  128. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  129. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor, expStudent);
  130. if (schoolAreaID.HasValue)
  131. {
  132. //校区
  133. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  134. }
  135. if (collegeID.HasValue)
  136. {
  137. //院系所
  138. query = query.Where(x => x.CollegeID == collegeID);
  139. }
  140. if (standardID.HasValue)
  141. {
  142. //专业ID(Value)
  143. query = query.Where(x => x.StandardID == standardID);
  144. }
  145. if (educationID.HasValue)
  146. {
  147. //培养层次
  148. query = query.Where(x => x.EducationID == educationID);
  149. }
  150. if (learningformID.HasValue)
  151. {
  152. //学习形式
  153. query = query.Where(x => x.LearningformID == learningformID);
  154. }
  155. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  156. {
  157. //学制
  158. var LearnSystems = Convert.ToDecimal(learnSystem);
  159. query = query.Where(x => x.LearnSystem == LearnSystems);
  160. }
  161. //if (inSchoolStatus != null && inSchoolStatus > -1)
  162. //{
  163. // //排除人数为0的信息
  164. // query = query.Where(x => x.StudentCount > 0);
  165. //}
  166. //查询条件
  167. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  168. {
  169. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  170. }
  171. return this.GetQueryByDataRangeByCollege(query)
  172. .GroupBy(x => new
  173. {
  174. x.CollegeCode,
  175. x.CollegeID,
  176. x.SchoolyearID,
  177. x.StandardID,
  178. x.CollegeName
  179. }).Select(x => new ExamProjectControlView
  180. {
  181. CollegeCode = x.Key.CollegeCode,
  182. CollegeID = x.Key.CollegeID,
  183. SchoolyearID = x.Key.SchoolyearID,
  184. StandardID = x.Key.StandardID,
  185. CollegeName = x.Key.CollegeName
  186. }).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  187. .ThenBy(x => x.StandardID)
  188. .ToGridResultSet<ExamProjectControlView>(pageIndex, pageSize);
  189. }
  190. /// <summary>
  191. /// 查询对应的年级专业信息GrademajorView
  192. /// </summary>
  193. /// <param name="configuretView"></param>
  194. /// <param name="campusID"></param>
  195. /// <param name="collegeID"></param>
  196. /// <param name="schoolyearID"></param>
  197. /// <param name="standardID"></param>
  198. /// <param name="educationID"></param>
  199. /// <param name="learningformID"></param>
  200. /// <param name="learnSystem"></param>
  201. /// <param name="inSchoolStatus"></param>
  202. /// <param name="pageIndex"></param>
  203. /// <param name="pageSize"></param>
  204. /// <returns></returns>
  205. public IGridResultSet<GrademajorView> GetGrademajorViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  206. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  207. int? inSchoolStatus, int pageIndex, int pageSize)
  208. {
  209. //年级专业信息
  210. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  211. if (schoolyearID.HasValue)
  212. {
  213. //年级
  214. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  215. }
  216. //学生信息
  217. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  218. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor, expStudent);
  219. if (schoolAreaID.HasValue)
  220. {
  221. //校区
  222. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  223. }
  224. if (collegeID.HasValue)
  225. {
  226. //院系所
  227. query = query.Where(x => x.CollegeID == collegeID);
  228. }
  229. if (standardID.HasValue)
  230. {
  231. //专业ID(Value)
  232. query = query.Where(x => x.StandardID == standardID);
  233. }
  234. if (educationID.HasValue)
  235. {
  236. //培养层次
  237. query = query.Where(x => x.EducationID == educationID);
  238. }
  239. if (learningformID.HasValue)
  240. {
  241. //学习形式
  242. query = query.Where(x => x.LearningformID == learningformID);
  243. }
  244. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  245. {
  246. //学制
  247. var LearnSystems = Convert.ToDecimal(learnSystem);
  248. query = query.Where(x => x.LearnSystem == LearnSystems);
  249. }
  250. //if (inSchoolStatus != null && inSchoolStatus > -1)
  251. //{
  252. // //排除人数为0的信息
  253. // query = query.Where(x => x.StudentCount > 0);
  254. //}
  255. //查询条件
  256. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  257. {
  258. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  259. }
  260. return this.GetQueryByDataRangeByCollege(query)
  261. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  262. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  263. .ToGridResultSet<GrademajorView>(pageIndex, pageSize);
  264. }
  265. /// <summary>
  266. /// 查询对应的年级专业信息List
  267. /// </summary>
  268. /// <param name="configuretView"></param>
  269. /// <param name="campusID"></param>
  270. /// <param name="collegeID"></param>
  271. /// <param name="schoolyearID"></param>
  272. /// <param name="standardID"></param>
  273. /// <param name="educationID"></param>
  274. /// <param name="learningformID"></param>
  275. /// <param name="learnSystem"></param>
  276. /// <param name="inSchoolStatus"></param>
  277. /// <returns></returns>
  278. public IList<GrademajorView> GetGrademajorViewList(ConfiguretView configuretView, int? schoolAreaID,
  279. Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID,
  280. string learnSystem, int? inSchoolStatus)
  281. {
  282. //年级专业信息
  283. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  284. if (schoolyearID.HasValue)
  285. {
  286. //年级
  287. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  288. }
  289. //学生信息
  290. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  291. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor, expStudent);
  292. if (schoolAreaID.HasValue)
  293. {
  294. //校区
  295. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  296. }
  297. if (collegeID.HasValue)
  298. {
  299. //院系所
  300. query = query.Where(x => x.CollegeID == collegeID);
  301. }
  302. if (standardID.HasValue)
  303. {
  304. //专业ID(Value)
  305. query = query.Where(x => x.StandardID == standardID);
  306. }
  307. if (educationID.HasValue)
  308. {
  309. //培养层次
  310. query = query.Where(x => x.EducationID == educationID);
  311. }
  312. if (learningformID.HasValue)
  313. {
  314. //学习形式
  315. query = query.Where(x => x.LearningformID == learningformID);
  316. }
  317. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  318. {
  319. //学制
  320. var LearnSystems = Convert.ToDecimal(learnSystem);
  321. query = query.Where(x => x.LearnSystem == LearnSystems);
  322. }
  323. //if (inSchoolStatus != null && inSchoolStatus > -1)
  324. //{
  325. // //排除人数为0的信息
  326. // query = query.Where(x => x.StudentCount > 0);
  327. //}
  328. //查询条件
  329. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  330. {
  331. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  332. }
  333. return this.GetQueryByDataRangeByCollege(query)
  334. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  335. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  336. .ToList();
  337. }
  338. /// <summary>
  339. /// 查询对应的年级专业信息GrademajorView(无数据范围)
  340. /// </summary>
  341. /// <param name="configuretView"></param>
  342. /// <param name="campusID"></param>
  343. /// <param name="collegeID"></param>
  344. /// <param name="schoolyearID"></param>
  345. /// <param name="standardID"></param>
  346. /// <param name="educationID"></param>
  347. /// <param name="learningformID"></param>
  348. /// <param name="learnSystem"></param>
  349. /// <param name="pageIndex"></param>
  350. /// <param name="pageSize"></param>
  351. /// <returns></returns>
  352. public IGridResultSet<GrademajorView> GetGrademajorViewGridWithoutRange(ConfiguretView configuretView, int? schoolAreaID,
  353. Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID,
  354. string learnSystem, int pageIndex, int pageSize)
  355. {
  356. //年级专业信息
  357. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  358. if (schoolyearID.HasValue)
  359. {
  360. //年级
  361. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  362. }
  363. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor);
  364. if (schoolAreaID.HasValue)
  365. {
  366. //校区
  367. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  368. }
  369. if (collegeID.HasValue)
  370. {
  371. //院系所
  372. query = query.Where(x => x.CollegeID == collegeID);
  373. }
  374. if (standardID.HasValue)
  375. {
  376. //专业ID(Value)
  377. query = query.Where(x => x.StandardID == standardID);
  378. }
  379. if (educationID.HasValue)
  380. {
  381. //培养层次
  382. query = query.Where(x => x.EducationID == educationID);
  383. }
  384. if (learningformID.HasValue)
  385. {
  386. //学习形式
  387. query = query.Where(x => x.LearningformID == learningformID);
  388. }
  389. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  390. {
  391. //学制
  392. var LearnSystems = Convert.ToDecimal(learnSystem);
  393. query = query.Where(x => x.LearnSystem == LearnSystems);
  394. }
  395. //查询条件
  396. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  397. {
  398. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  399. }
  400. return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  401. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  402. .ToGridResultSet<GrademajorView>(pageIndex, pageSize);
  403. }
  404. /// <summary>
  405. /// 查询对应的年级专业信息List(带数据范围)
  406. /// </summary>
  407. /// <param name="configuretView"></param>
  408. /// <param name="collegeID"></param>
  409. /// <param name="schoolyearID"></param>
  410. /// <returns></returns>
  411. public IList<GrademajorView> GetGrademajorViewList(ConfiguretView configuretView, Guid? collegeID, int? schoolyearID)
  412. {
  413. //年级专业信息
  414. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  415. if (schoolyearID.HasValue)
  416. {
  417. //年级
  418. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  419. }
  420. var query = GrademajorDAL.GetGrademajorViwQueryable(expGrademajor);
  421. //if (campusID.HasValue)
  422. //{
  423. // //校区
  424. // query = query.Where(x => x.CampusID == campusID);
  425. //}
  426. if (collegeID.HasValue)
  427. {
  428. //院系所
  429. query = query.Where(x => x.CollegeID == collegeID);
  430. }
  431. //if (standardID.HasValue)
  432. //{
  433. // //专业ID(Value)
  434. // query = query.Where(x => x.StandardID == standardID);
  435. //}
  436. //if (educationID.HasValue)
  437. //{
  438. // //培养层次
  439. // query = query.Where(x => x.EducationID == educationID);
  440. //}
  441. //if (learningformID.HasValue)
  442. //{
  443. // //学习形式
  444. // query = query.Where(x => x.LearningformID == learningformID);
  445. //}
  446. //if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  447. //{
  448. // //学制
  449. // var LearnSystems = Convert.ToDecimal(learnSystem);
  450. // query = query.Where(x => x.LearnSystem == LearnSystems);
  451. //}
  452. //查询条件
  453. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  454. {
  455. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  456. }
  457. return this.GetQueryByDataRangeByCollege(query)
  458. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  459. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  460. .ToList();
  461. }
  462. /// <summary>
  463. /// 查询年级专业中的专业信息StandardView(无数据范围)
  464. /// </summary>
  465. /// <param name="configuretView"></param>
  466. /// <param name="collegeID"></param>
  467. /// <param name="schoolyearID"></param>
  468. /// <param name="pageIndex"></param>
  469. /// <param name="pageSize"></param>
  470. /// <returns></returns>
  471. public IGridResultSet<StandardView> GetStandardViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  472. int? schoolyearID, int pageIndex, int pageSize)
  473. {
  474. //年级专业信息
  475. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  476. if (schoolAreaID.HasValue)
  477. {
  478. //院系所
  479. expGrademajor = expGrademajor.And(x => x.SchoolAreaID == schoolAreaID);
  480. }
  481. if (collegeID.HasValue)
  482. {
  483. //院系所
  484. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  485. }
  486. if (schoolyearID.HasValue)
  487. {
  488. //年级
  489. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  490. }
  491. var query = GrademajorDAL.GetStandardForComboGridQueryable(expGrademajor);
  492. //查询条件
  493. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  494. {
  495. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  496. }
  497. return query.OrderBy(x => x.StandardID)
  498. .ToGridResultSet<StandardView>(pageIndex, pageSize);
  499. }
  500. /// <summary>
  501. /// 查询年级专业中的专业信息List(无数据范围)
  502. /// </summary>
  503. /// <param name="configuretView"></param>
  504. /// <param name="collegeID"></param>
  505. /// <param name="schoolyearID"></param>
  506. /// <returns></returns>
  507. public IList<StandardView> GetStandardViewList(ConfiguretView configuretView, Guid? collegeID, int? schoolyearID)
  508. {
  509. //年级专业信息
  510. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  511. if (collegeID.HasValue)
  512. {
  513. //院系所
  514. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  515. }
  516. if (schoolyearID.HasValue)
  517. {
  518. //年级
  519. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  520. }
  521. var query = GrademajorDAL.GetStandardForComboGridQueryable(expGrademajor);
  522. //查询条件
  523. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  524. {
  525. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  526. }
  527. return query.OrderBy(x => x.StandardID)
  528. .ToList();
  529. }
  530. /// <summary>
  531. /// 查询年级专业中的专业信息List(无数据范围)
  532. /// </summary>
  533. /// <param name="configuretView"></param>
  534. /// <param name="collegeID"></param>
  535. /// <param name="schoolyearID"></param>
  536. /// <returns></returns>
  537. public IList<GrademajorView> GetStandardQueryableExcludeNotHaveStudentList(ConfiguretView configuretView, Guid? collegeID, int? schoolyearID)
  538. {
  539. //年级专业信息
  540. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  541. if (collegeID.HasValue)
  542. {
  543. //院系所
  544. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  545. }
  546. if (schoolyearID.HasValue)
  547. {
  548. //年级
  549. expGrademajor = expGrademajor.And(x => x.SchoolyearID == schoolyearID);
  550. }
  551. //学生信息
  552. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  553. var query = GrademajorDAL.GetStandardQueryableExcludeNotHaveStudent(expGrademajor, expStudent);
  554. //查询条件
  555. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  556. {
  557. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  558. }
  559. return query.OrderBy(x => x.StandardID)
  560. .ToList();
  561. }
  562. /// <summary>
  563. /// 查询年级专业中的年级信息SchoolyearView(无数据范围)
  564. /// </summary>
  565. /// <param name="configuretView"></param>
  566. /// <param name="collegeID"></param>
  567. /// <param name="standardID"></param>
  568. /// <param name="pageIndex"></param>
  569. /// <param name="pageSize"></param>
  570. /// <returns></returns>
  571. public IGridResultSet<SchoolyearView> GetSchoolyearViewGrid(ConfiguretView configuretView,
  572. Guid? collegeID, int? standardID, int pageIndex, int pageSize)
  573. {
  574. //年级专业信息
  575. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  576. if (collegeID.HasValue)
  577. {
  578. //院系所
  579. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  580. }
  581. if (standardID.HasValue)
  582. {
  583. //专业ID(Value)
  584. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.StandardID == standardID);
  585. }
  586. var query = GrademajorDAL.GetSchoolyearForComboGridQueryable(expGrademajor);
  587. //查询条件
  588. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  589. {
  590. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  591. }
  592. return query.OrderBy(x => x.SchoolyearID)
  593. .ToGridResultSet<SchoolyearView>(pageIndex, pageSize);
  594. }
  595. /// <summary>
  596. /// 查询年级专业中的年级信息List(无数据范围)
  597. /// </summary>
  598. /// <param name="configuretView"></param>
  599. /// <param name="collegeID"></param>
  600. /// <param name="standardID"></param>
  601. /// <returns></returns>
  602. public IList<SchoolyearView> GetSchoolyearViewGrid(ConfiguretView configuretView,
  603. Guid? collegeID, int? standardID)
  604. {
  605. //年级专业信息
  606. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  607. if (collegeID.HasValue)
  608. {
  609. //院系所
  610. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  611. }
  612. if (standardID.HasValue)
  613. {
  614. //专业ID(Value)
  615. expGrademajor = expGrademajor.And(x => x.CF_Facultymajor.StandardID == standardID);
  616. }
  617. var query = GrademajorDAL.GetSchoolyearForComboGridQueryable(expGrademajor);
  618. //查询条件
  619. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  620. {
  621. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  622. }
  623. return query.OrderBy(x => x.SchoolyearID)
  624. .ToList();
  625. }
  626. /// <summary>
  627. /// 查询对应的年级专业信息CF_Grademajor
  628. /// </summary>
  629. /// <param name="grademajorID"></param>
  630. /// <returns></returns>
  631. public CF_Grademajor GetGrademajorInfo(Guid? grademajorID)
  632. {
  633. try
  634. {
  635. var query = GrademajorDAL.GrademajorRepository.GetList(x => x.GrademajorID == grademajorID);
  636. return query.SingleOrDefault();
  637. }
  638. catch (Exception ex)
  639. {
  640. throw new Exception(ex.Message);
  641. }
  642. }
  643. /// <summary>
  644. /// 查询对应的年级专业信息GrademajorView
  645. /// </summary>
  646. /// <param name="grademajorID"></param>
  647. /// <returns></returns>
  648. public GrademajorView GetGrademajorView(Guid? grademajorID)
  649. {
  650. try
  651. {
  652. var query = GrademajorDAL.GetGrademajorViwQueryable(x => x.GrademajorID == grademajorID);
  653. return query.SingleOrDefault();
  654. }
  655. catch (Exception ex)
  656. {
  657. throw new Exception(ex.Message);
  658. }
  659. }
  660. /// <summary>
  661. /// 编辑(新增、修改,业务主键:年级专业编号或年级专业名称唯一)
  662. /// </summary>
  663. /// <param name="grademajorView"></param>
  664. public void GrademajorEdit(GrademajorView grademajorView)
  665. {
  666. try
  667. {
  668. //查询数据库进行验证
  669. var grademajorVerification = GrademajorDAL.GrademajorRepository
  670. .GetList(x => x.GrademajorID != grademajorView.GrademajorID
  671. && (x.Code == grademajorView.Code
  672. || x.Name == grademajorView.Name))
  673. .FirstOrDefault();
  674. if (grademajorVerification == null)
  675. {
  676. //计算相应的毕业学年学期Value 岭南不需要预计毕业学年学期
  677. //var facultymajor = GrademajorDAL.FacultymajorRepository
  678. // .GetSingle(x => x.FacultymajorID == grademajorView.FacultymajorID);
  679. //var graduateSchoolyearValue = (grademajorView.SchoolyearID.Value * 2) - 1
  680. // + (grademajorView.SchoolcodeID.Value - 1);
  681. //graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(facultymajor.LearnSystem.Value * 2 - 1));
  682. //var graduatingSemester = GrademajorDAL.SchoolyearRepository
  683. // .GetSingle(x => x.Value == graduateSchoolyearValue);
  684. //if (graduatingSemester == null)
  685. //{
  686. // throw new Exception("预计毕业学年学期超出了系统学年学期数据的范围,请添加足够的学年学期记录以支撑该操作。");
  687. //}
  688. //数据有误验证
  689. if (grademajorView.GrademajorID != Guid.Empty)
  690. {
  691. var grademajor = GrademajorDAL.GrademajorRepository
  692. .GetList(x => x.GrademajorID == grademajorView.GrademajorID)
  693. .SingleOrDefault();
  694. if (grademajor == null)
  695. {
  696. throw new Exception("数据有误,请核查");
  697. }
  698. else
  699. {
  700. //表示修改(暂时不考虑对应的班级信息下的学生拟毕业日期的更新,后续再处理)
  701. //目前通过修改对应的班级信息来更新
  702. grademajor.FacultymajorID = grademajorView.FacultymajorID;
  703. grademajor.Code = grademajorView.Code.Trim();
  704. grademajor.Name = grademajorView.Name;
  705. grademajor.Abbreviation = grademajorView.Abbreviation;
  706. grademajor.SchoolyearID = grademajorView.SchoolyearID;
  707. grademajor.SchoolcodeID = grademajorView.SchoolcodeID;
  708. //grademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  709. grademajor.Professional = grademajorView.Professional;
  710. grademajor.SchoolAreaID = grademajorView.SchoolAreaID;
  711. grademajor.Remark = grademajorView.Remark;
  712. SetModifyStatus(grademajor);
  713. }
  714. }
  715. else
  716. {
  717. //表示新增
  718. CF_Grademajor grademajor = new CF_Grademajor();
  719. grademajor.GrademajorID = Guid.NewGuid();
  720. grademajor.FacultymajorID = grademajorView.FacultymajorID;
  721. grademajor.Code = grademajorView.Code.Trim();
  722. grademajor.Name = grademajorView.Name;
  723. grademajor.Abbreviation = grademajorView.Abbreviation;
  724. grademajor.SchoolyearID = grademajorView.SchoolyearID;
  725. grademajor.SchoolcodeID = grademajorView.SchoolcodeID;
  726. //grademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  727. grademajor.Professional = grademajorView.Professional;
  728. grademajor.SchoolAreaID = grademajorView.SchoolAreaID;
  729. grademajor.Remark = grademajorView.Remark;
  730. SetNewStatus(grademajor);
  731. UnitOfWork.Add(grademajor);
  732. }
  733. }
  734. else
  735. {
  736. throw new Exception("已存在相同的年级专业编号或年级专业名称,请核查");
  737. }
  738. //事务提交
  739. UnitOfWork.Commit();
  740. }
  741. catch (Exception ex)
  742. {
  743. throw new Exception(ex.Message);
  744. }
  745. }
  746. /// <summary>
  747. /// 批量新增
  748. /// </summary>
  749. /// <param name="grademajorView"></param>
  750. /// <returns></returns>
  751. public int GrademajorBatchAdd(GrademajorView grademajorView)
  752. {
  753. try
  754. {
  755. List<CF_Grademajor> grade = new List<CF_Grademajor>();
  756. //获取源数据
  757. var Grademajor = GrademajorDAL.GetGrademajorViwQueryable(x => x.SchoolyearID == grademajorView.SchoolyearID);
  758. if (grademajorView.CollegeID != null)
  759. {
  760. Grademajor = Grademajor.Where(x => x.CollegeID == grademajorView.CollegeID);
  761. }
  762. if (grademajorView.StandardID != null && grademajorView.StandardID != -1)
  763. {
  764. Grademajor = Grademajor.Where(x => x.StandardID == grademajorView.StandardID);
  765. }
  766. //获取年级专业
  767. var GrademajorList = Grademajor.ToList();
  768. //获取学年学期
  769. var SchoolYearList = GrademajorDAL.SchoolyearRepository.GetList(x => x.RecordStatus == (int)SYS_STATUS.USABLE).ToList();
  770. //获取院系专业
  771. var FacultymajorIDList = GrademajorList.Select(x => x.FacultymajorID).ToList();
  772. var Facultymajorlist = GrademajorDAL.FacultymajorRepository.GetList(x => FacultymajorIDList.Contains(x.FacultymajorID)).ToList();
  773. //获取目标年级已存在数据
  774. var BatchGrademajor = GrademajorDAL.GetGrademajorViwQueryable(x => x.SchoolyearID == grademajorView.BatchSchoolyearID);
  775. if (grademajorView.CollegeID != null)
  776. {
  777. BatchGrademajor = BatchGrademajor.Where(x => x.CollegeID == grademajorView.CollegeID);
  778. }
  779. if (grademajorView.StandardID != null && grademajorView.StandardID != -1)
  780. {
  781. BatchGrademajor = BatchGrademajor.Where(x => x.StandardID == grademajorView.StandardID);
  782. }
  783. var BatchGrademajorList = BatchGrademajor.ToList();
  784. //插入数据
  785. foreach (var g in GrademajorList)
  786. {
  787. CF_Facultymajor facultymajor = new CF_Facultymajor();
  788. facultymajor = Facultymajorlist.Where(x => x.FacultymajorID == g.FacultymajorID).FirstOrDefault();
  789. var graduateSchoolyearValue = (grademajorView.BatchSchoolyearID.Value * 2) - 1 + (g.SchoolcodeID.Value - 1);
  790. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(facultymajor.LearnSystem.Value * 2 - 1));
  791. var graduatingSemester = SchoolYearList.Where(x => x.Value == graduateSchoolyearValue).FirstOrDefault();
  792. CF_Grademajor grademajor = new CF_Grademajor();
  793. if (graduatingSemester == null)
  794. {
  795. throw new Exception("预计毕业学年学期超出了系统学年学期数据的范围,请添加足够的学年学期记录以支撑该操作。");
  796. }
  797. string Schoolyear = g.SchoolyearID.ToString();
  798. string BatchSchoolyear = grademajorView.BatchSchoolyearID.Value.ToString();
  799. //替换复制的年级专业代码
  800. string Code = g.Code.Trim().Replace(Schoolyear, BatchSchoolyear);
  801. //替换复制的年级专业名称
  802. string Name = g.Name.Trim().Replace(Schoolyear, BatchSchoolyear);
  803. //替换复制的年级专业简称
  804. string Abbreviation = g.Abbreviation;
  805. if (g.Abbreviation != null)
  806. {
  807. Abbreviation = g.Abbreviation.Trim().Replace(Schoolyear, BatchSchoolyear);
  808. }
  809. grademajor.GrademajorID = Guid.NewGuid();
  810. grademajor.Code = Code;
  811. grademajor.Name = Name;
  812. grademajor.Abbreviation = Abbreviation;
  813. grademajor.SchoolyearID = grademajorView.BatchSchoolyearID;
  814. grademajor.Professional = g.Professional;
  815. grademajor.SchoolcodeID = g.SchoolcodeID;
  816. grademajor.FacultymajorID = g.FacultymajorID;
  817. grademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  818. grademajor.SchoolAreaID = g.SchoolAreaID;
  819. grademajor.Remark = g.Remark;
  820. SetNewStatus(grademajor);
  821. if (!grademajorView.IsOverwrite)
  822. {
  823. var batch = BatchGrademajorList.Where(x => x.Code == Code && x.SchoolyearID == grademajorView.BatchSchoolyearID && x.FacultymajorID == g.FacultymajorID).FirstOrDefault();
  824. if (batch == null)
  825. {
  826. grade.Add(grademajor);
  827. }
  828. }
  829. else
  830. {
  831. var BatchGrademajorIDList = BatchGrademajorList.Select(x => x.GrademajorID).ToList();
  832. List<Guid> ids = new List<Guid>();
  833. if (BatchGrademajorIDList.Count > 0)
  834. {
  835. foreach (var id in BatchGrademajorIDList)
  836. {
  837. ids.Add(id);
  838. }
  839. UnitOfWork.Remove<CF_Grademajor>(x => ids.Contains(x.GrademajorID));
  840. }
  841. grade.Add(grademajor);
  842. }
  843. }
  844. UnitOfWork.BulkInsert(grade);
  845. UnitOfWork.Commit();
  846. return grade.Count();
  847. }
  848. catch (Exception ex)
  849. {
  850. throw new Exception(ex.Message);
  851. }
  852. }
  853. /// <summary>
  854. /// 删除
  855. /// </summary>
  856. /// <param name="grademajorIDList"></param>
  857. /// <returns></returns>
  858. public bool GrademajorDelete(List<Guid?> grademajorIDList)
  859. {
  860. try
  861. {
  862. if (grademajorIDList.Count > 0)
  863. {
  864. UnitOfWork.Delete<CF_Grademajor>(x => grademajorIDList.Contains(x.GrademajorID));
  865. }
  866. return true;
  867. }
  868. catch (Exception)
  869. {
  870. throw;
  871. }
  872. }
  873. /// <summary>
  874. /// 查询年级专业对应的班级信息ClassmajorView(带对应的在校状态学生人数)
  875. /// </summary>
  876. /// <param name="configuretView"></param>
  877. /// <param name="grademajorID"></param>
  878. /// <param name="inSchoolStatus"></param>
  879. /// <param name="pageIndex"></param>
  880. /// <param name="pageSize"></param>
  881. /// <returns></returns>
  882. public IGridResultSet<ClassmajorView> GetClassmajorViewGrid(ConfiguretView configuretView, Guid? grademajorID,
  883. int? inSchoolStatus, int pageIndex, int pageSize)
  884. {
  885. //年级专业信息
  886. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  887. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  888. //学生信息
  889. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  890. var query = GrademajorDAL.GetClassmajorViewQueryable(expGrademajor, expStudent);
  891. //if (inSchoolStatus != null && inSchoolStatus > -1)
  892. //{
  893. // //排除人数为0的信息
  894. // query = query.Where(x => x.StudentCount > 0);
  895. //}
  896. //查询条件
  897. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  898. {
  899. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  900. }
  901. return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  902. .ThenBy(x => x.StandardID).ThenBy(x => x.No.Length)
  903. .ThenBy(x => x.No).ThenBy(x => x.ClassNum)
  904. .ToGridResultSet<ClassmajorView>(pageIndex, pageSize);
  905. }
  906. /// <summary>
  907. /// 查询年级专业对应的班级信息List(带对应的在校状态学生人数)
  908. /// </summary>
  909. /// <param name="configuretView"></param>
  910. /// <param name="grademajorID"></param>
  911. /// <param name="inSchoolStatus"></param>
  912. /// <returns></returns>
  913. public IList<ClassmajorView> GetClassmajorViewList(ConfiguretView configuretView, Guid? grademajorID, int? inSchoolStatus)
  914. {
  915. //年级专业信息
  916. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  917. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  918. //学生信息
  919. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  920. var query = GrademajorDAL.GetClassmajorViewQueryable(expGrademajor, expStudent);
  921. //if (inSchoolStatus != null && inSchoolStatus > -1)
  922. //{
  923. // //排除人数为0的信息
  924. // query = query.Where(x => x.StudentCount > 0);
  925. //}
  926. //查询条件
  927. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  928. {
  929. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  930. }
  931. return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  932. .ThenBy(x => x.StandardID).ThenBy(x => x.No.Length)
  933. .ThenBy(x => x.No).ThenBy(x => x.ClassNum)
  934. .ToList();
  935. }
  936. /// <summary>
  937. /// 查询年级专业对应的学生信息BaseStudentView
  938. /// </summary>
  939. /// <param name="configuretView"></param>
  940. /// <param name="grademajorID"></param>
  941. /// <param name="inSchoolStatus"></param>
  942. /// <param name="pageIndex"></param>
  943. /// <param name="pageSize"></param>
  944. /// <returns></returns>
  945. public IGridResultSet<BaseStudentView> GetBaseStudentViewGrid(ConfiguretView configuretView, Guid? grademajorID,
  946. int? inSchoolStatus, int pageIndex, int pageSize)
  947. {
  948. //年级专业信息
  949. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  950. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  951. //学生信息
  952. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  953. var query = GrademajorDAL.GetBaseStudentViewQueryable(expGrademajor, expStudent);
  954. //查询条件
  955. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  956. {
  957. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  958. }
  959. return query.OrderBy(x => x.LoginID)
  960. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  961. .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  962. }
  963. /// <summary>
  964. /// 查询年级专业对应的学生信息List
  965. /// </summary>
  966. /// <param name="configuretView"></param>
  967. /// <param name="grademajorID"></param>
  968. /// <param name="inSchoolStatus"></param>
  969. /// <returns></returns>
  970. public IList<BaseStudentView> GetBaseStudentViewList(ConfiguretView configuretView, Guid? grademajorID, int? inSchoolStatus)
  971. {
  972. //年级专业信息
  973. Expression<Func<CF_Grademajor, bool>> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  974. expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID);
  975. //学生信息
  976. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  977. var query = GrademajorDAL.GetBaseStudentViewQueryable(expGrademajor, expStudent);
  978. //查询条件
  979. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  980. {
  981. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  982. }
  983. return query.OrderBy(x => x.LoginID)
  984. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  985. .ToList();
  986. }
  987. /// <summary>
  988. /// 批量修改(重写)
  989. /// 暂时不考虑对应的班级信息下的学生拟毕业日期的更新,后续再处理
  990. /// 目前通过修改对应的班级信息来更新
  991. /// </summary>
  992. /// <param name="grademajorIDs"></param>
  993. /// <param name="schoolyearID"></param>
  994. /// <param name="schoolcodeID"></param>
  995. /// <returns></returns>
  996. public string BatchModify(string grademajorIDs, int? schoolyearID, int? schoolcodeID)
  997. {
  998. List<Guid> list = new List<Guid>();
  999. HashSet<string> hs = new HashSet<string>();
  1000. for (int i = 0; i < grademajorIDs.Split(',').Length; i++)
  1001. {
  1002. string id = grademajorIDs.Split(',')[i];
  1003. if (!string.IsNullOrEmpty(id))
  1004. {
  1005. Guid grademajorID = new Guid(id);
  1006. list.Add(grademajorID);
  1007. }
  1008. }
  1009. int sCount = 0;
  1010. int lCount = 0;
  1011. foreach (Guid li in list)
  1012. {
  1013. GrademajorView grademajorView = GrademajorDAL.GetGrademajorViwQueryable(x => x.GrademajorID == li).FirstOrDefault();
  1014. CF_Grademajor grademajor = new CF_Grademajor();
  1015. grademajor = GrademajorDAL.GrademajorRepository.GetSingle(x => x.GrademajorID == li);
  1016. if (schoolyearID != null)
  1017. {
  1018. sCount++;
  1019. grademajor.SchoolyearID = schoolyearID;
  1020. var graduateSchoolyearValue = (schoolyearID * 2) - 1 + ((int)grademajor.SchoolcodeID - 1);
  1021. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling((double)grademajorView.LearnSystem * 2 - 1));
  1022. var graduatingSemester = GrademajorDAL.SchoolyearRepository.GetSingle(x => x.Value == graduateSchoolyearValue);
  1023. if (graduatingSemester == null)
  1024. {
  1025. lCount++;
  1026. hs.Add("预计毕业学年学期超出了系统学年学期数据的范围,请添加足够的学年学期记录以支撑该操作。");
  1027. continue;
  1028. }
  1029. else
  1030. {
  1031. grademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  1032. }
  1033. }
  1034. if (schoolcodeID != null)
  1035. {
  1036. sCount++;
  1037. grademajor.SchoolcodeID = schoolcodeID;
  1038. var graduateSchoolyearValue = (grademajor.SchoolyearID * 2) - 1 + ((int)schoolcodeID - 1);
  1039. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling((double)grademajorView.LearnSystem * 2 - 1));
  1040. var graduatingSemester = GrademajorDAL.SchoolyearRepository.GetSingle(x => x.Value == graduateSchoolyearValue);
  1041. if (graduatingSemester == null)
  1042. {
  1043. lCount++;
  1044. hs.Add("预计毕业学年学期超出了系统学年学期数据的范围,请添加足够的学年学期记录以支撑该操作。");
  1045. continue;
  1046. }
  1047. else
  1048. {
  1049. grademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  1050. }
  1051. }
  1052. SetModifyStatus(grademajor);
  1053. UnitOfWork.Commit();
  1054. }
  1055. StringBuilder sb = new StringBuilder();
  1056. int s = hs.Count();
  1057. foreach (string li in hs)
  1058. {
  1059. sb.Append(li);
  1060. }
  1061. if (lCount > 0)
  1062. {
  1063. return "批量修改成功" + (grademajorIDs.Split(',').Length - lCount) + "条,批量修改失败" + lCount + "条,失败原因:" + sb;
  1064. }
  1065. else
  1066. {
  1067. return "批量修改成功" + (grademajorIDs.Split(',').Length - lCount) + "条";
  1068. }
  1069. }
  1070. /// <summary>
  1071. /// 年级专业信息Excel导入
  1072. /// </summary>
  1073. /// <param name="cellheader"></param>
  1074. /// <param name="inCount"></param>
  1075. /// <param name="upCount"></param>
  1076. /// <param name="errdataList"></param>
  1077. /// <param name="errCount"></param>
  1078. /// <param name="sourcePhysicalPath"></param>
  1079. public void GrademajorImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<GrademajorView> errdataList, out int? errCount, string sourcePhysicalPath)
  1080. {
  1081. try
  1082. {
  1083. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  1084. List<GrademajorView> errList = new List<GrademajorView>();
  1085. // 1.1解析文件,存放到一个List集合里
  1086. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  1087. List<GrademajorView> enlist = NpoiExcelHelper.ExcelToEntityList<GrademajorView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  1088. cellheader.Add("ErrorMessage", "未导入原因");
  1089. //对List集合进行有效性校验
  1090. if (enlist.Count() <= 0)
  1091. {
  1092. throw new Exception("Excel文件数据为空,请检查。");
  1093. }
  1094. Regex reg = null; //正则表达式
  1095. //DateTime result; //用于返回判断日期字段格式
  1096. inCount = 0; //导入个数
  1097. upCount = 0; //更新个数
  1098. errCount = 0; //失败个数
  1099. string errorMsgStr = ""; //错误信息
  1100. List<CF_Grademajor> newGrademajorInList = new List<CF_Grademajor>();
  1101. List<CF_Grademajor> newGrademajorUpList = new List<CF_Grademajor>();
  1102. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  1103. //年级专业信息
  1104. var grademajorList = GrademajorDAL.GrademajorRepository.GetList(x => true).ToList();
  1105. //年级专业编号
  1106. var grademajorCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).ToList();
  1107. //年级专业名称
  1108. var grademajorNameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList();
  1109. //对比后的newGrademajorList
  1110. var newGrademajorList = grademajorList
  1111. .Where(x => grademajorCodeList.Contains(x.Code) || grademajorNameList.Contains(x.Name)).ToList();
  1112. //院系专业信息
  1113. var facultymajorList = GrademajorDAL.FacultymajorRepository.GetList(x => true).ToList();
  1114. //院系专业编号
  1115. var facultymajorCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.FacultymajorCode)).Select(x => x.FacultymajorCode).ToList();
  1116. //对比后的newFacultymajorList
  1117. var newFacultymajorList = facultymajorList.Where(x => facultymajorCodeList.Contains(x.Code)).ToList();
  1118. //年级
  1119. var schoolyearList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Schoolyear).ToList();
  1120. //校区
  1121. var schoolAreaList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolArea).ToList();
  1122. //学期
  1123. var schoolcodeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Schoolcode).ToList();
  1124. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  1125. for (int i = 0; i < enlist.Count; i++)
  1126. {
  1127. GrademajorView en = enlist[i]; //Excel表数据视图
  1128. CF_Grademajor newGrademajor = new CF_Grademajor();
  1129. //年级专业编号
  1130. if (string.IsNullOrEmpty(en.Code))
  1131. {
  1132. errCount++;
  1133. errorMsgStr = "年级专业编号不能为空";
  1134. en.ErrorMessage = errorMsgStr;
  1135. errList.Add(en);
  1136. errorMsg.AppendLine(errorMsgStr);
  1137. continue;
  1138. }
  1139. else
  1140. {
  1141. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  1142. if (!reg.IsMatch(en.Code))
  1143. {
  1144. errCount++;
  1145. errorMsgStr = "年级专业编号格式不正确,请检查(数字或英文字母)";
  1146. en.ErrorMessage = errorMsgStr;
  1147. errList.Add(en);
  1148. errorMsg.AppendLine(errorMsgStr);
  1149. continue;
  1150. }
  1151. else
  1152. {
  1153. //年级专业编号
  1154. newGrademajor.Code = en.Code.Trim();
  1155. }
  1156. }
  1157. //年级专业名称
  1158. if (string.IsNullOrEmpty(en.Name))
  1159. {
  1160. errCount++;
  1161. errorMsgStr = "年级专业名称不能为空";
  1162. en.ErrorMessage = errorMsgStr;
  1163. errList.Add(en);
  1164. errorMsg.AppendLine(errorMsgStr);
  1165. continue;
  1166. }
  1167. else
  1168. {
  1169. //年级专业名称
  1170. newGrademajor.Name = en.Name.Trim();
  1171. }
  1172. //简称
  1173. if (string.IsNullOrEmpty(en.Abbreviation))
  1174. {
  1175. //不考虑
  1176. }
  1177. else
  1178. {
  1179. newGrademajor.Abbreviation = en.Abbreviation;
  1180. }
  1181. //院系专业编号
  1182. if (string.IsNullOrEmpty(en.FacultymajorCode))
  1183. {
  1184. errCount++;
  1185. errorMsgStr = "院系专业编号不能为空";
  1186. en.ErrorMessage = errorMsgStr;
  1187. errList.Add(en);
  1188. errorMsg.AppendLine(errorMsgStr);
  1189. continue;
  1190. }
  1191. else
  1192. {
  1193. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  1194. if (!reg.IsMatch(en.FacultymajorCode))
  1195. {
  1196. errCount++;
  1197. errorMsgStr = "院系专业编号格式不正确,请检查(数字或英文字母)";
  1198. en.ErrorMessage = errorMsgStr;
  1199. errList.Add(en);
  1200. errorMsg.AppendLine(errorMsgStr);
  1201. continue;
  1202. }
  1203. else
  1204. {
  1205. //暂时不考虑院系专业编号有相同的情况
  1206. var facultymajor = newFacultymajorList.Where(x => x.Code == en.FacultymajorCode.Trim())
  1207. .SingleOrDefault();
  1208. if (facultymajor == null)
  1209. {
  1210. errCount++;
  1211. errorMsgStr = "院系专业编号不存在,请检查";
  1212. en.ErrorMessage = errorMsgStr;
  1213. errList.Add(en);
  1214. errorMsg.AppendLine(errorMsgStr);
  1215. continue;
  1216. }
  1217. else
  1218. {
  1219. //院系专业信息ID
  1220. newGrademajor.FacultymajorID = facultymajor.FacultymajorID;
  1221. //学制(用于计算毕业学期)
  1222. en.LearnSystem = facultymajor.LearnSystem;
  1223. }
  1224. }
  1225. }
  1226. //年级
  1227. if (string.IsNullOrEmpty(en.SchoolyearStr))
  1228. {
  1229. errCount++;
  1230. errorMsgStr = "年级不能为空";
  1231. en.ErrorMessage = errorMsgStr;
  1232. errList.Add(en);
  1233. errorMsg.AppendLine(errorMsgStr);
  1234. continue;
  1235. }
  1236. else
  1237. {
  1238. var schoolyear = schoolyearList.Where(x => x.Name == en.SchoolyearStr.Trim()).SingleOrDefault();
  1239. if (schoolyear == null)
  1240. {
  1241. errCount++;
  1242. errorMsgStr = "年级不存在,请检查";
  1243. en.ErrorMessage = errorMsgStr;
  1244. errList.Add(en);
  1245. errorMsg.AppendLine(errorMsgStr);
  1246. continue;
  1247. }
  1248. else
  1249. {
  1250. //年级
  1251. newGrademajor.SchoolyearID = schoolyear.Value;
  1252. }
  1253. }
  1254. //入学学期
  1255. if (string.IsNullOrEmpty(en.SchoolcodeStr))
  1256. {
  1257. errCount++;
  1258. errorMsgStr = "入学学期不能为空";
  1259. en.ErrorMessage = errorMsgStr;
  1260. errList.Add(en);
  1261. errorMsg.AppendLine(errorMsgStr);
  1262. continue;
  1263. }
  1264. else
  1265. {
  1266. var schoolcode = schoolcodeList.Where(x => x.Name == en.SchoolcodeStr.Trim()).SingleOrDefault();
  1267. if (schoolcode == null)
  1268. {
  1269. errCount++;
  1270. errorMsgStr = "入学学期不存在,请检查";
  1271. en.ErrorMessage = errorMsgStr;
  1272. errList.Add(en);
  1273. errorMsg.AppendLine(errorMsgStr);
  1274. continue;
  1275. }
  1276. else
  1277. {
  1278. //入学学期
  1279. newGrademajor.SchoolcodeID = schoolcode.Value;
  1280. }
  1281. }
  1282. //专业方向
  1283. if (string.IsNullOrEmpty(en.Professional))
  1284. {
  1285. //不考虑
  1286. }
  1287. else
  1288. {
  1289. newGrademajor.Professional = en.Professional;
  1290. }
  1291. //备注
  1292. if (string.IsNullOrEmpty(en.Remark))
  1293. {
  1294. //不考虑
  1295. }
  1296. else
  1297. {
  1298. newGrademajor.Remark = en.Remark;
  1299. }
  1300. //学制
  1301. if (en.LearnSystem == null)
  1302. {
  1303. errCount++;
  1304. errorMsgStr = "院系专业编号中对应的学制有误(不能为空),请检查";
  1305. en.ErrorMessage = errorMsgStr;
  1306. errList.Add(en);
  1307. errorMsg.AppendLine(errorMsgStr);
  1308. continue;
  1309. }
  1310. else
  1311. {
  1312. //计算相应的毕业学年学期Value
  1313. var graduateSchoolyearValue = (newGrademajor.SchoolyearID.Value * 2) - 1
  1314. + (newGrademajor.SchoolcodeID.Value - 1);
  1315. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(en.LearnSystem.Value * 2 - 1));
  1316. var graduatingSemester = GrademajorDAL.SchoolyearRepository
  1317. .GetSingle(x => x.Value == graduateSchoolyearValue);
  1318. if (graduatingSemester == null)
  1319. {
  1320. errCount++;
  1321. errorMsgStr = "预计毕业学年学期超出了系统学年学期数据的范围,请添加足够的学年学期记录以支撑该操作,请检查";
  1322. en.ErrorMessage = errorMsgStr;
  1323. errList.Add(en);
  1324. errorMsg.AppendLine(errorMsgStr);
  1325. continue;
  1326. }
  1327. else
  1328. {
  1329. newGrademajor.GraduatingSemesterID = graduatingSemester.SchoolyearID;
  1330. }
  1331. }
  1332. //校区
  1333. if (string.IsNullOrEmpty(en.SchoolAreaStr))
  1334. {
  1335. errCount++;
  1336. errorMsgStr = "校区不能为空";
  1337. en.ErrorMessage = errorMsgStr;
  1338. errList.Add(en);
  1339. errorMsg.AppendLine(errorMsgStr);
  1340. continue;
  1341. }
  1342. else
  1343. {
  1344. var schoolyear = schoolAreaList.Where(x => x.Name == en.SchoolAreaStr.Trim()).SingleOrDefault();
  1345. if (schoolyear == null)
  1346. {
  1347. errCount++;
  1348. errorMsgStr = "校区不存在,请检查";
  1349. en.ErrorMessage = errorMsgStr;
  1350. errList.Add(en);
  1351. errorMsg.AppendLine(errorMsgStr);
  1352. continue;
  1353. }
  1354. else
  1355. {
  1356. //年级
  1357. newGrademajor.SchoolAreaID = schoolyear.Value;
  1358. }
  1359. }
  1360. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  1361. //for (int j = i + 1; j < enlist.Count; j++)
  1362. //{
  1363. // NewGrademajorView enA = enlist[j];
  1364. // //根据Excel表中的业务主键进行去重(年级专业编号或年级专业名称唯一)
  1365. // if (en.No == enA.No && en.Name == enA.Name)
  1366. // {
  1367. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  1368. // }
  1369. //}
  1370. //数据表重复性验证(年级专业编号或年级专业名称唯一)
  1371. var grademajorVerification = newGrademajorList
  1372. .Where(x => x.Code == newGrademajor.Code || x.Name == newGrademajor.Name)
  1373. .FirstOrDefault();
  1374. if (grademajorVerification == null)
  1375. {
  1376. //新增
  1377. if (!newGrademajorInList.Any(x => x.Code == newGrademajor.Code || x.Name == newGrademajor.Name))
  1378. {
  1379. //CF_Grademajor表
  1380. newGrademajor.GrademajorID = Guid.NewGuid();
  1381. SetNewStatus(newGrademajor);
  1382. newGrademajorInList.Add(newGrademajor);
  1383. inCount++;
  1384. }
  1385. else
  1386. {
  1387. //Excel表重复性验证
  1388. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  1389. inCount++;
  1390. }
  1391. }
  1392. else
  1393. {
  1394. //更新(Excel有重复时,以最后一条记录的更新为准)
  1395. grademajorVerification.Abbreviation = newGrademajor.Abbreviation;
  1396. grademajorVerification.FacultymajorID = newGrademajor.FacultymajorID;
  1397. grademajorVerification.SchoolyearID = newGrademajor.SchoolyearID;
  1398. grademajorVerification.SchoolcodeID = newGrademajor.SchoolcodeID;
  1399. grademajorVerification.GraduatingSemesterID = newGrademajor.GraduatingSemesterID;
  1400. grademajorVerification.Professional = newGrademajor.Professional;
  1401. grademajorVerification.SchoolAreaID = newGrademajor.SchoolAreaID;
  1402. grademajorVerification.Remark = newGrademajor.Remark;
  1403. SetModifyStatus(grademajorVerification);
  1404. newGrademajorUpList.Add(grademajorVerification);
  1405. upCount++;
  1406. }
  1407. }
  1408. UnitOfWork.BulkInsert(newGrademajorInList); //批量插入
  1409. //批量统一提交更新
  1410. if (newGrademajorUpList != null && newGrademajorUpList.Count() > 0)
  1411. {
  1412. UnitOfWork.BatchUpdate(newGrademajorUpList);
  1413. }
  1414. errdataList = errList.Distinct().ToList(); //错误列表List
  1415. }
  1416. catch (Exception ex)
  1417. {
  1418. //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
  1419. throw new Exception(ex.Message);
  1420. }
  1421. }
  1422. }
  1423. }