EvaluationProjectServices.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Data;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EvaluationManage.EvaluationTable;
  12. using EMIS.DataLogic.EvaluationManage.EvaluationTable;
  13. namespace EMIS.CommonLogic.EvaluationManage.EvaluationTable
  14. {
  15. public class EvaluationProjectServices : BaseServices, IEvaluationProjectServices
  16. {
  17. public EvaluationProjectDAL EvaluationProjectDAL { get; set; }
  18. /// <summary>
  19. /// 查询对应的评价项目信息View
  20. /// </summary>
  21. /// <param name="configuretView"></param>
  22. /// <param name="evaluationParticipateTypeID"></param>
  23. /// <param name="evaluationTypeID"></param>
  24. /// <param name="evaluationTableID"></param>
  25. /// <param name="evaluationTargetID"></param>
  26. /// <param name="pageIndex"></param>
  27. /// <param name="pageSize"></param>
  28. /// <returns></returns>
  29. public IGridResultSet<EvaluationProjectView> GetEvaluationProjectViewGrid(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationTargetID, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  32. if (evaluationTargetID.HasValue)
  33. {
  34. exp = exp.And(x => x.EvaluationTargetID == evaluationTargetID);
  35. }
  36. var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp);
  37. if (evaluationParticipateTypeID.HasValue)
  38. {
  39. query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
  40. }
  41. if (evaluationTypeID.HasValue)
  42. {
  43. query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
  44. }
  45. if (evaluationTableID.HasValue)
  46. {
  47. query = query.Where(x => x.EvaluationTableID == evaluationTableID);
  48. }
  49. //查询条件
  50. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  51. {
  52. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  53. }
  54. return query.OrderBy(x => x.EvaluationTargetCode.Length).ThenBy(x => x.EvaluationTargetCode).ThenBy(x => x.EvaluationTargetOrderNo).ThenBy(x => x.OrderNo).ToGridResultSet<EvaluationProjectView>(pageIndex, pageSize);
  55. }
  56. /// <summary>
  57. /// 查询对应的评价项目信息List
  58. /// </summary>
  59. /// <param name="configuretView"></param>
  60. /// <param name="evaluationParticipateTypeID"></param>
  61. /// <param name="evaluationTypeID"></param>
  62. /// <param name="evaluationTableID"></param>
  63. /// <param name="evaluationTargetID"></param>
  64. /// <returns></returns>
  65. public IList<EvaluationProjectView> GetEvaluationProjectViewList(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationTargetID)
  66. {
  67. Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  68. if (evaluationTargetID.HasValue)
  69. {
  70. exp = exp.And(x => x.EvaluationTargetID == evaluationTargetID);
  71. }
  72. var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp);
  73. if (evaluationParticipateTypeID.HasValue)
  74. {
  75. query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
  76. }
  77. if (evaluationTypeID.HasValue)
  78. {
  79. query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
  80. }
  81. if (evaluationTableID.HasValue)
  82. {
  83. query = query.Where(x => x.EvaluationTableID == evaluationTableID);
  84. }
  85. //查询条件
  86. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  87. {
  88. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  89. }
  90. return query.OrderBy(x => x.EvaluationTargetCode.Length).ThenBy(x => x.EvaluationTargetCode).ThenBy(x => x.EvaluationTargetOrderNo).ThenBy(x => x.OrderNo).ToList();
  91. }
  92. /// <summary>
  93. /// 查询对应的评价项目信息List
  94. /// </summary>
  95. /// <param name="evaluationTargetID"></param>
  96. /// <returns></returns>
  97. public IList<EM_EvaluationProject> GetEvaluationProjectList(Guid? evaluationTargetID)
  98. {
  99. Expression<Func<EM_EvaluationProject, bool>> expEvaluationProject = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  100. expEvaluationProject = expEvaluationProject.And(x => x.EvaluationTargetID == evaluationTargetID);
  101. var query = EvaluationProjectDAL.EvaluationProjectRepository.GetList(expEvaluationProject);
  102. return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ThenBy(x => x.OrderNo).ToList();
  103. }
  104. /// <summary>
  105. /// 查询对应的评价项目信息EvaluationProjectView
  106. /// </summary>
  107. /// <param name="evaluationProjectID"></param>
  108. /// <returns></returns>
  109. public EvaluationProjectView GetEvaluationProjectView(Guid? evaluationProjectID)
  110. {
  111. try
  112. {
  113. Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.EvaluationProjectID == evaluationProjectID);
  114. var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp).SingleOrDefault();
  115. return query;
  116. }
  117. catch (Exception ex)
  118. {
  119. throw new Exception(ex.Message);
  120. }
  121. }
  122. /// <summary>
  123. /// 编辑
  124. /// </summary>
  125. /// <param name="evaluationProjectView"></param>
  126. public void EvaluationProjectEdit(EvaluationProjectView evaluationProjectView)
  127. {
  128. try
  129. {
  130. var evaluationProjectVerify = EvaluationProjectDAL.EvaluationProjectRepository.GetList(x => x.EvaluationProjectID != evaluationProjectView.EvaluationProjectID && x.Code == evaluationProjectView.Code.Trim()).SingleOrDefault();
  131. if (evaluationProjectVerify == null)
  132. {
  133. if (evaluationProjectView.EvaluationProjectID != Guid.Empty)
  134. {
  135. var evaluationProject = EvaluationProjectDAL.EvaluationProjectRepository.GetList(x => x.EvaluationProjectID == evaluationProjectView.EvaluationProjectID).SingleOrDefault();
  136. if (evaluationProject == null)
  137. {
  138. throw new Exception("数据有误,请核查。");
  139. }
  140. else
  141. {
  142. //表示修改
  143. evaluationProject.OrderNo = evaluationProjectView.OrderNo;
  144. evaluationProject.Code = evaluationProjectView.Code.Trim();
  145. evaluationProject.Name = evaluationProjectView.Name.Trim();
  146. evaluationProject.EvaluationTargetID = evaluationProjectView.EvaluationTargetID;
  147. evaluationProject.Weight = evaluationProjectView.Weight;
  148. evaluationProject.Remark = evaluationProjectView.Remark;
  149. SetModifyStatus(evaluationProject);
  150. }
  151. }
  152. else
  153. {
  154. //表示新增
  155. var newEvaluationProject = new EM_EvaluationProject();
  156. newEvaluationProject.EvaluationProjectID = Guid.NewGuid();
  157. newEvaluationProject.OrderNo = evaluationProjectView.OrderNo;
  158. newEvaluationProject.Code = evaluationProjectView.Code.Trim();
  159. newEvaluationProject.Name = evaluationProjectView.Name.Trim();
  160. newEvaluationProject.EvaluationTargetID = evaluationProjectView.EvaluationTargetID;
  161. newEvaluationProject.Weight = evaluationProjectView.Weight;
  162. newEvaluationProject.Remark = evaluationProjectView.Remark;
  163. SetNewStatus(newEvaluationProject);
  164. UnitOfWork.Add(newEvaluationProject);
  165. }
  166. }
  167. else
  168. {
  169. throw new Exception("已存在相同的评价项目信息(项目编号唯一),请核查。");
  170. }
  171. UnitOfWork.Commit();
  172. }
  173. catch (Exception ex)
  174. {
  175. throw new Exception(ex.Message);
  176. }
  177. }
  178. /// <summary>
  179. /// 删除
  180. /// </summary>
  181. /// <param name="evaluationProjectIDs"></param>
  182. /// <returns></returns>
  183. public bool EvaluationProjectDelete(List<Guid?> evaluationProjectIDs)
  184. {
  185. try
  186. {
  187. UnitOfWork.Delete<EM_EvaluationProject>(x => evaluationProjectIDs.Contains(x.EvaluationProjectID));
  188. return true;
  189. }
  190. catch (Exception)
  191. {
  192. throw;
  193. }
  194. }
  195. }
  196. }