Skip to content

Commit 4772ecf

Browse files
committed
python op web
1 parent 8cbb203 commit 4772ecf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+103785
-0
lines changed

taiyangxue/python-op2/app.py

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# @Time : 2020/8/26 14:48
4+
# @Author : way
5+
# @Site :
6+
# @Describe:
7+
8+
import os
9+
import sys
10+
11+
# sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
12+
13+
from flask import Flask, render_template, jsonify
14+
from datasource.main import SaleRecord, DBSqlite
15+
from flask import request
16+
# import data as sd
17+
# from .data import SourceData
18+
19+
app = Flask(__name__)
20+
21+
source = {}
22+
datasource = SaleRecord(DBSqlite("datasource/database.db"))
23+
24+
@app.route('/')
25+
@app.route('/check_rate')
26+
def check_rate():
27+
data = datasource.show_check_rate(rtype='dict')
28+
ret = [['date', '1组', '2组', '3组', '4组', '5组']]
29+
for d in data:
30+
row = []
31+
for k in d:
32+
row.append(d[k])
33+
ret.append(row)
34+
return render_template('check_rate.html', title='打卡率', data=ret)
35+
36+
# 成员数据
37+
@app.route('/memberdata')
38+
def memberdata():
39+
return render_template('memberdata.html', title='成员数据')
40+
41+
# 组长数据
42+
@app.route('/teamleader')
43+
def teamleader():
44+
return render_template('teamleader.html', title='组长数据')
45+
46+
@app.route('/sale')
47+
def sale_page():
48+
return render_template('sale.html', title='开单数据')
49+
50+
#-------api----------
51+
@app.route('/api/memberdata')
52+
def api_memberdata():
53+
data = {'data': datasource.show_member_score(rtype='dict')}
54+
return jsonify(data)
55+
56+
@app.route('/api/teamcheckdetail')
57+
def api_teamcheckdetail():
58+
date = request.args.getlist('date')[0]
59+
team = request.args.getlist('team')[0]
60+
data = {'data': datasource.get_team_check_detail(team= team, date=date)}
61+
return jsonify(data)
62+
63+
@app.route('/api/teamleader')
64+
def api_teamleader():
65+
data = {'data': datasource.show_leader_score(rtype='dict')}
66+
return jsonify(data)
67+
68+
@app.route('/api/sale')
69+
def api_sale():
70+
data = {'data': datasource.get_sale_data()}
71+
return jsonify(data)
72+
73+
if __name__ == "__main__":
74+
app.run(host='127.0.0.1', debug=True)
75+

taiyangxue/python-op2/datasource/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2021/08/08 4组/张三-123456- 开单
2+
2021/08/08 1组/李四-123457- 开单
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import requests
2+
import json
3+
4+
def get_check_data(date, limit=1, sessionid='4551f206c64'):
5+
headers = {
6+
'authority': 'bushu.jingdaka.com',
7+
'pragma': 'no-cache',
8+
'cache-control': 'no-cache',
9+
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
10+
'sec-ch-ua-mobile': '?0',
11+
'upgrade-insecure-requests': '1',
12+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
13+
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
14+
'sec-fetch-site': 'none',
15+
'sec-fetch-mode': 'navigate',
16+
'sec-fetch-user': '?1',
17+
'sec-fetch-dest': 'document',
18+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
19+
'cookie': 'beegosessionID=%s;' % sessionid,
20+
}
21+
22+
params = (
23+
('team_id', '0'),
24+
('search_name', ''),
25+
('course_id', '1099357'),
26+
('record_at', date),
27+
('calendar_id', '0'),
28+
('limit', limit),
29+
('offset', '0'),
30+
)
31+
32+
response = requests.get('https://bushu.jingdaka.com/bg/course/userdatedata', headers=headers, params=params)
33+
data = json.loads(response.text)
34+
rows = []
35+
if data['err_code'] == 0:
36+
for d in data['data']['user_data']:
37+
if d['user_id'] not in [53433468,53433325]:
38+
rows.append((d['user_id'], date, '√'))
39+
else:
40+
print("抓取出错了:", data)
41+
return rows
42+
43+
if __name__ == '__main__':
44+
print(get_check_data('2021-08-04'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
Navicat Premium Data Transfer
3+
4+
Source Server : sale3
5+
Source Server Type : SQLite
6+
Source Server Version : 3030001
7+
Source Schema : main
8+
9+
Target Server Type : SQLite
10+
Target Server Version : 3030001
11+
File Encoding : 65001
12+
13+
Date: 12/08/2021 00:57:47
14+
*/
15+
16+
PRAGMA foreign_keys = false;
17+
18+
-- ----------------------------
19+
-- Table structure for tbas_score
20+
-- ----------------------------
21+
DROP TABLE IF EXISTS "tbas_score";
22+
CREATE TABLE "tbas_score" (
23+
"type" TEXT,
24+
"value" integer,
25+
"title" TEXT
26+
);
27+
28+
-- ----------------------------
29+
-- Table structure for tprj_activity
30+
-- ----------------------------
31+
DROP TABLE IF EXISTS "tprj_activity";
32+
CREATE TABLE "tprj_activity" (
33+
"mixin_id" INTEGER NOT NULL,
34+
"std_id" INTEGER,
35+
"date" TEXT,
36+
"type" text,
37+
"count" INTEGER,
38+
"check_type" TEXT,
39+
"cal_done" real
40+
);
41+
42+
-- ----------------------------
43+
-- Table structure for tprj_leader_score
44+
-- ----------------------------
45+
DROP TABLE IF EXISTS "tprj_leader_score";
46+
CREATE TABLE "tprj_leader_score" (
47+
"mixin_id" INTEGER,
48+
"score" integer
49+
);
50+
51+
-- ----------------------------
52+
-- Table structure for tprj_team_check_rate
53+
-- ----------------------------
54+
DROP TABLE IF EXISTS "tprj_team_check_rate";
55+
CREATE TABLE "tprj_team_check_rate" (
56+
"team" TEXT,
57+
"date" TEXT,
58+
"rate" integer
59+
);
60+
61+
-- ----------------------------
62+
-- Table structure for tprj_team_score
63+
-- ----------------------------
64+
DROP TABLE IF EXISTS "tprj_team_score";
65+
CREATE TABLE "tprj_team_score" (
66+
"team" TEXT,
67+
"score" integer
68+
);
69+
70+
-- ----------------------------
71+
-- Table structure for tprj_team_score_detail
72+
-- ----------------------------
73+
DROP TABLE IF EXISTS "tprj_team_score_detail";
74+
CREATE TABLE "tprj_team_score_detail" (
75+
"team" TEXT,
76+
"score" integer,
77+
"date" TEXT
78+
);
79+
80+
-- ----------------------------
81+
-- Table structure for tprj_user
82+
-- ----------------------------
83+
DROP TABLE IF EXISTS "tprj_user";
84+
CREATE TABLE "tprj_user" (
85+
"mixin_id" INTEGER NOT NULL,
86+
"std_id" INTEGER,
87+
"name" TEXT,
88+
"team" TEXT,
89+
"title" TEXT,
90+
PRIMARY KEY ("mixin_id")
91+
);
92+
93+
-- ----------------------------
94+
-- Table structure for tprj_user_score
95+
-- ----------------------------
96+
DROP TABLE IF EXISTS "tprj_user_score";
97+
CREATE TABLE "tprj_user_score" (
98+
"mixin_id" INTEGER,
99+
"score" integer,
100+
"team" TEXT,
101+
"title" TEXT
102+
);
103+
104+
-- ----------------------------
105+
-- Table structure for tprj_user_score_detail
106+
-- ----------------------------
107+
DROP TABLE IF EXISTS "tprj_user_score_detail";
108+
CREATE TABLE "tprj_user_score_detail" (
109+
"mixin_id" INTEGER,
110+
"score" integer,
111+
"team" TEXT,
112+
"title" TEXT,
113+
"date" TEXT
114+
);
115+
116+
PRAGMA foreign_keys = true;

0 commit comments

Comments
 (0)