Beispiel #1
0
def job(request):
    sql_builder = StringIO()
    sql_builder.write('SELECT 1 as ID, tr.TRIGGER_NAME, tr.JOB_NAME, qct.CRON_EXPRESSION, tr.NEXT_FIRE_TIME, tr.PREV_FIRE_TIME, tr.TRIGGER_STATE')
    sql_builder.write(' FROM QRTZ_TRIGGERS tr, QRTZ_CRON_TRIGGERS qct')
    sql_builder.write(' WHERE tr.TRIGGER_NAME = qct.TRIGGER_NAME')

    sql = sql_builder.getvalue()
    sql_builder.close()

    qs = CronJob.objects.raw(sql)
    setattr(type(qs), '__len__', get_len(qs))
    page_num = request.POST.get('page')
    if page_num is None or page_num == u'':
        page_num = 1
    else:
        page_num = int(page_num)
    try:
        p = RawPaginator(qs, 10)
        jobs = p.page(page_num)
        print jobs
    except Exception as e:
        print e.message
        jobs = p.page(1)

    return render(request, 'jobs.html', {'jobs': jobs, 'title': u'定时任务'})
Beispiel #2
0
def list_merchant_channel_service(request):
    query_sql = StringIO()
    query_sql.write("SELECT 1 as id, tpu.USER_ID as merchant_id, tpu.TITLE as merchant_name, tc.CHANNEL_ID,")
    query_sql.write(" tc.TITLE AS CHANNEL_NAME, tps.SERVICE_ID, tps.TITLE as SERVICE_NAME, tpa.ACCOUNT_ID, tpo.ORG_ID,tpo.ORG_NAME ")
    query_sql.write(" FROM T_PAYMENT_USER tpu, T_CHANNEL tc,T_CHANNEL_MERCHANT tcm, T_PAYMENT_SERVICE tps, ")
    query_sql.write(" T_CHANNEL_SERVICE tcs, T_PAYMENT_ACCOUNT tpa, T_PAYMENT_DELEGATION tpd, T_PAYMENT_ORG tpo ")
    query_sql.write(" WHERE tc.CHANNEL_ID = tcm.CHANNEL_ID AND tpu.USER_ID = tcm.USER_ID")
    query_sql.write(" AND tc.CHANNEL_ID = tcs.CHANNEL_ID AND tps.SERVICE_ID = tcs.SERVICE_ID")
    query_sql.write(" AND tps.SERVICE_ID= tpd.SERVICE_ID AND tpd.ACCOUNT_ID = tpa.ACCOUNT_ID AND tpu.USER_ID = tpa.USER_ID")
    query_sql.write(" AND tpd.ORG_ID = tpo.ORG_ID and tpa.ORG_ID = tpo.ORG_ID")

    params = []
    channel_id = request.POST.get('channel_id')
    service_id = request.POST.get('service_id')
    merchant_id = request.POST.get('merchant_id')

    if channel_id is not None and channel_id != u'':
        query_sql.write(" AND tc.CHANNEL_ID = %s")
        params.append(channel_id)
    if service_id is not None and service_id != u'':
        query_sql.write(" AND tps.SERVICE_ID = %s")
        params.append(service_id)
    if merchant_id is not None and merchant_id != u'':
        query_sql.write(" AND tpu.USER_ID = %s")
        params.append(merchant_id)

    sql = query_sql.getvalue()
    query_sql.close()

    qs = MerchantChannelServiceModel.objects.raw(sql, params if len(params) > 0 else None)
    page_num = request.POST.get('page')
    if page_num is None or page_num == u'':
        page_num = 1
    else:
        page_num = int(page_num)
    try:
        p = RawPaginator(qs, 10)
        results = p.page(page_num)
    except Exception as e:
        print e.message
        results = p.page(1)

    return render(request, 'merchant_channel_service_payorg.html', {'results': results, 'title': u'商户渠道业务支付方式'})