Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wsmonitor_sql
Overview
Overview
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
宋鹏博
wsmonitor_sql
Commits
a0b1981f
Commit
a0b1981f
authored
Sep 22, 2025
by
宋鹏博
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
添加审校排队监控 See merge request
!3
parents
5b5830a5
7696ceeb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
7 deletions
+106
-7
DButils_aireview.py
common/DButils_aireview.py
+72
-0
cutils.py
common/cutils.py
+20
-1
config.py
config.py
+10
-5
start.py
start.py
+4
-1
No files found.
common/DButils_aireview.py
0 → 100644
View file @
a0b1981f
# mysql数据库
import
pymysql
from
config
import
host1
,
user1
,
database_pwd1
,
database1
,
port1
class
DButils_aireview
:
__conn
=
None
__cursor
=
None
# 连接数据库
@classmethod
def
get_conn
(
cls
):
if
cls
.
__conn
is
None
:
cls
.
__conn
=
pymysql
.
connect
(
host
=
host1
,
port
=
port1
,
user
=
user1
,
password
=
database_pwd1
,
database
=
database1
,
charset
=
"utf8"
)
return
cls
.
__conn
# 创建游标方法
@classmethod
def
get_cursor
(
cls
):
if
cls
.
__cursor
is
None
:
cls
.
__cursor
=
cls
.
get_conn
()
.
cursor
()
return
cls
.
__cursor
# sql执行查询方法
@classmethod
def
select_sql
(
cls
,
sql
):
result
=
None
try
:
cursor
=
cls
.
get_cursor
()
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
except
Exception
as
e
:
print
(
e
)
finally
:
cls
.
close_cursor
()
cls
.
close_conn
()
return
result
# 数据库的增删改操作
@classmethod
def
uid_sql
(
cls
,
sql
):
try
:
conn
=
cls
.
get_conn
()
cursor
=
cls
.
get_cursor
()
cursor
.
execute
(
sql
)
conn
.
commit
()
except
Exception
as
e
:
print
(
e
)
cls
.
get_conn
()
.
rollback
()
finally
:
cls
.
close_cursor
()
cls
.
close_conn
()
# 关闭游标方法
@classmethod
def
close_cursor
(
cls
):
if
cls
.
__cursor
:
cls
.
__cursor
.
close
()
cls
.
__cursor
=
None
# 关闭连接
@classmethod
def
close_conn
(
cls
):
if
cls
.
__conn
:
cls
.
__conn
.
close
()
cls
.
__conn
=
None
common/cutils.py
View file @
a0b1981f
...
...
@@ -3,8 +3,9 @@ import json
import
requests
from
common.DButils
import
DButils
from
common.DButils_aireview
import
DButils_aireview
from
config
import
wechaturl
,
error_answer
,
file_path
from
config
import
wechaturl
,
error_answer
,
file_path
,
aireview_task_url
def
read_json
(
file_name
):
...
...
@@ -43,6 +44,16 @@ def mk_error_message(error_editor, error_answer, message_id, url=wechaturl):
requests
.
post
(
url
,
json
=
data
)
def
task_count
(
semantics_task_count
,
ideology_task_count
,
url
=
wechaturl
):
data
=
{
"msgtype"
:
"markdown"
,
"markdown"
:
{
"content"
:
f
"审校任务排队情况<font color=
\"
warning
\"
>异常</font>,请相关同事注意。
\n
>语义任务:<font color=
\"
comment
\"
>{semantics_task_count}</font>
\n
内容风险任务:<font color=
\"
comment
\"
>{ideology_task_count}</font> "
}
}
requests
.
post
(
url
,
json
=
data
)
# 查询ws异常消息
def
ws_error
(
minute
,
error_answer_list
=
error_answer
):
print
(
"开始"
)
...
...
@@ -59,4 +70,12 @@ def ws_error(minute, error_answer_list=error_answer):
print
(
"结束"
)
def
aireview_task
():
semantics_task_count
=
DButils_aireview
()
.
select_sql
(
"select count(*) from aireview.semantics_task where status = 0;"
)
ideology_task_count
=
DButils_aireview
()
.
select_sql
(
"select count(*) from aireview.ideology_task where status = 0;"
)
if
semantics_task_count
[
0
][
0
]
>
10000
or
ideology_task_count
[
0
][
0
]
>
10000
:
task_count
(
semantics_task_count
[
0
][
0
],
ideology_task_count
[
0
][
0
],
url
=
aireview_task_url
)
config.py
View file @
a0b1981f
...
...
@@ -4,12 +4,13 @@
# database_pwd = "0#ztXqUzECGen8E"
# database = "aireview"
# port = 3306
# 生产环境aireview数据库
# host
= "192.168.8.234"
# user
= "aireview110"
# database_pwd
= "4yFSvSBc"
# database
= "aireview"
# port
= 3306
host1
=
"192.168.8.234"
user1
=
"aireview110"
database_pwd1
=
"4yFSvSBc"
database1
=
"aireview"
port1
=
3306
import
os
# 生产环境aicaption数据库
...
...
@@ -27,3 +28,6 @@ error_answer = ["无法回答此类问题,请换个话题吧","二维码创建
# 文件路径设置
file_path
=
os
.
path
.
dirname
(
__file__
)
# 审校任务排队情况机器人url
aireview_task_url
=
'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=d8ab29fd-f0a6-4676-938a-7b17c2b68aec'
\ No newline at end of file
start.py
View file @
a0b1981f
from
common.cutils
import
ws_error
from
common.cutils
import
ws_error
,
aireview_task
ws_error
(
10
)
aireview_task
()
\ 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