Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
eb397968
Commit
eb397968
authored
Feb 11, 2020
by
桂前礼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
唤醒机制非回复缄默时长设置自我激活功能
parent
a135106a
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1156 additions
and
3 deletions
+1156
-3
PcloudRobotWakeUpService.java
...m/pcloud/book/guide/service/PcloudRobotWakeUpService.java
+19
-0
ClassifyInfoVO.java
...rc/main/java/com/pcloud/book/guide/vo/ClassifyInfoVO.java
+17
-0
RobotWakeUpConfigVO.java
...in/java/com/pcloud/book/guide/vo/RobotWakeUpConfigVO.java
+31
-0
RobotWakeUpMsgVO.java
.../main/java/com/pcloud/book/guide/vo/RobotWakeUpMsgVO.java
+32
-0
RobotWakeUpShowVO.java
...main/java/com/pcloud/book/guide/vo/RobotWakeUpShowVO.java
+32
-0
PcloudRobotWakeUpBiz.java
.../java/com/pcloud/book/guide/biz/PcloudRobotWakeUpBiz.java
+21
-0
PcloudRobotWakeUpBizImpl.java
.../pcloud/book/guide/biz/impl/PcloudRobotWakeUpBizImpl.java
+278
-0
PcloudGuideRedisConstant.java
.../pcloud/book/guide/constant/PcloudGuideRedisConstant.java
+3
-0
WakeUpInfoDto.java
...rc/main/java/com/pcloud/book/guide/dto/WakeUpInfoDto.java
+11
-0
PcloudRobotWakeup.java
.../java/com/pcloud/book/guide/entity/PcloudRobotWakeup.java
+71
-0
PcloudWakeupMessage.java
...ava/com/pcloud/book/guide/entity/PcloudWakeupMessage.java
+100
-0
PcloudRobotWakeUpFacadeImpl.java
...d/book/guide/facade/impl/PcloudRobotWakeUpFacadeImpl.java
+59
-0
PcloudRobotWakeupMapper.java
...com/pcloud/book/guide/mapper/PcloudRobotWakeupMapper.java
+32
-0
PcloudWakeupMessageMapper.java
...m/pcloud/book/guide/mapper/PcloudWakeupMessageMapper.java
+32
-0
PcloudRobotWakeUpServiceImpl.java
...loud/book/guide/service/PcloudRobotWakeUpServiceImpl.java
+51
-0
WxGroupSendTextListener.java
...ava/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
+27
-0
PcloudRobotDao.java
...ava/com/pcloud/book/pcloudkeyword/dao/PcloudRobotDao.java
+6
-0
PcloudRobotDaoImpl.java
...cloud/book/pcloudkeyword/dao/impl/PcloudRobotDaoImpl.java
+12
-0
PcloudRobot.java
...ava/com/pcloud/book/pcloudkeyword/entity/PcloudRobot.java
+3
-0
PcloudRobotWakeupMapper.xml
...c/main/resources/mapper/guide/PcloudRobotWakeupMapper.xml
+132
-0
PcloudWakeupMessageMapper.xml
...main/resources/mapper/guide/PcloudWakeupMessageMapper.xml
+166
-0
PcloudRobot.Mapper.xml
...ain/resources/mapper/pcloudkeyword/PcloudRobot.Mapper.xml
+21
-3
No files found.
pcloud-facade-book/src/main/java/com/pcloud/book/guide/service/PcloudRobotWakeUpService.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
service
;
import
com.pcloud.common.exceptions.BizException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.Map
;
@FeignClient
(
value
=
"pcloud-service-book"
,
qualifier
=
"pcloudRobotWakeUpServiceCloud"
,
path
=
"book/v1.0/pcloudRobotWakeUpService"
)
@Api
(
description
=
"机器人自动唤醒内部服务"
)
public
interface
PcloudRobotWakeUpService
{
@ApiOperation
(
"定时任务"
)
@PostMapping
(
"/doJob"
)
void
doJob
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
BizException
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/guide/vo/ClassifyInfoVO.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@ApiModel
(
description
=
"分类信息"
)
@Data
public
class
ClassifyInfoVO
{
@ApiModelProperty
(
"分类id"
)
private
Integer
classifyId
;
@ApiModelProperty
(
"分类名称"
)
private
String
classifyName
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/guide/vo/RobotWakeUpConfigVO.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
@Data
@ApiModel
(
description
=
"机器人唤醒配置"
)
public
class
RobotWakeUpConfigVO
{
@ApiModelProperty
(
"开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startTime
;
@ApiModelProperty
(
"间隔时间 单位小时"
)
private
Integer
cycle
;
@ApiModelProperty
(
"静默时长"
)
private
Integer
lastDay
;
@ApiModelProperty
(
"分类ID列表"
)
private
List
<
Integer
>
classifyList
;
@ApiModelProperty
(
"回复消息列表"
)
private
List
<
RobotWakeUpMsgVO
>
msgVOList
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/guide/vo/RobotWakeUpMsgVO.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
@ApiModel
(
description
=
"机器人唤醒 消息配置"
)
public
class
RobotWakeUpMsgVO
{
private
Integer
id
;
@ApiModelProperty
(
"消息类型 text image file"
)
private
Integer
replyType
;
@ApiModelProperty
(
"文本内容"
)
private
String
content
;
@ApiModelProperty
(
"图片地址"
)
private
String
picUrl
;
@ApiModelProperty
(
"文件地址"
)
private
String
fileUrl
;
@ApiModelProperty
(
"排序值"
)
private
Integer
seqNum
;
private
String
size
;
private
String
resourceTypeCode
;
}
pcloud-facade-book/src/main/java/com/pcloud/book/guide/vo/RobotWakeUpShowVO.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
@ApiModel
(
description
=
"机器人小号唤醒配置信息"
)
@Data
public
class
RobotWakeUpShowVO
{
@ApiModelProperty
(
"开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startTime
;
@ApiModelProperty
(
"间隔时间 单位小时"
)
private
Integer
cycle
;
@ApiModelProperty
(
"静默时长"
)
private
Integer
lastDay
;
@ApiModelProperty
(
"分类ID列表"
)
private
List
<
Integer
>
classifyList
;
@ApiModelProperty
(
"回复消息列表"
)
private
List
<
RobotWakeUpMsgVO
>
msgList
;
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/biz/PcloudRobotWakeUpBiz.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
biz
;
import
com.pcloud.book.guide.vo.RobotWakeUpConfigVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpShowVO
;
import
com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO
;
import
java.util.List
;
public
interface
PcloudRobotWakeUpBiz
{
void
robotWakeUpConfig
(
RobotWakeUpConfigVO
robotWakeUpConfigVO
);
void
robotWakeUpRemove
();
RobotWakeUpShowVO
getRobotWakeUpConfig
();
void
doJob
();
List
<
PcloudRobotClassifyResponseVO
>
listAllClassify
();
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/biz/impl/PcloudRobotWakeUpBizImpl.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
biz
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pcloud.book.base.exception.BookBizException
;
import
com.pcloud.book.guide.biz.PcloudRobotWakeUpBiz
;
import
com.pcloud.book.guide.dto.WakeUpInfoDto
;
import
com.pcloud.book.guide.entity.PcloudRobotWakeup
;
import
com.pcloud.book.guide.entity.PcloudWakeupMessage
;
import
com.pcloud.book.guide.mapper.PcloudRobotWakeupMapper
;
import
com.pcloud.book.guide.mapper.PcloudWakeupMessageMapper
;
import
com.pcloud.book.guide.vo.ClassifyInfoVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpConfigVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpMsgVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpShowVO
;
import
com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao
;
import
com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.facade.quartz.entity.CallBackParam
;
import
com.pcloud.facade.quartz.entity.ScheduleJob
;
import
com.pcloud.facade.quartz.service.ScheduleService
;
import
com.sdk.wxgroup.SendFileVO
;
import
com.sdk.wxgroup.SendPicMessageVO
;
import
com.sdk.wxgroup.SendTextMessageVO
;
import
com.sdk.wxgroup.WxGroupSDK
;
import
lombok.extern.slf4j.Slf4j
;
import
org.codehaus.jackson.JsonParseException
;
import
org.quartz.SchedulerException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.*
;
import
static
com
.
pcloud
.
book
.
guide
.
constant
.
PcloudGuideRedisConstant
.
PCLOUD_ROBOT_WAKE_UP_SUFFIX
;
import
static
com
.
pcloud
.
book
.
guide
.
constant
.
PcloudGuideRedisConstant
.
PCLOUD_WAKE_UP_CRON_JOB
;
@Component
(
"pcloudRobotWakeUpBiz"
)
@Slf4j
public
class
PcloudRobotWakeUpBizImpl
implements
PcloudRobotWakeUpBiz
{
@Autowired
private
PcloudRobotWakeupMapper
pcloudRobotWakeupMapper
;
@Autowired
private
PcloudRobotDao
pcloudRobotDao
;
@Autowired
private
PcloudWakeupMessageMapper
pcloudWakeupMessageMapper
;
@Autowired
private
ScheduleService
scheduleService
;
@Override
public
void
robotWakeUpConfig
(
RobotWakeUpConfigVO
robotWakeUpConfigVO
)
{
Integer
cycle
=
robotWakeUpConfigVO
.
getCycle
();
if
(
cycle
==
null
||
cycle
<
1
)
{
cycle
=
1
;
}
Integer
lastDay
=
robotWakeUpConfigVO
.
getLastDay
();
if
(
lastDay
==
1
)
{
lastDay
=
3
;
}
else
if
(
lastDay
==
2
)
{
lastDay
=
7
;
}
else
if
(
lastDay
==
3
)
{
lastDay
=
DateUtils
.
getDayOfMonth
(
new
Date
());
}
PcloudRobotWakeup
pcloudRobotWakeup
=
new
PcloudRobotWakeup
();
pcloudRobotWakeup
.
setCreateTime
(
new
Date
());
pcloudRobotWakeup
.
setCycle
(
cycle
);
pcloudRobotWakeup
.
setLast
(
lastDay
);
pcloudRobotWakeup
.
setStartTime
(
new
Date
());
pcloudRobotWakeupMapper
.
insertSelective
(
pcloudRobotWakeup
);
List
<
Integer
>
classifyList
=
robotWakeUpConfigVO
.
getClassifyList
();
pcloudRobotDao
.
updateWakeUpByClassifyIds
(
classifyList
);
List
<
RobotWakeUpMsgVO
>
list
=
robotWakeUpConfigVO
.
getMsgVOList
();
if
(
list
.
size
()
>
3
)
{
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_ERROR
,
"最多配置三条消息"
);
}
for
(
RobotWakeUpMsgVO
robotWakeUpMsgVO
:
list
)
{
PcloudWakeupMessage
pcloudWakeupMessage
=
new
PcloudWakeupMessage
();
pcloudWakeupMessage
.
setCreateTime
(
new
Date
());
if
(
robotWakeUpMsgVO
.
getReplyType
()
==
1
)
{
pcloudWakeupMessage
.
setType
(
"text"
);
pcloudWakeupMessage
.
setTextContent
(
robotWakeUpMsgVO
.
getContent
());
}
else
if
(
robotWakeUpMsgVO
.
getReplyType
()
==
2
)
{
pcloudWakeupMessage
.
setType
(
"image"
);
pcloudWakeupMessage
.
setImgUrl
(
robotWakeUpMsgVO
.
getPicUrl
());
}
else
if
(
robotWakeUpMsgVO
.
getReplyType
()
==
5
)
{
String
code
=
StringUtil
.
isEmpty
(
robotWakeUpMsgVO
.
getResourceTypeCode
())?
" "
:
robotWakeUpMsgVO
.
getResourceTypeCode
();
String
size
=
StringUtil
.
isEmpty
(
robotWakeUpMsgVO
.
getSize
())?
" "
:
robotWakeUpMsgVO
.
getSize
();
List
<
String
>
infos
=
new
ArrayList
<>();
infos
.
add
(
code
);
infos
.
add
(
size
);
pcloudWakeupMessage
.
setType
(
"file"
);
pcloudWakeupMessage
.
setTextContent
(
JSONObject
.
toJSONString
(
infos
));
pcloudWakeupMessage
.
setFileUrl
(
robotWakeUpMsgVO
.
getFileUrl
());
pcloudWakeupMessage
.
setFileName
(
robotWakeUpMsgVO
.
getContent
());
}
pcloudWakeupMessage
.
setSeqNum
(
robotWakeUpMsgVO
.
getSeqNum
());
pcloudWakeupMessage
.
setId
(
null
);
pcloudWakeupMessageMapper
.
insertSelective
(
pcloudWakeupMessage
);
}
String
cron
=
"0 0 0/$ * * ? "
;
cron
=
cron
.
replace
(
"$"
,
String
.
valueOf
(
cycle
));
createCronJob
(
cron
);
}
private
void
createCronJob
(
String
cronStr
)
{
try
{
scheduleService
.
deleteJob
(
PCLOUD_WAKE_UP_CRON_JOB
,
"book"
);
ScheduleJob
job
=
new
ScheduleJob
();
//定时器任务
job
.
setJobName
(
PCLOUD_WAKE_UP_CRON_JOB
);
//cron表达式
job
.
setCronExpression
(
cronStr
);
//定时器分组
job
.
setJobGroup
(
"book"
);
CallBackParam
param
=
new
CallBackParam
();
//service名称
param
.
setBeanName
(
"pcloudRobotWakeUpService"
);
//回调内部接口方法名称
param
.
setMethodName
(
"doJob"
);
//设置回调参数
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"jobName"
,
PCLOUD_WAKE_UP_CRON_JOB
);
param
.
setParamMap
(
map
);
Map
<
String
,
Object
>
scheduleMap
=
new
HashMap
<>();
scheduleMap
.
put
(
"scheduleJob"
,
job
);
scheduleMap
.
put
(
"callBackParam"
,
param
);
scheduleService
.
addCronJob
(
scheduleMap
);
}
catch
(
SchedulerException
|
JsonParseException
e
)
{
log
.
info
(
"【PcloudRobotWakeUpBizImpl.createCronJob】创建定时任务失败"
,
e
);
}
}
@Override
public
void
robotWakeUpRemove
()
{
pcloudRobotWakeupMapper
.
deleteAll
();
pcloudWakeupMessageMapper
.
deleteAll
();
pcloudRobotDao
.
clearWakeUp
();
try
{
scheduleService
.
deleteJob
(
PCLOUD_WAKE_UP_CRON_JOB
,
"book"
);
}
catch
(
SchedulerException
|
JsonParseException
e
)
{
log
.
info
(
"【PcloudRobotWakeUpBizImpl.robotWakeUpRemove】删除定时任务失败"
,
e
);
}
}
@Override
public
RobotWakeUpShowVO
getRobotWakeUpConfig
()
{
RobotWakeUpShowVO
robotWakeUpShowVO
=
new
RobotWakeUpShowVO
();
// 配置信息
PcloudRobotWakeup
pcloudRobotWakeup
=
pcloudRobotWakeupMapper
.
selectOne
();
if
(
pcloudRobotWakeup
==
null
)
{
return
robotWakeUpShowVO
;
}
robotWakeUpShowVO
.
setCycle
(
pcloudRobotWakeup
.
getCycle
());
Integer
last
=
pcloudRobotWakeup
.
getLast
();
if
(
last
==
3
)
{
last
=
1
;
}
else
if
(
last
==
7
)
{
last
=
2
;
}
else
{
last
=
3
;
}
robotWakeUpShowVO
.
setLastDay
(
last
);
robotWakeUpShowVO
.
setStartTime
(
pcloudRobotWakeup
.
getStartTime
());
// 分类信息
List
<
Integer
>
classifyInfoVOList
=
pcloudWakeupMessageMapper
.
getAllClassifyInfo
();
robotWakeUpShowVO
.
setClassifyList
(
classifyInfoVOList
);
// 消息列表
List
<
PcloudWakeupMessage
>
list
=
pcloudWakeupMessageMapper
.
selectAll
();
List
<
RobotWakeUpMsgVO
>
robotWakeUpMsgVOList
=
new
ArrayList
<>();
for
(
PcloudWakeupMessage
pcloudWakeupMessage
:
list
)
{
RobotWakeUpMsgVO
robotWakeUpMsgVO
=
new
RobotWakeUpMsgVO
();
robotWakeUpMsgVO
.
setSeqNum
(
pcloudWakeupMessage
.
getSeqNum
());
robotWakeUpMsgVO
.
setId
(
pcloudWakeupMessage
.
getId
());
if
(
"text"
.
equals
(
pcloudWakeupMessage
.
getType
()))
{
robotWakeUpMsgVO
.
setReplyType
(
1
);
robotWakeUpMsgVO
.
setContent
(
pcloudWakeupMessage
.
getTextContent
());
}
else
if
(
"image"
.
equals
(
pcloudWakeupMessage
.
getType
()))
{
robotWakeUpMsgVO
.
setReplyType
(
2
);
robotWakeUpMsgVO
.
setPicUrl
(
pcloudWakeupMessage
.
getImgUrl
());
}
else
if
(
"file"
.
equals
(
pcloudWakeupMessage
.
getType
()))
{
List
<
String
>
array
=
JSONObject
.
parseArray
(
pcloudWakeupMessage
.
getTextContent
(),
String
.
class
);
if
(
array
.
size
()>
1
){
robotWakeUpMsgVO
.
setResourceTypeCode
(
array
.
get
(
0
));
robotWakeUpMsgVO
.
setSize
(
array
.
get
(
1
));
}
robotWakeUpMsgVO
.
setReplyType
(
5
);
robotWakeUpMsgVO
.
setContent
(
pcloudWakeupMessage
.
getFileName
());
robotWakeUpMsgVO
.
setFileUrl
(
pcloudWakeupMessage
.
getFileUrl
());
}
robotWakeUpMsgVOList
.
add
(
robotWakeUpMsgVO
);
}
robotWakeUpShowVO
.
setMsgList
(
robotWakeUpMsgVOList
);
return
robotWakeUpShowVO
;
}
@Override
public
void
doJob
()
{
// 1. 查询所有开启自动提醒的小号
List
<
String
>
allRobot
=
pcloudRobotWakeupMapper
.
listAllRobot
();
// 2. 查询提醒时间
PcloudRobotWakeup
pcloudRobotWakeup
=
pcloudRobotWakeupMapper
.
selectOne
();
if
(
pcloudRobotWakeup
==
null
||
pcloudRobotWakeup
.
getLast
()
==
null
)
{
return
;
}
List
<
PcloudWakeupMessage
>
list
=
pcloudWakeupMessageMapper
.
selectAll
();
if
(
ListUtils
.
isEmpty
(
list
))
{
return
;
}
log
.
info
(
"[开始自动唤醒 推送消息] msg: {}"
,
JSONObject
.
toJSONString
(
list
));
for
(
String
robot
:
allRobot
)
{
Map
<
String
,
String
>
userInfo
=
JedisClusterUtils
.
hgetAll
(
robot
+
PCLOUD_ROBOT_WAKE_UP_SUFFIX
);
if
(
userInfo
.
isEmpty
())
{
return
;
}
Set
<
String
>
wxids
=
userInfo
.
keySet
();
if
(
wxids
.
isEmpty
())
{
return
;
}
for
(
String
wxid
:
wxids
)
{
WakeUpInfoDto
dto
=
JSONObject
.
parseObject
(
userInfo
.
get
(
wxid
),
WakeUpInfoDto
.
class
);
Date
date
=
dto
.
getTime
();
String
ip
=
dto
.
getIp
();
if
(
DateUtils
.
getDateDiff
(
date
,
new
Date
())
>
pcloudRobotWakeup
.
getLast
())
{
for
(
PcloudWakeupMessage
msg
:
list
)
{
if
(
"text"
.
equals
(
msg
.
getType
()))
{
SendTextMessageVO
txt
=
new
SendTextMessageVO
();
txt
.
setAltId
(
robot
);
txt
.
setContent
(
msg
.
getTextContent
());
txt
.
setWxGroupId
(
wxid
);
txt
.
setIp
(
ip
);
WxGroupSDK
.
sendTextMessage
(
txt
);
}
if
(
"image"
.
equals
(
msg
.
getType
()))
{
SendPicMessageVO
pic
=
new
SendPicMessageVO
();
pic
.
setAltId
(
robot
);
pic
.
setPicUrl
(
msg
.
getImgUrl
());
pic
.
setWxId
(
wxid
);
pic
.
setWxGroupId
(
wxid
);
pic
.
setIp
(
ip
);
WxGroupSDK
.
sendPicMessage
(
pic
);
}
if
(
"file"
.
equals
(
msg
.
getType
()))
{
SendFileVO
file
=
new
SendFileVO
();
file
.
setAltId
(
robot
);
file
.
setFileUrl
(
msg
.
getFileUrl
());
file
.
setFileName
(
msg
.
getFileName
());
pic
.
setWxId
(
wxid
);
file
.
setWxGroupId
(
wxid
);
file
.
setIp
(
ip
);
WxGroupSDK
.
sendFile
(
file
);
}
}
}
}
}
}
@Override
public
List
<
PcloudRobotClassifyResponseVO
>
listAllClassify
()
{
return
pcloudRobotWakeupMapper
.
listAllClassify
();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/constant/PcloudGuideRedisConstant.java
View file @
eb397968
...
...
@@ -10,4 +10,7 @@ public class PcloudGuideRedisConstant {
public
static
final
String
PCLOUD_GUIDE_LOCK
=
"PCLOUD_GUIDE_SILENCE_RUNNER_IMPL_LOCK"
;
public
static
final
String
PCLOUD_ROBOT_WAKE_UP_SUFFIX
=
"_PCLOUD_ROBOT_WAKE_UP_SUFFIX"
;
public
static
final
String
PCLOUD_WAKE_UP_CRON_JOB
=
"PCLOUD_WAKE_UP_CRON_JOB_SUFFIX"
;
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/dto/WakeUpInfoDto.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
dto
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
WakeUpInfoDto
{
private
String
ip
;
private
Date
time
;
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/entity/PcloudRobotWakeup.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.util.Date
;
public
class
PcloudRobotWakeup
{
private
Integer
id
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
startTime
;
private
Integer
cycle
;
private
Integer
last
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
updateTime
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
Date
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
Date
startTime
)
{
this
.
startTime
=
startTime
;
}
public
Integer
getCycle
()
{
return
cycle
;
}
public
void
setCycle
(
Integer
cycle
)
{
this
.
cycle
=
cycle
;
}
public
Integer
getLast
()
{
return
last
;
}
public
void
setLast
(
Integer
last
)
{
this
.
last
=
last
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/guide/entity/PcloudWakeupMessage.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
entity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.util.Date
;
public
class
PcloudWakeupMessage
{
private
Integer
id
;
private
String
type
;
private
String
textContent
;
private
String
imgUrl
;
private
String
fileUrl
;
private
String
fileName
;
private
Integer
seqNum
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
updateTime
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
==
null
?
null
:
type
.
trim
();
}
public
String
getTextContent
()
{
return
textContent
;
}
public
void
setTextContent
(
String
textContent
)
{
this
.
textContent
=
textContent
==
null
?
null
:
textContent
.
trim
();
}
public
String
getImgUrl
()
{
return
imgUrl
;
}
public
void
setImgUrl
(
String
imgUrl
)
{
this
.
imgUrl
=
imgUrl
==
null
?
null
:
imgUrl
.
trim
();
}
public
String
getFileUrl
()
{
return
fileUrl
;
}
public
void
setFileUrl
(
String
fileUrl
)
{
this
.
fileUrl
=
fileUrl
==
null
?
null
:
fileUrl
.
trim
();
}
public
String
getFileName
()
{
return
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
==
null
?
null
:
fileName
.
trim
();
}
public
Integer
getSeqNum
()
{
return
seqNum
;
}
public
void
setSeqNum
(
Integer
seqNum
)
{
this
.
seqNum
=
seqNum
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/guide/facade/impl/PcloudRobotWakeUpFacadeImpl.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
facade
.
impl
;
import
com.pcloud.book.guide.biz.PcloudRobotWakeUpBiz
;
import
com.pcloud.book.guide.vo.RobotWakeUpConfigVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpShowVO
;
import
com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz
;
import
com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.permission.PermissionException
;
import
com.pcloud.common.utils.SessionUtil
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@RestController
@RequestMapping
(
"robotWakeUp"
)
public
class
PcloudRobotWakeUpFacadeImpl
{
@Autowired
private
PcloudRobotWakeUpBiz
pcloudRobotWakeUpBiz
;
@Autowired
private
PcloudRobotClassifyBiz
pcloudRobotClassifyBiz
;
@ApiOperation
(
value
=
"机器人小号唤醒配置"
)
@PostMapping
(
"config"
)
ResponseDto
<?>
robotWakeUpConfig
(
@RequestHeader
String
token
,
@RequestBody
RobotWakeUpConfigVO
robotWakeUpConfigVO
)
throws
PermissionException
{
SessionUtil
.
getToken4Redis
(
token
);
pcloudRobotWakeUpBiz
.
robotWakeUpConfig
(
robotWakeUpConfigVO
);
return
new
ResponseDto
<>();
}
@ApiOperation
(
value
=
"解除机器人小号唤醒配置"
)
@PostMapping
(
"remove"
)
ResponseDto
<?>
robotWakeUpClose
(
@RequestHeader
String
token
)
throws
PermissionException
{
SessionUtil
.
getToken4Redis
(
token
);
pcloudRobotWakeUpBiz
.
robotWakeUpRemove
();
return
new
ResponseDto
<>();
}
@ApiOperation
(
value
=
"获取机器人小号配置"
)
@GetMapping
(
"get"
)
ResponseDto
<?>
getRobotWakeUpConfig
(
@RequestHeader
String
token
)
throws
PermissionException
{
SessionUtil
.
getToken4Redis
(
token
);
return
new
ResponseDto
<>(
pcloudRobotWakeUpBiz
.
getRobotWakeUpConfig
());
}
@ApiOperation
(
value
=
"平台端获取所有的个人号分类"
)
@GetMapping
(
"listClassify"
)
ResponseDto
<
List
<
PcloudRobotClassifyResponseVO
>>
listClassify
(
@RequestHeader
String
token
)
throws
PermissionException
{
SessionUtil
.
getToken4Redis
(
token
);
List
<
PcloudRobotClassifyResponseVO
>
classify
=
pcloudRobotWakeUpBiz
.
listAllClassify
();
return
new
ResponseDto
<>(
classify
);
}
}
pcloud-service-book/src/main/java/com/pcloud/book/guide/mapper/PcloudRobotWakeupMapper.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
mapper
;
import
com.pcloud.book.guide.entity.PcloudRobotWakeup
;
import
com.pcloud.book.guide.vo.RobotWakeUpShowVO
;
import
com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
public
interface
PcloudRobotWakeupMapper
{
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
PcloudRobotWakeup
record
);
int
insertSelective
(
PcloudRobotWakeup
record
);
PcloudRobotWakeup
selectByPrimaryKey
(
Integer
id
);
int
updateByPrimaryKeySelective
(
PcloudRobotWakeup
record
);
int
updateByPrimaryKey
(
PcloudRobotWakeup
record
);
void
deleteAll
();
PcloudRobotWakeup
selectOne
();
List
<
String
>
listAllRobot
();
List
<
PcloudRobotClassifyResponseVO
>
listAllClassify
();
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/guide/mapper/PcloudWakeupMessageMapper.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
mapper
;
import
com.pcloud.book.guide.entity.PcloudWakeupMessage
;
import
com.pcloud.book.guide.vo.ClassifyInfoVO
;
import
com.pcloud.book.guide.vo.RobotWakeUpMsgVO
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
public
interface
PcloudWakeupMessageMapper
{
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
PcloudWakeupMessage
record
);
int
insertSelective
(
PcloudWakeupMessage
record
);
PcloudWakeupMessage
selectByPrimaryKey
(
Integer
id
);
int
updateByPrimaryKeySelective
(
PcloudWakeupMessage
record
);
int
updateByPrimaryKey
(
PcloudWakeupMessage
record
);
void
deleteAll
();
List
<
PcloudWakeupMessage
>
selectAll
();
List
<
Integer
>
getAllClassifyInfo
();
Integer
countAll
();
}
\ No newline at end of file
pcloud-service-book/src/main/java/com/pcloud/book/guide/service/PcloudRobotWakeUpServiceImpl.java
0 → 100644
View file @
eb397968
package
com
.
pcloud
.
book
.
guide
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pcloud.book.guide.biz.PcloudRobotWakeUpBiz
;
import
com.pcloud.book.guide.dto.WakeUpInfoDto
;
import
com.pcloud.book.guide.service.PcloudRobotWakeUpService
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.cache.redis.JedisClusterUtils
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.Map
;
import
static
com
.
pcloud
.
book
.
guide
.
constant
.
PcloudGuideRedisConstant
.
PCLOUD_ROBOT_WAKE_UP_SUFFIX
;
@RestController
@RequestMapping
(
"pcloudRobotWakeUpService"
)
@Slf4j
public
class
PcloudRobotWakeUpServiceImpl
implements
PcloudRobotWakeUpService
{
@Autowired
private
PcloudRobotWakeUpBiz
pcloudRobotWakeUpBiz
;
@ApiOperation
(
"定时任务执行方法"
)
@PostMapping
(
"/doJob"
)
public
void
doJob
(
@RequestBody
Map
<
String
,
Object
>
map
)
throws
BizException
{
log
.
info
(
"PcloudRobotWakeUpServiceImpl.doJob 开始执行定时任务"
);
pcloudRobotWakeUpBiz
.
doJob
();
}
@ApiOperation
(
"手动自动唤醒设置缓存"
)
@GetMapping
(
"/hset"
)
public
ResponseDto
<?>
hset
(
@RequestParam
(
"wxid"
)
String
wxid
,
@RequestParam
(
"robotId"
)
String
robotId
,
@RequestParam
(
"ip"
)
String
ip
,
@RequestParam
(
"day"
)
Integer
day
){
WakeUpInfoDto
wakeUpInfoDto
=
new
WakeUpInfoDto
();
wakeUpInfoDto
.
setIp
(
ip
);
wakeUpInfoDto
.
setTime
(
DateUtils
.
addDay
(
new
Date
(),
day
));
JedisClusterUtils
.
hset
(
robotId
+
PCLOUD_ROBOT_WAKE_UP_SUFFIX
,
wxid
,
JSONObject
.
toJSONString
(
wakeUpInfoDto
));
return
new
ResponseDto
<>();
}
}
pcloud-service-book/src/main/java/com/pcloud/book/mq/topic/WxGroupSendTextListener.java
View file @
eb397968
...
...
@@ -5,9 +5,12 @@ import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import
com.pcloud.book.group.biz.BookGroupClassifyBiz
;
import
com.pcloud.book.group.dto.GroupClassifyQrcodeDTO
;
import
com.pcloud.book.guide.dto.PcloudGuideDelayDto
;
import
com.pcloud.book.guide.dto.WakeUpInfoDto
;
import
com.pcloud.book.guide.mapper.PcloudRobotSilenceMapper
;
import
com.pcloud.book.keywords.biz.BookKeywordBiz
;
import
com.pcloud.book.mq.config.MQTopicConumer
;
import
com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao
;
import
com.pcloud.book.pcloudkeyword.entity.PcloudRobot
;
import
com.pcloud.book.reading.biz.ReadingActivityBiz
;
import
com.pcloud.book.riddle.biz.RiddleRecordBiz
;
import
com.pcloud.book.util.common.ThreadPoolUtils
;
...
...
@@ -31,6 +34,7 @@ import java.util.Date;
import
java.util.List
;
import
static
com
.
pcloud
.
book
.
guide
.
constant
.
PcloudGuideRedisConstant
.
PCLOUD_GUIDE_SUFFIX
;
import
static
com
.
pcloud
.
book
.
guide
.
constant
.
PcloudGuideRedisConstant
.
PCLOUD_ROBOT_WAKE_UP_SUFFIX
;
/**
* @author lily
...
...
@@ -56,6 +60,8 @@ public class WxGroupSendTextListener {
private
ReadingActivityBiz
readingActivityBiz
;
@Autowired
private
PcloudRobotSilenceMapper
pcloudRobotSilenceMapper
;
@Autowired
private
PcloudRobotDao
pcloudRobotDao
;
/**
* 接收微信用户进群消息
...
...
@@ -71,6 +77,8 @@ public class WxGroupSendTextListener {
changeGroupInfo
(
sendTextDTO
);
// 缄默设置处理
silenceProcess
(
sendTextDTO
);
// 机器人自动唤醒
robotWakeUp
(
sendTextDTO
);
//校验是否机器人账号
List
<
String
>
allRobotWxIds
=
wechatGroupConsr
.
listAllRobotWxId
();
if
(!
ListUtils
.
isEmpty
(
allRobotWxIds
)
&&
!
allRobotWxIds
.
contains
(
wechatUserId
)
&&
!
StringUtil
.
isEmpty
(
sendTextDTO
.
getTextContent
()))
{
...
...
@@ -91,6 +99,25 @@ public class WxGroupSendTextListener {
}
/**
* 机器人自动唤醒配置
*/
private
void
robotWakeUp
(
SendTextDTO
sendTextDTO
)
{
// 个人号 用户回复消息
String
robotId
=
sendTextDTO
.
getWxId
();
String
userId
=
sendTextDTO
.
getWechatUserId
();
if
(
SendMessageTypeEnum
.
SELF
.
getCode
().
equals
(
sendTextDTO
.
getCode
())
&&
!
userId
.
equals
(
robotId
))
{
PcloudRobot
byWxId
=
pcloudRobotDao
.
getByWxId
(
robotId
);
if
(
byWxId
!=
null
&&
byWxId
.
getWakeUp
()
==
1
)
{
// 向缓存中写入用户与小号最后一次聊天时间
WakeUpInfoDto
wakeUpInfoDto
=
new
WakeUpInfoDto
();
wakeUpInfoDto
.
setIp
(
sendTextDTO
.
getIp
());
wakeUpInfoDto
.
setTime
(
new
Date
());
JedisClusterUtils
.
hset
(
robotId
+
PCLOUD_ROBOT_WAKE_UP_SUFFIX
,
userId
,
JSONObject
.
toJSONString
(
wakeUpInfoDto
));
}
}
}
/**
* 机器人缄默设置处理
*/
private
void
silenceProcess
(
SendTextDTO
sendTextDTO
)
{
...
...
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/dao/PcloudRobotDao.java
View file @
eb397968
...
...
@@ -3,9 +3,15 @@ package com.pcloud.book.pcloudkeyword.dao;
import
com.pcloud.book.pcloudkeyword.entity.PcloudRobot
;
import
com.pcloud.common.core.dao.BaseDao
;
import
java.util.List
;
public
interface
PcloudRobotDao
extends
BaseDao
<
PcloudRobot
>
{
PcloudRobot
getByWxId
(
String
wxId
);
PcloudRobot
getPcloudRobotByType
(
Integer
robotType
);
void
updateWakeUpByClassifyIds
(
List
<
Integer
>
classifyList
);
void
clearWakeUp
();
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/dao/impl/PcloudRobotDaoImpl.java
View file @
eb397968
...
...
@@ -5,6 +5,8 @@ import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import
com.pcloud.common.core.dao.BaseDaoImpl
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
(
"pcloudRobotDao"
)
public
class
PcloudRobotDaoImpl
extends
BaseDaoImpl
<
PcloudRobot
>
implements
PcloudRobotDao
{
...
...
@@ -17,4 +19,14 @@ public class PcloudRobotDaoImpl extends BaseDaoImpl<PcloudRobot> implements Pclo
public
PcloudRobot
getPcloudRobotByType
(
Integer
robotType
)
{
return
super
.
getSqlSession
().
selectOne
(
getStatement
(
"getPcloudRobotByType"
),
robotType
);
}
@Override
public
void
updateWakeUpByClassifyIds
(
List
<
Integer
>
list
)
{
this
.
getSessionTemplate
().
update
(
this
.
getStatement
(
"updateWakeUpByClassifyIds"
),
list
);
}
@Override
public
void
clearWakeUp
()
{
this
.
getSessionTemplate
().
update
(
this
.
getStatement
(
"clearWakeUp"
));
}
}
pcloud-service-book/src/main/java/com/pcloud/book/pcloudkeyword/entity/PcloudRobot.java
View file @
eb397968
...
...
@@ -49,4 +49,7 @@ public class PcloudRobot extends BaseEntity {
@ApiModelProperty
(
"缄默时长"
)
private
Integer
silenceDuration
;
@ApiModelProperty
(
"自动唤醒配置 1开启"
)
private
Integer
wakeUp
;
}
pcloud-service-book/src/main/resources/mapper/guide/PcloudRobotWakeupMapper.xml
0 → 100644
View file @
eb397968
<?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=
"com.pcloud.book.guide.mapper.PcloudRobotWakeupMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.guide.entity.PcloudRobotWakeup"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"start_time"
property=
"startTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"cycle"
property=
"cycle"
jdbcType=
"INTEGER"
/>
<result
column=
"last"
property=
"last"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, start_time, cycle, last, create_time, update_time
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from pcloud_robot_wakeup
where id = #{id,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from pcloud_robot_wakeup
where id = #{id,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.guide.entity.PcloudRobotWakeup"
>
insert into pcloud_robot_wakeup (id, start_time, cycle,
last, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{cycle,jdbcType=INTEGER},
#{last,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.pcloud.book.guide.entity.PcloudRobotWakeup"
>
insert into pcloud_robot_wakeup
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"startTime != null"
>
start_time,
</if>
<if
test=
"cycle != null"
>
cycle,
</if>
<if
test=
"last != null"
>
last,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id,jdbcType=INTEGER},
</if>
<if
test=
"startTime != null"
>
#{startTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"cycle != null"
>
#{cycle,jdbcType=INTEGER},
</if>
<if
test=
"last != null"
>
#{last,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.pcloud.book.guide.entity.PcloudRobotWakeup"
>
update pcloud_robot_wakeup
<set
>
<if
test=
"startTime != null"
>
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"cycle != null"
>
cycle = #{cycle,jdbcType=INTEGER},
</if>
<if
test=
"last != null"
>
last = #{last,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.pcloud.book.guide.entity.PcloudRobotWakeup"
>
update pcloud_robot_wakeup
set start_time = #{startTime,jdbcType=TIMESTAMP},
cycle = #{cycle,jdbcType=INTEGER},
last = #{last,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete
id=
"deleteAll"
>
delete from pcloud_robot_wakeup
</delete>
<select
id=
"selectOne"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from pcloud_robot_wakeup
limit 1
</select>
<select
id=
"listAllRobot"
resultType=
"java.lang.String"
>
SELECT wx_id FROM pcloud_robot WHERE wake_up=1
</select>
<select
id=
"listAllClassify"
resultType=
"com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO"
>
SELECT
id,
classify_name classifyName
FROM pcloud_robot_classify WHERE id IN (SELECT DISTINCT robot_type FROM pcloud_robot )
AND is_delete = 0
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/guide/PcloudWakeupMessageMapper.xml
0 → 100644
View file @
eb397968
<?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=
"com.pcloud.book.guide.mapper.PcloudWakeupMessageMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pcloud.book.guide.entity.PcloudWakeupMessage"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"type"
property=
"type"
jdbcType=
"VARCHAR"
/>
<result
column=
"text_content"
property=
"textContent"
jdbcType=
"VARCHAR"
/>
<result
column=
"img_url"
property=
"imgUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"file_url"
property=
"fileUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"file_name"
property=
"fileName"
jdbcType=
"VARCHAR"
/>
<result
column=
"seq_num"
property=
"seqNum"
jdbcType=
"BIT"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"update_time"
property=
"updateTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, type, text_content, img_url, file_url, file_name, seq_num, create_time, update_time
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from pcloud_wakeup_message
where id = #{id,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from pcloud_wakeup_message
where id = #{id,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.pcloud.book.guide.entity.PcloudWakeupMessage"
>
insert into pcloud_wakeup_message (id, type, text_content,
img_url, file_url, file_name,
seq_num, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{textContent,jdbcType=VARCHAR},
#{imgUrl,jdbcType=VARCHAR}, #{fileUrl,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
#{seqNum,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.pcloud.book.guide.entity.PcloudWakeupMessage"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into pcloud_wakeup_message
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"type != null"
>
type,
</if>
<if
test=
"textContent != null"
>
text_content,
</if>
<if
test=
"imgUrl != null"
>
img_url,
</if>
<if
test=
"fileUrl != null"
>
file_url,
</if>
<if
test=
"fileName != null"
>
file_name,
</if>
<if
test=
"seqNum != null"
>
seq_num,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id,jdbcType=INTEGER},
</if>
<if
test=
"type != null"
>
#{type,jdbcType=VARCHAR},
</if>
<if
test=
"textContent != null"
>
#{textContent,jdbcType=VARCHAR},
</if>
<if
test=
"imgUrl != null"
>
#{imgUrl,jdbcType=VARCHAR},
</if>
<if
test=
"fileUrl != null"
>
#{fileUrl,jdbcType=VARCHAR},
</if>
<if
test=
"fileName != null"
>
#{fileName,jdbcType=VARCHAR},
</if>
<if
test=
"seqNum != null"
>
#{seqNum,jdbcType=BIT},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.pcloud.book.guide.entity.PcloudWakeupMessage"
>
update pcloud_wakeup_message
<set
>
<if
test=
"type != null"
>
type = #{type,jdbcType=VARCHAR},
</if>
<if
test=
"textContent != null"
>
text_content = #{textContent,jdbcType=VARCHAR},
</if>
<if
test=
"imgUrl != null"
>
img_url = #{imgUrl,jdbcType=VARCHAR},
</if>
<if
test=
"fileUrl != null"
>
file_url = #{fileUrl,jdbcType=VARCHAR},
</if>
<if
test=
"fileName != null"
>
file_name = #{fileName,jdbcType=VARCHAR},
</if>
<if
test=
"seqNum != null"
>
seq_num = #{seqNum,jdbcType=BIT},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.pcloud.book.guide.entity.PcloudWakeupMessage"
>
update pcloud_wakeup_message
set type = #{type,jdbcType=VARCHAR},
text_content = #{textContent,jdbcType=VARCHAR},
img_url = #{imgUrl,jdbcType=VARCHAR},
file_url = #{fileUrl,jdbcType=VARCHAR},
file_name = #{fileName,jdbcType=VARCHAR},
seq_num = #{seqNum,jdbcType=BIT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete
id=
"deleteAll"
>
delete from pcloud_wakeup_message
</delete>
<select
id=
"selectAll"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
pcloud_wakeup_message
</select>
<select
id=
"getAllClassifyInfo"
resultType=
"java.lang.Integer"
>
SELECT
robot_type
FROM pcloud_robot
WHERE wake_up = 1
</select>
<select
id=
"countAll"
resultType=
"java.lang.Integer"
>
select count(0) from pcloud_robot_classify
</select>
</mapper>
\ No newline at end of file
pcloud-service-book/src/main/resources/mapper/pcloudkeyword/PcloudRobot.Mapper.xml
View file @
eb397968
...
...
@@ -10,10 +10,11 @@
<result
column=
"robot_type"
jdbcType=
"INTEGER"
property=
"robotType"
/>
<result
column=
"keyword_classify_id"
jdbcType=
"BIGINT"
property=
"keywordClassifyId"
/>
<result
column=
"state"
property=
"state"
jdbcType=
"INTEGER"
/>
<result
column=
"wake_up"
property=
"wakeUp"
jdbcType=
"INTEGER"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, wx_id, nick_name, head, qrcode_url, robot_type, keyword_classify_id, state
id, wx_id, nick_name, head, qrcode_url, robot_type, keyword_classify_id, state
, wake_up
</sql>
<insert
id=
"insert"
parameterType=
"PcloudRobot"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
...
...
@@ -24,7 +25,8 @@
qrcode_url,
robot_type,
keyword_classify_id,
state
state,
wake_up
)
values (
#{wxId,jdbcType=VARCHAR},
...
...
@@ -33,7 +35,8 @@
#{qrcodeUrl,jdbcType=VARCHAR},
#{robotType,jdbcType=INTEGER},
#{keywordClassifyId,jdbcType=BIGINT},
#{state,jdbcType=INTEGER}
#{state,jdbcType=INTEGER},
#{wakeUp,jdbcType=INTEGER}
)
</insert>
...
...
@@ -61,6 +64,9 @@
<if
test=
"state != null"
>
state = #{state,jdbcType=INTEGER},
</if>
<if
test=
"wakeUp != null"
>
wake_up = #{wakeUp,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
...
...
@@ -133,4 +139,15 @@
limit 1
</select>
<update
id=
"updateWakeUpByClassifyIds"
parameterType=
"list"
>
update pcloud_robot set wake_up = 1 where robot_type IN
<foreach
collection=
"list"
open=
"("
close=
")"
item=
"item"
separator=
","
>
#{item}
</foreach>
</update>
<update
id=
"clearWakeUp"
>
update pcloud_robot set wake_up = 0
</update>
</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