Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3f1914c8
authored
Nov 19, 2021
by
linkwechat8856@163.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
客户公海代码测试提交;
1 parent
eca6b40e
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
403 additions
and
16 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerSeasController.java
linkwe-common/src/main/java/com/linkwechat/common/config/RuoYiConfig.java
linkwe-common/src/main/java/com/linkwechat/common/utils/poi/ExcelUtil.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomerSeas.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/CustomerSeasCountVo.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/CustomerSeasRecordVo.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCustomerSeasMapper.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessagePushService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerSeasService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerSeasServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerSeasMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerSeasController.java
View file @
3f1914c
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.poi.ExcelUtil
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
com.linkwechat.wecom.service.IWeCustomerMessagePushService
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
/**
/**
* 客户公海相关
* 客户公海相关
...
@@ -17,6 +33,175 @@ public class WeCustomerSeasController extends BaseController {
...
@@ -17,6 +33,175 @@ public class WeCustomerSeasController extends BaseController {
private
IWeCustomerSeasService
iWeCustomerSeasService
;
private
IWeCustomerSeasService
iWeCustomerSeasService
;
@Autowired
private
IWeCustomerMessagePushService
iWeCustomerMessagePushService
;
/**
* 客户公海模版下载
* @return
*/
@GetMapping
(
"/importTemplate"
)
public
AjaxResult
importTemplate
()
{
ExcelUtil
<
WeCustomerSeas
>
util
=
new
ExcelUtil
<
WeCustomerSeas
>(
WeCustomerSeas
.
class
);
return
util
.
importTemplateExcel
(
DateUtils
.
dateTimeNow
(
DateUtils
.
YYYY_MM_DD
)+
"_客户公海"
);
}
/**
* 导入公海数据
* @param file
* @param weCustomerSea
* @return
*/
@PostMapping
(
"/importData"
)
public
AjaxResult
importData
(
MultipartFile
file
,
WeCustomerSeas
weCustomerSea
)
throws
Exception
{
ExcelUtil
<
WeCustomerSeas
>
util
=
new
ExcelUtil
<
WeCustomerSeas
>(
WeCustomerSeas
.
class
);
List
<
WeCustomerSeas
>
weCustomerSeas
=
util
.
importExcel
(
file
.
getInputStream
());
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerSeas
)){
if
(
StringUtils
.
isEmpty
(
weCustomerSea
.
getAddUserName
())&&
StringUtils
.
isEmpty
(
weCustomerSea
.
getAddUserId
())){
return
AjaxResult
.
error
(
"分配人不可为空!"
);
}
//过滤字段为空的数据
List
<
WeCustomerSeas
>
deduplicationSeas
=
weCustomerSeas
.
stream
().
filter
(
s
->
StringUtils
.
isNotEmpty
(
s
.
getCustomerName
())
||
StringUtils
.
isNotEmpty
(
s
.
getPhone
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isEmpty
(
deduplicationSeas
)){
return
AjaxResult
.
error
(
"导入用户数据不能为空!"
);
}
//跟根据手机号去重
List
<
WeCustomerSeas
>
deduplicationSeasNoRepeat
=
deduplicationSeas
.
stream
().
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
WeCustomerSeas
::
getPhone
))),
ArrayList:
:
new
));
Long
tabaleExcelId
=
SnowFlakeUtil
.
nextId
();
List
<
String
>
userIds
=
ListUtil
.
toList
(
weCustomerSea
.
getAddUserId
().
split
(
","
));
List
<
String
>
userNames
=
ListUtil
.
toList
(
weCustomerSea
.
getAddUserName
().
split
(
","
));
IntStream
.
range
(
0
,
deduplicationSeasNoRepeat
.
size
()).
forEach
(
i
->{
WeCustomerSeas
k
=
deduplicationSeasNoRepeat
.
get
(
i
);
if
(
Objects
.
nonNull
(
k
)){
k
.
setTagIds
(
weCustomerSea
.
getTagIds
());
k
.
setTagNames
(
weCustomerSea
.
getTagNames
());
k
.
setAddUserId
(
userIds
.
get
(
Math
.
floorMod
(
i
,
userIds
.
size
())));
k
.
setAddUserName
(
userNames
.
get
(
Math
.
floorMod
(
i
,
userNames
.
size
())));
k
.
setTableExcelName
(
file
.
getOriginalFilename
());
k
.
setTableExcelId
(
tabaleExcelId
);
}
});
iWeCustomerSeasService
.
saveBatch
(
deduplicationSeasNoRepeat
);
}
else
{
return
AjaxResult
.
error
(
"导入用户数据不能为空!"
);
}
return
AjaxResult
.
success
();
}
/**
* 获取公海客户列表
* @param weCustomerSea
* @return
*/
@GetMapping
(
"list"
)
public
TableDataInfo
list
(
WeCustomerSeas
weCustomerSea
){
startPage
();
List
<
WeCustomerSeas
>
weCustomerSeas
=
iWeCustomerSeasService
.
list
(
new
LambdaQueryWrapper
<
WeCustomerSeas
>()
.
eq
(
StringUtils
.
isNotEmpty
(
weCustomerSea
.
getPhone
()),
WeCustomerSeas:
:
getPhone
,
weCustomerSea
.
getPhone
())
.
like
(
StringUtils
.
isNotEmpty
(
weCustomerSea
.
getCustomerName
()),
WeCustomerSeas:
:
getCustomerName
,
weCustomerSea
.
getCustomerName
())
.
like
(
StringUtils
.
isNotEmpty
(
weCustomerSea
.
getAddUserName
()),
WeCustomerSeas:
:
getAddUserName
,
weCustomerSea
.
getAddUserName
())
.
eq
(
weCustomerSea
.
getAddState
()
!=
null
,
WeCustomerSeas:
:
getAddState
,
weCustomerSea
.
getAddState
())
);
return
getDataTable
(
weCustomerSeas
);
}
/**
* 删除公海客户
* @param ids
* @return
*/
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
iWeCustomerSeasService
.
removeByIds
(
ListUtil
.
toList
(
ids
)
);
return
AjaxResult
.
success
();
}
/**
* 提醒员工
* @param ids
* @return
*/
@PostMapping
(
"/remidUser/{ids}"
)
public
AjaxResult
remidUser
(
@PathVariable
Long
[]
ids
){
List
<
WeCustomerSeas
>
weCustomerSeas
=
iWeCustomerSeasService
.
listByIds
(
ListUtil
.
toList
(
ids
));
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerSeas
)){
weCustomerSeas
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerSeas:
:
getAddUserId
)).
forEach
((
k
,
v
)->{
String
messageRemindContent
=
"管理员给你分配了"
+
v
.
size
()+
"个客户还未添加,快去复制电话号码添加客户吧,<a href='%s?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'>点击查看详情</a>"
;
iWeCustomerMessagePushService
.
messagePushRemind
(
messageRemindContent
,
k
);
});
}
return
AjaxResult
.
success
();
}
/**
* 获取指定员工所拥有的状态(移动端)
* @param userId
* @param addState
* @return
*/
@GetMapping
(
"/findEmployeeCustomer"
)
public
TableDataInfo
findEmployeeCustomer
(
String
userId
,
Integer
addState
){
startPage
();
List
<
WeCustomerSeas
>
weCustomerSeas
=
iWeCustomerSeasService
.
list
(
new
LambdaQueryWrapper
<
WeCustomerSeas
>()
.
eq
(
StringUtils
.
isNotEmpty
(
userId
),
WeCustomerSeas:
:
getAddUserId
,
userId
)
.
eq
(
addState
!=
null
,
WeCustomerSeas:
:
getAddState
,
addState
));
return
getDataTable
(
weCustomerSeas
);
}
/**
* 详情头部统计
* @return
*/
@GetMapping
(
"/countCustomerSeas"
)
public
AjaxResult
countCustomerSeas
(){
return
AjaxResult
.
success
(
iWeCustomerSeasService
.
countCustomerSeas
()
);
}
/**
* 导入记录或员工添加统计
* @param groupByType 1:获取导入记录数据 2:员工添加统计
* @return
*/
@GetMapping
(
"/findSeasRecord"
)
public
TableDataInfo
findSeasRecord
(
@RequestParam
(
defaultValue
=
"1"
)
Integer
groupByType
){
startPage
();
List
<
CustomerSeasRecordVo
>
seasRecord
=
iWeCustomerSeasService
.
findSeasRecord
(
groupByType
);
return
getDataTable
(
seasRecord
);
}
...
...
linkwe-common/src/main/java/com/linkwechat/common/config/RuoYiConfig.java
View file @
3f1914c
...
@@ -100,7 +100,7 @@ public class RuoYiConfig
...
@@ -100,7 +100,7 @@ public class RuoYiConfig
return
"D:/linkWeChat/uploadPath"
;
return
"D:/linkWeChat/uploadPath"
;
}
}
return
"/
linkWeChat/uploadPath
"
;
return
"/
Users/robin/work/sr_project/lw
"
;
}
}
public
void
setProfile
(
String
profile
)
public
void
setProfile
(
String
profile
)
...
...
linkwe-common/src/main/java/com/linkwechat/common/utils/poi/ExcelUtil.java
View file @
3f1914c
...
@@ -9,17 +9,11 @@ import java.lang.reflect.Field;
...
@@ -9,17 +9,11 @@ import java.lang.reflect.Field;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
...
@@ -54,6 +48,12 @@ import com.linkwechat.common.exception.CustomException;
...
@@ -54,6 +48,12 @@ import com.linkwechat.common.exception.CustomException;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DictUtils
;
import
com.linkwechat.common.utils.DictUtils
;
import
com.linkwechat.common.utils.reflect.ReflectUtils
;
import
com.linkwechat.common.utils.reflect.ReflectUtils
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ResourceLoader
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* Excel相关处理
* Excel相关处理
...
@@ -732,7 +732,8 @@ public class ExcelUtil<T>
...
@@ -732,7 +732,8 @@ public class ExcelUtil<T>
*/
*/
public
String
encodingFilename
(
String
filename
)
public
String
encodingFilename
(
String
filename
)
{
{
filename
=
UUID
.
randomUUID
().
toString
()
+
"_"
+
filename
+
".xlsx"
;
// filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
filename
=
filename
+
".xlsx"
;
return
filename
;
return
filename
;
}
}
...
@@ -933,4 +934,26 @@ public class ExcelUtil<T>
...
@@ -933,4 +934,26 @@ public class ExcelUtil<T>
}
}
return
val
;
return
val
;
}
}
public
static
void
downloadExcel
(
HttpServletResponse
httpServletResponse
,
String
fileName
)
throws
Exception
{
InputStream
inputStream
=
new
ClassPathResource
(
"/excel/seas.xlsx"
).
getInputStream
();
//设置响应类型
httpServletResponse
.
setContentType
(
"multipart/form-data;charset=utf-8"
);
httpServletResponse
.
addHeader
(
"Content-Disposition"
,
" attachment;filename="
+
new
String
(
fileName
.
getBytes
(),
"iso-8859-1"
));
if
(
Objects
.
nonNull
(
inputStream
)){
try
(
ServletOutputStream
servletOutputStream
=
httpServletResponse
.
getOutputStream
()){
IOUtils
.
copy
(
inputStream
,
servletOutputStream
);
httpServletResponse
.
flushBuffer
();
}
catch
(
Exception
e
){
log
.
error
(
"模版下载失败"
+
fileName
+
":"
+
e
.
getMessage
());
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomerSeas.java
View file @
3f1914c
...
@@ -3,6 +3,7 @@ package com.linkwechat.wecom.domain;
...
@@ -3,6 +3,7 @@ package com.linkwechat.wecom.domain;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.annotation.Excel
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -17,9 +18,11 @@ public class WeCustomerSeas extends BaseEntity {
...
@@ -17,9 +18,11 @@ public class WeCustomerSeas extends BaseEntity {
private
Long
id
;
private
Long
id
;
//手机号
//手机号
@Excel
(
name
=
"手机号"
)
private
String
phone
;
private
String
phone
;
//客户备注名称
//客户备注名称
@Excel
(
name
=
"客户名称"
)
private
String
customerName
;
private
String
customerName
;
//标签名,多个使用逗号隔开
//标签名,多个使用逗号隔开
...
@@ -45,4 +48,6 @@ public class WeCustomerSeas extends BaseEntity {
...
@@ -45,4 +48,6 @@ public class WeCustomerSeas extends BaseEntity {
@TableLogic
@TableLogic
private
Integer
delFlag
;
private
Integer
delFlag
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/CustomerSeasCountVo.java
0 → 100644
View file @
3f1914c
package
com
.
linkwechat
.
wecom
.
domain
.
vo
;
import
lombok.Data
;
/**
* 客户公海统计
*/
@Data
public
class
CustomerSeasCountVo
{
//导入客户总数
private
Integer
importCustomerTotalNum
;
//已添加客户数
private
Integer
addCustomerNum
;
//完成率
private
Float
completionRate
;
//等待添加客户数
private
Integer
waitAddCustomerNum
;
//等待通过客户数
private
Integer
waitPassCustomerNum
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/CustomerSeasRecordVo.java
0 → 100644
View file @
3f1914c
package
com
.
linkwechat
.
wecom
.
domain
.
vo
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 公海导入记录
*/
@Data
public
class
CustomerSeasRecordVo
{
//导入表格名称
private
String
tableExcelName
;
//导入客户总数
private
Integer
cutomerTotalNum
;
//导入时间
private
Date
createTime
;
//分配员工
private
String
addUserName
;
//已添加客户数
private
Integer
addCustomerNum
;
//待添加客户数
private
Integer
waitAddCustomerNum
;
//待通过客户数
private
Integer
waitPassCustomerNum
;
//添加完成率
private
Float
completionRate
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCustomerSeasMapper.java
View file @
3f1914c
...
@@ -2,6 +2,14 @@ package com.linkwechat.wecom.mapper;
...
@@ -2,6 +2,14 @@ package com.linkwechat.wecom.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasCountVo
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
WeCustomerSeasMapper
extends
BaseMapper
<
WeCustomerSeas
>
{
public
interface
WeCustomerSeasMapper
extends
BaseMapper
<
WeCustomerSeas
>
{
CustomerSeasCountVo
countCustomerSeas
();
List
<
CustomerSeasRecordVo
>
findSeasRecord
(
@Param
(
"groupByType"
)
Integer
groupByType
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerMessagePushService.java
View file @
3f1914c
...
@@ -34,4 +34,12 @@ public interface IWeCustomerMessagePushService {
...
@@ -34,4 +34,12 @@ public interface IWeCustomerMessagePushService {
*/
*/
public
List
<
CustomerMessagePushVo
>
customerMessagePushs
(
String
sender
,
String
content
,
String
pushType
,
String
beginTime
,
String
endTime
);
public
List
<
CustomerMessagePushVo
>
customerMessagePushs
(
String
sender
,
String
content
,
String
pushType
,
String
beginTime
,
String
endTime
);
/**
* 消息推送提醒
* @param messageRemindContent
* @param toUserId
*/
public
void
messagePushRemind
(
String
messageRemindContent
,
String
toUserId
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerSeasService.java
View file @
3f1914c
...
@@ -2,6 +2,16 @@ package com.linkwechat.wecom.service;
...
@@ -2,6 +2,16 @@ package com.linkwechat.wecom.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasCountVo
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
java.util.List
;
public
interface
IWeCustomerSeasService
extends
IService
<
WeCustomerSeas
>
{
public
interface
IWeCustomerSeasService
extends
IService
<
WeCustomerSeas
>
{
CustomerSeasCountVo
countCustomerSeas
();
List
<
CustomerSeasRecordVo
>
findSeasRecord
(
Integer
groupByType
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
View file @
3f1914c
...
@@ -7,19 +7,25 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -7,19 +7,25 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.domain.entity.WeCorpAccount
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.core.redis.RedisCache
;
import
com.linkwechat.common.enums.MediaType
;
import
com.linkwechat.common.enums.MediaType
;
import
com.linkwechat.common.enums.MessageType
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.client.WeCustomerMessagePushClient
;
import
com.linkwechat.wecom.client.WeMessagePushClient
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomer
;
import
com.linkwechat.wecom.domain.WeCustomerList
;
import
com.linkwechat.wecom.domain.WeCustomerList
;
import
com.linkwechat.wecom.domain.WeCustomerMessageTimeTask
;
import
com.linkwechat.wecom.domain.WeCustomerMessageTimeTask
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.dto.WeMediaDto
;
import
com.linkwechat.wecom.domain.dto.WeMediaDto
;
import
com.linkwechat.wecom.domain.dto.WeMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.ImageMessageDto
;
import
com.linkwechat.wecom.domain.dto.message.ImageMessageDto
;
import
com.linkwechat.wecom.domain.dto.message.TextMessageDto
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
com.linkwechat.wecom.domain.vo.CustomerMessagePushVo
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper
;
import
com.linkwechat.wecom.service.*
;
import
com.linkwechat.wecom.service.*
;
...
@@ -31,10 +37,7 @@ import org.springframework.stereotype.Service;
...
@@ -31,10 +37,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -82,6 +85,13 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
...
@@ -82,6 +85,13 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Autowired
@Autowired
private
IWeMaterialService
materialService
;
private
IWeMaterialService
materialService
;
@Autowired
private
IWeCorpAccountService
weCorpAccountService
;
@Autowired
private
WeMessagePushClient
weMessagePushClient
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addWeCustomerMessagePush
(
CustomerMessagePushDto
customerMessagePushDto
)
throws
JsonProcessingException
,
ParseException
,
CloneNotSupportedException
{
public
void
addWeCustomerMessagePush
(
CustomerMessagePushDto
customerMessagePushDto
)
throws
JsonProcessingException
,
ParseException
,
CloneNotSupportedException
{
...
@@ -192,6 +202,8 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
...
@@ -192,6 +202,8 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
return
weCustomerMessageOriginalService
.
customerMessagePushs
(
sender
,
content
,
pushType
,
beginTime
,
endTime
);
return
weCustomerMessageOriginalService
.
customerMessagePushs
(
sender
,
content
,
pushType
,
beginTime
,
endTime
);
}
}
/**
/**
* 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户
* 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户
*
*
...
@@ -251,4 +263,29 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
...
@@ -251,4 +263,29 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
}
}
}
}
/**
* 员工推送文字消息
* @param messageRemindContent
* @param toUserId
*/
@Override
public
void
messagePushRemind
(
String
messageRemindContent
,
String
toUserId
)
{
WeCorpAccount
validWeCorpAccount
=
weCorpAccountService
.
findValidWeCorpAccount
();
if
(
null
!=
weCorpAccountService
){
if
(
StringUtils
.
isNotEmpty
(
validWeCorpAccount
.
getAgentId
())&&
StringUtils
.
isNotEmpty
(
validWeCorpAccount
.
getAgentSecret
())){
TextMessageDto
textMessageDto
=
new
TextMessageDto
();
textMessageDto
.
setContent
(
messageRemindContent
);
WeMessagePushDto
weMessagePushDto
=
new
WeMessagePushDto
();
weMessagePushDto
.
setMsgtype
(
MessageType
.
TEXT
.
getMessageType
());
weMessagePushDto
.
setTouser
(
toUserId
);
weMessagePushDto
.
setText
(
textMessageDto
);
weMessagePushDto
.
setAgentid
(
Integer
.
valueOf
(
validWeCorpAccount
.
getAgentId
()));
weMessagePushClient
.
sendMessageToUser
(
weMessagePushDto
,
weMessagePushDto
.
getAgentid
().
toString
());
}
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerSeasServiceImpl.java
View file @
3f1914c
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.WeCustomerSeas
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasCountVo
;
import
com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo
;
import
com.linkwechat.wecom.mapper.WeCustomerSeasMapper
;
import
com.linkwechat.wecom.mapper.WeCustomerSeasMapper
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
com.linkwechat.wecom.service.IWeCustomerSeasService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
@Service
@Service
public
class
WeCustomerSeasServiceImpl
extends
ServiceImpl
<
WeCustomerSeasMapper
,
WeCustomerSeas
>
implements
IWeCustomerSeasService
{
public
class
WeCustomerSeasServiceImpl
extends
ServiceImpl
<
WeCustomerSeasMapper
,
WeCustomerSeas
>
implements
IWeCustomerSeasService
{
@Override
public
CustomerSeasCountVo
countCustomerSeas
()
{
return
this
.
baseMapper
.
countCustomerSeas
();
}
@Override
public
List
<
CustomerSeasRecordVo
>
findSeasRecord
(
Integer
groupByType
)
{
return
this
.
baseMapper
.
findSeasRecord
(
groupByType
);
}
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerSeasMapper.xml
View file @
3f1914c
...
@@ -5,5 +5,41 @@
...
@@ -5,5 +5,41 @@
<mapper
namespace=
"com.linkwechat.wecom.mapper.WeCustomerSeasMapper"
>
<mapper
namespace=
"com.linkwechat.wecom.mapper.WeCustomerSeasMapper"
>
<select
id=
"countCustomerSeas"
resultType=
"com.linkwechat.wecom.domain.vo.CustomerSeasCountVo"
>
SELECT
COUNT(*) AS importCustomerTotalNum,
COUNT(IF(add_state=1,true,NULL)) AS addCustomerNum,
IFNULL(ROUND(COUNT(IF(add_state=1,true,NULL))/COUNT(*)*100,2),0) AS completionRate,
COUNT(IF(add_state=0,true,NULL)) AS waitAddCustomerNum,
COUNT(IF(add_state=3,true,NULL)) AS waitPassCustomerNum
FROM
we_customer_seas
</select>
<select
id=
"findSeasRecord"
resultType=
"com.linkwechat.wecom.domain.vo.CustomerSeasRecordVo"
>
SELECT
table_excel_name,
count(*) as cutomerTotalNum,
create_time,
GROUP_CONCAT(DISTINCT add_user_name) as addUserName,
COUNT(IF(add_state=1,true,NULL)) AS addCustomerNum,
COUNT(IF(add_state=0,true,NULL)) AS waitAddCustomerNum,
COUNT(IF(add_state=3,true,NULL)) AS waitPassCustomerNum,
IFNULL(ROUND(COUNT(IF(add_state=1,true,NULL))/COUNT(*)*100,2),0) AS completionRate
FROM
we_customer_seas
GROUP BY
<choose>
<when
test=
"groupByType==1"
>
table_excel_id
</when>
<otherwise>
add_user_id
</otherwise>
</choose>
ORDER BY create_time DESC
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
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