SpecialtyApplyServices.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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.Utility;
  8. using Bowin.Common.Linq;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.SystemView;
  13. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  14. using EMIS.DataLogic.EnrollManage.SpecialtyManage;
  15. using EMIS.CommonLogic.SystemServices;
  16. namespace EMIS.CommonLogic.EnrollManage.SpecialtyManage
  17. {
  18. public class SpecialtyApplyServices : BaseWorkflowServices<CF_SpecialtyApply>, ISpecialtyApplyServices
  19. {
  20. public SpecialtyApplyDAL specialtyApplyDAL { get; set; }
  21. /// <summary>
  22. /// 数据范围
  23. /// </summary>
  24. public SpecialtyApplyServices()
  25. {
  26. DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<CF_SpecialtyApply>(x, y, (w => w.CollegeID)));
  27. }
  28. /// <summary>
  29. /// 查询对应的专业申请信息View
  30. /// </summary>
  31. /// <param name="configuretView"></param>
  32. /// <param name="campusID"></param>
  33. /// <param name="collegeID"></param>
  34. /// <param name="gradeID"></param>
  35. /// <param name="standardID"></param>
  36. /// <param name="educationID"></param>
  37. /// <param name="learningformID"></param>
  38. /// <param name="learnSystem"></param>
  39. /// <param name="approvalStatus"></param>
  40. /// <param name="pageIndex"></param>
  41. /// <param name="pageSize"></param>
  42. /// <returns></returns>
  43. public IGridResultSet<SpecialtyApplyView> GetSpecialtyApplyViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
  44. int? standardID, int? educationID, int? learningformID, string learnSystem, int? approvalStatus, int pageIndex, int pageSize)
  45. {
  46. //结束流程环节ID
  47. var endStatusID = this.GetCorrectEndStatus();
  48. //审核流程状态IDList
  49. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  50. var applyStatusList = this.GetStatusViewList();
  51. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)).Select(x => x.ID).ToList();
  52. //专业申请
  53. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  54. expSpecialtyApply = expSpecialtyApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus));
  55. if (collegeID.HasValue)
  56. {
  57. expSpecialtyApply = expSpecialtyApply.And(x => x.CollegeID == collegeID);
  58. }
  59. if (gradeID.HasValue)
  60. {
  61. expSpecialtyApply = expSpecialtyApply.And(x => x.GradeID == gradeID);
  62. }
  63. if (approvalStatus.HasValue)
  64. {
  65. //审批状态
  66. expSpecialtyApply = expSpecialtyApply.And(x => x.ApprovalStatus == approvalStatus);
  67. }
  68. var query = specialtyApplyDAL.GetSpecialtyApplyViewQueryable(expSpecialtyApply);
  69. if (campusID.HasValue)
  70. {
  71. query = query.Where(x => x.CampusID == campusID);
  72. }
  73. if (standardID.HasValue)
  74. {
  75. query = query.Where(x => x.StandardID == standardID);
  76. }
  77. if (educationID.HasValue)
  78. {
  79. query = query.Where(x => x.EducationID == educationID);
  80. }
  81. if (learningformID.HasValue)
  82. {
  83. query = query.Where(x => x.LearningformID == learningformID);
  84. }
  85. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  86. {
  87. var LearnSystems = Convert.ToDecimal(learnSystem);
  88. query = query.Where(x => x.LearnSystem == LearnSystems);
  89. }
  90. //查询条件
  91. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  92. {
  93. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  94. }
  95. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeCode).ThenByDescending(x => x.GradeID).ThenBy(x => x.StandardName)
  96. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  97. .ThenBy(x => x.CreateTime).ToGridResultSet<SpecialtyApplyView>(pageIndex, pageSize);
  98. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  99. return result;
  100. }
  101. /// <summary>
  102. /// 查询对应的专业申请信息List
  103. /// </summary>
  104. /// <param name="configuretView"></param>
  105. /// <param name="campusID"></param>
  106. /// <param name="collegeID"></param>
  107. /// <param name="gradeID"></param>
  108. /// <param name="standardID"></param>
  109. /// <param name="educationID"></param>
  110. /// <param name="learningformID"></param>
  111. /// <param name="learnSystem"></param>
  112. /// <param name="approvalStatus"></param>
  113. /// <returns></returns>
  114. public List<SpecialtyApplyView> GetSpecialtyApplyViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
  115. int? standardID, int? educationID, int? learningformID, string learnSystem, int? approvalStatus)
  116. {
  117. //结束流程环节ID
  118. var endStatusID = this.GetCorrectEndStatus();
  119. //审核流程状态IDList
  120. var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  121. var applyStatusList = this.GetStatusViewList();
  122. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID)).Select(x => x.ID).ToList();
  123. //专业申请
  124. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  125. expSpecialtyApply = expSpecialtyApply.And(x => applyStatusIDList.Contains(x.ApprovalStatus));
  126. if (collegeID.HasValue)
  127. {
  128. expSpecialtyApply = expSpecialtyApply.And(x => x.CollegeID == collegeID);
  129. }
  130. if (gradeID.HasValue)
  131. {
  132. expSpecialtyApply = expSpecialtyApply.And(x => x.GradeID == gradeID);
  133. }
  134. if (approvalStatus.HasValue)
  135. {
  136. //审批状态
  137. expSpecialtyApply = expSpecialtyApply.And(x => x.ApprovalStatus == approvalStatus);
  138. }
  139. var query = specialtyApplyDAL.GetSpecialtyApplyViewQueryable(expSpecialtyApply);
  140. if (campusID.HasValue)
  141. {
  142. query = query.Where(x => x.CampusID == campusID);
  143. }
  144. if (standardID.HasValue)
  145. {
  146. query = query.Where(x => x.StandardID == standardID);
  147. }
  148. if (educationID.HasValue)
  149. {
  150. query = query.Where(x => x.EducationID == educationID);
  151. }
  152. if (learningformID.HasValue)
  153. {
  154. query = query.Where(x => x.LearningformID == learningformID);
  155. }
  156. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  157. {
  158. var LearnSystems = Convert.ToDecimal(learnSystem);
  159. query = query.Where(x => x.LearnSystem == LearnSystems);
  160. }
  161. //查询条件
  162. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  163. {
  164. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  165. }
  166. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeCode).ThenByDescending(x => x.GradeID).ThenBy(x => x.StandardName)
  167. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.CreateTime).ToList();
  168. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  169. return result;
  170. }
  171. /// <summary>
  172. /// 查询对应的专业审核信息View
  173. /// </summary>
  174. /// <param name="configuretView"></param>
  175. /// <param name="campusID"></param>
  176. /// <param name="collegeID"></param>
  177. /// <param name="gradeID"></param>
  178. /// <param name="standardID"></param>
  179. /// <param name="educationID"></param>
  180. /// <param name="learningformID"></param>
  181. /// <param name="learnSystem"></param>
  182. /// <param name="approvalStatus"></param>
  183. /// <param name="pageIndex"></param>
  184. /// <param name="pageSize"></param>
  185. /// <returns></returns>
  186. public IGridResultSet<SpecialtyApplyView> GetSpecialtyAuditingViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
  187. int? standardID, int? educationID, int? learningformID, string learnSystem, int? approvalStatus, int pageIndex, int pageSize)
  188. {
  189. var approveStatusList = this.GetApproveStatusViewList();
  190. var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
  191. //专业申请
  192. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  193. expSpecialtyApply = expSpecialtyApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
  194. if (collegeID.HasValue)
  195. {
  196. expSpecialtyApply = expSpecialtyApply.And(x => x.CollegeID == collegeID);
  197. }
  198. if (gradeID.HasValue)
  199. {
  200. expSpecialtyApply = expSpecialtyApply.And(x => x.GradeID == gradeID);
  201. }
  202. if (approvalStatus.HasValue)
  203. {
  204. //审批状态
  205. expSpecialtyApply = expSpecialtyApply.And(x => x.ApprovalStatus == approvalStatus);
  206. }
  207. var query = specialtyApplyDAL.GetSpecialtyApplyViewQueryable(expSpecialtyApply);
  208. if (campusID.HasValue)
  209. {
  210. query = query.Where(x => x.CampusID == campusID);
  211. }
  212. if (standardID.HasValue)
  213. {
  214. query = query.Where(x => x.StandardID == standardID);
  215. }
  216. if (educationID.HasValue)
  217. {
  218. query = query.Where(x => x.EducationID == educationID);
  219. }
  220. if (learningformID.HasValue)
  221. {
  222. query = query.Where(x => x.LearningformID == learningformID);
  223. }
  224. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  225. {
  226. var LearnSystems = Convert.ToDecimal(learnSystem);
  227. query = query.Where(x => x.LearnSystem == LearnSystems);
  228. }
  229. //查询条件
  230. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  231. {
  232. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  233. }
  234. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeCode).ThenByDescending(x => x.GradeID).ThenBy(x => x.StandardName)
  235. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.CreateTime).ToGridResultSet<SpecialtyApplyView>(pageIndex, pageSize);
  236. result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  237. return result;
  238. }
  239. /// <summary>
  240. /// 查询对应的专业审核信息List
  241. /// </summary>
  242. /// <param name="configuretView"></param>
  243. /// <param name="campusID"></param>
  244. /// <param name="collegeID"></param>
  245. /// <param name="gradeID"></param>
  246. /// <param name="standardID"></param>
  247. /// <param name="educationID"></param>
  248. /// <param name="learningformID"></param>
  249. /// <param name="learnSystem"></param>
  250. /// <param name="approvalStatus"></param>
  251. /// <returns></returns>
  252. public IList<SpecialtyApplyView> GetSpecialtyAuditingViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID,
  253. int? standardID, int? educationID, int? learningformID, string learnSystem, int? approvalStatus)
  254. {
  255. var approveStatusList = this.GetApproveStatusViewList();
  256. var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
  257. //专业申请
  258. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  259. expSpecialtyApply = expSpecialtyApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
  260. if (collegeID.HasValue)
  261. {
  262. expSpecialtyApply = expSpecialtyApply.And(x => x.CollegeID == collegeID);
  263. }
  264. if (gradeID.HasValue)
  265. {
  266. expSpecialtyApply = expSpecialtyApply.And(x => x.GradeID == gradeID);
  267. }
  268. if (approvalStatus.HasValue)
  269. {
  270. //审批状态
  271. expSpecialtyApply = expSpecialtyApply.And(x => x.ApprovalStatus == approvalStatus);
  272. }
  273. var query = specialtyApplyDAL.GetSpecialtyApplyViewQueryable(expSpecialtyApply);
  274. if (campusID.HasValue)
  275. {
  276. query = query.Where(x => x.CampusID == campusID);
  277. }
  278. if (standardID.HasValue)
  279. {
  280. query = query.Where(x => x.StandardID == standardID);
  281. }
  282. if (educationID.HasValue)
  283. {
  284. query = query.Where(x => x.EducationID == educationID);
  285. }
  286. if (learningformID.HasValue)
  287. {
  288. query = query.Where(x => x.LearningformID == learningformID);
  289. }
  290. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  291. {
  292. var LearnSystems = Convert.ToDecimal(learnSystem);
  293. query = query.Where(x => x.LearnSystem == LearnSystems);
  294. }
  295. //查询条件
  296. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  297. {
  298. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  299. }
  300. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeCode).ThenByDescending(x => x.GradeID).ThenBy(x => x.StandardName)
  301. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ThenBy(x => x.CreateTime).ToList();
  302. result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  303. return result;
  304. }
  305. /// <summary>
  306. /// 查询专业审核信息CF_SpecialtyApply(只查询审核状态信息,根据业务主键:专业信息ID、院系所、年级、学期)
  307. /// </summary>
  308. /// <param name="specialtyID"></param>
  309. /// <param name="collegeID"></param>
  310. /// <param name="gradeID"></param>
  311. /// <param name="semesterID"></param>
  312. /// <returns></returns>
  313. public CF_SpecialtyApply GetSpecialtyApply(Guid? specialtyID, Guid? collegeID, int? gradeID, int? semesterID)
  314. {
  315. try
  316. {
  317. var approveStatusList = this.GetApproveStatusViewList();
  318. var aprroveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
  319. Expression<Func<CF_SpecialtyApply, bool>> exp = (x => aprroveStatusIDList.Contains(x.ApprovalStatus));
  320. if (specialtyID.HasValue)
  321. {
  322. exp = exp.And(x => x.SpecialtyID == specialtyID);
  323. }
  324. if (collegeID.HasValue)
  325. {
  326. exp = exp.And(x => x.CollegeID == collegeID);
  327. }
  328. if (gradeID.HasValue)
  329. {
  330. exp = exp.And(x => x.GradeID == gradeID);
  331. }
  332. if (semesterID.HasValue)
  333. {
  334. exp = exp.And(x => x.SemesterID == semesterID);
  335. }
  336. return specialtyApplyDAL.specialtyApplyRepository.GetSingle(exp);
  337. }
  338. catch (Exception ex)
  339. {
  340. throw new Exception(ex.Message);
  341. }
  342. }
  343. /// <summary>
  344. /// 查询专业申请信息SpecialtyApplyView
  345. /// </summary>
  346. /// <param name="specialtyApplyID"></param>
  347. /// <returns></returns>
  348. public SpecialtyApplyView GetSpecialtyApplyView(Guid? specialtyApplyID)
  349. {
  350. try
  351. {
  352. var query = specialtyApplyDAL.GetSpecialtyApplyViewQueryable(x => x.SpecialtyApplyID == specialtyApplyID).SingleOrDefault();
  353. return query;
  354. }
  355. catch (Exception ex)
  356. {
  357. throw new Exception(ex.Message);
  358. }
  359. }
  360. /// <summary>
  361. /// 申请(批量新增,业务主键:专业信息ID、年级、学期、院系所)
  362. /// </summary>
  363. /// <param name="specialtyIDList"></param>
  364. /// <param name="specialtyApplyView"></param>
  365. /// <returns></returns>
  366. public string SpecialtyApplyBatchAdd(List<Guid?> specialtyIDList, SpecialtyApplyView specialtyApplyView)
  367. {
  368. try
  369. {
  370. //查询对应的工作流程环节状态信息View
  371. var approveStatusList = this.GetStatusViewList();
  372. if (approveStatusList == null || approveStatusList.Count() <= 0)
  373. {
  374. throw new Exception("工作流平台中,招生专业流程未配置,请核查。");
  375. }
  376. //查询工作流程开始环节状态
  377. var startStatusID = this.GetStartStatus();
  378. if (startStatusID == null)
  379. {
  380. throw new Exception("工作流平台中,招生专业流程开始环节未配置,请核查。");
  381. }
  382. //专业申请
  383. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  384. expSpecialtyApply = expSpecialtyApply.And(x => specialtyIDList.Contains(x.SpecialtyID));
  385. //查询对应的专业申请信息List
  386. var specialtyApplyList = specialtyApplyDAL.specialtyApplyRepository.GetList(expSpecialtyApply).ToList();
  387. int success = 0;
  388. int fail = 0;
  389. string tipMessage = null;
  390. List<CF_SpecialtyApply> specialtyApplyInList = new List<CF_SpecialtyApply>();
  391. foreach (var specialtyID in specialtyIDList)
  392. {
  393. var specialtyApplyVerify = specialtyApplyList.Where(x => x.SpecialtyID == specialtyID && x.CollegeID == specialtyApplyView.CollegeID
  394. && x.GradeID == specialtyApplyView.GradeID && x.SemesterID == specialtyApplyView.SemesterID).SingleOrDefault();
  395. if (specialtyApplyVerify == null)
  396. {
  397. //新增
  398. var specialtyApply = new CF_SpecialtyApply();
  399. specialtyApply.SpecialtyApplyID = Guid.NewGuid();
  400. specialtyApply.SpecialtyID = specialtyID;
  401. specialtyApply.CollegeID = specialtyApplyView.CollegeID;
  402. specialtyApply.GradeID = specialtyApplyView.GradeID;
  403. specialtyApply.SemesterID = specialtyApplyView.SemesterID;
  404. specialtyApply.ApprovalStatus = startStatusID;
  405. specialtyApply.Remark = specialtyApplyView.Remark;
  406. SetNewStatus(specialtyApply);
  407. specialtyApplyInList.Add(specialtyApply);
  408. success++;
  409. }
  410. else
  411. {
  412. //表示已存在相同的专业申请信息
  413. fail++;
  414. }
  415. }
  416. UnitOfWork.BulkInsert<CF_SpecialtyApply>(specialtyApplyInList);
  417. if (success > 0 && fail <= 0)
  418. {
  419. tipMessage = success + "条";
  420. }
  421. else
  422. {
  423. tipMessage = success + "条," + fail + "条失败,原因:已存在相同的专业申请信息,请检查";
  424. }
  425. return tipMessage;
  426. }
  427. catch (Exception ex)
  428. {
  429. throw new Exception(ex.Message);
  430. }
  431. }
  432. /// <summary>
  433. /// 查询专业申请中的未申请专业信息SpecialtyView
  434. /// </summary>
  435. /// <param name="configuretView"></param>
  436. /// <param name="collegeID"></param>
  437. /// <param name="gradeID"></param>
  438. /// <param name="semesterID"></param>
  439. /// <param name="standardID"></param>
  440. /// <param name="educationID"></param>
  441. /// <param name="learningformID"></param>
  442. /// <param name="learnSystem"></param>
  443. /// <param name="scienceclassID"></param>
  444. /// <param name="pageIndex"></param>
  445. /// <param name="pageSize"></param>
  446. /// <returns></returns>
  447. public IGridResultSet<SpecialtyView> GetSpecialtyViewNoApply(ConfiguretView configuretView, Guid? collegeID, int? gradeID, int? semesterID, int? standardID,
  448. int? educationID, int? learningformID, string learnSystem, int? scienceclassID, int pageIndex, int pageSize)
  449. {
  450. //专业信息(只查询启用状态的专业信息)
  451. Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  452. if (standardID.HasValue)
  453. {
  454. expSpecialty = expSpecialty.And(x => x.StandardID == standardID);
  455. }
  456. if (educationID.HasValue)
  457. {
  458. expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
  459. }
  460. if (learningformID.HasValue)
  461. {
  462. expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
  463. }
  464. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  465. {
  466. var LearnSystems = Convert.ToDecimal(learnSystem);
  467. expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
  468. }
  469. if (scienceclassID.HasValue)
  470. {
  471. expSpecialty = expSpecialty.And(x => x.ScienceclassID == scienceclassID);
  472. }
  473. //专业申请
  474. Expression<Func<CF_SpecialtyApply, bool>> expSpecialtyApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  475. if (collegeID.HasValue)
  476. {
  477. expSpecialtyApply = expSpecialtyApply.And(x => x.CollegeID == collegeID);
  478. }
  479. if (gradeID.HasValue)
  480. {
  481. expSpecialtyApply = expSpecialtyApply.And(x => x.GradeID == gradeID);
  482. }
  483. if (semesterID.HasValue)
  484. {
  485. expSpecialtyApply = expSpecialtyApply.And(x => x.SemesterID == semesterID);
  486. }
  487. //招生专业
  488. Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  489. if (collegeID.HasValue)
  490. {
  491. expRecruitSpecialty = expRecruitSpecialty.And(x => x.CollegeID == collegeID);
  492. }
  493. if (gradeID.HasValue)
  494. {
  495. expRecruitSpecialty = expRecruitSpecialty.And(x => x.GradeID == gradeID);
  496. }
  497. if (semesterID.HasValue)
  498. {
  499. expRecruitSpecialty = expRecruitSpecialty.And(x => x.SemesterID == semesterID);
  500. }
  501. var query = specialtyApplyDAL.GetSpecialtyViewNoApplyQueryable(expSpecialty, expSpecialtyApply, expRecruitSpecialty);
  502. //查询条件
  503. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  504. {
  505. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  506. }
  507. return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem).ToGridResultSet<SpecialtyView>(pageIndex, pageSize);
  508. }
  509. /// <summary>
  510. /// 删除
  511. /// </summary>
  512. /// <param name="specialtyApplyIDs"></param>
  513. /// <returns></returns>
  514. public bool SpecialtyApplyDelete(List<Guid?> specialtyApplyIDs)
  515. {
  516. try
  517. {
  518. //var startStatusID = this.GetStartStatus();
  519. //if (startStatusID == null)
  520. //{
  521. // throw new Exception("工作流平台中,招生专业流程开始环节流程未配置,请核查");
  522. //}
  523. //var approvalStatusList = specialtyApplyDAL.specialtyApplyRepository.GetList(x => specialtyApplyIDs.Contains(x.SpecialtyApplyID)).Select(x => x.ApprovalStatus).ToList();
  524. //foreach (var approvalStatus in approvalStatusList)
  525. //{
  526. // if (approvalStatus != startStatusID)
  527. // {
  528. // throw new Exception("只能对未提交状态的信息进行删除");
  529. // }
  530. //}
  531. UnitOfWork.Delete<CF_SpecialtyApply>(x => specialtyApplyIDs.Contains(x.SpecialtyApplyID));
  532. return true;
  533. }
  534. catch (Exception)
  535. {
  536. throw;
  537. }
  538. }
  539. /// <summary>
  540. /// 提交
  541. /// </summary>
  542. /// <param name="specialtyApplyIDs"></param>
  543. /// <param name="userID"></param>
  544. /// <param name="comment"></param>
  545. /// <returns></returns>
  546. public string SpecialtyApplySubmit(List<Guid> specialtyApplyIDs, Guid userID, string comment = "")
  547. {
  548. try
  549. {
  550. //查询招生专业工作流程开始环节状态
  551. var startStatusID = this.GetStartStatus();
  552. if (startStatusID == null)
  553. {
  554. throw new Exception("工作流平台中,招生专业流程开始环节流程未配置,请核查");
  555. }
  556. //查询对应的专业申请信息List
  557. var specialtyApplyList = specialtyApplyDAL.specialtyApplyRepository.GetList(x => specialtyApplyIDs.Contains(x.SpecialtyApplyID)).ToList();
  558. int success = 0; //成功
  559. string tipMessage = null; //提示消息
  560. var submitIDList = new List<Guid>();
  561. var approveIDList = new List<Guid>();
  562. foreach (var specialtyApply in specialtyApplyList)
  563. {
  564. if (specialtyApply.ApprovalStatus == startStatusID)
  565. {
  566. submitIDList.Add(specialtyApply.SpecialtyApplyID);
  567. }
  568. else
  569. {
  570. approveIDList.Add(specialtyApply.SpecialtyApplyID);
  571. }
  572. success++;
  573. }
  574. if (submitIDList.Count > 0)
  575. {
  576. this.StartUp(submitIDList, userID, comment);
  577. }
  578. if (approveIDList.Count > 0)
  579. {
  580. this.Approve(approveIDList, userID, Guid.Empty, comment);
  581. }
  582. tipMessage = success + "条";
  583. return tipMessage;
  584. }
  585. catch (Exception ex)
  586. {
  587. throw new Exception(ex.Message);
  588. }
  589. }
  590. /// <summary>
  591. /// 审核确定(批量)
  592. /// </summary>
  593. /// <param name="specialtyApplyIDs"></param>
  594. /// <param name="userID"></param>
  595. /// <param name="actionID"></param>
  596. /// <param name="comment"></param>
  597. public void SpecialtyApproveConfirm(List<Guid?> specialtyApplyIDs, Guid userID, Guid actionID, string comment)
  598. {
  599. try
  600. {
  601. //查询对应的专业审核信息List
  602. var specialtyApplyList = specialtyApplyDAL.specialtyApplyRepository.GetList(x => specialtyApplyIDs.Contains(x.SpecialtyApplyID)).ToList();
  603. foreach (var specialtyApplyID in specialtyApplyIDs)
  604. {
  605. //查询对应的专业审核信息
  606. var specialtyApply = specialtyApplyList.Where(x => x.SpecialtyApplyID == specialtyApplyID).SingleOrDefault();
  607. if (specialtyApply == null)
  608. {
  609. throw new Exception("数据有误,请核查。");
  610. }
  611. }
  612. //审核
  613. this.Approve(specialtyApplyIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
  614. }
  615. catch (Exception ex)
  616. {
  617. throw new Exception(ex.Message);
  618. }
  619. }
  620. /// <summary>
  621. /// 查询对应的流程审批步骤详细信息(暂时不用)
  622. /// </summary>
  623. /// <param name="specialtyApplyID"></param>
  624. /// <returns></returns>
  625. public IGridResultSet<WorkflowApproveHistoryView> GetWorkflowApproveHistoryView(Guid? specialtyApplyID)
  626. {
  627. try
  628. {
  629. var query = this.GetApproveHistoryViewList((Guid)specialtyApplyID).ToList();
  630. return query.AsQueryable<WorkflowApproveHistoryView>().ToGridResultSet<WorkflowApproveHistoryView>(0, 100);
  631. }
  632. catch (Exception)
  633. {
  634. throw;
  635. }
  636. }
  637. /// <summary>
  638. /// 流程结束跳转函数(工作流平台中配置)
  639. /// 注:需对招生专业信息进行处理(根据业务主键处理,专业信息ID、院系所、年级、学期)
  640. /// </summary>
  641. /// <param name="specialtyApplyIDList"></param>
  642. /// <param name="userID"></param>
  643. public void OnApproveEnd(List<Guid> specialtyApplyIDList, Guid? userID)
  644. {
  645. try
  646. {
  647. //查询对应的专业申请信息List
  648. var specialtyApplyList = specialtyApplyDAL.specialtyApplyRepository.GetList(x => specialtyApplyIDList.Contains(x.SpecialtyApplyID)).ToList();
  649. //招生专业
  650. Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  651. //查询招生专业信息
  652. var recruitSpecialtyList = specialtyApplyDAL.recruitSpecialtyRepository.GetList(expRecruitSpecialty).ToList();
  653. //流程审核通过结束状态
  654. var endApproveStatusID = this.GetCorrectEndStatus();
  655. List<CF_RecruitSpecialty> recruitSpecialtyInList = new List<CF_RecruitSpecialty>();
  656. List<CF_RecruitSpecialty> recruitSpecialtyUpList = new List<CF_RecruitSpecialty>();
  657. foreach (var specialtyApply in specialtyApplyList)
  658. {
  659. //对招生专业信息进行验证(专业信息ID、院系所ID、年级、学期)
  660. var recruitSpecialtyEntity = recruitSpecialtyList.Where(x => x.SpecialtyID == specialtyApply.SpecialtyID && x.CollegeID == specialtyApply.CollegeID
  661. && x.GradeID == specialtyApply.GradeID && x.SemesterID == specialtyApply.SemesterID).SingleOrDefault();
  662. if (recruitSpecialtyEntity == null)
  663. {
  664. //新增
  665. var recruitSpecialty = new CF_RecruitSpecialty();
  666. recruitSpecialty.RecruitSpecialtyID = Guid.NewGuid();
  667. recruitSpecialty.SpecialtyApplyID = specialtyApply.SpecialtyApplyID;
  668. recruitSpecialty.SpecialtyID = specialtyApply.SpecialtyID;
  669. recruitSpecialty.CollegeID = specialtyApply.CollegeID;
  670. recruitSpecialty.GradeID = specialtyApply.GradeID;
  671. recruitSpecialty.SemesterID = specialtyApply.SemesterID;
  672. recruitSpecialty.ApprovalStatus = endApproveStatusID;
  673. recruitSpecialty.isGenerated = false;
  674. recruitSpecialty.Remark = specialtyApply.Remark;
  675. SetNewStatus(recruitSpecialty);
  676. recruitSpecialtyInList.Add(recruitSpecialty);
  677. }
  678. else
  679. {
  680. //修改
  681. recruitSpecialtyEntity.SpecialtyApplyID = specialtyApply.SpecialtyApplyID;
  682. recruitSpecialtyEntity.ApprovalStatus = endApproveStatusID;
  683. SetModifyStatus(recruitSpecialtyEntity);
  684. recruitSpecialtyUpList.Add(recruitSpecialtyEntity);
  685. }
  686. }
  687. using (TransactionScope ts = new TransactionScope())
  688. {
  689. //批量统一提交更新
  690. if (recruitSpecialtyInList != null && recruitSpecialtyInList.Count() > 0)
  691. {
  692. this.UnitOfWork.BulkInsert(recruitSpecialtyInList);
  693. }
  694. //批量统一提交更新
  695. if (recruitSpecialtyUpList != null && recruitSpecialtyUpList.Count() > 0)
  696. {
  697. this.UnitOfWork.BatchUpdate(recruitSpecialtyUpList);
  698. }
  699. ts.Complete();
  700. }
  701. }
  702. catch (Exception)
  703. {
  704. throw;
  705. }
  706. }
  707. }
  708. }