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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
13 deletions
+111
-13
DButils_aireview.py
common/DButils_aireview.py
+72
-0
cutils.py
common/cutils.py
+24
-5
config.py
config.py
+11
-7
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
...
@@ -3,8 +3,9 @@ import json
import
requests
import
requests
from
common.DButils
import
DButils
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
):
def
read_json
(
file_name
):
...
@@ -35,11 +36,21 @@ def error_message(text, url=wechaturl, mobile_list=16638842134):
...
@@ -35,11 +36,21 @@ def error_message(text, url=wechaturl, mobile_list=16638842134):
# 发送mkdown格式微信消息
# 发送mkdown格式微信消息
def
mk_error_message
(
error_editor
,
error_answer
,
message_id
,
url
=
wechaturl
):
def
mk_error_message
(
error_editor
,
error_answer
,
message_id
,
url
=
wechaturl
):
data
=
{
data
=
{
"msgtype"
:
"markdown"
,
"msgtype"
:
"markdown"
,
"markdown"
:
{
"markdown"
:
{
"content"
:
f
"ws推送<font color=
\"
warning
\"
>异常</font>,请相关同事注意。
\n
>问题编辑:<font color=
\"
comment
\"
>{error_editor}</font>
\n
content:<font color=
\"
comment
\"
>{message_id}</font>
\n
>返回消息:<font color=
\"
comment
\"
>{error_answer}</font> "
"content"
:
f
"ws推送<font color=
\"
warning
\"
>异常</font>,请相关同事注意。
\n
>问题编辑:<font color=
\"
comment
\"
>{error_editor}</font>
\n
content:<font color=
\"
comment
\"
>{message_id}</font>
\n
>返回消息:<font color=
\"
comment
\"
>{error_answer}</font> "
}
}
}
}
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
)
requests
.
post
(
url
,
json
=
data
)
...
@@ -59,4 +70,12 @@ def ws_error(minute, error_answer_list=error_answer):
...
@@ -59,4 +70,12 @@ def ws_error(minute, error_answer_list=error_answer):
print
(
"结束"
)
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 @@
...
@@ -4,12 +4,13 @@
# database_pwd = "0#ztXqUzECGen8E"
# database_pwd = "0#ztXqUzECGen8E"
# database = "aireview"
# database = "aireview"
# port = 3306
# port = 3306
# 生产环境aireview数据库
# 生产环境aireview数据库
# host
= "192.168.8.234"
host1
=
"192.168.8.234"
# user
= "aireview110"
user1
=
"aireview110"
# database_pwd
= "4yFSvSBc"
database_pwd1
=
"4yFSvSBc"
# database
= "aireview"
database1
=
"aireview"
# port
= 3306
port1
=
3306
import
os
import
os
# 生产环境aicaption数据库
# 生产环境aicaption数据库
...
@@ -26,4 +27,7 @@ wechaturl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5a4fa3ba-9974-
...
@@ -26,4 +27,7 @@ wechaturl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=5a4fa3ba-9974-
error_answer
=
[
"无法回答此类问题,请换个话题吧"
,
"二维码创建失败"
,
"意图下发失败"
,
"文件处理失败"
,
"生成失败"
,
"润色任务失败"
,
"网络异常"
,
"获取书评助理结果失败"
,
"审校失败"
,
"图书生成报告失败"
,
"对不起,我暂时无法回答这个问题"
]
error_answer
=
[
"无法回答此类问题,请换个话题吧"
,
"二维码创建失败"
,
"意图下发失败"
,
"文件处理失败"
,
"生成失败"
,
"润色任务失败"
,
"网络异常"
,
"获取书评助理结果失败"
,
"审校失败"
,
"图书生成报告失败"
,
"对不起,我暂时无法回答这个问题"
]
# 文件路径设置
# 文件路径设置
file_path
=
os
.
path
.
dirname
(
__file__
)
file_path
=
os
.
path
.
dirname
(
__file__
)
\ No newline at end of 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
)
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