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 9a658cb0
authored
Oct 15, 2022
by
zhaolianjie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
a60855ce
0e865884
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
102 additions
and
22 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/entity/Employee.java
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/service/PainService.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageMsgCardSerivce.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/resources/mybatis/EmployeeMapper.xml
src/main/resources/mybatis/PainMapper.xml
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
9a658cb
...
@@ -9,10 +9,14 @@ import com.pipihelper.project.feishu.dto.FeiShuMsgCardEventDTO;
...
@@ -9,10 +9,14 @@ import com.pipihelper.project.feishu.dto.FeiShuMsgCardEventDTO;
import
com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO
;
import
com.pipihelper.project.feishu.dto.chat.FeiShuChatDTO
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.employee.FeiShuEmployeeDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.entity.Employee
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.EmployeeService
;
import
com.pipihelper.project.feishu.service.EmployeeService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuEventService
;
import
com.pipihelper.project.feishu.service.FeiShuEventService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce
;
import
com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
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
;
...
@@ -26,6 +30,7 @@ import java.io.InputStream;
...
@@ -26,6 +30,7 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -50,6 +55,10 @@ public class FeiShuEventController {
...
@@ -50,6 +55,10 @@ public class FeiShuEventController {
private
MassageMsgCardSerivce
massageMsgCardSerivce
;
private
MassageMsgCardSerivce
massageMsgCardSerivce
;
@Autowired
@Autowired
private
EmployeeService
employeeService
;
private
EmployeeService
employeeService
;
@Autowired
private
PainService
painService
;
@Autowired
private
MassageService
massageService
;
@PostMapping
(
"/event"
)
@PostMapping
(
"/event"
)
...
@@ -152,7 +161,18 @@ public class FeiShuEventController {
...
@@ -152,7 +161,18 @@ public class FeiShuEventController {
public
Object
event
()
{
public
Object
event
()
{
employeeService
.
uprsetAllEmployee
();
employeeService
.
uprsetAllEmployee
();
employeeService
.
findStartList
(
1
,
14
,
30
);
List
<
Employee
>
startList
=
employeeService
.
findStartList
(
1
,
14
,
30
);
AtomicInteger
i
=
new
AtomicInteger
();
startList
.
forEach
(
it
->
{
Pain
pain
=
new
Pain
();
pain
.
setOpenId
(
it
.
getOpenId
());
pain
.
setStatus
(
0
);
pain
.
setFloor
(
it
.
getFloor
());
pain
.
setIndex
(
i
.
getAndIncrement
());
painService
.
create
(
pain
);
});
/* massageService.sendMassageMsgCardToPiPiChat(userList);*/
List
<
FeiShuEmployeeDTO
>
dtos
=
feiShuApiService
.
getEmployeeList
();
List
<
FeiShuEmployeeDTO
>
dtos
=
feiShuApiService
.
getEmployeeList
();
return
dtos
;
return
dtos
;
}
}
...
...
src/main/java/com/pipihelper/project/feishu/entity/Employee.java
View file @
9a658cb
...
@@ -11,4 +11,5 @@ public class Employee {
...
@@ -11,4 +11,5 @@ public class Employee {
private
Integer
gender
;
private
Integer
gender
;
private
Integer
status
;
private
Integer
status
;
private
String
departmentId
;
private
String
departmentId
;
private
Integer
floor
;
}
}
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
View file @
9a658cb
...
@@ -2,12 +2,16 @@ package com.pipihelper.project.feishu.entity;
...
@@ -2,12 +2,16 @@ package com.pipihelper.project.feishu.entity;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
@Data
@Data
public
class
Pain
{
public
class
Pain
{
private
Integer
id
;
private
Integer
id
;
private
String
openId
;
private
String
openId
;
private
Integer
index
;
private
Integer
index
;
private
Integer
status
;
private
Integer
status
;
private
Date
startTime
;
private
Date
endTime
;
private
String
timeRange
;
private
String
timeRange
;
private
Integer
floor
;
private
Integer
floor
;
private
String
messageId
;
private
String
messageId
;
...
...
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
9a658cb
...
@@ -482,7 +482,7 @@ public class FeiShuApiService {
...
@@ -482,7 +482,7 @@ public class FeiShuApiService {
*
*
* @param feiShuMsgDTO
* @param feiShuMsgDTO
*/
*/
public
void
sendMsg
(
FeiShuMsgDTO
feiShuMsgDTO
,
String
receiveIdType
)
{
public
JSONObject
sendMsg
(
FeiShuMsgDTO
feiShuMsgDTO
,
String
receiveIdType
)
{
String
api
=
"/im/v1/messages?receive_id_type={receiveIdType}"
;
String
api
=
"/im/v1/messages?receive_id_type={receiveIdType}"
;
RestTemplate
restTemplate
=
new
RestTemplate
();
RestTemplate
restTemplate
=
new
RestTemplate
();
try
{
try
{
...
@@ -493,10 +493,14 @@ public class FeiShuApiService {
...
@@ -493,10 +493,14 @@ public class FeiShuApiService {
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
log
.
info
(
requestEntity
.
toString
());
log
.
info
(
requestEntity
.
toString
());
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
JSONObject
.
class
,
receiveIdType
);
ResponseEntity
<
JSONObject
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
requestEntity
,
JSONObject
.
class
,
receiveIdType
);
// ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class, receiveIdType);
if
(
responseEntity
.
getBody
().
getJSONObject
(
"data"
)
==
null
)
{
log
.
info
(
"单发消息成功, req:{}, resp: {}"
,
feiShuMsgDTO
,
responseEntity
);
return
null
;
}
log
.
info
(
"消息发送成功,接收人: {}"
,
feiShuMsgDTO
.
getReceiveId
());
return
responseEntity
.
getBody
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"单发消息失败"
,
e
);
log
.
error
(
"单发消息失败"
,
e
);
throw
new
ServiceException
(
"飞书:"
+
api
+
"接口调用失败"
+
"\n"
+
e
);
}
}
}
}
...
...
src/main/java/com/pipihelper/project/feishu/service/PainService.java
0 → 100644
View file @
9a658cb
package
com
.
pipihelper
.
project
.
feishu
.
service
;
import
com.pipihelper.project.feishu.dao.PainDao
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
PainService
{
@Autowired
private
PainDao
painDao
;
public
void
create
(
Pain
pain
)
{
painDao
.
create
(
pain
);
}
public
Pain
findById
(
Integer
id
)
{
return
painDao
.
findById
(
id
);
}
public
Pain
findByOpenId
(
String
openId
)
{
return
painDao
.
findByOpenId
(
openId
);
}
public
void
deleteById
(
Integer
id
)
{
painDao
.
deleteById
(
id
);
}
public
void
update
(
Pain
Pain
)
{
painDao
.
update
(
Pain
);
}
public
List
<
Pain
>
findAll
()
{
return
painDao
.
findAll
();
}
}
src/main/java/com/pipihelper/project/feishu/service/massage/MassageMsgCardSerivce.java
View file @
9a658cb
...
@@ -31,6 +31,12 @@ public class MassageMsgCardSerivce {
...
@@ -31,6 +31,12 @@ public class MassageMsgCardSerivce {
@Autowired
@Autowired
private
FeiShuApiService
feiShuApiService
;
private
FeiShuApiService
feiShuApiService
;
public
String
genMassageMsgCardForSingle
(){
String
fileName
=
String
.
format
(
"/templates/massage-singel-msg-card.json"
);
String
msgCardContent
=
String
.
format
(
getInteractiveCardStr
(
fileName
));
return
msgCardContent
;
}
public
String
genMassageMsgCardForCompany
(
List
<
List
<
String
>>
pushUser
){
public
String
genMassageMsgCardForCompany
(
List
<
List
<
String
>>
pushUser
){
try
{
try
{
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
9a658cb
package
com
.
pipihelper
.
project
.
feishu
.
service
.
massage
;
package
com
.
pipihelper
.
project
.
feishu
.
service
.
massage
;
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.Pain
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.PainService
;
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.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -30,12 +33,27 @@ public class MassageService {
...
@@ -30,12 +33,27 @@ public class MassageService {
@Autowired
@Autowired
private
FeiShuConfig
feiShuConfig
;
private
FeiShuConfig
feiShuConfig
;
@Autowired
private
PainService
painService
;
public
void
sendMassageMsgCardToPiPiChat
(
List
<
PushPainBO
>
pushPainBOList
){
public
void
sendMassageMsgCardToPiPiChat
(
List
<
PushPainBO
>
pushPainBOList
){
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
for
(
PushPainBO
pushPainBO:
pushPainBOList
){
for
(
PushPainBO
pushPainBO:
pushPainBOList
){
List
<
String
>
user
=
new
ArrayList
<>();
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
);
//构建给大群发送的名单
//构建给大群发送的名单
user
.
add
(
pushPainBO
.
getIndex
().
toString
());
user
.
add
(
pushPainBO
.
getIndex
().
toString
());
user
.
add
(
pushPainBO
.
getName
());
user
.
add
(
pushPainBO
.
getName
());
...
...
src/main/resources/mybatis/EmployeeMapper.xml
View file @
9a658cb
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from t_employee
from t_employee
<where>
<where>
id >= #{
i
d}
id >= #{
startI
d}
and floor = #{floor}
and floor = #{floor}
limit #{limit};
limit #{limit};
</where>
</where>
...
...
src/main/resources/mybatis/PainMapper.xml
View file @
9a658cb
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
<resultMap
id=
"PainResultMap"
type=
"com.pipihelper.project.feishu.entity.Pain"
>
<resultMap
id=
"PainResultMap"
type=
"com.pipihelper.project.feishu.entity.Pain"
>
<id
column=
"id"
property=
"id"
/>
<id
column=
"id"
property=
"id"
/>
<result
column=
"open_id"
property=
"openId"
/>
<result
column=
"open_id"
property=
"openId"
/>
<result
column=
"start_time"
property=
"start
_t
ime"
/>
<result
column=
"start_time"
property=
"start
T
ime"
/>
<result
column=
"end_time"
property=
"end
_t
ime"
/>
<result
column=
"end_time"
property=
"end
T
ime"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"floor"
property=
"floor"
/>
<result
column=
"floor"
property=
"floor"
/>
<result
column=
"messageId"
property=
"messageId"
/>
<result
column=
"messageId"
property=
"messageId"
/>
...
@@ -30,18 +30,6 @@
...
@@ -30,18 +30,6 @@
</where>
</where>
</select>
</select>
<select
id=
"findStartList"
resultMap=
"PainResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
id >= #{id}
and floor = #{floor}
limit #{limit};
</where>
</select>
<select
id=
"findByOpenId"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
<select
id=
"findByOpenId"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
...
@@ -65,12 +53,12 @@
...
@@ -65,12 +53,12 @@
</delete>
</delete>
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.pipihelper.project.feishu.entity.
Employee
"
>
parameterType=
"com.pipihelper.project.feishu.entity.
Pain
"
>
insert into t_pain (open_id, start_time, end_time, status, floor,message_id)
insert into t_pain (open_id, start_time, end_time, status, floor,message_id)
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId})
values (#{openId}, #{startTime}, #{endTime}, #{status},#{floor},#{messageId})
</insert>
</insert>
<update
id=
"update"
parameterType=
"com.pipihelper.project.feishu.entity.
Employee
"
>
<update
id=
"update"
parameterType=
"com.pipihelper.project.feishu.entity.
Pain
"
>
update t_pain
update t_pain
<set>
<set>
<if
test=
"openId != null"
>
<if
test=
"openId != null"
>
...
...
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