Commit 076b02f8 authored by zhangjianqian's avatar zhangjianqian

大屏环形图数据

parent 909ec438
...@@ -2,6 +2,9 @@ package com.zehong.web.controller.system; ...@@ -2,6 +2,9 @@ package com.zehong.web.controller.system;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -29,6 +32,7 @@ import com.zehong.system.service.ISysDeptService; ...@@ -29,6 +32,7 @@ import com.zehong.system.service.ISysDeptService;
* *
* @author zehong * @author zehong
*/ */
@Api("部门")
@RestController @RestController
@RequestMapping("/system/dept") @RequestMapping("/system/dept")
public class SysDeptController extends BaseController public class SysDeptController extends BaseController
...@@ -88,6 +92,16 @@ public class SysDeptController extends BaseController ...@@ -88,6 +92,16 @@ public class SysDeptController extends BaseController
return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
} }
/**
* 二级分类查询下属分类员工数量
* @return
*/
@ApiOperation("部门")
@GetMapping("/classification")
public AjaxResult classification()
{
return AjaxResult.success(deptService.classification());
}
/** /**
* 加载对应角色部门列表树 * 加载对应角色部门列表树
*/ */
......
...@@ -125,4 +125,11 @@ public interface SysDeptMapper ...@@ -125,4 +125,11 @@ public interface SysDeptMapper
public List<Map<String,Object>> selectDeptlabelList(); public List<Map<String,Object>> selectDeptlabelList();
public String selectNamesByIds(@Param("ids")List<Long> ids); public String selectNamesByIds(@Param("ids")List<Long> ids);
/**
*根据部门id查询下属部门
*/
public List<Map<String,Object>> classification(Long deptId);
public List<Map<String,Object>> classificationByList(@Param("list") List<Map<String,Object>> list);
} }
package com.zehong.system.service; package com.zehong.system.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.zehong.common.core.domain.TreeSelect; import com.zehong.common.core.domain.TreeSelect;
import com.zehong.common.core.domain.entity.SysDept; import com.zehong.common.core.domain.entity.SysDept;
...@@ -35,6 +37,12 @@ public interface ISysDeptService ...@@ -35,6 +37,12 @@ public interface ISysDeptService
*/ */
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts); public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
/**
* 二级分类查询下属分类员工数量
* @return
*/
public List<Map<String,Object>> classification();
/** /**
* 根据角色ID查询部门树信息 * 根据角色ID查询部门树信息
* *
......
...@@ -3,6 +3,7 @@ package com.zehong.system.service.impl; ...@@ -3,6 +3,7 @@ package com.zehong.system.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -89,6 +90,32 @@ public class SysDeptServiceImpl implements ISysDeptService ...@@ -89,6 +90,32 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
} }
/**
* 二级分类查询下属分类员工数量
* @return
*/
@Override
public List<Map<String, Object>> classification() {
List<Map<String,Object>> list = deptMapper.classification(100l);
for (Map<String,Object> map :list ){
List<Map<String,Object>> list1 = new ArrayList<>();
list1.add(map);
Long num = selectNum(list1,(Long) map.get("num"));
map.put("num",num);
}
return list;
}
public Long selectNum(List<Map<String,Object>> list,Long num){
List<Map<String,Object>> resultList = deptMapper.classificationByList(list);
if(resultList.size()==0){
return num;
}else{
for(Map<String,Object> map : resultList){
num = num + (Long) map.get("num");
}
return selectNum(resultList,num);
}
}
/** /**
* 根据角色ID查询部门树信息 * 根据角色ID查询部门树信息
* *
......
...@@ -163,4 +163,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -163,4 +163,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</select> </select>
<select id="classification" parameterType="Long" resultType="java.util.HashMap">
SELECT d.dept_id AS deptId,d.dept_name AS deptName,COUNT(d.dept_id) AS num FROM t_staff s
LEFT JOIN sys_dept d ON s.`dept_id` = d.`dept_id`
WHERE d.del_flag = 0
AND d.parent_id = #{deptId}
GROUP BY d.`dept_id`
</select>
<select id="classificationByList" resultType="java.util.HashMap">
SELECT d.dept_id AS deptId,d.dept_name AS deptName,COUNT(d.dept_id) AS num FROM t_staff s
LEFT JOIN sys_dept d ON s.`dept_id` = d.`dept_id`
WHERE d.del_flag = 0
AND d.parent_id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.deptId}
</foreach>
GROUP BY d.`dept_id`
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment