def edit_stencil(request, stencil_index_number): hb_if = HBASE_interface() list_str = LIST_to_STR() tablename = "stencil_config" table = hb_if.table(tablename) result_scan_dict = table.row(stencil_index_number) print result_scan_dict result_list = [result_scan_dict] result_json = json.dumps(result_list) print result_scan_dict['c1:WQAR256_IDC'] print result_scan_dict['c1:WQAR512_IDC'] list_WQAR256_model = list_str.str_to_int(result_scan_dict['c1:WQAR256_IDC']) list_WQAR512_model = list_str.str_to_int(result_scan_dict['c1:WQAR512_IDC']) list_WQAR256_para_index, list_WQAR512_para_index = list_str.make_para_id_list() result_list_256_id = [] result_list_512_id = [] for each_id_number in list_WQAR256_model: result_list_256_id.append(list_WQAR256_para_index[int(each_id_number)]) for each_id_number in list_WQAR512_model: result_list_512_id.append(list_WQAR512_para_index[int(each_id_number)]) print result_list_256_id,result_list_512_id return render(request, 'edit_stencil.html',{'result_json': result_json, 'result_json_256':result_list_256_id, 'result_json_512':result_list_512_id, 'stencil_index_number':stencil_index_number})
def edit_stencil(request, stencil_index_number): hb_if = HBASE_interface() list_str = LIST_to_STR() tablename = "stencil_config" table = hb_if.table(tablename) result_scan_dict = table.row(stencil_index_number) print result_scan_dict result_list = [result_scan_dict] result_json = json.dumps(result_list) print result_scan_dict['c1:WQAR256_IDC'] print result_scan_dict['c1:WQAR512_IDC'] list_WQAR256_model = list_str.str_to_int( result_scan_dict['c1:WQAR256_IDC']) list_WQAR512_model = list_str.str_to_int( result_scan_dict['c1:WQAR512_IDC']) list_WQAR256_para_index, list_WQAR512_para_index = list_str.make_para_id_list( ) result_list_256_id = [] result_list_512_id = [] for each_id_number in list_WQAR256_model: result_list_256_id.append(list_WQAR256_para_index[int(each_id_number)]) for each_id_number in list_WQAR512_model: result_list_512_id.append(list_WQAR512_para_index[int(each_id_number)]) print result_list_256_id, result_list_512_id return render( request, 'edit_stencil.html', { 'result_json': result_json, 'result_json_256': result_list_256_id, 'result_json_512': result_list_512_id, 'stencil_index_number': stencil_index_number })
def storing_stencil_ajax(request): #前端传入参数 ata = request.GET.get('stencil_ATA', None) name = request.GET.get('stencil_name', None) para_256 = request.GET.get('stencil_256_para', None) para_512 = request.GET.get('stencil_512_para', None) creator = request.GET.get('stencil_creator', None) #对传入进行解码 name_decode = name.encode('utf-8') creator_decode = creator.encode('utf-8') para_256_decode = para_256.split(',') para_512_decode = para_512.split(',') #防输错设计,前端多输入了,号,列表中有空值即去掉 while '' in para_256_decode: para_256_decode.remove('') while '' in para_512_decode: para_512_decode.remove('') #存入数据库 ''' stencil.objects.create(configuration = conf, ATA = ata, \ stencil_name = name_decode, list_para = para_decode) ''' hb_if = HBASE_interface() list_str = LIST_to_STR() table = hb_if.table('stencil_config') str_stencil_name = name_decode str_para_256 = list_str.int_to_str(para_256_decode) str_para_512 = list_str.int_to_str(para_512_decode) dict_cf_data = { 'c1:NAME': str_stencil_name, 'c1:WQAR512_IDC': str_para_512, 'c1:WQAR256_IDC': str_para_256, 'c1:ATA': ata, 'c1:creator': creator_decode, 'c1:ECHARTS_256': ';;', 'c1:ECHARTS_512': ';;' } cf_set = ['c1:NAME'] dict = hb_if.query_table('stencil_config', cf_set) table_max_index = len(dict.items()) print "table max index: %s" % table_max_index rowkey = (str(table_max_index + 1)).zfill(3) print rowkey print dict_cf_data table.put(rowkey, dict_cf_data) #回传前端,反馈结果 para_256_post = ','.join(para_256_decode) para_512_post = ','.join(para_512_decode) text = '<br>已录入<br>模版:' + str(name_decode) + \ '<br>参数256:' + str(para_256_post) + \ '<br>参数512:' + str(para_512_post) + \ '<br>章节:' + str(ata) return HttpResponse(text)
def storing_stencil_ajax(request): #前端传入参数 ata = request.GET.get('stencil_ATA', None) name = request.GET.get('stencil_name', None) para_256 = request.GET.get('stencil_256_para', None) para_512 = request.GET.get('stencil_512_para', None) creator = request.GET.get('stencil_creator', None) #对传入进行解码 name_decode = name.encode('utf-8') creator_decode = creator.encode('utf-8') para_256_decode = para_256.split(',') para_512_decode = para_512.split(',') #防输错设计,前端多输入了,号,列表中有空值即去掉 while '' in para_256_decode: para_256_decode.remove('') while '' in para_512_decode: para_512_decode.remove('') #存入数据库 ''' stencil.objects.create(configuration = conf, ATA = ata, \ stencil_name = name_decode, list_para = para_decode) ''' hb_if = HBASE_interface() list_str = LIST_to_STR() table = hb_if.table('stencil_config') str_stencil_name = name_decode str_para_256 = list_str.int_to_str(para_256_decode) str_para_512 = list_str.int_to_str(para_512_decode) dict_cf_data = {'c1:NAME': str_stencil_name, 'c1:WQAR512_IDC': str_para_512, 'c1:WQAR256_IDC': str_para_256, 'c1:ATA': ata, 'c1:creator':creator_decode, 'c1:ECHARTS_256':';;', 'c1:ECHARTS_512':';;'} cf_set = ['c1:NAME'] dict = hb_if.query_table('stencil_config', cf_set) table_max_index = len(dict.items()) print "table max index: %s" % table_max_index rowkey = (str(table_max_index + 1)).zfill(3) print rowkey print dict_cf_data table.put(rowkey, dict_cf_data) #回传前端,反馈结果 para_256_post = ','.join(para_256_decode) para_512_post = ','.join(para_512_decode) text = '<br>已录入<br>模版:' + str(name_decode) + \ '<br>参数256:' + str(para_256_post) + \ '<br>参数512:' + str(para_512_post) + \ '<br>章节:' + str(ata) return HttpResponse(text)
def stencil_echarts(request): stencil_index_number = request.GET.get('stencil_index_number', None) post_string_256 = request.GET.get('post_string_256', None) post_string_512 = request.GET.get('post_string_512', None) rowkey = (str(stencil_index_number)).zfill(3) print rowkey hb_if = HBASE_interface() list_str = LIST_to_STR() table = hb_if.table('stencil_config') dict_cf_data = { 'c1:ECHARTS_256': post_string_256, 'c1:ECHARTS_512': post_string_512 } table.put(rowkey, dict_cf_data) return HttpResponse("已录入")
def stencil_list(request): hb_if = HBASE_interface() list_str = LIST_to_STR() table = hb_if.table('stencil_config') tablename = "stencil_config" cf_set = [ 'c1:NAME', 'c1:ATA', 'c1:creator', ] result_scan_dict = hb_if.query_table(tablename, cf_set) result_list = [] for key, value in result_scan_dict.items(): print key, value single = { 'index': key, 'NAME': value['c1:NAME'], 'ATA': value['c1:ATA'], 'creator': value['c1:creator'], } result_list.append(single) result_json = json.dumps(result_list) return render(request, 'stencil_list.html', {'result_json': result_json})
#coding=utf-8 from hbase_function import HBASE_interface from hbase_function import LIST_to_STR hb_if = HBASE_interface() list_str = LIST_to_STR() connection = hb_if.connect_hbase table_stencil = connection.table("stencil_config") print table_stencil list_WQAR256_FUEL_MODEL = [65, 214, 216, 224, 225, 232, 233, 234, 433, 434] list_WQAR512_FUEL_MODEL = [69, 241, 242, 249, 250, 363, 364, 365, 394, 395] str_WQAR256_FUEL_MODEL = list_str.int_to_str(list_WQAR256_FUEL_MODEL) str_WQAR512_FUEL_MODEL = list_str.int_to_str(list_WQAR512_FUEL_MODEL) list_test = list_str.str_to_int(str_WQAR512_FUEL_MODEL) name = "燃油油量不平衡" dic_table_info = {'c1:WQAR512_IDC': str_WQAR512_FUEL_MODEL, 'c1:WQAR256_IDC': str_WQAR256_FUEL_MODEL, 'c1:NAME': name, 'c1:ATA': '28', 'c1:creator': "赵廷健"} table_stencil.put("000", dic_table_info) #table_stencil.put() for item in table_stencil.scan(): print item
def __init__(self): self.hb_if = HBASE_interface() self.list_str = LIST_to_STR() self.ac_config = AC_WQAR_CONFIG() pass
def ajax_some_para(request): hbase_interface = HBASE_interface() list_str = LIST_to_STR() post_index = request.GET.get('value_conf', None) print post_index post_flight_id = request.GET.get('flight_id', None) aircraft_id = post_flight_id[0:6] # 读取模版表的存储详情 table_stencil_name = "stencil_config" cf_set_stencil = ['c1:WQAR512_IDC', 'c1:WQAR256_IDC', 'c1:NAME', 'c1:ECHARTS_256', 'c1:ECHARTS_512'] result_scan_dict = hbase_interface.query_table(table_stencil_name,cf_set_stencil) dict_stencil_config = result_scan_dict[post_index] str_WQAR256 = dict_stencil_config['c1:WQAR256_IDC'] str_WQAR512 = dict_stencil_config['c1:WQAR512_IDC'] list_WQAR256 = list_str.str_to_int(str_WQAR256) list_WQAR512 = list_str.str_to_int(str_WQAR512) #取出echarts option echarts_option_256 = dict_stencil_config['c1:ECHARTS_256'] echarts_option_512 = dict_stencil_config['c1:ECHARTS_512'] # 机号构型判断 ac_wqar_config = AC_WQAR_CONFIG() if aircraft_id in ac_wqar_config.WQAR512_SERISE_list: model = list_WQAR512 str_echarts_option = echarts_option_512 elif aircraft_id in ac_wqar_config.WQAR256_SERISE_list: model = list_WQAR256 str_echarts_option = echarts_option_256 else: return HttpResponse("无此机号") tablename = post_flight_id cf_set = [] for item in model: cf_set.append('c1:' + str(item)) result_scan_dict = hbase_interface.query_table(tablename,cf_set) result_list = [] para_name_dic = result_scan_dict['00000'] for key, value in result_scan_dict.items(): single = {'index' : key} for key_para, value_para in value.items(): para_name = para_name_dic[key_para] single[para_name] = value_para result_list.append(single) #查询出C2的值 cf_set_c2 = ['c2:1'] dict_c2_scan = hbase_interface.query_table(tablename,cf_set_c2) dict_c2_para_name = dict_c2_scan['00000'] list_c1_c2 = [] i = 0 for key, value in dict_c2_scan.items(): single = result_list[i] for key_para, value_para in value.items(): para_name = dict_c2_para_name[key_para] single[para_name] = value_para list_c1_c2.append(single) i = i + 1 # 传递echarts设置信息 ec_op = Echarts_option() echarts_config_option = ec_op.str_to_obj(str_echarts_option) # 得出echarts_option中的逻辑值参数表列表 list_index_of_logic_echarts = ec_op.judge_logic_echart(echarts_config_option) result_json = json.dumps([list_c1_c2, echarts_config_option, list_index_of_logic_echarts]) return HttpResponse(result_json)
def ajax_some_para(request): hbase_interface = HBASE_interface() list_str = LIST_to_STR() post_index = request.GET.get('value_conf', None) print post_index post_flight_id = request.GET.get('flight_id', None) aircraft_id = post_flight_id[0:6] # 读取模版表的存储详情 table_stencil_name = "stencil_config" cf_set_stencil = [ 'c1:WQAR512_IDC', 'c1:WQAR256_IDC', 'c1:NAME', 'c1:ECHARTS_256', 'c1:ECHARTS_512' ] result_scan_dict = hbase_interface.query_table(table_stencil_name, cf_set_stencil) dict_stencil_config = result_scan_dict[post_index] str_WQAR256 = dict_stencil_config['c1:WQAR256_IDC'] str_WQAR512 = dict_stencil_config['c1:WQAR512_IDC'] list_WQAR256 = list_str.str_to_int(str_WQAR256) list_WQAR512 = list_str.str_to_int(str_WQAR512) #取出echarts option echarts_option_256 = dict_stencil_config['c1:ECHARTS_256'] echarts_option_512 = dict_stencil_config['c1:ECHARTS_512'] # 机号构型判断 ac_wqar_config = AC_WQAR_CONFIG() if aircraft_id in ac_wqar_config.WQAR512_SERISE_list: model = list_WQAR512 str_echarts_option = echarts_option_512 elif aircraft_id in ac_wqar_config.WQAR256_SERISE_list: model = list_WQAR256 str_echarts_option = echarts_option_256 else: return HttpResponse("无此机号") tablename = post_flight_id cf_set = [] for item in model: cf_set.append('c1:' + str(item)) result_scan_dict = hbase_interface.query_table(tablename, cf_set) result_list = [] para_name_dic = result_scan_dict['00000'] for key, value in result_scan_dict.items(): single = {'index': key} for key_para, value_para in value.items(): para_name = para_name_dic[key_para] single[para_name] = value_para result_list.append(single) #查询出C2的值 cf_set_c2 = ['c2:1'] dict_c2_scan = hbase_interface.query_table(tablename, cf_set_c2) dict_c2_para_name = dict_c2_scan['00000'] list_c1_c2 = [] i = 0 for key, value in dict_c2_scan.items(): single = result_list[i] for key_para, value_para in value.items(): para_name = dict_c2_para_name[key_para] single[para_name] = value_para list_c1_c2.append(single) i = i + 1 # 传递echarts设置信息 ec_op = Echarts_option() echarts_config_option = ec_op.str_to_obj(str_echarts_option) # 得出echarts_option中的逻辑值参数表列表 list_index_of_logic_echarts = ec_op.judge_logic_echart( echarts_config_option) result_json = json.dumps( [list_c1_c2, echarts_config_option, list_index_of_logic_echarts]) return HttpResponse(result_json)