Compare commits
4 Commits
d6df42fe7b
...
54a9ce5d62
Author | SHA1 | Date |
---|---|---|
dinggang | 54a9ce5d62 | |
dinggang | cb134396b3 | |
yitonglei | 9f704ea01d | |
yitonglei | 142ab2d84a |
|
@ -202,9 +202,13 @@ public class CensusControllerV3 {
|
|||
}
|
||||
|
||||
|
||||
|
||||
//以下是组件使用情况点击详情
|
||||
|
||||
/**
|
||||
* 使用次数是去tb_data_resource_rel查
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/assemblerUseTopInfo")
|
||||
@ApiOperation("TOP5使用组件")
|
||||
@LogOperation("TOP5使用组件")
|
||||
|
@ -213,25 +217,57 @@ public class CensusControllerV3 {
|
|||
@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
|
||||
})
|
||||
public Result<List<Map<String, Object>>> assemblerUseTopInfo(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
Object[] ps = {params.get("resourceType"),params.get("id")};
|
||||
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT b.name,count(a.id) AS useNum FROM tb_data_resource_rel a INNER JOIN tb_data_resource b ON a.reference_id = b.id\n" +
|
||||
"WHERE a.del_flag = 0 AND b.type = ? AND b.dept_id = ? GROUP BY b.name ORDER BY useNum desc LIMIT 5", ps);
|
||||
|
||||
return null;
|
||||
return new Result<List<Map<String,Object>>>().ok(maps);
|
||||
}
|
||||
|
||||
@GetMapping("/assemblerUseInfo")
|
||||
@ApiOperation("使用组件数量分布(算法、图层、开发、业务")
|
||||
@LogOperation("使用组件数量分布(算法、图层、开发、业务")
|
||||
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
|
||||
public Result<List<Map<String, Object>>> assemblerUseInfo(Long id){
|
||||
return null;
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"),
|
||||
@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
|
||||
})
|
||||
public Result<List<Map<String, Object>>> assemblerUseInfo(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
Object[] ps = {params.get("id"),params.get("resourceType")};
|
||||
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT count(d.id) as num,d.attr_value FROM tb_data_resource_rel a INNER JOIN sys_user b ON a.creator = b.id INNER JOIN tb_data_resource c ON a.reference_id = c.id INNER JOIN tb_data_attr d ON c.id = d.data_resource_id\n" +
|
||||
"WHERE a.del_flag = 0 AND b.dept_id = ? AND c.type = ? AND d.attr_type = '组件类型' \n" +
|
||||
"GROUP BY d.attr_value", ps);
|
||||
|
||||
return new Result<List<Map<String,Object>>>().ok(maps);
|
||||
}
|
||||
|
||||
@GetMapping("/assemblerUseProjectInfo")
|
||||
@ApiOperation("应用贡献组件数量分布(算法、图层、开发、业务)")
|
||||
@LogOperation("应用贡献组件数量分布(算法、图层、开发、业务)")
|
||||
@ApiImplicitParam(name = "keyId", value = "应用的id", paramType = "query", required = true, dataType = "long")
|
||||
public Result<List<Map<String, Object>>> assemblerUseProjectInfo(Long keyId){
|
||||
Object[] ps = {keyId};
|
||||
List<Map<String, Object>> maps = jdbcTemplate.queryForList("select count(b.id),b.attr_value from (select reference_id from tb_data_resource_rel where del_flag = 0 and key_id = ? ) a inner join tb_data_attr b on a.reference_id = b.data_resource_id \n" +
|
||||
" and b.attr_type = '应用类型' group by b.attr_value ", ps);
|
||||
|
||||
return new Result<List<Map<String,Object>>>().ok(maps);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/assemblerUseScoreTopInfo")
|
||||
@ApiOperation("使用组件评分top5")
|
||||
@LogOperation("使用组件评分top5")
|
||||
public Result<List<Map<String, Object>>> assemblerUseScoreTopInfo(Long id){
|
||||
return null;
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"),
|
||||
@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
|
||||
})
|
||||
public Result<List<Map<String, Object>>> assemblerUseScoreTopInfo(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
Object[] ps = {params.get("resourceType"),params.get("id")};
|
||||
List<Map<String, Object>> maps = jdbcTemplate.queryForList("select AVG(a.score) as score,b.name from tb_resource_score a inner join tb_data_resource b on a.resource_id = b.id\n" +
|
||||
"inner join sys_user c on a.user_id = c.id \n" +
|
||||
"where a.del_flag = 0 and b.type = ? and c.dept_id = ?\n" +
|
||||
"group by b.name order by score desc limit 5", ps);
|
||||
|
||||
return new Result<List<Map<String,Object>>>().ok(maps);
|
||||
}
|
||||
|
||||
|
||||
|
@ -248,14 +284,16 @@ public class CensusControllerV3 {
|
|||
|
||||
|
||||
@GetMapping("applicationUsedAreaCapabilityList")
|
||||
@ApiOperation("使用组件的应用领域分布情况")
|
||||
@LogOperation("使用组件的应用领域分布情况")
|
||||
@ApiOperation("使用组件应用领域分布情况")
|
||||
@LogOperation("使用组件应用领域分布情况")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"),
|
||||
@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
|
||||
})
|
||||
public Result<List<Map<String,Object>>> applicationUsedAreaCapabilityList(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
return null;
|
||||
|
||||
List<Map<String, Object>> maps = resourceService.applicationAreaCapabilityUseList(params);
|
||||
return new Result<List<Map<String,Object>>>().ok(maps);
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,8 +333,8 @@ public class CensusControllerV3 {
|
|||
return new Result<List<Map<String,Object>>>().ok(result);
|
||||
}
|
||||
@GetMapping("/applicationUsedCapabilityNum")
|
||||
@ApiOperation("贡献组件被多少应用使用")
|
||||
@LogOperation("贡献组件被多少应用使用")
|
||||
@ApiOperation("贡献组件分别被多少应用使用")
|
||||
@LogOperation("贡献组件分别被多少应用使用")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long"),
|
||||
@ApiImplicitParam(name = "resourceType",value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
|
||||
|
@ -384,7 +422,6 @@ public class CensusControllerV3 {
|
|||
if(keywords != null){
|
||||
treeMatch(result,keywords);
|
||||
}
|
||||
System.out.println("部门树--》"+result.size());
|
||||
return new Result<List<SysDeptDTO>>().ok(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -121,4 +121,5 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
List<Map<String,Object>> selectResurceCarDetails(Map params);
|
||||
List<Map<String,Object>> applicationAreaCapabilityList(Map params);
|
||||
List<Map<String,Object>> applicationUsedAreaCapabilityList(Map params);
|
||||
List<Map<String,Object>> applicationAreaCapabilityUseList(Map params);
|
||||
}
|
|
@ -27,11 +27,11 @@ public class TbDataResourceRelEntity {
|
|||
private Long referenceId;
|
||||
/**
|
||||
* 删除标志:
|
||||
0:正常;
|
||||
1:已删除;
|
||||
2:待审核;
|
||||
3:审核中;
|
||||
9其他
|
||||
0:正常;
|
||||
1:已删除;
|
||||
2:待审核;
|
||||
3:审核中;
|
||||
9其他
|
||||
*/
|
||||
private Integer delFlag;
|
||||
/**
|
||||
|
|
|
@ -102,4 +102,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
List<Map<String, Object>> assemblerCarDetail(Map<String, Object> params);
|
||||
|
||||
List<Map<String, Object>> applicationAreaCapabilityList(Map params);
|
||||
|
||||
List<Map<String, Object>> applicationAreaCapabilityUseList(Map params);
|
||||
}
|
|
@ -749,6 +749,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
return resourceDao.applicationAreaCapabilityList(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> applicationAreaCapabilityUseList(Map params){
|
||||
return resourceDao.applicationAreaCapabilityUseList(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectResourceListByType(String type) {
|
||||
return resourceDao.selectByType(type);
|
||||
|
|
|
@ -88,4 +88,20 @@ public class ResourceCarController {
|
|||
return new Result();
|
||||
}
|
||||
|
||||
@GetMapping("/selectResourceCarGroupByDept")
|
||||
@ApiOperation("查询申购车资源所属部门列表")
|
||||
@LogOperation("查询申购车资源所属部门列表")
|
||||
public Result selectResourceCarGroupByDept(@RequestParam String name,
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize) {
|
||||
return new Result().ok(resourceCarService.selectResourceCarGroupByDept(name, pageNum, pageSize));
|
||||
}
|
||||
|
||||
@GetMapping("/selectResourceListByDept")
|
||||
@ApiOperation("根据部门查询申购车资源列表")
|
||||
@LogOperation("根据部门查询申购车资源列表")
|
||||
public Result selectResourceListByDept(@RequestParam Long deptId, @RequestParam Integer pageNum, @RequestParam Integer pageSize) {
|
||||
return new Result().ok(resourceCarService.selectResourceListByDept(deptId, pageNum, pageSize));
|
||||
}
|
||||
|
||||
}
|
|
@ -25,4 +25,16 @@ public interface ResourceCarDao extends BaseDao<ResourceCarEntity> {
|
|||
@Param("pageSize") Integer pageSize);
|
||||
|
||||
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||
|
||||
List<Map> selectResourceCarGroupByDept(@Param("userId") Long userId,
|
||||
@Param("pageNum") Integer pageNum,
|
||||
@Param("pageSize") Integer pageSize,
|
||||
@Param("name") String name);
|
||||
|
||||
List<Map> selectResourceListByDept(@Param("userId") Long userId,
|
||||
@Param("deptId") Long deptId,
|
||||
@Param("pageNum") Integer pageNum,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
|
||||
Integer selectProvideDeptCount(@Param("userId") Long userId, @Param("name") String name);
|
||||
}
|
|
@ -3,6 +3,7 @@ package io.renren.modules.resourceCar.service;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.renren.common.service.CrudService;
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.modules.resourceCar.dto.ResourceCarDTO;
|
||||
import io.renren.modules.resourceCar.entity.ResourceCarEntity;
|
||||
|
||||
|
@ -23,4 +24,8 @@ public interface ResourceCarService extends CrudService<ResourceCarEntity, Resou
|
|||
IPage<ResourceCarDTO> selectPage(Map<String, Object> params);
|
||||
|
||||
Object total();
|
||||
|
||||
Object selectResourceCarGroupByDept(String name, Integer pageNum, Integer pageSize);
|
||||
|
||||
Object selectResourceListByDept(Long deptId, Integer pageNum, Integer pageSize);
|
||||
}
|
|
@ -100,4 +100,20 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
|
|||
resultMap.put("count", count);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectResourceCarGroupByDept(String name, Integer pageNum, Integer pageSize) {
|
||||
Long userId = SecurityUser.getUserId();
|
||||
HashMap<Object, Object> resultMap = new HashMap<>();
|
||||
List<Map> maps = resourceCarDao.selectResourceCarGroupByDept(userId, (pageNum - 1 ) * pageSize, pageSize, name);
|
||||
resultMap.put("list", maps);
|
||||
resultMap.put("deptCount", resourceCarDao.selectProvideDeptCount(userId, name));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectResourceListByDept(Long deptId, Integer pageNum, Integer pageSize) {
|
||||
Long userId = SecurityUser.getUserId();
|
||||
return resourceCarDao.selectResourceListByDept(userId, deptId, (pageNum - 1 ) * pageSize, pageSize);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import io.renren.common.validator.group.AddGroup;
|
|||
import io.renren.common.validator.group.DefaultGroup;
|
||||
import io.renren.common.validator.group.UpdateGroup;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
import io.renren.modules.security.user.UserDetail;
|
||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -40,29 +41,38 @@ public class SysDeptController {
|
|||
@ApiOperation("根据当前用户所在部门查询下属部门tree,可以根据部门名称模糊查询")
|
||||
@LogOperation("根据当前用户所在部门查询下属部门")
|
||||
public Result<List<SysDeptDTO>> treeList(@RequestParam(required = false,value = "模糊查询,部门名称") String keywords){
|
||||
Long deptId = SecurityUser.getDeptId();
|
||||
List<SysDeptDTO> result = new ArrayList<>();
|
||||
SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
|
||||
|
||||
//市大数据局展示全部部门,区大数据局展示本区所有部门,委办局展示自己部门及下级部门
|
||||
if(StringUtils.contains(sysDeptDTO.getName(),"青岛市大数据发展管理局")){//市大数据局
|
||||
UserDetail user = SecurityUser.getUser();
|
||||
if(user.getUsername().equals("admin")){//admin账户
|
||||
List<Map<String,Object>> deptMaps = jdbcTemplate.queryForList("SELECT id FROM sys_dept where pid = 0");
|
||||
deptMaps.forEach(dept->{
|
||||
SysDeptDTO depts = sysDeptService.getDeptListByPid(Long.valueOf(dept.get("id").toString()));
|
||||
result.add(depts);
|
||||
});
|
||||
}else if(StringUtils.contains(sysDeptDTO.getName(),"大数据") && sysDeptDTO.getType() == 3){//各区大数据局
|
||||
|
||||
SysDeptDTO depts = sysDeptService.getDeptListByPid(sysDeptDTO.getPid());
|
||||
result.add(depts);
|
||||
}else{
|
||||
SysDeptDTO deptListByPid = sysDeptService.getDeptListByPid(deptId);
|
||||
result.add(deptListByPid);
|
||||
Long deptId = SecurityUser.getDeptId();
|
||||
SysDeptDTO sysDeptDTO = sysDeptService.get(deptId);
|
||||
|
||||
//市大数据局展示全部部门,区大数据局展示本区所有部门,委办局展示自己部门及下级部门
|
||||
if(StringUtils.contains(sysDeptDTO.getName(),"青岛市大数据发展管理局")){//市大数据局
|
||||
List<Map<String,Object>> deptMaps = jdbcTemplate.queryForList("SELECT id FROM sys_dept where pid = 0");
|
||||
deptMaps.forEach(dept->{
|
||||
SysDeptDTO depts = sysDeptService.getDeptListByPid(Long.valueOf(dept.get("id").toString()));
|
||||
result.add(depts);
|
||||
});
|
||||
}else if(StringUtils.contains(sysDeptDTO.getName(),"大数据") && sysDeptDTO.getType() == 3){//各区大数据局
|
||||
|
||||
SysDeptDTO depts = sysDeptService.getDeptListByPid(sysDeptDTO.getPid());
|
||||
result.add(depts);
|
||||
}else{
|
||||
SysDeptDTO deptListByPid = sysDeptService.getDeptListByPid(deptId);
|
||||
result.add(deptListByPid);
|
||||
}
|
||||
}
|
||||
|
||||
if(keywords != null){
|
||||
treeMatch(result,keywords);
|
||||
}
|
||||
System.out.println("部门树--》"+result.size());
|
||||
return new Result<List<SysDeptDTO>>().ok(result);
|
||||
}
|
||||
/** ytl 2022-06-23 新增 end **/
|
||||
|
|
|
@ -346,7 +346,6 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
|
||||
deptNew.setType(Integer.parseInt(list.get("type").toString()));
|
||||
if(dept == null){
|
||||
System.out.println("deptname->"+deptNew.getName());
|
||||
sysDeptDao.insert(deptNew);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -938,7 +938,25 @@
|
|||
GROUP BY
|
||||
type
|
||||
</select>
|
||||
|
||||
<select id="applicationAreaCapabilityUseList" parameterType="java.util.Map" resultType="java.util.Map">
|
||||
SELECT
|
||||
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS type ,
|
||||
COUNT( tdav.data_resource_id ) AS total
|
||||
FROM
|
||||
( select a.* from tb_data_attr a inner join tb_data_resource d on a.data_resource_id = d.id
|
||||
inner join tb_data_resource_rel e on e.reference_id = d.id inner join sys_user f on e.creator = f.id where d.type=#{resourceType}
|
||||
and f.dept_id = #{id}
|
||||
) tdav
|
||||
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
||||
';', '' ) ) + 1 )
|
||||
WHERE
|
||||
1 = 1
|
||||
AND tdav.attr_type = '应用领域'
|
||||
AND tdav.del_flag = 0
|
||||
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
||||
GROUP BY
|
||||
type
|
||||
</select>
|
||||
|
||||
<select id="selectTopFiveComponentServiceApplications" resultType="java.util.Map">
|
||||
SELECT
|
||||
|
@ -1095,29 +1113,36 @@
|
|||
|
||||
<select id="selectResurceCarDetails" parameterType="java.util.Map" resultType="java.util.Map">
|
||||
SELECT COUNT(a.id) AS resourceCarNum,
|
||||
c.name as deptName
|
||||
c.name as deptName,c.id,COUNT(e.id) as useNum
|
||||
FROM
|
||||
tb_resource_car a
|
||||
tb_resource_car a
|
||||
INNER JOIN
|
||||
sys_user b
|
||||
sys_user b
|
||||
ON
|
||||
a.user_id = b.id
|
||||
a.user_id = b.id
|
||||
INNER JOIN
|
||||
sys_dept c
|
||||
sys_dept c
|
||||
ON
|
||||
b.dept_id = c.id
|
||||
b.dept_id = c.id
|
||||
INNER JOIN
|
||||
tb_data_resource d
|
||||
tb_data_resource d
|
||||
ON
|
||||
a.resource_id = d.id
|
||||
a.resource_id = d.id
|
||||
INNER JOIN tb_data_resource_rel e
|
||||
ON
|
||||
b.id = e.creator
|
||||
where
|
||||
(c.id = #{id} or c.pids LIKE CONCAT('%',CONCAT(#{id},'%')))
|
||||
AND
|
||||
d.type = #{resourceType}
|
||||
(c.id = #{id} or c.pids LIKE CONCAT('%',CONCAT(#{id},'%')))
|
||||
AND
|
||||
d.type = #{resourceType}
|
||||
AND
|
||||
a.del_flag = 0
|
||||
AND
|
||||
d.del_flag = 0
|
||||
group by
|
||||
c.name
|
||||
c.name,c.id
|
||||
order by
|
||||
c.name
|
||||
c.name,c.id
|
||||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
|
|
|
@ -60,4 +60,61 @@
|
|||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectResourceCarGroupByDept" resultType="java.util.Map">
|
||||
SELECT
|
||||
res.dept_id AS "deptId",
|
||||
dept.name AS "deptName",
|
||||
COUNT(car.id) AS "count"
|
||||
FROM
|
||||
tb_resource_car car,
|
||||
tb_data_resource res,
|
||||
sys_dept dept
|
||||
WHERE car.user_id = #{userId}
|
||||
AND car.resource_id = res.id
|
||||
AND res.dept_id = dept.id
|
||||
<if test="name != null and name != ''">
|
||||
AND res.name LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
GROUP BY res.dept_id
|
||||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectResourceListByDept" resultType="java.util.Map">
|
||||
SELECT
|
||||
res.id AS "resourceId",
|
||||
res.NAME AS "resourceName",
|
||||
res.description,
|
||||
res.type,
|
||||
res.del_flag AS "delFlag"
|
||||
FROM
|
||||
tb_resource_car car,
|
||||
tb_data_resource res
|
||||
WHERE 1 = 1
|
||||
AND car.resource_id = res.id
|
||||
AND car.user_id = #{userId}
|
||||
AND res.dept_id = #{deptId}
|
||||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectProvideDeptCount" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
tdr.dept_id
|
||||
FROM
|
||||
tb_resource_car trc
|
||||
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND trc.user_id = #{userId}
|
||||
<if test="name != null and name != ''">
|
||||
AND tdr.name LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
GROUP BY
|
||||
tdr.dept_id
|
||||
) temp
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -44,13 +44,10 @@ public class JhlDAPTool {
|
|||
env.put("java.naming.ldap.attributes.binary","objectGUID");
|
||||
try {
|
||||
ctx = new InitialLdapContext(env, connCtls);
|
||||
System.out.println( "连接成功" );
|
||||
return ctx;
|
||||
} catch (javax.naming.AuthenticationException e) {
|
||||
System.out.println("连接失败:");
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
System.out.println("连接出错:"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
@ -76,7 +73,7 @@ public class JhlDAPTool {
|
|||
public List<Map> readLdap(LdapContext ctx){//OU=即墨区,
|
||||
|
||||
List<Map> lm=new ArrayList<Map>(1000);
|
||||
byte[] cookie = null;
|
||||
byte[] cookie;
|
||||
|
||||
try {
|
||||
if(ctx!=null) {
|
||||
|
@ -89,33 +86,21 @@ public class JhlDAPTool {
|
|||
|
||||
do {
|
||||
NamingEnumeration<SearchResult> answer = ctx.search("", "sAMAccountType=805306368", searchControls);
|
||||
//NamingEnumeration<SearchResult> answer = ctx.search("", "objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn", searchControls);
|
||||
while (answer.hasMore()) {
|
||||
SearchResult result = (SearchResult) answer.next();
|
||||
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll();
|
||||
//System.out.println("getNameInNamespace-》"+result.getNameInNamespace());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区,OU=即墨区,DC=qd,DC=gov,DC=cn
|
||||
Map<String,Object> user = new HashMap<>();
|
||||
while (attrs.hasMore()) {
|
||||
Attribute next = attrs.next();
|
||||
//System.out.println(next);
|
||||
|
||||
if ("displayName".equals(next.getID())) {
|
||||
user.put("real_name",next.get().toString());
|
||||
//user.setDisplayName(next.get().toString());
|
||||
}else if("sAMAccountName".equals(next.getID())){
|
||||
user.put("username",next.get().toString());
|
||||
//user.setSamaccountName(next.get().toString());
|
||||
}else if("userPrincipalName".equals(next.getID())){
|
||||
user.put("email",next.get().toString());
|
||||
//user.setUserPrincipalName(next.get().toString());
|
||||
}else if("telephoneNumber".equals(next.getID())){
|
||||
user.put("mobile",next.get().toString());
|
||||
//user.setTelephoneNumber(next.get().toString());
|
||||
}else if("distinguishedName".equals(next.getID())){
|
||||
//CN=葛琳,OU=城阳区疾病预防控制中心,OU=城阳区卫生健康局,OU=区属机关,OU=城阳区,DC=qd,DC=gov,DC=cn
|
||||
// String distinguishedName = next.get().toString();
|
||||
// String[] distinguishedNames = distinguishedName.split(",");
|
||||
// String deptName = distinguishedNames[1].split("=")[1];
|
||||
user.put("distinguishedName",next.get().toString());
|
||||
}else if("objectGUID".equals(next.getID())){
|
||||
String guidStr = next.getID().toString();
|
||||
|
@ -126,7 +111,6 @@ public class JhlDAPTool {
|
|||
}
|
||||
}
|
||||
lm.add(user);
|
||||
|
||||
}
|
||||
cookie = parseControls(ctx.getResponseControls());
|
||||
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, cookie, Control.CRITICAL)});
|
||||
|
@ -134,12 +118,10 @@ public class JhlDAPTool {
|
|||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
System.out.println("获取用户信息异常:");
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
closeContext();
|
||||
}
|
||||
System.out.println(lm.size());
|
||||
return lm;
|
||||
}
|
||||
|
||||
|
@ -156,45 +138,20 @@ public class JhlDAPTool {
|
|||
|
||||
try {
|
||||
if(ctx!=null) {
|
||||
|
||||
//过滤条件
|
||||
//String filter = "(&(objectClass=*)(uid=*))";
|
||||
//String filter = "(&(userAccountControl=66048)(sAMAccountType=805306368))";
|
||||
//String[] attrPersonArray = {"sAMAccountName", "distinguishedName", "displayName"};
|
||||
//String[] attrPersonArray = { "uid", "userPassword", "displayName", "cn", "sn", "mail", "description","uidNumber","gidNumber" };
|
||||
|
||||
//2. 设置查询的属性
|
||||
SearchControls searchControls = new SearchControls();//搜索控件
|
||||
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);//搜索范围,1只搜索指定命名对象的一个级别,这是缺省值,2以指定命名对象为根结点的整棵树 SearchControls.SUBTREE_SCOPE
|
||||
//searchControls.setReturningAttributes(attrPersonArray);
|
||||
//分页
|
||||
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, Control.CRITICAL)});
|
||||
|
||||
//IdentifierGenerator identifierGenerator=new DefaultIdentifierGenerator();
|
||||
do {
|
||||
//3.(1)要搜索的上下文或对象的名称;(2).过滤条件,可为null,默认搜索所有信息;(3).搜索控件,可为null,使用默认的搜索控件
|
||||
//objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn
|
||||
//sAMAccountType=805306368
|
||||
|
||||
NamingEnumeration<SearchResult> answer = ctx.search("", filter, searchControls);
|
||||
//NamingEnumeration<SearchResult> answer = ctx.search("", "objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=gov,DC=cn", searchControls);
|
||||
|
||||
//<SearchResult> answer = ctx.search("",filter.toString(),searchControls);
|
||||
while (answer.hasMore()) {
|
||||
SearchResult result = (SearchResult) answer.next();
|
||||
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll();
|
||||
//System.out.println(result.getName());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区
|
||||
//System.out.println(result.getClass());
|
||||
System.out.println("getNameInNamespace-》"+result.getNameInNamespace());//CN=李平先,OU=抬三,OU=即墨普东中心社区,OU=即墨中心社区,OU=即墨区,DC=qd,DC=gov,DC=cn
|
||||
Map<String,Object> dept = new HashMap<>();
|
||||
while (attrs.hasMore()) {
|
||||
Attribute next = attrs.next();
|
||||
//System.out.println(next);
|
||||
|
||||
if ("name".equals(next.getID())) {
|
||||
String name = next.get().toString();
|
||||
dept.put("name",name);
|
||||
//dept.put("id",SingleID.getSingleID(name));
|
||||
}else if("distinguishedName".equals(next.getID())){
|
||||
//OU=事业发展中心,OU=办公厅,OU=人大常委会,DC=qd,DC=gov,DC=cn
|
||||
dept.put("namespace",next.get());
|
||||
|
@ -216,7 +173,6 @@ public class JhlDAPTool {
|
|||
if(!dept.get("name").toString().contains("停用") && !dept.get("name").toString().contains("删除") && !dept.get("name").toString().contains("人员") && !dept.get("name").toString().contains("临时")){
|
||||
lm.add(dept);
|
||||
}
|
||||
//System.out.println("-----------------------------------------------");
|
||||
}
|
||||
cookie = parseControls(ctx.getResponseControls());
|
||||
ctx.setRequestControls(new Control[]{new PagedResultsControl(2, cookie, Control.CRITICAL)});
|
||||
|
@ -224,12 +180,10 @@ public class JhlDAPTool {
|
|||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
System.out.println("获取区域信息异常:");
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
closeContext();
|
||||
}
|
||||
System.out.println(lm.size());
|
||||
return lm;
|
||||
}
|
||||
|
||||
|
@ -282,7 +236,6 @@ public class JhlDAPTool {
|
|||
if (controls[i] instanceof PagedResultsResponseControl) {
|
||||
PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls[i];
|
||||
cookie = prrc.getCookie();
|
||||
System.out.println(">>Next Page \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue