This commit is contained in:
512song committed 2025-12-22 21:13:47 +08:00
1 parent 6803e6fff6
commit b894e793a5
5 files changed
+1705 -202

No files matched your search

@@ -85,7 +85,7 @@
"id": "2ce125a6-a42f-4dd1-8c9c-a6a4ebcfce65",
"metadata": {},
"source": [
"## 体测人员导入(2025年11月)"
"### 体测人员导入(2025年11月)"
]
},
{
@@ -123,6 +123,67 @@
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "22b07903-00a2-437a-b7fc-73723496fe50",
"metadata": {},
"source": [
"### 体测人员导入(乒乓球高阶培训班)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "e08d1b73-ddbd-434e-a843-2c28803a7725",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T10:51:18.804347Z",
"iopub.status.busy": "2025-12-22T10:51:18.804029Z",
"iopub.status.idle": "2025-12-22T10:51:18.825533Z",
"shell.execute_reply": "2025-12-22T10:51:18.825029Z",
"shell.execute_reply.started": "2025-12-22T10:51:18.804321Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"48 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/新疆油田乒乓球高阶培训班成员名单.xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"\n",
"for n in range(2, sheet.max_row+1):\n",
" code = int(sheet.cell(n, 1).value)\n",
" person.setdefault(str(code), {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" if sheet.cell(n,2).value is not None:\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" else:\n",
" dict1['unit'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 7).value).replace('/','-').split(' ')[0]\n",
" dict1['phone'] = sheet.cell(n,6).value \n",
" dict1['age'] = int(sheet.cell(n,5).value) \n",
" dict1['month'] = int(sheet.cell(n,5).value)*12\n",
" person[code] = dict1\n",
"filename = 'data/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "6bcd45c2-10af-4d5f-9e0b-5cd1df4f7a7f",
@@ -185,6 +246,48 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "eb757f8a-8a98-47e5-a9db-a361da70dd54",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T10:59:29.789147Z",
"iopub.status.busy": "2025-12-22T10:59:29.788475Z",
"iopub.status.idle": "2025-12-22T10:59:29.801239Z",
"shell.execute_reply": "2025-12-22T10:59:29.800106Z",
"shell.execute_reply.started": "2025-12-22T10:59:29.789091Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"import my_module as My\n",
"\n",
"filename = 'data/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"filename = 'data/marks_20251222.csv'\n",
"re_ta = My.get_result(filename,dict1)\n",
"\n",
"\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))"
]
},
{
"cell_type": "markdown",
"id": "e75065f5-127e-49c9-bc1f-c0843ab1996b",
@@ -229,10 +332,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 40,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:30.947600Z",
"iopub.status.busy": "2025-12-22T11:00:30.946785Z",
"iopub.status.idle": "2025-12-22T11:00:30.964388Z",
"shell.execute_reply": "2025-12-22T11:00:30.963715Z",
"shell.execute_reply.started": "2025-12-22T11:00:30.947526Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import json\n",
"import time\n",
@@ -240,7 +359,7 @@
"\n",
"#list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','height','weight']\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
"filename = 'data/result_新疆油田采油工艺研究院1.json'\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k, v in dict2.items():\n",
@@ -263,7 +382,7 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_新疆油田采油工艺研究院1-1.json'\n",
"filename = f'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
@@ -438,15 +557,15 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 26,
"id": "f4fc0e48-5c8a-4ad9-817e-dd8dd1bf7b55",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-15T00:10:27.023346Z",
"iopub.status.busy": "2025-12-15T00:10:27.023028Z",
"iopub.status.idle": "2025-12-15T00:10:27.028151Z",
"shell.execute_reply": "2025-12-15T00:10:27.027670Z",
"shell.execute_reply.started": "2025-12-15T00:10:27.023320Z"
"iopub.execute_input": "2025-12-18T14:06:54.465137Z",
"iopub.status.busy": "2025-12-18T14:06:54.464816Z",
"iopub.status.idle": "2025-12-18T14:06:54.472416Z",
"shell.execute_reply": "2025-12-18T14:06:54.471751Z",
"shell.execute_reply.started": "2025-12-18T14:06:54.465112Z"
}
},
"outputs": [
@@ -454,14 +573,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2025-07-03 2025-08-18\n"
"2025-06-27 2025-07-02\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/result_新疆油田采油工艺研究院1-1.json'\n",
"filename = 'data/result_南京化工-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -826,6 +945,107 @@
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "27047aae-81ad-4996-85af-ec77c5f33db5",
"metadata": {},
"source": [
"### 导入问卷信息(乒乓球高阶培训班)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "01ee701f-af8c-48ff-ad3c-2315c1ce16d7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:47.106304Z",
"iopub.status.busy": "2025-12-22T11:00:47.105790Z",
"iopub.status.idle": "2025-12-22T11:00:47.126495Z",
"shell.execute_reply": "2025-12-22T11:00:47.125968Z",
"shell.execute_reply.started": "2025-12-22T11:00:47.106259Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"list1 = []\n",
"filename = 'data/sql_20251222-1.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" list1.append(line)\n",
"filename = 'data/新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"phone = {}\n",
"for k,v in dict3.items():\n",
" if 'phone' in v.keys():\n",
" phone[str(v['phone'])] = k\n",
"\n",
"\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone_num = str(item[0])[2:]\n",
" if phone_num in phone:\n",
" content = json.loads(json.loads(item[1]))\n",
" tcm = []\n",
" spine = []\n",
" psy = []\n",
" for i in range(0,45):\n",
" psy.append(0)\n",
" psy[44] = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" for k, v in content.items(): \n",
" if 'psy' in k:\n",
" i = int(k[3:])\n",
" psy[i-1] = int(v)\n",
" if 'tcm' in k:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" if 'spine' in k:\n",
" i = int(k[5:])\n",
" if i<23:\n",
" spine[i-1] = int(v)\n",
" else:\n",
" spine[i] = int(v)\n",
" for i in range(26,40):\n",
" new_valve = 1+psy[i]\n",
" psy[i] = new_valve \n",
" code = phone[phone_num]\n",
" if code in dict3.keys(): \n",
" dict1[code]['tcm'] = tcm \n",
" dict1[code]['spine'] = spine\n",
" dict1[code]['psy'] = psy\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "8d5f4103-0d1e-4711-b324-ece360f8dcd3",
@@ -1038,6 +1258,90 @@
"print(i)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "635709b0-5777-481f-8639-6988b8e31d82",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T11:00:53.865364Z",
"iopub.status.busy": "2025-12-22T11:00:53.864923Z",
"iopub.status.idle": "2025-12-22T11:01:08.186681Z",
"shell.execute_reply": "2025-12-22T11:01:08.186051Z",
"shell.execute_reply.started": "2025-12-22T11:00:53.865321Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24\n"
]
}
],
"source": [
"import requests\n",
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_新疆油田乒乓球高阶培训班.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"file_path ='./新疆油田乒乓球高阶培训班/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"#list2 = ['185','186','187','188','189','190','191','192','193','194','195','196','197','198']\n",
"for k, v in dict1.items():\n",
" \n",
" list1 = []\n",
" mydata = {}\n",
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '新疆油田乒乓球高阶培训班'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
" if v['sex'] == '男':\n",
" mydata['gender'] = 'male'\n",
" else:\n",
" mydata['gender'] = 'female'\n",
" \n",
" mydata['month'] = v['month']\n",
" mydata['fits'] = {}\n",
" survey_list = ['tcm','psy','spine']\n",
" for item in survey_list:\n",
" if item in v.keys():\n",
" mydata.setdefault('surveys',{})\n",
" mydata['surveys'][item] = v[item]\n",
" \n",
" \n",
" #mydata['fits'] = {}\n",
" for item in list_item:\n",
" if item in v.keys():\n",
" mydata.setdefault('fits',{})\n",
" if item in ['lung','pushup','step','situp']:\n",
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
" else:\n",
" mark = v[item]['成绩'].split()[0]\n",
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
" if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
" #if len(mydata['fits']) >2 : \n",
" list1.append(mydata)\n",
" i+=1\n",
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
" #print(id,v['name'],x.text)\n",
" #print(mydata)\n",
" #x.close()\n",
"print(i)"
]
},
{
"cell_type": "markdown",
"id": "ffb6c02a-8ae1-4332-96ca-ce541bfbf0be",