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 0755e32e
authored
Oct 16, 2022
by
zhaolianjie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
256e1a8c
d4682615
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
26 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
src/main/java/com/pipihelper/project/feishu/service/PainService.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/resources/mybatis/PainMapper.xml
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
0755e32
package
com
.
pipihelper
.
project
.
feishu
.
controller
;
package
com
.
pipihelper
.
project
.
feishu
.
controller
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
...
@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
import
com.pipihelper.project.utils.CacheUtil
;
import
com.pipihelper.project.utils.CacheUtil
;
import
jdk.nashorn.internal.ir.CatchNode
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -108,7 +106,7 @@ public class FeiShuEventController {
...
@@ -108,7 +106,7 @@ public class FeiShuEventController {
// 都需要返回 不能点击的卡片json
// 都需要返回 不能点击的卡片json
if
(
"revice"
.
equals
(
actionTypeSecond
))
{
if
(
"revice"
.
equals
(
actionTypeSecond
))
{
// 接受按摩
// 接受按摩
String
fileName
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName
,
"感谢支持"
);
return
getInteractiveCardStr
(
fileName
,
"感谢支持"
);
}
else
if
(
"giveUp"
.
equals
(
actionTypeSecond
))
{
}
else
if
(
"giveUp"
.
equals
(
actionTypeSecond
))
{
...
@@ -116,11 +114,11 @@ public class FeiShuEventController {
...
@@ -116,11 +114,11 @@ public class FeiShuEventController {
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setReceiveId
(
feiShuConfig
.
getChatId
());
feiShuMsgDTO
.
setReceiveId
(
feiShuConfig
.
getChatId
());
String
fileName
=
String
.
format
(
"/templates/massage-msg-card-rob.json
.json
"
);
String
fileName
=
String
.
format
(
"/templates/massage-msg-card-rob.json"
);
String
msgCardContent
=
String
.
format
(
massageMsgCardSerivce
.
getInteractiveCardStr
(
fileName
),
feiShuMsgCardEventDTO
.
getOpen_id
());
String
msgCardContent
=
String
.
format
(
massageMsgCardSerivce
.
getInteractiveCardStr
(
fileName
),
feiShuMsgCardEventDTO
.
getOpen_id
());
feiShuMsgDTO
.
setContent
(
msgCardContent
);
feiShuMsgDTO
.
setContent
(
msgCardContent
);
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"遗憾放弃"
);
return
getInteractiveCardStr
(
fileName1
,
"遗憾放弃"
);
}
else
if
(
"wait"
.
equals
(
actionTypeSecond
))
{
}
else
if
(
"wait"
.
equals
(
actionTypeSecond
))
{
...
@@ -131,7 +129,7 @@ public class FeiShuEventController {
...
@@ -131,7 +129,7 @@ public class FeiShuEventController {
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
//没有按摩群的id
//没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat();
// massageService.updateMassageMsgCardToPiPiChat();
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
...
@@ -144,14 +142,14 @@ public class FeiShuEventController {
...
@@ -144,14 +142,14 @@ public class FeiShuEventController {
Pain
oldPain
=
painService
.
findByOpenId
(
endUserId
);
Pain
oldPain
=
painService
.
findByOpenId
(
endUserId
);
oldPain
.
setStatus
(
2
);
oldPain
.
setStatus
(
2
);
painService
.
update
(
oldPain
);
painService
.
update
(
oldPain
);
List
<
Pain
>
painList
=
painService
.
findBackIndex
(
oldPain
.
get
I
ndex
(),
1
);
List
<
Pain
>
painList
=
painService
.
findBackIndex
(
oldPain
.
get
Pi
ndex
(),
1
);
if
(
CollectionUtil
.
isNotEmpty
(
painList
))
{
if
(
CollectionUtil
.
isNotEmpty
(
painList
))
{
Pain
noticePain
=
CollectionUtil
.
getFirst
(
painList
);
Pain
noticePain
=
CollectionUtil
.
getFirst
(
painList
);
noticePain
.
setStatus
(
1
);
noticePain
.
setStatus
(
1
);
painService
.
update
(
noticePain
);
painService
.
update
(
noticePain
);
massageService
.
updateSingleMassageMsgCardWhenBegin
(
noticePain
.
getMessageId
());
massageService
.
updateSingleMassageMsgCardWhenBegin
(
noticePain
.
getMessageId
());
}
}
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"欢迎下次光临~"
);
return
getInteractiveCardStr
(
fileName1
,
"欢迎下次光临~"
);
}
}
default
:
default
:
...
@@ -170,7 +168,7 @@ public class FeiShuEventController {
...
@@ -170,7 +168,7 @@ public class FeiShuEventController {
feiShuChatDTO
.
setIdList
(
new
String
[]{
feiShuMsgCardEventDTO
.
getOpen_id
()});
feiShuChatDTO
.
setIdList
(
new
String
[]{
feiShuMsgCardEventDTO
.
getOpen_id
()});
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
//ToDo 更新大群和按摩群的大卡片,异步
//ToDo 更新大群和按摩群的大卡片,异步
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json
.json.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
}
}
...
@@ -237,7 +235,7 @@ public class FeiShuEventController {
...
@@ -237,7 +235,7 @@ public class FeiShuEventController {
pain
.
setStatus
(
0
);
pain
.
setStatus
(
0
);
pain
.
setFloor
(
Optional
.
ofNullable
(
it
.
getFloor
()).
orElse
(
14
));
pain
.
setFloor
(
Optional
.
ofNullable
(
it
.
getFloor
()).
orElse
(
14
));
int
increment
=
i
.
getAndIncrement
();
int
increment
=
i
.
getAndIncrement
();
pain
.
set
I
ndex
(
increment
);
pain
.
set
Pi
ndex
(
increment
);
pain
.
setName
(
it
.
getName
());
pain
.
setName
(
it
.
getName
());
String
departMentName
=
departmentMap
.
getOrDefault
(
it
.
getDepartmentId
(),
new
FeiShuDepartmentDTO
()).
getName
();
String
departMentName
=
departmentMap
.
getOrDefault
(
it
.
getDepartmentId
(),
new
FeiShuDepartmentDTO
()).
getName
();
pain
.
setDepartMentName
(
departMentName
);
pain
.
setDepartMentName
(
departMentName
);
...
...
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
View file @
0755e32
...
@@ -28,4 +28,6 @@ public interface PainDao {
...
@@ -28,4 +28,6 @@ public interface PainDao {
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"index"
)
Integer
index
,
@Param
(
value
=
"limit"
)
int
limit
);
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"index"
)
Integer
index
,
@Param
(
value
=
"limit"
)
int
limit
);
void
deleteAllByFloor
(
int
floor
);
void
deleteAllByFloor
(
int
floor
);
List
<
Pain
>
findAllByFloor
(
int
floor
);
}
}
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
View file @
0755e32
...
@@ -8,7 +8,7 @@ import java.util.Date;
...
@@ -8,7 +8,7 @@ import java.util.Date;
public
class
Pain
{
public
class
Pain
{
private
Integer
id
;
private
Integer
id
;
private
String
openId
;
private
String
openId
;
private
Integer
index
;
private
Integer
p
index
;
private
String
name
;
private
String
name
;
private
Integer
status
;
private
Integer
status
;
private
Date
startTime
;
private
Date
startTime
;
...
...
src/main/java/com/pipihelper/project/feishu/service/PainService.java
View file @
0755e32
package
com
.
pipihelper
.
project
.
feishu
.
service
;
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.pipihelper.project.feishu.dao.PainDao
;
import
com.pipihelper.project.feishu.dao.PainDao
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
...
@@ -37,6 +40,15 @@ public class PainService {
...
@@ -37,6 +40,15 @@ public class PainService {
return
painDao
.
findAll
();
return
painDao
.
findAll
();
}
}
public
List
<
Pain
>
findAllReorderByFloor
(
int
floor
)
{
List
<
Pain
>
painList
=
painDao
.
findAllByFloor
(
floor
);
if
(
CollectionUtil
.
isEmpty
(
painList
))
{
return
new
ArrayList
<>();
}
painList
.
stream
().
sorted
(
Comparator
.
comparing
(
Pain:
:
getIndex
));
return
new
ArrayList
<>();
}
public
void
waitPain
(
String
openId
)
{
public
void
waitPain
(
String
openId
)
{
Pain
pain
=
new
Pain
();
Pain
pain
=
new
Pain
();
pain
.
setOpenId
(
openId
);
pain
.
setOpenId
(
openId
);
...
@@ -49,8 +61,8 @@ public class PainService {
...
@@ -49,8 +61,8 @@ public class PainService {
return
painDao
.
findListAsc
(
limit
);
return
painDao
.
findListAsc
(
limit
);
}
}
public
List
<
Pain
>
findBackIndex
(
Integer
index
,
int
limit
)
{
public
List
<
Pain
>
findBackIndex
(
Integer
index
,
int
limit
)
{
return
painDao
.
findBackIndex
(
index
,
limit
);
return
painDao
.
findBackIndex
(
index
,
limit
);
}
}
public
void
deleteAllByFloor
(
int
floor
)
{
public
void
deleteAllByFloor
(
int
floor
)
{
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
0755e32
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
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.entity.Pain
;
import
com.pipihelper.project.feishu.service.ChatMessageService
;
import
com.pipihelper.project.feishu.service.ChatMessageService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
...
@@ -76,7 +77,14 @@ public class MassageService {
...
@@ -76,7 +77,14 @@ public class MassageService {
feiShuMsgDTO
.
setContent
(
content
);
feiShuMsgDTO
.
setContent
(
content
);
feiShuMsgDTO
.
setReceiveId
(
chatId
);
feiShuMsgDTO
.
setReceiveId
(
chatId
);
log
.
info
(
feiShuMsgDTO
.
toString
());
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
);
}
}
...
@@ -96,10 +104,10 @@ public class MassageService {
...
@@ -96,10 +104,10 @@ public class MassageService {
for
(
Pain
pain:
pains
){
for
(
Pain
pain:
pains
){
List
<
String
>
user
=
new
ArrayList
<>();
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
.
getName
());
user
.
add
(
pain
.
getDepartMentName
());
user
.
add
(
pain
.
getDepartMentName
());
user
.
add
(
pain
.
getTimeRange
()
);
user
.
add
(
"15:00-18:00"
);
user
.
add
(
""
);
user
.
add
(
""
);
pushUser
.
add
(
user
);
pushUser
.
add
(
user
);
}
}
...
...
src/main/resources/mybatis/PainMapper.xml
View file @
0755e32
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<result
column=
"message_id"
property=
"messageId"
/>
<result
column=
"message_id"
property=
"messageId"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"depart_ment_name"
property=
"departMentName"
/>
<result
column=
"depart_ment_name"
property=
"departMentName"
/>
<result
column=
"
index"
property=
"
index"
/>
<result
column=
"
pindex"
property=
"p
index"
/>
</resultMap>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...
@@ -20,7 +20,8 @@
...
@@ -20,7 +20,8 @@
</resultMap>-->
</resultMap>-->
<sql
id=
"Base_Column_List"
>
<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>
</sql>
<select
id=
"findById"
parameterType=
"java.lang.Integer"
resultMap=
"PainResultMap"
>
<select
id=
"findById"
parameterType=
"java.lang.Integer"
resultMap=
"PainResultMap"
>
...
@@ -37,9 +38,9 @@
...
@@ -37,9 +38,9 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from t_pain
from t_pain
<where>
<where>
index >= #{
index}
pindex >= #{p
index}
and status = 0
and status = 0
order by index asc
order by
p
index asc
limit #{limit}
limit #{limit}
</where>
</where>
</select>
</select>
...
@@ -50,7 +51,7 @@
...
@@ -50,7 +51,7 @@
from t_pain
from t_pain
<where>
<where>
status = 0
status = 0
order by index asc
order by
p
index asc
limit #{limit}
limit #{limit}
</where>
</where>
</select>
</select>
...
@@ -65,7 +66,9 @@
...
@@ -65,7 +66,9 @@
</select>
</select>
<delete
id=
"deleteAllByFloor"
>
<delete
id=
"deleteAllByFloor"
>
delete from t_pain where floor = #{floor}
delete
from t_pain
where floor = #{floor}
</delete>
</delete>
<select
id=
"findByIndex"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
<select
id=
"findByIndex"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
...
@@ -73,7 +76,7 @@
...
@@ -73,7 +76,7 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from t_pain
from t_pain
<where>
<where>
index = #{
index}
pindex = #{p
index}
</where>
</where>
</select>
</select>
...
@@ -92,12 +95,12 @@
...
@@ -92,12 +95,12 @@
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
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
)
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
})
values (#{openId}, #{startTime}, #{endTime}, #{status},
#{floor}, #{messageId}, #{name}, #{departMentName},#{pindex
})
</insert>
</insert>
<update
id=
"waitPain"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
<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)
sub_selected_value) + 1)
<where>
<where>
open_id = #{openId}
open_id = #{openId}
...
@@ -133,6 +136,9 @@
...
@@ -133,6 +136,9 @@
<if
test=
"departMentName != null"
>
<if
test=
"departMentName != null"
>
depart_ment_name = #{departMentName},
depart_ment_name = #{departMentName},
</if>
</if>
<if
test=
"pindex != null"
>
pindex = #{pindex},
</if>
</set>
</set>
<where>
<where>
id = #{id}
id = #{id}
...
...
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