TeachersOrderServices.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.CommonLogic.SystemServices;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.Common.TeachingMaterial;
  8. using System.Configuration;
  9. using EMIS.ViewModel.TeachingMaterial;
  10. using EMIS.ViewModel;
  11. using Bowin.Common.Linq.Entity;
  12. using EMIS.ViewModel.WorkflowManage;
  13. using EMIS.CommonLogic.PlugworkflowServices;
  14. using EMIS.ViewModel.SystemView;
  15. using Bowin.Common.Utility;
  16. using EMIS.DataLogic.Repositories;
  17. using System.Linq.Expressions;
  18. using Bowin.Common.Linq;
  19. namespace EMIS.CommonLogic.TeachingMaterial
  20. {
  21. public class TeachersOrderServices : BaseWorkflowServices<ET_TeachersOrder>, ITeachersOrderServices
  22. {
  23. #region --定义--
  24. public TeachersOrderDAL TeachersOrderDAL { get; set; }
  25. public TeachersOrderRepository TeachersOrderRepository { get; set; }
  26. public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
  27. public TeachersConfirmOrderRepository TeachersConfirmOrderRepository { get; set; }
  28. public TeachersPreOrderRepository TeachersPreOrderRepository { get; set; }
  29. public UserRepository UserRepository { get; set; }
  30. public CoursematerialRepository CoursematerialRepository { get; set; }
  31. public PublishRepository PublishRepository { get; set; }
  32. public SchoolyearRepository SchoolyearRepository { get; set; }
  33. public CollegeRepository CollegeRepository { get; set; }
  34. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  35. #endregion
  36. public TeachersOrderServices()
  37. {
  38. DataRangeUserFunc = ((x, y) => this.IsUserInDataRangeByCollege<ET_TeachersOrder>(x, y, (w => w.CollegeID)));
  39. }
  40. /// <summary>
  41. /// 查询教师征订记录
  42. /// </summary>
  43. /// <param name="configuretView"></param>
  44. /// <param name="campusID"></param>
  45. /// <param name="collegeID"></param>
  46. /// <param name="schoolyearID"></param>
  47. /// <param name="educationID"></param>
  48. /// <param name="learningformID"></param>
  49. /// <param name="approvalStatus"></param>
  50. /// <param name="pageIndex"></param>
  51. /// <param name="pageSize"></param>
  52. /// <returns></returns>
  53. public IGridResultSet<TeachersOrderView> GetTeachersOrderViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID,
  54. Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize)
  55. {
  56. //.Where(x => x.ApproveStatus == (int)CF_TeachersOrderStatus.Canceled
  57. // || x.ApproveStatus == (int)CF_TeachersOrderStatus.UnSubmit || x.ApproveStatus == (int)CF_TeachersOrderStatus.Completed);
  58. var statusList = this.GetStatusViewList();
  59. Expression<Func<ET_TeachersOrder, bool>> exp = (x => true);
  60. if (schoolyearID.HasValue)
  61. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  62. if (collegeID.HasValue)
  63. exp = exp.And(x => x.CollegeID == collegeID);
  64. if (coursematerialID.HasValue)
  65. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  66. if (publishID.HasValue)
  67. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  68. if (ApprovalStatus.HasValue)
  69. exp = exp.And(x => x.ApprovalStatus == ApprovalStatus);
  70. var query = TeachersOrderDAL.GetTeachingOrderGridView(exp);
  71. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  72. //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  73. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime);
  74. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  75. result.rows.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  76. return result;
  77. }
  78. /// <summary>
  79. /// 导出教师征订记录
  80. /// </summary>
  81. /// <param name="configuretView"></param>
  82. /// <param name="campusID"></param>
  83. /// <param name="collegeID"></param>
  84. /// <param name="schoolyearID"></param>
  85. /// <param name="educationID"></param>
  86. /// <param name="learningformID"></param>
  87. /// <param name="approvalStatus"></param>
  88. /// <param name="pageIndex"></param>
  89. /// <param name="pageSize"></param>
  90. /// <returns></returns>
  91. public List<TeachersOrderView> GetTeachersOrderViewList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID,
  92. Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus)
  93. {
  94. var statusList = this.GetStatusViewList();
  95. Expression<Func<ET_TeachersOrder, bool>> exp = (x => true);
  96. if (schoolyearID.HasValue)
  97. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  98. if (collegeID.HasValue)
  99. exp = exp.And(x => x.CollegeID == collegeID);
  100. if (coursematerialID.HasValue)
  101. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  102. if (publishID.HasValue)
  103. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  104. if (ApprovalStatus.HasValue && ApprovalStatus != -1)
  105. exp = exp.And(x => x.ApprovalStatus == ApprovalStatus);
  106. var query = TeachersOrderDAL.GetTeachingOrderGridView(exp);
  107. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  108. //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime).ToList();
  109. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime);
  110. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToList();
  111. result.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  112. return result;
  113. }
  114. /// <summary>
  115. /// 提交教师征订记录
  116. /// </summary>
  117. /// <param name="teachersOrderIDs"></param>
  118. /// <param name="userID"></param>
  119. /// <param name="comment"></param>
  120. public void SubmitTeachersOrder(List<Guid> teachersOrderIDs, Guid userID, string comment = "")
  121. {
  122. try
  123. {
  124. bool IsSubmit = true;
  125. var startStatus = this.GetStartStatus();
  126. var backPointStatusList = this.GetBackpointStatus();
  127. var statusList = this.GetStatusViewList();
  128. var teachersOrderList = TeachersOrderRepository.GetList(x => teachersOrderIDs.Contains(x.TeachersOrderID)).ToList();
  129. foreach (var teachersOrder in teachersOrderList)
  130. {
  131. if (teachersOrder.ApprovalStatus != startStatus && !backPointStatusList.Contains(teachersOrder.ApprovalStatus))
  132. {
  133. IsSubmit = false;
  134. }
  135. }
  136. if (!IsSubmit)
  137. {
  138. throw new Exception(
  139. string.Format("勾选信息状态不正确,不能提交。只能提交处于{0}状态的信息",
  140. string.Join("、", statusList.Where(x => x.ID == startStatus || backPointStatusList.Contains(x.ID)).OrderBy(x => x.ID).ToList())
  141. )
  142. );
  143. }
  144. var submitTeacherOrderIDList = teachersOrderList.Where(x => x.ApprovalStatus == startStatus).Select(x => x.TeachersOrderID).ToList();
  145. var reSubmitTeacherOrderIDList = teachersOrderList.Where(x => backPointStatusList.Contains(x.ApprovalStatus) && !submitTeacherOrderIDList.Contains(x.TeachersOrderID))
  146. .Select(x => x.TeachersOrderID).ToList();
  147. if (submitTeacherOrderIDList.Count > 0)
  148. {
  149. StartUp(submitTeacherOrderIDList, userID, comment);
  150. }
  151. if (reSubmitTeacherOrderIDList.Count > 0)
  152. {
  153. Approve(reSubmitTeacherOrderIDList, userID, Guid.Empty, comment);
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. throw ex;
  159. }
  160. }
  161. /// <summary>
  162. /// 审核教师征订记录
  163. /// </summary>
  164. /// <param name="specialtyApplyIDs">专业申请ID</param>
  165. /// <param name="userID">当前操作用户ID</param>
  166. /// <param name="actionID">动作ID</param>
  167. /// <param name="comment">处理意见</param>
  168. public void ApproveTeachersOrder(List<Guid> teachersOrderIDs, Guid userID, ActionView actionView, string comment = "")
  169. {
  170. try
  171. {
  172. Approve(teachersOrderIDs, userID, actionView.ActionID, comment);
  173. }
  174. catch (Exception ex)
  175. {
  176. throw ex;
  177. }
  178. }
  179. /// <summary>
  180. /// 添加教师征订信息
  181. /// </summary>
  182. /// <param name="SpecialtyApply">申请专业实体</param>
  183. /// <returns></returns>
  184. public void AddTeachersOrder(List<TeachersOrderView> teachersOrderViews, Guid createUserID)
  185. {
  186. try
  187. {
  188. var startStatus = this.GetStartStatus();
  189. foreach (var teachersOrderView in teachersOrderViews)
  190. {
  191. ET_TeachersOrder teachingMaterialPool = new ET_TeachersOrder()
  192. {
  193. TeachersOrderID = Guid.NewGuid(),
  194. SchoolyearID = teachersOrderView.SchoolyearID.GetValueOrDefault(),
  195. TeachingMaterialPoolID = teachersOrderView.TeachingMaterialPoolID,
  196. CollegeID = teachersOrderView.CollegeID.GetValueOrDefault(),
  197. OrderUserID = createUserID,
  198. OrderDate = DateTime.Now,
  199. OrderDesc = teachersOrderView.OrderDesc,
  200. OrderQty = teachersOrderView.OrderQty.GetValueOrDefault(),
  201. ApprovalStatus = startStatus,
  202. CreateTime = DateTime.Now,
  203. CreateUserID = createUserID,
  204. ModifyTime = DateTime.Now,
  205. ModifyUserID = createUserID
  206. };
  207. UnitOfWork.Add(teachingMaterialPool);
  208. }
  209. UnitOfWork.Commit();
  210. }
  211. catch (Exception ex)
  212. {
  213. throw ex;
  214. }
  215. }
  216. /// <summary>
  217. /// 获取流程审批步骤详细信息
  218. /// </summary>
  219. /// <param name="specialtyApplyID"></param>
  220. /// <returns></returns>
  221. public IGridResultSet<WorkflowApproveHistoryView> GetWorkflowApproveHistoryView(Guid? teachersOrderID)
  222. {
  223. try
  224. {
  225. var query = GetApproveHistoryViewList((Guid)teachersOrderID).ToList().OrderByDescending(x => x.ApproveTime);
  226. return query.AsQueryable<WorkflowApproveHistoryView>().ToGridResultSet<WorkflowApproveHistoryView>(0, 100);
  227. }
  228. catch (Exception)
  229. {
  230. throw;
  231. }
  232. }
  233. /// <summary>
  234. /// 删除书库信息
  235. /// </summary>
  236. /// <param name="publishID"></param>
  237. public void DeleteTeachersOrder(List<Guid> teachersOrderIDs)
  238. {
  239. try
  240. {
  241. var statusList = this.GetBackpointStatus();
  242. statusList.Add(this.GetStartStatus());
  243. bool? IsOrdered = false;//是否包含审核完成数据!
  244. var teachersOrderList = TeachersOrderRepository.GetList(x => teachersOrderIDs.Contains(x.TeachersOrderID)).ToList();
  245. foreach (var teachersOrder in teachersOrderList)
  246. {
  247. //teachersOrder.ApprovalStatus != (int)CF_TeachersOrderStatus.Canceled ||
  248. if (!statusList.Contains(teachersOrder.ApprovalStatus))
  249. {
  250. IsOrdered = true;
  251. }
  252. }
  253. if ((bool)IsOrdered)
  254. {
  255. throw new Exception("只能删除未提交,已退回数据!");
  256. }
  257. TeachersOrderRepository.UnitOfWork.Delete<ET_TeachersOrder>(x => teachersOrderIDs.Contains(x.TeachersOrderID));
  258. }
  259. catch (Exception ex)
  260. {
  261. throw ex;
  262. }
  263. }
  264. /// <summary>
  265. /// 编辑征订信息
  266. /// </summary>
  267. /// <param name="TeachersOrderView"></param>
  268. /// <param name="createUserID"></param>
  269. public void EditTeachersOrder(TeachersOrderView teachersOrderView, Guid createUserID)
  270. {
  271. var startStatus = this.GetStartStatus();
  272. List<TeachersOrderView> teachersOrderList = new List<TeachersOrderView>();
  273. try
  274. {
  275. if (teachersOrderView.TeachersOrderID != null && teachersOrderView.TeachersOrderID != Guid.Empty)
  276. {
  277. ET_TeachersOrder teachersOrder = TeachersOrderRepository.GetSingle(x => x.TeachersOrderID == teachersOrderView.TeachersOrderID);
  278. teachersOrder.OrderQty = teachersOrderView.OrderQty.GetValueOrDefault();
  279. teachersOrder.OrderDesc = teachersOrderView.OrderDesc;
  280. teachersOrder.SchoolyearID = (Guid)teachersOrderView.SchoolyearID;
  281. TeachingMaterialPoolRepository.UnitOfWork.Update(teachersOrder);
  282. TeachingMaterialPoolRepository.UnitOfWork.Commit();
  283. }
  284. else
  285. {
  286. teachersOrderList.Add(teachersOrderView);
  287. foreach (var teachersOrderViewS in teachersOrderList)
  288. {
  289. ET_TeachersOrder teachingMaterialPool = new ET_TeachersOrder()
  290. {
  291. TeachersOrderID = Guid.NewGuid(),
  292. SchoolyearID = teachersOrderViewS.SchoolyearID.GetValueOrDefault(),
  293. TeachingMaterialPoolID = teachersOrderViewS.TeachingMaterialPoolID,
  294. CollegeID = teachersOrderViewS.CollegeID.GetValueOrDefault(),
  295. OrderUserID = createUserID,
  296. OrderDate = DateTime.Now,
  297. OrderDesc = teachersOrderViewS.OrderDesc,
  298. OrderQty = teachersOrderViewS.OrderQty.GetValueOrDefault(),
  299. ApprovalStatus = startStatus,
  300. CreateTime = DateTime.Now,
  301. CreateUserID = createUserID
  302. };
  303. TeachersOrderRepository.UnitOfWork.Add(teachingMaterialPool);
  304. }
  305. TeachersOrderRepository.UnitOfWork.Commit();
  306. }
  307. }
  308. catch (Exception ex)
  309. {
  310. throw ex;
  311. }
  312. }
  313. /// <summary>
  314. /// 获取征订信息列表导出
  315. /// </summary>
  316. /// <param name="exp"></param>
  317. /// <returns></returns>
  318. public IList<TeachersOrderView> GetTeachersOrderViewExcel(ConfiguretView configuretView, Guid? publishID, Guid? coursematerialID, bool? isLate)
  319. {
  320. var statusList = this.GetStatusViewList();
  321. var queryStatusList = this.GetBackpointStatus();
  322. queryStatusList.Add(this.GetStartStatus());
  323. List<TeachersOrderView> list = new List<TeachersOrderView>();
  324. var query = TeachersOrderDAL.GetTeachingOrderGridView(x => true).Where(x => queryStatusList.Contains(x.ApproveStatus));
  325. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  326. list = this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToList();
  327. else
  328. list = this.GetQueryByDataRangeByCollege(query).ToList();
  329. var result = list.OrderBy(x => x.CoursematerialCode).ToList();
  330. result.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  331. return result;
  332. }
  333. public TeachersOrderView GetSingleTeachersOrder(Guid teachersOrderID)
  334. {
  335. return TeachersOrderDAL.GetSingleTeachersOrderView(teachersOrderID);
  336. }
  337. /// <summary>
  338. /// 获取书库信息列表
  339. /// </summary>
  340. /// <param name="exp"></param>
  341. /// <returns></returns>
  342. public IGridResultSet<TeachingMaterialPoolView> GetTeachingOrderByTeachingMaterialPoolViewGrid(ConfiguretView configuretView, Guid? publishID, Guid? coursematerialID, Guid? teachingMaterialPoolID, Guid? teachersOrderID, bool? isLate, int pageIndex, int pageSize)
  343. {
  344. List<TeachingMaterialPoolView> teachingMaterialPoolViewList = new List<TeachingMaterialPoolView>();
  345. Expression<Func<CF_TeachingMaterialPool, bool>> teachingMaterialPoolExp = (x => true);
  346. if (publishID != null && publishID != Guid.Empty)
  347. {
  348. teachingMaterialPoolExp = teachingMaterialPoolExp.And(x => x.PublishID == publishID);
  349. }
  350. if (coursematerialID != null && coursematerialID != Guid.Empty)
  351. {
  352. teachingMaterialPoolExp = teachingMaterialPoolExp.And(x => x.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  353. }
  354. if (isLate != null)
  355. {
  356. teachingMaterialPoolExp = teachingMaterialPoolExp.And(x => x.IsLate == isLate);
  357. }
  358. var query = TeachersOrderDAL.GetTeachingOrderByTeachingMaterialPoolGridView(teachersOrderID, teachingMaterialPoolExp);
  359. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  360. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialTypeID).OrderByDescending(x => x.TeachingMaterialName).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
  361. return query.OrderBy(x => x.TeachingMaterialTypeID).OrderByDescending(x => x.TeachingMaterialName).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
  362. }
  363. /// <summary>
  364. /// 查询征订申请提交数据
  365. /// </summary>
  366. /// <param name="configuretView"></param>
  367. /// <param name="campusID"></param>
  368. /// <param name="collegeID"></param>
  369. /// <param name="schoolyearID"></param>
  370. /// <param name="educationID"></param>
  371. /// <param name="learningformID"></param>
  372. /// <param name="approvalStatus"></param>
  373. /// <param name="pageIndex"></param>
  374. /// <param name="pageSize"></param>
  375. /// <returns></returns>
  376. public IGridResultSet<TeachersOrderView> GetTeachersOrderExamineViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID,
  377. Guid? collegeID, Guid? coursematerialID, Guid? publishID, int? ApprovalStatus, int pageIndex, int pageSize)
  378. {
  379. var statusList = this.GetStatusViewList();
  380. var approveStatusList = this.GetApproveStatusViewList().Select(x => x.ID).ToList();
  381. Expression<Func<ET_TeachersOrder, bool>> exp = (x => approveStatusList.Contains(x.ApprovalStatus));
  382. if (schoolyearID.HasValue)
  383. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  384. if (collegeID.HasValue)
  385. exp = exp.And(x => x.CollegeID == collegeID);
  386. if (coursematerialID.HasValue)
  387. exp = exp.And(x => x.CF_TeachingMaterialPool.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  388. if (publishID.HasValue)
  389. exp = exp.And(x => x.CF_TeachingMaterialPool.PublishID == publishID);
  390. if (ApprovalStatus.HasValue)
  391. exp = exp.And(x => x.ApprovalStatus == ApprovalStatus);
  392. var query = TeachersOrderDAL.GetTeachingOrderGridView(exp);
  393. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  394. //return this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  395. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.CreateTime);
  396. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToGridResultSet<TeachersOrderView>(pageIndex, pageSize);
  397. result.rows.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  398. return result;
  399. }
  400. public TeachersOrderView GetSingleTeachersOrderById(Guid teachersOrderID)
  401. {
  402. return TeachersOrderDAL.GetSingleTeachersOrderById(teachersOrderID);
  403. }
  404. public IGridResultSet<TeachingMaterialPoolView> GetTeachersOrderOrTeachingMaterialPoolViewGrid(ConfiguretView configuretView, Guid? teachingMaterialID, Guid? coursematerialID, bool? isLate, Guid? college, Guid? schoolyearID, int pageIndex, int pageSize)
  405. {
  406. Expression<Func<CF_TeachingMaterialPool, bool>> exp = (x => true);
  407. if (teachingMaterialID != null && teachingMaterialID != Guid.Empty)
  408. {
  409. exp = exp.And(x => x.TeachingMaterialPoolID == teachingMaterialID);
  410. }
  411. if (coursematerialID != null && coursematerialID != Guid.Empty)
  412. {
  413. exp = exp.And(x => x.EM_Coursematerial.Any(w => w.CoursematerialID == coursematerialID));
  414. }
  415. if (isLate != null)
  416. {
  417. exp = exp.And(x => x.IsLate == isLate);
  418. }
  419. var query = TeachersOrderDAL.GetTeachersOrderByTeachingMaterial(exp);
  420. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  421. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
  422. return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
  423. }
  424. /******************加载征订明细****************************/
  425. public IGridResultSet<TeachersOrderView> GetTeachersOrderDetailViewList(Guid? teachersOrderID, int pageIndex, int pageSize)
  426. {
  427. var statusList = this.GetStatusViewList();
  428. var query = TeachersOrderDAL.GetTeachingOrderGridView(x => x.TeachersOrderID == teachersOrderID);
  429. var result = query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachersOrderView>(0, 10);
  430. result.rows.ForEach(x => x.ApproveStatusName = statusList.Where(w => w.ID == x.ApproveStatus).Select(w => w.Name).FirstOrDefault());
  431. return result;
  432. }
  433. public void OnApproveEnd(List<Guid> teacherOrderIDList, Guid? userID)
  434. {
  435. //var teacherOrderList = TeachersOrderDAL.TeachersOrderRepository.GetList(x => teacherOrderIDList.Contains(x.TeachersOrderID)).ToList();
  436. //var preOrderList = TeachersOrderDAL.GetPreOrderByTeachersOrderIDList(teacherOrderIDList);
  437. //foreach (var teacherOrder in teacherOrderList)
  438. //{
  439. // var preOrder = preOrderList.FirstOrDefault(x => x.SchoolyearID == teacherOrder.SchoolyearID
  440. // && x.TeachingMaterialPoolID == teacherOrder.TeachingMaterialPoolID);
  441. // if (preOrder == null)
  442. // {
  443. // ET_TeachersPreOrder teacherPreOrder = new ET_TeachersPreOrder()
  444. // {
  445. // TeachersPreOrderID = Guid.NewGuid(),
  446. // SchoolyearID = teacherOrder.SchoolyearID,
  447. // TeachingMaterialPoolID = teacherOrder.TeachingMaterialPoolID,
  448. // PreQty = 5,
  449. // Desc = "预加值",
  450. // CreateTime = DateTime.Now,
  451. // CreateUserID = userID,
  452. // ModifyTime = DateTime.Now,
  453. // ModifyUserID = userID
  454. // };
  455. // UnitOfWork.Add(teacherPreOrder);
  456. // }
  457. //}
  458. }
  459. }
  460. }