Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
6c3be6b2
Commit
6c3be6b2
authored
Jun 11, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增/编辑业务组优化
parent
f9a477e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
28 deletions
+63
-28
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroup.java
+2
-2
src/main/java/cn/timer/api/controller/crm/CrmController.java
+61
-26
No files found.
src/main/java/cn/timer/api/bean/crm/CrmBusinessGroup.java
View file @
6c3be6b2
...
@@ -87,7 +87,7 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
...
@@ -87,7 +87,7 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@Transient
@Transient
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"组管理员id"
)
@ApiModelProperty
(
value
=
"组管理员id"
)
private
Integer
[]
managerIds
;
private
List
<
Integer
>
managerIds
;
@Transient
@Transient
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
...
@@ -97,7 +97,7 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
...
@@ -97,7 +97,7 @@ public class CrmBusinessGroup extends Model<CrmBusinessGroup> {
@Transient
@Transient
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"组成员id"
)
@ApiModelProperty
(
value
=
"组成员id"
)
private
Integer
[]
memberIds
;
private
List
<
Integer
>
memberIds
;
@Transient
@Transient
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
...
...
src/main/java/cn/timer/api/controller/crm/CrmController.java
View file @
6c3be6b2
...
@@ -112,40 +112,74 @@ public class CrmController {
...
@@ -112,40 +112,74 @@ public class CrmController {
@PostMapping
(
"addBusinessGroup"
)
@PostMapping
(
"addBusinessGroup"
)
@Transactional
@Transactional
@ApiOperation
(
value
=
"新增业务组"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"新增
/编辑
业务组"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
addBusinessGroup
(
@CurrentUser
UserBean
userBean
,
public
Result
<
Object
>
addBusinessGroup
(
@CurrentUser
UserBean
userBean
,
@RequestBody
CrmBusinessGroup
crmBusinessGroup
)
{
@RequestBody
CrmBusinessGroup
crmBusinessGroup
)
{
Integer
orgCode
=
getOrgCode
(
userBean
);
Integer
orgCode
=
getOrgCode
(
userBean
);
Integer
empNum
=
getEmpNum
(
userBean
);
Integer
empNum
=
getEmpNum
(
userBean
);
CrmBusinessGroup
crmBusinessGroupOld
=
CrmBusinessGroup
.
builder
().
build
()
.
selectOne
(
new
QueryWrapper
<
CrmBusinessGroup
>().
lambda
().
eq
(
CrmBusinessGroup:
:
getOrgCode
,
orgCode
)
.
select
(
CrmBusinessGroup:
:
getSort
).
last
(
"limit 1"
).
orderByDesc
(
CrmBusinessGroup:
:
getId
));
if
(
crmBusinessGroupOld
==
null
)
crmBusinessGroup
.
setSort
(
1
);
else
crmBusinessGroup
.
setSort
(
crmBusinessGroupOld
.
getSort
()
+
1
);
// 排序
// crmBusinessGroup.setManagerName(getEmpName(orgCode, empNum)); // 设置管理员姓名
crmBusinessGroup
.
setCreateUser
(
empNum
);
// 创建人
crmBusinessGroup
.
setModifyUser
(
empNum
);
// 修改人
crmBusinessGroup
.
setOrgCode
(
orgCode
);
// crmBusinessGroup.setMember(member); // ,字符串拼接
boolean
result
=
crmBusinessGroup
.
insert
();
if
(!
result
)
return
ResultUtil
.
success
(
"新增失败"
);
Integer
gid
=
crmBusinessGroup
.
getId
();
Integer
gid
=
crmBusinessGroup
.
getId
();
Integer
[]
memberIds
=
crmBusinessGroup
.
getMemberIds
();
crmBusinessGroup
.
setModifyUser
(
empNum
);
// 修改人
for
(
Integer
empId
:
memberIds
)
{
if
(
gid
==
null
)
{
CrmBusinessGroupMember
.
builder
().
gid
(
gid
).
empNum
(
empId
).
orgCode
(
orgCode
).
type
(
0
).
build
().
insert
();
CrmBusinessGroup
crmBusinessGroupOld
=
CrmBusinessGroup
.
builder
().
build
()
.
selectOne
(
new
QueryWrapper
<
CrmBusinessGroup
>().
lambda
().
eq
(
CrmBusinessGroup:
:
getOrgCode
,
orgCode
)
.
select
(
CrmBusinessGroup:
:
getSort
).
last
(
"limit 1"
).
orderByDesc
(
CrmBusinessGroup:
:
getId
));
if
(
crmBusinessGroupOld
==
null
)
crmBusinessGroup
.
setSort
(
1
);
else
crmBusinessGroup
.
setSort
(
crmBusinessGroupOld
.
getSort
()
+
1
);
// 排序
crmBusinessGroup
.
setCreateUser
(
empNum
);
// 创建人
crmBusinessGroup
.
setOrgCode
(
orgCode
);
boolean
result
=
crmBusinessGroup
.
insert
();
if
(!
result
)
return
ResultUtil
.
success
(
"新增失败"
);
gid
=
crmBusinessGroup
.
getId
();
List
<
Integer
>
memberIds
=
crmBusinessGroup
.
getMemberIds
();
for
(
Integer
empId
:
memberIds
)
{
insertMembers
(
gid
,
empId
,
orgCode
,
0
);
}
List
<
Integer
>
managerIds
=
crmBusinessGroup
.
getManagerIds
();
for
(
Integer
empId
:
managerIds
)
{
insertMembers
(
gid
,
empId
,
orgCode
,
1
);
}
CrmSeaRule
crmSeaRule
=
crmBusinessGroup
.
getCrmSeaRules
();
crmSeaRule
.
setGid
(
gid
);
crmSeaRule
.
insert
();
}
else
{
List
<
Integer
>
memberIds
=
crmBusinessGroup
.
getMemberIds
();
List
<
Integer
>
managerIds
=
crmBusinessGroup
.
getManagerIds
();
// 更新组成员
updateMembers
(
orgCode
,
gid
,
memberIds
,
0
);
updateMembers
(
orgCode
,
gid
,
managerIds
,
1
);
// 更新公海规则
crmBusinessGroup
.
getCrmSeaRules
().
update
(
new
LambdaQueryWrapper
<
CrmSeaRule
>().
eq
(
CrmSeaRule:
:
getGid
,
gid
));
}
}
Integer
[]
managerIds
=
crmBusinessGroup
.
getManagerIds
();
return
ResultUtil
.
success
(
"新增业务组成功"
);
for
(
Integer
empId
:
managerIds
)
{
}
CrmBusinessGroupMember
.
builder
().
gid
(
gid
).
empNum
(
empId
).
orgCode
(
orgCode
).
type
(
1
).
build
().
insert
();
private
void
insertMembers
(
Integer
gid
,
Integer
empId
,
Integer
orgCode
,
Integer
type
)
{
CrmBusinessGroupMember
.
builder
().
gid
(
gid
).
empNum
(
empId
).
orgCode
(
orgCode
).
type
(
type
).
build
().
insert
();
}
private
void
updateMembers
(
Integer
orgCode
,
Integer
gid
,
List
<
Integer
>
memberIds
,
Integer
type
)
{
List
<
CrmBusinessGroupMember
>
oldMembers
=
CrmBusinessGroupMember
.
builder
().
build
()
.
selectList
(
new
LambdaQueryWrapper
<
CrmBusinessGroupMember
>().
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
)
.
eq
(
CrmBusinessGroupMember:
:
getType
,
type
).
select
(
CrmBusinessGroupMember:
:
getEmpNum
));
// 旧组成员idlist
List
<
Integer
>
oldIdsList
=
oldMembers
.
stream
().
map
(
CrmBusinessGroupMember:
:
getEmpNum
)
.
collect
(
Collectors
.
toList
());
List
<
Integer
>
deList
=
CheckUtil
.
reduce
(
oldIdsList
,
memberIds
);
// 删
for
(
Integer
integer
:
deList
)
{
CrmBusinessGroupMember
.
builder
().
build
()
.
delete
(
new
LambdaQueryWrapper
<
CrmBusinessGroupMember
>()
.
eq
(
CrmBusinessGroupMember:
:
getEmpNum
,
integer
).
eq
(
CrmBusinessGroupMember:
:
getGid
,
gid
)
.
eq
(
CrmBusinessGroupMember:
:
getOrgCode
,
orgCode
).
eq
(
CrmBusinessGroupMember:
:
getType
,
type
));
}
}
CrmSeaRule
crmSeaRule
=
crmBusinessGroup
.
getCrmSeaRules
();
List
<
Integer
>
addList
=
CheckUtil
.
reduce
(
memberIds
,
oldIdsList
);
// 增
crmSeaRule
.
setGid
(
gid
);
for
(
Integer
integer
:
addList
)
{
crmSeaRule
.
insert
();
CrmBusinessGroupMember
.
builder
().
empNum
(
integer
).
gid
(
gid
).
orgCode
(
orgCode
).
type
(
type
).
build
()
.
insert
();
return
ResultUtil
.
success
(
"新增业务组成功"
);
}
}
}
@GetMapping
(
"getBusinessGroup"
)
@GetMapping
(
"getBusinessGroup"
)
...
@@ -179,6 +213,7 @@ public class CrmController {
...
@@ -179,6 +213,7 @@ public class CrmController {
String
name
=
getEmpName
(
getOrgCode
(
userBean
),
empNum
);
String
name
=
getEmpName
(
getOrgCode
(
userBean
),
empNum
);
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"name"
,
name
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"empNum"
,
empNum
);
members
.
add
(
map
);
members
.
add
(
map
);
}
}
crmBusinessGroup
.
setMembers
(
members
);
crmBusinessGroup
.
setMembers
(
members
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment