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
115d13d4
Commit
115d13d4
authored
Jun 22, 2020
by
邓实川
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户管理统计图查询效率优化
parent
2679930c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
51 deletions
+151
-51
src/main/java/cn/timer/api/controller/crm/CrmController.java
+74
-48
src/main/java/cn/timer/api/dao/crm/CrmClientDataMapper.java
+11
-2
src/main/java/cn/timer/api/dto/crm/CrmCartogramDto.java
+34
-0
src/main/java/cn/timer/api/dto/crm/CrmClientDataImportVo.java
+1
-1
src/main/resources/mapping/crm/CrmClientDataMapper.xml
+31
-0
No files found.
src/main/java/cn/timer/api/controller/crm/CrmController.java
View file @
115d13d4
...
...
@@ -49,6 +49,7 @@ import cn.timer.api.config.annotation.UserBean;
import
cn.timer.api.config.enums.SysRoleType
;
import
cn.timer.api.dao.crm.CrmClientContactsMapper
;
import
cn.timer.api.dao.crm.CrmClientDataMapper
;
import
cn.timer.api.dto.crm.CrmCartogramDto
;
import
cn.timer.api.dto.crm.CrmClientDataImportVo
;
import
cn.timer.api.utils.CheckUtil
;
import
cn.timer.api.utils.Result
;
...
...
@@ -969,23 +970,25 @@ public class CrmController {
}
listAll
.
add
(
cartogram5
);
List
<
Map
<
String
,
Object
>>
cartogram6
=
new
ArrayList
<
Map
<
String
,
Object
>>();
// 图6
for
(
Integer
keyId
:
getKeyIdList
())
{
Map
<
String
,
Object
>
map
=
cartogram3
(
orgCode
,
groupId
,
keyId
,
belonger
,
startCreateTime
,
endCreateTime
);
if
((
Integer
)
map
.
get
(
"num"
)
>
0
)
{
cartogram6
.
add
(
map
);
}
}
// List<Map<String, Object>> cartogram6 = new ArrayList<Map<String, Object>>(); // 图6
// for (Integer keyId : getKeyIdList()) {
// Map<String, Object> map = cartogram3(orgCode, groupId, keyId, belonger, startCreateTime, endCreateTime);
// if ((Integer) map.get("num") > 0) {
// cartogram6.add(map);
// }
// }
List
<
CrmCartogramDto
>
cartogram6
=
getCartogram6
(
orgCode
,
belonger
,
groupId
,
startCreateTime
,
endCreateTime
);
listAll
.
add
(
cartogram6
);
return
ResultUtil
.
data
(
listAll
,
"获取成功"
);
}
// 获取省份id
private
List
<
Integer
>
getKeyIdList
()
{
List
<
SysRegion
>
list
=
SysRegion
.
builder
().
build
()
.
selectList
(
new
LambdaQueryWrapper
<
SysRegion
>().
eq
(
SysRegion:
:
getLevel
,
1
).
select
(
SysRegion:
:
getKeyId
));
return
list
.
stream
().
map
(
SysRegion:
:
getKeyId
).
collect
(
Collectors
.
toList
());
}
//
private List<Integer> getKeyIdList() {
//
List<SysRegion> list = SysRegion.builder().build()
//
.selectList(new LambdaQueryWrapper<SysRegion>().eq(SysRegion::getLevel, 1).select(SysRegion::getKeyId));
//
return list.stream().map(SysRegion::getKeyId).collect(Collectors.toList());
//
}
@GetMapping
(
"getAllBusinessMan"
)
@ApiOperation
(
value
=
"获取全部业务员"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
...
...
@@ -1022,7 +1025,12 @@ public class CrmController {
.
eq
(
belonger
!=
null
,
CrmClientData:
:
getBelongUser
,
belonger
)
.
ge
(
StringUtils
.
isNotBlank
(
startCreateTime
),
CrmClientData:
:
getCreateTime
,
startCreateTime
)
.
le
(
StringUtils
.
isNotBlank
(
endCreateTime
),
CrmClientData:
:
getCreateTime
,
endCreateTime
));
String
name
=
getEmpName
(
orgCode
,
belonger
);
String
name
=
"未知"
;
if
(
belonger
==
0
)
{
name
=
"公海客户"
;
}
else
{
name
=
getEmpName
(
orgCode
,
belonger
);
}
map
.
put
(
"name"
,
name
);
map
.
put
(
"num"
,
num
);
return
map
;
...
...
@@ -1048,6 +1056,10 @@ public class CrmController {
list
.
add
(
map
);
}
}
Map
<
String
,
Object
>
map
=
selectMap
(
orgCode
,
0
,
status
,
startCreateTime
,
endCreateTime
);
if
((
Integer
)
map
.
get
(
"num"
)
>
0
)
list
.
add
(
map
);
}
else
{
Map
<
String
,
Object
>
map
=
selectMap
(
orgCode
,
belonger
,
status
,
startCreateTime
,
endCreateTime
);
if
((
Integer
)
map
.
get
(
"num"
)
>
0
)
{
...
...
@@ -1109,42 +1121,56 @@ public class CrmController {
* @param belonger 业务员id (可不填)
* @return
*/
private
Map
<
String
,
Object
>
cartogram3
(
Integer
orgCode
,
Integer
groupId
,
Integer
provinceId
,
Integer
belonger
,
String
startCreateTime
,
String
endCreateTime
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Integer
num
=
0
;
if
(
belonger
==
null
)
{
List
<
Integer
>
members
=
getAllBusinessGroupMember
(
orgCode
,
groupId
);
for
(
Integer
memberId
:
members
)
{
num
+=
CrmClientData
.
builder
().
build
()
.
selectCount
(
new
QueryWrapper
<
CrmClientData
>().
lambda
().
eq
(
CrmClientData:
:
getOrgCode
,
orgCode
)
.
eq
(
CrmClientData:
:
getProvinceId
,
provinceId
).
eq
(
CrmClientData:
:
getBelongUser
,
memberId
)
.
ge
(
StringUtils
.
isNotBlank
(
startCreateTime
),
CrmClientData:
:
getCreateTime
,
startCreateTime
)
.
le
(
StringUtils
.
isNotBlank
(
endCreateTime
),
CrmClientData:
:
getCreateTime
,
endCreateTime
));
}
map
.
put
(
"provinceId"
,
provinceId
);
String
name
=
SysRegion
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SysRegion
>().
lambda
()
.
eq
(
SysRegion:
:
getLevel
,
1
).
eq
(
SysRegion:
:
getKeyId
,
provinceId
).
select
(
SysRegion:
:
getRegionName
))
.
getRegionName
();
map
.
put
(
"provinceName"
,
name
);
map
.
put
(
"num"
,
num
);
// private Map<String, Object> cartogram3(Integer orgCode, Integer groupId, Integer provinceId, Integer belonger,
// String startCreateTime, String endCreateTime) {
// Map<String, Object> map = new HashMap<String, Object>();
// Integer num = 0;
// if (belonger == null) {
//
// List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
// for (Integer memberId : members) {
// num += CrmClientData.builder().build()
// .selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
// .eq(CrmClientData::getProvinceId, provinceId).eq(CrmClientData::getBelongUser, memberId)
// .ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime,
// startCreateTime)
// .le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime,
// endCreateTime));
// }
// map.put("provinceId", provinceId);
// String name = SysRegion.builder().build().selectOne(new QueryWrapper<SysRegion>().lambda()
// .eq(SysRegion::getLevel, 1).eq(SysRegion::getKeyId, provinceId).select(SysRegion::getRegionName))
// .getRegionName();
// map.put("provinceName", name);
// map.put("num", num);
//
// } else {
// num = CrmClientData.builder().build()
// .selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
// .eq(CrmClientData::getProvinceId, provinceId).eq(CrmClientData::getBelongUser, belonger)
// .ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
// .le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
// map.put("provinceId", provinceId);
// String name = SysRegion.builder().build().selectOne(new QueryWrapper<SysRegion>().lambda()
// .eq(SysRegion::getLevel, 1).eq(SysRegion::getKeyId, provinceId).select(SysRegion::getRegionName))
// .getRegionName();
// map.put("provinceName", name);
// map.put("num", num);
// }
// return map;
// }
}
else
{
num
=
CrmClientData
.
builder
().
build
()
.
selectCount
(
new
QueryWrapper
<
CrmClientData
>().
lambda
().
eq
(
CrmClientData:
:
getOrgCode
,
orgCode
)
.
eq
(
CrmClientData:
:
getProvinceId
,
provinceId
).
eq
(
CrmClientData:
:
getBelongUser
,
belonger
)
.
ge
(
StringUtils
.
isNotBlank
(
startCreateTime
),
CrmClientData:
:
getCreateTime
,
startCreateTime
)
.
le
(
StringUtils
.
isNotBlank
(
endCreateTime
),
CrmClientData:
:
getCreateTime
,
endCreateTime
));
map
.
put
(
"provinceId"
,
provinceId
);
String
name
=
SysRegion
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SysRegion
>().
lambda
()
.
eq
(
SysRegion:
:
getLevel
,
1
).
eq
(
SysRegion:
:
getKeyId
,
provinceId
).
select
(
SysRegion:
:
getRegionName
))
.
getRegionName
();
map
.
put
(
"provinceName"
,
name
);
map
.
put
(
"num"
,
num
);
}
return
map
;
/**
* 统计图6-籍贯
*
* @param orgCode
* @param belongGroup
* @param createTime
* @return
*/
private
List
<
CrmCartogramDto
>
getCartogram6
(
Integer
orgCode
,
Integer
belongUser
,
Integer
belongGroup
,
String
startCreateTime
,
String
endCreateTime
)
{
return
crmClientDataMapper
.
crmCartogram
(
orgCode
,
belongUser
,
belongGroup
,
startCreateTime
,
endCreateTime
);
}
/**
...
...
src/main/java/cn/timer/api/dao/crm/CrmClientDataMapper.java
View file @
115d13d4
...
...
@@ -7,13 +7,17 @@
*/
package
cn
.
timer
.
api
.
dao
.
crm
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.timer.api.bean.crm.CrmClientData
;
import
cn.timer.api.dto.crm.CrmCartogramDto
;
/**
* Title: CrmClientDataMapper.java
* Description:
* Title: CrmClientDataMapper.java Description:
*
* @author dsc
* @date 2020年6月5日
...
...
@@ -21,4 +25,9 @@ import cn.timer.api.bean.crm.CrmClientData;
*/
public
interface
CrmClientDataMapper
extends
BaseMapper
<
CrmClientData
>
{
List
<
CrmCartogramDto
>
crmCartogram
(
@RequestParam
(
"orgCode"
)
Integer
orgCode
,
@RequestParam
(
name
=
"belongUser"
,
required
=
false
)
Integer
belongUser
,
@RequestParam
(
name
=
"belongGroup"
,
required
=
false
)
Integer
belongGroup
,
@RequestParam
(
name
=
"startCreateTime"
,
required
=
false
)
String
startCreateTime
,
@RequestParam
(
name
=
"endCreateTime"
,
required
=
false
)
String
endCreateTime
);
}
src/main/java/cn/timer/api/dto/crm/CrmCartogramDto.java
0 → 100644
View file @
115d13d4
/**
* Title: CrmCartogramDto.java
* Description:
* @author dsc
* @date 2020年6月22日
* @version 1.0
*/
package
cn
.
timer
.
api
.
dto
.
crm
;
import
java.io.Serializable
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* Title: CrmCartogramDto.java
*
* @Description:
* @author dsc
* @date 2020年6月22日
* @version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
CrmCartogramDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4445892627839823485L
;
private
Integer
provinceId
;
private
String
province
;
private
Integer
provinceNum
;
}
src/main/java/cn/timer/api/dto/crm/CrmClientDataImportVo.java
View file @
115d13d4
...
...
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor;
/**
* Title: CrmClientDataImportVo.java
*
* @Description:
* @Description:
客户导入
* @author dsc
* @date 2020年6月12日
* @version 1.0
...
...
src/main/resources/mapping/crm/CrmClientDataMapper.xml
0 → 100644
View file @
115d13d4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.timer.api.dao.crm.CrmClientDataMapper"
>
<select
id=
"crmCartogram"
resultType=
"cn.timer.api.dto.crm.CrmCartogramDto"
>
SELECT
province_id,province,count(province_id) provinceNum
FROM
crm_client_data
WHERE
org_code = #{orgCode}
<if
test=
'null != belongUser and belongUser !=""'
>
AND
belong_user = #{belongUser}
</if>
<if
test=
'null != belongGroup and belongGroup !=""'
>
AND
belong_group = #{belongGroup}
</if>
<if
test=
'null != startCreateTime and startCreateTime !=""'
>
AND
create_time
<![CDATA[>=]]>
#{startCreateTime}
</if>
<if
test=
'null != endCreateTime and endCreateTime !=""'
>
AND
create_time
<![CDATA[<=]]>
#{endCreateTime}
</if>
GROUP BY
province_id
</select>
</mapper>
\ No newline at end of file
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