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 75cc3f28
authored
Oct 16, 2022
by
weiss
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
331a5a2a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
29 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/dao/EmployeeDao.java
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
src/main/resources/mybatis/EmployeeMapper.xml
src/main/resources/templates/massage-msg-card-rob.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/feishu/controller/FeiShuEventController.java
View file @
75cc3f2
package
com
.
pipihelper
.
project
.
feishu
.
controller
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.pipihelper.project.core.Result
;
import
com.pipihelper.project.core.ResultGenerator
;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.FeiShuEventDTO
;
import
com.pipihelper.project.feishu.dto.FeiShuMsgCardEventDTO
;
...
...
@@ -16,11 +18,7 @@ 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.EmployeeService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuEventService
;
import
com.pipihelper.project.feishu.service.LastMaxPainService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.*
;
import
com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
...
...
@@ -35,12 +33,7 @@ import javax.annotation.Resource;
import
java.io.BufferedReader
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
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.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -195,18 +188,23 @@ public class FeiShuEventController {
@PostMapping
(
"/employee-list"
)
public
Object
event
()
{
//
employeeService.uprsetAllEmployee();
employeeService
.
uprsetAllEmployee
();
LastMaxPain
maxPain
=
lastMaxPainService
.
findByFloor
(
14
);
int
startEmployeeId
=
0
;
if
(
maxPain
!=
null
)
{
startEmployeeId
=
maxPain
.
getEmployeeId
();
}
List
<
Employee
>
employeeList
=
employeeService
.
findStartList
(
startEmployeeId
,
14
,
30
);
int
countByFloor
=
employeeService
.
findCountByFloor
(
14
);
int
limit
=
30
;
if
(
countByFloor
<
30
){
limit
=
countByFloor
;
}
List
<
Employee
>
employeeList
=
employeeService
.
findStartList
(
startEmployeeId
,
14
,
limit
);
Integer
maxEmploeeId
=
0
;
if
(
employeeList
.
size
()
==
30
)
{
if
(
employeeList
.
size
()
==
limit
)
{
maxEmploeeId
=
employeeList
.
stream
().
map
(
Employee:
:
getId
).
max
(
Comparator
.
comparing
(
x
->
x
)).
orElse
(
0
);
}
else
{
List
<
Employee
>
employees
=
employeeService
.
findStartList
(
0
,
14
,
30
-
employeeList
.
size
());
List
<
Employee
>
employees
=
employeeService
.
findStartList
(
0
,
14
,
limit
-
employeeList
.
size
());
maxEmploeeId
=
employees
.
stream
().
map
(
Employee:
:
getId
).
max
(
Comparator
.
comparing
(
x
->
x
)).
orElse
(
0
);
employeeList
.
addAll
(
employees
);
}
...
...
@@ -220,19 +218,40 @@ public class FeiShuEventController {
});
painService
.
deleteAllByFloor
(
14
);
AtomicInteger
i
=
new
AtomicInteger
();
System
.
out
.
println
(
employeeList
);
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
(
it
.
getFloor
());
pain
.
setIndex
(
i
.
getAndIncrement
());
pain
.
setFloor
(
Optional
.
ofNullable
(
it
.
getFloor
()).
orElse
(
14
));
int
increment
=
i
.
getAndIncrement
();
pain
.
setIndex
(
increment
);
pain
.
setName
(
it
.
getName
());
pain
.
setDepartMentName
(
departmentMap
.
getOrDefault
(
it
.
getDepartmentId
(),
new
FeiShuDepartmentDTO
()).
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
(
"15:00-16:00"
);
pushPainBOList
.
add
(
pushPainBO
);
userIdList
[
increment
-
1
]
=
it
.
getOpenId
();
});
/* massageService.sendMassageMsgCardToPiPiChat(userList);*/
System
.
out
.
println
(
pushPainBOList
);
FeiShuChatDTO
feiShuChatDTO
=
new
FeiShuChatDTO
();
feiShuChatDTO
.
setName
(
"etgh "
);
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
);
...
...
@@ -281,7 +300,7 @@ public class FeiShuEventController {
@PostMapping
(
"/start"
)
public
Result
start
()
{
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
for
(
Pain
pain:
pains
)
{
for
(
Pain
pain
:
pains
)
{
String
messageId
=
pain
.
getMessageId
();
massageService
.
updateSingleMassageMsgCardWhenBegin
(
messageId
);
//1代表正在按
...
...
src/main/java/com/pipihelper/project/feishu/dao/EmployeeDao.java
View file @
75cc3f2
...
...
@@ -22,4 +22,6 @@ public interface EmployeeDao {
List
<
Employee
>
findAll
();
List
<
Employee
>
findStartList
(
@Param
(
value
=
"startId"
)
int
startId
,
@Param
(
value
=
"floor"
)
int
floor
,
@Param
(
value
=
"limit"
)
int
limit
);
int
findCountByFloor
(
@Param
(
value
=
"floor"
)
int
floor
);
}
src/main/java/com/pipihelper/project/feishu/service/EmployeeService.java
View file @
75cc3f2
...
...
@@ -76,6 +76,7 @@ public class EmployeeService {
employee
.
setName
(
systemFieldsDTO
.
getName
());
employee
.
setMobile
(
systemFieldsDTO
.
getMobile
());
}
employee
.
setFloor
(
14
);
this
.
create
(
employee
);
});
}
...
...
@@ -83,4 +84,8 @@ public class EmployeeService {
public
List
<
Employee
>
findStartList
(
int
startId
,
int
floor
,
int
limit
)
{
return
employeeDao
.
findStartList
(
startId
,
floor
,
limit
);
}
public
int
findCountByFloor
(
int
floor
)
{
return
employeeDao
.
findCountByFloor
(
floor
);
}
}
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
View file @
75cc3f2
...
...
@@ -45,8 +45,8 @@ public class MassageNoticeScheduleService {
/**
* 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
*/
@Async
@Scheduled
(
cron
=
"0 0 10 * * ?"
)
//
@Async
//
@Scheduled(cron = "0 0 10 * * ?")
public
void
massageStart
(){
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
for
(
Pain
pain:
pains
){
...
...
src/main/resources/mybatis/EmployeeMapper.xml
View file @
75cc3f2
...
...
@@ -31,6 +31,15 @@
</select>
<select
id=
"findCountByFloor"
parameterType=
"java.lang.Integer"
resultType=
"java.lang.Integer"
>
select
count(*)
from t_employee
<where>
floor = #{floor}
</where>
</select>
<select
id=
"findStartList"
resultMap=
"EmployeeResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
src/main/resources/templates/massage-msg-card-rob.json
View file @
75cc3f2
...
...
@@ -21,7 +21,7 @@
},
"type"
:
"default"
,
"value"
:
{
"key
1
"
:
"massage-singel.rob.%s"
"key"
:
"massage-singel.rob.%s"
}
}
],
...
...
src/main/resources/templates/massage-singel-msg-card.json
View file @
75cc3f2
...
...
@@ -21,7 +21,7 @@
},
"type"
:
"default"
,
"value"
:
{
"key
1
"
:
"massage-singel.revice"
"key"
:
"massage-singel.revice"
}
},
{
...
...
@@ -32,7 +32,7 @@
},
"type"
:
"default"
,
"value"
:
{
"key
2
"
:
"massage-singel.giveUp"
"key"
:
"massage-singel.giveUp"
}
},
{
...
...
@@ -43,7 +43,7 @@
},
"type"
:
"default"
,
"value"
:
{
"key
3
"
:
"massage-singel.wait"
"key"
:
"massage-singel.wait"
}
}
],
...
...
src/main/resources/templates/massage-single-msg-card-next.json
View file @
75cc3f2
...
...
@@ -21,7 +21,7 @@
},
"type"
:
"default"
,
"value"
:
{
"key
1
"
:
"massage-singel.next"
"key"
:
"massage-singel.next"
}
}
],
...
...
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