FacultymajorServices.cs 55 KB

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