SELECT CreateBy FROM rb_okr_objective WHERE Group_Id={groupId} and Status <>5 and PeriodId={periodId}{(!string.IsNullOrEmpty(userIds)?"and CreateBy in("+userIds+")":"")} GROUP BY CreateBy
...
...
@@ -1052,15 +1052,89 @@ SELECT UserId FROM rb_okr_updateprogress WHERE Group_Id={group_Id} and PeriodId=
//select e.EmployeeId AS CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,SUM(CASE WHEN o.Id is null THEN 0 ELSE 1 END) as ObjectiveNum
//from rb_employee e
//LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy AND o.PeriodId ={periodId} AND o.Status =2
//where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds) ? "and e.EmployeeId in (" + userIds + ")" : "")} group by e.EmployeeId
//)t where t.ObjectiveNum >={startValue} {(endValue >= 0 ? "and t.ObjectiveNum <=" + endValue : "")} order by t.ObjectiveNum {(orderBy == 1 ? " asc" : " desc")}
//";
stringorderbyInfo=string.Empty;
if(orderBy==1)
{
orderbyInfo=" order by t.ObjectiveNCount asc";
}
elseif(orderBy==2)
{
orderbyInfo=" order by t.ObjectiveNCount desc";
}
elseif(orderBy==3)
{
orderbyInfo=" order by t.OBjectiveRelation desc";
}
elseif(orderBy==4)
{
orderbyInfo=" order by t.OBjectiveRelation desc";
}
elseif(orderBy==5)
{
orderbyInfo=" order by t.DayNum desc";
}
elseif(orderBy==6)
{
orderbyInfo=" order by t.DayNum desc";
}
elseif(orderBy==7)
{
orderbyInfo=" order by t.ScoreCount desc";
}
elseif(orderBy==8)
{
orderbyInfo=" order by t.ScoreCount desc";
}
stringsql=$@"
select * from(
select e.EmployeeId AS CreateBy,e.EmName,e.EmPhoto,e.DeptName,e.PostName,SUM(CASE WHEN o.Id is null THEN 0 ELSE 1 END) as ObjectiveNum
select e.EmployeeId AS Id,e.EmName as EmployeeName ,e.EmPhoto as UserIcon,e.DeptName,e.PostName,SUM(CASE WHEN o.Id is null THEN 0 ELSE 1 END) as ObjectiveNCount ,
sum(case when o.Score>0 then 1 else 0 end) as ScoreCount, IFNULL(obj.OBjectiveRelation,0) as OBjectiveRelation,IFNULL(okrp.daysum,-1) as DayNum
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy AND o.PeriodId ={periodId} AND o.Status =2
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy AND o.PeriodId ={periodId} AND o.Status =2 and o.Group_Id={group_Id}
LEFT JOIN (SELECT COUNT(0) as OBjectiveRelation,o1.CreateBy FROM
rb_okr_objectiverelation or1
LEFT JOIN rb_okr_objective o1 on or1.ObjectiveId = o1.Id
WHERE o1.`Status`=2 and o1.Group_Id={group_Id} and o1.PeriodId ={periodId} group by o1.CreateBy) as obj on e.EmployeeId =obj.CreateBy
LEFT JOIN (SELECT DATEDIFF(NOW(), MAX(UpdateTime)) as daysum,UserId from rb_okr_updateprogress GROUP BY UserId) as okrp on e.EmployeeId=okrp.UserId
where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(userIds)?"and e.EmployeeId in ("+userIds+")":"")} group by e.EmployeeId
)t where t.ObjectiveNum >={startValue}{(endValue>=0?"and t.ObjectiveNum <="+endValue:"")} order by t.ObjectiveNum {(orderBy==1?" asc":" desc")}
select e.EmployeeId AS Id,e.EmName as EmployeeName ,e.RB_Department_Id as Dept_Id,e.EmPhoto as UserIcon,e.DeptName,e.PostName,SUM(CASE WHEN o.Id is null THEN 0 ELSE 1 END) as ObjectiveNCount ,
sum(case when o.Score>0 then 1 else 0 end) as ScoreCount, IFNULL(obj.OBjectiveRelation,0) as OBjectiveRelation,IFNULL(okrp.daysum,-1) as DayNum
from rb_employee e
LEFT JOIN RB_OKR_Objective o on e.EmployeeId = o.CreateBy AND o.PeriodId ={periodId} AND o.Status =2 and o.Group_Id={group_Id}
LEFT JOIN (SELECT COUNT(0) as OBjectiveRelation,o1.CreateBy FROM
rb_okr_objectiverelation or1
LEFT JOIN rb_okr_objective o1 on or1.ObjectiveId = o1.Id
WHERE o1.`Status`=2 and o1.Group_Id={group_Id} and o1.PeriodId ={periodId} group by o1.CreateBy) as obj on e.EmployeeId =obj.CreateBy
LEFT JOIN (SELECT DATEDIFF(NOW(), MAX(UpdateTime)) as daysum,UserId from rb_okr_updateprogress GROUP BY UserId) as okrp on e.EmployeeId=okrp.UserId
where e.RB_Group_id={group_Id} and e.IsLeave =0 {(!string.IsNullOrEmpty(deptIdStr)?"and e.RB_Department_Id in ("+deptIdStr+")":"")} group by e.EmployeeId