Esempio n. 1
0
def insert_statistics_amount():
    # 计算昨天日期
    print('开始了')
    today = datetime.datetime.now()
    offset = datetime.timedelta(days=-1)
    yesterday = (today + offset).strftime('%Y-%m-%d')
    # 查询昨日造件数量
    piece_sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                        xml_tag='select',
                                        xml_id='select_chart_piece')
    piece_data = MysqlHandle.select_mysql_data(
        piece_sql.format(create_time=yesterday))
    piece_number = piece_data[0].get('number')
    print('piece_data---->', piece_data)
    # 查询昨日上传包数量
    app_sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                      xml_tag='select',
                                      xml_id='select_chart_app')
    app_data = MysqlHandle.select_mysql_data(
        app_sql.format(create_time=yesterday))
    app_number = app_data[0].get('number')
    print('app_number---->', app_number)

    # 将数量插入到statistics_amount中
    statistics_tuple = ((piece_number, 'PIECE'), (app_number, 'APP'))
    statistics_sql = MysqlHandle.get_xml_sql(
        xml_path='insert_sql',
        xml_tag='insert',
        xml_id='insert_into_statistics_data')
    for inner in statistics_tuple:
        tag = MysqlHandle.delete_update_insert_mysql_data(
            statistics_sql.format(date_record=yesterday,
                                  count=inner[0],
                                  category=inner[1]))
        print('tag----->', tag)
Esempio n. 2
0
    def IdNo(self):
        try:
            date = datetime.datetime.now().strftime('%m-%d')
            month_day = ''.join(date.split('-'))

            sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                          xml_tag='select',
                                          xml_id='select_regions_code')
            list = MysqlHandle.select_mysql_data(sql)
            dict = list[0]
            city_code = dict['regions_code']

            key = '\d{18}|\d{17}X'
            result = requests.get(
                'http://sfz.uzuzuz.com/?region=%s&birthday=%s%s&sex=2&num=1' %
                (city_code, self.year, month_day)).text
            data = re.findall(key, result)
            data = ''.join(data)
            sql = MysqlHandle.get_xml_sql(xml_path='update_sql',
                                          xml_tag='update',
                                          xml_id='update_regions_enabled')
            sql = sql.format(regions_code=city_code)
            MysqlHandle.delete_update_insert_mysql_data(sql)
            print('我被调用了')
        except Exception as e:
            self.code = 1
            return '身份证id生成接口出现问题---详情请咨询小叶同学'
        return data
Esempio n. 3
0
def del_app_list(request):
    column_id = request.POST['column_id']
    MysqlHandle.reConnect()
    sql_del = MysqlHandle.get_xml_sql(xml_path='delete_sql',
                                      xml_tag='delete',
                                      xml_id='delete_app_list_id')  # 删除app的sql
    sql_path = MysqlHandle.get_xml_sql(
        xml_path='select_sql', xml_tag='select',
        xml_id='delete_file_path')  # 查找app路径的sql
    data = MysqlHandle.select_mysql_data(sql_path.format(id=column_id))[0]
    app_path = data.get('appPath')
    app_path = './static/' + app_path[:18]
    try:
        shutil.rmtree(app_path)
    except Exception as e:
        tag = 2
    tag = MysqlHandle.delete_update_insert_mysql_data(
        sql_del.format(id=column_id))

    if tag == 1:
        return HttpResponse('1')
    elif tag == 2:
        return HttpResponse('2')
    else:
        return HttpResponse('0')
def delete_token_return_lend_request_id(request):
    data = request.JSON
    sale_no = data['sale_no']
    mobile = data['mobile']
    print('data======>', mobile)

    result = {'code': '202', 'data': '没有此手机号'}
    try:
        sql1 = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                       xml_tag='select',
                                       xml_id='select_lend_request_id')
        print(sql1.format(mobile=mobile))
        sql_data1 = MysqlHandle.select_mysql_data(sql1.format(mobile=mobile))
        sql2 = MysqlHandle.get_xml_sql(xml_path='delete_sql',
                                       xml_tag='delete',
                                       xml_id='delete_user_token')
        sql_data2 = MysqlHandle.delete_update_insert_mysql_data(
            sql2.format(sale_no=sale_no))

    except Exception as e:
        result['code'] = '400'
        result['data'] = e
        return JsonResponse(result, status=400)
    if sql_data1:
        result['code'] = '200'
        result['data'] = sql_data1[0]
    return JsonResponse(result, status=200)
Esempio n. 5
0
def qr_ios_download(request):
    ids = request.GET['id']
    sql_select = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                         xml_tag='select',
                                         xml_id='select_ios_qr_path')
    data = MysqlHandle.select_mysql_data(sql_select.format(id=ids))[0]

    return render(request, 'qr-ios-download.html', {'data': data})
Esempio n. 6
0
def update_app(request):
    ids = request.GET['id']

    sql_select = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                         xml_tag='select',
                                         xml_id='update_app_list')
    MysqlHandle.reConnect()
    data = MysqlHandle.select_mysql_data(sql_select.format(id=ids))[0]
    data['describe'] = data['describe'].replace("\r\n", "\\n")
    message = ''
    if request.method == 'POST':
        appType = request.POST.get('app_type')
        environment = request.POST.get('environment')
        customeroruser = request.POST.get('customeroruser')
        isfinal = request.POST.get('isfinal')
        app_version = request.POST.get('app_version')
        describe = request.POST.get('describe')
        test_or_beta = request.POST.get('test_or_beta')
        sql = MysqlHandle.get_xml_sql(xml_path='update_sql',
                                      xml_tag='update',
                                      xml_id='update_app_manage')
        tag = MysqlHandle.delete_update_insert_mysql_data(
            sql.format(appType=appType,
                       environment=environment,
                       customerOruser=customeroruser,
                       isFinal=isfinal,
                       appVersion=app_version,
                       describe=describe,
                       test_or_beta=test_or_beta,
                       id=ids))
        if tag == 0 or tag == 1:
            MysqlHandle.reConnect()
            data = MysqlHandle.select_mysql_data(sql_select.format(id=ids))[0]
            message = '修改成功!'
        else:
            message = '修改失败!'

    return render(request, 'update_app.html', {
        'data': data,
        'message': message
    })
def ProductIsRequired(request):
    data = request.JSON
    product_name = data['product_name']
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                  xml_tag='select',
                                  xml_id='search_product_required')
    sql_data = MysqlHandle.select_mysql_data(
        sql.format(product_name=product_name))
    result_data = []
    for inner in sql_data:
        result_data.append(inner["material_type"])
    result = {'code': 200, 'data': result_data}
    print('必填项-----》', result)
    return JsonResponse(result, status=200)
Esempio n. 8
0
def welcome(request):
    date = []
    app_count = []
    piece_count = []
    # 计算一周前今天的日期
    today = datetime.datetime.now()
    offset = datetime.timedelta(days=-7)
    hebdomad_ago = (today + offset).strftime('%Y-%m-%d')
    print('一周前的今天', hebdomad_ago)
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql', xml_tag='select', xml_id='select_statistics_amount_app_data')
    data = MysqlHandle.select_mysql_data(sql.format(hebdomad_ago=hebdomad_ago))
    for i in data:
        date.append(i['date'])
        app_count.append(i['count'])

    # 查询进件数
    piece_sql = MysqlHandle.get_xml_sql(xml_path='select_sql', xml_tag='select',
                                        xml_id='select_statistics_amount_piece_data')
    piece_data = MysqlHandle.select_mysql_data(piece_sql.format(hebdomad_ago=hebdomad_ago))
    for i in piece_data:
        piece_count.append(i['count'])
    result = {'date': mark_safe(date), 'piece_count': piece_count, 'app_count': app_count}
    print('result=======>', result)
    return render(request, 'welcome.html', result)
def mobile_to_id_status(request):
    data = request.JSON
    mobile = data['mobile']
    mobile_str = ''
    print('views 中 mobile----》', mobile)
    for i in mobile:
        mobile_str = mobile_str + '"%s"' % i + ','
    sql_moblie = mobile_str.rstrip(',')
    print('sql_moblie----->', sql_moblie)
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                  xml_tag='select',
                                  xml_id='select_id_status_to_piece')
    print(sql.format(mobile=sql_moblie))

    data = MysqlHandle.select_mysql_data(sql.format(mobile=sql_moblie))

    result = {'code': 200, 'data': data}
    return JsonResponse(result, status=200)
Esempio n. 10
0
def app_product(request):
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                  xml_tag='select',
                                  xml_id='select_product_list')
    data = MysqlHandle.select_mysql_data(sql)
    paginator = Paginator(data, 10)
    page = request.GET.get('page', 1)
    currentPage = int(page)
    try:
        print(page)
        result = paginator.page(page)
    except PageNotAnInteger:
        result = paginator.page(1)
    except EmptyPage:
        result = paginator.page(paginator.num_pages)
    return render(request, 'app-product.html', {
        'data': result,
        'paginator': paginator
    })
Esempio n. 11
0
def piece_list(request):
    print('post----------->', request.POST)
    sql = request.DPOST.get('sql') + ' order by create_time desc'
    data = MysqlHandle.select_mysql_data(sql)
    print('sqls------>', sql)
    paginator = Paginator(data, 20)
    page = request.GET.get('page', 1)
    currentPage = int(page)
    try:
        print(page)
        result = paginator.page(page)
    except PageNotAnInteger:
        result = paginator.page(1)
    except EmptyPage:
        result = paginator.page(paginator.num_pages)
    return render(request, 'piece-list.html', {
        'piecelist': result,
        'paginator': paginator
    })
def mobile_enable(request):
    data = request.JSON
    result = {'code': '200', 'data': '1'}
    mobile = data['mobile']
    try:
        sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                      xml_tag='select',
                                      xml_id='select_mobile_enable')
        print('sql---->', sql.format(mobile=mobile))
        mysql_data = MysqlHandle.select_mysql_data(sql.format(mobile=mobile))
        dicts = mysql_data[0]
        tag = dicts['counts']
    except Exception as e:
        result['code'] = '400'
        result['data'] = e
        return JsonResponse(result, status=400)
    if tag:
        return JsonResponse(result, status=200)
    result['data'] = '%s' % tag
    return JsonResponse(result, status=200)
Esempio n. 13
0
def app_list(request):
    sql = request.DPOST.get('sql') + ' order by create_time desc'

    MysqlHandle.reConnect()
    data = MysqlHandle.select_mysql_data(sql)

    paginator = Paginator(data, 10)
    page = request.GET.get('page', 1)
    currentPage = int(page)
    try:
        print(page)
        result = paginator.page(page)
    except PageNotAnInteger:
        result = paginator.page(1)
    except EmptyPage:
        result = paginator.page(paginator.num_pages)

    return render(request, 'app-list.html', {
        'applist': result,
        'paginator': paginator
    })
def SearchResult(request):
    data = request.JSON
    status = data['status']
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                  xml_tag='select',
                                  xml_id='search_result')
    sql_data = MysqlHandle.select_mysql_data(sql.format(status=status))
    count = len(sql_data)
    result = {'code': 200, 'data': sql_data}
    if count:
        strs = ''
        for inner in sql_data:
            strs = strs + ',' + inner['mobile']
        aus = AesUtils()
        mobile_list = aus.decrpyt(strs.lstrip(','))
        for let in range(len(mobile_list)):
            sql_data[let]['mobile'] = mobile_list[let]
        result['data'] = sql_data
        return JsonResponse(result, status=200)

    result['code'] = 202
    return JsonResponse(result, status=202)
Esempio n. 15
0
def add_piece(request):
    sql = MysqlHandle.get_xml_sql(xml_path='select_sql',
                                  xml_tag='select',
                                  xml_id='select_product_list')
    data = MysqlHandle.select_mysql_data(sql)
    return render(request, 'add-piece.html', {'data': data})