ClassmajorServices.cs 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.Specialtyclass;
  6. using EMIS.ViewModel.Specialtyclass;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.Utility;
  11. using Bowin.Common.Linq;
  12. using EMIS.DataLogic.Common.CalendarManage;
  13. using System.Linq.Expressions;
  14. using EMIS.CommonLogic.Students;
  15. using EMIS.ViewModel.Students;
  16. using EMIS.CommonLogic.CalendarManage;
  17. using Bowin.Common.Utility;
  18. using System.Text.RegularExpressions;
  19. using EMIS.CommonLogic.TeacherManagement;
  20. namespace EMIS.CommonLogic.Specialtyclass
  21. {
  22. public class ClassmajorServices : BaseServices, IClassmajorServices
  23. {
  24. public ClassmajorDAL ClassmajorDAL { get; set; }
  25. public GrademajorDAL GrademajorDAL { get; set; }
  26. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  27. public Lazy<IStaffServices> StaffServices { get; set; }
  28. /// <summary>
  29. /// 查询对应的班级信息View
  30. /// </summary>
  31. /// <param name="configuretView"></param>
  32. /// <param name="campusID"></param>
  33. /// <param name="collegeID"></param>
  34. /// <param name="schoolyearID"></param>
  35. /// <param name="standardID"></param>
  36. /// <param name="educationID"></param>
  37. /// <param name="learningformID"></param>
  38. /// <param name="learnSystem"></param>
  39. /// <param name="grademajorID"></param>
  40. /// <param name="inSchoolStatus"></param>
  41. /// <param name="pageIndex"></param>
  42. /// <param name="pageSize"></param>
  43. /// <returns></returns>
  44. public IGridResultSet<ClassmajorView> GetClassmajorViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  45. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  46. Guid? grademajorID, int? inSchoolStatus, int pageIndex, int pageSize)
  47. {
  48. //班级信息
  49. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  50. if (grademajorID.HasValue)
  51. {
  52. //年级专业
  53. expClassmajor = expClassmajor.And(x => x.GrademajorID == grademajorID);
  54. }
  55. //学生信息
  56. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  57. var query = ClassmajorDAL.GetClassmajorViewQueryable(expClassmajor, expStudent);
  58. if (schoolAreaID.HasValue)
  59. {
  60. //校区
  61. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  62. }
  63. if (collegeID.HasValue)
  64. {
  65. //院系所
  66. query = query.Where(x => x.CollegeID == collegeID);
  67. }
  68. if (schoolyearID.HasValue)
  69. {
  70. //年级
  71. query = query.Where(x => x.SchoolyearID == schoolyearID);
  72. }
  73. if (standardID.HasValue)
  74. {
  75. //专业ID(Value)
  76. query = query.Where(x => x.StandardID == standardID);
  77. }
  78. if (educationID.HasValue)
  79. {
  80. //培养层次
  81. query = query.Where(x => x.EducationID == educationID);
  82. }
  83. if (learningformID.HasValue)
  84. {
  85. //学习形式
  86. query = query.Where(x => x.LearningformID == learningformID);
  87. }
  88. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  89. {
  90. //学制
  91. var LearnSystems = Convert.ToDecimal(learnSystem);
  92. query = query.Where(x => x.LearnSystem == LearnSystems);
  93. }
  94. //if (inSchoolStatus != null && inSchoolStatus > -1)
  95. //{
  96. // //排除人数为0的信息
  97. // query = query.Where(x => x.StudentCount > 0);
  98. //}
  99. //查询条件
  100. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  101. {
  102. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  103. }
  104. return this.GetQueryByAssistant(query, null, this.GetQueryByDataRangeByCollege(query))
  105. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  106. .ThenByDescending(x => x.GrademajorCode.Length).ThenByDescending(x => x.GrademajorCode)
  107. .ThenByDescending(x => x.SchoolyearID).ThenBy(x => x.StandardID)
  108. .ThenBy(x => x.No.Length).ThenBy(x => x.No)
  109. .ToGridResultSet<ClassmajorView>(pageIndex, pageSize);
  110. }
  111. /// <summary>
  112. /// 查询对应的班级信息View
  113. /// </summary>
  114. /// <param name="configuretView"></param>
  115. /// <param name="campusID"></param>
  116. /// <param name="collegeID"></param>
  117. /// <param name="schoolyearID"></param>
  118. /// <param name="standardID"></param>
  119. /// <param name="educationID"></param>
  120. /// <param name="learningformID"></param>
  121. /// <param name="learnSystem"></param>
  122. /// <param name="grademajorID"></param>
  123. /// <param name="inSchoolStatus"></param>
  124. /// <param name="pageIndex"></param>
  125. /// <param name="pageSize"></param>
  126. /// <returns></returns>
  127. public IGridResultSet<ClassmajorView> GetInschoolClassmajorViewGrid(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  128. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  129. Guid? grademajorID, int pageIndex, int pageSize)
  130. {
  131. //班级信息
  132. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  133. if (grademajorID.HasValue)
  134. {
  135. //年级专业
  136. expClassmajor = expClassmajor.And(x => x.GrademajorID == grademajorID);
  137. }
  138. //学生信息
  139. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  140. var query = ClassmajorDAL.GetClassmajorViewQueryable(expClassmajor, expStudent);
  141. if (schoolAreaID.HasValue)
  142. {
  143. //校区
  144. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  145. }
  146. if (collegeID.HasValue)
  147. {
  148. //院系所
  149. query = query.Where(x => x.CollegeID == collegeID);
  150. }
  151. if (schoolyearID.HasValue)
  152. {
  153. //年级
  154. query = query.Where(x => x.SchoolyearID == schoolyearID);
  155. }
  156. if (standardID.HasValue)
  157. {
  158. //专业ID(Value)
  159. query = query.Where(x => x.StandardID == standardID);
  160. }
  161. if (educationID.HasValue)
  162. {
  163. //培养层次
  164. query = query.Where(x => x.EducationID == educationID);
  165. }
  166. if (learningformID.HasValue)
  167. {
  168. //学习形式
  169. query = query.Where(x => x.LearningformID == learningformID);
  170. }
  171. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  172. {
  173. //学制
  174. var LearnSystems = Convert.ToDecimal(learnSystem);
  175. query = query.Where(x => x.LearnSystem == LearnSystems);
  176. }
  177. //if (inSchoolStatus != null && inSchoolStatus > -1)
  178. //{
  179. // //排除人数为0的信息
  180. // query = query.Where(x => x.StudentCount > 0);
  181. //}
  182. //查询条件
  183. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  184. {
  185. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  186. }
  187. return this.GetQueryByAssistant(query, null, query)
  188. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  189. .ThenByDescending(x => x.GrademajorCode.Length).ThenByDescending(x => x.GrademajorCode)
  190. .ThenByDescending(x => x.SchoolyearID).ThenBy(x => x.StandardID)
  191. .ThenBy(x => x.No.Length).ThenBy(x => x.No)
  192. .ToGridResultSet<ClassmajorView>(pageIndex, pageSize);
  193. }
  194. /// <summary>
  195. /// 查询对应的班级信息List
  196. /// </summary>
  197. /// <param name="configuretView"></param>
  198. /// <param name="campusID"></param>
  199. /// <param name="collegeID"></param>
  200. /// <param name="schoolyearID"></param>
  201. /// <param name="standardID"></param>
  202. /// <param name="educationID"></param>
  203. /// <param name="learningformID"></param>
  204. /// <param name="learnSystem"></param>
  205. /// <param name="grademajorID"></param>
  206. /// <param name="inSchoolStatus"></param>
  207. /// <returns></returns>
  208. public IList<ClassmajorView> GetClassmajorViewList(ConfiguretView configuretView, int? schoolAreaID, Guid? collegeID,
  209. int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  210. Guid? grademajorID, int? inSchoolStatus)
  211. {
  212. //班级信息
  213. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  214. if (grademajorID.HasValue)
  215. {
  216. //年级专业
  217. expClassmajor = expClassmajor.And(x => x.GrademajorID == grademajorID);
  218. }
  219. //学生信息
  220. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  221. var query = ClassmajorDAL.GetClassmajorViewQueryable(expClassmajor, expStudent);
  222. if (schoolAreaID.HasValue)
  223. {
  224. //校区
  225. query = query.Where(x => x.SchoolAreaID == schoolAreaID);
  226. }
  227. if (collegeID.HasValue)
  228. {
  229. //院系所
  230. query = query.Where(x => x.CollegeID == collegeID);
  231. }
  232. if (schoolyearID.HasValue)
  233. {
  234. //年级
  235. query = query.Where(x => x.SchoolyearID == schoolyearID);
  236. }
  237. if (standardID.HasValue)
  238. {
  239. //专业ID(Value)
  240. query = query.Where(x => x.StandardID == standardID);
  241. }
  242. if (educationID.HasValue)
  243. {
  244. //培养层次
  245. query = query.Where(x => x.EducationID == educationID);
  246. }
  247. if (learningformID.HasValue)
  248. {
  249. //学习形式
  250. query = query.Where(x => x.LearningformID == learningformID);
  251. }
  252. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  253. {
  254. //学制
  255. var LearnSystems = Convert.ToDecimal(learnSystem);
  256. query = query.Where(x => x.LearnSystem == LearnSystems);
  257. }
  258. //if (inSchoolStatus != null && inSchoolStatus > -1)
  259. //{
  260. // //排除人数为0的信息
  261. // query = query.Where(x => x.StudentCount > 0);
  262. //}
  263. //查询条件
  264. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  265. {
  266. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  267. }
  268. return this.GetQueryByAssistant(query, null, this.GetQueryByDataRangeByCollege(query))
  269. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  270. .ThenByDescending(x => x.GrademajorCode.Length).ThenByDescending(x => x.GrademajorCode)
  271. .ThenByDescending(x => x.SchoolyearID).ThenBy(x => x.StandardID)
  272. .ThenBy(x => x.No.Length).ThenBy(x => x.No)
  273. .ToList();
  274. }
  275. /// <summary>
  276. /// 查询对应的班级信息View(带毕业学期)
  277. /// </summary>
  278. /// <param name="configuretView"></param>
  279. /// <param name="collegeID"></param>
  280. /// <param name="standardID"></param>
  281. /// <param name="schoolyearID"></param>
  282. /// <param name="educationID"></param>
  283. /// <param name="learningformID"></param>
  284. /// <param name="learnSystem"></param>
  285. /// <param name="graduatingSemesterID"></param>
  286. /// <param name="pageIndex"></param>
  287. /// <param name="pageSize"></param>
  288. /// <returns></returns>
  289. public IGridResultSet<ClassmajorView> GetClassmajorViewGridForGraduateReport(ConfiguretView configuretView, Guid? collegeID,
  290. int? standardID, int? schoolyearID, int? educationID, int? learningformID, string learnSystem,
  291. Guid? graduatingSemesterID, int pageIndex, int pageSize)
  292. {
  293. //班级信息
  294. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  295. var query = ClassmajorDAL.GetClassmajorViewQueryable(expClassmajor);
  296. if (collegeID.HasValue)
  297. {
  298. //院系所
  299. query = query.Where(x => x.CollegeID == collegeID);
  300. }
  301. if (schoolyearID.HasValue)
  302. {
  303. //年级
  304. query = query.Where(x => x.SchoolyearID == schoolyearID);
  305. }
  306. if (standardID.HasValue)
  307. {
  308. //专业ID(Value)
  309. query = query.Where(x => x.StandardID == standardID);
  310. }
  311. if (educationID.HasValue)
  312. {
  313. //培养层次
  314. query = query.Where(x => x.EducationID == educationID);
  315. }
  316. if (learningformID.HasValue)
  317. {
  318. //学习形式
  319. query = query.Where(x => x.LearningformID == learningformID);
  320. }
  321. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  322. {
  323. //学制
  324. var LearnSystems = Convert.ToDecimal(learnSystem);
  325. query = query.Where(x => x.LearnSystem == LearnSystems);
  326. }
  327. if (graduatingSemesterID.HasValue)
  328. {
  329. //毕业学期
  330. query = query.Where(x => x.GraduatingSemesterID == graduatingSemesterID);
  331. }
  332. //查询条件
  333. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  334. {
  335. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  336. }
  337. return this.GetQueryByAssistant(query, null, this.GetQueryByDataRangeByCollege(query))
  338. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  339. .ThenByDescending(x => x.GrademajorCode.Length).ThenByDescending(x => x.GrademajorCode)
  340. .ThenByDescending(x => x.SchoolyearID).ThenBy(x => x.StandardID)
  341. .ThenBy(x => x.No.Length).ThenBy(x => x.No)
  342. .ToGridResultSet<ClassmajorView>(pageIndex, pageSize);
  343. }
  344. /// <summary>
  345. /// 查询对应的班级信息List(带毕业学期)
  346. /// </summary>
  347. /// <param name="configuretView"></param>
  348. /// <param name="collegeID"></param>
  349. /// <param name="standardID"></param>
  350. /// <param name="schoolyearID"></param>
  351. /// <param name="educationID"></param>
  352. /// <param name="learningformID"></param>
  353. /// <param name="learnSystem"></param>
  354. /// <param name="graduatingSemesterID"></param>
  355. /// <returns></returns>
  356. public IList<ClassmajorView> GetClassmajorViewGridForGraduateReport(ConfiguretView configuretView, Guid? collegeID,
  357. int? standardID, int? schoolyearID, int? educationID, int? learningformID, string learnSystem,
  358. Guid? graduatingSemesterID)
  359. {
  360. //班级信息
  361. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  362. var query = ClassmajorDAL.GetClassmajorViewQueryable(expClassmajor);
  363. if (collegeID.HasValue)
  364. {
  365. //院系所
  366. query = query.Where(x => x.CollegeID == collegeID);
  367. }
  368. if (schoolyearID.HasValue)
  369. {
  370. //年级
  371. query = query.Where(x => x.SchoolyearID == schoolyearID);
  372. }
  373. if (standardID.HasValue)
  374. {
  375. //专业ID(Value)
  376. query = query.Where(x => x.StandardID == standardID);
  377. }
  378. if (educationID.HasValue)
  379. {
  380. //培养层次
  381. query = query.Where(x => x.EducationID == educationID);
  382. }
  383. if (learningformID.HasValue)
  384. {
  385. //学习形式
  386. query = query.Where(x => x.LearningformID == learningformID);
  387. }
  388. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  389. {
  390. //学制
  391. var LearnSystems = Convert.ToDecimal(learnSystem);
  392. query = query.Where(x => x.LearnSystem == LearnSystems);
  393. }
  394. if (graduatingSemesterID.HasValue)
  395. {
  396. //毕业学期
  397. query = query.Where(x => x.GraduatingSemesterID == graduatingSemesterID);
  398. }
  399. //查询条件
  400. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  401. {
  402. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  403. }
  404. return this.GetQueryByAssistant(query, null, this.GetQueryByDataRangeByCollege(query))
  405. .OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  406. .ThenByDescending(x => x.GrademajorCode.Length).ThenByDescending(x => x.GrademajorCode)
  407. .ThenByDescending(x => x.SchoolyearID).ThenBy(x => x.StandardID)
  408. .ThenBy(x => x.No.Length).ThenBy(x => x.No)
  409. .ToList();
  410. }
  411. /// <summary>
  412. /// 根据年级专业信息ID查询对应的班级信息List
  413. /// </summary>
  414. /// <param name="grademajorID"></param>
  415. /// <returns></returns>
  416. public List<CF_Classmajor> GetClassmajorList(Guid? grademajorID)
  417. {
  418. var query = ClassmajorDAL.ClassmajorRepository.GetList(x => x.GrademajorID == grademajorID);
  419. return query.OrderBy(x => x.No.Length).ThenBy(x => x.No)
  420. .ToList();
  421. }
  422. /// <summary>
  423. /// 查询对应的班级信息List(无数据范围)
  424. /// </summary>
  425. /// <param name="collegeID"></param>
  426. /// <param name="schoolyearID"></param>
  427. /// <param name="standardID"></param>
  428. /// <returns></returns>
  429. public List<CF_Classmajor> GetClassmajorListWithoutRange(Guid? collegeID, int? schoolyearID, int? standardID)
  430. {
  431. //班级信息
  432. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  433. if (collegeID.HasValue)
  434. {
  435. //院系所
  436. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  437. }
  438. if (schoolyearID.HasValue)
  439. {
  440. //年级
  441. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.SchoolyearID == schoolyearID);
  442. }
  443. if (standardID.HasValue)
  444. {
  445. //专业ID(Value)
  446. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  447. }
  448. var query = ClassmajorDAL.ClassmajorRepository.GetList(expClassmajor);
  449. return query.OrderBy(x => x.No.Length).ThenBy(x => x.No)
  450. .ToList();
  451. }
  452. /// <summary>
  453. /// 查询对应的班级信息List(带数据范围)
  454. /// </summary>
  455. /// <param name="collegeID"></param>
  456. /// <param name="schoolyearID"></param>
  457. /// <param name="standardID"></param>
  458. /// <returns></returns>
  459. public List<CF_Classmajor> GetClassmajorList(Guid? collegeID, int? schoolyearID, int? standardID)
  460. {
  461. //班级信息
  462. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  463. if (collegeID.HasValue)
  464. {
  465. //院系所
  466. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  467. }
  468. if (schoolyearID.HasValue)
  469. {
  470. //年级
  471. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.SchoolyearID == schoolyearID);
  472. }
  473. if (standardID.HasValue)
  474. {
  475. //专业ID(Value)
  476. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  477. }
  478. var query = ClassmajorDAL.ClassmajorRepository.GetList(expClassmajor);
  479. return this.GetQueryByAssistant(query, null, this.GetQueryByDataRangeByCollege(query))
  480. .OrderBy(x => x.No.Length).ThenBy(x => x.No)
  481. .ToList();
  482. }
  483. /// <summary>
  484. /// 查询对应的班级信息CF_Classmajor
  485. /// </summary>
  486. /// <param name="classmajorID"></param>
  487. /// <returns></returns>
  488. public CF_Classmajor GetClassmajorInfo(Guid? classmajorID)
  489. {
  490. try
  491. {
  492. var query = ClassmajorDAL.ClassmajorRepository.GetList(x => x.ClassmajorID == classmajorID);
  493. return query.SingleOrDefault();
  494. }
  495. catch (Exception ex)
  496. {
  497. throw new Exception(ex.Message);
  498. }
  499. }
  500. /// <summary>
  501. /// 查询对应的班级信息ClassmajorView
  502. /// </summary>
  503. /// <param name="classmajorID"></param>
  504. /// <returns></returns>
  505. public ClassmajorView GetClassmajorView(Guid? classmajorID)
  506. {
  507. try
  508. {
  509. var query = ClassmajorDAL.GetClassmajorViewQueryable(x => x.ClassmajorID == classmajorID);
  510. return query.SingleOrDefault();
  511. }
  512. catch (Exception ex)
  513. {
  514. throw new Exception(ex.Message);
  515. }
  516. }
  517. /// <summary>
  518. /// 编辑(新增、修改,业务主键:班级编号或班级名称唯一)
  519. /// </summary>
  520. /// <param name="classmajorView"></param>
  521. public void ClassmajorEdit(ClassmajorView classmajorView)
  522. {
  523. try
  524. {
  525. //查询数据库进行验证
  526. var classmajorVerification = ClassmajorDAL.ClassmajorRepository
  527. .GetList(x => x.ClassmajorID != classmajorView.ClassmajorID
  528. && (x.No == classmajorView.No
  529. || x.Name == classmajorView.Name))
  530. .FirstOrDefault();
  531. if (classmajorVerification == null)
  532. {
  533. //数据有误验证
  534. if (classmajorView.ClassmajorID != Guid.Empty)
  535. {
  536. var classmajor = ClassmajorDAL.ClassmajorRepository
  537. .GetList(x => x.ClassmajorID == classmajorView.ClassmajorID, x => x.CF_Student)
  538. .SingleOrDefault();
  539. if (classmajor == null)
  540. {
  541. throw new Exception("数据有误,请核查");
  542. }
  543. else
  544. {
  545. //表示修改
  546. classmajor.GrademajorID = classmajorView.GrademajorID;
  547. classmajor.No = classmajorView.No.Trim();
  548. classmajor.Name = classmajorView.Name;
  549. classmajor.Abbreviation = classmajorView.Abbreviation;
  550. classmajor.EnglishName = classmajorView.EnglishName;
  551. classmajor.ClassNum = classmajorView.ClassNum;
  552. classmajor.UserID = classmajorView.UserID;
  553. classmajor.AssistantUserID = classmajorView.AssistantUserID;
  554. classmajor.Fixedclassroom = classmajorView.Fixedclassroom;
  555. classmajor.Remark = classmajorView.Remark;
  556. SetModifyStatus(classmajor);
  557. //计算对应学生的拟毕业时间
  558. var grademajor = this.ClassmajorDAL.GrademajorRepository
  559. .GetSingle(x => x.GrademajorID == classmajor.GrademajorID);
  560. if (grademajor == null)
  561. {
  562. throw new Exception("年级专业有误,请重新选择。");
  563. }
  564. else
  565. {
  566. if (grademajor.GraduatingSemesterID == null)
  567. {
  568. throw new Exception("年级专业信息中毕业学期有误,请核查。");
  569. }
  570. }
  571. //这里应该用新的学年学期来算学生的拟毕业时间,原来的逻辑是用旧的……
  572. var schoolyearView = SchoolYearServices.Value
  573. .GetSchoolYearView(grademajor.GraduatingSemesterID);
  574. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  575. {
  576. throw new Exception("请先设置配置文件的预计毕业月份(春季入学)。");
  577. }
  578. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  579. {
  580. throw new Exception("请先设置配置文件的预计毕业日期(春季入学)。");
  581. }
  582. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  583. {
  584. throw new Exception("请先设置配置文件的预计毕业月份(秋季入学)。");
  585. }
  586. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  587. {
  588. throw new Exception("请先设置配置文件的预计毕业日期(秋季入学)。");
  589. }
  590. List<CF_Student> studentUpList = new List<CF_Student>();
  591. foreach (var item in classmajor.CF_Student)
  592. {
  593. item.PlanningGraduateDate = PlanningGraduateDateHelper
  594. .GetPlanningGraduateDate(schoolyearView.FirstWeek.Value);
  595. studentUpList.Add(item);
  596. }
  597. //事务提交
  598. UnitOfWork.Commit();
  599. //批量统一提交更新(预计毕业日期)
  600. if (studentUpList != null && studentUpList.Count() > 0)
  601. {
  602. UnitOfWork.BatchUpdate(studentUpList);
  603. }
  604. }
  605. }
  606. else
  607. {
  608. //表示新增
  609. CF_Classmajor classmajor = new CF_Classmajor();
  610. classmajor.ClassmajorID = Guid.NewGuid();
  611. classmajor.GrademajorID = classmajorView.GrademajorID;
  612. classmajor.No = classmajorView.No.Trim();
  613. classmajor.Name = classmajorView.Name;
  614. classmajor.Abbreviation = classmajorView.Abbreviation;
  615. classmajor.EnglishName = classmajorView.EnglishName;
  616. classmajor.ClassNum = classmajorView.ClassNum;
  617. classmajor.UserID = classmajorView.UserID;
  618. classmajor.AssistantUserID = classmajorView.AssistantUserID;
  619. classmajor.Fixedclassroom = classmajorView.Fixedclassroom;
  620. classmajor.Remark = classmajorView.Remark;
  621. SetNewStatus(classmajor);
  622. UnitOfWork.Add(classmajor);
  623. //事务提交
  624. UnitOfWork.Commit();
  625. }
  626. }
  627. else
  628. {
  629. throw new Exception("已存在相同的班级编号或班级名称,请核查");
  630. }
  631. }
  632. catch (Exception ex)
  633. {
  634. throw new Exception(ex.Message);
  635. }
  636. }
  637. /// <summary>
  638. /// 批量新增
  639. /// </summary>
  640. /// <param name="classmajorView"></param>
  641. /// <returns></returns>
  642. public string ClassmajorBatchAdd(ClassmajorView classmajorView)
  643. {
  644. try
  645. {
  646. List<CF_Classmajor> ClassmajorList = new List<CF_Classmajor>();
  647. //获取源数据
  648. var Grademajor = GrademajorDAL.GetGrademajorViwQueryable(x => x.SchoolyearID == classmajorView.BatchSchoolyearID);
  649. if (classmajorView.CollegeID != null)
  650. {
  651. Grademajor = Grademajor.Where(x => x.CollegeID == classmajorView.CollegeID);
  652. }
  653. if (classmajorView.StandardID != null && classmajorView.StandardID != -1)
  654. {
  655. Grademajor = Grademajor.Where(x => x.StandardID == classmajorView.StandardID);
  656. }
  657. //获取目标年级对应的年级专业
  658. var GrademajorList = Grademajor.ToList();
  659. //获取班级
  660. var SourceClass = ClassmajorDAL.GetClassmajorViewQueryable(x => true);
  661. if (classmajorView.CollegeID != null)
  662. {
  663. SourceClass = SourceClass.Where(x => x.CollegeID == classmajorView.CollegeID);
  664. }
  665. if (classmajorView.StandardID != null && classmajorView.StandardID != -1)
  666. {
  667. SourceClass = SourceClass.Where(x => x.StandardID == classmajorView.StandardID);
  668. }
  669. if (classmajorView.SchoolyearID != null)
  670. {
  671. SourceClass = SourceClass.Where(x => x.SchoolyearID == classmajorView.SchoolyearID);
  672. }
  673. var SourceClassmajorList = SourceClass.ToList();
  674. //获取目标年级中已存在数据
  675. var BatchClass = ClassmajorDAL.GetClassmajorViewQueryable(x => true);
  676. if (classmajorView.CollegeID != null)
  677. {
  678. BatchClass = BatchClass.Where(x => x.CollegeID == classmajorView.CollegeID);
  679. }
  680. if (classmajorView.StandardID != null && classmajorView.StandardID != -1)
  681. {
  682. BatchClass = BatchClass.Where(x => x.StandardID == classmajorView.StandardID);
  683. }
  684. if (classmajorView.BatchSchoolyearID != null)
  685. {
  686. BatchClass = BatchClass.Where(x => x.SchoolyearID == classmajorView.BatchSchoolyearID);
  687. }
  688. var BatchClassmajorList = BatchClass.ToList();
  689. //插入数据
  690. foreach (var sc in SourceClassmajorList)
  691. {
  692. var Class = GrademajorList.Where(x => x.SchoolyearID == classmajorView.BatchSchoolyearID && x.StandardID == sc.StandardID && x.CollegeID == sc.CollegeID).FirstOrDefault();
  693. if (Class != null)
  694. {
  695. CF_Classmajor classmajor = new CF_Classmajor();
  696. string Schoolyear = sc.SchoolyearID.ToString();
  697. string BatchSchoolyear = classmajorView.BatchSchoolyearID.Value.ToString();
  698. //替换复制的年级专业代码
  699. string No = sc.No.Trim().Replace(Schoolyear, BatchSchoolyear);
  700. //替换复制的年级专业名称
  701. string Name = sc.Name.Trim().Replace(Schoolyear, BatchSchoolyear);
  702. //替换复制的年级专业简称
  703. string Abbreviation = sc.Abbreviation.Trim().Replace(Schoolyear, BatchSchoolyear);
  704. classmajor.ClassmajorID = Guid.NewGuid();
  705. classmajor.GrademajorID = Class.GrademajorID;
  706. classmajor.No = No;
  707. classmajor.Name = Name;
  708. classmajor.Abbreviation = Abbreviation;
  709. classmajor.EnglishName = classmajorView.EnglishName;
  710. classmajor.ClassNum = sc.ClassNum;
  711. classmajor.UserID = sc.UserID;
  712. classmajor.AssistantUserID = sc.AssistantUserID;
  713. classmajor.Fixedclassroom = sc.Fixedclassroom;
  714. classmajor.Remark = sc.Remark;
  715. SetNewStatus(classmajor);
  716. if (!classmajorView.IsOverwrite)
  717. {
  718. var batch = BatchClassmajorList.Where(x => x.No == No && x.SchoolyearID == classmajorView.BatchSchoolyearID && x.GrademajorID == Class.GrademajorID).FirstOrDefault();
  719. if (batch == null)
  720. {
  721. ClassmajorList.Add(classmajor);
  722. }
  723. }
  724. else
  725. {
  726. var BatchClassmajorIDList = BatchClassmajorList.Select(x => x.ClassmajorID).ToList();
  727. List<Guid> ids = new List<Guid>();
  728. if (BatchClassmajorIDList.Count > 0)
  729. {
  730. foreach (var batch in BatchClassmajorIDList)
  731. {
  732. string BatchClassmajorID = batch.ToString();
  733. Guid id = new Guid(BatchClassmajorID);
  734. ids.Add(id);
  735. }
  736. UnitOfWork.Remove<CF_Classmajor>(x => ids.Contains(x.ClassmajorID));
  737. }
  738. ClassmajorList.Add(classmajor);
  739. }
  740. }
  741. }
  742. UnitOfWork.BulkInsert(ClassmajorList);
  743. UnitOfWork.Commit();
  744. int DefeatedCount = SourceClassmajorList.Count() - ClassmajorList.Count();
  745. int SuccessCount = SourceClassmajorList.Count() - DefeatedCount;
  746. int BatchClassmajorCount = BatchClassmajorList.Count();
  747. var result = "一共处理了" + SourceClassmajorList.Count() + "条数据,其中成功" + SuccessCount + "条,失败0条";
  748. if (DefeatedCount > 0 && BatchClassmajorCount == 0)
  749. {
  750. result = "一共处理了" + SourceClassmajorList.Count() + "条数据,其中成功" + SuccessCount + "条,失败" + DefeatedCount + "条,失败原因:没有对应的年级专业";
  751. }
  752. if (DefeatedCount > 0 && BatchClassmajorCount > 0)
  753. {
  754. DefeatedCount = SourceClassmajorList.Count() - BatchClassmajorCount;
  755. SuccessCount = SourceClassmajorList.Count() - BatchClassmajorCount - DefeatedCount;
  756. result = "一共处理了" + SourceClassmajorList.Count() + "条数据,其中成功" + SuccessCount + " 条,有" + BatchClassmajorCount + "条数据已存在,失败" + DefeatedCount + "条,失败原因:没有对应的年级专业。";
  757. }
  758. return result;
  759. }
  760. catch (Exception ex)
  761. {
  762. throw new Exception(ex.Message);
  763. }
  764. }
  765. /// <summary>
  766. /// 删除
  767. /// </summary>
  768. /// <param name="classmajorIDList"></param>
  769. /// <returns></returns>
  770. public bool ClassmajorDelete(IList<Guid?> classmajorIDList)
  771. {
  772. try
  773. {
  774. if (classmajorIDList.Count > 0)
  775. {
  776. UnitOfWork.Delete<CF_Classmajor>(x => classmajorIDList.Contains(x.ClassmajorID));
  777. }
  778. return true;
  779. }
  780. catch (Exception)
  781. {
  782. throw;
  783. }
  784. }
  785. /// <summary>
  786. /// 查询班级信息对应的学生信息BaseStudentView
  787. /// </summary>
  788. /// <param name="configuretView"></param>
  789. /// <param name="classmajorID"></param>
  790. /// <param name="inSchoolStatus"></param>
  791. /// <param name="pageIndex"></param>
  792. /// <param name="pageSize"></param>
  793. /// <returns></returns>
  794. public IGridResultSet<BaseStudentView> GetBaseStudentViewGrid(ConfiguretView configuretView, Guid? classmajorID,
  795. int? inSchoolStatus, int pageIndex, int pageSize)
  796. {
  797. //班级信息
  798. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  799. expClassmajor = expClassmajor.And(x => x.ClassmajorID == classmajorID);
  800. //学生信息
  801. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  802. var query = ClassmajorDAL.GetBaseStudentViewQueryable(expClassmajor, expStudent);
  803. //查询条件
  804. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  805. {
  806. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  807. }
  808. return query.OrderBy(x => x.LoginID)
  809. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  810. .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  811. }
  812. /// <summary>
  813. /// 查询班级信息对应的学生信息List
  814. /// </summary>
  815. /// <param name="configuretView"></param>
  816. /// <param name="classmajorID"></param>
  817. /// <param name="inSchoolStatus"></param>
  818. /// <returns></returns>
  819. public List<BaseStudentView> GetBaseStudentViewList(ConfiguretView configuretView, Guid? classmajorID, int? inSchoolStatus)
  820. {
  821. //班级信息
  822. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  823. expClassmajor = expClassmajor.And(x => x.ClassmajorID == classmajorID);
  824. //学生信息
  825. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  826. var query = ClassmajorDAL.GetBaseStudentViewQueryable(expClassmajor, expStudent);
  827. //查询条件
  828. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  829. {
  830. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  831. }
  832. return query.OrderBy(x => x.LoginID)
  833. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  834. .ToList();
  835. }
  836. /// <summary>
  837. /// 班级信息Excel导入
  838. /// </summary>
  839. /// <param name="cellheader"></param>
  840. /// <param name="inCount"></param>
  841. /// <param name="upCount"></param>
  842. /// <param name="errdataList"></param>
  843. /// <param name="errCount"></param>
  844. /// <param name="sourcePhysicalPath"></param>
  845. public void ClassmajorImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<ClassmajorView> errdataList, out int? errCount, string sourcePhysicalPath)
  846. {
  847. try
  848. {
  849. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  850. List<ClassmajorView> errList = new List<ClassmajorView>();
  851. // 1.1解析文件,存放到一个List集合里
  852. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  853. List<ClassmajorView> enlist = NpoiExcelHelper.ExcelToEntityList<ClassmajorView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  854. cellheader.Add("ErrorMessage", "未导入原因");
  855. //对List集合进行有效性校验
  856. if (enlist.Count() <= 0)
  857. {
  858. throw new Exception("Excel文件数据为空,请检查。");
  859. }
  860. Regex reg = null; //正则表达式
  861. //DateTime result; //用于返回判断日期字段格式
  862. inCount = 0; //导入个数
  863. upCount = 0; //更新个数
  864. errCount = 0; //失败个数
  865. string errorMsgStr = ""; //错误信息
  866. List<CF_Classmajor> newClassmajorInList = new List<CF_Classmajor>();
  867. List<CF_Classmajor> newClassmajorUpList = new List<CF_Classmajor>();
  868. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  869. //班级信息
  870. var classmajorList = ClassmajorDAL.ClassmajorRepository.GetList(x => true).ToList();
  871. //班级编号
  872. var classmajorNoList = enlist.Where(x => !string.IsNullOrEmpty(x.No)).Select(x => x.No).ToList();
  873. //班级名称
  874. var classmajorNameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList();
  875. //对比后的newClassmajorList
  876. var newClassmajorList = classmajorList
  877. .Where(x => classmajorNoList.Contains(x.No) || classmajorNameList.Contains(x.Name)).ToList();
  878. //年级专业信息
  879. var grademajorList = ClassmajorDAL.GrademajorRepository.GetList(x => true).ToList();
  880. //年级专业编号
  881. var grademajorCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.GrademajorCode)).Select(x => x.GrademajorCode).ToList();
  882. //对比后的newGrademajorList
  883. var newGrademajorList = grademajorList.Where(x => grademajorCodeList.Contains(x.Code)).ToList();
  884. //教职工信息
  885. var staffViewList = StaffServices.Value.GetListStaffView();
  886. //教职工姓名(暂时不考虑,教职工号不同,姓名相同的情况)
  887. var staffNameUList = enlist.Where(x => !string.IsNullOrEmpty(x.UserName)).Select(x => x.UserName).ToList();
  888. var staffNameAList = enlist.Where(x => !string.IsNullOrEmpty(x.AssistantUserName)).Select(x => x.AssistantUserName).ToList();
  889. //对比后的newStaffViewList
  890. var newStaffViewList = staffViewList
  891. .Where(x => staffNameUList.Contains(x.Name) || staffNameAList.Contains(x.Name)).ToList();
  892. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  893. for (int i = 0; i < enlist.Count; i++)
  894. {
  895. ClassmajorView en = enlist[i]; //Excel表数据视图
  896. CF_Classmajor newClassmajor = new CF_Classmajor();
  897. //班级编号
  898. if (string.IsNullOrEmpty(en.No))
  899. {
  900. errCount++;
  901. errorMsgStr = "班级编号不能为空";
  902. en.ErrorMessage = errorMsgStr;
  903. errList.Add(en);
  904. errorMsg.AppendLine(errorMsgStr);
  905. continue;
  906. }
  907. else
  908. {
  909. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  910. if (!reg.IsMatch(en.No))
  911. {
  912. errCount++;
  913. errorMsgStr = "班级编号格式不正确,请检查(数字或英文字母)";
  914. en.ErrorMessage = errorMsgStr;
  915. errList.Add(en);
  916. errorMsg.AppendLine(errorMsgStr);
  917. continue;
  918. }
  919. else
  920. {
  921. //班级编号
  922. newClassmajor.No = en.No.Trim();
  923. }
  924. }
  925. //班级名称
  926. if (string.IsNullOrEmpty(en.Name))
  927. {
  928. errCount++;
  929. errorMsgStr = "班级名称不能为空";
  930. en.ErrorMessage = errorMsgStr;
  931. errList.Add(en);
  932. errorMsg.AppendLine(errorMsgStr);
  933. continue;
  934. }
  935. else
  936. {
  937. //班级名称
  938. newClassmajor.Name = en.Name.Trim();
  939. }
  940. //简称
  941. if (string.IsNullOrEmpty(en.Abbreviation))
  942. {
  943. //不考虑
  944. }
  945. else
  946. {
  947. newClassmajor.Abbreviation = en.Abbreviation;
  948. }
  949. //英文名称
  950. if (string.IsNullOrEmpty(en.EnglishName))
  951. {
  952. //不考虑
  953. }
  954. else
  955. {
  956. newClassmajor.EnglishName = en.EnglishName;
  957. }
  958. //年级专业编号
  959. if (string.IsNullOrEmpty(en.GrademajorCode))
  960. {
  961. errCount++;
  962. errorMsgStr = "年级专业编号不能为空";
  963. en.ErrorMessage = errorMsgStr;
  964. errList.Add(en);
  965. errorMsg.AppendLine(errorMsgStr);
  966. continue;
  967. }
  968. else
  969. {
  970. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  971. if (!reg.IsMatch(en.GrademajorCode))
  972. {
  973. errCount++;
  974. errorMsgStr = "年级专业编号格式不正确,请检查(数字或英文字母)";
  975. en.ErrorMessage = errorMsgStr;
  976. errList.Add(en);
  977. errorMsg.AppendLine(errorMsgStr);
  978. continue;
  979. }
  980. else
  981. {
  982. var grademajor = newGrademajorList.Where(x => x.Code == en.GrademajorCode.Trim())
  983. .SingleOrDefault();
  984. if (grademajor == null)
  985. {
  986. errCount++;
  987. errorMsgStr = "年级专业编号不存在,请检查";
  988. en.ErrorMessage = errorMsgStr;
  989. errList.Add(en);
  990. errorMsg.AppendLine(errorMsgStr);
  991. continue;
  992. }
  993. else
  994. {
  995. //年级专业信息ID
  996. newClassmajor.GrademajorID = grademajor.GrademajorID;
  997. }
  998. }
  999. }
  1000. //班序
  1001. if (string.IsNullOrEmpty(en.ClassNumStr))
  1002. {
  1003. errCount++;
  1004. errorMsgStr = "班序不能为空";
  1005. en.ErrorMessage = errorMsgStr;
  1006. errList.Add(en);
  1007. errorMsg.AppendLine(errorMsgStr);
  1008. continue;
  1009. }
  1010. else
  1011. {
  1012. reg = new Regex(@"^[1-9]\d*|0$"); //班序字段正则表达式()
  1013. if (!reg.IsMatch(en.ClassNumStr))
  1014. {
  1015. errCount++;
  1016. errorMsgStr = "班序格式不正确,请检查(自然数)";
  1017. en.ErrorMessage = errorMsgStr;
  1018. errList.Add(en);
  1019. errorMsg.AppendLine(errorMsgStr);
  1020. continue;
  1021. }
  1022. else
  1023. {
  1024. //班序
  1025. newClassmajor.ClassNum = Convert.ToInt32(en.ClassNumStr);
  1026. }
  1027. }
  1028. //班主任
  1029. if (string.IsNullOrEmpty(en.UserName))
  1030. {
  1031. //不考虑
  1032. }
  1033. else
  1034. {
  1035. var staffViewByU = newStaffViewList.Where(x => x.Name == en.UserName.Trim())
  1036. .FirstOrDefault();
  1037. if (staffViewByU == null)
  1038. {
  1039. ////暂不考虑
  1040. //errCount++;
  1041. //errorMsgStr = "班主任不存在,请检查";
  1042. //en.ErrorMessage = errorMsgStr;
  1043. //errList.Add(en);
  1044. //errorMsg.AppendLine(errorMsgStr);
  1045. //continue;
  1046. }
  1047. else
  1048. {
  1049. //班主任
  1050. newClassmajor.UserID = staffViewByU.UserID;
  1051. }
  1052. }
  1053. //辅导员
  1054. if (string.IsNullOrEmpty(en.AssistantUserName))
  1055. {
  1056. //不考虑
  1057. }
  1058. else
  1059. {
  1060. var staffViewByA = newStaffViewList.Where(x => x.Name == en.AssistantUserName.Trim())
  1061. .FirstOrDefault();
  1062. if (staffViewByA == null)
  1063. {
  1064. ////暂不考虑
  1065. //errCount++;
  1066. //errorMsgStr = "辅导员不存在,请检查";
  1067. //en.ErrorMessage = errorMsgStr;
  1068. //errList.Add(en);
  1069. //errorMsg.AppendLine(errorMsgStr);
  1070. //continue;
  1071. }
  1072. else
  1073. {
  1074. //辅导员
  1075. newClassmajor.AssistantUserID = staffViewByA.UserID;
  1076. }
  1077. }
  1078. //固定教室
  1079. if (string.IsNullOrEmpty(en.Fixedclassroom))
  1080. {
  1081. //不考虑
  1082. }
  1083. else
  1084. {
  1085. newClassmajor.Fixedclassroom = en.Fixedclassroom;
  1086. }
  1087. //备注
  1088. if (string.IsNullOrEmpty(en.Remark))
  1089. {
  1090. //不考虑
  1091. }
  1092. else
  1093. {
  1094. newClassmajor.Remark = en.Remark;
  1095. }
  1096. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  1097. //for (int j = i + 1; j < enlist.Count; j++)
  1098. //{
  1099. // NewClassmajorView enA = enlist[j];
  1100. // //根据Excel表中的业务主键进行去重(班级编号或班级名称唯一)
  1101. // if (en.No == enA.No && en.Name == enA.Name)
  1102. // {
  1103. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  1104. // }
  1105. //}
  1106. //数据表重复性验证(班级编号或班级名称唯一)
  1107. var classmajorVerification = newClassmajorList
  1108. .Where(x => x.No == newClassmajor.No || x.Name == newClassmajor.Name)
  1109. .FirstOrDefault();
  1110. if (classmajorVerification == null)
  1111. {
  1112. //新增
  1113. if (!newClassmajorInList.Any(x => x.No == newClassmajor.No || x.Name == newClassmajor.Name))
  1114. {
  1115. //CF_Classmajor表
  1116. newClassmajor.ClassmajorID = Guid.NewGuid();
  1117. SetNewStatus(newClassmajor);
  1118. newClassmajorInList.Add(newClassmajor);
  1119. inCount++;
  1120. }
  1121. else
  1122. {
  1123. //Excel表重复性验证
  1124. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  1125. inCount++;
  1126. }
  1127. }
  1128. else
  1129. {
  1130. //更新(Excel有重复时,以最后一条记录的更新为准)
  1131. //注:暂时不更新对应的年级专业信息
  1132. //classmajorVerification.GrademajorID = newClassmajor.GrademajorID;
  1133. classmajorVerification.Abbreviation = newClassmajor.Abbreviation;
  1134. classmajorVerification.EnglishName = newClassmajor.EnglishName;
  1135. classmajorVerification.ClassNum = newClassmajor.ClassNum;
  1136. classmajorVerification.UserID = newClassmajor.UserID;
  1137. classmajorVerification.AssistantUserID = newClassmajor.AssistantUserID;
  1138. classmajorVerification.Fixedclassroom = newClassmajor.Fixedclassroom;
  1139. classmajorVerification.Remark = newClassmajor.Remark;
  1140. SetModifyStatus(classmajorVerification);
  1141. newClassmajorUpList.Add(classmajorVerification);
  1142. upCount++;
  1143. }
  1144. }
  1145. UnitOfWork.BulkInsert(newClassmajorInList); //批量插入
  1146. //批量统一提交更新
  1147. if (newClassmajorUpList != null && newClassmajorUpList.Count() > 0)
  1148. {
  1149. UnitOfWork.BatchUpdate(newClassmajorUpList);
  1150. }
  1151. errdataList = errList.Distinct().ToList(); //错误列表List
  1152. }
  1153. catch (Exception ex)
  1154. {
  1155. //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
  1156. throw new Exception(ex.Message);
  1157. }
  1158. }
  1159. }
  1160. }