-
Notifications
You must be signed in to change notification settings - Fork 1
/
searchutil.py
85 lines (72 loc) · 2.55 KB
/
searchutil.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
import json
import requests
base_url = "http://114.55.168.6/"
search_api = base_url + "es-test/essearch.php"
oper_api = base_url + "es-test/oper-search.php"
# 操作类别:1:建单 2:派单 3:审核 4:结算 5:回访
def getAdminids():
params = dict()
params['method'] = 'search'
params['index'] = 'yxgoper'
params['from'] = 0
params['size'] = 30
params['groupby'] = 'adminid'
params['keyword'] = ''
params['field_return'] = 'adminid'
checkRes = requests.post(search_api, data=params)
checkRes.encoding = 'utf-8'
adminids = []
if checkRes and checkRes.status_code == 200:
# print("获取所有网点id成功:")
# print(checkRes.text)
results = json.loads(checkRes.text)
adminids.append('24')
for element in results['element']:
adminids.append(str(element['adminid']))
return adminids
def getMasters(adminid):
params = dict()
params['method'] = 'search'
params['index'] = 'yxgoper'
params['from'] = 0
params['size'] = 100
params['groupby'] = 'username'
params['keyword'] = ''
params['field_return'] = ['username', 'userid']
params['adminid'] = adminid
checkRes = requests.post(search_api, data=params)
checkRes.encoding = 'utf-8'
adminids = []
if checkRes and checkRes.status_code == 200:
# print("获取所有网点id成功:")
print(checkRes.text)
results = json.loads(checkRes.text)
adminids.append({'userid': '', 'username': '全部'})
for element in results['element']:
adminids.append(element)
return adminids
# print(getMasters(24))
def getOperators(adminid, userid, start, end):
params = dict()
params['method'] = 'search'
params['index'] = 'yxgoper'
params['from'] = 0
params['size'] = 100
params['groupby'] = 'opertype'
params['keyword'] = ''
params['opertime'] = json.dumps([['egt', start], ['elt', end], 'and'])
params['userids'] = json.dumps(userid)
params['field_return'] = json.dumps(['username', 'opertype'])
params['adminid'] = adminid
checkRes = requests.post(oper_api, data=params)
checkRes.encoding = 'utf-8'
opers = []
if checkRes and checkRes.status_code == 200:
# print("获取所有网点id成功:")
print(checkRes.text)
results = json.loads(checkRes.text)
for element in results['element']:
opers.append(element)
return opers
# print(getMasters('24'))
# print(getOperators('24', ['250', '281', '23'], '2020-01-08 00:00:00', '2020-05-08 00:00:00'))