Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
zhangshaowu
/
pipi-helper
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 b7d1d463
authored
Oct 16, 2022
by
zhangshaowu
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
fbdfc69b
c607f49c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
558 additions
and
103 deletions
src/main/java/com/pipihelper/project/controller/LoveChatController.java
src/main/java/com/pipihelper/project/feishu/bo/LoveChatVO.java
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/dao/ChatMessageDao.java
src/main/java/com/pipihelper/project/feishu/dao/LoveChatDao.java
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
src/main/java/com/pipihelper/project/feishu/entity/LoveChat.java
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
src/main/java/com/pipihelper/project/feishu/service/ChatMessageService.java
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuEventService.java
src/main/java/com/pipihelper/project/feishu/service/LoveChatService.java
src/main/java/com/pipihelper/project/feishu/service/PainService.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
src/main/java/com/pipihelper/project/utils/CacheUtil.java
src/main/java/com/pipihelper/project/utils/GraphicsGenerationUtil.java
src/main/resources/mybatis/ChatMessageMapper.xml
src/main/resources/mybatis/LoveChatMapper.xml
src/main/resources/mybatis/PainMapper.xml
src/main/resources/templates/massage-msg-card-rob-end.json
src/main/resources/templates/massage-msg-card-rob.json
src/main/resources/templates/massage-msg-card.json
src/main/resources/templates/massage-singel-msg-card.json
src/main/resources/templates/massage-single-msg-card-next.json
src/main/java/com/pipihelper/project/controller/LoveChatController.java
0 → 100644
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
controller
;
import
com.pipihelper.project.core.Result
;
import
com.pipihelper.project.core.ResultGenerator
;
import
com.pipihelper.project.feishu.service.LoveChatService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/api/v1/love-chat"
)
public
class
LoveChatController
{
@Autowired
private
LoveChatService
loveChatService
;
@PostMapping
(
value
=
"list"
)
public
Result
list
(
@RequestParam
(
value
=
"title"
,
required
=
false
)
String
title
,
@RequestParam
(
"pageNum"
)
Integer
pageNum
,
@RequestParam
(
"pageSize"
)
Integer
pageSize
)
{
return
ResultGenerator
.
genSuccessResult
(
loveChatService
.
list
(
title
,
pageNum
,
pageSize
));
}
}
src/main/java/com/pipihelper/project/feishu/bo/LoveChatVO.java
0 → 100644
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
bo
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
LoveChatVO
{
private
Integer
id
;
private
String
title
;
private
List
<
LoveChatDetail
>
loveChatDetails
;
@Data
public
static
class
LoveChatDetail
{
private
Integer
type
;
private
String
text
;
}
}
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
b7d1d46
This diff is collapsed.
Click to expand it.
src/main/java/com/pipihelper/project/feishu/dao/ChatMessageDao.java
View file @
b7d1d46
...
...
@@ -19,4 +19,6 @@ public interface ChatMessageDao {
List
<
ChatMessage
>
findAll
();
List
<
ChatMessage
>
findListChatAndType
(
@Param
(
value
=
"chatId"
)
String
chatId
,
@Param
(
value
=
"type"
)
Integer
type
);
void
deleteAll
();
}
src/main/java/com/pipihelper/project/feishu/dao/LoveChatDao.java
0 → 100644
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
dao
;
import
com.pipihelper.project.feishu.entity.LoveChat
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
@Mapper
public
interface
LoveChatDao
{
List
<
LoveChat
>
findList
(
@Param
(
value
=
"title"
)
String
title
);
}
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
View file @
b7d1d46
...
...
@@ -25,7 +25,9 @@ public interface PainDao {
List
<
Pain
>
findListAsc
(
int
limit
);
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"
index"
)
Integer
index
,
@Param
(
value
=
"limit"
)
int
limit
);
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"
pindex"
)
Integer
p
index
,
@Param
(
value
=
"limit"
)
int
limit
);
void
deleteAllByFloor
(
int
floor
);
List
<
Pain
>
findAllByFloor
(
@Param
(
value
=
"floor"
)
int
floor
);
}
src/main/java/com/pipihelper/project/feishu/entity/LoveChat.java
0 → 100644
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
entity
;
import
lombok.Data
;
@Data
public
class
LoveChat
{
private
Integer
id
;
private
String
title
;
private
String
content
;
private
Integer
isDelete
;
}
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
View file @
b7d1d46
...
...
@@ -8,7 +8,7 @@ import java.util.Date;
public
class
Pain
{
private
Integer
id
;
private
String
openId
;
private
Integer
index
;
private
Integer
p
index
;
private
String
name
;
private
Integer
status
;
private
Date
startTime
;
...
...
src/main/java/com/pipihelper/project/feishu/service/ChatMessageService.java
View file @
b7d1d46
...
...
@@ -36,4 +36,8 @@ public class ChatMessageService {
public
List
<
ChatMessage
>
findListChatAndType
(
String
chatId
,
Integer
type
)
{
return
chatMessageDao
.
findListChatAndType
(
chatId
,
type
);
}
public
void
deleteAll
()
{
chatMessageDao
.
deleteAll
();
}
}
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
View file @
b7d1d46
...
...
@@ -7,6 +7,7 @@ import com.pipihelper.project.feishu.entity.Employee;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
...
...
@@ -18,6 +19,21 @@ public class EmployeeService {
@Autowired
private
EmployeeDao
employeeDao
;
private
static
final
List
<
String
>
eightFloorEightdepartmentIdList
=
new
ArrayList
<>();
static
{
eightFloorEightdepartmentIdList
.
add
(
"od-3890573b4cd286f437d8e935e10f79bd"
);
eightFloorEightdepartmentIdList
.
add
(
"od-80c6807080faabbb1c4db7bd4d9bd3fd"
);
eightFloorEightdepartmentIdList
.
add
(
"od-257f04c282e11a4dbb40bbce905dc288"
);
eightFloorEightdepartmentIdList
.
add
(
"od-4ff65217e64292e3ff5726258ddb2bd8"
);
eightFloorEightdepartmentIdList
.
add
(
"od-5493776cfddf24c28e1c4620b9ee3406"
);
eightFloorEightdepartmentIdList
.
add
(
"od-133305bbba80fa87b979453a1ffc689a"
);
eightFloorEightdepartmentIdList
.
add
(
"od-2a43207cc2d92d781cb1cdfdcf33dc28"
);
eightFloorEightdepartmentIdList
.
add
(
"od-f2a40e56473fbdfbdcca9efb4302cbca"
);
eightFloorEightdepartmentIdList
.
add
(
"od-d7ddf7e8b966b0886319ff93f4dac95b"
);
eightFloorEightdepartmentIdList
.
add
(
"od-ab7c4b49f80d53ca54f60bb47661bad3"
);
}
@Autowired
private
FeiShuApiService
feiShuApiService
;
...
...
@@ -76,7 +92,7 @@ public class EmployeeService {
employee
.
setName
(
systemFieldsDTO
.
getName
());
employee
.
setMobile
(
systemFieldsDTO
.
getMobile
());
}
employee
.
setFloor
(
14
);
employee
.
setFloor
(
eightFloorEightdepartmentIdList
.
contains
(
employee
.
getDepartmentId
())
?
8
:
14
);
this
.
create
(
employee
);
});
}
...
...
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
b7d1d46
...
...
@@ -25,7 +25,6 @@ import okhttp3.Request;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
...
...
@@ -156,7 +155,7 @@ public class FeiShuApiService {
@Async
public
JSONObject
patchUrgentApp
(
String
message_id
,
JSONObject
content
)
{
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
sms?user_id_type=user
_id"
;
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
app?user_id_type=open
_id"
;
OkHttpClient
client
=
new
OkHttpClient
();
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
...
...
@@ -180,7 +179,7 @@ public class FeiShuApiService {
@Async
public
JSONObject
patchUrgentSms
(
String
message_id
,
JSONObject
content
)
{
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
app?user_id_type=open
_id"
;
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
sms?user_id_type=user
_id"
;
OkHttpClient
client
=
new
OkHttpClient
();
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
...
...
@@ -433,7 +432,7 @@ public class FeiShuApiService {
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
@Async
public
String
joinChatList
(
FeiShuChatDTO
feiShuChatDTO
)
{
String
api
=
"/im/v1/chats/{chat_id}/members"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
...
...
@@ -454,6 +453,26 @@ public class FeiShuApiService {
}
}
public
String
deleteChatList
(
String
chatId
)
{
String
api
=
"/im/v1/chats/:{chat_id}"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
set
(
"Authorization"
,
"Bearer "
+
getTenantToken
());
headers
.
set
(
"Content-Type"
,
"application/json; charset=utf-8"
);
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
try
{
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
headers
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
DELETE
,
requestEntity
,
String
.
class
,
chatId
);
System
.
out
.
println
(
responseEntity
.
getBody
());
Type
type
=
new
TypeReference
<
FeiShuResultDTO
>()
{
}.
getType
();
FeiShuResultDTO
feiShuResultDTO
=
JSONObject
.
parseObject
(
responseEntity
.
getBody
(),
type
);
return
feiShuResultDTO
.
getData
().
getChatId
();
}
catch
(
Exception
e
)
{
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
/**
* 群发消息
* https://open.feishu.cn/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM
...
...
src/main/java/com/pipihelper/project/feishu/service/FeiShuEventService.java
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.FeiShuEventDTO
;
import
com.pipihelper.project.feishu.dto.FeiShuEventHeaderDTO
;
import
com.pipihelper.project.feishu.dto.FeiShuEventReceiveMessageDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.tx.dto.TxConfig
;
import
com.pipihelper.project.tx.service.TxApiService
;
import
com.tencentcloudapi.tbp.v20190627.models.Group
;
import
com.tencentcloudapi.tbp.v20190627.models.TextProcessResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.regex.Pattern
;
/**
* @Description: TODO
...
...
@@ -41,22 +48,37 @@ public class FeiShuEventService {
@Async
public
void
imMessageReceiveV1
(
FeiShuEventDTO
feiShuEventDTO
){
FeiShuEventHeaderDTO
feiShuEventHeaderDTO
=
feiShuEventDTO
.
getHeader
();
FeiShuEventReceiveMessageDTO
feiShuEventReceiveMessageDTO
=
feiShuEventDTO
.
getEvent
().
toJavaObject
(
FeiShuEventReceiveMessageDTO
.
class
);
FeiShuEventReceiveMessageDTO
.
Sender
sender
=
feiShuEventReceiveMessageDTO
.
getSender
();
FeiShuEventReceiveMessageDTO
.
Message
message
=
feiShuEventReceiveMessageDTO
.
getMessage
();
//单独处理群消息
if
(
message
.
getChat_id
().
equals
(
feiShuConfig
.
getChatId
())
||
message
.
getChat_id
().
equals
(
feiShuConfig
.
getChatId
()))
{
//判断是否为指定群消息
return
;
if
(
message
.
getChat_type
().
equals
(
"p2p"
))
{
robotTalk
(
feiShuEventDTO
);
}
else
{
//如果是单聊
if
(
message
.
getChat_type
().
equals
(
"p2p"
))
{
// robotTalk(feiShuEventDTO);
}
public
void
robotTalk
(
FeiShuEventDTO
feiShuEventDTO
){
FeiShuEventReceiveMessageDTO
feiShuEventReceiveMessageDTO
=
feiShuEventDTO
.
getEvent
().
toJavaObject
(
FeiShuEventReceiveMessageDTO
.
class
);
FeiShuEventReceiveMessageDTO
.
Sender
sender
=
feiShuEventReceiveMessageDTO
.
getSender
();
FeiShuEventReceiveMessageDTO
.
Message
message
=
feiShuEventReceiveMessageDTO
.
getMessage
();
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setReceiveId
(
sender
.
getSender_id
().
getOpen_id
());
if
(
message
.
getMessage_type
().
equals
(
"text"
)){
JSONObject
jsonObjectText
=
JSON
.
parseObject
(
message
.
getContent
());
String
inputText
=
jsonObjectText
.
getString
(
"text"
);
String
uuid
=
IdUtil
.
randomUUID
();
TextProcessResponse
textProcessResponse
=
txApiService
.
txTextProcessRequest
(
uuid
,
inputText
);
for
(
Group
group
:
textProcessResponse
.
getResponseMessage
().
getGroupList
())
{
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
group
.
getContent
());
feiShuMsgDTO
.
setContent
(
content
.
toString
());
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"open_id"
);
}
}
}
}
}
src/main/java/com/pipihelper/project/feishu/service/LoveChatService.java
0 → 100644
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.github.pagehelper.PageHelper
;
import
com.pipihelper.project.feishu.bo.LoveChatVO
;
import
com.pipihelper.project.feishu.dao.LoveChatDao
;
import
com.pipihelper.project.feishu.entity.LoveChat
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
LoveChatService
{
@Autowired
private
LoveChatDao
loveChatDao
;
public
List
<
LoveChatVO
>
list
(
String
title
,
Integer
pageNum
,
Integer
pageSize
)
{
if
(
StringUtils
.
isBlank
(
title
)){
title
=
null
;
}
PageHelper
.
startPage
(
pageNum
,
pageSize
);
List
<
LoveChat
>
chatList
=
loveChatDao
.
findList
(
title
);
if
(
CollectionUtil
.
isEmpty
(
chatList
))
{
return
new
ArrayList
<>();
}
return
chatList
.
stream
().
map
(
it
->
{
LoveChatVO
loveChatVO
=
new
LoveChatVO
();
loveChatVO
.
setTitle
(
it
.
getTitle
());
loveChatVO
.
setId
(
it
.
getId
());
List
<
SpeedContent
>
speedContentList
=
JSON
.
parseArray
(
it
.
getContent
(),
SpeedContent
.
class
);
loveChatVO
.
setLoveChatDetails
(
speedContentList
.
stream
().
map
(
speedContent
->
{
LoveChatVO
.
LoveChatDetail
chatDetail
=
new
LoveChatVO
.
LoveChatDetail
();
chatDetail
.
setType
(
"me"
.
equals
(
speedContent
.
getObject
())
?
1
:
2
);
chatDetail
.
setText
(
speedContent
.
getPlan
());
return
chatDetail
;
}).
collect
(
Collectors
.
toList
()));
return
loveChatVO
;
}).
collect
(
Collectors
.
toList
());
}
@Data
private
static
class
SpeedContent
{
private
String
object
;
private
String
plan
;
}
}
src/main/java/com/pipihelper/project/feishu/service/PainService.java
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.pipihelper.project.feishu.dao.PainDao
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
@Service
public
class
PainService
{
...
...
@@ -13,6 +20,14 @@ public class PainService {
@Autowired
private
PainDao
painDao
;
private
final
static
List
<
PindexFloor
>
pindexFloors
=
new
ArrayList
<>();
static
{
pindexFloors
.
add
(
new
PindexFloor
().
setStartIndex
(
1
).
setEndIndex
(
12
).
setTimeRange
(
"15:00-16:00"
).
setFloor
(
14
));
pindexFloors
.
add
(
new
PindexFloor
().
setStartIndex
(
13
).
setEndIndex
(
24
).
setTimeRange
(
"16:00-17:00"
).
setFloor
(
14
));
pindexFloors
.
add
(
new
PindexFloor
().
setStartIndex
(
25
).
setEndIndex
(
30
).
setTimeRange
(
"17:00-17:30"
).
setFloor
(
14
));
}
public
void
create
(
Pain
pain
)
{
painDao
.
create
(
pain
);
}
...
...
@@ -37,6 +52,29 @@ public class PainService {
return
painDao
.
findAll
();
}
public
String
getTimeRange
(
int
pindex
,
int
floor
)
{
String
timeRange
=
pindexFloors
.
stream
().
filter
(
it
->
it
.
floor
!=
null
&&
it
.
floor
==
floor
)
.
filter
(
it
->
pindex
<=
it
.
getEndIndex
()
&&
pindex
>=
it
.
getStartIndex
()).
findFirst
().
get
().
timeRange
;
return
timeRange
;
}
public
List
<
Pain
>
findAllReorderByFloor
(
int
floor
)
{
List
<
Pain
>
painList
=
painDao
.
findAllByFloor
(
floor
);
if
(
CollectionUtil
.
isEmpty
(
painList
))
{
return
new
ArrayList
<>();
}
painList
=
painList
.
stream
().
sorted
(
Comparator
.
comparing
(
Pain:
:
getPindex
)).
collect
(
Collectors
.
toList
());
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
1
);
painList
.
forEach
(
pain
->
{
int
increment
=
atomicInteger
.
getAndIncrement
();
pain
.
setPindex
(
increment
);
String
timeRange
=
pindexFloors
.
stream
().
filter
(
it
->
it
.
floor
!=
null
&&
it
.
floor
==
floor
)
.
filter
(
it
->
increment
<=
it
.
getEndIndex
()
&&
increment
>=
it
.
getStartIndex
()).
findFirst
().
get
().
timeRange
;
pain
.
setTimeRange
(
timeRange
);
});
return
painList
;
}
public
void
waitPain
(
String
openId
)
{
Pain
pain
=
new
Pain
();
pain
.
setOpenId
(
openId
);
...
...
@@ -49,11 +87,20 @@ public class PainService {
return
painDao
.
findListAsc
(
limit
);
}
public
List
<
Pain
>
findBackIndex
(
Integer
index
,
int
limit
)
{
return
painDao
.
findBackIndex
(
index
,
limit
);
public
List
<
Pain
>
findBackIndex
(
Integer
pindex
,
int
limit
)
{
return
painDao
.
findBackIndex
(
pindex
,
limit
);
}
public
void
deleteAllByFloor
(
int
floor
)
{
painDao
.
deleteAllByFloor
(
floor
);
}
@Data
@Accessors
(
chain
=
true
)
public
static
class
PindexFloor
{
private
Integer
startIndex
;
private
Integer
endIndex
;
private
String
timeRange
;
private
Integer
floor
;
}
}
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
b7d1d46
...
...
@@ -3,11 +3,14 @@ package com.pipihelper.project.feishu.service.massage;
import
com.alibaba.fastjson.JSONObject
;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.entity.ChatMessage
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.ChatMessageService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.utils.CacheUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
...
...
@@ -42,24 +45,26 @@ public class MassageService {
private
ChatMessageService
chatMessageService
;
//给群里发送消息
public
void
sendMassageMsgCardToPiPiChat
(
List
<
PushPainBO
>
pushPainBOList
,
String
chatId
){
public
void
sendMassageMsgCardToPiPiChat
(
List
<
PushPainBO
>
pushPainBOList
,
String
chatId
)
{
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
for
(
PushPainBO
pushPainBO:
pushPainBOList
)
{
for
(
PushPainBO
pushPainBO
:
pushPainBOList
)
{
List
<
String
>
user
=
new
ArrayList
<>();
//给单个用户发送
String
singleContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingle
();
log
.
info
(
"给单个用户发送按摩消息:{}"
,
singleContent
);
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setContent
(
singleContent
);
feiShuMsgDTO
.
setReceiveId
(
pushPainBO
.
getOpenId
());
log
.
info
(
feiShuMsgDTO
.
toString
());
JSONObject
sendMsgResponse
=
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"open_id"
);
String
messageId
=
sendMsgResponse
.
getJSONObject
(
"data"
).
getString
(
"message_id"
);
//更新按摩记录表中的messageId
Pain
pain
=
painService
.
findByOpenId
(
pushPainBO
.
getOpenId
());
pain
.
setMessageId
(
messageId
);
painService
.
update
(
pain
);
if
(
chatId
.
equals
(
feiShuConfig
.
getChatId
()))
{
//给单个用户发送
String
singleContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingle
();
log
.
info
(
"给单个用户发送按摩消息:{}"
,
singleContent
);
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setContent
(
singleContent
);
feiShuMsgDTO
.
setReceiveId
(
pushPainBO
.
getOpenId
());
log
.
info
(
feiShuMsgDTO
.
toString
());
JSONObject
sendMsgResponse
=
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"open_id"
);
String
messageId
=
sendMsgResponse
.
getJSONObject
(
"data"
).
getString
(
"message_id"
);
//更新按摩记录表中的messageId
Pain
pain
=
painService
.
findByOpenId
(
pushPainBO
.
getOpenId
());
pain
.
setMessageId
(
messageId
);
painService
.
update
(
pain
);
}
//构建给大群发送的名单
user
.
add
(
pushPainBO
.
getIndex
().
toString
());
user
.
add
(
pushPainBO
.
getName
());
...
...
@@ -70,17 +75,24 @@ public class MassageService {
}
//给大群发送消息
String
content
=
massageMsgCardSerivce
.
genMassageMsgCardForCompany
(
pushUser
);
log
.
info
(
"给大群发送按摩消息:{}"
,
content
);
log
.
info
(
"给大群发送按摩消息:{}"
,
content
);
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setContent
(
content
);
feiShuMsgDTO
.
setReceiveId
(
chatId
);
log
.
info
(
feiShuMsgDTO
.
toString
());
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
JSONObject
rep
=
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
String
messageId
=
rep
.
getJSONObject
(
"data"
).
getString
(
"message_id"
);
ChatMessage
chatMessage
=
new
ChatMessage
();
chatMessage
.
setChatId
(
chatId
);
chatMessage
.
setMessageId
(
messageId
);
chatMessage
.
setType
(
1
);
chatMessageService
.
create
(
chatMessage
);
}
public
void
updateSingleMassageMsgCardWhenBegin
(
String
messageId
){
public
void
updateSingleMassageMsgCardWhenBegin
(
String
messageId
)
{
JSONObject
patchMsg
=
new
JSONObject
();
String
msgCardContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingleStart
();
patchMsg
.
put
(
"content"
,
msgCardContent
);
...
...
@@ -89,14 +101,15 @@ public class MassageService {
//更新群消息
@Async
public
void
updateMassageMsgCardToPiPiChat
(
String
chatId
){
List
<
Pain
>
pains
=
painService
.
findAll
();
public
void
updateMassageMsgCardToPiPiChat
(
String
chatId
)
{
List
<
Pain
>
pains
=
painService
.
findAllReorderByFloor
(
14
);
System
.
out
.
println
(
pains
);
String
messageId
=
chatMessageService
.
findListChatAndType
(
chatId
,
1
).
get
(
0
).
getMessageId
();
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
for
(
Pain
pain:
pains
)
{
for
(
Pain
pain
:
pains
)
{
List
<
String
>
user
=
new
ArrayList
<>();
//构建给大群发送的名单
user
.
add
(
pain
.
get
I
ndex
().
toString
());
user
.
add
(
pain
.
get
Pi
ndex
().
toString
());
user
.
add
(
pain
.
getName
());
user
.
add
(
pain
.
getDepartMentName
());
user
.
add
(
pain
.
getTimeRange
());
...
...
@@ -105,13 +118,48 @@ public class MassageService {
}
//给大群更新发送消息
String
content
=
massageMsgCardSerivce
.
genMassageMsgCardForCompany
(
pushUser
);
log
.
info
(
"给大群发送按摩消息:{}"
,
content
);
log
.
info
(
"给大群发送按摩消息:{}"
,
content
);
JSONObject
patchMsg
=
new
JSONObject
();
patchMsg
.
put
(
"content"
,
content
);
feiShuApiService
.
patchMsg
(
messageId
,
patchMsg
);
}
@Async
public
void
robSingle
(
String
robUserId
,
String
oldUserId
,
String
name
)
{
Pain
oldPain
=
painService
.
findByOpenId
(
oldUserId
);
oldPain
.
setOpenId
(
robUserId
);
oldPain
.
setName
(
name
);
painService
.
update
(
oldPain
);
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setChatId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuChatDTO
.
setIdList
(
new
String
[]{
robUserId
});
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
sendSingle
(
robUserId
);
// 更新大群和按摩群的大卡片,异步
// 大群
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
//按摩群
updateMassageMsgCardToPiPiChat
((
String
)
CacheUtil
.
get
(
"chatId"
));
}
public
void
sendSingle
(
String
openId
)
{
//给单个用户发送
String
singleContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingle
();
log
.
info
(
"给单个用户发送按摩消息:{}"
,
singleContent
);
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setContent
(
singleContent
);
feiShuMsgDTO
.
setReceiveId
(
openId
);
log
.
info
(
feiShuMsgDTO
.
toString
());
JSONObject
sendMsgResponse
=
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"open_id"
);
String
messageId
=
sendMsgResponse
.
getJSONObject
(
"data"
).
getString
(
"message_id"
);
//更新按摩记录表中的messageId
Pain
pain
=
painService
.
findByOpenId
(
openId
);
pain
.
setMessageId
(
messageId
);
painService
.
update
(
pain
);
}
}
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
View file @
b7d1d46
package
com
.
pipihelper
.
project
.
scheduled
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO
;
import
com.pipihelper.project.feishu.dto.department.FeiShuDepartmentDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.entity.Employee
;
import
com.pipihelper.project.feishu.entity.LastMaxPain
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.ChatMessageService
;
import
com.pipihelper.project.feishu.service.EmployeeService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.LastMaxPainService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.utils.CacheUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
/**
* @Description: TODO
...
...
@@ -32,58 +54,152 @@ public class MassageNoticeScheduleService {
@Autowired
private
FeiShuApiService
feiShuApiService
;
@Autowired
private
EmployeeService
employeeService
;
@Autowired
private
LastMaxPainService
lastMaxPainService
;
@Autowired
private
ChatMessageService
chatMessageService
;
@Resource
private
FeiShuConfig
feiShuConfig
;
private
final
static
Map
<
Integer
,
Integer
>
floorCountMap
=
new
HashMap
<>();
static
{
floorCountMap
.
put
(
8
,
10
);
floorCountMap
.
put
(
14
,
30
);
}
// /**
// * 每周四定时生成要按摩的人员名单,并发送大群和单人消息
// */
// @Async
// @Scheduled(cron = "0 0 10 * * ?")
public
void
sendMsgCardToPipiChat
()
{
employeeService
.
uprsetAllEmployee
();
chatMessageService
.
deleteAll
();
for
(
Integer
floor
:
Lists
.
newArrayList
(
14
))
{
LastMaxPain
maxPain
=
lastMaxPainService
.
findByFloor
(
floor
);
int
startEmployeeId
=
0
;
if
(
maxPain
!=
null
)
{
startEmployeeId
=
maxPain
.
getEmployeeId
();
}
int
countByFloor
=
employeeService
.
findCountByFloor
(
floor
);
int
limit
=
floorCountMap
.
get
(
floor
);
if
(
countByFloor
<
limit
)
{
limit
=
countByFloor
;
}
List
<
Employee
>
employeeList
=
employeeService
.
findStartList
(
startEmployeeId
,
floor
,
limit
);
Integer
maxEmploeeId
;
if
(
employeeList
.
size
()
==
limit
)
{
maxEmploeeId
=
employeeList
.
stream
().
map
(
Employee:
:
getId
).
max
(
Comparator
.
comparing
(
x
->
x
)).
orElse
(
0
);
}
else
{
List
<
Employee
>
employees
=
employeeService
.
findStartList
(
0
,
floor
,
limit
-
employeeList
.
size
());
maxEmploeeId
=
employees
.
stream
().
map
(
Employee:
:
getId
).
max
(
Comparator
.
comparing
(
x
->
x
)).
orElse
(
0
);
employeeList
.
addAll
(
employees
);
}
Map
<
String
,
FeiShuDepartmentDTO
>
departmentMap
=
new
HashMap
<>();
List
<
String
>
departmentIdList
=
employeeList
.
stream
().
map
(
Employee:
:
getDepartmentId
).
distinct
().
collect
(
Collectors
.
toList
());
departmentIdList
.
forEach
(
it
->
{
FeiShuDepartmentDTO
department
=
feiShuApiService
.
getDepartment
(
it
);
departmentMap
.
put
(
it
,
department
);
});
painService
.
deleteAllByFloor
(
floor
);
if
(
CollectionUtil
.
isEmpty
(
employeeList
))
{
return
;
}
List
<
PushPainBO
>
pushPainBOList
=
new
ArrayList
<>();
String
[]
userIdList
=
new
String
[
employeeList
.
size
()];
AtomicInteger
i
=
new
AtomicInteger
(
1
);
employeeList
.
forEach
(
it
->
{
Pain
pain
=
new
Pain
();
pain
.
setOpenId
(
it
.
getOpenId
());
pain
.
setStatus
(
0
);
pain
.
setFloor
(
Optional
.
ofNullable
(
it
.
getFloor
()).
orElse
(
floor
));
int
increment
=
i
.
getAndIncrement
();
pain
.
setPindex
(
increment
);
pain
.
setName
(
it
.
getName
());
String
departMentName
=
departmentMap
.
getOrDefault
(
it
.
getDepartmentId
(),
new
FeiShuDepartmentDTO
()).
getName
();
pain
.
setDepartMentName
(
departMentName
);
painService
.
create
(
pain
);
PushPainBO
pushPainBO
=
new
PushPainBO
();
pushPainBO
.
setIndex
(
increment
);
pushPainBO
.
setName
(
it
.
getName
());
pushPainBO
.
setDepartMentName
(
departMentName
);
pushPainBO
.
setOpenId
(
it
.
getOpenId
());
pushPainBO
.
setTimeRange
(
painService
.
getTimeRange
(
increment
,
floor
));
pushPainBOList
.
add
(
pushPainBO
);
userIdList
[
increment
-
1
]
=
it
.
getOpenId
();
});
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setName
(
"按摩群 "
+
DateUtil
.
today
());
feiShuChatDTO
.
setOwnerId
(
pushPainBOList
.
get
(
0
).
getOpenId
());
feiShuChatDTO
.
setUserIdList
(
userIdList
);
String
chatId
=
feiShuApiService
.
createChatList
(
feiShuChatDTO
);
massageService
.
sendMassageMsgCardToPiPiChat
(
pushPainBOList
,
chatId
);
massageService
.
sendMassageMsgCardToPiPiChat
(
pushPainBOList
,
feiShuConfig
.
getChatId
());
if
(
maxPain
!=
null
)
{
maxPain
.
setEmployeeId
(
maxEmploeeId
);
lastMaxPainService
.
update
(
maxPain
);
}
else
{
maxPain
=
new
LastMaxPain
();
maxPain
.
setEmployeeId
(
maxEmploeeId
);
maxPain
.
setFloor
(
floor
);
lastMaxPainService
.
create
(
maxPain
);
}
}
}
/**
* 每周四
定时生成要按摩的人员名单,并发送大群和单人消息
* 每周四
18:00删除当天的群聊
*/
@Async
@Scheduled
(
cron
=
"0 0 10 * * ?"
)
public
void
sendMsgCardToPipiChat
(){
// @Async
// @Scheduled(cron = "0 0 18 * * ?")
public
void
deleteChatList
()
{
String
chatId
=
(
String
)
CacheUtil
.
get
(
"chatId"
);
feiShuApiService
.
deleteChatList
(
chatId
);
}
/**
* 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
*/
// @Async
// @Scheduled(cron = "0 0 10 * * ?")
public
void
massageStart
(){
public
void
massageStart
()
{
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
for
(
Pain
pain:
pains
){
// String msg = "{\"text\":\"当前按摩进度:<at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at>\"}";
StringBuilder
userString
=
new
StringBuilder
();
for
(
Pain
pain
:
pains
)
{
String
messageId
=
pain
.
getMessageId
();
massageService
.
updateSingleMassageMsgCardWhenBegin
(
messageId
);
userString
.
append
(
String
.
format
(
"<at user_id=\"%s\">%s</at>"
,
pain
.
getOpenId
(),
pain
.
getName
()));
//1代表正在按
pain
.
setStatus
(
1
);
painService
.
update
(
pain
);
//发送应用内提醒
JSONObject
noticeMsg
=
new
JSONObject
();
noticeMsg
.
put
(
"user_id_list"
,
Arrays
.
asList
(
pain
.
getOpenId
()));
//发送应用内提醒
log
.
info
(
"发送应用内容消息提醒"
);
feiShuApiService
.
patchUrgentApp
(
messageId
,
noticeMsg
);
}
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
String
msg
=
"当前按摩进度:"
+
userString
;
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
msg
);
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuMsgDTO
.
setContent
(
content
.
toString
());
feiShuMsgDTO
.
setReceiveId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
}
// /**
// * 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
// */
// @Async
// @Scheduled(cron = "0 0 10 * * ?")
// public void massageStart(){
// List<Pain> pains = painService.findListAsc(3);
// for(Pain pain:pains){
// String messageId = pain.getMessageId();
// massageService.updateSingleMassageMsgCardWhenBegin(messageId);
// //1代表正在按
// pain.setStatus(1);
// painService.update(pain);
// JSONObject noticeMsg = new JSONObject();
// noticeMsg.put("user_id_list", Arrays.asList(pain.getOpenId()));
// //发送应用内提醒
// log.info("发送应用内容消息提醒");
// feiShuApiService.patchUrgentApp(messageId, noticeMsg);
// }
//
// }
}
src/main/java/com/pipihelper/project/utils/CacheUtil.java
View file @
b7d1d46
...
...
@@ -7,10 +7,11 @@ import java.util.Map;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.concurrent.ConcurrentHashMap
;
@Slf4j
@Component
public
class
CacheUtil
{
private
static
final
long
DEFAULT_TIMEOUT
=
3600
;
private
static
final
long
DEFAULT_TIMEOUT
=
3600
*
1000
*
10
;
private
static
final
int
DEFAULT_CAPACITY
=
1024
;
private
static
final
Timer
timer
;
private
static
final
int
MAX_CAPACITY
=
10000
;
...
...
@@ -25,7 +26,7 @@ public class CacheUtil {
}
/**
*
缓存任务清除类
* 缓存任务清除类
*/
static
class
ClearTask
extends
TimerTask
{
private
String
key
;
...
...
@@ -40,6 +41,7 @@ public class CacheUtil {
}
}
//私有化构造方法
private
CacheUtil
()
{
...
...
@@ -47,7 +49,7 @@ public class CacheUtil {
//==================缓存的增删改查
/**
*
添加缓存
* 添加缓存
*/
public
static
boolean
put
(
String
key
,
Object
object
)
{
if
(
checkCapacity
())
{
...
...
@@ -60,7 +62,7 @@ public class CacheUtil {
}
/**
*
添加缓存
* 添加缓存
*/
public
static
boolean
put
(
String
key
,
Object
object
,
int
time_out
)
{
if
(
checkCapacity
())
{
...
...
@@ -73,14 +75,14 @@ public class CacheUtil {
/**
*
判断容量大小
* 判断容量大小
*/
public
static
boolean
checkCapacity
()
{
return
map
.
size
()
<
MAX_CAPACITY
;
}
/**
*
批量增加缓存
* 批量增加缓存
*/
public
static
boolean
put
(
Map
<
String
,
Object
>
m
,
int
time_out
)
{
if
(
map
.
size
()
+
m
.
size
()
<=
MAX_CAPACITY
)
{
...
...
@@ -94,14 +96,14 @@ public class CacheUtil {
}
/**
*
删除缓存
* 删除缓存
*/
public
static
void
remove
(
String
key
)
{
map
.
remove
(
key
);
}
/**
*
清除所有缓存
* 清除所有缓存
*/
public
void
clearAll
()
{
if
(
map
.
size
()
>
0
)
{
...
...
@@ -111,14 +113,14 @@ public class CacheUtil {
}
/**
*
获取缓存
* 获取缓存
*/
public
static
Object
get
(
String
key
)
{
return
map
.
get
(
key
);
}
/**
*
是否包含某个缓存
* 是否包含某个缓存
*/
public
static
boolean
isContain
(
String
key
)
{
return
map
.
contains
(
key
);
...
...
src/main/java/com/pipihelper/project/utils/GraphicsGenerationUtil.java
View file @
b7d1d46
...
...
@@ -28,7 +28,7 @@ public class GraphicsGenerationUtil {
totalcol
=
data
.
get
(
0
).
size
();
}
// 图片宽度
int
imageWidth
=
1024
;
int
imageWidth
=
750
;
// 行高
int
rowheight
=
40
;
// 图片高度
...
...
src/main/resources/mybatis/ChatMessageMapper.xml
View file @
b7d1d46
...
...
@@ -27,6 +27,11 @@
</where>
</select>
<delete
id=
"deleteAll"
>
delete from t_chat_message
</delete>
<select
id=
"findListChatAndType"
resultMap=
"ChatMessageResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
src/main/resources/mybatis/LoveChatMapper.xml
0 → 100644
View file @
b7d1d46
<?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.pipihelper.project.feishu.dao.LoveChatDao"
>
<resultMap
id=
"ChatMessageResultMap"
type=
"com.pipihelper.project.feishu.entity.LoveChat"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"title"
property=
"title"
/>
<result
column=
"content"
property=
"content"
/>
<result
column=
"is_delete"
property=
"isDelete"
/>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
extends="ChatMessageResultMap">
</resultMap>-->
<sql
id=
"Base_Column_List"
>
id,title,content,is_delete
</sql>
<select
id=
"findList"
resultMap=
"ChatMessageResultMap"
>
SELECT
<include
refid=
"Base_Column_List"
/>
FROM t_love_chat
<where>
is_delete = 0
<if
test=
"title != null"
>
and title like '%${title}%'
</if>
</where>
</select>
</mapper>
src/main/resources/mybatis/PainMapper.xml
View file @
b7d1d46
...
...
@@ -12,7 +12,7 @@
<result
column=
"message_id"
property=
"messageId"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"depart_ment_name"
property=
"departMentName"
/>
<result
column=
"
index"
property=
"
index"
/>
<result
column=
"
pindex"
property=
"p
index"
/>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...
...
@@ -20,7 +20,8 @@
</resultMap>-->
<sql
id=
"Base_Column_List"
>
id,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name
id
,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name,`pindex`
</sql>
<select
id=
"findById"
parameterType=
"java.lang.Integer"
resultMap=
"PainResultMap"
>
...
...
@@ -32,14 +33,23 @@
</where>
</select>
<select
id=
"findAllByFloor"
parameterType=
"java.lang.Integer"
resultMap=
"PainResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
floor = #{floor}
</where>
</select>
<select
id=
"findBackIndex"
resultMap=
"PainResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
index >= #{
index}
pindex >= #{p
index}
and status = 0
order by index asc
order by
p
index asc
limit #{limit}
</where>
</select>
...
...
@@ -50,7 +60,7 @@
from t_pain
<where>
status = 0
order by index asc
order by
p
index asc
limit #{limit}
</where>
</select>
...
...
@@ -65,7 +75,9 @@
</select>
<delete
id=
"deleteAllByFloor"
>
delete from t_pain where floor = #{floor}
delete
from t_pain
where floor = #{floor}
</delete>
<select
id=
"findByIndex"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
...
...
@@ -73,7 +85,7 @@
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
index = #{
index}
pindex = #{p
index}
</where>
</select>
...
...
@@ -92,12 +104,12 @@
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
insert into t_pain (open_id, start_time, end_time, status, floor,
message_id,name,depart_ment_name
)
values (#{openId}, #{startTime}, #{endTime}, #{status},
#{floor},#{messageId},#{name},#{departMentName
})
insert into t_pain (open_id, start_time, end_time, status, floor,
message_id, name, depart_ment_name, pindex
)
values (#{openId}, #{startTime}, #{endTime}, #{status},
#{floor}, #{messageId}, #{name}, #{departMentName},#{pindex
})
</insert>
<update
id=
"waitPain"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
UPDATE t_pain set
`index` = ((SELECT selected_value FROM (SELECT MAX(`index`
) AS selected_value FROM t_pain) AS
UPDATE t_pain set
pindex = ((SELECT selected_value FROM (SELECT MAX(pindex
) AS selected_value FROM t_pain) AS
sub_selected_value) + 1)
<where>
open_id = #{openId}
...
...
@@ -133,6 +145,9 @@
<if
test=
"departMentName != null"
>
depart_ment_name = #{departMentName},
</if>
<if
test=
"pindex != null"
>
pindex = #{pindex},
</if>
</set>
<where>
id = #{id}
...
...
src/main/resources/templates/massage-msg-card-rob-end.json
View file @
b7d1d46
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"
已经被抢啦啦啦~
"
,
"content"
:
"
%s
"
,
"tag"
:
"lark_md"
}
}
...
...
@@ -15,7 +15,7 @@
"header"
:
{
"template"
:
"turquoise"
,
"title"
:
{
"content"
:
"👻
按摩提醒请查收
!"
,
"content"
:
"👻
有按摩名额空余啦
!"
,
"tag"
:
"plain_text"
}
}
...
...
src/main/resources/templates/massage-msg-card-rob.json
View file @
b7d1d46
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"
当前空余一个名额
"
,
"content"
:
"
有人怕疼放弃了,快来抢吧!
"
,
"tag"
:
"lark_md"
}
},
...
...
@@ -16,7 +16,7 @@
{
"tag"
:
"button"
,
"text"
:
{
"content"
:
"😁 我
抢
"
,
"content"
:
"😁 我
不怕
"
,
"tag"
:
"plain_text"
},
"type"
:
"default"
,
...
...
@@ -31,7 +31,7 @@
"header"
:
{
"template"
:
"turquoise"
,
"title"
:
{
"content"
:
"👻
按摩提醒请查收
!"
,
"content"
:
"👻
有按摩名额空余啦
!"
,
"tag"
:
"plain_text"
}
}
...
...
src/main/resources/templates/massage-msg-card.json
View file @
b7d1d46
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"1. 按摩时间15:00-17:30;
\n
2. 按摩时长每人15分钟,3人一组,按照图片顺序从上至下依次进行;
\n
3. 按完
请在自己的卡片上点击完成,系统会自动@下一位成员;4. 放弃请直接点击放弃,名额将会发送到大群秒杀,先到先得;
\n
5. 有事暂时来不了,可以推迟到最后;
\n
6. 轮到你的时候超过1分钟未确认,将自动调换至末尾,@下一位成员;
"
,
"content"
:
"1. 按摩时间15:00-17:30;
\n
2. 按摩时长每人15分钟,3人一组,按照图片顺序从上至下依次进行;
\n
3. 按完
记得在自己的卡片上点击完成哦,系统会自动通知下一位成员;4. 点击放弃,名额将会发送到大群秒杀,先到先得;
\n
5. 有事暂时来不了,可以推迟到队伍最后;
\n
"
,
"tag"
:
"lark_md"
}
},
...
...
src/main/resources/templates/massage-singel-msg-card.json
View file @
b7d1d46
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"欢呼吧,你
排到了按摩
哦!"
,
"content"
:
"欢呼吧,你
本周有按摩名额
哦!"
,
"tag"
:
"lark_md"
}
},
...
...
@@ -38,7 +38,7 @@
{
"tag"
:
"button"
,
"text"
:
{
"content"
:
"😢
等一下
"
,
"content"
:
"😢
我最后来
"
,
"tag"
:
"plain_text"
},
"type"
:
"default"
,
...
...
src/main/resources/templates/massage-single-msg-card-next.json
View file @
b7d1d46
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"
欢呼吧,你排到了按摩
哦!"
,
"content"
:
"
按摩到你了
哦!"
,
"tag"
:
"lark_md"
}
},
...
...
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