123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.EvaluationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.ViewModel.EvaluationManage;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationNormServices : BaseServices, IEvaluationNormServices
- {
- public EvaluationNormDAL evaluationNormDAL { get; set; }
- /// <summary>
- /// 查询评分标准信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="intType">评分类型</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<EvaluationNormView> GetEvaluationNormViewGrid(ConfiguretView configuretView, int? intType, int pageIndex, int pageSize)
- {
- var query = evaluationNormDAL.GetEvaluationNormQueryable(x => true);
- if (intType.HasValue && intType > 0)
- query = query.Where(x => x.IntType == intType);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.Name).ToGridResultSet<EvaluationNormView>(pageIndex, pageSize);
- return query.OrderBy(x => x.Name).ToGridResultSet<EvaluationNormView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询评分标准信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="intType">评分类型</param>
- /// <returns></returns>
- public List<EvaluationNormView> GetEvaluationNormViewList(ConfiguretView configuretView, int? intType)
- {
- var query = evaluationNormDAL.GetEvaluationNormQueryable(x => true);
- if (intType.HasValue && intType > 0)
- query = query.Where(x => x.IntType == intType);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.CreateTime).ToList();
- return query.OrderByDescending(x => x.CreateTime).ToList();
- }
- /// <summary>
- /// 获取评分标准信息
- /// </summary>
- /// <param name="normID">主键ID</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationNorm GetEvaluationNorm(Guid? normID)
- {
- //查询条件
- Expression<Func<EMIS.Entities.EM_EvaluationNorm, bool>> expression = (x => x.EvaluationNormID == normID.Value);
- return evaluationNormDAL.evaluationNormRepository.GetSingle(expression, (x => x.EM_EvaluationNormDetail));
- }
- /// <summary>
- /// 获取评分标准信息
- /// </summary>
- /// <param name="Name">评分标准名称</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationNorm GetEvaluationNorm(string Name)
- {
- //查询条件
- Expression<Func<EMIS.Entities.EM_EvaluationNorm, bool>> expression = (x => x.Name == Name);
- return evaluationNormDAL.evaluationNormRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取评分标准信息
- /// </summary>
- /// <param name="normID">主键ID</param>
- /// <returns></returns>
- public EvaluationNormView GetEvaluationNormView(Guid? normID)
- {
- EvaluationNormView evaluationNormView = new EvaluationNormView();
- if (normID.HasValue && normID != Guid.Empty)
- evaluationNormView = evaluationNormDAL.GetEvaluationNormQueryable(x => true).Where(x => x.NormID == normID).FirstOrDefault();
- return evaluationNormView;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="evaluationNorm">实体</param>
- /// <returns></returns>
- public bool EvaluationNormAdd(EMIS.Entities.EM_EvaluationNorm evaluationNorm)
- {
- try
- {
- UnitOfWork.Add(evaluationNorm);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="evaluationNorm">实体</param>
- /// <returns></returns>
- public bool EvaluationNormUpdate(EMIS.Entities.EM_EvaluationNorm evaluationNorm)
- {
- try
- {
- UnitOfWork.Update(evaluationNorm);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="normIDs"></param>
- /// <returns></returns>
- public bool EvaluationNormDelete(List<Guid> normIDs)
- {
- try
- {
- UnitOfWork.Remove<EM_EvaluationNormDetail>(w => normIDs.Contains(w.EvaluationNormID.Value));
- UnitOfWork.Remove<EM_EvaluationNorm>(x => normIDs.Contains(x.EvaluationNormID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取评分标准明细信息
- /// </summary>
- /// <param name="detailID">主键ID</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationNormDetail GetEvaluationNormDetail(Guid? detailID)
- {
- Expression<Func<EMIS.Entities.EM_EvaluationNormDetail, bool>> expression = (x => x.EvaluationNormDetailID == detailID.Value);
- return evaluationNormDAL.evaluationNormDetailRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取评分标准明细信息
- /// </summary>
- /// <param name="Name">评分标准名称</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationNormDetail GetEvaluationNormDetail(string Name)
- {
- Expression<Func<EMIS.Entities.EM_EvaluationNormDetail, bool>> expression = (x => x.Name == Name);
- return evaluationNormDAL.evaluationNormDetailRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取评分标准明细信息
- /// </summary>
- /// <param name="detailID">主键ID</param>
- /// <returns></returns>
- public EvaluationNormDetailView GetEvaluationNormDetailView(Guid? detailID)
- {
- EvaluationNormDetailView evaluationNormDetailView = new EvaluationNormDetailView();
- if (detailID.HasValue && detailID != Guid.Empty)
- evaluationNormDetailView = evaluationNormDAL.GetEvaluationNormDetailQueryable(x => true).Where(x => x.DetailID == detailID).FirstOrDefault();
- return evaluationNormDetailView;
- }
- public void Save(EvaluationNormView norm, IList<EvaluationNormDetailView> detailList)
- {
- EMIS.Entities.EM_EvaluationNorm evaluationNorm = this.GetEvaluationNorm(norm.NormID);
- if (this.evaluationNormDAL.evaluationNormRepository
- .GetList(x => x.Name == norm.Name && x.EvaluationNormID != norm.NormID).Count() > 0)
- {
- throw new Exception("评分标准名称已存在,请重新输入!");
- }
- if (evaluationNorm == null)
- {
- evaluationNorm = new EM_EvaluationNorm();
- evaluationNorm.EvaluationNormID = Guid.NewGuid();
- this.SetNewStatus(evaluationNorm);
- this.UnitOfWork.Add(evaluationNorm);
- }
- else
- {
- this.SetModifyStatus(evaluationNorm);
- }
- //evaluationNorm.Code = norm.Code;
- evaluationNorm.Name = norm.Name;
- evaluationNorm.NormTypeID = norm.IntType;
- evaluationNorm.SatisfyWeight = norm.SatisfyWeight;
- evaluationNorm.Remark = norm.Remark;
- if (evaluationNorm.NormTypeID == (int)EM_EvaluationNormType.CheckBox)
- {
- if (evaluationNorm.EM_EvaluationNormDetail.Count > 0)
- {
- evaluationNorm.EM_EvaluationNormDetail.ToList().ForEach(x => this.UnitOfWork.Remove(x));
- evaluationNorm.EM_EvaluationNormDetail = new HashSet<EM_EvaluationNormDetail>();
- }
- foreach (var item in detailList)
- {
- EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail = new EMIS.Entities.EM_EvaluationNormDetail();
- evaluationNormDetail.EvaluationNormDetailID = Guid.NewGuid();
- evaluationNormDetail.EvaluationNormID = evaluationNorm.EvaluationNormID;
- evaluationNormDetail.OrderNo = item.OrderID;
- evaluationNormDetail.Name = item.Name;
- evaluationNormDetail.Weight = (decimal)item.Weight;
- evaluationNormDetail.Remark = item.Remark;
- this.SetNewStatus(evaluationNormDetail);
- evaluationNorm.EM_EvaluationNormDetail.Add(evaluationNormDetail);
- }
- }
- this.UnitOfWork.Commit();
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="evaluationNormDetail">实体</param>
- /// <returns></returns>
- public bool EvaluationNormDetailAdd(EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail)
- {
- try
- {
- UnitOfWork.Add(evaluationNormDetail);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="evaluationNormDetail">实体</param>
- /// <returns></returns>
- public bool EvaluationNormDetailUpdate(EMIS.Entities.EM_EvaluationNormDetail evaluationNormDetail)
- {
- try
- {
- UnitOfWork.Update(evaluationNormDetail);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="detailIDs"></param>
- /// <returns></returns>
- public bool EvaluationNormDetailDelete(List<Guid> detailIDs)
- {
- try
- {
- UnitOfWork.Delete<EMIS.Entities.EM_EvaluationNormDetail>(x => detailIDs.Contains(x.EvaluationNormDetailID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IList<EvaluationNormDetailView> GetEvaluationNormDetailViewList(Guid normID)
- {
- return evaluationNormDAL.GetEvaluationNormDetailQueryable(x => x.EvaluationNormID == normID).OrderBy(o => o.OrderID).ToList();
- }
- public IList<EvaluationNormDetailView> GetEvaluationNormOrProjectDetailViewList(Guid normID)
- {
- return evaluationNormDAL.GetEvaluationNormDetailOrProjectQueryable(x => x.EvaluationNormID == normID).OrderByDescending(o => o.Weight).ToList();
- }
- }
- }
|