1210 lines
38 KiB
Plaintext
1210 lines
38 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "04524c85-988e-4dbf-86eb-939a9db7aa28",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 体测人员导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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(code, {})\n",
|
||
" dict1 = {}\n",
|
||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||
" if sheet.cell(n,4).value is not None:\n",
|
||
" dict1['unit'] = sheet.cell(n, 4).value\n",
|
||
" else:\n",
|
||
" dict1['unit'] = ''\n",
|
||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||
" dict1['phone'] = sheet.cell(n, 6).value \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": "code",
|
||
"execution_count": null,
|
||
"id": "de3144e7-544a-4430-bf69-3d20479d50c9",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/新疆油田采油工艺研究院-1.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(code, {})\n",
|
||
" dict1 = {}\n",
|
||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||
" if sheet.cell(n,4).value is not None:\n",
|
||
" dict1['unit'] = sheet.cell(n, 4).value\n",
|
||
" else:\n",
|
||
" dict1['unit'] = ''\n",
|
||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||
" dict1['phone'] = sheet.cell(n, 6).value \n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/新疆油田采油工艺研究院-1.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": "2ce125a6-a42f-4dd1-8c9c-a6a4ebcfce65",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 体测人员导入(2025年11月)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"id": "cac3736a-56da-403b-9e62-5caaf989a6d4",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:48:24.228686Z",
|
||
"iopub.status.busy": "2025-11-21T02:48:24.228035Z",
|
||
"iopub.status.idle": "2025-11-21T02:48:26.022844Z",
|
||
"shell.execute_reply": "2025-11-21T02:48:26.022393Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:48:24.228627Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"96 ok\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/采油院11月份测试名单.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, 2).value)\n",
|
||
" person.setdefault(str(code), {})\n",
|
||
" dict1 = {}\n",
|
||
" dict1['name'] = sheet.cell(n, 1).value\n",
|
||
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||
" if sheet.cell(n,8).value is not None:\n",
|
||
" dict1['unit'] = sheet.cell(n, 8).value\n",
|
||
" else:\n",
|
||
" dict1['unit'] = ''\n",
|
||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||
" dict1['phone'] = sheet.cell(n,7).value \n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/新疆油田采油工艺研究院-202511.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",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 获取人员测试成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import datetime\n",
|
||
"import csv\n",
|
||
"from datetime import date\n",
|
||
"import my_module as My\n",
|
||
"\n",
|
||
"filename = 'data/新疆油田采油工艺研究院-1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"filename = 'data/marks_20250813.csv'\n",
|
||
"re_ta = My.get_result(filename,dict1)\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院1.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||
"print(len(re_ta))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "d1270459-e27a-46cc-b436-ec7e82b47be2",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"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_20250727.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": "code",
|
||
"execution_count": 8,
|
||
"id": "925f7152-b365-4df8-8d98-73569aef68f8",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:51:03.993610Z",
|
||
"iopub.status.busy": "2025-11-21T02:51:03.993034Z",
|
||
"iopub.status.idle": "2025-11-21T02:51:04.009834Z",
|
||
"shell.execute_reply": "2025-11-21T02:51:04.008842Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:51:03.993560Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"48\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/新疆油田采油工艺研究院-202511.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"filename = 'data/marks_20251121-1.csv'\n",
|
||
"re_ta = My.get_result(filename,dict1)\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院2511.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": "6d381859-6d21-45d2-8313-55ebbabf8bd4",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成测试得分"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 9,
|
||
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:51:14.528104Z",
|
||
"iopub.status.busy": "2025-11-21T02:51:14.527417Z",
|
||
"iopub.status.idle": "2025-11-21T02:51:14.544192Z",
|
||
"shell.execute_reply": "2025-11-21T02:51:14.543168Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:51:14.528044Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"ok!\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import my_module as My\n",
|
||
"\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",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl) \n",
|
||
"for k, v in dict2.items():\n",
|
||
" #print(k)\n",
|
||
" if v['sex'] == '男':\n",
|
||
" sex = 'M'\n",
|
||
" else:\n",
|
||
" sex = 'F' \n",
|
||
" if 'bmi' in v.keys():\n",
|
||
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||
" bmi_data = v['bmi']['成绩']\n",
|
||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||
" dict2[k]['bmi'] = {}\n",
|
||
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||
" dict2[k]['bmi']['score'] = My.cal_bmi(data1)\n",
|
||
" for item_en in list_item:\n",
|
||
" if item_en in v.keys(): \n",
|
||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||
" #print(k,v['name'])\n",
|
||
" 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",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||
"print('ok!') "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 11,
|
||
"id": "0e71f6b8-e17e-49f8-a577-7a2eb6f5e994",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:54:29.164196Z",
|
||
"iopub.status.busy": "2025-11-21T02:54:29.163638Z",
|
||
"iopub.status.idle": "2025-11-21T02:54:29.182035Z",
|
||
"shell.execute_reply": "2025-11-21T02:54:29.181011Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:54:29.164147Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"ok!\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import my_module as My\n",
|
||
"\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_新疆油田采油工艺研究院2511.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl) \n",
|
||
"for k, v in dict2.items():\n",
|
||
" #print(k)\n",
|
||
" if v['sex'] == '男':\n",
|
||
" sex = 'M'\n",
|
||
" else:\n",
|
||
" sex = 'F' \n",
|
||
" if 'bmi' in v.keys():\n",
|
||
" #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n",
|
||
" bmi_data = v['bmi']['成绩']\n",
|
||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':'HeightWeight','result':bmi_data}\n",
|
||
" dict2[k]['bmi'] = {}\n",
|
||
" dict2[k]['bmi']['成绩'] = bmi_data\n",
|
||
" dict2[k]['bmi']['score'] = My.cal_bmi(data1)\n",
|
||
" for item_en in list_item:\n",
|
||
" if item_en in v.keys(): \n",
|
||
" data1 = {'code':k,'sex':sex,'age':v['age'],'item':item_en,'result':float(v[item_en]['成绩'].split()[0])}\n",
|
||
" #print(k,v['name'])\n",
|
||
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
|
||
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
||
"\n",
|
||
"filename = f'data/result_新疆油田采油工艺研究院2511.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||
"print('ok!') "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d034a61d-1fbd-417b-99bd-277e43ebb678",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导出测试人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/新疆油田采油工艺研究院-1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['unit'])\n",
|
||
" if 'bmi' in v.keys():\n",
|
||
" height = v['bmi']['成绩'].split(',')[0]\n",
|
||
" weight = v['bmi']['成绩'].split(',')[1]\n",
|
||
" list2.append(height)\n",
|
||
" list2.append(weight)\n",
|
||
" else:\n",
|
||
" list2.append('')\n",
|
||
" list2.append('')\n",
|
||
" for item in items:\n",
|
||
" if item in v.keys():\n",
|
||
" list2.append(v[item]['成绩']) \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(v[item])\n",
|
||
" else:\n",
|
||
" list2.append('')\n",
|
||
" \n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/新疆油田采油工艺研究院测试情况明细表(第二批).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "f44edca7-a1bd-4937-a290-bf80ea91dd5b",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导出未体测人员"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "bf6b900f-1fcc-49c8-9b03-7723f9ca2429",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||
"title = ['编号','姓名','性别','单位','部门']\n",
|
||
"\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/新疆油田采油工艺研究院.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"print(dict1.keys()) \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict2.items():\n",
|
||
" \n",
|
||
" if k not in dict1.keys():\n",
|
||
" \n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['unit'])\n",
|
||
" \n",
|
||
" list1.append(list2)\n",
|
||
"print(list1)\n",
|
||
"filename = 'data/新疆油田采油工艺研究院未体测人员(截至20250725).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计问卷人员情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import csv\n",
|
||
"import openpyxl\n",
|
||
"import time\n",
|
||
"from datetime import date\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/新疆油田采油工艺研究院.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"phone1 = set()\n",
|
||
"phone2 = set()\n",
|
||
"for k,v in dict1.items():\n",
|
||
" phone1.add(v['phone'])\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/survey_records_20250725.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",
|
||
"\n",
|
||
"i =1\n",
|
||
"list2 = []\n",
|
||
"for item in list1:\n",
|
||
" code = int(item[3])\n",
|
||
" for k, v in dict1.items():\n",
|
||
" list3 = []\n",
|
||
" if v['phone'] == code: \n",
|
||
" list3.append(k)\n",
|
||
" list3.append(v['name'])\n",
|
||
" list3.append(v['sex'])\n",
|
||
" list3.append(v['unit'])\n",
|
||
" list3.append(code)\n",
|
||
" list2.append(list3)\n",
|
||
"filename = 'data/新疆油田采油工艺研究院问卷情况表.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"#sheet.append(title)\n",
|
||
"for row in list2:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "9cb0172e-5f6c-4b47-8431-83dc5cc4601c",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import csv\n",
|
||
"import openpyxl\n",
|
||
"import time\n",
|
||
"from datetime import date\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/新疆油田采油工艺研究院.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"phone1 = set()\n",
|
||
"phone2 = set()\n",
|
||
"for k,v in dict1.items():\n",
|
||
" phone1.add(v['phone'])\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/survey_records_20250725.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",
|
||
"\n",
|
||
"for item in list1:\n",
|
||
" code = int(item[3]) \n",
|
||
" content = json.loads(item[4])\n",
|
||
" name = item[4]\n",
|
||
" if code not in phone1: \n",
|
||
" print(code,content['name'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "2528bc3c-bf40-4459-9c33-b795600a6cb1",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导入问卷信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "2fa85089-8dc7-42f7-9ff3-c37cbe0899ed",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import csv\n",
|
||
"import openpyxl\n",
|
||
"import time\n",
|
||
"from datetime import date\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'data/新疆油田采油工艺研究院-1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict3 = json.load(fl)\n",
|
||
"\n",
|
||
"phone = {}\n",
|
||
"for k,v in dict3.items():\n",
|
||
" if 'phone' in v.keys():\n",
|
||
" phone[v['phone']] = k\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/survey_records_20250813.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",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"nn = 0\n",
|
||
"for item in list1:\n",
|
||
" \n",
|
||
" if int(item[3]) in phone.keys():\n",
|
||
" code = phone[int(item[3])]\n",
|
||
" tcm = []\n",
|
||
" spine = []\n",
|
||
" for i in range(0,60):\n",
|
||
" tcm.append(0)\n",
|
||
" for i in range(0,26):\n",
|
||
" spine.append(0)\n",
|
||
" \n",
|
||
" content = json.loads(item[4])\n",
|
||
" if code not in dict1.keys():\n",
|
||
" dict1[code] = dict3[code]\n",
|
||
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
|
||
" dict1[code]['rq'] = item[5].replace('/','-').split(' ')[0]\n",
|
||
" for k, v in content.items():\n",
|
||
" \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",
|
||
" spine[i-1] = int(v)\n",
|
||
" \n",
|
||
" if 'tcm' in item[4]:\n",
|
||
" \n",
|
||
" dict1[code]['tcm'] = tcm\n",
|
||
" if 'spine' in item[4]:\n",
|
||
" for ii in range(25,23,-1):\n",
|
||
" spine[ii] = spine[ii-1]\n",
|
||
" spine[22] = 0 \n",
|
||
" dict1[code]['spine'] = spine\n",
|
||
" birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n",
|
||
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
|
||
" days = (rq-birth).days \n",
|
||
" dict1[code]['age'] = int(days/365)\n",
|
||
" dict1[code]['month'] = int(days/365*12)\n",
|
||
" #print(phone[item[2]])\n",
|
||
" nn+=1\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院1-1.json'\n",
|
||
"\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||
"print(nn)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6eea20f8-b457-455e-8409-5c8cdaa1efb6",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 导入问卷信息(202511)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 10,
|
||
"id": "83872322-129c-410d-a9a3-ef6f4fe8dcde",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:53:17.422865Z",
|
||
"iopub.status.busy": "2025-11-21T02:53:17.422300Z",
|
||
"iopub.status.idle": "2025-11-21T02:53:17.441843Z",
|
||
"shell.execute_reply": "2025-11-21T02:53:17.441201Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:53:17.422814Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"48\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_20251121.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/新疆油田采油工艺研究院-202511.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict3 = json.load(fl)\n",
|
||
"filename = 'data/result_新疆油田采油工艺研究院2511.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",
|
||
" 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 '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",
|
||
" \n",
|
||
" code = phone[phone_num]\n",
|
||
" if code in dict3.keys(): \n",
|
||
" dict1[code]['tcm'] = tcm \n",
|
||
" dict1[code]['spine'] = spine\n",
|
||
"\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",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成报告"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"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_新疆油田采油工艺研究院1-1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"file_path ='./新疆油田采油工艺研究院1/'\n",
|
||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||
"i=0\n",
|
||
"list2 = []\n",
|
||
"for k, v in dict1.items():\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','psy57','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",
|
||
" list2.append([k,v['name']])\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": "code",
|
||
"execution_count": 12,
|
||
"id": "694ad38e-755e-4885-94a9-c157ddc96564",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-21T02:55:17.019680Z",
|
||
"iopub.status.busy": "2025-11-21T02:55:17.019091Z",
|
||
"iopub.status.idle": "2025-11-21T02:55:45.001413Z",
|
||
"shell.execute_reply": "2025-11-21T02:55:45.000749Z",
|
||
"shell.execute_reply.started": "2025-11-21T02:55:17.019625Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"48\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_新疆油田采油工艺研究院2511.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"file_path ='./新疆油田采油工艺研究院2511/'\n",
|
||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||
"i=0\n",
|
||
"list2 = []\n",
|
||
"for k, v in dict1.items():\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','psy57','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",
|
||
" list2.append([k,v['name']])\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",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 问卷信息统计"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "d22061b2-0109-4d6c-90d7-c31d9e318add",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import csv\n",
|
||
"import openpyxl\n",
|
||
"import time\n",
|
||
"from datetime import date\n",
|
||
"\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/sql_20251106.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",
|
||
"nn = 0\n",
|
||
"for item in list1:\n",
|
||
" dict2 = {}\n",
|
||
" \n",
|
||
" phone = str(item[0])[2:]\n",
|
||
" content = json.loads(json.loads(item[1]))\n",
|
||
" tcm = []\n",
|
||
" for i in range(0,60):\n",
|
||
" tcm.append(0)\n",
|
||
" for k, v in content.items(): \n",
|
||
" if 'tcm' not in k:\n",
|
||
" dict2[k] = v\n",
|
||
" else:\n",
|
||
" i = int(k[3:])\n",
|
||
" tcm[i-1] = int(v)\n",
|
||
" \n",
|
||
" code = phone\n",
|
||
" dict1.setdefault(code,{})\n",
|
||
" dict1[code]['name'] = content['name']\n",
|
||
" if content['gender'] == 'male':\n",
|
||
" dict1[code]['sex'] = '男'\n",
|
||
" else:\n",
|
||
" dict1[code]['sex'] = '女'\n",
|
||
" dict1[code]['birth'] = str(content['birth'])\n",
|
||
" dict1[code]['unit'] = '采油工艺研究院'\n",
|
||
" #dict1[code]['phone'] = phone\n",
|
||
" #dict1[code]['weight'] = dict2['weight']\n",
|
||
" #dict1[code]['waist'] = dict2['waist']\n",
|
||
" #dict1[code]['hip'] = dict2['hip']\n",
|
||
" dict1[code]['tcm'] = tcm\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = [k,v['name'],v['sex'],v['birth']]\n",
|
||
" list1.append(list2)\n",
|
||
"title =['手机号码','姓名','性别','出生年月']\n",
|
||
"filename = 'data/采油工艺研究院问卷人员(截至20251105).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 26,
|
||
"id": "73d28b6a-91be-47bb-bf76-1b8c26faafb5",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-11T04:31:28.041103Z",
|
||
"iopub.status.busy": "2025-11-11T04:31:28.040413Z",
|
||
"iopub.status.idle": "2025-11-11T04:31:28.055394Z",
|
||
"shell.execute_reply": "2025-11-11T04:31:28.054740Z",
|
||
"shell.execute_reply.started": "2025-11-11T04:31:28.041040Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"27\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import csv\n",
|
||
"import openpyxl\n",
|
||
"import time\n",
|
||
"from datetime import date\n",
|
||
"\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/sql_20251106.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",
|
||
"nn = 0\n",
|
||
"for item in list1:\n",
|
||
" dict2 = {}\n",
|
||
" \n",
|
||
" phone = str(item[0])[2:]\n",
|
||
" content = json.loads(json.loads(item[1]))\n",
|
||
" tcm = []\n",
|
||
" spine = []\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 '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",
|
||
" \n",
|
||
" code = phone\n",
|
||
" dict1.setdefault(code,{})\n",
|
||
" dict1[code]['name'] = content['name']\n",
|
||
" if content['gender'] == 'male':\n",
|
||
" dict1[code]['sex'] = '男'\n",
|
||
" else:\n",
|
||
" dict1[code]['sex'] = '女'\n",
|
||
" dict1[code]['birth'] = str(content['birth'])+'-01'\n",
|
||
" dict1[code]['unit'] = '采油工艺研究院'\n",
|
||
" dict1[code]['tcm'] = tcm \n",
|
||
" dict1[code]['spine'] = spine\n",
|
||
" \n",
|
||
"filename = 'data/result_新疆油田-2511-1.json'\n",
|
||
"\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||
"print(len(dict1))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "3a7bc501-6739-4b74-90f6-21066de637e2",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成问卷报告"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 27,
|
||
"id": "cdbeb2f8-2784-4688-806a-6506799941cb",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2025-11-11T04:31:58.919201Z",
|
||
"iopub.status.busy": "2025-11-11T04:31:58.918605Z",
|
||
"iopub.status.idle": "2025-11-11T04:32:06.150780Z",
|
||
"shell.execute_reply": "2025-11-11T04:32:06.149803Z",
|
||
"shell.execute_reply.started": "2025-11-11T04:31:58.919144Z"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"27\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_新疆油田-2511-1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"file_path ='./新疆油田-2511-1/'\n",
|
||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||
"i=0\n",
|
||
"list2 = []\n",
|
||
"for k, v in dict1.items():\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'] = 60\n",
|
||
" mydata['fits'] = {}\n",
|
||
" survey_list = ['tcm','psy57','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",
|
||
" list2.append([k,v['name']])\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": "code",
|
||
"execution_count": null,
|
||
"id": "8564de3a-1511-4a79-9ec3-32aea03595c7",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3 (ipykernel)",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.12.3"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|