Exemplo n.º 1
0
def showdata1(request):
    log('start showdata')

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    getListJson()
    # s_date = time.strftime('%Y-%m-%d', time.localtime())
    stat_list_json.clear()
    stat_list = yything_stat.objects.all()
    for var in stat_list:
        dict_data = {"stat_id": var.stat_id, "stat_name": var.stat_name}
        stat_list_json.append(dict_data)
    req = {
        'title': 'abcd'
        # , 'date': s_date
        ,
        'stat_list_json': stat_list_json,
        'type_list_json': type_list_json,
        'zycd_list_json': zycd_list_json,
        'jjcd_list_json': jjcd_list_json,
        'team_list_json': team_list_json,
        'department_list_json': department_list_json
    }
    return render(request, 'trans_zl_helloworld/show_data.html', req)
Exemplo n.º 2
0
def show_update(request, info_id):
    print('index show_update')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': False,
        'perm': 'search_problem.add_info'
    }
    resp_auth = main.auth(auth_data)
    print('user : '******'code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    print('info_id = [' + str(info_id) + ']')
    for line in info.objects.filter(id=info_id):
        data = line.__dict__
        data_channel_id = line.t_channel.code
        data_type_id = line.t_type.code

    print(data)

    channel_data = []
    for line in info_channel.objects.all():
        channel_data.append(line.__dict__)

    type_data = []
    for line in info_type.objects.all():
        type_data.append(line.__dict__)

    comments_data = []
    for line in info.objects.filter(id=info_id):
        data = line.__dict__
        for line_comments in line.t_comments.all():
            comments_data.append({
                "name":
                line_comments.name,
                "update_oper":
                line_comments.update_oper,
                "update_date":
                line_comments.update_date.strftime("%Y-%m-%d %H:%M:%S")
            })

    comments_data.sort(key=lambda item: item.get('update_date'), reverse=True)

    resp = {
        "code": 0,
        "data": data,
        'type': 'update',
        "stat": 0,
        "channel": channel_data,
        'type_data': type_data,
        "data_channel_id": data_channel_id,
        "data_type_id": data_type_id,
        "comments_data": comments_data
    }
    return render(request, 'search_problem/show.html', resp)
Exemplo n.º 3
0
def index(request):
    log('start index hello world')
    print(request.POST)  # form 包含提交的数据
    print(request.POST.get('zh'))

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': False, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    bank_list = []
    s_date = time.strftime('%Y-%m-%d', time.localtime())
    # data = config.objects.all()
    data = config.objects.filter(plat_name="V2核心系统")
    for line in data:
        if line.user == 'cib':
            bank_list.append({'bank_name': line.name_ch})
            # print(bank_list)
    req = {
        'title': '冻结控制查询',
        'date': s_date,
        'req': bank_list,
    }
    print(req)
    return render(request, 'trans_zl_helloworld/index.html', req)
Exemplo n.º 4
0
def index(request):
    print('index myview home')

    # 权限检查
    # resp_auth = main.auth(request, True, False, '')
    # if resp_auth[0] == False:
    #     return render(request, 'alarm/resp.html', {"message": resp_auth[1]})
    auth_data = {'request': request, 'net': False, 'login': False, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    user = request.user

    # 调用数据中台API
    res = requests.post(url='http://' + request.META.get('HTTP_HOST') + '/' +
                        'data_api/oper/',
                        data={"comm_i_user_first_name": user.first_name})
    resp = json.loads(res.text)

    user_data = {}
    for line in resp.get('data'):
        user_data = line

    if user_data.get('is_authenticated') == True:
        user_id = user_data.get('first_name')
    else:
        user_id = '未登陆'
    req = {"user_id": user_id, "score": user_data.get('score')}

    for line in user_data.get('group_data'):
        if line.get('name') == '应用人员':
            return render(request, 'myview/index.html', req)
    return render(request, 'myview/index2.html', req)
Exemplo n.º 5
0
def index(request):
    print('start index cloud_file')

    # 权限检查
    auth_data = {
        'request': request
        , 'net': False
        , 'login': True
        , 'debug': True
        , 'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html', {"message": resp_auth.get('msg')})

    # print(chardet(data))



    file_path = request.GET.get('file_path')
    if file_path == None :
        file_path = '/'

    req = {
        'title': 'cloud_file'
        , 'file_path': file_path
    }
    # print(req)
    return render(request, 'cloud_file/index.html', req)
Exemplo n.º 6
0
def index(request):
    print('start index data_control')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': True,
        'perm': 'make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    plat_list = [{
        'plat_id': 'cib',
        'plat_name': '核心系统'
    }
                 # , {'plat_id': 'v3_cib', 'plat_name': 'V3核心系统'}
                 ]
    bank_list = []
    bank_list.clear()

    # V2核心数据载入
    queryset_data1 = config.objects.filter(plat_id='cib')
    for line in queryset_data1:
        if line.name_ch[-4:] != '_CLJ':
            bank_list.append({
                'name': line.name,
                'name_ch': line.name_ch,
                'ip': line.ip,
                'ver': 'V2'
            })

    # V3核心数据载入
    queryset_data2 = config_discovery.objects.filter(plat='v3_cib')
    for line in queryset_data2:
        queryset_data3 = config.objects.filter(plat_id='v3_cib',
                                               name_ch=line.bank_group)
        for line2 in queryset_data3:
            bank_list.append({
                'name': line.bank_id,
                'name_ch': line.bank_name,
                'ip': line2.ip,
                'ver': 'V3'
            })

    user = request.user
    req = {
        'title': '数据文件载入',
        'user_name': user.username,
        'date': time.strftime('%Y%m%d', time.localtime()),
        'bank_list': bank_list,
        'plat_list': plat_list
    }
    # print(req)
    return render(request, 'data_control/index.html', req)
Exemplo n.º 7
0
def show_update_comments_stat_update(request, info_id):
    print('index show_update_comments_stat_update')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': False,
        'perm': '',
        'perm_group': '知识库管理员'
    }
    resp_auth = main.auth(auth_data)
    print('user : '******'code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    r = info_comments.objects.get(id=request.POST.get('comments_id'))
    r_old = info_comments.objects.get(id=request.POST.get('comments_id'))
    r.i_stat = info_comments_stat.objects.get(
        code=request.POST.get('comment_stat_code'))
    r.save()

    try:
        r_old_stat_code = r_old.i_stat.code
    except:
        r_old_stat_code = 999
    print(r.i_stat.code)

    if r_old_stat_code != 0 and r.i_stat.code == 0:
        # 积分计算
        main.action_log(
            request, {
                "app_type": "search_problem",
                'action_type': "comments",
                'info_id': info_id,
                'text': r.id,
                'oper': r.update_oper
            })
    if r_old_stat_code == 0 and r.i_stat.code != 0:
        # 积分计算
        main.action_log(
            request, {
                "app_type": "search_problem",
                'action_type': "comments_close",
                'info_id': info_id,
                'text': r.id,
                'oper': r.update_oper
            })

    resp = {"code": 0}
    return HttpResponse(json.dumps(resp), content_type="application/json")
Exemplo n.º 8
0
def show(request):
    print('start index make')

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {'title': '软件下发流程管理'}
    return render(request, 'rjxf_server/show.html', req)
Exemplo n.º 9
0
def index(request):
    print('start index rota_day')

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {'title': 'rota_day'}
    # print(req)
    return render(request, 'qq_data/index.html', req)
Exemplo n.º 10
0
def cmdb_input(request):
    print('start cmdb_input index')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': True,
        'perm': 'rjxf_make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    # 所属产品
    plat_info = []

    for line in i_plat.objects.all():
        plat_info.append({
            'plat_id':
            line.plat_ver.name + '-' + line.plat_id,
            'plat_name':
            line.plat_ver.name + '-' + line.plat_id + '-' + line.plat_name
        })

    # 所属服务器
    sys_info = []
    for line in i_app_server.objects.all():
        sys_info.append({
            'id': line.ip + '-' + line.user,
            'name': line.ip + '-' + line.user
        })

    # 合作行
    bank_info = []
    for line in i_bank.objects.all():
        bank_info.append({
            'id': line.name,
            'name': line.name + '-' + line.name_ch
        })

    req = {
        'title': '运维对象配置',
        'plat_info': plat_info,
        'sys_info': sys_info,
        'bank_info': bank_info
    }
    print(req)
    return render(request, 'cmdb/cmdb_input.html', req)
Exemplo n.º 11
0
def show_update_close(request, info_id):
    print('index show_update_close')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': False,
        'perm': '',
        'perm_group': '知识库管理员'
    }
    resp_auth = main.auth(auth_data)
    print('user : '******'code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    r = info.objects.get(id=info_id)
    r_old = info.objects.get(id=info_id)

    r.t_close = info_close.objects.get(code=999)
    r.save()

    try:
        r_old_close_code = r_old.t_close.code
    except:
        r_old_close_code = 0

    if r_old_close_code != 999 and r.t_close.code == 999:
        # 积分计算
        if r.t_stat.stat_id == 1:
            main.action_log(
                request, {
                    "app_type": "search_problem",
                    'action_type': "answer_close",
                    'info_id': info_id,
                    'oper': r.answer_oper
                })
        main.action_log(
            request, {
                "app_type": "search_problem",
                'action_type': "input_close",
                'info_id': info_id,
                'oper': r.input_oper
            })

    resp = {"code": 0}
    return HttpResponse(json.dumps(resp), content_type="application/json")
Exemplo n.º 12
0
def make(request):
    print('start index make')
    user = request.user
    print(user)

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': True,
        'perm': 'rjxf_server.add_flow'
    }
    resp_auth = main.auth(auth_data)
    print('user : '******'code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})
    file_list.clear()
    i = 1
    for rjxf_line in ftp_path.objects.all():
        print(rjxf_line)
        print(rjxf_line.ftp_id)

        # 多线程不增加 sleep 的情况下 expect 会出现异常
        sleep(0.02)

        data = {'ftp_id': rjxf_line.ftp_id, 'ftp_pwd': rjxf_line.ftp_pwd}

        exec('thread{} = forThread_make(data)'.format(i))
        exec('thread{}.start()'.format(i))
        i += 1

    x = 1
    while x < i:
        exec('thread{}.join()'.format(x))
        x += 1

    s_date = time.strftime('%Y-%m-%d', time.localtime())
    req = {
        'title': '软件下发版本制作',
        'date': s_date
        # , 'req': list_req
        ,
        'file_list': file_list,
        'user_list': User.objects.all()
    }
    # print(req)
    return render(request, 'rjxf_server/make.html', req)
Exemplo n.º 13
0
def showdata3(request):
    log('start showdata3')  # zl

    # # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    res = requests.post(url='http://' + request.META.get('HTTP_HOST') + '/' +
                        'trans_zl_helloworld/abcd/boardsAPI',
                        data=request.POST)
    resp = json.loads(res.text)

    return HttpResponse(json.dumps(resp), content_type="application/json")
Exemplo n.º 14
0
def index(request):
    print('start index auth_control')
    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': False,
        'perm': 'make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})
    req = {'title': 'auth_control'}
    # print(req)
    return render(request, 'auth_control/index.html', req)
Exemplo n.º 15
0
def index(request):
    print('start index data_control')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': True,
        'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    plat_list = [{
        'plat_id': 'cib',
        'plat_name': 'V2核心系统'
    }
                 # , {'plat_id': 'v3_cib', 'plat_name': 'V3核心系统'}
                 ]
    cmdb_data = config.objects.filter(plat_id='cib')

    bank_list = []
    bank_list.clear()
    for line in cmdb_data:
        if line.name_ch[-4:] != '_CLJ':
            bank_list.append({'name': line.name, 'name_ch': line.name_ch})

    # for line in config.objects.filter(plat_id='v3_cib'):
    #     if line.name_ch[-4:] != '_CLJ':
    #         bank_list.append({
    #             'name': line.name
    #             , 'name_ch': line.name_ch
    #         })

    user = request.user
    req = {
        'title': '数据文件载入',
        'user_name': user.username,
        'date': time.strftime('%Y%m%d', time.localtime()),
        'bank_list': bank_list,
        'plat_list': plat_list
    }
    # print(req)
    return render(request, 'data_control/index.html', req)
Exemplo n.º 16
0
def upload_file(request):

    # 权限检查
    auth_data = {
        'request': request,
        'net_sc': True,
        'login': True,
        'debug': True,
        'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        resp = resp_auth
        return HttpResponse(json.dumps(resp), content_type="application/json")

    file_pwd = os.getcwd() + '/static/app/search_problem/file/'
    file_obj = request.FILES.get('file', None)
    s_date = time.strftime('%Y-%m-%d-%H:%M:%S', time.localtime())

    print(file_pwd)
    print(file_obj.name)
    print(file_obj.size)

    file_name = s_date + '-' + file_obj.name
    with open(file_pwd + file_name, 'wb') as f:
        for line in file_obj.chunks():
            f.write(line)
        message = '上传[' + file_name + ']文件成功,大小[' + str(file_obj.size) + ']'
        code = 0
        f.close()

    resp = {
        "code": code,
        "msg": message,
        "data": {
            "file_name": file_obj.name,
            "src": "/static/app/search_problem/file/" + file_name,
            "class": "layui-upload-img"
            # , "title": "building.png"
        }
    }
    # resp = {
    #     "code": 0
    #     , "msg": ""
    # }
    return HttpResponse(json.dumps(resp), content_type="application/json")
Exemplo n.º 17
0
def upload(request):
    file_obj = request.FILES.get('file', None)
    print(file_obj.name)
    print(request.GET.get('file_path'))

    # os.chdir(home_path + request.GET.get('file_path'))
    code = -1

    # 权限检查
    auth_data = {
        'request': request
        , 'net_sc': True
        , 'login': True
        , 'debug': True
        , 'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        resp = {"code": -1}
        return HttpResponse(json.dumps(resp), content_type="application/json")

    with open(home_path + request.GET.get('file_path') + file_obj.name, 'wb') as f:
        for line in file_obj.chunks():
            f.write(line)
        code = 0
        f.close()

    if code == 0 :
        r = info(
            file_name=file_obj.name
            , file_size=file_obj.size
            , update_oper=request.user.first_name
            , update_date=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
            , file_type='f'
            , file_path=request.GET.get('file_path')
        )

        r.save()

    # code 为 0 表示上传文件成功
    resp = {
        "code": code
    }
    # os.chdir(_work_path)
    return HttpResponse(json.dumps(resp), content_type="application/json")
Exemplo n.º 18
0
def index(request):
    print('start cmdb index')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'perm': 'rjxf_make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {'title': 'CMDB配置操作', 'req': list_req}
    # print(req)
    return render(request, 'cmdb/index.html', req)
Exemplo n.º 19
0
def config_bank(request):
    print('start config_bank')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'perm': 'rjxf_make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {'title': '多法人租户配置', 'req': list_req}
    # print(req)
    return render(request, 'cmdb/config_bank.html', req)
Exemplo n.º 20
0
def cmdb_plat_info(request):
    print('start cmdb_plat_info index')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': True,
        'perm': 'rjxf_make'
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {'title': 'CMDB配置操作'}
    # print(req)
    return render(request, 'cmdb/cmdb_plat_info.html', req)
Exemplo n.º 21
0
def show(request):
    print('start index show')

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    start_date = datetime.datetime.now()
    end_date = datetime.datetime.now()
    for line in range(7):
        start_date -= datetime.timedelta(days=1)
    req = {
        'title': 'show',
        'start_date': start_date.strftime("%Y-%m-%d"),
        'end_date': end_date.strftime("%Y-%m-%d")
    }
    # print(req)
    return render(request, 'qq_data/show.html', req)
Exemplo n.º 22
0
    def do_POST(self):  #POST request: Relay it to auth script
        content_length = int(self.headers['Content-Length'])

        #Get the payload
        payload_raw = self.rfile.read(content_length)
        payload = json.loads(payload_raw.decode('utf8'))

        try:  #Get the operation number
            op = int(payload["op"])
        except TypeError:  #NaN, inform the requester and send help message
            self.sendHelp(400, 'Invalid payload.\n')
            return

        try:
            response = None
            if op == 0:  #Authenticate
                response = main.auth(payload["name"], payload["password"])
            elif op == 1:  #Sign up
                response = main.signUp(payload["name"], payload["password"])
            else:  #Invalid operation
                self.sendHelp(501, 'Operation not found.\n')
                return

            if response == 0:  #Signed up correctly
                self.send(200, 'Signed up successfully. Please sign in now.')
            elif response == 1:  #Authentication error
                self.send(403, 'Username or password incorrect.')
            elif response == 2:  #Username is taken
                self.send(403, 'That name is already taken.')
            elif response == 3:  #Password is too common
                self.send(
                    403,
                    'The password cant be in the 10.000 most used passwords list.'
                )
            else:  #Authenticated correctly
                self.send(
                    200, 'Signed in successfully. Session token:\n' + response)
        except Exception as e:  #??? I dont even know why I put this in
            self.sendHelp(400, 'Invalid payload.\n')
            return
Exemplo n.º 23
0
def index(request):
    print('start index rota_day')
    search_type = request.GET.get('type')

    bank_info_list = []
    if search_type == "get":
        search_type = "get"
    elif search_type == "search":
        search_type = "search"

        # 调用数据中台API
        res = requests.post(url='http://' + request.META.get('HTTP_HOST') +
                            '/' + 'data_api/cmdb_info/',
                            data={'comm_i_info_stat': 0})
        resp = json.loads(res.text)

        for line in resp.get('comm_i_c_config_bank'):
            # yhdm=line.get('yhdm')
            # name=line.get('name')
            # name_ch=line.get('name_ch')
            # bank_msg=str(yhdm)+'_'+str(name)+'_'+str(name_ch)
            bank_info_list.append(line)

    else:
        search_type = "get"

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': False, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    req = {
        'title': '系统成功率',
        'search_type': search_type,
        'bank_info_list': bank_info_list
    }
    # print(req)
    return render(request, 'rate_system/index.html', req)
Exemplo n.º 24
0
def index(request):
    print('start index')

    # 权限检查
    auth_data = {
        'request': request
        , 'net': False
        , 'login': False
        , 'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html', {"message": resp_auth.get('msg')})

    s_date = time.strftime('%Y-%m-%d', time.localtime())
    list_req = [{'bank_id': 'v3_cib', 'bank_name': 'V3核心'}]
    req = {
        'title': 'V3核心日结查询'
        , 'date': s_date
        , 'req': list_req
    }
    return render(request, 'chkpcl_server/index.html', req)
Exemplo n.º 25
0
def index(request):
    print('start index trans_dlzf')
    user = request.user
    print(user)

    # 权限检查
    auth_data = {'request': request, 'net': True, 'login': False, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    print(user.has_perm('myApp'))
    s_date = time.strftime('%Y-%m-%d', time.localtime())
    # input = 'topfe_server'
    # f = open('/home/insp_ap/inspect/src/switch/' + input + '/config.ini', 'r', encoding='gbk')
    list_req = []
    resp = shell.getKey(
        'check[run_command:user:./trans_search/get_bank_info.sh]', _ip, _port)
    try:
        info = resp[1].decode('GBK').split('\n')
    except:
        info = resp[1]

    for line_info in info:
        if line_info.startswith('RETURN:') == True:
            list_req.append({'bank_id': line_info.split(':')[1].strip()})

    # for line in f.readlines():
    #     line = line.rstrip('\n')
    #     if line.startswith('#') != True:
    #         # print(line.split(':')[1] + '_' + line.split(':')[0])
    #         list_req.append({'bank_id': line.split(':')[1], 'bank_name': line.split(':')[0]})
    # print(list_req)
    req = {'title': '代理支付交易查询', 'date': s_date, 'req': list_req}
    # print(req)
    return render(request, 'trans_dlzf/index.html', req)
Exemplo n.º 26
0
def add_data(request):
    log('start add_data')

    # 权限检查
    auth_data = {'request': request, 'net': False, 'login': True, 'perm': ''}
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    getListJson()

    s_date = time.strftime('%Y-%m-%d', time.localtime())

    req = {
        'title': 'abcd',
        'date': s_date,
        'stat_list_json': stat_list_json,
        'team_list_json': team_list_json,
        'department_list_json': department_list_json,
        'person_list_json': person_list_json,
        'bank_list_json': bank_list_json
    }
    return render(request, 'trans_zl_helloworld/add_data.html', req)
Exemplo n.º 27
0
def new(request):
    print('index new')
    type = request.GET.get('type')
    print('type = [' + str(type) + ']')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'login': True,
        'debug': False,
        'perm': 'rjxf_server.view_flow'
    }

    resp_auth = main.auth(auth_data)
    # print('user : '******'code') == False:
        return render(request, 'alarm/resp.html',
                      {"message": resp_auth.get('msg')})

    t1 = time.time()

    # 调用数据中台API
    # 取人员名单
    res = requests.post(url='http://' + request.META.get('HTTP_HOST') + '/' +
                        'data_api/oper/',
                        data={})
    resp = json.loads(res.text)
    t2 = time.time()
    t = (t2 - t1) * 1000
    print('oper use ' + str(t))

    # 取合作行名 data_api/cib_qd_count/
    res2 = requests.post(url='http://' + request.META.get('HTTP_HOST') + '/' +
                         'data_api/cmdb_info/',
                         data={"comm_s_plat_id": "cib"})
    resp2 = json.loads(res2.text)

    t3 = time.time()
    t = (t3 - t2) * 1000
    print('cmdb_info use ' + str(t))

    # 调用数据中台API
    res3 = requests.post(url='http://' + request.META.get('HTTP_HOST') + '/' +
                         'data_api/search_problem/',
                         data={"comm_i_info_stat": 0})
    resp3 = json.loads(res3.text)

    t4 = time.time()
    t = (t4 - t3) * 1000
    print('search_problem use ' + str(t))

    req = {
        'title': '小鲲知道',
        'oper': resp.get('data'),
        'bank_info': resp2.get('comm_i_c_config_bank'),
        'comm_i_info_channel': resp3.get('comm_i_info_channel'),
        'comm_i_info_type': resp3.get('comm_i_info_type'),
        'type': type
    }
    print('ok')
    return render(request, 'search_problem/new.html', req)
Exemplo n.º 28
0
def spotify_login():
    auth(request.url)
    return request.url
Exemplo n.º 29
0
def post(request):
    print('start post')
    os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.ZHS16GBK'
    os.environ['ORACLE_HOME'] = '/oracle/orasoft/product/11.2.0/dbhome_1'
    # req = json.loads(sys.argv[1])
    # req = sys.argv[1]
    print(request.POST.get('recid'))
    print(request.POST)

    # httpResp = "保存成功,感谢您对知识库的完善:)"

    auth_data = {
        'request': request
        # , 'net_sc': True
        ,
        'login': True,
        'debug': False,
        'perm': ''
    }
    resp_auth = main.auth(auth_data)
    if resp_auth.get('code') == False:
        resp = {"msg": '风险控制,生产环境不得保存信息,请谅解:)'}
        return HttpResponse(json.dumps(resp), content_type="application/json")

    def UpdateKey(a, b):
        if a in request.POST:
            print("ok")
        try:
            if request.POST.get(a) == '':
                print('UpdateKey try row ' + a + ':' + str(b))
                return row.get(b)
            else:
                print('UpdateKey except req ' + a + ':' + str(b))
                return request.POST.get(a).replace('\xa0',
                                                   ' ').replace('\u202c', ' ')
                # return request.POST.get(a)
        except:
            print('UpdateKey except ' + a + ':' + str(b))
            return ''

    def runsql(input_cursor, input_sql, input_data):
        try:
            input_cursor.execute(input_sql, input_data)
            conn.commit()
            input_cursor.close()
            return "保存成功,感谢您对知识库的完善:)"
        except cx_Oracle.DatabaseError as msg:
            return '处理方式目前最大内容长度为:3000字节</br>' + str(msg)
        except UnicodeEncodeError as msg:
            return '检测到异常的字符,请联系开发人员处理</br>' + str(msg)
        cursor.close()

    conn = cx_Oracle.connect(main.getConnInfo())
    cursor = conn.cursor()

    if request.POST.get('recid') == '0':
        print('insert data')
        insert_cursor = conn.cursor()
        sql = 'insert into MYVIEW_INFO_DATA(recid,text,proc,username,tel,mail,input,setdate) values(seq_info.nextval,:text,:proc,:username,:tel,:mail,:input,:setdate)'
        data = {
            "text": request.POST.get('text'),
            "proc": request.POST.get('proc').replace('\xa0', ' '),
            "username": request.POST.get('username'),
            "tel": request.POST.get('tel'),
            "mail": request.POST.get('mail'),
            "input": request.POST.get('input'),
            "setdate": request.POST.get('setdate')
        }
        httpResp = runsql(insert_cursor, sql, data)
    else:
        sql = 'select * from myview_info_data where recid = ' + request.POST.get(
            'recid')
        cursor.execute(sql)
        row = cursor.fetchone()
        print('update recid ' + str(row[0]))

        update_cursor = conn.cursor()
        sql = 'update MYVIEW_INFO_DATA set text=:text, proc=:proc, username=:username, tel=:tel, mail=:mail, input=:input, setdate=:setdate where recid = ' + str(
            row[0])
        print(sql)
        data = {
            "text": UpdateKey('text', 1),
            "proc": UpdateKey('proc', 2),
            "username": UpdateKey('username', 3),
            "tel": UpdateKey('tel', 4),
            "mail": UpdateKey('mail', 5),
            "input": UpdateKey('input', 6),
            "setdate": UpdateKey('setdate', 7)
        }
        print(data)
        # update_cursor.execute(sql, data)
        httpResp = runsql(update_cursor, sql, data)

    print('msg = [' + str(httpResp) + ']')
    return HttpResponse(json.dumps({"msg": str(httpResp)}),
                        content_type="application/json")
Exemplo n.º 30
0
def new_submit(request):
    print('index new_submit')

    # 权限检查
    auth_data = {
        'request': request,
        'net': False,
        'net_sc': True,
        'login': True,
        'debug': False,
        'perm': 'rjxf_server.view_flow'
    }

    resp_auth = main.auth(auth_data)
    # print('user : '******'code') == False:
        # return render(request, 'alarm/resp.html', {"message": resp_auth.get('msg')})
        resp = {"code": resp_auth.get('code'), "msg": resp_auth.get('msg')}
        return HttpResponse(json.dumps(resp), content_type="application/json")

    input_data = json.loads(request.POST.get('input_data'))
    fwb_data = request.POST.get('fwb_data')
    fwb_text_answer = request.POST.get('fwb_text_answer')
    user = request.user

    print(input_data)
    print(fwb_data)

    if request.POST.get('type') == 'input':
        stat = 1
        answer_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
    else:
        stat = 0
        answer_date = None

    print('type = [' + request.POST.get('type') + ']')

    print(fwb_text_answer)
    if fwb_text_answer is None:
        fwb_text_answer = ''
    if input_data.get('comm_i_info_channel') is None:
        info__t_channel = None
    else:
        info__t_channel = info_channel.objects.get(
            code=input_data.get('comm_i_info_channel'))

    if input_data.get('comm_i_info_type') is None:
        info__t_type = None
    else:
        info__t_type = info_type.objects.get(
            code=input_data.get('comm_i_info_type'))

    problem_answer = BeautifulSoup(fwb_text_answer, 'html.parser')

    r = info(title=input_data.get('title'),
             trans_code=input_data.get('trans_code'),
             trans_err=input_data.get('trans_err'),
             problem_info=fwb_data,
             problem_answer=fwb_text_answer,
             problem_answer_txt=problem_answer.get_text(),
             input_oper=user.first_name,
             answer_oper=input_data.get('answer_oper'),
             bank_id=input_data.get('bank_id'),
             bank_oper=input_data.get('bank_oper'),
             problem_source=input_data.get('problem_source'),
             input_date=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
             update_date=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
             answer_date=answer_date,
             t_stat=info_stat.objects.get(stat_id=stat),
             t_channel=info__t_channel,
             t_type=info__t_type,
             info_check_flag=0,
             info_check_update=0,
             count_search=0,
             count_chick=0)
    code = 0
    msg = ''

    try:
        r.save()
        code = 0
        msg = '感谢您对知识库的完善:)'

        # 操作记录
        a = action(type=action_type.objects.get(code=3),
                   text=str(r.id),
                   oper=request.user.first_name,
                   date=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
        a.save()

        # 积分计算
        main.action_log(request, {
            "app_type": "search_problem",
            'action_type': "input",
            'info_id': r.id
        })
        if stat == 1:
            main.action_log(
                request, {
                    "app_type": "search_problem",
                    'action_type': "answer",
                    'info_id': r.id,
                    'oper': r.answer_oper
                })
    except Exception as msg_info:
        code = -1
        print(repr(msg_info))
        print(msg_info)
        print(msg_info.args[0])

        if msg_info.args[0] == 1406:
            msg = '录入失败了,答案的内容超出长度限制,入库失败了哟~~~'
        elif msg_info.args[0] == 1062:
            msg = '录入失败了,可能该标题已存在,无法重复入库~'
        else:
            msg = '录入失败了。。。<br>报错信息:' + str(msg_info)
            # msg = '录入失败了~' + str(msg_info)

    resp = {"code": code, "msg": msg}
    return HttpResponse(json.dumps(resp), content_type="application/json")