123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Data;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.EvaluationTable;
- using EMIS.DataLogic.EvaluationManage.EvaluationTable;
- namespace EMIS.CommonLogic.EvaluationManage.EvaluationTable
- {
- public class EvaluationTargetServices : BaseServices, IEvaluationTargetServices
- {
- public EvaluationTargetDAL EvaluationTargetDAL { get; set; }
- /// <summary>
- /// 查询对应的评价指标信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationNormID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationTargetView> GetEvaluationTargetViewGrid(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationNormID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationTarget, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTableID.HasValue)
- {
- exp = exp.And(x => x.EvaluationTableID == evaluationTableID);
- }
- if (evaluationNormID.HasValue)
- {
- exp = exp.And(x => x.EvaluationNormID == evaluationNormID);
- }
- var query = EvaluationTargetDAL.GetEvaluationTargetViewQueryable(exp);
- if (evaluationParticipateTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EvaluationTableCode.Length).ThenBy(x => x.EvaluationTableCode).ThenBy(x => x.OrderNo).ToGridResultSet<EvaluationTargetView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的评价指标信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationNormID"></param>
- /// <returns></returns>
- public IList<EvaluationTargetView> GetEvaluationTargetViewList(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationNormID)
- {
- Expression<Func<EM_EvaluationTarget, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTableID.HasValue)
- {
- exp = exp.And(x => x.EvaluationTableID == evaluationTableID);
- }
- if (evaluationNormID.HasValue)
- {
- exp = exp.And(x => x.EvaluationNormID == evaluationNormID);
- }
- var query = EvaluationTargetDAL.GetEvaluationTargetViewQueryable(exp);
- if (evaluationParticipateTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EvaluationTableCode.Length).ThenBy(x => x.EvaluationTableCode).ThenBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询对应的评价指标信息List
- /// </summary>
- /// <param name="evaluationTargetIDList"></param>
- /// <returns></returns>
- public IList<EM_EvaluationTarget> GetEvaluationTargetList(List<Guid?> evaluationTargetIDList)
- {
- Expression<Func<EM_EvaluationTarget, bool>> expEvaluationTarget = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEvaluationTarget = expEvaluationTarget.And(x => evaluationTargetIDList.Contains(x.EvaluationTargetID));
- var query = EvaluationTargetDAL.EvaluationTargetRepository.GetList(expEvaluationTarget);
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ThenBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询对应的评价指标信息EvaluationTargetView
- /// </summary>
- /// <param name="evaluationTargetID"></param>
- /// <returns></returns>
- public EvaluationTargetView GetEvaluationTargetView(Guid? evaluationTargetID)
- {
- try
- {
- Expression<Func<EM_EvaluationTarget, bool>> exp = (x => x.EvaluationTargetID == evaluationTargetID);
- var query = EvaluationTargetDAL.GetEvaluationTargetViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="evaluationTargetView"></param>
- public void EvaluationTargetEdit(EvaluationTargetView evaluationTargetView)
- {
- try
- {
- var evaluationTargetVerify = EvaluationTargetDAL.EvaluationTargetRepository.GetList(x => x.EvaluationTargetID != evaluationTargetView.EvaluationTargetID && x.Code == evaluationTargetView.Code.Trim()).SingleOrDefault();
- if (evaluationTargetVerify == null)
- {
- if (evaluationTargetView.EvaluationTargetID != Guid.Empty)
- {
- var evaluationTarget = EvaluationTargetDAL.EvaluationTargetRepository.GetList(x => x.EvaluationTargetID == evaluationTargetView.EvaluationTargetID).SingleOrDefault();
- if (evaluationTarget == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- evaluationTarget.OrderNo = evaluationTargetView.OrderNo;
- evaluationTarget.Code = evaluationTargetView.Code.Trim();
- evaluationTarget.Name = evaluationTargetView.Name.Trim();
- evaluationTarget.EvaluationTableID = evaluationTargetView.EvaluationTableID;
- evaluationTarget.EvaluationNormID = evaluationTargetView.EvaluationNormID;
- evaluationTarget.Weight = evaluationTargetView.Weight;
- evaluationTarget.Remark = evaluationTargetView.Remark;
- SetModifyStatus(evaluationTarget);
- }
- }
- else
- {
- //表示新增
- var newEvaluationTarget = new EM_EvaluationTarget();
- newEvaluationTarget.EvaluationTargetID = Guid.NewGuid();
- newEvaluationTarget.OrderNo = evaluationTargetView.OrderNo;
- newEvaluationTarget.Code = evaluationTargetView.Code.Trim();
- newEvaluationTarget.Name = evaluationTargetView.Name.Trim();
- newEvaluationTarget.EvaluationTableID = evaluationTargetView.EvaluationTableID;
- newEvaluationTarget.EvaluationNormID = evaluationTargetView.EvaluationNormID;
- newEvaluationTarget.Weight = evaluationTargetView.Weight;
- newEvaluationTarget.Remark = evaluationTargetView.Remark;
- SetNewStatus(newEvaluationTarget);
- UnitOfWork.Add(newEvaluationTarget);
- }
- }
- else
- {
- throw new Exception("已存在相同的评价指标信息(指标编号唯一),请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationTargetIDs"></param>
- /// <returns></returns>
- public bool EvaluationTargetDelete(List<Guid?> evaluationTargetIDs)
- {
- try
- {
- UnitOfWork.Delete<EM_EvaluationTarget>(x => evaluationTargetIDs.Contains(x.EvaluationTargetID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|