Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alittleTom committed Dec 2, 2016
0 parents commit 3941e5b
Show file tree
Hide file tree
Showing 265 changed files with 58,073 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/treeshow.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added CJComparison/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions CJComparison/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions CJComparison/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CjcomparisonConfig(AppConfig):
name = 'CJComparison'
Empty file.
3 changes: 3 additions & 0 deletions CJComparison/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
8 changes: 8 additions & 0 deletions CJComparison/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.test import TestCase
from CJComparison import views
# Create your tests here.

class T(TestCase):
def testname(self):
print("test")
views.executeSql()
122 changes: 122 additions & 0 deletions CJComparison/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
from django.shortcuts import render, render_to_response
from django.http import HttpResponse
from django.db import connection, connections, transaction
from treeShowMessage.models import *
import json


# Create your views here.

# 测试执行自定义sql
def executeSql(request):
cursor = connections['oracle'].cursor()
cursor.execute("select * from rwd_core_param")
transaction.commit()
list = cursor.fetchall()
print(type(list))
print(list)
return HttpResponse("ok")


# 开发多算酬金
def kf_more_cj(mxname, date):
print('--'+mxname)
cjname = get_cj_nama(mxname)
kf_cj_table_name = get_kf_cj_table(mxname, date)
cs_cj_table_name = get_cs_cj_table(cjname)
print(cjname)
print(kf_cj_table_name)
print(cs_cj_table_name)
print(date)
if (cs_cj_table_name == None):
list = []
dic = {}
dic['主键1'] = '无'
dic['主键2'] = '无'
dic['酬金'] = '没有该酬金表'
dic['渠道编码'] = '无'
list.append(dic)
json_data = json.dumps(list, ensure_ascii=False)
jsonstr = "{\"total\":" + '1' + ",\"rows\":" + json_data + "}"
return jsonstr
else:
cursor = connections['oracle'].cursor()
sql = "select data_id 主键1,data2_id 主键2,stat_VAL 酬金,LINK_ID 渠道编码 from " + kf_cj_table_name + " a where a.id= %s minus select to_char(BILL_ID), to_char(ID),to_char(CJ),to_char(CHNL_CODE) from " + cs_cj_table_name + " a where a.id= %s and a.value_month= %s"
data = [mxname, cjname, date]
cursor.execute(sql, data)
transaction.commit()
return resultToJson(cursor.fetchall())
# 测试多算酬金
def cs_more_cj(mxname, date):
cjname = get_cj_nama(mxname)
kf_cj_table_name = get_kf_cj_table(mxname, date)
cs_cj_table_name = get_cs_cj_table(cjname)
if (cs_cj_table_name == None):
list = []
dic = {}
dic['主键1'] = '无'
dic['主键2'] = '无'
dic['酬金'] = '没有该酬金表'
dic['渠道编码'] = '无'
list.append(dic)
json_data = json.dumps(list, ensure_ascii=False)
jsonstr = "{\"total\":" + '1' + ",\"rows\":" + json_data + "}"
return jsonstr
else:
cursor = connections['oracle'].cursor()
sql = "select to_char(BILL_ID) 主键1, to_char(ID) 主键2,to_char(CJ) 酬金,to_char(CHNL_CODE) 渠道编码 from " + cs_cj_table_name + " a where a.id= %s and a.value_month=%s minus select data_id,data2_id,stat_VAL,LINK_ID from " + kf_cj_table_name + " a where a.id=%s"
data = [cjname, date, mxname]
cursor.execute(sql, data)
transaction.commit()
return resultToJson(cursor.fetchall())


# 返回拼接好的开发酬金表
def get_kf_cj_table(cjname, date):
cursor = connections['oracle'].cursor()
cursor.execute("select sch_id from rwd_core_param a where a.code= %s ", [cjname])
transaction.commit()
name = cursor.fetchone()[0]
print(name + '_' + date + '_mz')
return name + '_' + date + '_mz'

# 返回测试的酬金表
def get_cs_cj_table(cjname):
if (cjname == ""):
return None
else:
return rwd_kmk_cjhz.objects.using('oracle').get(酬金名称=cjname).酬金结果表


# 根据明细name得到酬金name
def get_cj_nama(name):
return rwd_kmk_cjhz.objects.using('oracle').get(mingxi=name).酬金名称


# 取到的结果元组封装成json
def resultToJson(tuple):
list = []
for i in range(len(tuple)):
dic = {}
dic['主键1'] = tuple[i][0]
dic['主键2'] = tuple[i][1]
dic['酬金'] = tuple[i][2]
dic['渠道编码'] = tuple[i][3]
list.append(dic)
num = str(len(tuple))
json_data = json.dumps(list, ensure_ascii=False)
jsonstr = "{\"total\":" + num + ",\"rows\":" + json_data + "}"
return jsonstr


def getkftable(request):
date = str(request.GET['date']).replace('-', '')
mxname = request.GET['mxname']
# limit=request.GET['limit']
# offset=request.GET['offset']
# 分页功能未实现
return HttpResponse(kf_more_cj(mxname, date))
def getcstable(request):
date = str(request.GET['date']).replace('-', '')
mxname = request.GET['mxname']
return HttpResponse(cs_more_cj(mxname,date))
17 changes: 17 additions & 0 deletions PyMySQL-master/PyMySQL-master/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[run]
branch = True
source =
pymysql
omit = pymysql/tests/*
pymysql/tests/thirdparty/test_MySQLdb/*

[report]
exclude_lines =
pragma: no cover
except ImportError:
if DEBUG:
def __repr__
def __str__
raise NotImplementedError
def __getattr__
raise ValueError
89 changes: 89 additions & 0 deletions PyMySQL-master/PyMySQL-master/.github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--- Provide a general summary of the issue in the Title above -->

<!---
IMPORTANT NOTE:
This project is maintained one busy person having frail wife and infant daughter.
My time and energy is very limited resource. I'm not teacher or free tech support.
Don't ask a question here. Don't file an issue until you believe it's a not problem of your code.
Search friendly volunteer who can teach you or review your code on ML or Q&A site.
See also: https://medium.com/@methane/why-you-must-not-ask-questions-on-github-issues-51d741d83fde
--->


## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->

## Executable script to reproduce (for bugs)

<!--- Overwrite following code and schema --->

code:
```python
import pymysql.cursors

# Connect to the database
connection = pymysql.connect(host='localhost',
user='user',
password='passwd',
db='db',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)

try:
with connection.cursor() as cursor:
# Create a new record
sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
cursor.execute(sql, ('webmaster@python.org', 'very-secret'))

# connection is not autocommit by default. So you must commit to save
# your changes.
connection.commit()

with connection.cursor() as cursor:
# Read a single record
sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
cursor.execute(sql, ('webmaster@python.org',))
result = cursor.fetchone()
print(result)
finally:
connection.close()
```

schema:
```sql
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_bin NOT NULL,
`password` varchar(255) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
AUTO_INCREMENT=1 ;
```

## Tracebacks (for bugs)

```
paste here
```

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->

* Operating System and version:
* Python version and build (cygwin, python.org, homebrew, pyenv, Linux distribution's package, PyPy etc...)
* PyMySQL Version used:
* my.cnf if possible. If you don't have it, related system variables like [connection encoding](https://dev.mysql.com/doc/refman/5.6/en/charset-connection.html).
12 changes: 12 additions & 0 deletions PyMySQL-master/PyMySQL-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.pyc
*.pyo
__pycache__
.coverage
/dist
/PyMySQL.egg-info
/.tox
/build
/pymysql/tests/databases.json

/.idea
docs/build
Loading

0 comments on commit 3941e5b

Please sign in to comment.