예제 #1
0
        public object QueryManageDetail([FromForm] List <int> employeeIds, [FromForm] KpiPlan kpiId)
        {
            if (employeeIds.Count() > 0)
            {
                var condition = new Condition <KpiTemplateRecord>();
                condition.And(p => p.KpiType == KpiType.User);
                condition.And(p => p.KpiId == kpiId);
                if (employeeIds.Count() > 0)
                {
                    condition.And(p => employeeIds.Contains(p.EmployeeId));
                }
                var lsTpl        = _tplRecordBusiness.Query(condition.Combine());
                var lsTplContent = new List <KpiTemplateContentsDto>();
                if (lsTpl.Count() > 0)
                {
                    foreach (var item in lsTpl)
                    {
                        lsTplContent.AddRange(JsonConvert.DeserializeObject <List <KpiTemplateContentsDto> >(item.Contents).ToList());
                    }

                    return(lsTplContent
                           .GroupBy(p => new { p.EvaluationId, p.EvaluationName, p.EvaluationType })
                           .Select(p => p.Key)
                           .OrderBy(p => p.EvaluationId)
                           .Select(p => new EvaluationDto {
                        Id = p.EvaluationId, Name = p.EvaluationName, EvaluationTypeName = p.EvaluationType
                    })
                           .ToList());
                }
            }

            return(new List <EvaluationDto>());
        }
예제 #2
0
        public IList <ScheduleKPI> GetByKpi([FromForm] int eid, [FromForm] KpiPlan planId, [FromForm] DateTime startDate, [FromForm] DateTime endDate)
        {
            //先根据条件获取所有日程
            IList <Schedule> list = _scheduleBusiness.GetByKpi(eid, planId, startDate, endDate);
            //封装新集合
            IList <ScheduleKPI> newList = new List <ScheduleKPI>();

            foreach (Schedule item in list)
            {
                ScheduleKPI sm = new ScheduleKPI();
                sm.Id                  = item.Id;
                sm.Title               = item.Title;
                sm.BeginTime           = item.BeginTime;
                sm.EndTime             = item.EndTime;
                sm.KpiManageRecordId   = item.KpiManageRecordId;
                sm.KpiManageRecordName = item.KpiManageRecordName;
                //完成了的集合
                IList <ScheduleComplete> cmp = _scheduleCompleteBusiness.Get(item.Id);
                //执行人集合
                string exestring = item.Executors.Substring(1);
                exestring = exestring.Substring(0, exestring.Length - 1);
                string[] exes = exestring.Split(",");
                //如果完成数等于执行人数
                if (cmp.Count >= exes.Length)
                {
                    sm.Completion = "已完成";
                }
                else
                {
                    sm.Completion = "未完成";
                }
                newList.Add(sm);
            }
            return(newList);
        }
        /// <summary>
        /// 查询需要生成的数据
        /// </summary>
        /// <param name="kpiId">考核方案</param>
        /// <param name="year">年份</param>
        /// <param name="kpiDate">考核时间</param>
        /// <returns></returns>
        public List <KpiTemplateRecord> QueryByGenerated(KpiPlan kpiId, int year, string kpiDate)
        {
            var query = from tr in _dbContext.KpiTemplateRecord
                        where tr.KpiId == kpiId &
                        !(
                from mr in _dbContext.KpiManageRecord where mr.KpiId == kpiId & mr.Year == year & mr.KpiDate == kpiDate select mr.KpiTemplateRecordId
                ).Contains(tr.Id)
                        select tr;

            return(query.ToList());
        }
예제 #4
0
        public IList <Schedule> GetByKpi(int eid, KpiPlan planId, DateTime startDate, DateTime endDate)
        {
            List <KeyValuePair <string, OrderBy> > order = new List <KeyValuePair <string, OrderBy> >
            {
                new KeyValuePair <string, OrderBy>("AddTime", OrderBy.Desc)
            };

            return(base.Query(p => p.EmployeeId == eid && p.KpiPlan == planId &&
                              p.EndTime >= startDate.Date
                              //DateTime.Compare(DateTime.ParseExact(p.EndTime.ToString(), "yyyy-MM-dd", null),
                              //DateTime.ParseExact(startDate.ToString(), "yyyy-MM-dd", null)) >= 0
                              &&
                              p.EndTime <= endDate.Date,
                              //DateTime.Compare(DateTime.ParseExact(p.EndTime.ToString(), "yyyy-MM-dd", null),
                              //DateTime.ParseExact(endDate.ToString(), "yyyy-MM-dd", null)) <= 0,
                              p => p, order));
            //&& p.KpiPlan.Equals((KpiPlan)planId) && p.EndTime.ToString("yyyy-MM-dd").Contains(date)
        }
예제 #5
0
 public Result GeneratedManage(KpiPlan kpiId)
 {
     return(_wrappers.GeneratedManage(kpiId));
 }
 /// <summary>
 /// 查询需要生成的数据
 /// </summary>
 /// <param name="kpiId">考核方案</param>
 /// <param name="year">年份</param>
 /// <param name="kpiDate">考核时间</param>
 /// <returns></returns>
 public List <KpiTemplateRecord> QueryByGenerated(KpiPlan kpiId, int year, string kpiDate)
 {
     return(_repository.QueryByGenerated(kpiId, year, kpiDate));
 }
예제 #7
0
        /// <summary>
        /// [生成] 考核记录
        /// </summary>
        /// <param name="kpiId">考核方案</param>
        /// <returns></returns>
        public Result GeneratedManage(KpiPlan kpiId)
        {
            try
            {
                var dtNow = DateTime.Now;
                var currTime = 0;
                var currYear = dtNow.Year;

                switch (kpiId)
                {
                    case KpiPlan.Monthly:
                        currTime = dtNow.Month;
                        break;
                    case KpiPlan.Quarter:
                        currTime = TimeHelper.GetQurater(dtNow);
                        break;
                    case KpiPlan.HalfYear:
                        currTime = dtNow.Month < 7 ? 1 : 2;
                        break;
                    case KpiPlan.Annual:
                        currTime = 1;
                        break;
                }
                var kpiDate = currTime.ToString();

                using (TransactionScope ts = new TransactionScope())
                {
                    var dbTplRecord = _tplRecordBusiness.QueryByGenerated(kpiId, currYear, kpiDate);
                    if (dbTplRecord.Count <= 0)
                    {
                        return Result.Fail("没有需要生成的数据", "201");
                    }

                    //考核管理统计
                    var dbMagTotal = _magTotalBusiness.Query(p => p.KpiId == kpiId && p.Year == currYear);

                    //考核管理统计
                    var lsNotExistMagTotal = new List<KpiManageTotal>();
                    var lsExistMagTotal = new List<KpiManageTotal>();
                    //考核管理记录
                    var lsNotExistMagRecord = new List<KpiManageRecord>();
                    //考核管理明细
                    var lsNotExistMagDetail = new List<KpiManageDetail>();
                    foreach (var tplRecord in dbTplRecord)
                    {
                        #region 考核管理统计
                        KpiManageTotal modelMagTotal = null;
                        if (dbMagTotal.Count > 0)
                        {
                            modelMagTotal = dbMagTotal.FirstOrDefault(p => p.KpiType == tplRecord.KpiType && p.CompanyId == tplRecord.CompanyId && p.DptId == tplRecord.DptId && p.EmployeeId == tplRecord.EmployeeId);
                        }
                        if (modelMagTotal == null)
                        {
                            modelMagTotal = new KpiManageTotal()
                            {
                                Id = 0,
                                KpiType = tplRecord.KpiType,
                                KpiId = tplRecord.KpiId,
                                KpiName = tplRecord.KpiName,
                                CompanyId = tplRecord.CompanyId,
                                CompanyName = tplRecord.CompanyName,
                                DptId = tplRecord.DptId,
                                DptName = tplRecord.DptName,
                                EmployeeId = tplRecord.EmployeeId,
                                UserName = tplRecord.UserName,
                                Year = currYear
                            };
                            for (int i = 0; i < 12; i++)
                            {
                                DynaimcHelper.DynamicFileds[i].Score.SetValue(modelMagTotal, (decimal)0);
                                if ((i + 1) < currTime)
                                {
                                    DynaimcHelper.DynamicFileds[i].Status.SetValue(modelMagTotal, KpiStatus.Invalid);
                                }
                                else if ((i + 1) == currTime)
                                {
                                    DynaimcHelper.DynamicFileds[i].Status.SetValue(modelMagTotal, KpiStatus.Assess);
                                }
                                else
                                {
                                    DynaimcHelper.DynamicFileds[i].Status.SetValue(modelMagTotal, KpiStatus.NotStarted);
                                }
                            }
                            lsNotExistMagTotal.Add(modelMagTotal);
                        }
                        else
                        {
                            for (int i = 0; i < 12; i++)
                            {
                                if ((i + 1) == currTime)
                                {
                                    DynaimcHelper.DynamicFileds[i].Status.SetValue(modelMagTotal, KpiStatus.Assess);
                                }
                            }
                            lsExistMagTotal.Add(modelMagTotal);
                        }
                        #endregion

                        lsNotExistMagRecord.Add(new KpiManageRecord()
                        {
                            Id = 0,
                            KpiTemplateRecordId = tplRecord.Id,
                            KpiType = tplRecord.KpiType,
                            KpiId = tplRecord.KpiId,
                            KpiName = tplRecord.KpiName,
                            CompanyId = tplRecord.CompanyId,
                            CompanyName = tplRecord.CompanyName,
                            DptId = tplRecord.DptId,
                            DptName = tplRecord.DptName,
                            EmployeeId = tplRecord.EmployeeId,
                            UserName = tplRecord.UserName,
                            Year = currYear,
                            KpiDate = kpiDate,
                            Steps = KpiSteps.Zero,
                            StepsCompanyId = tplRecord.CompanyId,
                            StepsCompanyName = tplRecord.CompanyName,
                            StepsDptId = tplRecord.DptId,
                            StepsDptName = tplRecord.DptName,
                            StepsEmployeeId = tplRecord.EmployeeId,
                            StepsUserName = tplRecord.UserName,
                            AddDate = dtNow,
                            Score = 0,
                            Status = KpiStatus.Assess
                        });
                    }

                    _magRecordBusiness.AddRange(lsNotExistMagRecord);

                    foreach (var magTecord in lsNotExistMagRecord)
                    {
                        var modelTplRecord = dbTplRecord.FirstOrDefault(p => p.Id == magTecord.KpiTemplateRecordId);
                        if (modelTplRecord != null)
                        {
                            var lsTplContents = JsonConvert.DeserializeObject<List<KpiTemplateContentsDto>>(modelTplRecord.Contents).OrderBy(p => p.EvaluationId);
                            foreach (var tplContent in lsTplContents)
                            {
                                lsNotExistMagDetail.Add(new KpiManageDetail
                                {
                                    Id = 0,
                                    KpiManageRecordId = magTecord.Id,
                                    CompanyId = magTecord.CompanyId,
                                    DptId = magTecord.DptId,
                                    EmployeeId = magTecord.EmployeeId,
                                    EvaluationId = tplContent.EvaluationId,
                                    EvaluationName = tplContent.EvaluationName,
                                    EvaluationType = tplContent.EvaluationType,
                                    Weight = tplContent.Weight,
                                    Explain = tplContent.Explain,
                                    Year = magTecord.Year,
                                    KpiDate = magTecord.KpiDate,
                                    SelfScore = 0,
                                    OneScore = 0,
                                    TwoScore = 0
                                });
                            }
                        }
                    }
                    if (lsNotExistMagDetail.Count > 0)
                    {
                        _magDetailBusiness.AddRange(lsNotExistMagDetail);
                    }

                    _magTotalBusiness.AddRange(lsNotExistMagTotal);
                    if (lsExistMagTotal.Count > 0)
                    {
                        _magTotalBusiness.UpdateRange(lsExistMagTotal);
                    }

                    ts.Complete();
                    return Result.Success();
                }
            }
            catch (Exception ex)
            {
                return Result.Fail("失败:" + ex.Message);
            }
        }