def GET(self):
all_col = ('value','description','type_fid','ci_fid','owner','family_id','time','change_log','citype_name','ci_name','ciat_name','value_type')
ci_input = web.input()
condition = " "
for col in range(len(all_col)):
col_name = all_col[col]
value = ci_input.get(col_name,None)
if value <> None:
if col_name == 'time' :
condition = condition + "a.starttime <= '" + value + "' and a.endtime > '" + value + "' and b.starttime <= '" + value + "' and b.endtime > '" + value + "' and c.starttime <= '" + value + "' and c.endtime > '" + value + "' and d.starttime <= '" + value + "' and d.endtime > '" + value + "' and "
elif col_name == 'citype_name':
condition = condition + "d.name = '" + value + "' and "
elif col_name == 'ci_name':
condition = condition + "b.name = '" + value + "' and "
elif col_name == 'ciat_name':
condition = condition + "c.name = '" + value + "' and "
elif col_name == 'value_type':
condition = condition + "c.value_type = '" + value + "' and "
else :
condition = condition + "a." + col_name + " = '" + value + "' and "
if value == None and col_name == 'time':
condition = condition + "a.endtime = '" + ENDTIME + "' and b.endtime = '" + ENDTIME + "' and c.endtime = '" + ENDTIME + "' and d.endtime = '" + ENDTIME + "' and "
v_sql = "select distinct d.name citype_name, b.name ci_name, c.name ciat_name, c.value_type, a.value, convert(a.description,'utf8') description, a.type_fid, a.ci_fid, a.owner, a.family_id, a.change_log from t_ci_attribute a, t_ci b, t_ci_attribute_type c, t_ci_type d where " + condition + "a.type_fid = c.family_id and a.ci_fid = b.family_id and b.type_fid = d.family_id and c.ci_type_fid = d.family_id "
ci_recs = db.query(v_sql)
ci_as_dict = []
for ci in ci_recs:
ci_as_dict.append(ci)
ci_json = json.dumps(ci_as_dict, indent = 4,ensure_ascii=False, separators = (',',':')).decode("GB2312")
# import sys,httplib, urllib
# params = urllib.urlencode({'fid':'FCAD00000002','change_log':'test'})
# headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
# con2 = httplib.HTTPConnection("localhost:8080")
# con2.request("DELETE","/ciattr",params,headers)
# con2.close()
return ci_json
评论列表
文章目录