GraduateCardApplyServices.cs 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.GraduationManage.GraduateCardManage;
  12. using EMIS.ViewModel.ScoreManage;
  13. using EMIS.DataLogic.GraduationManage.GraduateCardManage;
  14. using EMIS.CommonLogic.SystemServices;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  17. namespace EMIS.CommonLogic.GraduationManage.GraduateCardManage
  18. {
  19. public class GraduateCardApplyServices : BaseWorkflowServices<ER_GraduateCardApply>, IGraduateCardApplyServices, IFileUploadServices
  20. {
  21. public GraduateCardApplyDAL GraduateCardApplyDAL { get; set; }
  22. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  23. public Lazy<IParameterServices> ParameterServices { get; set; }
  24. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  25. /// <summary>
  26. /// 查询去向申请信息View
  27. /// </summary>
  28. /// <param name="configuretView"></param>
  29. /// <param name="gradSchoolyearID"></param>
  30. /// <param name="campusID"></param>
  31. /// <param name="collegeID"></param>
  32. /// <param name="yearID"></param>
  33. /// <param name="standardID"></param>
  34. /// <param name="educationID"></param>
  35. /// <param name="learningformID"></param>
  36. /// <param name="learnSystem"></param>
  37. /// <param name="graduationTypeID"></param>
  38. /// <param name="inSchoolStatus"></param>
  39. /// <param name="approvalStatus"></param>
  40. /// <param name="pageIndex"></param>
  41. /// <param name="pageSize"></param>
  42. /// <returns></returns>
  43. public IGridResultSet<GraduateCardApplyView> GetGraduateCardApplyViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  44. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID,
  45. string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? approvalStatus, int pageIndex, int pageSize)
  46. {
  47. //结束流程环节ID
  48. var endStatusID = this.GetCorrectEndStatus();
  49. //审核流程状态IDList
  50. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  51. var applyStatusList = this.GetStatusViewList();
  52. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  53. .Select(x => x.ID).ToList();
  54. //去向申请
  55. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  56. expGraduateCardApply = expGraduateCardApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus));
  57. if (gradSchoolyearID.HasValue)
  58. {
  59. //毕业学期(实际的毕业学期)
  60. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  61. }
  62. if (graduationTypeID.HasValue)
  63. {
  64. //毕业类型
  65. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID);
  66. }
  67. if (approvalStatus.HasValue)
  68. {
  69. //审批状态
  70. expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus);
  71. }
  72. //学生信息
  73. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  74. if (inSchoolStatus != null && inSchoolStatus > -1)
  75. {
  76. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  77. if (inSchoolStatus == 1)
  78. {
  79. //表示在校
  80. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  81. }
  82. if (inSchoolStatus == 0)
  83. {
  84. //不在校
  85. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  86. }
  87. }
  88. var query = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent);
  89. if (campusID.HasValue)
  90. {
  91. query = query.Where(x => x.CampusID == campusID);
  92. }
  93. if (collegeID.HasValue)
  94. {
  95. query = query.Where(x => x.CollegeID == collegeID);
  96. }
  97. if (yearID.HasValue)
  98. {
  99. query = query.Where(x => x.SchoolyearID == yearID);
  100. }
  101. if (standardID.HasValue)
  102. {
  103. query = query.Where(x => x.StandardID == standardID);
  104. }
  105. if (educationID.HasValue)
  106. {
  107. query = query.Where(x => x.EducationID == educationID);
  108. }
  109. if (learningformID.HasValue)
  110. {
  111. query = query.Where(x => x.LearningformID == learningformID);
  112. }
  113. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  114. {
  115. var LearnSystems = Convert.ToDecimal(learnSystem);
  116. query = query.Where(x => x.LearnSystem == LearnSystems);
  117. }
  118. //查询条件
  119. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  120. {
  121. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  122. }
  123. var result = this.GetQueryByDataRangeByCollege(query)
  124. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  125. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  126. .ThenBy(x => x.GraduatingSemesterValue)
  127. .ToGridResultSet<GraduateCardApplyView>(pageIndex, pageSize);
  128. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  129. return result;
  130. }
  131. /// <summary>
  132. /// 查询去向申请信息List
  133. /// </summary>
  134. /// <param name="configuretView"></param>
  135. /// <param name="gradSchoolyearID"></param>
  136. /// <param name="campusID"></param>
  137. /// <param name="collegeID"></param>
  138. /// <param name="yearID"></param>
  139. /// <param name="standardID"></param>
  140. /// <param name="educationID"></param>
  141. /// <param name="learningformID"></param>
  142. /// <param name="learnSystem"></param>
  143. /// <param name="graduationTypeID"></param>
  144. /// <param name="inSchoolStatus"></param>
  145. /// <param name="approvalStatus"></param>
  146. /// <returns></returns>
  147. public IList<GraduateCardApplyView> GetGraduateCardApplyViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  148. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID,
  149. string learnSystem, int? graduationTypeID, int? inSchoolStatus, int? approvalStatus)
  150. {
  151. //结束流程环节ID
  152. var endStatusID = this.GetCorrectEndStatus();
  153. //审核流程状态IDList
  154. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  155. var applyStatusList = this.GetStatusViewList();
  156. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  157. .Select(x => x.ID).ToList();
  158. //去向申请
  159. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  160. expGraduateCardApply = expGraduateCardApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus));
  161. if (gradSchoolyearID.HasValue)
  162. {
  163. //毕业学期(实际的毕业学期)
  164. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  165. }
  166. if (graduationTypeID.HasValue)
  167. {
  168. //毕业类型
  169. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID);
  170. }
  171. if (approvalStatus.HasValue)
  172. {
  173. //审批状态
  174. expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus);
  175. }
  176. //学生信息
  177. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  178. if (inSchoolStatus != null && inSchoolStatus > -1)
  179. {
  180. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  181. if (inSchoolStatus == 1)
  182. {
  183. //表示在校
  184. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  185. }
  186. if (inSchoolStatus == 0)
  187. {
  188. //不在校
  189. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  190. }
  191. }
  192. var query = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent);
  193. if (campusID.HasValue)
  194. {
  195. query = query.Where(x => x.CampusID == campusID);
  196. }
  197. if (collegeID.HasValue)
  198. {
  199. query = query.Where(x => x.CollegeID == collegeID);
  200. }
  201. if (yearID.HasValue)
  202. {
  203. query = query.Where(x => x.SchoolyearID == yearID);
  204. }
  205. if (standardID.HasValue)
  206. {
  207. query = query.Where(x => x.StandardID == standardID);
  208. }
  209. if (educationID.HasValue)
  210. {
  211. query = query.Where(x => x.EducationID == educationID);
  212. }
  213. if (learningformID.HasValue)
  214. {
  215. query = query.Where(x => x.LearningformID == learningformID);
  216. }
  217. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  218. {
  219. var LearnSystems = Convert.ToDecimal(learnSystem);
  220. query = query.Where(x => x.LearnSystem == LearnSystems);
  221. }
  222. //查询条件
  223. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  224. {
  225. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  226. }
  227. var result = this.GetQueryByDataRangeByCollege(query)
  228. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  229. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  230. .ThenBy(x => x.GraduatingSemesterValue)
  231. .ToList();
  232. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  233. return result;
  234. }
  235. /// <summary>
  236. /// 查询对应的去向申请信息GraduateCardApplyView
  237. /// </summary>
  238. /// <param name="graduateCardApplyID"></param>
  239. /// <returns></returns>
  240. public GraduateCardApplyView GetGraduateCardApplyView(Guid? graduateCardApplyID)
  241. {
  242. try
  243. {
  244. var graduateCardApplyView = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(x => x.GraduateCardApplyID == graduateCardApplyID)
  245. .SingleOrDefault();
  246. return graduateCardApplyView;
  247. }
  248. catch (Exception ex)
  249. {
  250. throw new Exception(ex.Message);
  251. }
  252. }
  253. /// <summary>
  254. /// 名单生成(新增、修改)
  255. /// 新增包括:毕业学期小于等于当前启用的毕业学期、学籍信息为在校(排除在校状态为结业、毕业的信息)、在毕业申请允许最大年限(年)范围内
  256. /// 修改:未提交
  257. /// 业务主键:学生信息ID、毕业学期ID(实际的毕业学期)
  258. /// </summary>
  259. /// <returns></returns>
  260. public string GraduateCardApplyEdit()
  261. {
  262. try
  263. {
  264. //查询对应的工作流程环节状态信息View
  265. var approveStatusList = this.GetStatusViewList();
  266. if (approveStatusList == null || approveStatusList.Count() <= 0)
  267. {
  268. throw new Exception("工作流平台中,毕业去向流程未配置,请核查。");
  269. }
  270. //查询工作流程开始环节状态
  271. var approveStartStatusID = this.GetStartStatus();
  272. if (approveStartStatusID == null)
  273. {
  274. throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。");
  275. }
  276. //查询工作流程结束环节状态
  277. var approveEndStatusID = this.GetCorrectEndStatus();
  278. if (approveEndStatusID == null)
  279. {
  280. throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。");
  281. }
  282. //查询工作流程审核流程状态IDList
  283. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  284. var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID))
  285. .Select(x => x.ID).ToList();
  286. //查询培养类型设置信息List
  287. var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository
  288. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  289. if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0)
  290. {
  291. throw new Exception("培养类型设置未设置,请设置。");
  292. }
  293. //查询设置的毕业学期信息
  294. var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear);
  295. if (!string.IsNullOrEmpty(graduatingSemesterID))
  296. {
  297. var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID));
  298. if (graSchoolYearView == null)
  299. {
  300. throw new Exception("毕业学期设置有误,请重新设置。");
  301. }
  302. //查询设置的毕业申请允许最大年限(年)
  303. var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit);
  304. if (setGraduationApplyMaxAgeLimit == null)
  305. {
  306. throw new Exception("未设置毕业申请允许最大年限(年),请设置。");
  307. }
  308. var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit);
  309. //学生信息
  310. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  311. //在校状态
  312. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  313. //表示在校
  314. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  315. //排除在校状态为毕业的信息
  316. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation);
  317. //排除在校状态为结业的信息
  318. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete);
  319. //毕业学期
  320. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  321. //应届、往届毕业(小于等于当前启用的毕业学期)
  322. expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value);
  323. //去向申请(需排除的信息)
  324. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  325. //去向申请中待审核、已通过状态
  326. expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus)
  327. || x.ApprovalStatus == approveEndStatusID);
  328. //查询对应的毕业学生信息ViewList(注:数据范围)
  329. var query = GraduateCardApplyDAL.GetGraduationStudentViewQueryable(expStudent, expSchoolyear,
  330. expGraduateCardApply, graSchoolYearView.SchoolYearID);
  331. //在毕业申请允许最大年限(年)范围内
  332. query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit);
  333. //匹配对应的数据范围
  334. var graduationStudentViewList = this.GetQueryByDataRangeByCollege(query).ToList();
  335. //对应的学生信息IDList
  336. var userIDList = graduationStudentViewList.Select(x => x.UserID).ToList();
  337. //查询去向申请信息graduateCardApplyList
  338. var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository.GetList(x => true).ToList();
  339. //匹配对应的条件查询
  340. graduateCardApplyList = graduateCardApplyList.Where(x => userIDList.Contains(x.UserID)).ToList();
  341. int insert = 0;
  342. int update = 0;
  343. string tipMessage = null;
  344. List<ER_GraduateCardApply> graduateCardApplyInList = new List<ER_GraduateCardApply>();
  345. List<ER_GraduateCardApply> graduateCardApplyUpList = new List<ER_GraduateCardApply>();
  346. foreach (var graduationStudentView in graduationStudentViewList)
  347. {
  348. //根据对应的信息查询去向申请信息
  349. var graduateCardApply = graduateCardApplyList.Where(x => x.UserID == graduationStudentView.UserID
  350. && x.GraduatingSemesterID == graSchoolYearView.SchoolYearID)
  351. .SingleOrDefault();
  352. if (graduateCardApply == null)
  353. {
  354. //新增
  355. ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply();
  356. newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid();
  357. newGraduateCardApply.UserID = graduationStudentView.UserID;
  358. if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value)
  359. {
  360. //应届
  361. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh;
  362. }
  363. else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value)
  364. {
  365. //往届
  366. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former;
  367. }
  368. else
  369. {
  370. //提前
  371. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance;
  372. }
  373. newGraduateCardApply.GraduatingSemesterID = graSchoolYearView.SchoolYearID;
  374. newGraduateCardApply.NeedCardResult = null;
  375. newGraduateCardApply.ApprovalStatus = approveStartStatusID;
  376. newGraduateCardApply.Remark = null;
  377. SetNewStatus(newGraduateCardApply);
  378. graduateCardApplyInList.Add(newGraduateCardApply);
  379. insert++;
  380. }
  381. else
  382. {
  383. //表示修改(只处理未提交状态)if (applyStatusIDList.Any(x => x == graduateCardApply.ApprovalStatus))
  384. if (graduateCardApply.ApprovalStatus == approveStartStatusID)
  385. {
  386. if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value)
  387. {
  388. //应届
  389. graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh;
  390. }
  391. else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value)
  392. {
  393. //往届
  394. graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former;
  395. }
  396. else
  397. {
  398. //提前
  399. graduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance;
  400. }
  401. graduateCardApply.NeedCardResult = null;
  402. SetModifyStatus(graduateCardApply);
  403. graduateCardApplyUpList.Add(graduateCardApply);
  404. update++;
  405. }
  406. }
  407. }
  408. //批量插入
  409. UnitOfWork.BulkInsert<ER_GraduateCardApply>(graduateCardApplyInList);
  410. if (graduateCardApplyUpList != null && graduateCardApplyUpList.Count() > 0)
  411. {
  412. //批量更新
  413. UnitOfWork.BatchUpdate<ER_GraduateCardApply>(graduateCardApplyUpList);
  414. }
  415. if (insert > 0 && update <= 0)
  416. {
  417. tipMessage = insert + "条";
  418. }
  419. else
  420. {
  421. tipMessage = insert + "条,更新成功" + update + "条";
  422. }
  423. return tipMessage;
  424. }
  425. else
  426. {
  427. throw new Exception("未设置毕业学期,请设置。");
  428. }
  429. }
  430. catch (Exception ex)
  431. {
  432. throw new Exception(ex.Message);
  433. }
  434. }
  435. /// <summary>
  436. /// 查询对应的附件文件(根据外键表ID)
  437. /// </summary>
  438. /// <param name="formID"></param>
  439. /// <returns></returns>
  440. public List<FileUploadView> GetFileList(Guid? formID)
  441. {
  442. var query = GraduateCardApplyDAL.GetGraduateCardApplyAttachmentQueryable(x => x.GraduateCardApplyID == formID).ToList();
  443. return query;
  444. }
  445. /// <summary>
  446. /// 编辑(新增、修改,业务主键:学生信息ID、毕业学期ID(实际的毕业学期))
  447. /// </summary>
  448. /// <param name="graduateCardApplyView"></param>
  449. /// <param name="fileList"></param>
  450. public void GraduateCardApplyEdit(GraduateCardApplyView graduateCardApplyView, List<FileUploadView> fileList)
  451. {
  452. try
  453. {
  454. //查询对应的工作流程环节状态信息View
  455. var approveStatusList = this.GetStatusViewList();
  456. if (approveStatusList == null || approveStatusList.Count() <= 0)
  457. {
  458. throw new Exception("工作流平台中,毕业去向流程未配置,请核查。");
  459. }
  460. //查询工作流程开始环节状态
  461. var approveStartStatus = this.GetStartStatus();
  462. if (approveStartStatus == null)
  463. {
  464. throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。");
  465. }
  466. //结束流程环节ID
  467. var endStatusID = this.GetCorrectEndStatus();
  468. if (endStatusID == null)
  469. {
  470. throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。");
  471. }
  472. //审核流程状态IDList
  473. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  474. var applyStatusIDList = approveStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  475. .Select(x => x.ID).ToList();
  476. //查询培养类型设置信息List
  477. var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository
  478. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  479. if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0)
  480. {
  481. throw new Exception("培养类型设置未设置,请设置。");
  482. }
  483. //查询数据库进行验证
  484. var graduateCardApplyVerification = GraduateCardApplyDAL.GraduateCardApplyRepository
  485. .GetList(x => x.GraduateCardApplyID != graduateCardApplyView.GraduateCardApplyID
  486. && x.UserID == graduateCardApplyView.UserID
  487. && x.GraduatingSemesterID == graduateCardApplyView.GraduatingSemesterID)
  488. .SingleOrDefault();
  489. if (graduateCardApplyVerification == null)
  490. {
  491. //数据有误验证
  492. if (graduateCardApplyView.GraduateCardApplyID != Guid.Empty)
  493. {
  494. var graduateCardApply = GraduateCardApplyDAL.GraduateCardApplyRepository
  495. .GetList(x => x.GraduateCardApplyID == graduateCardApplyView.GraduateCardApplyID,
  496. (x => x.ER_GraduateCardApplyAttachment)).SingleOrDefault();
  497. if (graduateCardApply == null)
  498. {
  499. throw new Exception("数据有误,请核查。");
  500. }
  501. else
  502. {
  503. //表示修改
  504. if (applyStatusIDList.Any(x => x == graduateCardApply.ApprovalStatus))
  505. {
  506. graduateCardApply.GraduationTypeID = graduateCardApplyView.GraduationTypeID;
  507. graduateCardApply.Remark = graduateCardApplyView.Remark;
  508. SetModifyStatus(graduateCardApply);
  509. }
  510. else
  511. {
  512. throw new Exception("数据有误,请核查(只能修改未提交、已退回状态的信息)。");
  513. }
  514. }
  515. }
  516. else
  517. {
  518. //表示新增
  519. ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply();
  520. newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid();
  521. newGraduateCardApply.UserID = graduateCardApplyView.UserID;
  522. newGraduateCardApply.GraduationTypeID = graduateCardApplyView.GraduationTypeID;
  523. newGraduateCardApply.GraduatingSemesterID = graduateCardApplyView.GraduatingSemesterID;
  524. newGraduateCardApply.NeedCardResult = null;
  525. newGraduateCardApply.ApprovalStatus = approveStartStatus;
  526. newGraduateCardApply.Remark = graduateCardApplyView.Remark;
  527. SetNewStatus(newGraduateCardApply);
  528. UnitOfWork.Add(newGraduateCardApply);
  529. }
  530. }
  531. else
  532. {
  533. throw new Exception("已存在相同的去向申请信息,请核查。");
  534. }
  535. //事务提交
  536. UnitOfWork.Commit();
  537. }
  538. catch (Exception ex)
  539. {
  540. throw new Exception(ex.Message);
  541. }
  542. }
  543. /// <summary>
  544. /// 去向申请批量新增(业务主键:学生信息ID、毕业学期ID(实际的毕业学期))
  545. /// </summary>
  546. /// <param name="graduationStudentViewList"></param>
  547. /// <param name="graduateCardApplyView"></param>
  548. /// <returns></returns>
  549. public string GraduateCardApplyBatchAdd(List<GraduateCardApplyView> graduationStudentViewList, GraduateCardApplyView graduateCardApplyView)
  550. {
  551. try
  552. {
  553. //查询对应的工作流程环节状态信息View
  554. var approveStatusList = this.GetStatusViewList();
  555. if (approveStatusList == null || approveStatusList.Count() <= 0)
  556. {
  557. throw new Exception("工作流平台中,毕业去向流程未配置,请核查。");
  558. }
  559. //查询工作流程开始环节状态
  560. var approveStartStatusID = this.GetStartStatus();
  561. if (approveStartStatusID == null)
  562. {
  563. throw new Exception("工作流平台中,毕业去向流程开始环节未配置,请核查。");
  564. }
  565. //查询工作流程结束环节状态
  566. var approveEndStatusID = this.GetCorrectEndStatus();
  567. if (approveEndStatusID == null)
  568. {
  569. throw new Exception("工作流平台中,毕业去向流程结束环节未配置,请核查。");
  570. }
  571. //查询培养类型设置信息List
  572. var educationTypeSettingList = GraduateCardApplyDAL.EducationTypeSettingRepository
  573. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  574. if (educationTypeSettingList == null || educationTypeSettingList.Count() <= 0)
  575. {
  576. throw new Exception("培养类型设置未设置,请设置。");
  577. }
  578. //查询设置的毕业学期信息
  579. var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear);
  580. if (!string.IsNullOrEmpty(graduatingSemesterID))
  581. {
  582. var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID));
  583. if (graSchoolYearView == null)
  584. {
  585. throw new Exception("毕业学期设置有误,请重新设置。");
  586. }
  587. //查询设置的毕业申请允许最大年限(年)
  588. var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit);
  589. if (setGraduationApplyMaxAgeLimit == null)
  590. {
  591. throw new Exception("未设置毕业申请允许最大年限(年),请设置。");
  592. }
  593. //查询去向申请信息graduationApplyList
  594. var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository.GetList(x => true).ToList();
  595. //查询对应的学生信息userIDList
  596. var userIDList = graduationStudentViewList.Where(x => !string.IsNullOrEmpty(x.UserID.ToString()))
  597. .Select(x => x.UserID).ToList();
  598. //匹配对应的条件查询
  599. graduateCardApplyList = graduateCardApplyList.Where(x => userIDList.Contains(x.UserID)).ToList();
  600. int success = 0; //成功
  601. int fail = 0; //失败
  602. string tipMessage = null; //提示消息
  603. List<ER_GraduateCardApply> graduateCardApplyInList = new List<ER_GraduateCardApply>();
  604. foreach (var graduationStudentView in graduationStudentViewList)
  605. {
  606. //根据对应的信息查询去向申请信息(业务主键:学生信息ID、毕业学期ID(实际的毕业学期))
  607. var graduateCardApply = graduateCardApplyList.Where(x => x.UserID == graduationStudentView.UserID
  608. && x.GraduatingSemesterID == graSchoolYearView.SchoolYearID)
  609. .SingleOrDefault();
  610. if (graduateCardApply == null)
  611. {
  612. //新增
  613. ER_GraduateCardApply newGraduateCardApply = new ER_GraduateCardApply();
  614. newGraduateCardApply.GraduateCardApplyID = Guid.NewGuid();
  615. newGraduateCardApply.UserID = graduationStudentView.UserID;
  616. if (graduationStudentView.GraduatingSemesterValue == graSchoolYearView.Value)
  617. {
  618. //应届
  619. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Fresh;
  620. }
  621. else if (graduationStudentView.GraduatingSemesterValue < graSchoolYearView.Value)
  622. {
  623. //往届
  624. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Former;
  625. }
  626. else
  627. {
  628. //提前
  629. newGraduateCardApply.GraduationTypeID = (int)ER_GraduationType.Advance;
  630. }
  631. newGraduateCardApply.GraduatingSemesterID = graSchoolYearView.SchoolYearID;
  632. newGraduateCardApply.NeedCardResult = null;
  633. newGraduateCardApply.ApprovalStatus = approveStartStatusID;
  634. newGraduateCardApply.Remark = null;
  635. SetNewStatus(newGraduateCardApply);
  636. graduateCardApplyInList.Add(newGraduateCardApply);
  637. success++;
  638. }
  639. else
  640. {
  641. //表示已存在相同的去向申请信息
  642. fail++;
  643. }
  644. }
  645. //批量插入
  646. UnitOfWork.BulkInsert<ER_GraduateCardApply>(graduateCardApplyInList);
  647. if (success > 0 && fail <= 0)
  648. {
  649. tipMessage = success + "条";
  650. }
  651. else
  652. {
  653. tipMessage = success + "条,失败" + fail + "条,原因:已存在相同的去向申请信息,请检查";
  654. }
  655. return tipMessage;
  656. }
  657. else
  658. {
  659. throw new Exception("未设置毕业学期,请设置。");
  660. }
  661. }
  662. catch (Exception ex)
  663. {
  664. throw new Exception(ex.Message);
  665. }
  666. }
  667. /// <summary>
  668. /// 查询未新增毕业学生信息GraduateCardApplyView
  669. /// </summary>
  670. /// <param name="configuretView"></param>
  671. /// <param name="campusID"></param>
  672. /// <param name="collegeID"></param>
  673. /// <param name="schoolyearID"></param>
  674. /// <param name="standardID"></param>
  675. /// <param name="educationID"></param>
  676. /// <param name="learningformID"></param>
  677. /// <param name="learnSystem"></param>
  678. /// <param name="inSchoolStatus"></param>
  679. /// <param name="gradSchoolyearID"></param>
  680. /// <param name="pageIndex"></param>
  681. /// <param name="pageSize"></param>
  682. /// <returns></returns>
  683. public IGridResultSet<GraduateCardApplyView> GetGraduationStudentNoAddViewGrid(ConfiguretView configuretView, Guid? campusID,
  684. Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  685. int? inSchoolStatus, Guid? gradSchoolyearID, int pageIndex, int pageSize)
  686. {
  687. //查询对应的工作流程环节状态信息View
  688. var approveStatusList = this.GetStatusViewList();
  689. //查询工作流程结束环节状态
  690. var approveEndStatusID = this.GetCorrectEndStatus();
  691. //查询工作流程审核流程状态IDList
  692. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  693. var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID))
  694. .Select(x => x.ID).ToList();
  695. //查询设置的毕业学期信息
  696. var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear);
  697. //查询毕业学期对应的学年学期信息graSchoolYearView
  698. var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID));
  699. //查询设置的毕业申请允许最大年限(年)
  700. var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit);
  701. var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit);
  702. //学生信息
  703. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  704. if (inSchoolStatus != null && inSchoolStatus > -1)
  705. {
  706. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  707. if (inSchoolStatus == 1)
  708. {
  709. //表示在校
  710. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  711. }
  712. if (inSchoolStatus == 0)
  713. {
  714. //不在校
  715. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  716. }
  717. }
  718. //排除在校状态为毕业的信息
  719. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation);
  720. //排除在校状态为结业的信息
  721. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete);
  722. //毕业学期
  723. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  724. //应届、往届毕业(小于等于当前启用的毕业学期)
  725. expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value);
  726. //去向申请(需排除的信息)
  727. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  728. //去向申请中待审核、已通过状态
  729. expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus)
  730. || x.ApprovalStatus == approveEndStatusID);
  731. //查询对应的毕业学生信息ViewList(注:数据范围)
  732. var query = GraduateCardApplyDAL.GetGraduationStudentNoAddViewQueryable(expStudent, expSchoolyear,
  733. expGraduateCardApply, graSchoolYearView.SchoolYearID);
  734. //在毕业申请允许最大年限(年)范围内
  735. query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit);
  736. if (campusID.HasValue)
  737. {
  738. query = query.Where(x => x.CampusID == campusID);
  739. }
  740. if (collegeID.HasValue)
  741. {
  742. query = query.Where(x => x.CollegeID == collegeID);
  743. }
  744. if (schoolyearID.HasValue)
  745. {
  746. query = query.Where(x => x.SchoolyearID == schoolyearID);
  747. }
  748. if (standardID.HasValue)
  749. {
  750. query = query.Where(x => x.StandardID == standardID);
  751. }
  752. if (educationID.HasValue)
  753. {
  754. query = query.Where(x => x.EducationID == educationID);
  755. }
  756. if (learningformID.HasValue)
  757. {
  758. query = query.Where(x => x.LearningformID == learningformID);
  759. }
  760. if (gradSchoolyearID.HasValue)
  761. {
  762. //预毕业学期
  763. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  764. }
  765. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  766. {
  767. var LearnSystems = Convert.ToDecimal(learnSystem);
  768. query = query.Where(x => x.LearnSystem == LearnSystems);
  769. }
  770. //查询条件
  771. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  772. {
  773. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  774. }
  775. return this.GetQueryByDataRangeByCollege(query)
  776. .OrderBy(x => x.ClassNo.Length)
  777. .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length)
  778. .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue)
  779. .ToGridResultSet<GraduateCardApplyView>(pageIndex, pageSize);
  780. }
  781. /// <summary>
  782. /// 查询未新增毕业学生信息List
  783. /// </summary>
  784. /// <param name="configuretView"></param>
  785. /// <param name="campusID"></param>
  786. /// <param name="collegeID"></param>
  787. /// <param name="schoolyearID"></param>
  788. /// <param name="standardID"></param>
  789. /// <param name="educationID"></param>
  790. /// <param name="learningformID"></param>
  791. /// <param name="learnSystem"></param>
  792. /// <param name="inSchoolStatus"></param>
  793. /// <param name="gradSchoolyearID"></param>
  794. /// <returns></returns>
  795. public IList<GraduateCardApplyView> GetGraduationStudentNoAddViewList(ConfiguretView configuretView, Guid? campusID,
  796. Guid? collegeID, int? schoolyearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  797. int? inSchoolStatus, Guid? gradSchoolyearID)
  798. {
  799. //查询对应的工作流程环节状态信息View
  800. var approveStatusList = this.GetStatusViewList();
  801. //查询工作流程结束环节状态
  802. var approveEndStatusID = this.GetCorrectEndStatus();
  803. //查询工作流程审核流程状态IDList
  804. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  805. var applyStatusIDList = approveStatusList.Where(x => x.ID != approveEndStatusID && !approveStatusIDList.Contains(x.ID))
  806. .Select(x => x.ID).ToList();
  807. //查询设置的毕业学期信息
  808. var graduatingSemesterID = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationSchoolyear);
  809. //查询毕业学期对应的学年学期信息graSchoolYearView
  810. var graSchoolYearView = SchoolYearServices.Value.GetSchoolYearView(Guid.Parse(graduatingSemesterID));
  811. //查询设置的毕业申请允许最大年限(年)
  812. var setGraduationApplyMaxAgeLimit = ParameterServices.Value.GetParameterValue(CF_ParameterType.GraduationApplyMaxAgeLimit);
  813. var graduationApplyMaxAgeLimit = Convert.ToDecimal(setGraduationApplyMaxAgeLimit);
  814. //学生信息
  815. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  816. if (inSchoolStatus != null && inSchoolStatus > -1)
  817. {
  818. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  819. if (inSchoolStatus == 1)
  820. {
  821. //表示在校
  822. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  823. }
  824. if (inSchoolStatus == 0)
  825. {
  826. //不在校
  827. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  828. }
  829. }
  830. //排除在校状态为毕业的信息
  831. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Graduation);
  832. //排除在校状态为结业的信息
  833. expStudent = expStudent.And(x => x.InSchoolStatusID != (int)CF_InschoolStatus.Complete);
  834. //毕业学期
  835. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  836. //应届、往届毕业(小于等于当前启用的毕业学期)
  837. expSchoolyear = expSchoolyear.And(x => x.Value <= graSchoolYearView.Value);
  838. //去向申请(需排除的信息)
  839. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  840. //去向申请中待审核、已通过状态
  841. expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus)
  842. || x.ApprovalStatus == approveEndStatusID);
  843. //查询对应的毕业学生信息ViewList(注:数据范围)
  844. var query = GraduateCardApplyDAL.GetGraduationStudentNoAddViewQueryable(expStudent, expSchoolyear,
  845. expGraduateCardApply, graSchoolYearView.SchoolYearID);
  846. //在毕业申请允许最大年限(年)范围内
  847. query = query.Where(x => x.GraduationAgeLimitValue <= graduationApplyMaxAgeLimit);
  848. if (campusID.HasValue)
  849. {
  850. query = query.Where(x => x.CampusID == campusID);
  851. }
  852. if (collegeID.HasValue)
  853. {
  854. query = query.Where(x => x.CollegeID == collegeID);
  855. }
  856. if (schoolyearID.HasValue)
  857. {
  858. query = query.Where(x => x.SchoolyearID == schoolyearID);
  859. }
  860. if (standardID.HasValue)
  861. {
  862. query = query.Where(x => x.StandardID == standardID);
  863. }
  864. if (educationID.HasValue)
  865. {
  866. query = query.Where(x => x.EducationID == educationID);
  867. }
  868. if (learningformID.HasValue)
  869. {
  870. query = query.Where(x => x.LearningformID == learningformID);
  871. }
  872. if (gradSchoolyearID.HasValue)
  873. {
  874. //预毕业学期
  875. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  876. }
  877. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  878. {
  879. var LearnSystems = Convert.ToDecimal(learnSystem);
  880. query = query.Where(x => x.LearnSystem == LearnSystems);
  881. }
  882. //查询条件
  883. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  884. {
  885. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  886. }
  887. return this.GetQueryByDataRangeByCollege(query)
  888. .OrderBy(x => x.ClassNo.Length)
  889. .ThenBy(x => x.ClassNo).ThenBy(x => x.StudentNo.Length)
  890. .ThenBy(x => x.StudentNo).ThenBy(x => x.GraduatingSemesterValue)
  891. .ToList();
  892. }
  893. /// <summary>
  894. /// 删除
  895. /// </summary>
  896. /// <param name="graduateCardApplyIDs"></param>
  897. /// <returns></returns>
  898. public bool GraduateCardApplyDelete(List<Guid?> graduateCardApplyIDs)
  899. {
  900. try
  901. {
  902. using (TransactionScope ts = new TransactionScope())
  903. {
  904. UnitOfWork.Delete<ER_GraduateCardApplyAttachment>(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID));
  905. UnitOfWork.Delete<ER_GraduateCardApply>(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID));
  906. ts.Complete();
  907. return true;
  908. }
  909. }
  910. catch (Exception)
  911. {
  912. throw;
  913. }
  914. }
  915. /// <summary>
  916. /// 查询去向申请对应的学生最终成绩信息FinallyScoreView
  917. /// </summary>
  918. /// <param name="configuretView"></param>
  919. /// <param name="graduateCardApplyID"></param>
  920. /// <param name="schoolyearID"></param>
  921. /// <param name="courseTypeID"></param>
  922. /// <param name="courseSelectTypeID"></param>
  923. /// <param name="examsCategoryID"></param>
  924. /// <param name="starttermID"></param>
  925. /// <param name="isMainCourse"></param>
  926. /// <param name="handleModeID"></param>
  927. /// <param name="isExecutablePlan"></param>
  928. /// <param name="executablePlanStatus"></param>
  929. /// <param name="pageIndex"></param>
  930. /// <param name="pageSize"></param>
  931. /// <returns></returns>
  932. public IGridResultSet<FinallyScoreView> GetFinallyScoreViewGrid(ConfiguretView configuretView, Guid? graduateCardApplyID, Guid? schoolyearID,
  933. int? courseTypeID, int? courseSelectTypeID, int? examsCategoryID, int? starttermID, int? isMainCourse, int? handleModeID,
  934. int? isExecutablePlan, int? executablePlanStatus, int pageIndex, int pageSize)
  935. {
  936. //去向申请
  937. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  938. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduateCardApplyID == graduateCardApplyID);
  939. var query = GraduateCardApplyDAL.GetFinallyScoreViewQueryable(expGraduateCardApply);
  940. if (schoolyearID.HasValue)
  941. {
  942. query = query.Where(x => x.SchoolyearID == schoolyearID);
  943. }
  944. if (courseTypeID.HasValue)
  945. {
  946. query = query.Where(x => x.CourseTypeID == courseTypeID);
  947. }
  948. if (courseSelectTypeID.HasValue)
  949. {
  950. query = query.Where(x => x.CourseSelectTypeID == courseSelectTypeID);
  951. }
  952. if (examsCategoryID.HasValue)
  953. {
  954. query = query.Where(x => x.ExamsCategoryID == examsCategoryID);
  955. }
  956. if (starttermID.HasValue)
  957. {
  958. query = query.Where(x => x.StarttermID == starttermID);
  959. }
  960. if (isMainCourse.HasValue)
  961. {
  962. //可否学位课程
  963. if (isMainCourse.Value == (int)CF_GeneralPurpose.IsYes)
  964. {
  965. query = query.Where(x => x.IsMainCourse == true);
  966. }
  967. if (isMainCourse.Value == (int)CF_GeneralPurpose.IsNo)
  968. {
  969. query = query.Where(x => x.IsMainCourse != true);
  970. }
  971. }
  972. if (handleModeID.HasValue)
  973. {
  974. query = query.Where(x => x.HandleModeID == handleModeID);
  975. }
  976. if (isExecutablePlan.HasValue)
  977. {
  978. //是否计划(执行计划)
  979. if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsYes)
  980. {
  981. query = query.Where(x => x.IsExecutablePlan == true);
  982. }
  983. if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsNo)
  984. {
  985. query = query.Where(x => x.IsExecutablePlan != true);
  986. }
  987. }
  988. if (executablePlanStatus.HasValue)
  989. {
  990. //执行计划状态
  991. query = query.Where(x => x.ExecutablePlanStatus == executablePlanStatus);
  992. }
  993. //查询条件
  994. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  995. {
  996. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  997. }
  998. return this.GetQueryByDataRangeByCollege(query)
  999. .OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode)
  1000. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  1001. .ToGridResultSet<FinallyScoreView>(pageIndex, pageSize);
  1002. }
  1003. /// <summary>
  1004. /// 查询去向申请对应的学生最终成绩信息List
  1005. /// </summary>
  1006. /// <param name="configuretView"></param>
  1007. /// <param name="graduateCardApplyID"></param>
  1008. /// <param name="schoolyearID"></param>
  1009. /// <param name="courseTypeID"></param>
  1010. /// <param name="courseSelectTypeID"></param>
  1011. /// <param name="examsCategoryID"></param>
  1012. /// <param name="starttermID"></param>
  1013. /// <param name="isMainCourse"></param>
  1014. /// <param name="handleModeID"></param>
  1015. /// <param name="isExecutablePlan"></param>
  1016. /// <param name="executablePlanStatus"></param>
  1017. /// <returns></returns>
  1018. public IList<FinallyScoreView> GetFinallyScoreViewList(ConfiguretView configuretView, Guid? graduateCardApplyID, Guid? schoolyearID,
  1019. int? courseTypeID, int? courseSelectTypeID, int? examsCategoryID, int? starttermID, int? isMainCourse, int? handleModeID,
  1020. int? isExecutablePlan, int? executablePlanStatus)
  1021. {
  1022. //去向申请
  1023. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1024. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduateCardApplyID == graduateCardApplyID);
  1025. var query = GraduateCardApplyDAL.GetFinallyScoreViewQueryable(expGraduateCardApply);
  1026. if (schoolyearID.HasValue)
  1027. {
  1028. query = query.Where(x => x.SchoolyearID == schoolyearID);
  1029. }
  1030. if (courseTypeID.HasValue)
  1031. {
  1032. query = query.Where(x => x.CourseTypeID == courseTypeID);
  1033. }
  1034. if (courseSelectTypeID.HasValue)
  1035. {
  1036. query = query.Where(x => x.CourseSelectTypeID == courseSelectTypeID);
  1037. }
  1038. if (examsCategoryID.HasValue)
  1039. {
  1040. query = query.Where(x => x.ExamsCategoryID == examsCategoryID);
  1041. }
  1042. if (starttermID.HasValue)
  1043. {
  1044. query = query.Where(x => x.StarttermID == starttermID);
  1045. }
  1046. if (isMainCourse.HasValue)
  1047. {
  1048. //可否学位课程
  1049. if (isMainCourse.Value == (int)CF_GeneralPurpose.IsYes)
  1050. {
  1051. query = query.Where(x => x.IsMainCourse == true);
  1052. }
  1053. if (isMainCourse.Value == (int)CF_GeneralPurpose.IsNo)
  1054. {
  1055. query = query.Where(x => x.IsMainCourse != true);
  1056. }
  1057. }
  1058. if (handleModeID.HasValue)
  1059. {
  1060. query = query.Where(x => x.HandleModeID == handleModeID);
  1061. }
  1062. if (isExecutablePlan.HasValue)
  1063. {
  1064. //是否计划(执行计划)
  1065. if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsYes)
  1066. {
  1067. query = query.Where(x => x.IsExecutablePlan == true);
  1068. }
  1069. if (isExecutablePlan.Value == (int)CF_GeneralPurpose.IsNo)
  1070. {
  1071. query = query.Where(x => x.IsExecutablePlan != true);
  1072. }
  1073. }
  1074. if (executablePlanStatus.HasValue)
  1075. {
  1076. //执行计划状态
  1077. query = query.Where(x => x.ExecutablePlanStatus == executablePlanStatus);
  1078. }
  1079. //查询条件
  1080. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1081. {
  1082. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1083. }
  1084. return this.GetQueryByDataRangeByCollege(query)
  1085. .OrderBy(x => x.SchoolyearCode.Length).ThenBy(x => x.SchoolyearCode)
  1086. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  1087. .ToList();
  1088. }
  1089. /// <summary>
  1090. /// 流程已退回跳转函数(工作流平台中配置)
  1091. /// </summary>
  1092. /// <param name="graduateCardApplyIDList"></param>
  1093. /// <param name="userID"></param>
  1094. public void OnApproveReturn(List<Guid> graduateCardApplyIDList, Guid? userID)
  1095. {
  1096. //查询对应的去向申请信息List
  1097. var graduateCardApplyList = GraduateCardApplyDAL.GraduateCardApplyRepository
  1098. .GetList(x => graduateCardApplyIDList.Contains(x.GraduateCardApplyID)).ToList();
  1099. //更新对应的去向申请信息
  1100. List<ER_GraduateCardApply> graduateCardApplyUpList = new List<ER_GraduateCardApply>();
  1101. foreach (var graduateCardApply in graduateCardApplyList)
  1102. {
  1103. graduateCardApply.NeedCardResult = null;
  1104. this.SetModifyStatus(graduateCardApply);
  1105. graduateCardApplyUpList.Add(graduateCardApply);
  1106. }
  1107. this.UnitOfWork.BatchUpdate(graduateCardApplyUpList);
  1108. }
  1109. }
  1110. }