-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
212 lines (197 loc) · 5.16 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2020/8/26 14:48
# @Author : way
# @Site :
# @Describe:
import json
# import mysql.connector
# mydb = mysql.connector.connect(
# host="localhost",
# user="root",
# password="719458145",
# database="bank_index",
# auth_plugin='mysql_native_password'
# )
# mydb = mysql.connector.connect(
# host="localhost",
# user="root",
# password="root",
# database="sql_test",
# auth_plugin='mysql_native_password'
# )
# class SourceData:
# @property
def echart1(month):
#------------------------雷达图1-----------------
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM radar1 Where MONTH(date)="+month+" order BY name")
data1= mycursor.fetchall()
mycursor.execute("SELECT * FROM radar1_industry Where MONTH(date)="+month+" order BY name")
data2 = mycursor.fetchall()
jsonData1 = []
jsonData2 = []
for row in data1:
result = {}
result['value'] = row[2]
jsonData1.append(result)
print(jsonData1)
for row in data2:
result = {}
result['value'] = row[2]
jsonData2.append(result)
print(jsonData2)
try:
echart = {
'title1':"本行",
'xAxis1': [i.get("value") for i in jsonData1],
'title2': "行业",
'xAxis2': [i.get("value") for i in jsonData2]
}
return echart
except:
print("Error")
mycursor.close()
return echart
def echart2(month):
# ------------------------1113尝试-----------------
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM radar2 Where MONTH(date)="+month+" order BY name")
data1 = mycursor.fetchall()
mycursor.execute("SELECT * FROM radar2_industry Where MONTH(date)=" + month +" Order by name")
data2 = mycursor.fetchall()
jsonData1 = []
jsonData2 = []
for row in data1:
result = {}
result['value'] = row[2]
jsonData1.append(result)
# print(jsonData1)
for row in data2:
result = {}
result['value'] = row[2]
jsonData2.append(result)
# print(jsonData2)
try:
echart = {
'title1': "本行",
'xAxis1': [i.get("value") for i in jsonData1],
'title2': "参照值",
'xAxis2': [i.get("value") for i in jsonData2]
}
return echart
except:
print("Error")
mycursor.close()
return echart
# def echart3_1(self):
#
# mycursor = mydb.cursor()
# mycursor.execute("SELECT * FROM Asset_table")
# data = mycursor.fetchall()
# jsonData = []
#
# for row in data:
# result = {}
# result['value'] = row[1]
# # result['per'] = row[1]
# jsonData.append(result)
# print("财务-资产规模",result)
# try:
# echart = {
# 'title': "财务-资产规模",
# 'xAxis': [i.get("value") for i in jsonData],
# # 'max': [i.get("per") for i in jsonData]
# }
# return echart
# except:
# print("Error")
#
# mycursor.close()
# return echart
#
# def echart3_2(self):
#
# mycursor = mydb.cursor()
# mycursor.execute("SELECT * FROM Asset_table")
# data = mycursor.fetchall()
# jsonData = []
#
# for row in data:
# result = {}
# result['value'] = row[2]
# # result['per'] = row[1]
# jsonData.append(result)
# print("增速",result)
# try:
# echart = {
# 'title': "财务-资产规模",
# 'xAxis': [i.get("value") for i in jsonData],
# # 'max': [i.get("per") for i in jsonData]
# }
# return echart
# except:
# print("Error")
#
# mycursor.close()
# return echart
#
# def echart4_1(self):
#
# mycursor = mydb.cursor()
# mycursor.execute("SELECT * FROM AUM")
# data = mycursor.fetchall()
# jsonData = []
#
# for row in data:
# result = {}
# result['value'] = row[1]
# # result['per'] = row[1]
# jsonData.append(result)
# print("业务-AUM",result)
# try:
# echart = {
# 'title': "业务-AUM",
# 'xAxis': [i.get("value") for i in jsonData],
# # 'max': [i.get("per") for i in jsonData]
# }
# return echart
# except:
# print("Error")
#
# mycursor.close()
# return echart
#
# def echart4_2(self):
#
# mycursor = mydb.cursor()
# mycursor.execute("SELECT * FROM AUM")
# data = mycursor.fetchall()
# jsonData = []
#
# for row in data:
# result = {}
# result['value'] = row[2]
# # result['per'] = row[1]
# jsonData.append(result)
# print("增速",result)
# try:
# echart = {
# 'title': "业务-AUM",
# 'xAxis': [i.get("value") for i in jsonData],
# # 'max': [i.get("per") for i in jsonData]
# }
# return echart
# except:
# print("Error")
#
# mycursor.close()
# return echart
@property
def map_1(self):
data = self.map_1_data
echart = {
'symbolSize': data.get('symbolSize'),
'data': data.get('data'),
}
return echart