mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 10:52:18 +08:00
readme
This commit is contained in:
parent
a2df4e6e3a
commit
6138f9aca8
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (WeChatMsg)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -504,211 +504,42 @@ def get_myInfo():
|
||||
}
|
||||
|
||||
|
||||
from pyecharts import options as opts
|
||||
from pyecharts.charts import Bar, Line, Timeline, Grid
|
||||
import pandas as pd
|
||||
import xmltodict
|
||||
def search_Latest_chat_time(wxid):
|
||||
# 查找聊天最晚的消息
|
||||
sql = '''
|
||||
SELECT strftime('%H:%M:%S',createTime/1000,'unixepoch','localtime') as t,content,strftime('%Y-%m-%d %H:%M:%S',createTime/1000,'unixepoch','localtime')
|
||||
from message
|
||||
where talker = ? and t>'00:00:00' and t<'05:00:00' and type=1
|
||||
order by t desc
|
||||
'''
|
||||
cursor.execute(sql, [wxid])
|
||||
result = cursor.fetchall()
|
||||
return result
|
||||
|
||||
|
||||
def sport(username):
|
||||
sports = get_sport()
|
||||
ranks = []
|
||||
steps = []
|
||||
date = []
|
||||
for sport in sports:
|
||||
try:
|
||||
timestamp, content, t = sport
|
||||
rank_data = xmltodict.parse(content)
|
||||
sub_data = rank_data['msg']['appmsg']['hardwareinfo']['messagenodeinfo']
|
||||
# print(sub_data)
|
||||
my_rank = sub_data['rankinfo']['rank']['rankdisplay']
|
||||
my_steps = int(sub_data['rankinfo']['score']['scoredisplay'])
|
||||
# print(f'rank: {my_rank},steps: {my_steps}')
|
||||
rank_view = rank_data['msg']['appmsg']['hardwareinfo']['rankview']['rankinfolist']['rankinfo']
|
||||
for userinfo in rank_view:
|
||||
username0 = userinfo['username']
|
||||
if username0 == username:
|
||||
rank_ta = int(userinfo['rank']['rankdisplay'])
|
||||
steps_ta = int(userinfo['score']['scoredisplay'])
|
||||
ranks.append(rank_ta)
|
||||
steps.append(steps_ta)
|
||||
date.append(t)
|
||||
except:
|
||||
continue
|
||||
df = pd.DataFrame({'ranks': ranks, 'score': steps, 'date': date}, index=date)
|
||||
months = pd.date_range(date[0], date[-1], freq='M')
|
||||
tl = Timeline(init_opts=opts.InitOpts(width="440px", height="245px"))
|
||||
tl.add_schema(is_auto_play=True)
|
||||
for i in range(len(months) - 1):
|
||||
da = df[(months[i + 1].strftime("%Y-%m-%d") >= df['date']) & (df['date'] > months[i].strftime("%Y-%m-%d"))]
|
||||
bar = (
|
||||
Bar(init_opts=opts.InitOpts(width="400px", height="235px"))
|
||||
.add_xaxis(list(da['date']))
|
||||
.add_yaxis(
|
||||
"步数",
|
||||
list(da['score']),
|
||||
yaxis_index=1,
|
||||
color="#d14a61",
|
||||
)
|
||||
.extend_axis(
|
||||
yaxis=opts.AxisOpts(
|
||||
name="步数",
|
||||
type_="value",
|
||||
# grid_index=0,
|
||||
# min_=0,
|
||||
# max_=250,
|
||||
position="right",
|
||||
axisline_opts=opts.AxisLineOpts(
|
||||
linestyle_opts=opts.LineStyleOpts(color="#d14a61")
|
||||
),
|
||||
# axislabel_opts=opts.LabelOpts(formatter="{value} ml"),
|
||||
)
|
||||
)
|
||||
.extend_axis(
|
||||
yaxis=opts.AxisOpts(
|
||||
type_="value",
|
||||
name="排名",
|
||||
# min_=0,
|
||||
# max_=25,
|
||||
position="left",
|
||||
is_inverse=True,
|
||||
# interval=True,
|
||||
# grid_index=1,
|
||||
axisline_opts=opts.AxisLineOpts(
|
||||
linestyle_opts=opts.LineStyleOpts(color="#675bba")
|
||||
),
|
||||
# axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
|
||||
splitline_opts=opts.SplitLineOpts(
|
||||
is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)
|
||||
),
|
||||
)
|
||||
)
|
||||
.set_global_opts(
|
||||
title_opts=opts.TitleOpts(title="{}月运动步数".format(months[i + 1].strftime("%Y-%m"))),
|
||||
# legend_opts=opts.LegendOpts(is_show=False),
|
||||
yaxis_opts=opts.AxisOpts(is_inverse=True)
|
||||
)
|
||||
.set_series_opts(
|
||||
label_opts=opts.LabelOpts(
|
||||
is_show=False
|
||||
)
|
||||
)
|
||||
)
|
||||
# init_opts = opts.InitOpts(width="400px", height="235px")
|
||||
line = (
|
||||
Line(init_opts=opts.InitOpts(width="400px", height="235px"))
|
||||
.add_xaxis(list(da['date']))
|
||||
.add_yaxis(
|
||||
"排名",
|
||||
list(da['ranks']),
|
||||
yaxis_index=0,
|
||||
color="#675bba",
|
||||
# label_opts=opts.LabelOpts(is_show=False),
|
||||
|
||||
)
|
||||
.set_global_opts(
|
||||
yaxis_opts=opts.AxisOpts(is_inverse=True)
|
||||
)
|
||||
)
|
||||
bar.overlap(line)
|
||||
grid = Grid()
|
||||
grid.add(bar, opts.GridOpts(pos_left="5%", pos_right="20%"), is_control_axis_index=True)
|
||||
grid.render("grid_multi_yaxis.html")
|
||||
quit()
|
||||
# tl.add(bar, "{}".format(months[i].strftime("%Y-%m")))
|
||||
# tl.render("./sports.html")
|
||||
|
||||
return {
|
||||
username: {
|
||||
'ranks': ranks,
|
||||
'score': steps,
|
||||
'date': date,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def radar_hour(username):
|
||||
msg_data = get_msg_by_hour(username)
|
||||
x_axis = list(map(lambda x: x[0], msg_data))
|
||||
y_data = list(map(lambda x: x[1], msg_data))
|
||||
print(x_axis)
|
||||
print(y_data)
|
||||
max_ = max(y_data)
|
||||
c = (
|
||||
Line()
|
||||
.add_xaxis(xaxis_data=x_axis)
|
||||
.add_yaxis(
|
||||
series_name="聊天频率",
|
||||
y_axis=y_data,
|
||||
markpoint_opts=opts.MarkPointOpts(
|
||||
data=[
|
||||
opts.MarkPointItem(type_="max", name="最大值"),
|
||||
opts.MarkPointItem(type_="min", name="最小值"),
|
||||
]
|
||||
),
|
||||
markline_opts=opts.MarkLineOpts(
|
||||
data=[opts.MarkLineItem(type_="average", name="平均值")]
|
||||
),
|
||||
)
|
||||
.render("temperature_change_line_chart.html")
|
||||
)
|
||||
|
||||
|
||||
def chat_start_endTime(username):
|
||||
start_time = get_msg_start_time(username)
|
||||
end_time = get_msg_end_time(username)
|
||||
year = start_time[:4]
|
||||
month = start_time[5:7]
|
||||
day = start_time[8:10]
|
||||
hour = start_time[11:13]
|
||||
minute = start_time[14:16]
|
||||
second = start_time[17:]
|
||||
print(year, month, day, hour, minute, second)
|
||||
def search_emoji(wxid):
|
||||
# 查找聊天最晚的消息
|
||||
sql = '''
|
||||
SELECT imgPath,strftime('%Y-%m-%d %H:%M:%S',createTime/1000,'unixepoch','localtime') as t,count(imgPath)
|
||||
from message
|
||||
where talker = ? and t>'2022-01-01 00:00:00' and t<'2022-12-31 00::00:00' and type=47 and isSend=0
|
||||
group by content
|
||||
order by count(imgPath) desc
|
||||
'''
|
||||
cursor.execute(sql, [wxid])
|
||||
result = cursor.fetchall()
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
wxid = 'wxid_8piw6sb4hvfm22'
|
||||
wxid = 'wxid_wt2vsktnu4z022'
|
||||
# wxid = 'wxid_wt2vsktnu4z022'
|
||||
# emotion_analysis(wxid)
|
||||
plot_emotion(wxid)
|
||||
'''
|
||||
if __name__ == '__main__':
|
||||
# rconversation = get_rconversation()
|
||||
# for i in rconversation:
|
||||
# print(i)
|
||||
# contacts = get_all_message('wxid_vqave8lcp49r22')
|
||||
# for contact in contacts:
|
||||
# print(contact)
|
||||
# [(177325,)] (73546,) (103770,)
|
||||
# print(search_send_message(1, 1))
|
||||
# print(send_nums('wxid_vqave8lcp49r22'))
|
||||
# print(recv_nums('wxid_vqave8lcp49r22'))
|
||||
# # for t in get_text('wxid_vqave8lcp49r22'):
|
||||
# # print(t)
|
||||
# print(msg_type_num('wxid_vqave8lcp49r22'))
|
||||
# st = get_msg_start_time('wxid_vqave8lcp49r22')
|
||||
# print(st, timestamp2str(st))
|
||||
# st = get_msg_end_time('wxid_vqave8lcp49r22')
|
||||
# print(st, timestamp2str(st))
|
||||
# print(get_msg_by_month('wxid_8piw6sb4hvfm22', year='2022'))
|
||||
# print(len(get_sport()))
|
||||
# result = sport('wxid_8piw6sb4hvfm22')
|
||||
# print(get_imgPath('THUMBNAIL_DIRPATH://th_92f32326df645b3e1aecef9b6266a3b8'))
|
||||
# result = get_msg_by_hour('wxid_8piw6sb4hvfm22')
|
||||
# print(result)
|
||||
# radar_hour('wxid_8piw6sb4hvfm22')
|
||||
# print(result)
|
||||
# print(get_msg_start_time('wxid_8piw6sb4hvfm22'), get_msg_end_time('wxid_8piw6sb4hvfm22'))
|
||||
# chat_start_endTime('wxid_8piw6sb4hvfm22')
|
||||
msg = get_text_by_num('wxid_8piw6sb4hvfm22', 1)
|
||||
from snownlp import SnowNLP
|
||||
|
||||
# print(msg[0])
|
||||
for m in msg:
|
||||
content = m[0]
|
||||
print(content)
|
||||
s = SnowNLP(content)
|
||||
# # 输出情绪为积极的概率
|
||||
print(s.sentiments)
|
||||
# print(msg)
|
||||
'''
|
||||
t = search_Latest_chat_time(wxid)
|
||||
print(t[0])
|
||||
d = get_msg_by_days(wxid)
|
||||
print(len(d))
|
||||
e = search_emoji(wxid)
|
||||
print(e)
|
||||
p = get_emoji(e[1][0])
|
||||
print(p)
|
||||
|
@ -16,6 +16,7 @@ from PyQt5.QtWidgets import *
|
||||
from .analysis import analysis
|
||||
from .contactUi import *
|
||||
from .emotion import emotion
|
||||
from .report import report
|
||||
from .userinfo import userinfoUi
|
||||
from ...DataBase import data, output
|
||||
|
||||
@ -71,6 +72,7 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.btn_output.clicked.connect(self.output)
|
||||
self.btn_analysis.clicked.connect(self.analysis)
|
||||
self.btn_emotion.clicked.connect(self.emotionale_Analysis)
|
||||
self.btn_report.clicked.connect(self.annual_report)
|
||||
|
||||
self.lay0 = QVBoxLayout()
|
||||
# self.widget.setLayout(self.lay0)
|
||||
@ -192,6 +194,12 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
# 判断talkerId是否已经分析过了
|
||||
# 是:则清空其他界面,直接显示该界面
|
||||
# 否:清空其他界面,创建用户界面并显示
|
||||
if 'room' in self.now_talkerId:
|
||||
QMessageBox.warning(
|
||||
self, '警告',
|
||||
'暂不支持群组'
|
||||
)
|
||||
return
|
||||
if self.now_talkerId in self.view_analysis:
|
||||
self.setViewVisible(self.now_talkerId, mod=ANALYSIS)
|
||||
return True
|
||||
@ -221,6 +229,10 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.setViewVisible(self.now_talkerId, mod=EMOTION)
|
||||
pass
|
||||
|
||||
def annual_report(self):
|
||||
self.report = report.ReportController(123)
|
||||
self.report.show()
|
||||
|
||||
def showUserinfo(self):
|
||||
pass
|
||||
# self.analysisView = analysis.AnalysisController(self.now_talkerId)
|
||||
|
@ -80,6 +80,9 @@ class Ui_Dialog(object):
|
||||
self.btn_emotion = QtWidgets.QPushButton(self.frame)
|
||||
self.btn_emotion.setObjectName("btn_emotion")
|
||||
self.horizontalLayout_3.addWidget(self.btn_emotion)
|
||||
self.btn_report = QtWidgets.QPushButton(self.frame)
|
||||
self.btn_report.setObjectName("btn_report")
|
||||
self.horizontalLayout_3.addWidget(self.btn_report)
|
||||
self.btn_output = QtWidgets.QPushButton(self.frame)
|
||||
self.btn_output.setObjectName("btn_output")
|
||||
self.horizontalLayout_3.addWidget(self.btn_output)
|
||||
@ -108,5 +111,6 @@ class Ui_Dialog(object):
|
||||
self.label.setText(_translate("Dialog", "TextLabel"))
|
||||
self.btn_analysis.setText(_translate("Dialog", "统计信息"))
|
||||
self.btn_emotion.setText(_translate("Dialog", "情感分析"))
|
||||
self.btn_report.setText(_translate("Dialog", "生成年度报告"))
|
||||
self.btn_output.setText(_translate("Dialog", "导出聊天记录"))
|
||||
self.btn_back.setText(_translate("Dialog", "退出"))
|
||||
|
@ -196,6 +196,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_report">
|
||||
<property name="text">
|
||||
<string>生成年度报告</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_output">
|
||||
<property name="text">
|
||||
|
0
app/Ui/contact/report/__init__.py
Normal file
0
app/Ui/contact/report/__init__.py
Normal file
69
app/Ui/contact/report/report.py
Normal file
69
app/Ui/contact/report/report.py
Normal file
@ -0,0 +1,69 @@
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
|
||||
class ReportController(QWidget):
|
||||
def __init__(self, username, parent=None):
|
||||
super().__init__(parent)
|
||||
self.ta_username = username
|
||||
|
||||
# self.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
|
||||
# 加载动画
|
||||
self.center()
|
||||
self.label_01()
|
||||
|
||||
def center(self): # 定义一个函数使得窗口居中显示
|
||||
# 获取屏幕坐标系
|
||||
screen = QDesktopWidget().screenGeometry()
|
||||
# 获取窗口坐标系
|
||||
size = self.geometry()
|
||||
newLeft = (screen.width() - size.width()) / 2
|
||||
newTop = (screen.height() - size.height()) / 2
|
||||
self.move(int(newLeft), int(newTop))
|
||||
|
||||
def label_01(self):
|
||||
w = self.size().width()
|
||||
h = self.size().height()
|
||||
self.label = QLabel(self)
|
||||
self.label.setGeometry(w // 2, h // 2, 100, 100)
|
||||
self.label.setToolTip("这是一个标签")
|
||||
# self.m_movie()
|
||||
self.initUI()
|
||||
|
||||
def m_movie(self):
|
||||
movie = QMovie("./app/data/bg.gif")
|
||||
self.label.setMovie(movie)
|
||||
movie.start()
|
||||
|
||||
def initUI(self):
|
||||
self.label.setVisible(False)
|
||||
# self.setStyleSheet('''QWidget{background-color:rgb(244, 244, 244);}''')
|
||||
main_box = QHBoxLayout(self)
|
||||
self.browser1 = QWebEngineView()
|
||||
self.browser1.load(QUrl('file:///data/AnnualReport/index.html'))
|
||||
# self.browser1.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
|
||||
|
||||
splitter1 = QSplitter(Qt.Vertical)
|
||||
|
||||
splitter1.addWidget(self.browser1)
|
||||
main_box.addWidget(splitter1)
|
||||
self.setLayout(main_box)
|
||||
|
||||
def setBackground(self):
|
||||
palette = QPalette()
|
||||
pix = QPixmap("./app/data/bg.png")
|
||||
pix = pix.scaled(self.width(), self.height(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation) # 自适应图片大小
|
||||
palette.setBrush(self.backgroundRole(), QBrush(pix)) # 设置背景图片
|
||||
# palette.setColor(self.backgroundRole(), QColor(192, 253, 123)) # 设置背景颜色
|
||||
self.setPalette(palette)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
ex = ReportController(1)
|
||||
ex.show()
|
||||
sys.exit(app.exec_())
|
Loading…
Reference in New Issue
Block a user