Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7a8173ae
authored
Jun 07, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了组织结构相关的接口及实现
1 parent
f9a03434
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
931 additions
and
0 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrganizationController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerInfoDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgBranchDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgClusterDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgGroupDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgTeamDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgTeamEngineerDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/LevelReqDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationEngineersRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTeamsRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTreeReqDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTreeRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerInfoEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgBranchEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgClusterEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgGroupEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgTeamEngineerEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgTeamEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/OrganizationService.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrganizationServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrganizationController.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
controller
;
import
com.alibaba.cloud.integration.common.BusinessException
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dto.LevelReqDTO
;
import
com.alibaba.cloud.integration.order.service.OrganizationService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@RestController
public
class
OrganizationController
{
@Autowired
OrganizationService
organizationService
;
@GetMapping
(
"/organization/tree"
)
public
Result
<?>
organizationTree
(
LevelReqDTO
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
organizationService
.
getOrganizationTree
(
reqDTO
.
getLevelType
(),
reqDTO
.
getLevelValue
());
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
@GetMapping
(
"/organization/team/list"
)
public
Result
<?>
getTeams
(
LevelReqDTO
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
organizationService
.
getTeamsByLevel
(
reqDTO
.
getLevelType
(),
reqDTO
.
getLevelValue
());
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
@GetMapping
(
"/organization/engineer/list"
)
public
Result
<?>
getTeamsEngineers
(
@RequestParam
String
[]
teamIds
)
{
Result
<?>
res
=
null
;
try
{
res
=
organizationService
.
getEngineersByTeams
(
teamIds
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/EngineerInfoDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.EngineerInfoEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
EngineerInfoDao
extends
JpaRepository
{
EngineerInfoEntity
getByEngineerCode
(
String
engineerCode
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgBranchDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrgBranchEntity
;
import
com.alibaba.cloud.integration.order.entity.OrgClusterEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
OrgBranchDao
extends
JpaRepository
<
OrgBranchEntity
,
Integer
>
{
List
<
OrgBranchEntity
>
findAllByClusterId
(
String
clusterId
);
OrgBranchEntity
getByBranchId
(
String
branchId
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgClusterDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrgClusterEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
OrgClusterDao
extends
JpaRepository
<
OrgClusterEntity
,
Integer
>
{
OrgClusterEntity
getByClusterId
(
String
clusterId
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgGroupDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrgGroupEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
OrgGroupDao
extends
JpaRepository
<
OrgGroupEntity
,
Integer
>
{
List
<
OrgGroupEntity
>
findAllByBranchId
(
String
branchId
);
OrgGroupEntity
getByGroupId
(
String
groupId
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgTeamDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrgTeamEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
OrgTeamDao
extends
JpaRepository
<
OrgTeamEntity
,
Integer
>
{
List
<
OrgTeamEntity
>
findAllByClusterId
(
String
clusterId
);
List
<
OrgTeamEntity
>
findAllByBranchId
(
String
branchId
);
List
<
OrgTeamEntity
>
findAllByGroupId
(
String
groupId
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrgTeamEngineerDao.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.OrgTeamEngineerEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
OrgTeamEngineerDao
{
List
<
OrgTeamEngineerEntity
>
findAllByTeamidIn
(
String
[]
teamIds
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/LevelReqDTO.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
@Data
@Accessors
(
chain
=
true
)
public
class
LevelReqDTO
{
private
String
levelType
;
private
String
levelValue
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationEngineersRespDTO.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.experimental.Accessors
;
import
org.checkerframework.checker.units.qual.Acceleration
;
import
java.util.List
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
class
OrganizationEngineersRespDTO
{
private
List
<?>
engineers
;
@lombok
.
Data
public
static
class
Engineer
{
/**
* 技术员id
*/
private
String
engineerCode
;
/**
* 技术员姓名
*/
private
String
engineerName
;
/**
* 所属团队Id
*/
private
String
teamId
;
public
Engineer
(){
}
public
Engineer
(
String
teamId
,
String
engineerCode
,
String
engineerName
){
this
.
teamId
=
teamId
;
this
.
engineerCode
=
engineerCode
;
this
.
engineerName
=
engineerName
;
}
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTeamsRespDTO.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
class
OrganizationTeamsRespDTO
{
private
List
<?>
teams
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
static
class
Team
{
/**
* 所属的分部ID
*/
private
String
branchId
;
/**
* 所属的大区ID
*/
private
String
clusterId
;
/**
* 所属的分站ID
*/
private
String
groupId
;
/**
* 工作队ID
*/
private
String
teamId
;
/**
* 工作队名称
*/
private
String
teamName
;
/**
* 工作队类型,1-系统默认工作队名称 2-自定义工作队
*/
private
long
teamType
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTreeReqDTO.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
@lombok
.
Data
public
class
OrganizationTreeReqDTO
{
private
String
levelType
;
private
String
levelId
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/OrganizationTreeRespDTO.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
class
OrganizationTreeRespDTO
{
private
List
<?>
clusters
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
static
class
Cluster
{
/**
* 下级
*/
private
List
<?>
children
;
/**
* 大区ID
*/
private
String
id
;
/**
* 大区名称
*/
private
String
title
;
/**
* 类型
*/
private
String
type
;
}
/**
* Branch
*/
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
static
class
Branch
{
/**
* 下级
*/
private
List
<?>
children
;
/**
* 分部ID
*/
private
String
id
;
/**
* 分部名称
*/
private
String
title
;
/**
* 类型
*/
private
String
type
;
}
/**
* Group
*/
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
static
class
Group
{
/**
* 分站ID
*/
private
String
id
;
/**
* 分站名称
*/
private
String
title
;
/**
* 类型
*/
private
String
type
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/EngineerInfoEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Data
@Entity
@Table
(
name
=
"engineer_info"
)
public
class
EngineerInfoEntity
{
/**
* 工程师id
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
/**
* 工程师工号
*/
private
String
engineerCode
;
/**
* 工程师姓名
*/
private
String
name
;
/**
* 归属小组(分站、网点..)
*/
private
String
groupId
;
/**
* 原cosmos id
*/
private
String
cosmosId
;
/**
* 性别
*/
private
String
gender
;
/**
* 出生年份
*/
private
String
birth
;
/**
* 手机号码
*/
private
String
phone
;
/**
* 地址
*/
private
String
address
;
/**
* 类型(1全职 2兼职)
*/
private
int
kind
;
/**
* 职级,c2,c1...
*/
private
String
grade
;
/**
* 证书,如:低压电工证、燃气证
*/
private
String
credentials
;
/**
* 交通工具,1电动车 2摩托车 3公交车 4自驾
*/
private
int
vehicle
;
/**
* 摩托车、汽车的车牌号,便于计算限行
*/
private
String
vehicleNo
;
/**
* bean帐号状态(0无效 1有效)
*/
private
int
beanStatus
;
/**
* 技术员软标签 { 营销技能 :9, 沟通能力 :7}
*/
private
String
tags
;
/**
* 备注
*/
private
String
memo
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
EngineerInfoEntity
()
{}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgBranchEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Entity
@Data
@Table
(
name
=
"org_branch"
)
public
class
OrgBranchEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
private
String
branchId
;
private
String
branchName
;
private
String
clusterId
;
private
String
address
;
private
String
x
;
private
String
y
;
private
String
citycodeList
;
private
int
kind
;
private
String
layerId
;
private
String
memo
;
private
Date
createTime
;
private
Date
updateTime
;
public
OrgBranchEntity
()
{}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgClusterEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Entity
@Data
@Table
(
name
=
"org_cluster"
)
public
class
OrgClusterEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
private
String
clusterId
;
private
String
name
;
private
String
citycodeList
;
private
String
address
;
private
String
cityName
;
private
int
status
;
private
String
updateUser
;
private
Date
createTime
;
private
Date
updateTime
;
public
OrgClusterEntity
()
{
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgGroupEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Entity
@Data
@Table
(
name
=
"org_group"
)
public
class
OrgGroupEntity
{
/**
* id
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
/**
* 小组id
*/
private
String
groupId
;
/**
* 小组名称
*/
private
String
groupName
;
/**
* 归属大区
*/
private
String
clusterId
;
/**
* 归属分部
*/
private
String
branchId
;
/**
* 办公地址
*/
private
String
address
;
/**
* 办公地址经度
*/
private
String
x
;
/**
* 办公地址纬度
*/
private
String
y
;
/**
* 小组所在城市code
*/
private
String
cityCode
;
/**
* 类型(1分站,2外围,3小组,4网点,5自保点)
*/
private
int
kind
;
/**
* 类型(1自有,2加盟)
*/
private
int
category
;
/**
* 默认配件仓
*/
private
int
warehouseId
;
/**
* 备注
*/
private
String
memo
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
OrgGroupEntity
()
{}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgTeamEngineerEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Entity
@Data
@Table
(
name
=
"org_team_engineer"
)
public
class
OrgTeamEngineerEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* id
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
/**
* 工作队id
*/
private
String
teamId
;
/**
* 工程师工号
*/
private
String
engineerCode
;
/**
* 状态(0无效 1有效)
*/
private
int
status
;
/**
* 备注
*/
private
String
memo
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
OrgTeamEngineerEntity
()
{
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/OrgTeamEntity.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Entity
@Data
@Table
(
name
=
"org_team"
)
public
class
OrgTeamEntity
{
/**
* id
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
/**
* 工作队id
*/
private
String
teamId
;
/**
* 工作队名称
*/
private
String
teamName
;
/**
* 类别:1 映射工作队 2自定义工作队
*/
private
int
teamType
;
/**
* 归属大区
*/
private
String
clusterId
;
/**
* 归属分部
*/
private
String
branchId
;
/**
* 归属小组
*/
private
String
groupId
;
/**
* 取件配件仓
*/
private
String
warehouseId
;
/**
* 工作日,1表示星期一,2表示星期二
*/
private
String
workdays
;
/**
* 备注
*/
private
String
memo
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
public
OrgTeamEntity
(){
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/OrganizationService.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
;
import
com.alibaba.cloud.integration.common.Result
;
public
interface
OrganizationService
{
Result
<?>
getOrganizationTree
(
String
levelType
,
String
levelId
);
Result
<?>
getEngineersByTeams
(
String
[]
teamIds
);
Result
<?>
getTeamsByLevel
(
String
levelType
,
String
levelValue
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/OrganizationServiceImpl.java
0 → 100644
View file @
7a8173a
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
.
impl
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.*
;
import
com.alibaba.cloud.integration.order.dto.OrganizationEngineersRespDTO
;
import
com.alibaba.cloud.integration.order.dto.OrganizationTeamsRespDTO
;
import
com.alibaba.cloud.integration.order.dto.OrganizationTreeRespDTO
;
import
com.alibaba.cloud.integration.order.entity.*
;
import
com.alibaba.cloud.integration.order.service.OrganizationService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
@Service
@Slf4j
public
class
OrganizationServiceImpl
implements
OrganizationService
{
@Autowired
OrgClusterDao
orgClusterDao
;
@Autowired
OrgBranchDao
orgBranchDao
;
@Autowired
OrgGroupDao
orgGroupDao
;
@Autowired
OrgTeamEngineerDao
orgTeamEngineerDao
;
@Autowired
EngineerInfoDao
engineerInfoDao
;
@Autowired
OrgTeamDao
orgTeamDao
;
@Override
public
Result
<?>
getOrganizationTree
(
String
levelType
,
String
levelId
)
{
// 如果传递了精确的id,只返回对应的tree内容;如果没有传递,返回所有tree内容
if
(
"group"
.
equals
(
levelType
))
{
OrgGroupEntity
orgGroupEntity
=
orgGroupDao
.
getByGroupId
(
levelId
);
if
(
orgGroupEntity
==
null
)
{
return
Result
.
failed
(
"groupId对应的信息不存在"
);
}
List
<?>
groups
=
new
ArrayList
<>(
Collections
.
singletonList
(
groupEntity2Dto
(
orgGroupEntity
)));
OrgBranchEntity
orgBranchEntity
=
orgBranchDao
.
getByBranchId
(
orgGroupEntity
.
getBranchId
());
List
<?>
branchs
=
new
ArrayList
<>(
Collections
.
singletonList
(
branchEntityh2Dto
(
orgBranchEntity
).
setChildren
(
groups
)));
OrgClusterEntity
orgClusterEntity
=
orgClusterDao
.
getByClusterId
(
orgGroupEntity
.
getClusterId
());
List
<?>
clusters
=
new
ArrayList
<>(
Collections
.
singletonList
(
clusterEntity2Dto
(
orgClusterEntity
).
setChildren
(
branchs
)));
return
Result
.
success
(
new
OrganizationTreeRespDTO
().
setClusters
(
clusters
));
}
else
if
(
"branch"
.
equals
(
levelType
))
{
OrgBranchEntity
orgBranchEntity
=
orgBranchDao
.
getByBranchId
(
levelId
);
if
(
orgBranchEntity
==
null
)
{
return
Result
.
failed
(
"分站信息不存在"
);
}
OrgClusterEntity
orgClusterEntity
=
orgClusterDao
.
getByClusterId
(
orgBranchEntity
.
getClusterId
());
List
<?>
groups
=
getChildByBranch
(
levelId
);
List
<?>
branchs
=
new
ArrayList
<>(
Collections
.
singletonList
(
branchEntityh2Dto
(
orgBranchEntity
).
setChildren
(
groups
)));
List
<?>
clusters
=
new
ArrayList
<>(
Collections
.
singletonList
(
clusterEntity2Dto
(
orgClusterEntity
).
setChildren
(
branchs
)));
return
Result
.
success
(
new
OrganizationTreeRespDTO
().
setClusters
(
clusters
));
}
else
if
(
"cluster"
.
equals
(
levelType
))
{
OrgClusterEntity
orgClusterEntity
=
orgClusterDao
.
getByClusterId
(
levelId
);
if
(
orgClusterEntity
==
null
)
{
return
Result
.
failed
(
"大区信息不存在"
);
}
List
<?>
branchs
=
getChildByCluster
(
levelId
);
List
<?>
clusters
=
new
ArrayList
<>(
Collections
.
singletonList
(
clusterEntity2Dto
(
orgClusterEntity
).
setChildren
(
branchs
)));
return
Result
.
success
(
new
OrganizationTreeRespDTO
().
setClusters
(
clusters
));
}
else
{
return
Result
.
success
(
new
OrganizationTreeRespDTO
().
setClusters
(
getTreeByRoot
()));
}
}
@Override
public
Result
<?>
getEngineersByTeams
(
String
[]
teamIds
)
{
List
<
OrganizationEngineersRespDTO
.
Engineer
>
engineers
=
new
ArrayList
<>();
for
(
OrgTeamEngineerEntity
e
:
orgTeamEngineerDao
.
findAllByTeamidIn
(
teamIds
))
{
EngineerInfoEntity
engineerInfoEntity
=
engineerInfoDao
.
getByEngineerCode
(
e
.
getEngineerCode
());
if
(
engineerInfoEntity
==
null
)
{
log
.
error
(
"技术员信息不存在!engineer_code[%s]"
,
e
.
getEngineerCode
());
continue
;
}
engineers
.
add
(
new
OrganizationEngineersRespDTO
.
Engineer
(
e
.
getTeamId
(),
e
.
getEngineerCode
(),
engineerInfoEntity
.
getName
()));
}
return
Result
.
success
(
new
OrganizationEngineersRespDTO
().
setEngineers
(
engineers
));
}
@Override
public
Result
<?>
getTeamsByLevel
(
String
levelType
,
String
levelValue
)
{
List
<
OrgTeamEntity
>
entities
;
if
(
"cluster"
.
equals
(
levelType
))
{
entities
=
orgTeamDao
.
findAllByClusterId
(
levelValue
);
}
else
if
(
"branch"
.
equals
(
levelType
))
{
entities
=
orgTeamDao
.
findAllByBranchId
(
levelValue
);
}
else
if
(
"group"
.
equals
(
levelType
))
{
entities
=
orgTeamDao
.
findAllByGroupId
(
levelValue
);
}
else
{
entities
=
orgTeamDao
.
findAll
();
}
List
<
OrganizationTeamsRespDTO
.
Team
>
teams
=
new
ArrayList
<>();
for
(
OrgTeamEntity
e
:
entities
)
{
teams
.
add
(
new
OrganizationTeamsRespDTO
.
Team
()
.
setTeamType
(
e
.
getTeamType
())
.
setTeamId
(
e
.
getTeamId
())
.
setTeamName
(
e
.
getTeamName
())
.
setClusterId
(
e
.
getClusterId
())
.
setBranchId
(
e
.
getBranchId
())
.
setGroupId
(
e
.
getGroupId
())
);
}
return
Result
.
success
(
new
OrganizationTeamsRespDTO
().
setTeams
(
teams
));
}
private
List
<?>
getTreeByRoot
()
{
List
<
OrganizationTreeRespDTO
.
Cluster
>
clusters
=
new
ArrayList
<>();
for
(
OrgClusterEntity
c
:
orgClusterDao
.
findAll
())
{
clusters
.
add
(
clusterEntity2Dto
(
c
).
setChildren
(
getChildByCluster
(
c
.
getClusterId
())));
}
return
clusters
;
}
private
List
<?>
getChildByCluster
(
String
clusterId
)
{
List
<
OrganizationTreeRespDTO
.
Branch
>
branches
=
new
ArrayList
<>();
for
(
OrgBranchEntity
b
:
orgBranchDao
.
findAllByClusterId
(
clusterId
))
{
branches
.
add
(
branchEntityh2Dto
(
b
).
setChildren
(
getChildByBranch
(
b
.
getBranchId
())));
}
return
branches
;
}
private
List
<?>
getChildByBranch
(
String
branchId
)
{
// 获取branch及下面的group
List
<
OrganizationTreeRespDTO
.
Group
>
groups
=
new
ArrayList
<>();
for
(
OrgGroupEntity
g
:
orgGroupDao
.
findAllByBranchId
(
branchId
))
{
groups
.
add
(
groupEntity2Dto
(
g
));
}
return
groups
;
}
private
OrganizationTreeRespDTO
.
Group
groupEntity2Dto
(
OrgGroupEntity
orgGroupEntity
)
{
return
new
OrganizationTreeRespDTO
.
Group
()
.
setType
(
"group"
)
.
setId
(
orgGroupEntity
.
getGroupId
())
.
setTitle
(
orgGroupEntity
.
getGroupName
());
}
private
OrganizationTreeRespDTO
.
Branch
branchEntityh2Dto
(
OrgBranchEntity
orgBranchEntity
)
{
return
new
OrganizationTreeRespDTO
.
Branch
()
.
setType
(
"branch"
)
.
setId
(
orgBranchEntity
.
getBranchId
())
.
setTitle
(
orgBranchEntity
.
getBranchName
());
}
private
OrganizationTreeRespDTO
.
Cluster
clusterEntity2Dto
(
OrgClusterEntity
orgClusterEntity
)
{
return
new
OrganizationTreeRespDTO
.
Cluster
()
.
setType
(
"custer"
)
.
setId
(
orgClusterEntity
.
getClusterId
())
.
setTitle
(
orgClusterEntity
.
getName
());
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment