Commit e66f93ce authored by 李明杰's avatar 李明杰

Final document

parent 2e09f51f
#!/bin/bash
#set env
export PATH=$PATH:/bin:/sbin:/usr/sbin
function sortfile() {
logfile1=/home/work/semantic_platform_DAS/bottom_function/data
logfile1_1=${logfile1}/semantic/m1
logfile1_2=${logfile1}/semantic/m1_1
logfile2=/home/work/logfile/ctoc/unisound
logfile2_1=${logfile1}/semantic/m2
logfile3=${logfile1}/semantic/unorder/unisoundCtoC_logfile_`date +%Y%m%d`
logfile4=${logfile1}/semantic/order/semantic.txt
logfile5=${logfile1}/semantic/order/semantic_`date +%Y%m%d`
[ -d "${logfile1_1}" ] || mkdir -p "${logfile1_1}"
[ -d "${logfile1_2}" ] || mkdir -p "${logfile1_2}"
[ -d "${logfile2_1}" ] || mkdir -p "${logfile2_1}"
[ -d "${logfile1}/semantic/unorder" ] || mkdir -p "${logfile1}/semantic/unorder"
[ -d "${logfile1}/semantic/order" ] || mkdir -p "${logfile1}/semantic/order"
[ -f "${logfile3}" ] || touch "${logfile3}"
[ -f "${logfile4}" ] || touch "${logfile4}"
[ -f "${logfile5}" ] || touch "${logfile5}"
[ -f "${logfile1_2}/unisoundCtoC_logfile_`date +%Y%m%d`" ] || touch "${logfile1_2}/unisoundCtoC_logfile_`date +%Y%m%d`"
[ -f "${logfile2_1}/unisoundCtoC_logfile_`date +%Y%m%d`" ] || touch "${logfile2_1}/unisoundCtoC_logfile_`date +%Y%m%d`"
rsync -av root@10.7.19.130::testlogs ${logfile1_1} --password-file=/etc/rsync.password >/dev/null
touch /tmp/temp
temp=/tmp/temp
diff ${logfile1_2}/unisoundCtoC_logfile_`date +%Y%m%d` ${logfile1_1}/unisoundCtoC_logfile_`date +%Y%m%d` | grep ">"|awk -F "> " '{print $2}' > ${temp}
rsync -av ${logfile1_1}/unisoundCtoC_logfile_`date +%Y%m%d` ${logfile1_2}/unisoundCtoC_logfile_`date +%Y%m%d` >/dev/null
cat ${temp} >>${logfile1_2}/unisoundCtoC_logfile_`date +%Y%m%d`
cat /dev/null>${logfile3}
cat ${temp} >> ${logfile3}
diff ${logfile2_1}/unisoundCtoC_logfile_`date +%Y%m%d` ${logfile2}/unisoundCtoC_logfile_`date +%Y%m%d` | grep ">"|awk -F "> " '{print $2}' > ${temp}
rsync -av ${logfile2}/unisoundCtoC_logfile_`date +%Y%m%d` ${logfile2_1}/unisoundCtoC_logfile_`date +%Y%m%d` >/dev/null
cat ${temp} >>${logfile2_1}/unisoundCtoC_logfile_`date +%Y%m%d`
cat ${temp} >> ${logfile3}
#sed 'N;s#\n#,#g' ${logfile3}
if [ -s ${logfile3} ]
then
paste -sd ',\n' ${logfile3} | sort -u > ${logfile4}
else
echo 0
exit 1
fi
lastEndTime=`tail -1 ${logfile5} |awk -F "(])|( request)" '{print $2} '`
newStartTime=`head -1 ${logfile4} |awk -F "(])|( request)" '{print $2} '`
t1=`date -d "${lastEndTime}" +%s`
t2=`date -d "${newStartTime}" +%s`
if [ ! -s ${logfile5} ]
then
cat ${logfile4}>>${logfile5}
else
[ ${t1} -lt ${t2} ] && cat ${logfile4}>>${logfile5}||echo "no new logfiles"
fi
find ${logfile1}/semantic/order -name "unisoundCtoC_logfile_*" -type f -mtime +30|xargs rm -f
echo ${logfile4}
}
sortfile
...@@ -9,7 +9,7 @@ import jieba.posseg as psg ...@@ -9,7 +9,7 @@ import jieba.posseg as psg
def get_stopword_list(): def get_stopword_list():
# 停用词表存储路径,每一行为一个词,按行读取进行加载 # 停用词表存储路径,每一行为一个词,按行读取进行加载
# 进行编码转换确保匹配准确率 # 进行编码转换确保匹配准确率
stop_word_path = './data/HGDstopwords.txt' stop_word_path = '/home/work/semantic_platform_DAS/bottom_function/data/HGDstopwords.txt'
stopword_list = [sw.replace('\n', '') for sw in open(stop_word_path, encoding='UTF-8').readlines()] stopword_list = [sw.replace('\n', '') for sw in open(stop_word_path, encoding='UTF-8').readlines()]
return stopword_list return stopword_list
...@@ -40,7 +40,7 @@ def word_filter(seg_list, pos=False): ...@@ -40,7 +40,7 @@ def word_filter(seg_list, pos=False):
if not flag.startswith('n'): if not flag.startswith('n'):
continue continue
# 过滤停用词表中的词,以及长度为<2的词 # 过滤停用词表中的词,以及长度为<2的词
if not word in stopword_list and len(word) > 0: if not word in stopword_list and len(word) > 2:
filter_list.append(word) filter_list.append(word)
return filter_list return filter_list
......
#coding=utf-8
import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
import matplotlib.pyplot as plt
from sklearn.manifold import MDS
from sklearn.metrics.pairwise import cosine_similarity
import random
from matplotlib.font_manager import FontProperties
from sklearn.cluster import KMeans
from sklearn import metrics
from collections import Counter
from scipy.cluster.hierarchy import ward, dendrogram
import bottom_function.normalization as normalization
import bottom_function.m_SQL as qb
# import json
# from flask import Flask
# from flask import request
# from flask_cors import CORS
class Culter:
def __init__(self, start_time, end_time):
self.start_time = start_time
self.end_time = end_time
csv_data = pd.DataFrame()
self.chat_data = pd.DataFrame()
tablename = "semantic_data_table"
db = qb.Schema(host="localhost", user="560193", password="jay560193", mysqlName="semantic_data_schema",
port="3306")
csv_data = db.getData(tableName=tablename, startTime=start_time, endTime=end_time)
self.chat_data = csv_data[(csv_data['domain'] == 'chat')]
# self.chat_data.drop_duplicates(subset=['query'], inplace=True)
# self.chat_data.dropna(subset=['query'], inplace=True)
self.out_data = '' # 写入分析结果
self.feature_names = []
self.f_sse = []
self.feature_matrix = np.matrix([])
def build_feature_matrix(self, documents, feature_type, ngram_range, min_df, max_df):
feature_type = feature_type.lower().strip()
if feature_type == 'binary':
vectorizer = CountVectorizer(binary=True,
max_df=max_df, ngram_range=ngram_range)
elif feature_type == 'frequency':
vectorizer = CountVectorizer(binary=False, min_df=min_df,
max_df=max_df, ngram_range=ngram_range)
elif feature_type == 'tfidf':
vectorizer = TfidfVectorizer(token_pattern=r"(?u)\b\w+\b", max_df=max_df)
else:
raise Exception("Wrong feature type entered. Possible values: 'binary', 'frequency', 'tfidf'")
feature_matrix = vectorizer.fit_transform(documents).astype(float)
return vectorizer, feature_matrix
def feature_extraction_data(self):
chat_one = self.chat_data['query'].tolist()
norm_chat_one = normalization.normalize_corpus(chat_one, pos=False)
# 提取 tf-idf 特征
vectorizer, self.feature_matrix = self.build_feature_matrix(norm_chat_one, feature_type='tfidf', min_df=0.2,
max_df=0.90,
ngram_range=(1, 2))
# 查看特征数量)
self.out_data = '聚类分析结果:\n' + '**' * 30
self.out_data = self.out_data + '\n特征数量:\n' + str(self.feature_matrix.shape)
# 获取特征名字
self.feature_names = vectorizer.get_feature_names()
# 打印某些特征
self.out_data = self.out_data + '\n部分特征:\n' + ', '.join(self.feature_names[:5])
def get_cluster_data(self, clustering_obj, m_data, feature_names, num_clusters, topn_features):
cluster_data = {}
# 获取cluster的center
ordered_centroids = clustering_obj.cluster_centers_.argsort()[:, ::-1]
# 获取每个cluster的关键特征
# 获取每个cluster的query
for cluster_num in range(num_clusters):
cluster_data[cluster_num] = {}
cluster_data[cluster_num]['cluster_num'] = cluster_num
key_features = [feature_names[index]
for index
in ordered_centroids[cluster_num, :topn_features]]
cluster_data[cluster_num]['key_features'] = key_features
c_datas = m_data[m_data['Cluster'] == cluster_num]['query'].values.tolist()
cluster_data[cluster_num]['query'] = c_datas
return cluster_data
def print_cluster_data(self, cluster_data):
self.out_data = self.out_data + '\n\n聚类详细数据:\n'
for cluster_num, cluster_details in cluster_data.items():
self.out_data = self.out_data + '\nCluster {} details:\n'.format(cluster_num)
self.out_data = self.out_data + '-' * 20
self.out_data = self.out_data + '\nKey features:\n'
self.out_data = self.out_data + ', '.join(cluster_details['key_features'])
self.out_data = self.out_data + '\ndata in this cluster:\n'
self.out_data = self.out_data + ', '.join(cluster_details['query'])
self.out_data = self.out_data + '\n' + '=' * 40
def plot_clusters(self, feature_matrix, cluster_data, m_data, plot_size):
def generate_random_color(): # generate random color for clusters
color = '#%06x' % random.randint(0, 0xFFFFFF)
return color
# define markers for clusters
markers = ['o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd']
# build cosine distance matrix
cosine_distance = 1 - cosine_similarity(feature_matrix)
# dimensionality reduction using MDS
mds = MDS(n_components=2, dissimilarity="precomputed",
random_state=1)
# get coordinates of clusters in new low-dimensional space
plot_positions = mds.fit_transform(cosine_distance)
x_pos, y_pos = plot_positions[:, 0], plot_positions[:, 1]
# build cluster plotting data
cluster_color_map = {}
cluster_name_map = {}
# print(cluster_data)
for cluster_num, cluster_details in cluster_data.items():
# assign cluster features to unique label
cluster_color_map[cluster_num] = generate_random_color()
cluster_name_map[cluster_num] = ', '.join(cluster_details['key_features'][:5]).strip()
# map each unique cluster label with its coordinates and books
cluster_plot_frame = pd.DataFrame({'x': x_pos,
'y': y_pos,
'label': m_data['Cluster'].values.tolist(),
'query': m_data['query'].values.tolist()
})
grouped_plot_frame = cluster_plot_frame.groupby('label')
# set plot figure size and axes
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
matplotlib.rcParams['font.family'] = 'sans-serif'
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
fig, ax = plt.subplots(figsize=plot_size)
ax.margins(0.05)
# plot each cluster using co-ordinates and titles
for cluster_num, cluster_frame in grouped_plot_frame:
marker = markers[cluster_num] if cluster_num < len(markers) \
else np.random.choice(markers, size=1)[0]
ax.plot(cluster_frame['x'], cluster_frame['y'],
marker=marker, linestyle='', ms=12,
label=cluster_name_map[cluster_num],
color=cluster_color_map[cluster_num], mec='none')
ax.set_aspect('auto')
ax.tick_params(axis='x', which='both', bottom=False, top=False,
labelbottom='off')
ax.tick_params(axis='y', which='both', left=False, top=False,
labelleft=False)
fontP = FontProperties()
fontP.set_size(23)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.01), fancybox=True,
shadow=True, ncol=5, numpoints=1, prop=fontP)
# add labels as the film titles
for index in range(len(cluster_plot_frame)):
ax.text(cluster_plot_frame.ix[index]['x'], cluster_plot_frame.ix[index]['y'],
cluster_plot_frame.ix[index]['query'], size=20)
# show the plot
plt.title(self.start_time + ' to ' + self.end_time + 'chat data cluster point set', fontsize=25)
path = '/roobo/soft/phpmyadmin/cluster_point.jpg'
plt.savefig(path)
return 'http://120.79.171.145:8000/cluster_point.jpg'
def k_means(self, feature_matrix):
f_sse = []
num_clusters = []
for i in range(2, 21):
km = KMeans(n_clusters=i, max_iter=10000)
km.fit(feature_matrix)
clusters = km.labels_
num_matrix = feature_matrix.todense()
sse = metrics.calinski_harabaz_score(num_matrix, clusters)
num_clusters.append(i)
f_sse.append(sse)
pd_see = pd.Series(f_sse, index=num_clusters)
pct_see = pd_see.pct_change()
fig, ax = plt.subplots(figsize=(10, 8))
ax.plot(num_clusters, f_sse, 'o-', c='orangered', label='clustering quality')
plt.legend(loc=2)
plt.xticks(num_clusters)
ax.set_xlabel("cluster number")
ax.set_ylabel("coefficient")
ax1 = ax.twinx()
ax1.plot(pct_see.values, 'o-', c='blue', label='gradient change')
ax1.set_ylabel("gradient")
plt.legend(loc=1)
plt.title(self.start_time + " to " + self.end_time + " the analysis of clusters with different numbers", fontsize=12)
path = '/roobo/soft/phpmyadmin/choice_num.jpg'
plt.savefig(path)
# input_num = input('输入最优聚类数目:')
# best_num = int(input_num)
self.f_sse = f_sse
return 'http://120.79.171.145:8000/choice_num.jpg'
def k_means_cluster(self, best_num):
self.out_data = self.out_data + '\n' + "=" * 20
self.out_data = self.out_data + "\n\n聚类效果分析:\n"
self.out_data = self.out_data + "\n聚类数目为:" + str(best_num)
f_sse = self.f_sse
sse = f_sse[best_num]
km = KMeans(n_clusters=best_num, max_iter=10000)
km.fit(self.feature_matrix)
clusters = km.labels_
self.chat_data['Cluster'] = clusters
# 获取每个cluster的数量
c = Counter(clusters)
sort_c = sorted(c.items(), key=lambda c: c[0], reverse=False)
c.clear()
for key, value in sort_c:
c[key] = value
self.out_data = self.out_data + '\nCalinski-Harabasz分数:' + str(sse)
self.out_data = self.out_data + '\n每个特征的数据量:\n'
self.out_data = self.out_data + (str(c.items()))
self.out_data = self.out_data + '\n' + "=" * 20
cluster_data = self.get_cluster_data(clustering_obj=km,
m_data=self.chat_data,
feature_names=self.feature_names,
num_clusters=best_num,
topn_features=5)
self.print_cluster_data(cluster_data)
path = self.plot_clusters(feature_matrix=self.feature_matrix, cluster_data=cluster_data, m_data=self.chat_data,
plot_size=(40, 25))
return path
def ward_hierarchical_clustering(self, feature_matrix):
cosine_distance = 1 - cosine_similarity(feature_matrix)
linkage_matrix = ward(cosine_distance)
return linkage_matrix
def plot_hierarchical_clusters(self, linkage_matrix, m_data, figure_size):
# set size
fig, ax = plt.subplots(figsize=figure_size)
m_titles = m_data['query'].values.tolist()
# plot dendrogram
ax = dendrogram(linkage_matrix, orientation="left", labels=m_titles)
plt.tick_params(axis='x',
which='both',
bottom=False,
top=False,
labelbottom=False)
plt.tight_layout()
plt.title(self.start_time + ' to ' + self.end_time + 'chat data ward hierachical clusters',fontsize=12)
path = '/roobo/soft/phpmyadmin/hierachical_clusters.jpg'
plt.savefig(path)
return 'http://120.79.171.145:8000/hierachical_clusters.jpg'
# app = Flask(__name__)
# CORS(app, supports_credentials=True)
#
# data_cluster = Culter(start_time="2018-12-01 00:00:00", end_time="2018-12-02 00:00:00")
#
#
# @app.route('/SPDAS/chat_function_analysis/choice1', methods=['POST'])
# def choice():
# param = ({"time": "2018-12-01 00:00:00/2018-12-02 00:00:00"})
# return json.JSONEncoder().encode(param)
#
#
# @app.route('/SPDAS/chat_function_analysis/choice2', methods=['POST'])
# def choice_form():
# # 需要从request对象读取表单内容:
# data = request.get_data()
# json_re = json.loads(data)
#
# m_time = json_re['time']
# str_time = str(m_time)
# m_time = str_time.split('/')
# starttime = m_time[0]
# endtime = m_time[1]
# data_cluster = Culter(start_time=starttime, end_time=endtime)
# data_cluster.feature_extraction_data()
# image_path = data_cluster.k_means(data_cluster.feature_matrix)
# path = ({"num_image": image_path})
# return json.JSONEncoder().encode(path)
#
#
# @app.route('/SPDAS/chat_function_analysis/chat1', methods=['POST'])
# def chat():
# param = ({"best_num": "2"})
# return json.JSONEncoder().encode(param)
#
#
# @app.route('/SPDAS/chat_function_analysis/chat2', methods=['POST'])
# def chat_form():
# # 需要从request对象读取表单内容:
# data = request.get_data()
# json_re = json.loads(data)
# bestnum = json_re['best_num']
# image_path1 = data_cluster.k_means_cluster(best_num=bestnum)
#
# linkage_matrix = data_cluster.ward_hierarchical_clustering(data_cluster.feature_matrix)
#
# image_path2 = data_cluster.plot_hierarchical_clusters(linkage_matrix=linkage_matrix, m_data=data_cluster.chat_data,
# figure_size=(35, 40))
# with open("/roobo/soft/phpmyadmin/chat_function_data.txt", 'w') as file:
# file.writelines(data_cluster.out_data)
#
# path = ({"cluster_point": image_path1, "ward_image": image_path2})
# return json.JSONEncoder().encode(path)
#
#
# if __name__ == '__main__':
# app.run(debug=True, host='10.7.19.129', port=5000)
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import bottom_function.data_read as dr import bottom_function.data_read as dr
import json
from flask import Flask # import json
from flask import request # from flask import Flask
from flask_cors import CORS # from flask import request
# from flask_cors import CORS
def data_statistics_plot(datatype, starttime, endtime, graphtype): def data_statistics_plot(datatype, starttime, endtime, graphtype):
...@@ -24,7 +25,7 @@ def data_statistics_plot(datatype, starttime, endtime, graphtype): ...@@ -24,7 +25,7 @@ def data_statistics_plot(datatype, starttime, endtime, graphtype):
# m_data.dropna(inplace=True) # m_data.dropna(inplace=True)
m_data.sort_values(ascending=False, inplace=True) m_data.sort_values(ascending=False, inplace=True)
m_data = m_data[m_data.values != 0] m_data = m_data[m_data.values != 0]
fig = plt.figure(figsize=(10, 6)) plt.figure(figsize=(10, 8))
if graphtype == 'pie': if graphtype == 'pie':
e = [] e = []
...@@ -60,49 +61,49 @@ def data_statistics_plot(datatype, starttime, endtime, graphtype): ...@@ -60,49 +61,49 @@ def data_statistics_plot(datatype, starttime, endtime, graphtype):
plt.xticks(rotation=45) plt.xticks(rotation=45)
plt.ylabel('Number', fontsize=12, labelpad=5) plt.ylabel('Number', fontsize=12, labelpad=5)
for x, y in zip(range(len(num_list)), num_list): for x, y in zip(range(len(num_list)), num_list):
plt.text(x, y, '%d' % y, ha='left', va='center', fontsize=9) plt.text(x, y, '%d' % y, ha='left', va='center', fontsize=12)
else: else:
m_data.plot(kind=graphtype, use_index=True) m_data.plot(kind=graphtype, use_index=True)
plt.title(str(starttime) + ' to ' + str(endtime) + ' semantic domain analysis of ' + graphtype + ' graph', plt.title(str(starttime) + ' to ' + str(endtime) + ' semantic domain analysis of ' + graphtype + ' graph',
fontsize=12) fontsize=15)
plt.tight_layout(5) plt.tight_layout(5)
path = '/roobo/soft/phpmyadmin/plot_domain.jpg' path = '/roobo/soft/phpmyadmin/plot_domain.jpg'
plt.savefig(path) plt.savefig(path)
return path return 'http://120.79.171.145:8000/plot_domain.jpg'
app = Flask(__name__)
CORS(app, supports_credentials=True)
@app.route('/SPDAS/domain_structure_analysis1', methods=['POST'])
def domain():
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
"time": "2018-12-01 00:00:00/2018-12-02 00:00:00",
"graph_type": [{"value": "bar"}, {"value": "pie"}]})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/domain_structure_analysis2', methods=['POST']) # app = Flask(__name__)
def domain_form(): # CORS(app, supports_credentials=True)
# 需要从request对象读取表单内容: #
data = request.get_data() #
json_re = json.loads(data) # @app.route('/SPDAS/domain_structure_analysis1', methods=['POST'])
print(json_re) # def domain():
datatype = json_re['data_type'] # param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
m_time = json_re['time'] # "time": "2018-12-01 00:00:00/2018-12-02 00:00:00",
graphtype = json_re['graph_type'] # "graph_type": [{"value": "bar"}, {"value": "pie"}]})
str_time = str(m_time) # return json.JSONEncoder().encode(param)
m_time = str_time.split('/') #
starttime = m_time[0] #
endtime = m_time[1] # @app.route('/SPDAS/domain_structure_analysis2', methods=['POST'])
image_path = data_statistics_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype) # def domain_form():
path = ({"domain_image": image_path}) # # 需要从request对象读取表单内容:
return json.JSONEncoder().encode(path) # data = request.get_data()
# json_re = json.loads(data)
# print(json_re)
if __name__ == '__main__': # datatype = json_re['data_type']
app.run(debug=True, host='10.7.19.129', port=5000) # m_time = json_re['time']
# graphtype = json_re['graph_type']
# str_time = str(m_time)
# m_time = str_time.split('/')
# starttime = m_time[0]
# endtime = m_time[1]
# image_path = data_statistics_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype)
# path = ({"domain_image": image_path})
# return json.JSONEncoder().encode(path)
#
#
# if __name__ == '__main__':
# app.run(debug=True, host='10.7.19.129', port=5000)
# str_time = str('2018.12.01 00:00:00/2018.12.02 00:00:00') # str_time = str('2018.12.01 00:00:00/2018.12.02 00:00:00')
# m_time = str_time.split('/') # m_time = str_time.split('/')
......
This diff is collapsed.
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# author:Li Mingjie time:2019/1/24 # author:Li Mingjie time:2019/1/24
# Brief:process unisound logfile # Brief:process unisound logfile
...@@ -9,13 +9,16 @@ import threading ...@@ -9,13 +9,16 @@ import threading
import bottom_function.m_SQL as qb import bottom_function.m_SQL as qb
import datetime as dt import datetime as dt
import paramiko import paramiko
import os
import time
import bottom_function.data_read as dr
class timing_processing: class timing_processing:
def __init__(self): def __init__(self):
self.data = pd.DataFrame() self.data = pd.DataFrame()
self.datetime = pd.Timestamp("2019-01-01 00:00:00") self.datetime = pd.Timestamp("2019-01-01 00:00:00")
self.db = qb.Schema(host="localhost", user="root", password="560193", mysqlName="semantic_data_schema", self.db = qb.Schema(host="localhost", user="560193", password="jay560193", mysqlName="semantic_data_schema",
port="3306") port="3306")
self.gree_list = ["aircleaner", "airconditioner", "airconditionerfan", "airsteward", "curtain", self.gree_list = ["aircleaner", "airconditioner", "airconditionerfan", "airsteward", "curtain",
"dehumidifier", "disinfection", "fanner", "furnace", "humidifier", "playcontrol", "dehumidifier", "disinfection", "fanner", "furnace", "humidifier", "playcontrol",
...@@ -27,7 +30,10 @@ class timing_processing: ...@@ -27,7 +30,10 @@ class timing_processing:
"recipe", "science", "sound", "sports", "stock", "translate", "weather"] "recipe", "science", "sound", "sports", "stock", "translate", "weather"]
def data_storage(self): def data_storage(self):
data = open('./data/unisound_logfile', 'r', encoding='utf-8').readlines() os.system("sh /home/work/semantic_platform_DAS/bottom_function/data/sortLog.sh")
data = open('/home/work/semantic_platform_DAS/bottom_function/data/semantic/order/semantic.txt', 'r', encoding='utf-8').readlines()
if len(data) == 0:
print("data is null")
datetime_data = [] datetime_data = []
macwifi_data = [] macwifi_data = []
...@@ -41,6 +47,8 @@ class timing_processing: ...@@ -41,6 +47,8 @@ class timing_processing:
costtime_data = [] costtime_data = []
error_data = [] error_data = []
error_num = []
n = 1
for line_data in data: for line_data in data:
if line_data == '': if line_data == '':
continue continue
...@@ -56,7 +64,10 @@ class timing_processing: ...@@ -56,7 +64,10 @@ class timing_processing:
# data1 = data1.replace('\\', '') # data1 = data1.replace('\\', '')
data1 = data1.replace('response:', '"response":').replace('costtime:', ',"costtime":"') data1 = data1.replace('response:', '"response":').replace('costtime:', ',"costtime":"')
data1 = data1.replace('\t', '') data1 = data1.replace('\t', '')
try:
js_data = json.loads(data1) js_data = json.loads(data1)
except:
error_data.append(line_data)
try: try:
dom = 'null' dom = 'null'
...@@ -118,40 +129,46 @@ class timing_processing: ...@@ -118,40 +129,46 @@ class timing_processing:
costtime_data.append(m_cost) costtime_data.append(m_cost)
except: except:
error_data.append(line_data) error_data.append(line_data)
error_num.append(n)
n += 1
outdata = pd.DataFrame( outdata = pd.DataFrame(
{'datetime': datetime_data, 'mac_wifi': macwifi_data, 'mac_voice': macvoice_data, {'datetime': datetime_data, 'mac_wifi': macwifi_data, 'mac_voice': macvoice_data,
'query': query_data, 'classify': classify_data, 'code': code_data, 'query': query_data, 'classify': classify_data, 'code': code_data,
'domain': domain_data, 'intent': intent_data, 'response_data': response_data, 'domain': domain_data, 'intent': intent_data, 'response_data': response_data,
'cost_time_ms': costtime_data}) 'cost_time_ms': costtime_data})
errordata = pd.DataFrame({'data': error_data}) #errordata = pd.DataFrame({'num': error_num, 'data': error_data})
outdata['datetime'] = pd.to_datetime(outdata['datetime']) outdata['datetime'] = pd.to_datetime(outdata['datetime'])
outdata = outdata.sort_values(by=['datetime']) outdata = outdata.sort_values(by=['datetime'])
self.datetime = dt.datetime.strftime(outdata['datetime'][0], "%Y-%m-%d %H ") # print(outdata['datetime'])
self.datetime = time.strftime("%Y-%m-%d %H ", time.localtime(time.time()))
outdata = outdata.set_index('datetime') outdata = outdata.set_index('datetime')
self.data = outdata self.data = outdata
control_error_data = outdata[(outdata['classify'] == 'control') & (outdata['code'] != 0)] control_error_data = outdata[(outdata['classify'] == 'control') & (outdata['code'] != 0)]
application_error_data = outdata[(outdata['classify'] == 'application') & (outdata['code'] != 0)] application_error_data = outdata[(outdata['classify'] == 'application') & (outdata['code'] != 0)]
control_error_data.drop_duplicates(subset='query', keep='first', inplace=True)
application_error_data.drop_duplicates(subset='query', keep='first', inplace=True) # control_error_data.drop_duplicates(subset='query', keep='first', inplace=True)
# application_error_data.drop_duplicates(subset='query', keep='first', inplace=True)
self.db.dataframeToMysql(data=outdata, tableName="semantic_data_table") self.db.dataframeToMysql(data=outdata, tableName="semantic_data_table")
self.db.dataframeToMysql(data=errordata, tableName="error_format_data")
self.db.dataframeToMysql(data=control_error_data, tableName="control_error_data") self.db.dataframeToMysql(data=control_error_data, tableName="control_error_data")
self.db.dataframeToMysql(data=application_error_data, tableName="application_error_data") self.db.dataframeToMysql(data=application_error_data, tableName="application_error_data")
#errordata.to_csv('./bottom_function/data/fromat_error_data.csv')
print('storage the data to SQL is complete') # self.domain_data_to_statistics(control_data, data_type="control")
# self.domain_data_to_statistics(application_data, data_type="application")
# self.costtime_data_to_statistics(outdata)
# timer=threading.Timer(3600,data_storage) print('storage the data to SQL is complete')
# timer.start()
def domain_data_to_statistics(self, data, data_type): def domain_data_to_statistics(self, data, data_type):
print('Start domain data classification:') print('Start domain data classification:')
data_dict_domain = {} data_dict_domain = {}
if data_type == 'control': if data_type == 'control':
data_dict_domain = {"datetime": pd.Timestamp(2019, 1, 1), "aircleaner": 0, "airconditioner": 0, data_dict_domain = {"datetime": self.datetime, "aircleaner": 0, "airconditioner": 0,
"airconditionerfan": 0, "airsteward": 0, "curtain": 0, "dehumidifier": 0, "airconditionerfan": 0, "airsteward": 0, "curtain": 0, "dehumidifier": 0,
"disinfection": 0, "fanner": 0, "furnace": 0, "humidifier": 0, "playcontrol": 0, "disinfection": 0, "fanner": 0, "furnace": 0, "humidifier": 0, "playcontrol": 0,
"refrigerator": 0, "ricecooker": 0, "refrigerator": 0, "ricecooker": 0,
...@@ -163,7 +180,7 @@ class timing_processing: ...@@ -163,7 +180,7 @@ class timing_processing:
domain_list = self.gree_list domain_list = self.gree_list
elif data_type == 'application': elif data_type == 'application':
data_dict_domain = {"datetime": pd.Timestamp(2019, 1, 1), "almanac": 0, "ancient_poem": 0, "astro": 0, data_dict_domain = {"datetime": self.datetime, "almanac": 0, "ancient_poem": 0, "astro": 0,
"baike": 0, "chat": 0, "chengyu": 0, "common_qa": 0, "finance": 0, "fm": 0, "food": 0, "baike": 0, "chat": 0, "chengyu": 0, "common_qa": 0, "finance": 0, "fm": 0, "food": 0,
"general_question_answering": 0, "history": 0, "holiday": 0, "joke": 0, "music": 0, "general_question_answering": 0, "history": 0, "holiday": 0, "joke": 0, "music": 0,
"news": 0, "recipe": 0, "science": 0, "sound": 0, "sports": 0, "stock": 0, "news": 0, "recipe": 0, "science": 0, "sound": 0, "sports": 0, "stock": 0,
...@@ -186,7 +203,7 @@ class timing_processing: ...@@ -186,7 +203,7 @@ class timing_processing:
if domain_data not in domain_list: if domain_data not in domain_list:
if data_type == 'control': if data_type == 'control':
self.gree_list.append(domain_data) self.gree_list.append(domain_data)
if data_type == 'control': if data_type == 'application':
self.tencent_list.append(domain_data) self.tencent_list.append(domain_data)
self.db.setAddField(tableName=table_name, field=domain_data) self.db.setAddField(tableName=table_name, field=domain_data)
...@@ -205,7 +222,7 @@ class timing_processing: ...@@ -205,7 +222,7 @@ class timing_processing:
gree_list = self.gree_list gree_list = self.gree_list
tencent_list = self.tencent_list tencent_list = self.tencent_list
all_data_dict = {"datetime": pd.Timestamp(2019, 1, 1), "0~500ms": "0", "500~1000ms": "0", "1000~2000ms": "0", all_data_dict = {"datetime": self.datetime, "0~500ms": "0", "500~1000ms": "0", "1000~2000ms": "0",
"2000~3000ms": "0", "3000~5000ms": "0", "morethan5000ms": "0", } "2000~3000ms": "0", "3000~5000ms": "0", "morethan5000ms": "0", }
all_tencent_dict = {} all_tencent_dict = {}
...@@ -213,8 +230,8 @@ class timing_processing: ...@@ -213,8 +230,8 @@ class timing_processing:
gree_data_dict = {} gree_data_dict = {}
tencent_data_dict = {} tencent_data_dict = {}
tencent_data = data[data['classify'] == 'tencent'] tencent_data = data[data['classify'] == 'application']
gree_data = data[data['classify'] == 'gree'] gree_data = data[data['classify'] == 'control']
for dom1 in tencent_list: for dom1 in tencent_list:
num1 = tencent_data.loc[(tencent_data['cost_time_ms'] >= 0) & (tencent_data['cost_time_ms'] < 500) & ( num1 = tencent_data.loc[(tencent_data['cost_time_ms'] >= 0) & (tencent_data['cost_time_ms'] < 500) & (
tencent_data['domain'] == dom1), ['domain', 'cost_time_ms']].domain.count() tencent_data['domain'] == dom1), ['domain', 'cost_time_ms']].domain.count()
...@@ -374,17 +391,33 @@ class timing_processing: ...@@ -374,17 +391,33 @@ class timing_processing:
def run(self): def run(self):
self.data_storage() self.data_storage()
controldata = self.data[(self.data['classify'] == 'gree') & (self.data['code'] == 0)] pr_datetime = time.strftime("%Y-%m-%d %H ", time.localtime(time.time() - 3600))
applicationdata = self.data[(self.data['classify'] == 'tencent') & (self.data['code'] == 0)] pr_datetime = str(pd.to_datetime(pr_datetime))
nw_datetime = str(pd.to_datetime(self.datetime))
print("时间为:### %s" % pr_datetime)
print("时间为:### %s" % nw_datetime)
cdata = dr.read_data(datatype='control', starttime=pr_datetime, endtime=nw_datetime)
adata = dr.read_data(datatype='application', starttime=pr_datetime, endtime=nw_datetime)
print("all****%d\n" % (len(cdata)))
print("all****%d\n" % (len(adata)))
controldata = cdata[cdata['code'] == 0]
applicationdata = adata[adata['code'] == 0]
print("****%d\n" % (len(controldata)))
print("****%d\n" % (len(applicationdata)))
self.domain_data_to_statistics(data=controldata, data_type="control") self.domain_data_to_statistics(data=controldata, data_type="control")
self.domain_data_to_statistics(data=applicationdata, data_type="application") self.domain_data_to_statistics(data=applicationdata, data_type="application")
self.costtime_data_to_statistics(data=self.data) self.costtime_data_to_statistics(data=self.data)
# TP = timing_processing() def load_run():
# TP.run() print ("*****datetime:")
# timer = threading.Timer(20, TP.run) print(time.strftime("%Y-%m-%d %H ", time.localtime(time.time())))
# timer.start() print ("*****\n")
TP = timing_processing()
TP.run()
load_run()
# st = pd.Timestamp("2018-12-01 00:00:00") # st = pd.Timestamp("2018-12-01 00:00:00")
# et = pd.Timestamp("2019-01-01 00:00:00") # et = pd.Timestamp("2019-01-01 00:00:00")
...@@ -404,5 +437,5 @@ class timing_processing: ...@@ -404,5 +437,5 @@ class timing_processing:
# TP.domain_data_to_statistics(data=applicationdata, data_type="application") # TP.domain_data_to_statistics(data=applicationdata, data_type="application")
# TP.costtime_data_to_statistics(data=data) # TP.costtime_data_to_statistics(data=data)
TP = timing_processing() # TP = timing_processing()
TP.data_storage() # TP.data_storage()
...@@ -2,49 +2,49 @@ ...@@ -2,49 +2,49 @@
# author:Li Mingjie time:2019/3/7 # author:Li Mingjie time:2019/3/7
# Brief: # Brief:
import json # import json
from flask import Flask # from flask import Flask
from flask import request # from flask import request
from flask_cors import CORS # from flask_cors import CORS
import response_time_analysis # import response_time_analysis
import response_error_analysis # import response_error_analysis
#
app = Flask(__name__) # app = Flask(__name__)
CORS(app, supports_credentials=True) # CORS(app, supports_credentials=True)
#
#
@app.route('/SPDAS/response_analysis1', methods=['POST']) # @app.route('/SPDAS/response_analysis1', methods=['POST'])
def domain(): # def domain():
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}], # param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
"effect_type": [{"value": "cost_time"}, {"value": "response_error"}], # "effect_type": [{"value": "cost_time"}, {"value": "response_error"}],
"time": "2018-12-01 00:00:00/2018-12-02 00:00:00"}) # "time": "2018-12-01 00:00:00/2018-12-02 00:00:00"})
return json.JSONEncoder().encode(param) # return json.JSONEncoder().encode(param)
#
#
@app.route('/SPDAS/response_analysis2', methods=['POST']) # @app.route('/SPDAS/response_analysis2', methods=['POST'])
def domain_form(): # def domain_form():
# 需要从request对象读取表单内容: # # 需要从request对象读取表单内容:
data = request.get_data() # data = request.get_data()
json_re = json.loads(data) # json_re = json.loads(data)
datatype = json_re['data_type'] # datatype = json_re['data_type']
#
effecttype = json_re['effect_type'] # effecttype = json_re['effect_type']
m_time = json_re['time'] # m_time = json_re['time']
str_time = str(m_time) # str_time = str(m_time)
m_time = str_time.split('/') # m_time = str_time.split('/')
starttime = m_time[0] # starttime = m_time[0]
endtime = m_time[1] # endtime = m_time[1]
if effecttype == 'cost_time': # if effecttype == 'cost_time':
image_path = response_time_analysis.cost_time_plot(datatype=datatype, starttime=starttime, endtime=endtime) # image_path = response_time_analysis.cost_time_plot(datatype=datatype, starttime=starttime, endtime=endtime)
path = ({"response_image": image_path}) # path = ({"response_image": image_path})
return json.JSONEncoder().encode(path) # return json.JSONEncoder().encode(path)
else: # else:
image_path = response_error_analysis.error_data_statistics_plot(datatype=datatype, starttime=starttime, # image_path = response_error_analysis.error_data_statistics_plot(datatype=datatype, starttime=starttime,
endtime=endtime, # endtime=endtime,
graphtype='bar') # graphtype='bar')
path = ({"response_image": image_path}) # path = ({"response_image": image_path})
return json.JSONEncoder().encode(path) # return json.JSONEncoder().encode(path)
#
#
if __name__ == '__main__': # if __name__ == '__main__':
app.run(debug=True, host='10.7.19.129', port=5000) # app.run(debug=True, host='10.7.19.129', port=5000)
...@@ -4,15 +4,19 @@ ...@@ -4,15 +4,19 @@
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import sys
import bottom_function.data_read as dr import bottom_function.data_read as dr
import cgi
def error_data_statistics_plot(datatype, starttime, endtime, graphtype): def error_data_statistics_plot(datatype, starttime, endtime, graphtype):
if datatype == 'control':
datatype = 'error_control'
else:
datatype = 'error_application'
csv_data = pd.DataFrame() csv_data = pd.DataFrame()
csv_data = dr.read_data(datatype=datatype, starttime=starttime, endtime=endtime) csv_data = dr.read_data(datatype=datatype, starttime=starttime, endtime=endtime)
print(len(csv_data))
csv_data.drop_duplicates(subset='query', keep='first', inplace=True) csv_data.drop_duplicates(subset='query', keep='first', inplace=True)
csv_data = csv_data.reset_index(drop=True)
error_dict = {} error_dict = {}
for i in range(len(csv_data)): for i in range(len(csv_data)):
error_code = "error " + str(csv_data.ix[i]['code']) error_code = "error " + str(csv_data.ix[i]['code'])
...@@ -21,7 +25,7 @@ def error_data_statistics_plot(datatype, starttime, endtime, graphtype): ...@@ -21,7 +25,7 @@ def error_data_statistics_plot(datatype, starttime, endtime, graphtype):
else: else:
error_dict.update({error_code: 1}) error_dict.update({error_code: 1})
fig = plt.figure(figsize=(10, 6)) plt.figure(figsize=(10, 8))
if graphtype == 'pie': if graphtype == 'pie':
e = [] e = []
code_other = 0 code_other = 0
...@@ -54,10 +58,9 @@ def error_data_statistics_plot(datatype, starttime, endtime, graphtype): ...@@ -54,10 +58,9 @@ def error_data_statistics_plot(datatype, starttime, endtime, graphtype):
for x, y in zip(range(len(num_list)), num_list): for x, y in zip(range(len(num_list)), num_list):
plt.text(x, y, '%d' % y, ha='center', va='bottom', fontsize=9) plt.text(x, y, '%d' % y, ha='center', va='bottom', fontsize=9)
plt.title(str(starttime) + ' to ' + str(endtime) + ' semantic domain analysis of ' + graphtype + ' graph', plt.title(str(starttime) + ' to ' + str(endtime) + ' ' + datatype + ' response analysis of ' + graphtype + ' graph',
fontsize=12) fontsize=15)
plt.tight_layout(5) plt.tight_layout(5)
path = '/roobo/soft/phpmyadmin/response_error.jpg' path = '/roobo/soft/phpmyadmin/response_error.jpg'
plt.savefig(path) plt.savefig(path)
return path return 'http://120.79.171.145:8000/response_error.jpg'
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import bottom_function.data_read as dr import bottom_function.data_read as dr
import numpy as np
def cost_time_plot(datatype, starttime, endtime): def cost_time_plot(datatype, starttime, endtime):
cost_time_dict = dr.read_cost_time_data(datatype=datatype, starttime=starttime, endtime=endtime) cost_time_dict = dr.read_cost_time_data(datatype=datatype, starttime=starttime, endtime=endtime)
y_max = 0 y_max = 0
xl_list = list(cost_time_dict.keys()) xl_list = list(cost_time_dict.keys())
fig = plt.figure(figsize=(10, 6)) plt.figure(figsize=(10, 8))
for x in range(6): for x in range(6):
lab_list = [] lab_list = []
...@@ -26,6 +27,8 @@ def cost_time_plot(datatype, starttime, endtime): ...@@ -26,6 +27,8 @@ def cost_time_plot(datatype, starttime, endtime):
plt.bar(x_list, y_list, width=0.2, color=['r', 'g', 'b']) plt.bar(x_list, y_list, width=0.2, color=['r', 'g', 'b'])
for i, j, lab in zip(x_list, y_list, lab_list): for i, j, lab in zip(x_list, y_list, lab_list):
if j == 0:
continue
plt.text(i, j, lab, ha='center', va='bottom', fontsize=9, rotation=70) plt.text(i, j, lab, ha='center', va='bottom', fontsize=9, rotation=70)
# plt.rcParams['font.family'] = ['sans-serif'] # plt.rcParams['font.family'] = ['sans-serif']
# plt.rcParams['font.sans-serif'] = ['SimHei'] # plt.rcParams['font.sans-serif'] = ['SimHei']
...@@ -33,13 +36,13 @@ def cost_time_plot(datatype, starttime, endtime): ...@@ -33,13 +36,13 @@ def cost_time_plot(datatype, starttime, endtime):
plt.ylim(0, y_max * 1.2) plt.ylim(0, y_max * 1.2)
plt.xticks(np.arange(0.5, 6, 1), xl_list) plt.xticks(np.arange(0.5, 6, 1), xl_list)
if datatype == 'application': if datatype == 'application':
plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of application resources', fontsize=12) plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of application resources', fontsize=15)
elif datatype == 'control': elif datatype == 'control':
plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of control resources', fontsize=12) plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of control resources', fontsize=15)
else: else:
plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of all resources', fontsize=12) plt.title(str(starttime) + ' to ' + str(endtime) + ' cost time analysis of all resources', fontsize=15)
plt.tight_layout(5) plt.tight_layout(5)
path = '/roobo/soft/phpmyadmin/response_time.jpg' path = '/roobo/soft/phpmyadmin/response_time.jpg'
plt.savefig(path) plt.savefig(path)
return path return 'http://120.79.171.145:8000/response_time.jpg'
This diff is collapsed.
# -*- coding: utf-8 -*-
# author:Li Mingjie time:2019/3/9
# Brief:
import domain_structure_analysis as DS
import time_series_analysis as TS
import user_portrait_analysis as UP
import chat_function_analysis as CF
import response_time_analysis as RT
import response_error_analysis as RE
import second_test as ST
import json
from flask import Flask, render_template
from flask import request
from flask_cors import CORS
from flask_caching import Cache
import time
import base64
import random
app = Flask(__name__)
CORS(app, supports_credentials=True)
# cache = Cache(app, config={'CACHE_TYPE': 'simple'})
print("*****datetime:")
now_time = time.strftime("%b %d %Y %H:%M:%S", time.localtime(time.time()))
print(now_time)
print("*****\n")
users = {
"admin": "spdas!23"
}
def gen_token(uid):
token = base64.b64encode((':'.join([str(uid), str(random.random()), str(now_time)])).encode('utf-8'))
print("BASE64加密串:\n" + str(token, 'utf-8'))
# users[uid].append(token)
return token
@app.route('/SPDAS', methods=['GET'])
def index():
return render_template('index.html')
@app.route('/SPDAS/login', methods=['POST'])
def login():
data = request.get_data()
json_re = json.loads(data)
username = json_re['user']
password = json_re['password']
if username in users.keys() and password == users[username]:
return gen_token(username)
# gen_token(username)
#return 'yes'
else:
return "error"
@app.route('/SPDAS/domain_structure_analysis1', methods=['POST'])
def domain():
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
"time": "2019-01-01 00:00:00/2019-01-02 00:00:00",
"graph_type": [{"value": "bar"}, {"value": "pie"}],
"image_path": "http://120.79.171.145:8000/plot_domain1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/domain_structure_analysis2', methods=['POST'])
def domain_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
datatype = json_re['data_type']
m_time = json_re['time']
graphtype = json_re['graph_type']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
image_path = DS.data_statistics_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype)
path = ({"domain_image": image_path})
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/time_series_analysis1', methods=['POST'])
def time():
param = ({"time_type": [{"value": "hour", "id": 1}, {"value": "day", "id": 2},
{"value": "month", "id": 3}, {"value": "year", "id": 4}],
"time": "2019-01-01 00:00:00/2019-01-02 00:00:00",
"graph_type": [{"value": "bar"}, {"value": "pie"}],
"image_path": "http://120.79.171.145:8000/plot_time1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/time_series_analysis2', methods=['POST'])
def time_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
timetype = json_re['time_type']
m_time = json_re['time']
graphtype = json_re['graph_type']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
image_path = TS.datetime_data_plot(timetype=timetype, starttime=starttime, endtime=endtime, graphtype=graphtype)
path = ({"time_image": image_path})
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/user_portrait_analysis1', methods=['POST'])
def user():
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "chat"}, {"value": "all"}],
"time": "2019-01-01 00:00:00/2019-01-02 00:00:00",
"image_path": "http://120.79.171.145:8000/plot_user1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/user_portrait_analysis2', methods=['POST'])
def user_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
datatype = json_re['data_type']
m_time = json_re['time']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
image_path = UP.portrait_plot(datatype=datatype, starttime=starttime, endtime=endtime)
path = {"user_image": image_path}
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/chat_function_analysis/choice1', methods=['POST'])
def choice():
param = (
{"time": "2018-12-01 00:00:00/2018-12-28 20:00:00", "image_path": "http://120.79.171.145:8000/choice_num1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/chat_function_analysis/choice2', methods=['POST'])
# @cache.cached(timeout=60 * 30, key_prefix='choice_form')
def choice_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
m_time = json_re['time']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
data_cluster = CF.Culter(start_time=starttime, end_time=endtime)
data_cluster.feature_extraction_data()
image_path = data_cluster.k_means(data_cluster.feature_matrix)
path = ({"num_image": image_path})
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/chat_function_analysis/chat1', methods=['POST'])
def chat():
param = ({"time": "2018-12-01 00:00:00/2018-12-28 20:00:00", "best_num": "1",
"image1_path": "http://120.79.171.145:8000/hierachical_clusters1.jpg",
"image2_path": "http://120.79.171.145:8000/cluster_point1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/chat_function_analysis/chat2', methods=['POST'])
def chat_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
m_time = json_re['time']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
data_cluster = CF.Culter(start_time=starttime, end_time=endtime)
data_cluster.feature_extraction_data()
image_path = data_cluster.k_means(data_cluster.feature_matrix)
charnum = json_re['best_num']
bestnum = int(charnum)
print(bestnum)
image_path1 = data_cluster.k_means_cluster(best_num=bestnum)
linkage_matrix = data_cluster.ward_hierarchical_clustering(data_cluster.feature_matrix)
image_path2 = data_cluster.plot_hierarchical_clusters(linkage_matrix=linkage_matrix, m_data=data_cluster.chat_data,
figure_size=(35, 40))
with open("/roobo/soft/phpmyadmin/chat_function_data.txt", 'w') as file:
file.writelines(data_cluster.out_data)
path = ({"cluster_point": image_path2, "ward_image": image_path1})
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/response_analysis1', methods=['POST'])
def response():
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
"effect_type": [{"value": "cost_time"}, {"value": "response_error"}],
"time": "2019-01-01 00:00:00/2019-01-02 00:00:00",
"image_path": "http://120.79.171.145:8000/response_time1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/response_analysis2', methods=['POST'])
def response_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
datatype = json_re['data_type']
effecttype = json_re['effect_type']
m_time = json_re['time']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
if effecttype == 'cost_time':
image_path = RT.cost_time_plot(datatype=datatype, starttime=starttime, endtime=endtime)
else:
image_path = RE.error_data_statistics_plot(datatype=datatype, starttime=starttime, endtime=endtime,
graphtype='bar')
path = ({"response_image": image_path})
print(image_path)
return json.JSONEncoder().encode(path)
@app.route('/SPDAS/second_test1', methods=['POST'])
def second():
param = ({"data_type": [{"value": "error_control"}, {"value": "error_application"}],
"time": "2019-01-01 00:00:00/2019-01-02 00:00:00",
"graph_type": [{"value": "bar"}, {"value": "pie"}],
"image_path": "http://120.79.171.145:8000/response_error1.jpg"})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/second_test2', methods=['POST'])
def second_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
datatype = json_re['data_type']
m_time = json_re['time']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
graphtype = json_re['graph_type']
image_path = ST.second_test_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype)
path = ({"test_image": image_path})
return json.JSONEncoder().encode(path)
if __name__ == '__main__':
app.run(debug=True, host='10.7.19.129', port=5000)
...@@ -9,9 +9,11 @@ import pandas as pd ...@@ -9,9 +9,11 @@ import pandas as pd
import bottom_function.m_SQL as qb import bottom_function.m_SQL as qb
import bottom_function.data_read as dr import bottom_function.data_read as dr
import json import json
from flask import Flask
from flask import request
from flask_cors import CORS # from flask import Flask
# from flask import request
# from flask_cors import CORS
def second_test(text, classify): def second_test(text, classify):
...@@ -55,10 +57,14 @@ def second_test_plot(datatype, starttime, endtime, graphtype): ...@@ -55,10 +57,14 @@ def second_test_plot(datatype, starttime, endtime, graphtype):
csv_data = dr.read_data(datatype=datatype, starttime=starttime, endtime=endtime) csv_data = dr.read_data(datatype=datatype, starttime=starttime, endtime=endtime)
if datatype == 'error_control': if datatype == 'error_control':
table_name = "control_error_data" table_name = "control_error_data"
classsify = 'control'
elif datatype == 'error_application': elif datatype == 'error_application':
table_name = "application_error_data" table_name = "application_error_data"
classsify = 'application'
db = qb.Schema(host="localhost", user="560193", password="jay560193", mysqlName="semantic_data_schema", port="3306") db = qb.Schema(host="localhost", user="560193", password="jay560193", mysqlName="semantic_data_schema", port="3306")
classsify = csv_data.ix[0]['classify'] csv_data.drop_duplicates(subset='query', keep='first', inplace=True)
csv_data = csv_data.rest_index(drop=True)
error_dict = {} error_dict = {}
for i in range(len(csv_data)): for i in range(len(csv_data)):
# query = str(csv_data.ix[i]['query'].encode('utf-8').decode('utf-8-sig')) # query = str(csv_data.ix[i]['query'].encode('utf-8').decode('utf-8-sig'))
...@@ -78,7 +84,7 @@ def second_test_plot(datatype, starttime, endtime, graphtype): ...@@ -78,7 +84,7 @@ def second_test_plot(datatype, starttime, endtime, graphtype):
else: else:
error_dict.update({error_code: 1}) error_dict.update({error_code: 1})
fig = plt.figure(figsize=(10, 6)) plt.figure(figsize=(10, 8))
if graphtype == 'pie': if graphtype == 'pie':
e = [] e = []
code_other = 0 code_other = 0
...@@ -117,43 +123,42 @@ def second_test_plot(datatype, starttime, endtime, graphtype): ...@@ -117,43 +123,42 @@ def second_test_plot(datatype, starttime, endtime, graphtype):
plt.title( plt.title(
str(starttime) + ' to ' + str(endtime) + ' second test of error response analysis with ' + graphtype + ' graph', str(starttime) + ' to ' + str(endtime) + ' second test of error response analysis with ' + graphtype + ' graph',
fontsize=12) fontsize=15)
plt.tight_layout(5) plt.tight_layout(5)
path = '/roobo/soft/phpmyadmin/second_test.jpg' path = '/roobo/soft/phpmyadmin/second_test.jpg'
plt.savefig(path) plt.savefig(path)
return path return 'http://120.79.171.145:8000/second_test.jpg'
# app = Flask(__name__)
app = Flask(__name__) # CORS(app, supports_credentials=True)
CORS(app, supports_credentials=True) #
#
# @app.route('/SPDAS/second_test1', methods=['POST'])
@app.route('/SPDAS/second_test1', methods=['POST']) # def domain():
def domain(): # param = ({"data_type": [{"value": "error_control"}, {"value": "error_application"}],
param = ({"data_type": [{"value": "error_control"}, {"value": "error_application"}], # "time": "2018-12-01 00:00:00/2018-12-02 00:00:00",
"time": "2018-12-01 00:00:00/2018-12-02 00:00:00", # "graph_type": [{"value": "bar"}, {"value": "pie"}]})
"graph_type": [{"value": "bar"}, {"value": "pie"}]}) # return json.JSONEncoder().encode(param)
return json.JSONEncoder().encode(param) #
#
# @app.route('/SPDAS/second_test2', methods=['POST'])
@app.route('/SPDAS/second_test2', methods=['POST']) # def domain_form():
def domain_form(): # # 需要从request对象读取表单内容:
# 需要从request对象读取表单内容: # data = request.get_data()
data = request.get_data() # json_re = json.loads(data)
json_re = json.loads(data) # datatype = json_re['data_type']
datatype = json_re['data_type'] #
# m_time = json_re['time']
m_time = json_re['time'] # str_time = str(m_time)
str_time = str(m_time) # m_time = str_time.split('/')
m_time = str_time.split('/') # starttime = m_time[0]
starttime = m_time[0] # endtime = m_time[1]
endtime = m_time[1] # graphtype = json_re['graph_type']
graphtype = json_re['graph_type'] #
# image_path = second_test_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype)
image_path = second_test_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype=graphtype) # path = ({"test_image": image_path})
path = ({"test_image": image_path}) # return json.JSONEncoder().encode(path)
return json.JSONEncoder().encode(path) #
#
# if __name__ == '__main__':
if __name__ == '__main__': # app.run(debug=True, host='10.7.19.129', port=5000)
app.run(debug=True, host='10.7.19.129', port=5000)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
webpackJsonp([1],{"+ZrS":function(e,t){},"0Kq5":function(e,t){},"8zSp":function(e,t){},LE12:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={name:"SideBar",props:{activeName:{type:String,default:1},collapsed:{type:Boolean}},data:function(){return{iconSize:20,menuList:[{name:"domain",toLink:"/SPDAS/domain",title:"领域结构分析",type:"ios-navigate"},{name:"seriesTime",toLink:"/SPDAS/seriesTime",title:"时序数据分析",type:"ios-cog-outline"},{name:"user",toLink:"/SPDAS/user",title:"用户画像分析",type:"ios-analytics"},{name:"chat",toLink:"/SPDAS/chat",title:"闲聊功能分析",type:"ios-pie-outline"},{name:"responsive",toLink:"/SPDAS/responsive",title:"响应效果分析",type:"ios-paper-outline"}],menuList2:[{name:"domain",toLink:"/SPDAS/domain",type:"ios-navigate"},{name:"seriesTime",toLink:"/SPDAS/seriesTime",type:"ios-cog-outline"},{name:"user",toLink:"/SPDAS/user",type:"ios-analytics"},{name:"chat",toLink:"/SPDAS/chat",type:"ios-pie-outline"},{name:"responsive",toLink:"/SPDAS/responsive",type:"ios-paper-outline"}]}},methods:{goto:function(e){this.$router.push(e)},handleSelect:function(e){this.$emit("on-select",e)}}},s={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"side-con"},[e._t("default"),e._v(" "),e.collapsed?e._e():a("Menu",{attrs:{theme:"dark","active-name":e.activeName},on:{"on-select":e.handleSelect}},e._l(e.menuList,function(t,n){return a("Menu-item",{key:t.index,attrs:{name:t.name,to:t.toLink}},[a("Icon",{attrs:{type:t.type,size:e.iconSize}}),e._v(" "),a("span",{staticClass:"layout-text"},[e._v(e._s(t.title))])],1)}),1),e._v(" "),e.collapsed?a("div",{staticClass:"menu-collapsed"},[a("Menu",{attrs:{theme:"dark","active-name":e.activeName},on:{"on-select":e.handleSelect}},e._l(e.menuList2,function(t){return a("Menu-item",{key:t.index,attrs:{to:t.toLink,name:t.name}},[a("Icon",{attrs:{type:t.type,size:e.iconSize}})],1)}),1)],1):e._e()],2)},staticRenderFns:[]};var o=a("VU/8")(n,s,!1,function(e){a("0Kq5")},"data-v-6390284e",null).exports,i={name:"sider-trigger",props:{collapsed:Boolean,icon:{type:String,default:"navicon-round"},size:{type:Number,default:26}},methods:{handleChange:function(){this.$emit("on-change",!this.collapsed)}}},r={render:function(){var e=this.$createElement,t=this._self._c||e;return t("a",{class:["sider-trigger-a",this.collapsed?"collapsed":""],attrs:{type:"text"},on:{click:this.handleChange}},[t("Icon",{attrs:{type:this.icon,size:this.size}})],1)},staticRenderFns:[]};var l={name:"HeaderBar",components:{SiderTrigger:a("VU/8")(i,r,!1,function(e){a("fz/P")},"data-v-06b3f4fc",null).exports},props:{collapsed:Boolean},methods:{handleCollapsedChange:function(e){this.$emit("on-coll-change",e)}}},c={render:function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"header-bar"},[t("sider-trigger",{attrs:{collapsed:this.collapsed,icon:"md-menu"},on:{"on-change":this.handleCollapsedChange}}),this._v(" "),t("div",{staticClass:"custom-content-con"},[this._t("default")],2)],1)},staticRenderFns:[]};var d=a("VU/8")(l,c,!1,function(e){a("+ZrS")},"data-v-cc64f222",null).exports,u={name:"user",props:{userAvator:{type:String,default:""},messageUnreadCount:{type:Number,default:0}},methods:{logout:function(){sessionStorage.removeItem("token"),this.$router.push("/login")},message:function(){this.$router.push("")},handleClick:function(e){switch(e){case"logout":this.logout();break;case"message":this.message()}}}},p={render:function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"user-avator-dropdown"},[t("Dropdown",{attrs:{trigger:"click"},on:{"on-click":this.handleClick}},[t("Badge",{attrs:{dot:!!this.messageUnreadCount}},[t("Avatar",{attrs:{src:this.userAvator}})],1),this._v(" "),t("Icon",{attrs:{size:18,type:"md-arrow-dropdown"}}),this._v(" "),t("DropdownMenu",{attrs:{slot:"list"},slot:"list"},[t("DropdownItem",{attrs:{name:"logout"}},[this._v("退出登录")])],1)],1)],1)},staticRenderFns:[]};var m=a("VU/8")(u,p,!1,function(e){a("lOuJ")},"data-v-350b767a",null).exports,h=a("r217"),v=a.n(h),g={name:"home-page",components:{SideBar:o,HeaderBar:d,User:m},data:function(){return{collapsed:!1,activeId:"1",maxLogo:"语义数据分析平台",minLogo:"Logo",userImg:""}},computed:{userAvator:function(){return v.a},unreadCount:function(){return 4}},methods:{handleCollapsedChange:function(e){this.collapsed=e},turnToPage:function(){}}},f={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("Layout",{staticClass:"main",staticStyle:{height:"100%"}},[a("Sider",{staticClass:"left-side",style:{overflow:"hidden"},attrs:{"hide-trigger":"",collapsible:"",width:240,"collapsed-width":64},model:{value:e.collapsed,callback:function(t){e.collapsed=t},expression:"collapsed"}},[a("side-bar",{attrs:{collapsed:e.collapsed,"active-name":e.activeId},on:{"on-select":e.turnToPage}},[a("div",{staticClass:"logo-con"},[a("span",{directives:[{name:"show",rawName:"v-show",value:!e.collapsed,expression:"!collapsed"}],staticClass:"big-logo"},[e._v(e._s(e.maxLogo))]),e._v(" "),a("span",{directives:[{name:"show",rawName:"v-show",value:e.collapsed,expression:"collapsed"}],staticClass:"small-logo"},[e._v(e._s(e.minLogo))])])])],1),e._v(" "),a("Layout",[a("Header",{staticClass:"header-con"},[a("header-bar",{attrs:{collapsed:e.collapsed},on:{"on-coll-change":e.handleCollapsedChange}},[a("user",{attrs:{"message-unread-count":e.unreadCount,"user-avator":e.userAvator}},[a("img",{attrs:{src:e.userImg}})])],1)],1),e._v(" "),a("Content",{staticClass:"main-content-con"},[a("keep-alive",[a("router-view")],1)],1),e._v(" "),a("Footer",[a("div",{staticStyle:{"text-align":"center"}},[e._v("2011-2019 © TalkingData")])])],1)],1)},staticRenderFns:[]};var S=a("VU/8")(g,f,!1,function(e){a("8zSp")},"data-v-79fa437f",null);t.default=S.exports},"fz/P":function(e,t){},lOuJ:function(e,t){},r217:function(e,t,a){e.exports=a.p+"static/img/fullstack.e51bafb.jpg"}});
\ No newline at end of file
webpackJsonp([2],{"7Otq":function(t,e,r){t.exports=r.p+"static/img/logo.1e6719b.png"},AA1p:function(t,e){},vdVF:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var s=r("VkeE"),o={data:function(){return{form:{user:"",password:""},rules:{user:[{required:!0,message:"账号不能为空",trigger:"blur"}],password:[{required:!0,message:"密码不能为空",trigger:"blur"}]},loginLoading:!1}},created:function(){},methods:{handleSubmit:function(){var t=this;if(""===this.form.user||""===this.form.password)return console.log("error submit!"),!1;this.loginLoading=!0,this.$api.post(s.g,{user:this.form.user,password:this.form.password}).then(function(e){console.log("res_token",e.data),sessionStorage.setItem("token",e.data),setTimeout(function(){t.$router.push("/SPDAS/domain")},1e3)}).catch(function(e){t.$Message.error("登录失败!"),t.loginLoading=!1})}}},n={render:function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"login pull-height"},[t._m(0),t._v(" "),r("div",{staticClass:"login-con"},[r("h2",[t._v("登录语义数据分析平台")]),t._v(" "),r("div",{staticClass:"form-con"},[r("i-form",{ref:"loginForm",attrs:{autocomplete:"on",model:t.form,rules:t.rules}},[r("FormItem",{attrs:{prop:"user"}},[r("Input",{attrs:{placeholder:"请输入用户名"},model:{value:t.form.user,callback:function(e){t.$set(t.form,"user",e)},expression:"form.user"}},[r("span",{attrs:{slot:"prepend"},slot:"prepend"},[r("Icon",{attrs:{size:16,type:"ios-person"}})],1)])],1),t._v(" "),r("FormItem",{attrs:{prop:"password"}},[r("Input",{attrs:{type:"password",placeholder:"请输入密码"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.handleSubmit(e)}},model:{value:t.form.password,callback:function(e){t.$set(t.form,"password",e)},expression:"form.password"}},[r("span",{attrs:{slot:"prepend"},slot:"prepend"},[r("Icon",{attrs:{size:14,type:"md-lock"}})],1)])],1),t._v(" "),r("FormItem",[r("Button",{attrs:{type:"primary",long:"",loading:t.loginLoading},on:{click:function(e){return t.handleSubmit("form")}}},[t._v("登录")])],1)],1)],1)])])},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"login-info text-white animated fadeInLeft"},[e("div",{staticClass:"logo"},[e("img",{staticStyle:{"vertical-align":"middle"},attrs:{src:r("7Otq"),width:"300px",height:"78px",alt:"logo"}})])])}]};var i=r("VU/8")(o,n,!1,function(t){r("AA1p")},null,null);e.default=i.exports}});
\ No newline at end of file
webpackJsonp([3],{"fKh/":function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=s("VkeE"),i=s("PJh5"),r=s.n(i),n=s("6d20"),o={name:"responsive",data:function(){return{responsiveForm:{resSelect:"",effectSelect:""},getTime1:[],getTime2:[],secondResForm:{resChartSelect:"",secResSelect:""},ruleResponsiveForm:{resSelect:{required:!0,trigger:"change",message:"请输入类型"},resChartSelect:{required:!0,trigger:"change",message:"请输入图表类型"},effectSelect:{required:!0,trigger:"change",message:"请输入时间区段"},responsiveGetDates:{required:!0,trigger:"change",message:"请输入时间"}},ruleSecResForm:{resChartSelect:{required:!0,trigger:"change",message:"请输入图表类型"},secResSelect:{required:!0,trigger:"change",message:"请输入类型"},secResGetDates:{required:!0,trigger:"change",message:"请输入时间"}},responsiveOptions:{disabledDate:function(e){return e<r()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss")||e.valueOf()>Date.now()}},secResOptions:{disabledDate:function(e){return e<r()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss")||e.valueOf()>Date.now()}},firstResList:[],timeAreaList:[],secResList:[],graphList:[],resImg1:"",resImg2:"",isBtnLoading1:!1,isBtnLoading2:!1,isImgLoading1:!0,isImgLoading2:!0}},mounted:function(){var e=this;this.$api.post(a.h).then(function(t){e.isImgLoading1=!1,console.log("res",t.data),e.firstResList=t.data.data_type,e.timeAreaList=t.data.effect_type;var s=t.data.time.split("/"),a=r()(s[0],"YYYY-MM-DD HH:mm:ss").toDate(),i=r()(s[1],"YYYY-MM-DD HH:mm:ss").toDate();e.getTime1=[a,i],e.responsiveForm.resSelect=t.data.data_type[2].value,e.responsiveForm.effectSelect=t.data.effect_type[0].value,e.resImg1=t.data.image_path}).catch(function(t){console.log(t.data),e.isImgLoading1=!0}),this.$api.post(a.j).then(function(t){e.isImgLoading2=!1,e.secResList=t.data.data_type,e.graphList=t.data.graph_type;var s=t.data.time.split("/"),a=r()(s[0],"YYYY-MM-DD HH:mm:ss").toDate(),i=r()(s[1],"YYYY-MM-DD HH:mm:ss").toDate();e.getTime2=[a,i],console.log("second",t.data),e.secondResForm.secResSelect=t.data.data_type[0].value,e.secondResForm.resChartSelect=t.data.graph_type[0].value,e.resImg2=t.data.image_path}).catch(function(t){console.log(t),e.isImgLoading2=!0})},filters:{kindsChange:function(e){return n.c[e]},responseChange:function(e){return n.d[e]},chartsChange:function(e){return n.a[e]},errChange:function(e){return n.b[e]}},methods:{handleResSubmit_one:function(){var e=this;this.$refs.responsiveForm.validate(function(t){if(t&&!1===e.isBtnLoading1){e.isBtnLoading1=!0,e.isImgLoading1=!0;var s={data_type:e.responsiveForm.resSelect,effect_type:e.responsiveForm.effectSelect,time:r()(e.getTime1[0]).format("YYYY-MM-DD HH:mm:ss")+"/"+r()(e.getTime1[1]).format("YYYY-MM-DD HH:mm:ss")};e.$api.post(a.i,s).then(function(t){console.log("responsive",t.data),e.resImg1=t.data.response_image+"?t="+(new Date).getTime(),200===t.status&&(e.isBtnLoading1=!1,e.isImgLoading1=!1)}).catch(function(t){console.log(t),e.isBtnLoading1=!0,e.isImgLoading1=!0})}})},handleResSubmit_second:function(){var e=this;this.$refs.secondResForm.validate(function(t){if(t&&!1===e.isBtnLoading2){e.isBtnLoading2=!0,e.isImgLoading2=!0;var s={data_type:e.secondResForm.secResSelect,graph_type:e.secondResForm.resChartSelect,time:r()(e.getTime2[0]).format("YYYY-MM-DD HH::mm:ss")+"/"+r()(e.getTime2[1]).format("YYYY-MM-DD HH:mm:ss")};e.$api.post(a.k,s).then(function(t){e.resImg2=t.data.test_image+"?t="+(new Date).getTime(),200===t.status&&(e.isBtnLoading2=!1,e.isImgLoading2=!1)}).catch(function(t){console.log(t),e.isBtnLoading2=!0,e.isImgLoading2=!0})}})}}},c={render:function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",[s("Row",{attrs:{gutter:20}},[s("i-col",{attrs:{span:"24",xs:24,lg:24}},[s("Card",{attrs:{shadow:""}},[s("i-form",{ref:"responsiveForm",attrs:{inline:"",model:e.responsiveForm,rules:e.ruleResponsiveForm}},[s("Form-item",{attrs:{prop:"data_type"}},[s("i-select",{staticStyle:{width:"100px"},attrs:{placeholder:"请选择类型",clearable:""},model:{value:e.responsiveForm.resSelect,callback:function(t){e.$set(e.responsiveForm,"resSelect",t)},expression:"responsiveForm.resSelect"}},e._l(e.firstResList,function(t){return s("i-option",{key:t.index,attrs:{value:t.value}},[e._v(e._s(e._f("kindsChange")(t.value)))])}),1)],1),e._v(" "),s("Form-item",{attrs:{prop:"effect_type"}},[s("i-select",{staticStyle:{width:"120px"},attrs:{placeholder:"请选择时间区",clearable:""},model:{value:e.responsiveForm.effectSelect,callback:function(t){e.$set(e.responsiveForm,"effectSelect",t)},expression:"responsiveForm.effectSelect"}},e._l(e.timeAreaList,function(t){return s("i-option",{key:t.index,attrs:{value:t.value}},[e._v(e._s(e._f("responseChange")(t.value)))])}),1)],1),e._v(" "),s("Form-item",{attrs:{prop:"time"}},[s("Date-picker",{staticStyle:{width:"300px"},attrs:{confirm:"",options:e.responsiveOptions,type:"datetimerange",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间和结束时间"},model:{value:e.getTime1,callback:function(t){e.getTime1=t},expression:"getTime1"}})],1),e._v(" "),s("Form-item",[s("i-button",{attrs:{loading:e.isBtnLoading1,type:"primary"},on:{click:e.handleResSubmit_one}},[e._v("确定")])],1)],1),e._v(" "),s("div",{staticClass:"img-div"},[s("viewer",[s("img",{attrs:{src:e.resImg1}})]),e._v(" "),e.isImgLoading1?s("Spin",{attrs:{fix:""}},[e._v("加载中...")]):e._e()],1)],1)],1)],1),e._v(" "),s("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[s("i-col",[s("Card",{attrs:{shadow:""}},[s("i-form",{ref:"secondResForm",attrs:{inline:"",model:e.secondResForm,rules:e.ruleSecResForm}},[s("Form-item",{attrs:{prop:"graph_type"}},[s("i-select",{staticStyle:{width:"100px"},attrs:{placeholder:"请选择图表类型",clearable:""},model:{value:e.secondResForm.resChartSelect,callback:function(t){e.$set(e.secondResForm,"resChartSelect",t)},expression:"secondResForm.resChartSelect"}},e._l(e.graphList,function(t){return s("i-option",{key:t.index,attrs:{value:t.value}},[e._v(e._s(e._f("chartsChange")(t.value)))])}),1)],1),e._v(" "),s("Form-item",{attrs:{prop:"data_type"}},[s("i-select",{staticStyle:{width:"120px"},attrs:{placeholder:"请选择类型",clearable:""},model:{value:e.secondResForm.secResSelect,callback:function(t){e.$set(e.secondResForm,"secResSelect",t)},expression:"secondResForm.secResSelect"}},e._l(e.secResList,function(t){return s("i-option",{key:t.index,attrs:{value:t.value}},[e._v(e._s(e._f("errChange")(t.value)))])}),1)],1),e._v(" "),s("Form-item",{attrs:{prop:"time"}},[s("Date-picker",{staticStyle:{width:"300px"},attrs:{confirm:"",options:e.secResOptions,type:"datetimerange",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间和结束时间"},model:{value:e.getTime2,callback:function(t){e.getTime2=t},expression:"getTime2"}})],1),e._v(" "),s("Form-item",[s("i-button",{attrs:{loading:e.isBtnLoading2,type:"primary"},on:{click:e.handleResSubmit_second}},[e._v("二次测试按钮")])],1)],1),e._v(" "),s("div",{staticClass:"img-div"},[s("viewer",[s("img",{attrs:{src:e.resImg2}})]),e._v(" "),e.isImgLoading2?s("Spin",{attrs:{fix:""}},[e._v("加载中...")]):e._e()],1)],1)],1)],1)],1)},staticRenderFns:[]};var m=s("VU/8")(o,c,!1,function(e){s("h0gS")},"data-v-9305f30e",null);t.default=m.exports},h0gS:function(e,t){}});
\ No newline at end of file
webpackJsonp([4],{M2d4:function(t,i,a){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var e=a("PJh5"),s=a.n(e),n=a("VkeE"),m={name:"chat",data:function(){return{chatTimeForm:{},getInitTime:[],chatSelectForm:{chatSlider:""},ruleChatTimeForm:{chatGetDates:{required:!0,type:"date",trigger:"change",message:"请选择日期和时间"}},ruleChatSelectForm:{chatSlider:{required:!0,trigger:"change",message:"请滑动选择数量"}},chatTimeFormOptions:{disabledDate:function(t){return t<s()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss")||t.valueOf()>Date.now()}},maxNum:20,minNum:1,defaultVal:1,isDisabled:!0,isSliderDisabled:!0,image1:"",image2:"",image3:"",isBtnLoading1:!1,isBtnLoading2:!1,isImgLoading:!0,isImgLoading2:!0,isImgLoading3:!0}},mounted:function(){var t=this;this.$api.post(n.c).then(function(i){var a=i.data.time.split("/"),e=s()(a[0],"YYYY-MM-DD HH:mm:ss").toDate(),n=s()(a[1],"YYYY-MM-DD HH:mm:ss").toDate();t.getInitTime=[e,n],t.image1=i.data.image_path,t.isImgLoading=!1}).catch(function(i){t.isImgLoading=!0}),this.$api.post(n.a).then(function(i){t.chatSelectForm.chatSlider=i.data.best_num,t.image2=i.data.image1_path,t.image3=i.data.image2_path,t.isImgLoading2=!1,t.isImgLoading3=!1}).catch(function(i){t.isImgLoading2=!0,t.isImgLoading3=!0})},methods:{chatTimeSubmit:function(){var t=this;if(!1===this.isBtnLoading1){this.isImgLoading=!0,this.isBtnLoading1=!0;var i={time:s()(this.getInitTime[0]).format("YYYY-MM-DD HH:mm:ss")+"/"+s()(this.getInitTime[1]).format("YYYY-MM-DD HH:mm:ss")};this.$api.post(n.d,i).then(function(i){console.log("chat",i.data),t.image1=i.data.num_image+"?t="+(new Date).getTime(),200===i.status&&(t.isDisabled=!1,t.isSliderDisabled=!1,t.isBtnLoading1=!1,t.isImgLoading=!1)}).catch(function(i){t.isDisabled=!0,t.isSliderDisabled=!0,t.isBtnLoading1=!1})}},sliderMove:function(){var t=this;if(!1===this.isDisabled&&!1===this.isBtnLoading2){this.isBtnLoading2=!0,this.isImgLoading2=!0,this.isImgLoading3=!0;var i={best_num:this.defaultVal.toString(),time:s()(this.getInitTime[0]).format("YYYY-MM-DD HH:mm:ss")+"/"+s()(this.getInitTime[1]).format("YYYY-MM-DD HH:mm:ss")};this.$api.post(n.b,i).then(function(i){t.image2=i.data.cluster_point+"?t="+(new Date).getTime(),t.image3=i.data.ward_image+"?t="+(new Date).getTime(),200===i.status&&(t.isBtnLoading2=!1,t.isImgLoading2=!1,t.isImgLoading3=!1)}).catch(function(i){t.isBtnLoading2=!1,500===i.status&&t.$Message.error("请求失败!"),t.$Message.error("请求失败!")})}else this.$Message.error("按钮不可用")}}},o={render:function(){var t=this,i=t.$createElement,a=t._self._c||i;return a("div",[a("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[a("i-col",{attrs:{span:"24",md:24,lg:24}},[a("Card",{attrs:{shadow:""}},[a("i-form",{ref:"chatTimeForm",attrs:{inline:"",model:t.chatTimeForm,rules:t.ruleChatTimeForm}},[a("Form-item",{attrs:{prop:"time"}},[a("Date-picker",{staticStyle:{width:"300px"},attrs:{confirm:"",options:t.chatTimeFormOptions,type:"datetimerange",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间和结束时间"},model:{value:t.getInitTime,callback:function(i){t.getInitTime=i},expression:"getInitTime"}})],1),t._v(" "),a("Form-item",[a("i-button",{attrs:{type:"primary",loading:t.isBtnLoading1},on:{click:t.chatTimeSubmit}},[t._v("确定")])],1)],1),t._v(" "),a("div",{staticClass:"img-div loading"},[a("viewer",[a("img",{attrs:{src:t.image1,width:"300"}})]),t._v(" "),t.isImgLoading?a("Spin",{attrs:{fix:""}},[t._v("加载中...")]):t._e()],1)],1)],1)],1),t._v(" "),a("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[a("i-col",{attrs:{span:"24",md:24,lg:24}},[a("Card",{attrs:{shadow:""}},[a("i-form",{ref:"chatSelectForm",attrs:{inline:"",rules:t.ruleChatSelectForm}},[a("Form-item",{attrs:{prop:"best_num"}},[a("Slider",{staticStyle:{width:"300px"},attrs:{"show-stops":"",disabled:t.isSliderDisabled,max:t.maxNum,min:t.minNum},model:{value:t.defaultVal,callback:function(i){t.defaultVal=i},expression:"defaultVal"}})],1),t._v(" "),a("Form-item",[a("i-button",{attrs:{type:"primary",disabled:t.isDisabled,loading:t.isBtnLoading2},on:{click:t.sliderMove},model:{value:t.defaultVal,callback:function(i){t.defaultVal=i},expression:"defaultVal"}},[t._v("确定")])],1)],1),t._v(" "),a("div",{staticClass:"con-img"},[a("div",{staticClass:"loading"},[a("viewer",[a("img",{attrs:{src:t.image2}})]),t._v(" "),t.isImgLoading2?a("Spin",{attrs:{fix:""}},[t._v("加载中...")]):t._e()],1),t._v(" "),a("div",{staticClass:"loading"},[a("viewer",[a("img",{attrs:{src:t.image3}})]),t._v(" "),t.isImgLoading3?a("Spin",{attrs:{fix:""}},[t._v("加载中...")]):t._e()],1)])],1)],1)],1)],1)},staticRenderFns:[]};var r=a("VU/8")(m,o,!1,function(t){a("m7eG")},"data-v-6c138d9a",null);i.default=r.exports},m7eG:function(t,i){}});
\ No newline at end of file
webpackJsonp([5],{"6NKR":function(e,s,t){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var r=t("PJh5"),i=t.n(r),a=t("VkeE"),o=t("6d20"),n={name:"seriesTime",data:function(){return{seriesForm:{seriesSelectModel:"",charSelectModel:"",seriesGetYear_start:"",seriesGetYear_end:"",seriesGetMonth_start:"",seriesGetMonth_end:""},seriesGetDay:[],seriesGetHour_start:"",seriesGetHour_end:"",read:!0,ruleSeriesForm:{seriesSelectModel:[{required:!0,trigger:"change",message:"请选择类型"}],charSelectModel:[{required:!0,trigger:"change",message:"请选择图表类型"}],seriesGetYear_start:[{required:!0,type:"date",trigger:"change",message:"请输入开始年份"}],seriesGetYear_end:[{required:!0,type:"date",trigger:"change",message:"请输入结束年份"}],seriesGetMonth_start:[{required:!0,type:"date",trigger:"change",message:"请输入开始月份"}],seriesGetMonth_end:[{required:!0,type:"date",trigger:"change",message:"请输入结束月份"}]},timeList:[],charList:[],seriesImg:"",seriesIndex:4,yearOptions:{disabledDate:function(e){var s=(new Date).getFullYear();return e<i()("2018-12-21","YYYY").toDate()||new Date(e.valueOf()).getFullYear()>=s+1}},monthOptions:{disabledDate:function(e){return e<i()("2018-12-21","YYYY-MM").toDate()||e.valueOf()>Date.now()}},dayOptions:{disabledDate:function(e){return e<i()("2018-12-21","YYYY-MM-DD").toDate()||e.valueOf()>Date.now()}},hourOptions:{disabledDate:function(e){return e<i()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss").toDate()||e.valueOf()>Date.now()}},dataPram:{},isBtnLoading:!1,isImgLoading:!0}},mounted:function(){var e=this;this.$api.post(a.l).then(function(s){e.timeList=s.data.time_type,e.charList=s.data.graph_type,e.seriesImg=s.data.image_path,e.seriesForm.charSelectModel=s.data.graph_type[0].value,e.seriesForm.seriesSelectModel=s.data.time_type[0].value;var t=s.data.time.split("/"),r=i()(t[0],"YYYY-MM-DD HH:mm").toDate(),a=i()(t[1],"YYYY-MM-DD HH:mm").toDate();e.seriesGetHour_start=r,e.seriesGetHour_end=a,e.isImgLoading=!1}).catch(function(s){e.isImgLoading=!0})},filters:{chartChange:function(e){return o.a[e]},timesChange:function(e){return o.e[e]}},methods:{sHourChange:function(e){this.seriesGetHour_start=e,this.seriesGetHour_end=i()(e,"YYYY-MM-DD HH:mm:ss").add(1,"days").toDate(),console.log("sHourChange:",this.seriesGetHour_end)},changeUserSelect:function(){return"year"===this.seriesForm.seriesSelectModel?this.seriesIndex=1:"month"===this.seriesForm.seriesSelectModel?this.seriesIndex=2:"day"===this.seriesForm.seriesSelectModel?this.seriesIndex=3:"hour"===this.seriesForm.seriesSelectModel?this.seriesIndex=4:void 0},returnData:function(){var e=i()(this.seriesForm.seriesGetYear_start).format("YYYY"),s=i()(this.seriesForm.seriesGetYear_end).format("YYYY"),t=i()(this.seriesForm.seriesGetMonth_start).format("YYYY-MM"),r=i()(this.seriesForm.seriesGetMonth_end).format("YYYY-MM");return"year"===this.seriesForm.seriesSelectModel&&s>=e?{time_type:this.seriesForm.seriesSelectModel,time:e+"/"+s,graph_type:this.seriesForm.charSelectModel}:"month"===this.seriesForm.seriesSelectModel&&s>=e?{time_type:this.seriesForm.seriesSelectModel,time:t+"/"+r,graph_type:this.seriesForm.charSelectModel}:"day"===this.seriesForm.seriesSelectModel?{time_type:this.seriesForm.seriesSelectModel,time:i()(this.seriesGetDay[0]).format("YYYY-MM-DD")+"/"+i()(this.seriesGetDay[1]).format("YYYY-MM-DD"),graph_type:this.seriesForm.charSelectModel}:"hour"===this.seriesForm.seriesSelectModel?{time_type:this.seriesForm.seriesSelectModel,time:i()(this.seriesGetHour_start).format("YYYY-MM-DD HH:mm:ss")+"/"+i()(this.seriesGetHour_end).format("YYYY-MM-DD HH:mm:ss"),graph_type:this.seriesForm.charSelectModel}:void 0},handleSeriesSubmit:function(){var e=this;this.$refs.seriesForm.validate(function(s){s&&!1===e.isBtnLoading&&(e.isBtnLoading=!0,e.isImgLoading=!0,e.$api.post(a.m,e.returnData()).then(function(s){e.seriesImg=s.data.time_image+"?t="+(new Date).getTime(),200===s.status&&(e.isBtnLoading=!1,e.isImgLoading=!1)}).catch(function(s){e.isBtnLoading=!0,e.isImgLoading=!0}))})}}},d={render:function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("div",[t("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[t("i-col",{attrs:{span:"24",md:24,lg:24}},[t("Card",{attrs:{shadow:""}},[t("i-form",{ref:"seriesForm",attrs:{inline:"",model:e.seriesForm,rules:e.ruleSeriesForm}},[t("Form-item",{attrs:{prop:"time_type"}},[t("i-select",{staticStyle:{width:"100px"},attrs:{clearable:""},on:{"on-change":e.changeUserSelect},model:{value:e.seriesForm.seriesSelectModel,callback:function(s){e.$set(e.seriesForm,"seriesSelectModel",s)},expression:"seriesForm.seriesSelectModel"}},e._l(e.timeList,function(s){return t("i-option",{key:s.index,attrs:{value:s.value}},[e._v(e._s(e._f("timesChange")(s.value)))])}),1)],1),e._v(" "),t("Form-item",{attrs:{prop:"time"}},[t("div",{directives:[{name:"show",rawName:"v-show",value:1===e.seriesIndex,expression:"seriesIndex === 1"}]},[t("Date-picker",{staticStyle:{width:"130px"},attrs:{options:e.yearOptions,type:"year",placeholder:"请选择开始年份"},model:{value:e.seriesForm.seriesGetYear_start,callback:function(s){e.$set(e.seriesForm,"seriesGetYear_start",s)},expression:"seriesForm.seriesGetYear_start"}}),e._v(" "),t("span",[e._v("-")]),e._v(" "),t("Date-picker",{staticStyle:{width:"130px"},attrs:{options:e.yearOptions,type:"year",placeholder:"请选择结束年份"},model:{value:e.seriesForm.seriesGetYear_end,callback:function(s){e.$set(e.seriesForm,"seriesGetYear_end",s)},expression:"seriesForm.seriesGetYear_end"}})],1),e._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:2===e.seriesIndex,expression:"seriesIndex === 2"}]},[t("Date-picker",{staticStyle:{width:"130px"},attrs:{options:e.monthOptions,type:"month",placeholder:"请选择开始月份"},model:{value:e.seriesForm.seriesGetMonth_start,callback:function(s){e.$set(e.seriesForm,"seriesGetMonth_start",s)},expression:"seriesForm.seriesGetMonth_start"}}),e._v(" -\n "),t("Date-picker",{staticStyle:{width:"130px"},attrs:{options:e.monthOptions,type:"month",placeholder:"请选择结束月份"},model:{value:e.seriesForm.seriesGetMonth_end,callback:function(s){e.$set(e.seriesForm,"seriesGetMonth_end",s)},expression:"seriesForm.seriesGetMonth_end"}})],1),e._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:3===e.seriesIndex,expression:"seriesIndex === 3"}]},[t("Date-picker",{staticStyle:{width:"300px"},attrs:{options:e.dayOptions,confirm:"",type:"daterange",format:"yyyy-MM-dd",placeholder:"请选择日期"},model:{value:e.seriesGetDay,callback:function(s){e.seriesGetDay=s},expression:"seriesGetDay"}})],1),e._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:4===e.seriesIndex,expression:"seriesIndex === 4"}]},[t("Date-picker",{attrs:{options:e.hourOptions,type:"datetime",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间"},on:{"on-change":e.sHourChange},model:{value:e.seriesGetHour_start,callback:function(s){e.seriesGetHour_start=s},expression:"seriesGetHour_start"}}),e._v(" "),t("span",[e._v("-")]),e._v(" "),t("Date-picker",{attrs:{options:e.hourOptions,readonly:e.read,type:"datetime",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择结束时间"},model:{value:e.seriesGetHour_end,callback:function(s){e.seriesGetHour_end=s},expression:"seriesGetHour_end"}})],1)]),e._v(" "),t("Form-item",[t("i-button",{attrs:{loading:e.isBtnLoading,type:"primary"},on:{click:function(s){return e.handleSeriesSubmit("seriesForm")}}},[e._v("确定")])],1)],1),e._v(" "),t("div",{staticClass:"img-div"},[t("viewer",[t("img",{attrs:{src:e.seriesImg}})]),e._v(" "),e.isImgLoading?t("Spin",{attrs:{fix:""}},[e._v("加载中...")]):e._e()],1)],1)],1)],1)],1)},staticRenderFns:[]};var m=t("VU/8")(n,d,!1,function(e){t("IHwx")},"data-v-3408eb7d",null);s.default=m.exports},IHwx:function(e,s){}});
\ No newline at end of file
webpackJsonp([6],{SwKW:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=a("PJh5"),n=a.n(i),o=a("VkeE"),m=a("6d20"),d={name:"domain",data:function(){return{domainForm:{domainSelect:"",domainChartSelect:""},domainGetInitTime:[],ruleDomainForm:{domainSelected:[{required:!0,trigger:"change",message:"请选择类型"}],domainChartSelected:[{required:!0,trigger:"change",message:"请选择图表类型"}],domainGetDates:[{required:!0,type:"date",trigger:"change",message:"请选择日期和时间"}]},selectTime:"",getDatesOptions:{disabledDate:function(t){return t<n()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss").toDate()||t.valueOf()>Date.now()}},data_type:[],graph_type:[],chartList:[],loading1:!1,loading2:!1,domainImage:"",isBtnLoading:!1,isImgLoading:!0}},mounted:function(){var t=this;this.$api.post(o.e).then(function(e){t.domainImage=e.data.image,t.data_type=e.data.data_type,t.graph_type=e.data.graph_type,t.domainImage=e.data.image_path,t.domainForm.domainSelect=e.data.data_type[2].value,t.domainForm.domainChartSelect=e.data.graph_type[0].value;var a=e.data.time.split("/"),i=n()(a[0],"YYYY-MM-DD HH:mm:ss").toDate(),o=n()(a[1],"YYYY-MM-DD HH:mm:ss").toDate();t.domainGetInitTime=[i,o],t.isImgLoading=!1}).catch(function(e){t.isImgLoading=!0})},filters:{kindsChange:function(t){return m.c[t]},chartChange:function(t){return m.a[t]}},methods:{handleSubmit:function(){var t=this;this.$refs.domainForm.validate(function(e){if(e){if(!1===t.isBtnLoading){t.isBtnLoading=!0,t.isImgLoading=!0;var a={time:n()(t.domainGetInitTime[0]).format("YYYY-MM-DD HH:mm:ss")+"/"+n()(t.domainGetInitTime[1]).format("YYYY-MM-DD HH:mm:ss"),data_type:t.domainForm.domainSelect,graph_type:t.domainForm.domainChartSelect};t.$api.post(o.f,a).then(function(e){console.log("domain",e.data),t.domainImage=e.data.domain_image+"?t="+(new Date).getTime(),200===e.status&&(t.isBtnLoading=!1,t.isImgLoading=!1)}).catch(function(e){console.log(e),t.isBtnLoading=!1,t.isImgLoading=!0})}t.$Message.success("Success")}else t.$Message.error("failed")})},imgBig:function(){console.log("1111"),console.log("imgWidth:",document.getElementsByTagName("img")[0].width);var t=document.getElementsByTagName("img")[0],e=t.length;console.log("imgLen:",e);for(var a=0;a<e;a++)t.width<600&&(t[a].width=2*t[a].width)}}},r={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[a("i-col",{attrs:{span:"24",md:24,lg:24}},[a("Card",{attrs:{shadow:""}},[a("i-form",{ref:"domainForm",attrs:{inline:"",model:t.domainForm,rules:t.ruleDomainForm}},[a("Form-item",{attrs:{prop:"data_type"}},[a("i-select",{staticStyle:{width:"120px"},attrs:{clearable:""},model:{value:t.domainForm.domainSelect,callback:function(e){t.$set(t.domainForm,"domainSelect",e)},expression:"domainForm.domainSelect"}},t._l(t.data_type,function(e){return a("i-option",{key:e.index,attrs:{value:e.value}},[t._v(t._s(t._f("kindsChange")(e.value))+"\n ")])}),1)],1),t._v(" "),a("Form-item",{attrs:{prop:"graph_type"}},[a("i-select",{staticStyle:{width:"100px"},attrs:{clearable:""},model:{value:t.domainForm.domainChartSelect,callback:function(e){t.$set(t.domainForm,"domainChartSelect",e)},expression:"domainForm.domainChartSelect"}},t._l(t.graph_type,function(e){return a("i-option",{key:e.index,attrs:{value:e.value}},[t._v(t._s(t._f("chartChange")(e.value))+"\n ")])}),1)],1),t._v(" "),a("Form-item",{attrs:{prop:"time"}},[a("Date-picker",{staticStyle:{width:"300px"},attrs:{confirm:"",options:t.getDatesOptions,type:"datetimerange",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间和结束时间"},model:{value:t.domainGetInitTime,callback:function(e){t.domainGetInitTime=e},expression:"domainGetInitTime"}})],1),t._v(" "),a("Form-item",[a("i-button",{attrs:{type:"primary",loading:t.isBtnLoading},on:{click:t.handleSubmit}},[t._v("确定")])],1)],1),t._v(" "),a("div",{staticClass:"img-div loading"},[a("viewer",[a("img",{attrs:{src:t.domainImage},on:{click:t.imgBig}})]),t._v(" "),t.isImgLoading?a("Spin",{attrs:{fix:""}},[t._v("加载中...")]):t._e()],1)],1)],1)],1)],1)},staticRenderFns:[]};var s=a("VU/8")(d,r,!1,function(t){a("dDHT")},"data-v-0e6c7106",null);e.default=s.exports},dDHT:function(t,e){}});
\ No newline at end of file
webpackJsonp([7],{GIxB:function(e,t){},ZeSV:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=a("VkeE"),r=a("6d20"),i=a("PJh5"),n=a.n(i),o={name:"user",data:function(){return{userForm:{userSelectModel:""},userGetInitTime:[],ruleUserForm:{userSelectModel:[{required:!0,trigger:"change",message:"请选择类型"}],userGetDates:[{required:!0,type:"date",trigger:"change",message:"请选择日期和时间"}]},userOptions:{disabledDate:function(e){return e<n()("2018-12-21 01:00:00","YYYY-MM-DD HH:mm:ss")||e.valueOf()>Date.now()}},userList:[],userImg:"",isBtnLoading:!1,isImgLoading:!0}},mounted:function(){var e=this;this.$api.post(s.n).then(function(t){e.isImgLoading=!1,console.log("user 1:",t.data),e.userList=t.data.data_type,e.userImg=t.data.image_path,e.userForm.userSelectModel=t.data.data_type[3].value;var a=t.data.time.split("/"),s=a[0],r=a[1];e.userGetInitTime=[new Date(s),new Date(r)]}).catch(function(t){e.isImgLoading=!0})},filters:{changeWord:function(e){return r.c[e]}},methods:{handleUserSubmit:function(){var e=this;this.$refs.userForm.validate(function(t){if(t&&!1===e.isBtnLoading){e.isBtnLoading=!0,e.isImgLoading=!0;var a={data_type:e.userForm.userSelectModel,time:n()(e.userGetInitTime[0]).format("YYYY-MM-DD HH:mm:ss")+"/"+n()(e.userGetInitTime[1]).format("YYYY-MM-DD HH:mm:ss")};e.$api.post(s.o,a).then(function(t){console.log("user",t.data),e.userImg=t.data.user_image+"?t= "+(new Date).getTime(),200===t.status&&(e.isBtnLoading=!1,e.isImgLoading=!1)}).catch(function(t){e.isBtnLoading=!0,e.isImgLoading=!0})}})},handleDatesChange:function(e){this.userGetInitTime=e,console.log(e)}}},u={render:function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",[a("Row",{staticStyle:{"margin-top":"10px"},attrs:{gutter:20}},[a("i-col",{attrs:{span:"24",md:24,lg:24}},[a("Card",{attrs:{shadow:""}},[a("i-form",{ref:"userForm",attrs:{inline:"",model:e.userForm,rules:e.ruleUserForm}},[a("Form-item",{attrs:{prop:"data_type"}},[a("i-select",{staticStyle:{width:"100px"},attrs:{clearable:""},model:{value:e.userForm.userSelectModel,callback:function(t){e.$set(e.userForm,"userSelectModel",t)},expression:"userForm.userSelectModel"}},e._l(e.userList,function(t){return a("i-option",{key:t.index,attrs:{value:t.value}},[e._v(e._s(e._f("changeWord")(t.value)))])}),1)],1),e._v(" "),a("Form-item",{attrs:{prop:"time"}},[a("Date-picker",{staticStyle:{width:"300px"},attrs:{value:e.userGetInitTime,options:e.userOptions,confirm:"",type:"datetimerange",format:"yyyy-MM-dd HH:mm:ss",placeholder:"请选择开始时间和结束时间"},on:{"on-change":e.handleDatesChange}})],1),e._v(" "),a("Form-item",[a("i-button",{attrs:{loading:e.isBtnLoading,type:"primary"},on:{click:e.handleUserSubmit}},[e._v("确定")])],1)],1),e._v(" "),a("div",{staticClass:"img-div"},[a("viewer",[a("img",{attrs:{src:e.userImg}})]),e._v(" "),e.isImgLoading?a("Spin",{attrs:{fix:""}},[e._v("加载中...")]):e._e()],1)],1)],1)],1)],1)},staticRenderFns:[]};var d=a("VU/8")(o,u,!1,function(e){a("GIxB")},"data-v-0ad18c31",null);t.default=d.exports}});
\ No newline at end of file
webpackJsonp([9],{"+skl":function(e,n){},B774:function(e,n){},N1kN:function(e,n){},NHnr:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("7+uW"),a={render:function(){var e=this.$createElement,n=this._self._c||e;return n("div",{attrs:{id:"app"}},[n("router-view")],1)},staticRenderFns:[]};var o=t("VU/8")({name:"App"},a,!1,function(e){t("B774")},null,null).exports,s=t("/ocq");r.default.use(s.a);var u=new s.a({routes:[{path:"/",redirect:"/login"},{path:"/login",name:"login",component:function(){return t.e(2).then(t.bind(null,"vdVF"))}},{path:"/SPDAS",name:"homePage",component:function(){return t.e(1).then(t.bind(null,"LE12"))},redirect:"/SPDAS/domain",meta:{requireAuth:!0},children:[{path:"/SPDAS/domain",name:"domain",component:function(){return Promise.all([t.e(0),t.e(6)]).then(t.bind(null,"SwKW"))},meta:{requireAuth:!0}},{path:"/SPDAS/seriesTime",name:"seriesTime",component:function(){return Promise.all([t.e(0),t.e(5)]).then(t.bind(null,"6NKR"))},meta:{requireAuth:!0}},{path:"/SPDAS/user",name:"user",component:function(){return Promise.all([t.e(0),t.e(7)]).then(t.bind(null,"ZeSV"))},meta:{requireAuth:!0}},{path:"/SPDAS/chat",name:"chat",component:function(){return Promise.all([t.e(0),t.e(4)]).then(t.bind(null,"M2d4"))},meta:{requireAuth:!0}},{path:"/SPDAS/responsive",name:"responsive",component:function(){return Promise.all([t.e(0),t.e(3)]).then(t.bind(null,"fKh/"))},meta:{requireAuth:!0}}]}]});u.beforeEach(function(e,n,t){var r=sessionStorage.getItem("token");console.log("token:",r),e.meta.requireAuth?(console.log(123),r?t():t({path:"/login"})):t()});var i=u,c=(t("j1ja"),t("//Fk")),l=t.n(c),p=t("mtWM"),d=t.n(p),f=t("VkeE"),m=this,h="http://120.79.171.145:5000/SPDAS",_=d.a.create();_.defaults.baseURL=h,_.defaults.timeout=6e5,_.defaults.headers.post["Content-Type"]="application/x-www-form-urlencoded",_.defaults.headers.post["X-Request-With"]="XMLHttpRequest",_.defaults.headers.post.login_token="",_.interceptors.request.use(function(e){var n="";try{n=JSON.parse(localStorage.getItem(f.p))}catch(e){localStorage.removeItem(f.p),console.log(e)}return n&&(e.headers.login_token=n),e},function(e){return m.$Message.error("网络错误,请稍后再试"),l.a.reject(e)}),_.interceptors.response.use(function(e){return e.data&&200!==e.status?(m.$Message.error("登录信息过期,请重新登录!"),i.replace({name:"login"}),l.a.reject(e)):l.a.resolve(e)},function(e){if(e.response)switch(e.response.status){case 401:localStorage.removeItem(f.p),m.$Message.error("请重新授权登录"),i.replace({name:"login"});break;case 404:m.$Message.error("请求页面不存在");break;case 500:m.$Message.error("服务器错误,请稍后再试")}else m.$Message.error("请求超时,请稍后重试");return l.a.reject(e)});var g=_,S=t("BTaQ"),A=t.n(S),v=(t("+skl"),t("EAZf")),y=t.n(v);t("N1kN");r.default.use(A.a),r.default.config.productionTip=!1,r.default.prototype.$api=g,r.default.use(y.a,{defaultOptions:{zIndex:9999}}),new r.default({el:"#app",router:i,components:{App:o},template:"<App/>"})},VkeE:function(e,n,t){"use strict";t.d(n,"p",function(){return r}),t.d(n,"g",function(){return a}),t.d(n,"e",function(){return o}),t.d(n,"f",function(){return s}),t.d(n,"l",function(){return u}),t.d(n,"m",function(){return i}),t.d(n,"n",function(){return c}),t.d(n,"o",function(){return l}),t.d(n,"c",function(){return p}),t.d(n,"d",function(){return d}),t.d(n,"a",function(){return f}),t.d(n,"b",function(){return m}),t.d(n,"h",function(){return h}),t.d(n,"i",function(){return _}),t.d(n,"j",function(){return g}),t.d(n,"k",function(){return S});var r="",a="/login",o="/domain_structure_analysis1",s="/domain_structure_analysis2",u="/time_series_analysis1",i="/time_series_analysis2",c="/user_portrait_analysis1",l="/user_portrait_analysis2",p="/chat_function_analysis/choice1",d="/chat_function_analysis/choice2",f="/chat_function_analysis/chat1",m="/chat_function_analysis/chat2",h="/response_analysis1",_="/response_analysis2",g="/second_test1",S="/second_test2"}},["NHnr"]);
\ No newline at end of file
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,a){for(var f,i,u,s=0,l=[];s<r.length;s++)i=r[s],t[i]&&l.push(t[i][0]),t[i]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(e[f]=c[f]);for(n&&n(r,c,a);l.length;)l.shift()();if(a)for(s=0;s<a.length;s++)u=o(o.s=a[s]);return u};var r={},t={10:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var c=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,o.nc&&a.setAttribute("nonce",o.nc),a.src=o.p+"static/js/"+e+"."+{0:"929eb24a6140a29a71e9",1:"7bc85965315ad5f725e9",2:"9e073194c7971f80ffb1",3:"ac8f0baf4212298750c4",4:"0b2eb810526861297b2f",5:"49d9f21e16f136fa71c7",6:"2eabc7342bc8bb97de0c",7:"931938d5b9ce23d1c7c9"}[e]+".js";var f=setTimeout(i,12e4);function i(){a.onerror=a.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return a.onerror=a.onload=i,c.appendChild(a),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="./",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
This diff is collapsed.
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>语义数据分析平台</title><style>html,body{
padding: 0;
margin: 0;
height: 100%;
overflow:hidden;
}</style><link href=./static/css/app.9c4162e157000096832f7467b0da7465.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.ffddd6eb6c14b28fe19d.js></script><script type=text/javascript src=./static/js/vendor.e324bda0bd56a2f46d94.js></script><script type=text/javascript src=./static/js/app.d34b7f33f5584be04934.js></script></body></html>
\ No newline at end of file
...@@ -5,10 +5,11 @@ import pandas as pd ...@@ -5,10 +5,11 @@ import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import datetime as dt import datetime as dt
import bottom_function.data_read as dr import bottom_function.data_read as dr
import json
from flask import Flask # import json
from flask import request # from flask import Flask
from flask_cors import CORS # from flask import request
# from flask_cors import CORS
def datetime_data_plot(timetype, starttime, endtime, graphtype): def datetime_data_plot(timetype, starttime, endtime, graphtype):
...@@ -63,49 +64,49 @@ def datetime_data_plot(timetype, starttime, endtime, graphtype): ...@@ -63,49 +64,49 @@ def datetime_data_plot(timetype, starttime, endtime, graphtype):
index_data[i] = dt.datetime.strftime(index_data[i], "%Y") index_data[i] = dt.datetime.strftime(index_data[i], "%Y")
all_data.index = index_data all_data.index = index_data
fig = plt.figure(figsize=(16, 6)) # fig = plt.figure(figsize=(16, 6))
all_data.plot(kind=graphtype, stacked=True, use_index=True) all_data.plot(kind=graphtype, stacked=True, use_index=True,figsize=(10, 8))
plt.xticks(rotation=45) plt.xticks(rotation=45)
plt.title(str(starttime) + ' to ' + str( plt.title(str(starttime) + ' to ' + str(
endtime) + ' ' + timetype + ' datetime domain analysis of ' + graphtype + ' graph', endtime) + ' ' + timetype + ' datetime domain analysis of ' + graphtype + ' graph',
fontsize=10) fontsize=15)
plt.tight_layout(5) plt.tight_layout(5)
path = '/roobo/soft/phpmyadmin/plot_time.jpg' path = '/roobo/soft/phpmyadmin/plot_time.jpg'
plt.savefig(path) plt.savefig(path)
return path return 'http://120.79.171.145:8000/plot_time.jpg'
app = Flask(__name__)
CORS(app, supports_credentials=True)
@app.route('/SPDAS/time_series_analysis1', methods=['POST'])
def domain():
param = ({"time_type": [{"value": "hour", "id": 1}, {"value": "day", "id": 2},
{"value": "month", "id": 3}, {"value": "year", "id": 4}],
"time": "2018-12-01 00:00:00/2018-12-02 00:00:00",
"graph_type": [{"value": "bar"}, {"value": "pie"}]})
return json.JSONEncoder().encode(param)
@app.route('/SPDAS/time_series_analysis2', methods=['POST'])
def domain_form():
# 需要从request对象读取表单内容:
data = request.get_data()
json_re = json.loads(data)
print(json_re)
timetype = json_re['time_type']
m_time = json_re['time']
graphtype = json_re['graph_type']
str_time = str(m_time)
m_time = str_time.split('/')
starttime = m_time[0]
endtime = m_time[1]
image_path = datetime_data_plot(timetype=timetype, starttime=starttime, endtime=endtime, graphtype=graphtype)
path = ({"time_image": image_path})
return json.JSONEncoder().encode(path)
if __name__ == '__main__': # app = Flask(__name__)
app.run(debug=True, host='10.7.19.129', port=5000) # CORS(app, supports_credentials=True)
#
#
# @app.route('/SPDAS/time_series_analysis1', methods=['POST'])
# def domain():
# param = ({"time_type": [{"value": "hour", "id": 1}, {"value": "day", "id": 2},
# {"value": "month", "id": 3}, {"value": "year", "id": 4}],
# "time": "2018-12-01 00:00:00/2018-12-02 00:00:00",
# "graph_type": [{"value": "bar"}, {"value": "pie"}]})
# return json.JSONEncoder().encode(param)
#
#
# @app.route('/SPDAS/time_series_analysis2', methods=['POST'])
# def domain_form():
# # 需要从request对象读取表单内容:
# data = request.get_data()
# json_re = json.loads(data)
# print(json_re)
# timetype = json_re['time_type']
# m_time = json_re['time']
# graphtype = json_re['graph_type']
# str_time = str(m_time)
# m_time = str_time.split('/')
# starttime = m_time[0]
# endtime = m_time[1]
# image_path = datetime_data_plot(timetype=timetype, starttime=starttime, endtime=endtime, graphtype=graphtype)
# path = ({"time_image": image_path})
# return json.JSONEncoder().encode(path)
#
#
# if __name__ == '__main__':
# app.run(debug=True, host='10.7.19.129', port=5000)
# -*- coding: utf-8 -*-
# author:Li Mingjie time:2019/3/14
# Brief:
import time
import threading
def run():
datetime = time.localtime(time.time())
print(datetime)
run()
...@@ -7,10 +7,12 @@ import cv2 ...@@ -7,10 +7,12 @@ import cv2
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import bottom_function.data_read as dr import bottom_function.data_read as dr
from bottom_function import normalization as norm from bottom_function import normalization as norm
import json
from flask import Flask
from flask import request # import json
from flask_cors import CORS # from flask import Flask
# from flask import request
# from flask_cors import CORS
def portrait_plot(datatype, starttime, endtime): def portrait_plot(datatype, starttime, endtime):
...@@ -24,11 +26,11 @@ def portrait_plot(datatype, starttime, endtime): ...@@ -24,11 +26,11 @@ def portrait_plot(datatype, starttime, endtime):
cut_text = norm.remove_special_characters(query_data) cut_text = norm.remove_special_characters(query_data)
color_mask = cv2.imread('./bottom_function/data/gree_logo.jpg') color_mask = cv2.imread('/home/work/semantic_platform_DAS/bottom_function/data/gree_logo.jpg')
cloud = WordCloud( cloud = WordCloud(
# 设置字体,不指定就会出现乱码 # 设置字体,不指定就会出现乱码
font_path=" C:\\Windows\\Fonts\\STXINGKA.TTF", font_path="./bottom_function/data/msyh.ttf",
# font_path=path.join(d,'simsun.ttc'), # font_path=path.join(d,'simsun.ttc'),
font_step=1, font_step=1,
width=720, width=720,
...@@ -48,41 +50,44 @@ def portrait_plot(datatype, starttime, endtime): ...@@ -48,41 +50,44 @@ def portrait_plot(datatype, starttime, endtime):
# wCloud.to_file('../data/word_cloud/cloud.jpg') # wCloud.to_file('../data/word_cloud/cloud.jpg')
plt.imshow(wCloud, interpolation='bilinear') plt.imshow(wCloud, interpolation='bilinear')
plt.axis('off') plt.axis('off')
til = datatype + ' ' + starttime + endtime + 'user portrait of word cloud' til = starttime + ' to ' + endtime + ' ' + datatype + ' user portrait of word cloud'
plt.title(til) plt.title(til)
path = '/roobo/soft/phpmyadmin/plot_user.jpg' path = '/roobo/soft/phpmyadmin/plot_user.jpg'
plt.savefig(path) wCloud.to_file(path)
return path # plt.savefig(path)
return 'http://120.79.171.145:8000/plot_user.jpg'
app = Flask(__name__) # portrait_plot(datatype='all', starttime='2018-12-28 00:00:00', endtime='2018-12-29 00:00:00')
CORS(app, supports_credentials=True)
# app = Flask(__name__)
# CORS(app, supports_credentials=True)
@app.route('/SPDAS/user_portrait_analysis1', methods=['POST']) #
def domain(): #
param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}], # @app.route('/SPDAS/user_portrait_analysis1', methods=['POST'])
"time": "2019.01.01 00:00:00/2019.01.02 00:00:00"}) # def domain():
return json.JSONEncoder().encode(param) # param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}],
# "time": "2019.01.01 00:00:00/2019.01.02 00:00:00"})
# return json.JSONEncoder().encode(param)
@app.route('/SPDAS/user_portrait_analysis2', methods=['POST']) #
def domain_form(): #
# 需要从request对象读取表单内容: # @app.route('/SPDAS/user_portrait_analysis2', methods=['POST'])
data = request.get_data() # def domain_form():
json_re = json.loads(data) # # 需要从request对象读取表单内容:
# data = request.get_data()
datatype = json_re['data_type'] # json_re = json.loads(data)
m_time = json_re['time'] #
str_time = str(m_time) # datatype = json_re['data_type']
m_time = str_time.split('/') # m_time = json_re['time']
starttime = m_time[0] # str_time = str(m_time)
endtime = m_time[1] # m_time = str_time.split('/')
image_path = portrait_plot(datatype=datatype, starttime=starttime, endtime=endtime) # starttime = m_time[0]
path = {"user_image": image_path} # endtime = m_time[1]
return json.JSONEncoder().encode(path) # image_path = portrait_plot(datatype=datatype, starttime=starttime, endtime=endtime)
# path = {"user_image": image_path}
# return json.JSONEncoder().encode(path)
if __name__ == '__main__': #
app.run(debug=True, host='10.7.19.129', port=5000) #
# if __name__ == '__main__':
# app.run(debug=True, host='10.7.19.129', port=5000)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment