EvaluationNormServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.EvaluationManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.ViewModel.EvaluationManage;
  11. namespace EMIS.CommonLogic.EvaluationManage
  12. {
  13. public class EvaluationNormServices : BaseServices, IEvaluationNormServices
  14. {
  15. public EvaluationNormDAL evaluationNormDAL { get; set; }
  16. /// <summary>
  17. /// 查询评分标准信息
  18. /// </summary>
  19. /// <param name="configuretView">查询条件实体</param>
  20. /// <param name="intType">评分类型</param>
  21. /// <param name="pageIndex">页码</param>
  22. /// <param name="pageSize">显示页数</param>
  23. /// <returns></returns>
  24. public IGridResultSet<EvaluationNormView> GetEvaluationNormViewGrid(ConfiguretView configuretView, int? intType, int pageIndex, int pageSize)
  25. {
  26. var query = evaluationNormDAL.GetEvaluationNormQueryable(x => true);
  27. if (intType.HasValue && intType > 0)
  28. query = query.Where(x => x.IntType == intType);
  29. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  30. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.Name).ToGridResultSet<EvaluationNormView>(pageIndex, pageSize);
  31. return query.OrderBy(x => x.Name).ToGridResultSet<EvaluationNormView>(pageIndex, pageSize);
  32. }
  33. /// <summary>
  34. /// 查询评分标准信息
  35. /// </summary>
  36. /// <param name="configuretView">查询条件实体</param>
  37. /// <param name="intType">评分类型</param>
  38. /// <returns></returns>
  39. public List<EvaluationNormView> GetEvaluationNormViewList(ConfiguretView configuretView, int? intType)
  40. {
  41. var query = evaluationNormDAL.GetEvaluationNormQueryable(x => true);
  42. if (intType.HasValue && intType > 0)
  43. query = query.Where(x => x.IntType == intType);
  44. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  45. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.CreateTime).ToList();
  46. return query.OrderByDescending(x => x.CreateTime).ToList();
  47. }
  48. /// <summary>
  49. /// 获取评分标准信息
  50. /// </summary>
  51. /// <param name="normID">主键ID</param>
  52. /// <returns></returns>
  53. public EMIS.Entities.EM_EvaluationNorm GetEvaluationNorm(Guid? normID)
  54. {
  55. //查询条件
  56. Expression<Func<EMIS.Entities.EM_EvaluationNorm, bool>> expression = (x => x.EvaluationNormID == normID.Value);
  57. return evaluationNormDAL.evaluationNormRepository.GetSingle(expression, (x => x.EM_EvaluationNormDetail));
  58. }
  59. /// <summary>
  60. /// 获取评分标准信息
  61. /// </summary>
  62. /// <param name="Name">评分标准名称</param>
  63. /// <returns></returns>
  64. public EMIS.Entities.EM_EvaluationNorm GetEvaluationNorm(string Name)
  65. {
  66. //查询条件
  67. Expression<Func<EMIS.Entities.EM_EvaluationNorm, bool>> expression = (x => x.Name == Name);
  68. return evaluationNormDAL.evaluationNormRepository.GetSingle(expression);
  69. }
  70. /// <summary>
  71. /// 获取评分标准信息
  72. /// </summary>
  73. /// <param name="normID">主键ID</param>
  74. /// <returns></returns>
  75. public EvaluationNormView GetEvaluationNormView(Guid? normID)
  76. {
  77. EvaluationNormView evaluationNormView = new EvaluationNormView();
  78. if (normID.HasValue && normID != Guid.Empty)
  79. evaluationNormView = evaluationNormDAL.GetEvaluationNormQueryable(x => true).Where(x => x.NormID == normID).FirstOrDefault();
  80. return evaluationNormView;
  81. }
  82. /// <summary>
  83. /// 添加
  84. /// </summary>
  85. /// <param name="evaluationNorm">实体</param>
  86. /// <returns></returns>
  87. public bool EvaluationNormAdd(EMIS.Entities.EM_EvaluationNorm evaluationNorm)
  88. {
  89. try
  90. {
  91. UnitOfWork.Add(evaluationNorm);
  92. UnitOfWork.Commit();
  93. return true;
  94. }
  95. catch (Exception)
  96. {
  97. throw;
  98. }
  99. }
  100. /// <summary>
  101. /// 修改
  102. /// </summary>
  103. /// <param name="evaluationNorm">实体</param>
  104. /// <returns></returns>
  105. public bool EvaluationNormUpdate(EMIS.Entities.EM_EvaluationNorm evaluationNorm)
  106. {
  107. try
  108. {
  109. UnitOfWork.Update(evaluationNorm);
  110. UnitOfWork.Commit();
  111. return true;
  112. }
  113. catch (Exception)
  114. {
  115. throw;
  116. }
  117. }
  118. /// <summary>
  119. /// 删除
  120. /// </summary>
  121. /// <param name="normIDs"></param>
  122. /// <returns></returns>
  123. public bool EvaluationNormDelete(List<Guid> normIDs)
  124. {
  125. try
  126. {
  127. UnitOfWork.Remove<EM_EvaluationNormDetail>(w => normIDs.Contains(w.EvaluationNormID.Value));
  128. UnitOfWork.Remove<EM_EvaluationNorm>(x => normIDs.Contains(x.EvaluationNormID));
  129. UnitOfWork.Commit();
  130. return true;
  131. }
  132. catch (Exception)
  133. {
  134. throw;
  135. }
  136. }
  137. /// <summary>
  138. /// 获取评分标准明细信息
  139. /// </summary>
  140. /// <param name="detailID">主键ID</param>
  141. /// <returns></returns>
  142. public EMIS.Entities.EM_EvaluationNormDetail GetEvaluationNormDetail(Guid? detailID)
  143. {
  144. Expression<Func<EMIS.Entities.EM_EvaluationNormDetail, bool>> expression = (x => x.EvaluationNormDetailID == detailID.Value);
  145. return evaluationNormDAL.evaluationNormDetailRepository.GetSingle(expression);
  146. }
  147. /// <summary>
  148. /// 获取评分标准明细信息
  149. /// </summary>
  150. /// <param name="Name">评分标准名称</param>
  151. /// <returns></returns>
  152. public EMIS.Entities.EM_EvaluationNormDetail GetEvaluationNormDetail(string Name)
  153. {
  154. Expression<Func<EMIS.Entities.EM_EvaluationNormDetail, bool>> expression = (x => x.Name == Name);
  155. return evaluationNormDAL.evaluationNormDetailRepository.GetSingle(expression);
  156. }
  157. /// <summary>
  158. /// 获取评分标准明细信息
  159. /// </summary>
  160. /// <param name="detailID">主键ID</param>
  161. /// <returns></returns>
  162. public EvaluationNormDetailView GetEvaluationNormDetailView(Guid? detailID)
  163. {
  164. EvaluationNormDetailView evaluationNormDetailView = new EvaluationNormDetailView();
  165. if (detailID.HasValue && detailID != Guid.Empty)
  166. evaluationNormDetailView = evaluationNormDAL.GetEvaluationNormDetailQueryable(x => true).Where(x => x.DetailID == detailID).FirstOrDefault();
  167. return evaluationNormDetailView;
  168. }
  169. public void Save(EvaluationNormView norm, IList<EvaluationNormDetailView> detailList)
  170. {
  171. EMIS.Entities.EM_EvaluationNorm evaluationNorm = this.GetEvaluationNorm(norm.NormID);
  172. if (this.evaluationNormDAL.evaluationNormRepository
  173. .GetList(x => x.Name == norm.Name && x.EvaluationNormID != norm.NormID).Count() > 0)
  174. {
  175. throw new Exception("评分标准名称已存在,请重新输入!");
  176. }
  177. if (evaluationNorm == null)
  178. {
  179. evaluationNorm = new EM_EvaluationNorm();
  180. evaluationNorm.EvaluationNormID = Guid.NewGuid();
  181. this.SetNewStatus(evaluationNorm);
  182. this.UnitOfWork.Add(evaluationNorm);
  183. }
  184. else
  185. {
  186. this.SetModifyStatus(evaluationNorm);
  187. }
  188. //evaluationNorm.Code = norm.Code;
  189. evaluationNorm.Name = norm.Name;
  190. evaluationNorm.NormTypeID = norm.IntType;
  191. evaluationNorm.SatisfyWeight = norm.SatisfyWeight;
  192. evaluationNorm.Remark = norm.Remark;
  193. if (evaluationNorm.NormTypeID == (int)EM_EvaluationNormType.CheckBox)
  194. {
  195. if (evaluationNorm.EM_EvaluationNormDetail.Count > 0)
  196. {
  197. evaluationNorm.EM_EvaluationNormDetail.ToList().ForEach(x => this.UnitOfWork.Remove(x));
  198. evaluationNorm.EM_EvaluationNormDetail = new HashSet<EM_EvaluationNormDetail>();
  199. }
  200. foreach (var item in detailList)
  201. {
  202. EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail = new EMIS.Entities.EM_EvaluationNormDetail();
  203. evaluationNormDetail.EvaluationNormDetailID = Guid.NewGuid();
  204. evaluationNormDetail.EvaluationNormID = evaluationNorm.EvaluationNormID;
  205. evaluationNormDetail.OrderNo = item.OrderID;
  206. evaluationNormDetail.Name = item.Name;
  207. evaluationNormDetail.Weight = (decimal)item.Weight;
  208. evaluationNormDetail.Remark = item.Remark;
  209. this.SetNewStatus(evaluationNormDetail);
  210. evaluationNorm.EM_EvaluationNormDetail.Add(evaluationNormDetail);
  211. }
  212. }
  213. this.UnitOfWork.Commit();
  214. }
  215. /// <summary>
  216. /// 添加
  217. /// </summary>
  218. /// <param name="evaluationNormDetail">实体</param>
  219. /// <returns></returns>
  220. public bool EvaluationNormDetailAdd(EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail)
  221. {
  222. try
  223. {
  224. UnitOfWork.Add(evaluationNormDetail);
  225. UnitOfWork.Commit();
  226. return true;
  227. }
  228. catch (Exception)
  229. {
  230. throw;
  231. }
  232. }
  233. /// <summary>
  234. /// 修改
  235. /// </summary>
  236. /// <param name="evaluationNormDetail">实体</param>
  237. /// <returns></returns>
  238. public bool EvaluationNormDetailUpdate(EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail)
  239. {
  240. try
  241. {
  242. UnitOfWork.Update(evaluationNormDetail);
  243. UnitOfWork.Commit();
  244. return true;
  245. }
  246. catch (Exception)
  247. {
  248. throw;
  249. }
  250. }
  251. /// <summary>
  252. /// 删除
  253. /// </summary>
  254. /// <param name="detailIDs"></param>
  255. /// <returns></returns>
  256. public bool EvaluationNormDetailDelete(List<Guid> detailIDs)
  257. {
  258. try
  259. {
  260. UnitOfWork.Delete<EMIS.Entities.EM_EvaluationNormDetail>(x => detailIDs.Contains(x.EvaluationNormDetailID));
  261. UnitOfWork.Commit();
  262. return true;
  263. }
  264. catch (Exception)
  265. {
  266. throw;
  267. }
  268. }
  269. public IList<EvaluationNormDetailView> GetEvaluationNormDetailViewList(Guid normID)
  270. {
  271. return evaluationNormDAL.GetEvaluationNormDetailQueryable(x => x.EvaluationNormID == normID).OrderBy(o => o.OrderID).ToList();
  272. }
  273. public IList<EvaluationNormDetailView> GetEvaluationNormOrProjectDetailViewList(Guid normID)
  274. {
  275. return evaluationNormDAL.GetEvaluationNormDetailOrProjectQueryable(x => x.EvaluationNormID == normID).OrderByDescending(o => o.Weight).ToList();
  276. }
  277. }
  278. }