Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
rota
Project
Project
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
刘丙寅
rota
Commits
84f3c3b0
Commit
84f3c3b0
authored
May 06, 2021
by
刘丙寅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动分配用户
parent
90b62139
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
0 deletions
+114
-0
workspace.xml
.idea/workspace.xml
+0
-0
peizhi.py
peizhi.py
+19
-0
rota_gm.py
rota_gm.py
+5
-0
rota_gm_new.py
rota_gm_new.py
+90
-0
No files found.
.idea/workspace.xml
View file @
84f3c3b0
This diff is collapsed.
Click to expand it.
peizhi.py
View file @
84f3c3b0
...
...
@@ -10,3 +10,21 @@ Personnel_list={
20210619
:
"淑琴、婷婷"
}
Personnel_list_new
=
[
"淑琴"
,
"婷婷"
,
"崔鑫"
,
"张慧"
,
"丙寅"
,
"韧开"
,
"陈雪"
,
"林颖"
,
"艮霞"
,
"莹莹"
,
"奉龙"
,
"伟男"
]
Personnel_list_1
=
{
"淑琴"
:
15201310698
,
"婷婷"
:
17796839512
,
"崔鑫"
:
17777863287
,
"张慧"
:
17610410225
,
"丙寅"
:
17601625117
,
"韧开"
:
18331001142
,
"陈雪"
:
18645658305
,
"林颖"
:
15033502665
,
"艮霞"
:
17610450939
,
"莹莹"
:
18301089928
,
"奉龙"
:
13608913121
,
"伟男"
:
18646292152
}
\ No newline at end of file
rota_gm.py
View file @
84f3c3b0
...
...
@@ -20,6 +20,7 @@ def test():
}
result
=
requests
.
get
(
url
=
url
,
params
=
params
)
res
=
result
.
json
()
pprint
(
res
)
list
=
res
.
get
(
"data"
)
.
get
(
"list"
)
for
i
in
range
(
len
(
list
)):
workday
=
list
[
i
]
.
get
(
"workday"
)
...
...
@@ -32,6 +33,10 @@ def test():
message
=
worker
if
worker
==
None
:
message
=
"还没有分配具体的值班人员请尽快分配"
# 钉钉报警
dd_url
=
"https://oapi.dingtalk.com/robot/send?access_token=062ab7f98f47c85e6c200efd21ae5d532e4f1bbfd6782ae1268b9a1f4d3dc7b9"
text
=
"明日开始休息:本次值班人员为:
%
s 值班人员记得带 电脑,手机, vpn环境"
%
{
message
}
json_text
=
{
...
...
rota_gm_new.py
0 → 100644
View file @
84f3c3b0
import
requests
from
pprint
import
pprint
import
peizhi
import
redis
,
json
def
test
():
from
datetime
import
date
,
timedelta
r
=
redis
.
Redis
()
today
=
date
.
today
()
format_today
=
today
.
strftime
(
"
%
Y
%
m
%
d"
)
tomorrow
=
today
+
timedelta
(
days
=
1
)
format_tomorrow
=
tomorrow
.
strftime
(
"
%
Y
%
m
%
d"
)
days
=
[]
url
=
"https://api.apihubs.cn/holiday/get"
params
=
{
"year"
:
2021
,
"size"
:
1000
}
result
=
requests
.
get
(
url
=
url
,
params
=
params
)
res
=
result
.
json
()
pprint
(
res
)
list
=
res
.
get
(
"data"
)
.
get
(
"list"
)
for
i
in
range
(
len
(
list
)):
workday
=
list
[
i
]
.
get
(
"workday"
)
if
workday
==
2
:
date
=
list
[
i
]
.
get
(
"date"
)
days
.
append
(
date
)
message
=
""
print
(
format_tomorrow
)
print
(
format_today
)
print
(
days
)
# 如果明天是节假日 今天不是节假日,则进入判断
if
int
(
format_tomorrow
)
in
days
and
int
(
format_today
)
not
in
days
:
# 循环判断接下来的时间,看这个假期有多长
for
i
in
range
(
1
,
10
):
print
(
i
)
dayday
=
today
+
timedelta
(
days
=
i
)
dayday
=
int
(
dayday
.
strftime
(
"
%
Y
%
m
%
d"
))
# 下一个是工作日 则跳出循环,以获得一共多长假期
if
dayday
not
in
days
:
break
# redis 存储数据
redis_list
=
r
.
lrange
(
"zhiban"
,
0
,
-
1
)
redis_list
=
[
item
.
decode
()
for
item
in
redis_list
]
print
(
"*"
*
100
)
print
(
redis_list
)
print
(
"*"
*
100
)
www
=
[]
# 如果redis里面的列表是空的
if
not
redis_list
:
new_list
=
peizhi
.
Personnel_list_new
else
:
new_list
=
redis_list
+
peizhi
.
Personnel_list_new
# 取出来名字
for
o
in
range
(
0
,
i
):
print
(
i
)
www
.
append
(
new_list
[
o
])
new_list
.
remove
(
new_list
[
o
])
r
.
delete
(
"zhiban"
)
phone_list
=
[]
for
i
in
new_list
:
phone
=
peizhi
.
Personnel_list_1
.
get
(
i
)
phone_list
.
append
(
phone
)
new_www
=
' '
.
join
(
www
)
print
(
new_www
)
r
.
rpush
(
"zhiban"
,
*
new_list
)
dd_url
=
"https://oapi.dingtalk.com/robot/send?access_token=062ab7f98f47c85e6c200efd21ae5d532e4f1bbfd6782ae1268b9a1f4d3dc7b9"
text
=
"明日开始休假:休息
%
s 天 值班人员为:
%
s 值班人员记得带 电脑,手机,调通vpn环境"
%
(
i
,
new_www
)
json_text
=
{
"msgtype"
:
"text"
,
"at"
:
{
"atMobiles"
:
phone_list
,
# 变为true 就会@所有人
"isAtAll"
:
False
},
"text"
:
{
"content"
:
text
}
}
requests
.
post
(
url
=
dd_url
,
json
=
json_text
,
verify
=
False
)
if
__name__
==
'__main__'
:
test
()
\ 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