protected void Page_Load(object sender, EventArgs e) { DeptExamineRelation ent = null; switch (RequestActionString) { case "delete": id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { sql = @"select Count(A.Id) from BJKY_Examine..ExamineStage as A left join BJKY_Examine..ExamineStageDetail as B on A.Id=B.ExamineStageId where B.ExamineRelationId='" + id + "'"; int result = DataHelper.QueryValue <int>(sql); if (result > 0) { PageState.Add("Allow", "F"); } else { ent = DeptExamineRelation.Find(id); ent.DoDelete(); PageState.Add("Allow", "T"); } } break; default: DoSelect(); break; } }
private void CreateTask() { IList <ExamineStageDetail> esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, esEnt.Id); foreach (ExamineStageDetail esdEnt in esdEnts) { DeptExamineRelation derEnt = DeptExamineRelation.Find(esdEnt.ExamineRelationId); string[] beUserIdArray = new string[] { }; string[] beUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(derEnt.BeUserIds)) { beUserIdArray = derEnt.BeUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); beUserNameArray = derEnt.BeUserNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } string toUserIds = derEnt.UpLevelUserIds + "," + derEnt.SameLevelUserIds + "," + derEnt.DownLevelUserIds; string toUserNames = derEnt.UpLevelUserNames + "," + derEnt.SameLevelUserNames + "," + derEnt.DownLevelUserNames; string[] toUserIdArray = new string[] { }; string[] toUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(toUserIds)) { toUserIdArray = toUserIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); toUserNameArray = toUserNames.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int i = 0; i < beUserIdArray.Length; i++) { //2013-12-5追加功能 生成考核任务的时候针对每一个考核对象,自动创建本阶段考核的自定义考核指标 CreateCustomIndicator(beUserIdArray[i], beUserNameArray[i], esEnt, esdEnt); for (int j = 0; j < toUserIdArray.Length; j++) { if (beUserIdArray[i] != toUserIdArray[j])//防止一个人身兼两职。自己对自己不能打分 { ExamineTask etEnt = new ExamineTask(); etEnt.ExamineStageId = esEnt.Id; etEnt.BeUserId = beUserIdArray[i]; etEnt.BeUserName = beUserNameArray[i]; string[] bedept = Utility.GetDeptInfo(beUserIdArray[i]); etEnt.BeDeptId = bedept[0]; etEnt.BeDeptName = bedept[1]; etEnt.ToUserId = toUserIdArray[j]; etEnt.ToUserName = toUserNameArray[j]; string[] todept = Utility.GetDeptInfo(toUserIdArray[j]); etEnt.ToDeptId = todept[0]; etEnt.ToDeptName = todept[1]; etEnt.ExamineRelationId = esdEnt.ExamineRelationId; etEnt.ExamineIndicatorId = esdEnt.ExamineIndicatorId; etEnt.State = "0"; etEnt.DoCreate(); } } } } }
protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ent = DeptExamineRelation.Find(id); } IList <string> strList1 = RequestData.GetList <string>("data1"); IList <string> strList2 = RequestData.GetList <string>("data2"); IList <string> strList3 = RequestData.GetList <string>("data3"); IList <string> strList4 = RequestData.GetList <string>("data4"); switch (RequestActionString) { case "update": ent = GetMergedData <DeptExamineRelation>(); UpdateToField(strList1, "data1"); UpdateToField(strList2, "data2"); UpdateToField(strList3, "data3"); UpdateToField(strList4, "data4"); ent.DoUpdate(); break; case "create": ent = GetPostedData <DeptExamineRelation>(); ent.DoCreate(); UpdateToField(strList1, "data1"); UpdateToField(strList2, "data2"); UpdateToField(strList3, "data3"); UpdateToField(strList4, "data4"); ent.DoUpdate(); break; default: DoSelect(); break; } }
private void StartExamine() { IList <ExamineStageDetail> esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, esEnt.Id); if (esEnt.ExamineType == "院级考核") { foreach (ExamineStageDetail esdEnt in esdEnts) { string beUserIds = string.Empty;//存储被考核对象具体的人 string beUserNames = string.Empty; string beDeptIds = string.Empty; string beDeptNames = string.Empty; string[] array = GetBeUsersInfo(esdEnt); beUserIds = array[0]; beUserNames = array[1]; beDeptIds = array[2]; beDeptNames = array[3]; ExamineRelation erEnt = ExamineRelation.Find(esdEnt.ExamineRelationId); ConfirmPara(beUserIds, beUserNames, beDeptIds, beDeptNames, esdEnt, erEnt); CreateSpecialTask(beUserIds, beUserNames, beDeptIds, beDeptNames, esdEnt); } } else//部门级考核 { foreach (ExamineStageDetail esdEnt in esdEnts) { DeptExamineRelation derEnt = DeptExamineRelation.Find(esdEnt.ExamineRelationId); string[] beUserIdArray = new string[] { }; string[] beUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(derEnt.BeUserIds)) { beUserIdArray = derEnt.BeUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); beUserNameArray = derEnt.BeUserNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } string toUserIds = derEnt.UpLevelUserIds + "," + derEnt.SameLevelUserIds + "," + derEnt.DownLevelUserIds; string toUserNames = derEnt.UpLevelUserNames + "," + derEnt.SameLevelUserNames + "," + derEnt.DownLevelUserNames; string[] toUserIdArray = new string[] { }; string[] toUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(toUserIds)) { toUserIdArray = toUserIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); toUserNameArray = toUserNames.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int i = 0; i < beUserIdArray.Length; i++) { for (int j = 0; j < toUserIdArray.Length; j++) { if (beUserIdArray[i] != toUserIdArray[j]) //防止一个人身兼两职。自己对自己不能打分 { TempTask etEnt = new TempTask(); //部门级考核不存在角色的概念。直接对人生成任务 etEnt.ExamineStageId = esEnt.Id; etEnt.BeUserId = beUserIdArray[i]; etEnt.BeUserName = beUserNameArray[i]; etEnt.BeDeptId = esEnt.LaunchDeptId; etEnt.BeDeptName = esEnt.LaunchDeptName; etEnt.ToUserId = toUserIdArray[j]; etEnt.ToUserName = toUserNameArray[j]; etEnt.ToDeptId = esEnt.LaunchDeptId; etEnt.ToDeptName = esEnt.LaunchDeptName; etEnt.ExamineRelationId = esdEnt.ExamineRelationId; etEnt.ExamineIndicatorId = esdEnt.ExamineIndicatorId; etEnt.State = "0"; etEnt.DoCreate(); } } } } } }
private void EndExamine() { IList <ExamineStageDetail> esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, id); #region 院级考核算分 if (esEnt.ExamineType == "院级考核") { string beUserIds = string.Empty;//存储被考核对象具体的人 string beUserNames = string.Empty; string beDeptIds = string.Empty; string beDeptNames = string.Empty; foreach (ExamineStageDetail esdEnt in esdEnts)//循环考核对象 { string[] array = GetBeUsersInfo(esdEnt); beUserIds = array[0]; beUserNames = array[1]; beDeptIds = array[2]; beDeptNames = array[3]; //人+部门+被考核对象CODE就可以找到这个其下所有的任务 不能单纯按人查。因为有特例。一个人在在多个部门任职 string[] beUserIdArray = new string[] { }; string[] beUserNameArray = new string[] { }; string[] beDeptIdArray = new string[] { }; string[] beDeptNameArray = new string[] { }; if (!string.IsNullOrEmpty(beUserIds))//防止部分角色下无人 { beUserIdArray = beUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrEmpty(beUserNames)) { beUserNameArray = beUserNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrEmpty(beDeptIds)) { beDeptIdArray = beDeptIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrEmpty(beDeptNames)) { beDeptNameArray = beDeptNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } ExamineRelation erEnt = ExamineRelation.Find(esdEnt.ExamineRelationId); string UpLevelCode = ""; string SameLevelCode = ""; string DownLevelCode = ""; if (!string.IsNullOrEmpty(erEnt.UpLevelCode)) { string[] upArray = erEnt.UpLevelCode.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int n = 0; n < upArray.Length; n++) { if (n != upArray.Length - 1) { UpLevelCode += "'" + upArray[n] + "',"; } else { UpLevelCode += "'" + upArray[n] + "'"; } } } if (!string.IsNullOrEmpty(erEnt.SameLevelCode)) { string[] sameArray = erEnt.SameLevelCode.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int n = 0; n < sameArray.Length; n++) { if (n != sameArray.Length - 1) { SameLevelCode += "'" + sameArray[n] + "',"; } else { SameLevelCode += "'" + sameArray[n] + "'"; } } } if (!string.IsNullOrEmpty(erEnt.DownLevelCode)) { string[] downArray = erEnt.DownLevelCode.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int n = 0; n < downArray.Length; n++) { if (n != downArray.Length - 1) { DownLevelCode += "'" + downArray[n] + "',"; } else { DownLevelCode += "'" + downArray[n] + "'"; } } } #region 开始计算个人成绩 for (int i = 0; i < beUserIdArray.Length; i++) { ExamineStageResult esrEnt = new ExamineStageResult(); esrEnt.ExamineStageId = esEnt.Id; esrEnt.BeRoleCode = esdEnt.BeRoleCode; esrEnt.BeRoleName = esdEnt.BeRoleName; esrEnt.UserId = beUserIdArray[i]; esrEnt.UserName = beUserNameArray[i]; esrEnt.DeptId = beDeptIdArray[i]; esrEnt.DeptName = beDeptNameArray[i]; esrEnt.StageType = esEnt.StageType; esrEnt.Year = esEnt.Year; //分别计算上级 同级 下级评分 decimal tempScore = 0; string subBalanceUserIds = ""; int subBalanceWeightTotal = 0; if (esdEnt.BeRoleCode == "BeBusinessDeptLeader")//经营目标单位正职 (有一部分特殊任务) 需要计算特殊分 Tag='1' { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and Tag='1'"; sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i]); tempScore = DataHelper.QueryValue <decimal>(sql); } if (!string.IsNullOrEmpty(UpLevelCode))//如果有上级考核对象 { //因为考核关系有时候需要把级别权重拆分到人分权重 不能单独取所有上级的平均分 //20130430 已更新到如下代码 IList <UserBalance> ubEnts = UserBalance.FindAllByProperties("ExamineRelationId", erEnt.Id, "ToRoleCode", "UpLevel");//该考核关系下 上级考核的人员权重明细 foreach (UserBalance ubEnt in ubEnts) { if (ubEnt.Balance > 0) { subBalanceUserIds += ubEnt.ToUserId + ","; subBalanceWeightTotal += ubEnt.Balance.Value; } } decimal subScore = 0; if (subBalanceWeightTotal < 100) //如果人员权重没有将100的总权重分配完 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and ToRoleCode in (" + UpLevelCode + ") and PatIndex('%ToUserId%','{4}')= 0"; //去掉已分配人员权重的人 sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i], subBalanceUserIds); if (DataHelper.QueryValue <decimal>(sql) > 0) { foreach (UserBalance ubEnt in ubEnts) { if (ubEnt.Balance > 0) { sql = @"select top 1 Score from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and ToUserId='{4}'"; sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i], ubEnt.ToUserId); subScore += DataHelper.QueryValue <decimal>(sql) * (ubEnt.Balance.Value / 100); } } esrEnt.UpAvgScore = subScore + (DataHelper.QueryValue <decimal>(sql) * (100 - subBalanceWeightTotal) / 100) + tempScore; } else //如果没有其他的分数,但权重又没有分配完 { foreach (UserBalance ubEnt in ubEnts) { if (ubEnt.Balance > 0) { sql = @"select top 1 Score from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and ToUserId='{4}'"; sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i], ubEnt.ToUserId); subScore += DataHelper.QueryValue <decimal>(sql) * (ubEnt.Balance.Value / subBalanceWeightTotal); } } esrEnt.UpAvgScore = subScore + tempScore; } } else//如果人员权重已经满100,这个时候不计算已打分但未分配子权重的人员提交的考核任务 { esrEnt.UpAvgScore = subScore + tempScore; } } if (!string.IsNullOrEmpty(SameLevelCode))//如果有同级考核对象 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and ToRoleCode in (" + SameLevelCode + ")"; sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i]); esrEnt.SameAvgScore = DataHelper.QueryValue <decimal>(sql) + tempScore; } if (!string.IsNullOrEmpty(DownLevelCode))//如果有下级考核对象 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeRoleCode='{1}' and BeDeptId='{2}' and BeUserId='{3}' and ToRoleCode in (" + DownLevelCode + ")"; sql = string.Format(sql, esEnt.Id, esdEnt.BeRoleCode, beDeptIdArray[i], beUserIdArray[i]); esrEnt.DownAvgScore = DataHelper.QueryValue <decimal>(sql) + tempScore; } decimal score = 0; //这里需要考虑一种特例就是 权重配好了 但可能没人给他打分 就是有权重 无分的现象 这个时候该权重不计入总权重 int upWeight = 0; int sameWeight = 0; int downWeight = 0; if (erEnt.UpLevelWeight > 0 && esrEnt.UpAvgScore > 0) { upWeight = erEnt.UpLevelWeight.Value; } if (erEnt.SameLevelWeight > 0 && esrEnt.SameAvgScore > 0) { sameWeight = erEnt.SameLevelWeight.Value; } if (erEnt.DownLevelWeight > 0 && esrEnt.DownAvgScore > 0) { downWeight = erEnt.DownLevelWeight.Value; } int totalWeight = upWeight + sameWeight + downWeight; if (upWeight > 0 && esrEnt.UpAvgScore > 0) { score += (((decimal)upWeight / (decimal)totalWeight) * esrEnt.UpAvgScore).Value; } if (sameWeight > 0 && esrEnt.SameAvgScore > 0) { score += (((decimal)sameWeight / (decimal)totalWeight) * esrEnt.SameAvgScore).Value; } if (downWeight > 0 && esrEnt.DownAvgScore > 0) { score += (((decimal)downWeight / (decimal)totalWeight) * esrEnt.DownAvgScore).Value; } esrEnt.Score = score; esrEnt.SortIndex = i + 1; esrEnt.DoCreate(); } #endregion } } #endregion #region 部门级考核 else //部门级考核关联的是部门级考核关系 { foreach (ExamineStageDetail esdEnt in esdEnts) { DeptExamineRelation derEnt = DeptExamineRelation.Find(esdEnt.ExamineRelationId); string[] beUserIdArray = new string[] { }; string[] beUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(derEnt.BeUserIds)) { beUserIdArray = derEnt.BeUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); beUserNameArray = derEnt.BeUserNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int i = 0; i < beUserIdArray.Length; i++) { ExamineStageResult esrEnt = new ExamineStageResult(); esrEnt.ExamineStageId = esEnt.Id; esrEnt.UserId = beUserIdArray[i]; esrEnt.UserName = beUserNameArray[i]; esrEnt.DeptId = esEnt.LaunchDeptId; esrEnt.DeptName = esEnt.LaunchDeptName; esrEnt.StageType = esEnt.StageType; esrEnt.Year = esEnt.Year; //分别计算上级 同级 下级评分 if (!string.IsNullOrEmpty(derEnt.UpLevelUserIds))//如果有上级考核人 { // IList<UserBalance> ubEnts = UserBalance.FindAllByProperties("ExamineRelationId", derEnt.Id, "ToRoleCode", "UpLevel");//该考核关系下 上级考核的人员权重明细 decimal subScore = 0; // if (ubEnts.Count > 0)//如果存在人员权重 // { // foreach (UserBalance ubEnt in ubEnts) // { // if (ubEnt.Balance > 0) // { // sql = @"select top 1 Score from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' // and BeUserId='{1}' and ToUserId ='{2}'"; // sql = string.Format(sql, esEnt.Id, beUserIdArray[i], ubEnt.ToUserId); // subScore += DataHelper.QueryValue<decimal>(sql) * (ubEnt.Balance.Value / 100); // } // } // } // else // { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.UpLevelUserIds); subScore = DataHelper.QueryValue <decimal>(sql); // } esrEnt.UpAvgScore = subScore; } if (!string.IsNullOrEmpty(derEnt.SameLevelUserIds))//如果有同级考核人 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.SameLevelUserIds); esrEnt.SameAvgScore = DataHelper.QueryValue <decimal>(sql); } if (!string.IsNullOrEmpty(derEnt.DownLevelUserIds))//如果有下级考核人 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.DownLevelUserIds); esrEnt.DownAvgScore = DataHelper.QueryValue <decimal>(sql); } decimal score = 0; //这里需要考虑一种特例就是 权重配好了 但可能没人给他打分 就是有权重 无分的现象 这个时候该权重不计入总权重 int upWeight = 0; int sameWeight = 0; int downWeight = 0; if (derEnt.UpLevelWeight > 0 && esrEnt.UpAvgScore > 0) { upWeight = derEnt.UpLevelWeight.Value; } if (derEnt.SameLevelWeight > 0 && esrEnt.SameAvgScore > 0) { sameWeight = derEnt.SameLevelWeight.Value; } if (derEnt.DownLevelWeight > 0 && esrEnt.DownAvgScore > 0) { downWeight = derEnt.DownLevelWeight.Value; } int totalWeight = upWeight + sameWeight + downWeight; if (upWeight > 0 && esrEnt.UpAvgScore > 0) { score += (((decimal)upWeight / (decimal)totalWeight) * esrEnt.UpAvgScore).Value; } if (sameWeight > 0 && esrEnt.SameAvgScore > 0) { score += (((decimal)sameWeight / (decimal)totalWeight) * esrEnt.SameAvgScore).Value; } if (downWeight > 0 && esrEnt.DownAvgScore > 0) { score += (((decimal)downWeight / (decimal)totalWeight) * esrEnt.DownAvgScore).Value; } esrEnt.Score = score; esrEnt.SortIndex = i + 1; esrEnt.DoCreate(); } } } #endregion IList <ExamineTask> etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, esEnt.Id); //更改任务状态 foreach (ExamineTask etEnt in etEnts) { //0 表示已生成的任务 1 表示已启动的任务 可以打分 if (etEnt.State == "2") //提交的任务 { etEnt.State = "3"; //已结束的任务 } else { etEnt.State = "4";//已作废的任务 } etEnt.DoUpdate(); } if (esEnt.StageType == "4") { CaculateYearResult(); } esEnt.State = 3; // 0: '已创建', 1: '已生成', 2: '已启动', 3: '已结束' esEnt.DoUpdate(); PageState.Add("Result", "T"); }
private void EndExamine() { IList <ExamineStageDetail> esdEnts = ExamineStageDetail.FindAllByProperty(ExamineStageDetail.Prop_ExamineStageId, id); foreach (ExamineStageDetail esdEnt in esdEnts) { DeptExamineRelation derEnt = DeptExamineRelation.Find(esdEnt.ExamineRelationId); string[] beUserIdArray = new string[] { }; string[] beUserNameArray = new string[] { }; if (!string.IsNullOrEmpty(derEnt.BeUserIds)) { beUserIdArray = derEnt.BeUserIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); beUserNameArray = derEnt.BeUserNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } for (int i = 0; i < beUserIdArray.Length; i++) { ExamineStageResult esrEnt = new ExamineStageResult(); esrEnt.ExamineStageId = esEnt.Id; esrEnt.UserId = beUserIdArray[i]; esrEnt.UserName = beUserNameArray[i]; string[] bedept = Utility.GetDeptInfo(beUserIdArray[i]); esrEnt.DeptId = bedept[0]; esrEnt.DeptName = bedept[1]; esrEnt.StageType = esEnt.StageType; esrEnt.Year = esEnt.Year; //分别计算上级 同级 下级评分 if (!string.IsNullOrEmpty(derEnt.UpLevelUserIds))//如果有上级考核人 { // IList<UserBalance> ubEnts = UserBalance.FindAllByProperties("ExamineRelationId", derEnt.Id, "ToRoleCode", "UpLevel");//该考核关系下 上级考核的人员权重明细 decimal subScore = 0; // if (ubEnts.Count > 0)//如果存在人员权重 // { // foreach (UserBalance ubEnt in ubEnts) // { // if (ubEnt.Balance > 0) // { // sql = @"select top 1 Score from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' // and BeUserId='{1}' and ToUserId ='{2}'"; // sql = string.Format(sql, esEnt.Id, beUserIdArray[i], ubEnt.ToUserId); // subScore += DataHelper.QueryValue<decimal>(sql) * (ubEnt.Balance.Value / 100); // } // } // } // else // { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.UpLevelUserIds); subScore = DataHelper.QueryValue <decimal>(sql); // } esrEnt.UpAvgScore = subScore; } if (!string.IsNullOrEmpty(derEnt.SameLevelUserIds))//如果有同级考核人 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.SameLevelUserIds); esrEnt.SameAvgScore = DataHelper.QueryValue <decimal>(sql); } if (!string.IsNullOrEmpty(derEnt.DownLevelUserIds))//如果有下级考核人 { sql = @"select avg(isnull(Score,0)) from BJKY_Examine..ExamineTask where State='2' and ExamineStageId='{0}' and BeUserId='{1}' and PatIndex('%'+ToUserId+'%','{2}')>0"; sql = string.Format(sql, esEnt.Id, beUserIdArray[i], derEnt.DownLevelUserIds); esrEnt.DownAvgScore = DataHelper.QueryValue <decimal>(sql); } decimal score = 0; //这里需要考虑一种特例就是 权重配好了 但可能没人给他打分 就是有权重 无分的现象 这个时候该权重不计入总权重 int upWeight = 0; int sameWeight = 0; int downWeight = 0; if (derEnt.UpLevelWeight > 0 && esrEnt.UpAvgScore > 0) { upWeight = derEnt.UpLevelWeight.Value; } if (derEnt.SameLevelWeight > 0 && esrEnt.SameAvgScore > 0) { sameWeight = derEnt.SameLevelWeight.Value; } if (derEnt.DownLevelWeight > 0 && esrEnt.DownAvgScore > 0) { downWeight = derEnt.DownLevelWeight.Value; } int totalWeight = upWeight + sameWeight + downWeight; if (upWeight > 0 && esrEnt.UpAvgScore > 0) { score += (((decimal)upWeight / (decimal)totalWeight) * esrEnt.UpAvgScore).Value; } if (sameWeight > 0 && esrEnt.SameAvgScore > 0) { score += (((decimal)sameWeight / (decimal)totalWeight) * esrEnt.SameAvgScore).Value; } if (downWeight > 0 && esrEnt.DownAvgScore > 0) { score += (((decimal)downWeight / (decimal)totalWeight) * esrEnt.DownAvgScore).Value; } esrEnt.Score = score; esrEnt.SortIndex = i + 1; esrEnt.DoCreate(); } } IList <ExamineTask> etEnts = ExamineTask.FindAllByProperty(ExamineTask.Prop_ExamineStageId, esEnt.Id);//更改任务状态 foreach (ExamineTask etEnt in etEnts) { //0 表示已生成的任务 1 表示已启动的任务 可以打分 if (etEnt.State == "2") //提交的任务 { etEnt.State = "3"; //已结束的任务 } else { etEnt.State = "4";//已作废的任务 } etEnt.DoUpdate(); } if (esEnt.StageType == "4") { CaculateYearResult(); } esEnt.State = 3; // 0: '已创建', 1: '已生成', 2: '已启动', 3: '已结束' esEnt.DoUpdate(); PageState.Add("Result", "T"); }