[img]http://dl.iteye.com/upload/attachment/614048/268c1abc-104f-3e8f-99dc-0a263dc033b2.jpg[/img]
在列表项所显示的数据 ,是通过一个任务节点表和任务表进行查询统计.
这是写在ibatis.xml里面的SQL!
SELECT d.name as businessType,d.userName as userName,count(d.userId) as countNum ,d.taskId,d.userId
from (select b.taskId,b.userId,b.userName,c.code,c.name from
(select taskId,userId,userName from T_OA_TaskNode group by taskId,userId,userName) as b
left join T_OA_Task as a on b.taskId = a.id
left join SY_YeWuLeiXingWeiHu as c on a.businessType = c.id
where
<if test="orgId != 0">
b.userId in (select id from HI_User WHERE org = #{orgId}) and
</if>
a.businessType IS NOT NULL and a.businessType!=' ' and a.status=1) as d
group by d.username ,d.code,d.name,d.taskId,d.userId
同过这条SQL的句子 ,来查询统计.
树的每个部门都是一个treeId,点击后会往Action里面传递一个treeId,treeId是根据Org一个部门表的id.所以treeid对应的也就是orgid。
Action里面的代码是这样处理的:
public String countNum() {
String userName = user.getUserName();// 获取登录系统用户名
Integer treeId = Integer.valueOf(request.getParameter("treeId"));// 获取树ID
if (userName.equals("Xxy")) { //管理员的orgId为null,所以,这只能根据他的名字来判断,而管理员能看到所有的人员 和每个部门的人员.
操作是根据treeId
list = JianGuanLvZhiService.countJianGuanLvZhi(treeId);
}else{//这里就是其它的普通用户了,是根据登录后取到得用户Id
0 查询所有 ,如果treeId等于用户ID ,就能看到当前部门的
int orgId = user.getOrg().getId();
if (treeId == 0 || treeId == orgId) {
list = JianGuanLvZhiService.countJianGuanLvZhi(treeId);
}
}
returnPageURL = "/taskManagement/jianguanlvzhi/JianGuanLvZhi.jsp";
return "dispatcher";
}
下面是具体的Service:
public static List countJianGuanLvZhi(int orgId) {//通过action里面传过来的treeId,这里用的是Map
CommonService commonService = (CommonService) SpringContextHolder.getBean("commonServiceImpl");
Map parMap = new HashMap();
parMap.put("orgId", orgId);
list = commonService.getManyObject("org.hi.zongheguanli.taskmanagement.dao.ibatis3.JianGuanLvZhi.selectJianGuanLvZhi", parMap);
return list;
}
上面已经贴出来XML.配置文件里面的SQL了 ..
这个语句我也不是很懂 ,是高人指点我写出来的 ..
大概的意思 ,我明白!
刚开发不久 ,每次做完一个功能 ,都会写一点总结 ,算是积累 ,以后总是会用到的!
在列表项所显示的数据 ,是通过一个任务节点表和任务表进行查询统计.
这是写在ibatis.xml里面的SQL!
SELECT d.name as businessType,d.userName as userName,count(d.userId) as countNum ,d.taskId,d.userId
from (select b.taskId,b.userId,b.userName,c.code,c.name from
(select taskId,userId,userName from T_OA_TaskNode group by taskId,userId,userName) as b
left join T_OA_Task as a on b.taskId = a.id
left join SY_YeWuLeiXingWeiHu as c on a.businessType = c.id
where
<if test="orgId != 0">
b.userId in (select id from HI_User WHERE org = #{orgId}) and
</if>
a.businessType IS NOT NULL and a.businessType!=' ' and a.status=1) as d
group by d.username ,d.code,d.name,d.taskId,d.userId
同过这条SQL的句子 ,来查询统计.
树的每个部门都是一个treeId,点击后会往Action里面传递一个treeId,treeId是根据Org一个部门表的id.所以treeid对应的也就是orgid。
Action里面的代码是这样处理的:
public String countNum() {
String userName = user.getUserName();// 获取登录系统用户名
Integer treeId = Integer.valueOf(request.getParameter("treeId"));// 获取树ID
if (userName.equals("Xxy")) { //管理员的orgId为null,所以,这只能根据他的名字来判断,而管理员能看到所有的人员 和每个部门的人员.
操作是根据treeId
list = JianGuanLvZhiService.countJianGuanLvZhi(treeId);
}else{//这里就是其它的普通用户了,是根据登录后取到得用户Id
0 查询所有 ,如果treeId等于用户ID ,就能看到当前部门的
int orgId = user.getOrg().getId();
if (treeId == 0 || treeId == orgId) {
list = JianGuanLvZhiService.countJianGuanLvZhi(treeId);
}
}
returnPageURL = "/taskManagement/jianguanlvzhi/JianGuanLvZhi.jsp";
return "dispatcher";
}
下面是具体的Service:
public static List countJianGuanLvZhi(int orgId) {//通过action里面传过来的treeId,这里用的是Map
CommonService commonService = (CommonService) SpringContextHolder.getBean("commonServiceImpl");
Map parMap = new HashMap();
parMap.put("orgId", orgId);
list = commonService.getManyObject("org.hi.zongheguanli.taskmanagement.dao.ibatis3.JianGuanLvZhi.selectJianGuanLvZhi", parMap);
return list;
}
上面已经贴出来XML.配置文件里面的SQL了 ..
这个语句我也不是很懂 ,是高人指点我写出来的 ..
大概的意思 ,我明白!
刚开发不久 ,每次做完一个功能 ,都会写一点总结 ,算是积累 ,以后总是会用到的!