Exemple #1
0
def letao_manage(request):
    grid_id = request.GET.get('grid_id', '')
    export = request.GET.get('export', '')
    if grid_id:
        letaocon = BaseModelHelp().get_grid_dbcon(dbname='letaotrailcenter',
                                                  grid_id=grid_id)
        sql = request.GET['sql']
        if "password" in sql:
            return Response({'error': '带有敏感字符'},
                            status=status.HTTP_400_BAD_REQUEST)
        sql = f"{sql} limit 100"
        data = letaocon.select(sql)
        if data == False:
            return Response({'error': '该节点无数据'},
                            status=status.HTTP_400_BAD_REQUEST)
        title = []
        for key in list(data):
            title = list(key.keys())
            key['password'] = ''
        if export:
            d = {}
            for key in title:
                d[key] = key
            return Excel_export('weixin-site-list', d, list(data)).export_csv()
        else:
            return JsonResponse(list(data), safe=False)
    else:
        return Response({'error': '请先选择grid'},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #2
0
def test(request):

    siteid = request.GET['siteid']
    stationinfo_data = BaseModelHelp().get_workorder_info(siteid)
    grid_id = stationinfo_data[0]['station_info__grid_id']
    # 根据节点获取kf库配置
    kf_dbcon = BaseModelHelp().get_grid_dbcon(grid_id=grid_id,dbname='kf')
    KfModel(kf_dbcon).modify_t2d_site_classify(siteid)
    data = KfModel(kf_dbcon).get_t2d_site_classify(siteid)[0]['id']
    return HttpResponse(data)
Exemple #3
0
def get_siteid_server(request):
    siteid = request.GET['siteid']
    aliobj = AliModel()
    routing = aliobj.get_siteid_routing(siteid)
    gridname = aliobj.get_url_gridname(routing[0]['scripturl'])
    kfcon = BaseModelHelp().get_grid_dbcon(gridname=gridname, dbname='kf')
    sql = f"select a.siteid,a.name,a.url,a.version_id,b.historyurl,b.spamserver,b.fileserver,b.t2dserver,b.tchatserver,b.trailserver,b.crmserver,b.dir,b.t2dmqttserver,b.tchatmqttserver,b.queryurl,b.robotserver from t2d_enterpriseinfo a, t_wdk_sit b where b.sitid='{siteid}' and a.siteid=b.sitid"
    data = kfcon.select(sql)
    if data == False:
        return Response({'error': '该节点无数据'},
                        status=status.HTTP_400_BAD_REQUEST)
    return JsonResponse(list(data), safe=False)
Exemple #4
0
def get_grid_dbcon(request):
    grid_id = request.GET['grid_id']
    if grid_id:
        kfcon = BaseModelHelp().get_grid_dbcon(dbname='kf', grid_id=grid_id)
        letaocon = BaseModelHelp().get_grid_dbcon(dbname='letaotrailcenter',
                                                  grid_id=grid_id)
        if kfcon and letaocon:
            return JsonResponse({"state": True}, safe=False)
        else:
            return JsonResponse({"state": False}, safe=False)
    else:
        return Response({'error': '请先选择grid'},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #5
0
 def get_site_ids(self):
     if checkversion(self.site_id) == 'b2b':
         siteid_prefix = str(self.site_id.split('_')[0]) + '_%'
         sql = f"SELECT siteid FROM t2d_enterpriseinfo where siteid like \"{siteid_prefix}\""
         kf_dbcon = BaseModelHelp().get_grid_dbcon(gridname=self.grid_name,
                                                   dbname='kf')
         siteid_data = kf_dbcon.select(sql)
         siteid_list = []
         for site_id in siteid_data:
             siteid_list.append(site_id['siteid'])
         return siteid_list
     else:
         return [self.site_id]
Exemple #6
0
def get_siteid_weixin(request):
    grid_id = request.GET.get("grid_id", '')
    export = request.GET.get('export', '')
    if grid_id:
        try:
            kfcon = BaseModelHelp().get_grid_dbcon(dbname='kf',
                                                   grid_id=grid_id)
            data = KfModel(kfcon).get_weixin_list()
            if export:
                title = {
                    "openid": "openid",
                    "企业ID": "企业id",
                    "企业名称": "企业名称",
                    '微信公众号': "微信公众号"
                }
                return Excel_export('weixin-site-list', title,
                                    data).export_csv()
            else:
                return JsonResponse(list(data), safe=False)
        except:
            return Response({'error': '该节点无数据'},
                            status=status.HTTP_400_BAD_REQUEST)
    else:
        return Response({'error': '请先选择grid'},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #7
0
def get_server_siteid(request):
    grid_id = request.GET.get('grid_id', '')
    #export=1为导出,默认等于0
    export = request.GET.get('export', '')
    if grid_id:
        data_list = BaseModelHelp().get_grid_siteid(grid_id)
        siteid_str = ''
        for key in list(data_list):
            siteid_str += '"' + key['company_id'] + '",'
        siteid_str = siteid_str[:-1]
        data = AliModel().get_siteid_routing_list(siteid_str)
        if data == False:
            return Response({'error': '该节点无数据'},
                            status=status.HTTP_400_BAD_REQUEST)
        datas = []
        for key in list(data):
            _datas = {}
            for k in list(data_list):
                if key['siteid'] == k['company_id']:
                    _datas['siteid'] = key['siteid']
                    _datas['name'] = k[
                        'open_station__company_info__company_name']
            datas.append(_datas)
        if export:
            title = {"siteid": "企业id", "name": "企业名称"}
            return Excel_export('site-list', title, datas).export_csv()
        else:
            return JsonResponse(datas, safe=False)
    else:
        return Response({'error': '请先选择grid'},
                        status=status.HTTP_400_BAD_REQUEST)
    def week_pwd(self):
        duanxin_promptsuccess = {
            18001220003: '霍飞',
            13241388585: '王丽颖',
            18701636870: '刘晓',
            18501233134: '王云飞',
            15712938695: '杨晓',
            18813004324: '徐浩然',
            13121867233: '李玉岩',
            18810691453: '段会',
            18330021318: '李慧',
            13161487200: '丁泽漪'
        }
        youjian_promptsuccess = {
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '霍飞',
            '*****@*****.**': '王丽颖',
            '*****@*****.**': '刘晓',
            '*****@*****.**': '王云飞',
            '*****@*****.**': '杨晓',
            '*****@*****.**': '徐浩然',
            '*****@*****.**': '李玉岩',
            '*****@*****.**': '段会',
            '*****@*****.**': '李慧',
            '*****@*****.**': '运维',
            '*****@*****.**': '丁泽漪'
        }
        youjian_prompterror = {
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '运维'
        }
        duanxin_prompterror = {13311071024: '郭吉发', 18511583871: '邱瑞杰'}
        ntalker_maliqun = md5Encode("ntalker_maliqun" +
                                    MONTH_KEY[time.strftime("%m")] +
                                    time.strftime("%Y%m"))
        ntalker_maliqun_pwd = ntalker_maliqun[0:8]
        db_con_list = BaseModelHelp().get_db_list_con('kf')
        error_str = ''
        for key in db_con_list:
            try:
                user_sql = f'update t2d_user set password="******" where userid like "%ISME9754_T2D_ntalker_maliqun"'
                key.add_up_de_commit(user_sql)
            except:
                error_str += key + ','
                continue

        error_tip = f"修改(maliqun)密码异常需运维和开发者检测,异常信息:{error_str}连接数据库失败。【小能科技】"
        success_tip = f"测试账号(maliqun)密码更换为({ntalker_maliqun_pwd}),谨慎保管!【小能科技】"
        if error_str:
            for key in duanxin_prompterror:
                Sms().send(key, error_tip)
            for key in youjian_prompterror:
                Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换', error_tip)
        for key in duanxin_promptsuccess:
            Sms().send(key, success_tip)
        for key in youjian_promptsuccess:
            Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换', success_tip)
Exemple #9
0
 def get_gridconfig(self, siteid):
     try:
         data = BaseModelHelp().get_grid_getFlashserver(siteid)
         domain_name = eval(data[0]['domain_name'])
         self.user_center = domain_name['usercenter']  #用户中心的url
         self.setting_center = domain_name['dolphinsetting']  #设置的url
         self.client = domain_name['client']  #客户端的url
         self.init = domain_name['init']  #getflashserver的url
         self.getFlashserver_kf = data[0]['getFlashserver']  #客户端需传送的json
         self.getFlashserver_visitant = data[0]['visitors']  #访客端需传送的json
         return True
     except Exception as e:
         print(e)
         return False
Exemple #10
0
def get_user_trail(request):
    try:
        userid = request.GET['userid']
        siteid = userid.split('_')
        siteid = siteid[0] + '_' + siteid[1]
        data = BaseModelHelp().get_workorder_seraddress(siteid, 'trailserver')
        trail_url = data[0][
            'server_grp__ser_address__ser_address'] + f'/uids={userid}&type=3'
        return JsonResponse({'url': trail_url}, safe=False)
    except Exception as e:
        return Response({
            'error': 'userid输入错误',
            'e': str(e)
        },
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #11
0
def get_robot(request):
    grid_id = request.GET.get("grid_id", '')
    export = request.GET.get('export', '')
    if grid_id:
        kfcon = BaseModelHelp().get_grid_dbcon(dbname='kf', grid_id=grid_id)
        data = KfModel(kfcon).get_robot_list()
        if export:
            title = {
                "siteid": "siteid",
                "name": "企业名称",
                "robotversionid": "机器人类型",
                'servergroup': "服务器组"
            }
            return Excel_export('robot-site-list', title, data).export_csv()
        else:
            return JsonResponse(list(data), safe=False)
    else:
        return Response({'error': '请先选择grid'},
                        status=status.HTTP_400_BAD_REQUEST)
Exemple #12
0
def supply_order(request):
    grid_id = request.GET.get("grid_id", '')
    siteid = request.GET['siteid']
    price = request.GET['price']
    date = request.GET['date']
    clientid = request.GET['clientid']
    userid = request.GET['userid']
    ordernum = request.GET['ordernum']
    try:
        letaocon = BaseModelHelp().get_grid_dbcon(dbname='letaotrailcenter',
                                                  grid_id=grid_id)
        data = LetaoModel(letaocon).get_region_code(siteid)
        clientid = data[0][clientid]
        LetaoModel(letaocon).modify_keypage_hits(siteid=siteid,
                                                 date=date,
                                                 price=price,
                                                 userid=userid,
                                                 ordernum=ordernum,
                                                 clientid=clientid)
        return JsonResponse(True, safe=False)
    except:
        return JsonResponse(False, safe=False)
    def day_pwd(self):
        duanxin_promptsuccess_ntalker_steven = {
            13911101998: 'steven',
            18601293995: '任斌',
            13522070301: '马立群',
            13552690112: '赵林海',
            15010060738: '杜鹏飞',
            18911207028: '崔雨涵',
        }
        youjian_promptsuccess_ntalker_steven = {
            '*****@*****.**': 'steven',
            '*****@*****.**': '任斌',
            '*****@*****.**': '马立群',
            '*****@*****.**': '赵林海',
            '*****@*****.**': '杜鹏飞',
            '*****@*****.**': '崔雨涵',
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '运维'
        }
        duanxin_promptsuccess_ntalker_lizhipeng = {
            15810399849: '李自飞',
            13810706710: '李先磊'
        }
        youjian_promptsuccess_ntalker_lizhipeng = {
            '*****@*****.**': '李自飞',
            '*****@*****.**': '李先磊',
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '运维'
        }
        duanxin_promptsuccess_ralf = {15010060738: '杜鹏飞'}
        youjian_promptsuccess_ralf = {
            '*****@*****.**': '杜鹏飞',
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '运维'
        }
        youjian_prompterror = {
            '*****@*****.**': '郭吉发',
            '*****@*****.**': '运维'
        }
        duanxin_prompterror = {13311071024: '郭吉发', 18511583871: '邱瑞杰'}
        ntalker_steven = md5Encode("ntalker_steven" +
                                   MONTH_KEY[time.strftime("%m")] +
                                   time.strftime("%Y%m"))
        ntalker_steven_pwd = ntalker_steven[0:8]
        ntalker_lizhipeng = md5Encode("ntalker_lizhipeng" +
                                      MONTH_KEY[time.strftime("%m")] +
                                      time.strftime("%Y%m"))
        ntalker_lizhipeng_pwd = ntalker_lizhipeng[0:8]
        ralf = md5Encode("ralf" + MONTH_KEY[time.strftime("%m")] +
                         time.strftime("%Y%m"))
        ralf_pwd = ralf[0:8]
        db_con_list = BaseModelHelp().get_db_list_con('kf')
        error_str = ''
        for key in db_con_list:
            try:
                user_sql = f'update t2d_user set password="******" where userid like "%ISME9754_T2D_ntalker_steven"'
                key.add_up_de_commit(user_sql)
                user_sql = f'update t2d_user set password="******" where userid like "%ISME9754_T2D_ntalker_lizhipeng"'
                key.add_up_de_commit(user_sql)
                user_sql = f'update t2d_user set password="******" where userid like "%ISME9754_T2D_ralf"'
                key.add_up_de_commit(user_sql)
            except:
                error_str += key + ','
                continue

        error_tip = f"修改(maliqun)密码异常需运维和开发者检测,异常信息:{error_str}连接数据库失败。【小能科技】"
        success_tip_ntalker_steven = f"系统账号(ntalker_steven)密码更换为({ntalker_steven_pwd}),谨慎保管!【小能科技】"
        success_tip_ntalker_lizhipeng = f"系统账号(ntalker_lizhipeng)密码更换为({ntalker_lizhipeng_pwd}),谨慎保管!【小能科技】"
        success_tip_ralf = f"系统账号(ralf)密码更换为({ralf_pwd}),谨慎保管!【小能科技】"
        if error_str:
            for key in duanxin_prompterror:
                Sms().send(key, error_tip)
            for key in youjian_prompterror:
                Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换', error_tip)
        #ntalker_steven
        for key in duanxin_promptsuccess_ntalker_steven:
            Sms().send(key, success_tip_ntalker_steven)
        for key in youjian_promptsuccess_ntalker_steven:
            Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换',
                               success_tip_ntalker_steven)
        # ntalker_lizhipeng
        for key in duanxin_promptsuccess_ntalker_lizhipeng:
            Sms().send(key, success_tip_ntalker_steven)
        for key in youjian_promptsuccess_ntalker_lizhipeng:
            Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换',
                               success_tip_ntalker_lizhipeng)
        # ralf
        for key in duanxin_promptsuccess_ralf:
            Sms().send(key, success_tip_ntalker_steven)
        for key in youjian_promptsuccess_ralf:
            Email_base().email(key, '小能系统账号密码更换', '小能系统账号密码更换',
                               success_tip_ralf)
Exemple #14
0
def get_grid_list(request):
    data = BaseModelHelp().get_grid_list()
    return JsonResponse(list(data), safe=False)
Exemple #15
0
def apitest(request):
    siteid = request.GET['siteid']
    data = BaseModelHelp().get_grid_getFlashserver(siteid)
    #return HttpResponse(data)
    return JsonResponse(data,safe=False)