3074 lines
95 KiB
Plaintext
3074 lines
95 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "511a2aee-e09b-475a-a201-f6e1c72e053b",
|
|
"metadata": {
|
|
"jp-MarkdownHeadingCollapsed": true
|
|
},
|
|
"source": [
|
|
"# 体测数据处理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "04524c85-988e-4dbf-86eb-939a9db7aa28",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 体测人员导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-09-16T14:38:56.520481Z",
|
|
"iopub.status.busy": "2024-09-16T14:38:56.519690Z",
|
|
"iopub.status.idle": "2024-09-16T14:38:56.978133Z",
|
|
"shell.execute_reply": "2024-09-16T14:38:56.977605Z",
|
|
"shell.execute_reply.started": "2024-09-16T14:38:56.520410Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook('data/青海员工个人健康档案名单.xlsx')\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, 3).value\n",
|
|
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
|
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
|
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n",
|
|
" dict1['phone'] = str(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('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "482517fc-650c-4b8c-bdf3-b32ec508de99",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook('data/青海员工花名册名单.xlsx')\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, 4).value\n",
|
|
" dict1['sex'] = sheet.cell(n, 5).value\n",
|
|
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
|
" dict1['birth'] = str(sheet.cell(n, 8).value).replace('/','-').split(' ')[0] \n",
|
|
" dict1['phone'] = str(sheet.cell(n,10).value)\n",
|
|
" person[code] = dict1\n",
|
|
"filename = 'data/青海2024.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "048a95aa-1691-45f6-b933-6eaf95ae1d30",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成读卡系统文件"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "ce406710-6b7d-4c51-98ec-78883bd3ce5f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"filename = 'data/青海.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict2 = {}\n",
|
|
" #if dict1['sex'] =='男':\n",
|
|
" # sex = 1\n",
|
|
" \n",
|
|
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
|
|
" list1.append(dict2)\n",
|
|
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
|
|
"\n",
|
|
"# 将 json 数据写入文件\n",
|
|
"with open(\"data/data_青海.json\", \"w\",encoding = 'utf-8') as file:\n",
|
|
" file.write(json_data) \n",
|
|
"print('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 time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k,v in dict1.items():\n",
|
|
" item[k] = v\n",
|
|
"re_ta = {}\n",
|
|
"dict1 = {}\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/青海2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20240311.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",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append(line)\n",
|
|
"#print(list1)\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" if user in dict1.keys(): \n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
|
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
|
" item_name = item[m_item]['name']\n",
|
|
" re_ta[user].setdefault(item_name,{}) \n",
|
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
|
"print(len(re_ta))\n",
|
|
"filename = 'data/result_青海20240515.json'\n",
|
|
"\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": "c6703be2-b6d7-4fe3-9c13-ea55b752d933",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 转换报告格式"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "724306c7-6b00-4322-856b-28ec96dfe9d0",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import datetime\n",
|
|
"import csv\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k,v in dict1.items():\n",
|
|
" item[k] = v\n",
|
|
"item['1']['en'] = 'lung'\n",
|
|
"item['2']['en'] = 'grip'\n",
|
|
"item['3']['en'] = 'flexion'\n",
|
|
"item['4']['en'] = 'jump'\n",
|
|
"item['5']['en'] = 'pushup'\n",
|
|
"item['6']['en'] = 'balance'\n",
|
|
"item['7']['en'] = 'reaction'\n",
|
|
"item['8']['en'] = 'step'\n",
|
|
"item['9']['en'] = 'situp'\n",
|
|
"item['10']['en'] = 'height'\n",
|
|
"item['11']['en'] = 'weight'\n",
|
|
"\n",
|
|
"\n",
|
|
"re_ta = {}\n",
|
|
"dict1 = {}\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/青海2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20240311.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",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append(line)\n",
|
|
"#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
|
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
|
|
" if user in dict1.keys():\n",
|
|
" l_xm = []\n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
|
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
|
" if dict1[user]['sex'] == '男':\n",
|
|
" l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
|
" else:\n",
|
|
" l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
|
" #birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
|
" birth = date.fromisoformat(dict1[user]['birth'])\n",
|
|
" #nian = int(birth[0].strip())\n",
|
|
" #yue = int(birth[1].strip())\n",
|
|
" #ri = int(birth[2].strip())\n",
|
|
" #print(k,nian,yue,ri)\n",
|
|
" item_name = item[m_item]['en'] \n",
|
|
" if item_name in l_xm: \n",
|
|
" days = (rq-birth).days \n",
|
|
" re_ta[user]['age'] = int(days/365)\n",
|
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
|
" re_ta[user]['rq'] = result[6]\n",
|
|
"\n",
|
|
"\n",
|
|
" re_ta[user].setdefault(item_name,{}) \n",
|
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
|
"print(len(re_ta))\n",
|
|
"filename = 'data/result_青海all.json'\n",
|
|
"\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": "b9b5d490-b303-481c-b1f2-cb1c281aabe6",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成完善得分"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a9228dc5-e3b1-4a48-8938-747abb59786c",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict3 = json.load(fl) \n",
|
|
"for k,v in dict3.items():\n",
|
|
" item[k] = v\n",
|
|
"item['1']['en'] = 'lung'\n",
|
|
"item['2']['en'] = 'grip'\n",
|
|
"item['3']['en'] = 'flexion'\n",
|
|
"item['4']['en'] = 'jump'\n",
|
|
"item['5']['en'] = 'pushup'\n",
|
|
"item['6']['en'] = 'balance'\n",
|
|
"item['7']['en'] = 'reaction'\n",
|
|
"item['8']['en'] = 'step'\n",
|
|
"item['9']['en'] = 'situp'\n",
|
|
"item['10']['en'] = 'height'\n",
|
|
"item['11']['en'] = 'weight'\n",
|
|
"\n",
|
|
"filename = 'data/体质检测标准 (1).json' \n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"def cal_score(data1):\n",
|
|
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
|
|
" person = dict1['person']\n",
|
|
" criteria = dict1['criteria']\n",
|
|
" if data1['age'] >59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" mx = criteria[bz][data1['item']]\n",
|
|
" result = data1['result'] \n",
|
|
" if data1['item'] == 'reaction':\n",
|
|
" for bz1 in mx:\n",
|
|
" if result > bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" else:\n",
|
|
" for bz1 in mx:\n",
|
|
" if result < bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" return(score)\n",
|
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict4 = json.load(fl) \n",
|
|
" \n",
|
|
"def cal_bmi(data1):\n",
|
|
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
|
|
" person = dict4['person']\n",
|
|
" criteria = dict4['criteria']\n",
|
|
" if data1['age'] > 59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" #print(bz)\n",
|
|
" result = data1['result']\n",
|
|
" #print(data1['code'],result)\n",
|
|
" height = int(float(result.split(',')[0]))\n",
|
|
" weight = float(result.split(',')[1])\n",
|
|
" if str(height) not in criteria[bz]:\n",
|
|
" score = 1\n",
|
|
" else: \n",
|
|
" mx = criteria[bz][str(height)]\n",
|
|
" if weight < mx[0]:\n",
|
|
" score = 1\n",
|
|
" elif weight < mx[1]:\n",
|
|
" score = 3\n",
|
|
" elif weight < mx[2]:\n",
|
|
" score = 5 \n",
|
|
" elif weight <= mx[3]:\n",
|
|
" score = 3 \n",
|
|
" elif weight > mx[3]:\n",
|
|
" score = 1\n",
|
|
" return score\n",
|
|
" \n",
|
|
" \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_青海all.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 'height' in v.keys() and 'weight' in v.keys():\n",
|
|
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\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'] = 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",
|
|
" dict2[k][item_en]['score'] = cal_score(data1)\n",
|
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
|
"\n",
|
|
"filename = f'data/result_青海all.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 = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
|
"\n",
|
|
"filename = 'data/result_青海20240515.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"filename = 'data/青海2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict2 = json.load(fl)\n",
|
|
" \n",
|
|
"list1 = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if k in dict2.keys():\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",
|
|
" 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",
|
|
" list1.append(list2)\n",
|
|
"filename = 'data/青海20240515.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": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"filename = 'data/result_青海all.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/青海2024.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",
|
|
"list1 = []\n",
|
|
"filename = 'data/Survey_20240612.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",
|
|
"#print(list1)\n",
|
|
"dict2 = {}\n",
|
|
"psy =[]\n",
|
|
"tcm = []\n",
|
|
"spine = []\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",
|
|
"\n",
|
|
"for item in list1:\n",
|
|
" if item[2] in phone.keys():\n",
|
|
" psy =[]\n",
|
|
" tcm = []\n",
|
|
" spine = []\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",
|
|
" \n",
|
|
" content = json.loads(item[5])\n",
|
|
" if phone[item[2]] not in dict1.keys():\n",
|
|
" dict1[phone[item[2]]] = dict3[phone[item[2]]]\n",
|
|
" #print(item[2])\n",
|
|
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
|
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[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",
|
|
" spine[i-1] = int(v)\n",
|
|
" if 'psy' in item[5]:\n",
|
|
" #for i in range(5,26):\n",
|
|
" # new_valve = 5-psy[i]\n",
|
|
" # psy[i] = new_valve\n",
|
|
" for i in range(26,40):\n",
|
|
" new_valve = 1+psy[i]\n",
|
|
" psy[i] = new_valve\n",
|
|
" \n",
|
|
" dict1[phone[item[2]]]['psy'] = psy\n",
|
|
" if 'tcm' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['tcm'] = tcm\n",
|
|
" if 'spine' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['spine'] = spine\n",
|
|
" birth = date.fromisoformat(dict3[phone[item[2]]]['birth'].replace('/','-'))\n",
|
|
" #rq =date.fromisoformat('2023-12-08')\n",
|
|
" days = (rq-birth).days \n",
|
|
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
|
|
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
|
|
" else:\n",
|
|
" print(item[2])\n",
|
|
"filename = 'data/result_青海all_2.json'\n",
|
|
"\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "cc211422-c097-4b80-994d-f7cf11594185",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成报告"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9e96d70b-3f7c-4c55-8c7a-f8373c2d9a7a",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"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_青海all_2.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','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",
|
|
" 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": "c776f605-c7c4-494e-b172-c5dc7f9beef4",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计人员情况"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "11727a08-9da8-4eb2-aadf-69dc72031bdc",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"wj = []\n",
|
|
"tc = []\n",
|
|
"all = []\n",
|
|
"filename = 'data/result_青海20240515.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" tc.append(k)\n",
|
|
"print(len(tc))\n",
|
|
" \n",
|
|
"filename = 'data/result_青海all_2.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'psy' in v.keys():\n",
|
|
" wj.append(k)\n",
|
|
"print(len(wj))\n",
|
|
"for item in wj:\n",
|
|
" if item in tc:\n",
|
|
" all.append(item)\n",
|
|
"print(len(all))\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5e97c15a-8f92-4c17-9f2e-cb76a2e0043b",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计问卷人员情况表"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f93523ed-a9fb-46f4-8f38-17ebde168303",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/青海2024.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",
|
|
"list1 = []\n",
|
|
"filename = 'data/Survey_20240603.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",
|
|
" if line[2] in phone.keys() and line[2] not in list1:\n",
|
|
" list1.append(line[2])\n",
|
|
"print(list1) \n",
|
|
"for item in list1:\n",
|
|
" print(phone[item])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c175912f-a1ea-4849-8bfa-3a9e25883850",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计报告发送情况表"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "953e6f09-74dd-48cf-810e-ffe78f621c81",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"filename = 'data/result_青海all_1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 = []\n",
|
|
"for k,v in dict1.items():\n",
|
|
" list2 = []\n",
|
|
" list2 = [k,v['name'],v['sex'],v['unit'],v['phone']]\n",
|
|
" list1.append(list2)\n",
|
|
"\n",
|
|
"filename = 'data/青海体测报告发送明细.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"\n",
|
|
"for row in list1:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5274f18f-c63b-4bfa-9222-d1586c42fac2",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 筛选家属人员"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3cc922d2-9a1f-4aa6-8011-5541fe2e9715",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"dict3 = {}\n",
|
|
"filename = 'data/青海.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"filename = 'data/青海2024.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict2 = json.load(fl)\n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if k not in dict2.keys():\n",
|
|
" dict3[k] = v\n",
|
|
"filename = 'data/青海_家属.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "804f1cf0-c2e6-4c4d-841b-1cc5e25c35f7",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k,v in dict1.items():\n",
|
|
" item[k] = v\n",
|
|
"re_ta = {}\n",
|
|
"dict1 = {}\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/青海_家属.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20240311.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",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append(line)\n",
|
|
"#print(list1)\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" if user in dict1.keys(): \n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
|
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
|
" item_name = item[m_item]['name']\n",
|
|
" re_ta[user].setdefault(item_name,{}) \n",
|
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
|
"print(len(re_ta))\n",
|
|
"filename = 'data/result_青海家属.json'\n",
|
|
"\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": "0faf3ee7-e075-42bd-84ca-aea2b4ee890e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import datetime\n",
|
|
"import csv\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k,v in dict1.items():\n",
|
|
" item[k] = v\n",
|
|
"item['1']['en'] = 'lung'\n",
|
|
"item['2']['en'] = 'grip'\n",
|
|
"item['3']['en'] = 'flexion'\n",
|
|
"item['4']['en'] = 'jump'\n",
|
|
"item['5']['en'] = 'pushup'\n",
|
|
"item['6']['en'] = 'balance'\n",
|
|
"item['7']['en'] = 'reaction'\n",
|
|
"item['8']['en'] = 'step'\n",
|
|
"item['9']['en'] = 'situp'\n",
|
|
"item['10']['en'] = 'height'\n",
|
|
"item['11']['en'] = 'weight'\n",
|
|
"\n",
|
|
"\n",
|
|
"re_ta = {}\n",
|
|
"dict1 = {}\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/青海_家属.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20240311.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",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append(line)\n",
|
|
"#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
|
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
|
|
" if user in dict1.keys():\n",
|
|
" l_xm = []\n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
|
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
|
" if dict1[user]['sex'] == '男':\n",
|
|
" l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
|
" else:\n",
|
|
" l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
|
" #birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
|
" birth = date.fromisoformat(dict1[user]['birth'])\n",
|
|
" #nian = int(birth[0].strip())\n",
|
|
" #yue = int(birth[1].strip())\n",
|
|
" #ri = int(birth[2].strip())\n",
|
|
" #print(k,nian,yue,ri)\n",
|
|
" item_name = item[m_item]['en'] \n",
|
|
" if item_name in l_xm: \n",
|
|
" days = (rq-birth).days \n",
|
|
" re_ta[user]['age'] = int(days/365)\n",
|
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
|
" re_ta[user]['rq'] = result[6]\n",
|
|
"\n",
|
|
"\n",
|
|
" re_ta[user].setdefault(item_name,{}) \n",
|
|
" score = int(result[4])/item[m_item]['divisor'] \n",
|
|
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
|
"print(len(re_ta))\n",
|
|
"filename = 'data/result_青海家属.json'\n",
|
|
"\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": "62863430-1d61-4282-b500-7261c66ec176",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"\n",
|
|
"filename = '../item.json'\n",
|
|
"item = {}\n",
|
|
"unit = {}\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict3 = json.load(fl) \n",
|
|
"for k,v in dict3.items():\n",
|
|
" item[k] = v\n",
|
|
"item['1']['en'] = 'lung'\n",
|
|
"item['2']['en'] = 'grip'\n",
|
|
"item['3']['en'] = 'flexion'\n",
|
|
"item['4']['en'] = 'jump'\n",
|
|
"item['5']['en'] = 'pushup'\n",
|
|
"item['6']['en'] = 'balance'\n",
|
|
"item['7']['en'] = 'reaction'\n",
|
|
"item['8']['en'] = 'step'\n",
|
|
"item['9']['en'] = 'situp'\n",
|
|
"item['10']['en'] = 'height'\n",
|
|
"item['11']['en'] = 'weight'\n",
|
|
"\n",
|
|
"filename = 'data/体质检测标准 (1).json' \n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"def cal_score(data1):\n",
|
|
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
|
|
" person = dict1['person']\n",
|
|
" criteria = dict1['criteria']\n",
|
|
" if data1['age'] >59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" mx = criteria[bz][data1['item']]\n",
|
|
" result = data1['result'] \n",
|
|
" if data1['item'] == 'reaction':\n",
|
|
" for bz1 in mx:\n",
|
|
" if result > bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" else:\n",
|
|
" for bz1 in mx:\n",
|
|
" if result < bz1:\n",
|
|
" #print(bz1)\n",
|
|
" score = mx.index(bz1,0)\n",
|
|
" break\n",
|
|
" else:\n",
|
|
" score = 5\n",
|
|
" return(score)\n",
|
|
"filename = 'data/体质检测标准_BMI.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict4 = json.load(fl) \n",
|
|
" \n",
|
|
"def cal_bmi(data1):\n",
|
|
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
|
|
" person = dict4['person']\n",
|
|
" criteria = dict4['criteria']\n",
|
|
" if data1['age'] > 59:\n",
|
|
" data1['age'] = 59\n",
|
|
" if data1['age'] <20:\n",
|
|
" data1['age'] = 20\n",
|
|
" info = data1['sex']+str(data1['age'])\n",
|
|
" bz = person[info]\n",
|
|
" #print(bz)\n",
|
|
" result = data1['result']\n",
|
|
" #print(data1['code'],result)\n",
|
|
" height = int(float(result.split(',')[0]))\n",
|
|
" weight = float(result.split(',')[1])\n",
|
|
" if str(height) not in criteria[bz]:\n",
|
|
" score = 1\n",
|
|
" else: \n",
|
|
" mx = criteria[bz][str(height)]\n",
|
|
" if weight < mx[0]:\n",
|
|
" score = 1\n",
|
|
" elif weight < mx[1]:\n",
|
|
" score = 3\n",
|
|
" elif weight < mx[2]:\n",
|
|
" score = 5 \n",
|
|
" elif weight <= mx[3]:\n",
|
|
" score = 3 \n",
|
|
" elif weight > mx[3]:\n",
|
|
" score = 1\n",
|
|
" return score\n",
|
|
" \n",
|
|
" \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_青海家属.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 'height' in v.keys() and 'weight' in v.keys():\n",
|
|
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\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'] = 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",
|
|
" dict2[k][item_en]['score'] = cal_score(data1)\n",
|
|
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
|
|
"\n",
|
|
"filename = f'data/result_青海家属.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
|
"print('ok!') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "35c83ea5-e331-4655-aba5-42720e2bc63a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\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",
|
|
" 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",
|
|
"list1 = []\n",
|
|
"filename = 'data/Survey_20240612.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",
|
|
"#print(list1)\n",
|
|
"dict2 = {}\n",
|
|
"psy =[]\n",
|
|
"tcm = []\n",
|
|
"spine = []\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",
|
|
"\n",
|
|
"for item in list1:\n",
|
|
" if item[2] in phone.keys():\n",
|
|
" psy =[]\n",
|
|
" tcm = []\n",
|
|
" spine = []\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",
|
|
" \n",
|
|
" content = json.loads(item[5])\n",
|
|
" if phone[item[2]] not in dict1.keys():\n",
|
|
" dict1[phone[item[2]]] = dict3[phone[item[2]]]\n",
|
|
" #print(item[2])\n",
|
|
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
|
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[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",
|
|
" spine[i-1] = int(v)\n",
|
|
" if 'psy' in item[5]:\n",
|
|
" #for i in range(5,26):\n",
|
|
" # new_valve = 5-psy[i]\n",
|
|
" # psy[i] = new_valve\n",
|
|
" for i in range(26,40):\n",
|
|
" new_valve = 1+psy[i]\n",
|
|
" psy[i] = new_valve\n",
|
|
" \n",
|
|
" dict1[phone[item[2]]]['psy'] = psy\n",
|
|
" if 'tcm' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['tcm'] = tcm\n",
|
|
" if 'spine' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['spine'] = spine\n",
|
|
" birth = date.fromisoformat(dict3[phone[item[2]]]['birth'].replace('/','-'))\n",
|
|
" #rq =date.fromisoformat('2023-12-08')\n",
|
|
" days = (rq-birth).days \n",
|
|
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
|
|
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
|
|
" else:\n",
|
|
" print(item[2])\n",
|
|
"filename = 'data/result_青海家属.json'\n",
|
|
"\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1f137b9b-b51b-4a7a-baea-b1978e5f00c1",
|
|
"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_青海家属.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 = []\n",
|
|
"file_path ='./青海家属/'\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'] = ''\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",
|
|
" 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": "8feaa7bb-92dd-44ab-9869-c601d468b4b8",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 体测数据处理(2025年)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "54ed5a3c-ba4d-463f-83f7-3c621142f7bb",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 体测人员导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 23,
|
|
"id": "80a24c3c-8f7d-4c02-a5ee-3daa438ca35b",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-01-20T01:27:26.442760Z",
|
|
"iopub.status.busy": "2025-01-20T01:27:26.442000Z",
|
|
"iopub.status.idle": "2025-01-20T01:27:26.468889Z",
|
|
"shell.execute_reply": "2025-01-20T01:27:26.468324Z",
|
|
"shell.execute_reply.started": "2025-01-20T01:27:26.442687Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"81 ok\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook('data/青海2025.xlsx')\n",
|
|
"sheet = wb.active\n",
|
|
"# sheets = wb.sheetnames\n",
|
|
"person = {}\n",
|
|
"\n",
|
|
"for n in range(2, sheet.max_row+1):\n",
|
|
" if sheet.cell(n, 1).value is not None:\n",
|
|
" #print(sheet.cell(n, 1).value)\n",
|
|
" code = int(sheet.cell(n, 1).value)\n",
|
|
" person.setdefault(code, {})\n",
|
|
" dict1 = {}\n",
|
|
" dict1['name'] = sheet.cell(n, 3).value\n",
|
|
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
|
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
|
" dict1['phone'] = int(sheet.cell(n, 6).value)\n",
|
|
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
|
" person[code] = dict1\n",
|
|
"\n",
|
|
"filename = 'data/青海人员2025.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": "90ce631b-0eeb-4d27-965a-7efa09332139",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 获取人员测试成绩"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"id": "905dbd60-ef28-4bf4-85a2-5b2e6543dcfe",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-01-20T01:12:15.444982Z",
|
|
"iopub.status.busy": "2025-01-20T01:12:15.444234Z",
|
|
"iopub.status.idle": "2025-01-20T01:12:15.461283Z",
|
|
"shell.execute_reply": "2025-01-20T01:12:15.460768Z",
|
|
"shell.execute_reply.started": "2025-01-20T01:12:15.444909Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"72\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import datetime\n",
|
|
"import csv\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"\n",
|
|
"re_ta = {}\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/青海人员2025.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/marks_20250118.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",
|
|
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
|
" list1.append(line)\n",
|
|
"\n",
|
|
"for result in list1:\n",
|
|
" user = str(result[2])\n",
|
|
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
|
|
" if user in dict1.keys():\n",
|
|
" l_xm = []\n",
|
|
" m_item = str(result[3]) \n",
|
|
" re_ta.setdefault(user,{}) \n",
|
|
" re_ta[user]['name'] = dict1[user]['name']\n",
|
|
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
|
" if 'phone' in dict1[user].keys():\n",
|
|
" re_ta[user]['phone'] = dict1[user]['phone']\n",
|
|
" if dict1[user]['sex'] == '男':\n",
|
|
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
|
" else:\n",
|
|
" l_xm = ['bmi','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
|
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
|
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
|
" item_name = result[3] \n",
|
|
" if item_name in l_xm: \n",
|
|
" days = (rq-birth).days \n",
|
|
" re_ta[user]['age'] = int(days/365)\n",
|
|
" re_ta[user]['month'] = int(days/365*12)\n",
|
|
" re_ta[user]['rq'] = result[5]\n",
|
|
" re_ta[user].setdefault(item_name,{}) \n",
|
|
" score = result[4] \n",
|
|
" re_ta[user][item_name]['成绩'] = score\n",
|
|
"\n",
|
|
"filename = 'data/result_青海2025.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": "0658cf8a-9c37-45c8-84db-e24ad29b64c7",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成测试得分"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "58e5805d-e778-4ec5-a1cb-3b34207baea7",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-03-26T05:55:00.358304Z",
|
|
"iopub.status.busy": "2025-03-26T05:55:00.357480Z",
|
|
"iopub.status.idle": "2025-03-26T05:55:00.376296Z",
|
|
"shell.execute_reply": "2025-03-26T05:55:00.375437Z",
|
|
"shell.execute_reply.started": "2025-03-26T05:55:00.358233Z"
|
|
}
|
|
},
|
|
"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_青海2025.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_青海2025.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
|
"print('ok!') "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c6ede59a-e5a0-489b-853f-f317e12b1fa3",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 导出测试人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "f3d39079-fa3a-400c-990e-75a8a0a7b42d",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-03-26T05:55:54.431815Z",
|
|
"iopub.status.busy": "2025-03-26T05:55:54.431138Z",
|
|
"iopub.status.idle": "2025-03-26T05:55:54.621742Z",
|
|
"shell.execute_reply": "2025-03-26T05:55:54.621190Z",
|
|
"shell.execute_reply.started": "2025-03-26T05:55:54.431756Z"
|
|
}
|
|
},
|
|
"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_青海2025.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"filename = 'data/青海人员2025.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/青海体测情况表2025.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": "cd0822ae-0d56-4da4-88f4-abbef0bbe77d",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 导入问卷信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"id": "a9ead9a5-8006-414d-afe9-c1cb9ccfc378",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-03-26T08:49:28.501374Z",
|
|
"iopub.status.busy": "2025-03-26T08:49:28.500816Z",
|
|
"iopub.status.idle": "2025-03-26T08:49:28.528745Z",
|
|
"shell.execute_reply": "2025-03-26T08:49:28.528262Z",
|
|
"shell.execute_reply.started": "2025-03-26T08:49:28.501320Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"46\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"#import my_module as My\n",
|
|
"\n",
|
|
"dict1 = {}\n",
|
|
"filename = 'data/result_青海2025.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"filename = 'data/青海人员2025.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[str(v['phone'])] = k\n",
|
|
"\n",
|
|
"list1 = []\n",
|
|
"filename = 'data/Survey_20250118.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",
|
|
"#print(list1)\n",
|
|
"dict2 = {}\n",
|
|
"psy =[]\n",
|
|
"tcm = []\n",
|
|
"spine = []\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",
|
|
"\n",
|
|
"for item in list1:\n",
|
|
" if item[2] in phone.keys():\n",
|
|
" psy =[]\n",
|
|
" tcm = []\n",
|
|
" spine = []\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",
|
|
" \n",
|
|
" content = json.loads(item[5])\n",
|
|
" if phone[item[2]] not in dict1.keys():\n",
|
|
" dict1[phone[item[2]]] = dict3[phone[item[2]]]\n",
|
|
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
|
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
|
" else:\n",
|
|
" rq = date.fromisoformat('2025-01-18')\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",
|
|
" spine[i-1] = int(v)\n",
|
|
" if 'psy' in item[5]:\n",
|
|
" #for i in range(5,26):\n",
|
|
" # new_valve = 5-psy[i]\n",
|
|
" # psy[i] = new_valve\n",
|
|
" \n",
|
|
" \n",
|
|
" dict1[phone[item[2]]]['psy'] = psy\n",
|
|
" if 'tcm' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['tcm'] = tcm\n",
|
|
" if 'spine' in item[5]:\n",
|
|
" dict1[phone[item[2]]]['spine'] = spine\n",
|
|
" birth = date.fromisoformat(dict3[phone[item[2]]]['birth'].replace('/','-'))\n",
|
|
" \n",
|
|
" days = (rq-birth).days \n",
|
|
" dict1[phone[item[2]]]['age'] = int(days/365)\n",
|
|
" dict1[phone[item[2]]]['month'] = int(days/365*12)\n",
|
|
" \n",
|
|
"\n",
|
|
"filename = 'data/result_青海2025-1.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
|
"print(data1[1])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a19c9733-7af5-4dc6-a0ca-cc35069f532a",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计参加问卷人员"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 25,
|
|
"id": "f0ee678a-1dd1-4928-a198-df0ff5142f89",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-01-20T01:27:43.425720Z",
|
|
"iopub.status.busy": "2025-01-20T01:27:43.425142Z",
|
|
"iopub.status.idle": "2025-01-20T01:27:43.449977Z",
|
|
"shell.execute_reply": "2025-01-20T01:27:43.449445Z",
|
|
"shell.execute_reply.started": "2025-01-20T01:27:43.425664Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"80\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/青海人员2025.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_20250118.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",
|
|
"print(len(phone1))\n",
|
|
"i =1\n",
|
|
"list2 = []\n",
|
|
"for item in list1:\n",
|
|
" code = int(item[2])\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/青海问卷情况表2025.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": "markdown",
|
|
"id": "19aaf610-b15d-45c8-b22e-c56e9b8d8450",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计问卷人员手机号码未登记"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"id": "00eb991d-771f-4ff4-af9f-35a0d3b64581",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-01-20T01:27:34.074005Z",
|
|
"iopub.status.busy": "2025-01-20T01:27:34.073295Z",
|
|
"iopub.status.idle": "2025-01-20T01:27:34.085198Z",
|
|
"shell.execute_reply": "2025-01-20T01:27:34.084107Z",
|
|
"shell.execute_reply.started": "2025-01-20T01:27:34.073939Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"80\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/青海人员2025.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_20250118.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",
|
|
"print(len(phone1))\n",
|
|
"i =1\n",
|
|
"list2 = []\n",
|
|
"for item in list1:\n",
|
|
" code = int(item[2])\n",
|
|
" if code not in phone1:\n",
|
|
" content = json.loads(item[5])\n",
|
|
" if 'name' in content.keys():\n",
|
|
" print(code,content['name'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "9cabe52a-2862-4ba8-847f-d685df1060cd",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 统计未参加问卷人员"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "d91e74d4-22f0-4db2-bad4-717f7537c043",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-01-22T05:32:09.347446Z",
|
|
"iopub.status.busy": "2025-01-22T05:32:09.346691Z",
|
|
"iopub.status.idle": "2025-01-22T05:32:09.373252Z",
|
|
"shell.execute_reply": "2025-01-22T05:32:09.372574Z",
|
|
"shell.execute_reply.started": "2025-01-22T05:32:09.347377Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"45\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"import openpyxl\n",
|
|
"import time\n",
|
|
"from datetime import date\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/青海人员2025.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_20250118.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",
|
|
" phone2.add(int(line[2]))\n",
|
|
"print(len(phone2))\n",
|
|
"i =1\n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if v['phone'] not in phone2:\n",
|
|
" list2 = []\n",
|
|
" list2 = [k,v['name'],v['sex'],v['phone']]\n",
|
|
" list1.append(list2)\n",
|
|
"filename = 'data/青海未参加问卷人员2025.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": "dfaaae02-8f9b-42b1-80df-51e7c0e22495",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成报告"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "0ca61654-55b9-4d29-87ce-879c5f87ecd9",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-07T12:22:29.224569Z",
|
|
"iopub.status.busy": "2025-04-07T12:22:29.223783Z",
|
|
"iopub.status.idle": "2025-04-07T12:23:12.231320Z",
|
|
"shell.execute_reply": "2025-04-07T12:23:12.230105Z",
|
|
"shell.execute_reply.started": "2025-04-07T12:22:29.224494Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"72\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_青海2025-1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 = []\n",
|
|
"file_path ='./青海2025-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','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",
|
|
" 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": "1208eb16-a220-48c4-8c9e-cc4dbf67306e",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 体测数据分析"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "edec8124-5432-4248-964e-69e1ed425782",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 常用参数及自定义函数"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "523523ed-340a-4d0e-bd7a-d0b09b36ab13",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-11T01:39:01.155159Z",
|
|
"iopub.status.busy": "2025-04-11T01:39:01.154556Z",
|
|
"iopub.status.idle": "2025-04-11T01:39:01.172592Z",
|
|
"shell.execute_reply": "2025-04-11T01:39:01.171866Z",
|
|
"shell.execute_reply.started": "2025-04-11T01:39:01.155105Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"questions = [\n",
|
|
" [1],\n",
|
|
" [-1, 2],\n",
|
|
" [-1, 2],\n",
|
|
" [-1, 8],\n",
|
|
" [-1, 3],\n",
|
|
" [1],\n",
|
|
" [-1],\n",
|
|
" [-1, 7],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [2, 3],\n",
|
|
" [2],\n",
|
|
" [2],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [3],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [4],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [5],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [6],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [7],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [8],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9],\n",
|
|
" [9]\n",
|
|
"]\n",
|
|
"\n",
|
|
"kinds = [\n",
|
|
" '平和',\n",
|
|
" '气虚',\n",
|
|
" '阳虚',\n",
|
|
" '阴虚',\n",
|
|
" '痰湿',\n",
|
|
" '湿热',\n",
|
|
" '血瘀',\n",
|
|
" '气郁',\n",
|
|
" '特禀'\n",
|
|
"]\n",
|
|
"\n",
|
|
"def tcm_calc(arr):\n",
|
|
" qa = [8, 8, 7, 8, 8, 6, 7, 7, 7]\n",
|
|
" # 成绩数组\n",
|
|
" s = [0] * 9\n",
|
|
" # 遍历五进制\n",
|
|
" for i in range(len(questions)):\n",
|
|
" m = arr[i] - 1\n",
|
|
" for v in questions[i]:\n",
|
|
" if v < 0:\n",
|
|
" s[-v - 1] += 4 - m\n",
|
|
" else:\n",
|
|
" s[v - 1] += m\n",
|
|
" return [int((v / qa[i]) * 25) for i, v in enumerate(s)]\n",
|
|
"\n",
|
|
"def tcm_kind(score):\n",
|
|
" kind = 0\n",
|
|
" near = False\n",
|
|
" max_kind = 0\n",
|
|
" max_score = 0\n",
|
|
" for i in range(1, 9):\n",
|
|
" if score[i] > max_score:\n",
|
|
" max_kind = i\n",
|
|
" max_score = score[i]\n",
|
|
" if score[0] >= 60 and max_score < 40:\n",
|
|
" if max_score >= 30:\n",
|
|
" near = True\n",
|
|
" kind = max_kind\n",
|
|
" else:\n",
|
|
" kind = max_kind\n",
|
|
" return {\n",
|
|
" \"kind\": kind,\n",
|
|
" \"near\": near\n",
|
|
" }\n",
|
|
"list2 = ['成就感','愉快心境','放松程度','压力应对','体力充沛','情感充沛度']\n",
|
|
"list3 = [[5,7],[7,4],[7,4],[7,4],[8,1],[6,1]] \n",
|
|
"list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n",
|
|
"list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4eda4ded-9be7-4a64-af16-5b6e4942b540",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算中医体质"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "3ab82376-e416-4411-a017-0463a9b8c10a",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-11T01:40:21.406928Z",
|
|
"iopub.status.busy": "2025-04-11T01:40:21.406232Z",
|
|
"iopub.status.idle": "2025-04-11T01:40:21.421476Z",
|
|
"shell.execute_reply": "2025-04-11T01:40:21.420393Z",
|
|
"shell.execute_reply.started": "2025-04-11T01:40:21.406860Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"5 特禀 False [65, 37, 32, 56, 53, 50, 35, 35, 57]\n",
|
|
"99 平和 False [84, 3, 14, 12, 0, 8, 3, 0, 3]\n",
|
|
"101 湿热 False [50, 40, 17, 37, 53, 54, 35, 28, 21]\n",
|
|
"100 阴虚 False [71, 21, 14, 40, 12, 20, 32, 21, 14]\n",
|
|
"102 平和 False [81, 18, 3, 9, 28, 20, 14, 14, 3]\n",
|
|
"105 湿热 False [37, 81, 21, 50, 50, 83, 57, 50, 42]\n",
|
|
"104 阳虚 False [59, 34, 42, 40, 28, 37, 32, 35, 32]\n",
|
|
"103 阳虚 False [56, 43, 53, 53, 53, 45, 42, 32, 53]\n",
|
|
"18 血瘀 False [25, 81, 71, 68, 81, 66, 89, 71, 57]\n",
|
|
"28 气虚 True [65, 37, 21, 34, 28, 12, 7, 14, 17]\n",
|
|
"33 湿热 False [87, 31, 10, 25, 34, 41, 10, 10, 35]\n",
|
|
"107 痰湿 False [65, 34, 10, 46, 53, 45, 32, 17, 10]\n",
|
|
"39 气虚 False [78, 50, 10, 25, 40, 16, 10, 3, 21]\n",
|
|
"15 痰湿 False [50, 43, 50, 50, 56, 54, 50, 53, 53]\n",
|
|
"108 湿热 False [62, 40, 42, 31, 53, 58, 28, 28, 32]\n",
|
|
"36 气郁 False [62, 18, 35, 34, 28, 45, 35, 50, 17]\n",
|
|
"43 湿热 True [62, 34, 21, 15, 25, 37, 35, 32, 21]\n",
|
|
"24 平和 False [71, 25, 3, 0, 3, 0, 17, 14, 3]\n",
|
|
"61 阳虚 False [56, 37, 46, 31, 46, 41, 42, 32, 39]\n",
|
|
"40 阴虚 False [65, 37, 42, 43, 34, 29, 25, 28, 25]\n",
|
|
"113 阴虚 False [71, 40, 28, 46, 31, 33, 17, 0, 14]\n",
|
|
"114 阴虚 False [56, 28, 7, 43, 28, 33, 25, 21, 25]\n",
|
|
"55 平和 False [90, 9, 3, 15, 18, 20, 7, 3, 17]\n",
|
|
"57 痰湿 False [56, 37, 10, 46, 50, 37, 28, 35, 21]\n",
|
|
"69 阴虚 False [56, 37, 17, 53, 34, 41, 21, 21, 14]\n",
|
|
"50 阳虚 False [56, 46, 50, 43, 46, 45, 35, 32, 25]\n",
|
|
"118 痰湿 False [34, 62, 53, 40, 65, 62, 57, 57, 21]\n",
|
|
"20 气虚 False [56, 50, 50, 9, 34, 25, 17, 35, 3]\n",
|
|
"35 阴虚 True [87, 25, 3, 34, 28, 12, 14, 3, 3]\n",
|
|
"44 平和 False [71, 21, 28, 25, 18, 29, 21, 28, 3]\n",
|
|
"41 痰湿 False [40, 50, 42, 50, 71, 37, 53, 57, 32]\n",
|
|
"131 痰湿 False [56, 43, 21, 34, 50, 45, 32, 32, 32]\n",
|
|
"9 平和 False [84, 9, 17, 18, 15, 20, 17, 7, 3]\n",
|
|
"132 湿热 True [100, 6, 0, 31, 21, 33, 25, 7, 21]\n",
|
|
"134 阳虚 False [53, 37, 64, 25, 34, 37, 39, 50, 42]\n",
|
|
"133 阴虚 False [75, 31, 10, 59, 21, 8, 7, 14, 14]\n",
|
|
"3 痰湿 False [78, 31, 46, 34, 59, 41, 21, 14, 35]\n",
|
|
"71 阳虚 True [78, 21, 32, 21, 25, 20, 14, 7, 7]\n",
|
|
"6 阳虚 False [68, 28, 46, 43, 28, 25, 25, 7, 10]\n",
|
|
"135 湿热 False [53, 43, 39, 37, 56, 58, 57, 25, 39]\n",
|
|
"48 气虚 False [59, 43, 14, 43, 37, 41, 14, 39, 35]\n",
|
|
"53 痰湿 False [46, 68, 53, 59, 84, 79, 64, 57, 78]\n",
|
|
"138 湿热 False [43, 25, 42, 25, 28, 50, 25, 39, 10]\n",
|
|
"139 阳虚 False [53, 34, 46, 37, 40, 41, 42, 42, 25]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"filename = 'data/result_青海2025-1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'tcm' in v.keys():\n",
|
|
" list1 = []\n",
|
|
" tcm =v['tcm']\n",
|
|
" for item in tcm:\n",
|
|
" list1.append(item)\n",
|
|
" score = tcm_calc(list1)\n",
|
|
"\n",
|
|
" result = tcm_kind(score)\n",
|
|
" kind = result['kind']\n",
|
|
" near = result['near']\n",
|
|
" print(k,kinds[kind], near, score)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "35adcab6-e388-4abd-beba-b8bbc07b157e",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算心理"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "ffce959e-d42b-40eb-b694-d47cc7a73124",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-11T01:40:25.347203Z",
|
|
"iopub.status.busy": "2025-04-11T01:40:25.346884Z",
|
|
"iopub.status.idle": "2025-04-11T01:40:25.359777Z",
|
|
"shell.execute_reply": "2025-04-11T01:40:25.359185Z",
|
|
"shell.execute_reply.started": "2025-04-11T01:40:25.347169Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"{1: 30, 4: 14, 3: 12, 2: 8, 5: 1, 6: 1}\n",
|
|
"5\n",
|
|
"成就感 85\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 42\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 12\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 20, 4: 8, 3: 7, 2: 7, 5: 6, 6: 6}\n",
|
|
"99\n",
|
|
"成就感 57\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 25\n",
|
|
"压力应对 28\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 100\n",
|
|
"{1: 20, 4: 17, 3: 10, 2: 8, 5: 2, 6: 0}\n",
|
|
"101\n",
|
|
"成就感 57\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 35\n",
|
|
"压力应对 60\n",
|
|
"体力充沛 25\n",
|
|
"情感充沛度 0\n",
|
|
"{1: 35, 4: 9, 3: 10, 2: 9, 5: 2, 6: 1}\n",
|
|
"100\n",
|
|
"成就感 100\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 35\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 25\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 17, 4: 9, 3: 8, 2: 10, 5: 3, 6: 5}\n",
|
|
"102\n",
|
|
"成就感 48\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 28\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 12, 4: 25, 3: 28, 2: 28, 5: 0, 6: 2}\n",
|
|
"105\n",
|
|
"成就感 34\n",
|
|
"愉快心境 100\n",
|
|
"放松程度 100\n",
|
|
"压力应对 89\n",
|
|
"体力充沛 0\n",
|
|
"情感充沛度 33\n",
|
|
"{1: 20, 4: 13, 3: 12, 2: 11, 5: 3, 6: 1}\n",
|
|
"104\n",
|
|
"成就感 57\n",
|
|
"愉快心境 39\n",
|
|
"放松程度 42\n",
|
|
"压力应对 46\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 35, 4: 14, 3: 11, 2: 8, 5: 2, 6: 3}\n",
|
|
"103\n",
|
|
"成就感 100\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 39\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 25\n",
|
|
"情感充沛度 50\n",
|
|
"{1: 32, 4: 17, 3: 15, 2: 12, 5: 3, 6: 2}\n",
|
|
"18\n",
|
|
"成就感 91\n",
|
|
"愉快心境 42\n",
|
|
"放松程度 53\n",
|
|
"压力应对 60\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 33\n",
|
|
"{1: 27, 4: 8, 3: 9, 2: 10, 5: 5, 6: 4}\n",
|
|
"28\n",
|
|
"成就感 77\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 32\n",
|
|
"压力应对 28\n",
|
|
"体力充沛 62\n",
|
|
"情感充沛度 66\n",
|
|
"{1: 35, 4: 11, 3: 11, 2: 7, 5: 6, 6: 6}\n",
|
|
"33\n",
|
|
"成就感 100\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 39\n",
|
|
"压力应对 39\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 100\n",
|
|
"{1: 32, 4: 14, 3: 11, 2: 12, 5: 4, 6: 5}\n",
|
|
"107\n",
|
|
"成就感 91\n",
|
|
"愉快心境 42\n",
|
|
"放松程度 39\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 50\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 31, 4: 14, 3: 9, 2: 9, 5: 3, 6: 5}\n",
|
|
"39\n",
|
|
"成就感 88\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 32\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 25, 4: 14, 3: 13, 2: 13, 5: 3, 6: 3}\n",
|
|
"15\n",
|
|
"成就感 71\n",
|
|
"愉快心境 46\n",
|
|
"放松程度 46\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 50\n",
|
|
"{1: 26, 4: 19, 3: 16, 2: 14, 5: 0, 6: 5}\n",
|
|
"108\n",
|
|
"成就感 74\n",
|
|
"愉快心境 50\n",
|
|
"放松程度 57\n",
|
|
"压力应对 67\n",
|
|
"体力充沛 0\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 33, 4: 12, 3: 9, 2: 9, 5: 4, 6: 1}\n",
|
|
"36\n",
|
|
"成就感 94\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 32\n",
|
|
"压力应对 42\n",
|
|
"体力充沛 50\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 34, 4: 11, 3: 9, 2: 8, 5: 8, 6: 5}\n",
|
|
"43\n",
|
|
"成就感 97\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 32\n",
|
|
"压力应对 39\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 29, 4: 7, 3: 7, 2: 7, 5: 8, 6: 5}\n",
|
|
"24\n",
|
|
"成就感 82\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 25\n",
|
|
"压力应对 25\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 20, 4: 9, 3: 11, 2: 9, 5: 3, 6: 4}\n",
|
|
"61\n",
|
|
"成就感 57\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 39\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 66\n",
|
|
"{1: 27, 4: 13, 3: 11, 2: 13, 5: 3, 6: 4}\n",
|
|
"40\n",
|
|
"成就感 77\n",
|
|
"愉快心境 46\n",
|
|
"放松程度 39\n",
|
|
"压力应对 46\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 66\n",
|
|
"{1: 35, 4: 13, 3: 14, 2: 10, 5: 3, 6: 2}\n",
|
|
"113\n",
|
|
"成就感 100\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 50\n",
|
|
"压力应对 46\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 33\n",
|
|
"{1: 33, 4: 14, 3: 10, 2: 10, 5: 6, 6: 5}\n",
|
|
"114\n",
|
|
"成就感 94\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 35\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 24, 4: 10, 3: 8, 2: 9, 5: 8, 6: 6}\n",
|
|
"55\n",
|
|
"成就感 68\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 28\n",
|
|
"压力应对 35\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 100\n",
|
|
"{1: 26, 4: 15, 3: 14, 2: 11, 5: 2, 6: 0}\n",
|
|
"57\n",
|
|
"成就感 74\n",
|
|
"愉快心境 39\n",
|
|
"放松程度 50\n",
|
|
"压力应对 53\n",
|
|
"体力充沛 25\n",
|
|
"情感充沛度 0\n",
|
|
"{1: 29, 4: 11, 3: 9, 2: 10, 5: 6, 6: 2}\n",
|
|
"69\n",
|
|
"成就感 82\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 32\n",
|
|
"压力应对 39\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 33\n",
|
|
"{1: 20, 4: 12, 3: 11, 2: 10, 5: 6, 6: 2}\n",
|
|
"50\n",
|
|
"成就感 57\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 39\n",
|
|
"压力应对 42\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 33\n",
|
|
"{1: 27, 4: 16, 3: 11, 2: 14, 5: 3, 6: 4}\n",
|
|
"118\n",
|
|
"成就感 77\n",
|
|
"愉快心境 50\n",
|
|
"放松程度 39\n",
|
|
"压力应对 57\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 66\n",
|
|
"{1: 35, 4: 16, 3: 7, 2: 9, 5: 5, 6: 5}\n",
|
|
"20\n",
|
|
"成就感 100\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 25\n",
|
|
"压力应对 57\n",
|
|
"体力充沛 62\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 35, 4: 9, 3: 8, 2: 7, 5: 4, 6: 5}\n",
|
|
"35\n",
|
|
"成就感 100\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 28\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 50\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 24, 4: 14, 3: 9, 2: 9, 5: 8, 6: 5}\n",
|
|
"44\n",
|
|
"成就感 68\n",
|
|
"愉快心境 32\n",
|
|
"放松程度 32\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 21, 4: 14, 3: 11, 2: 10, 5: 1, 6: 4}\n",
|
|
"41\n",
|
|
"成就感 60\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 39\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 12\n",
|
|
"情感充沛度 66\n",
|
|
"{1: 29, 4: 12, 3: 14, 2: 11, 5: 1, 6: 3}\n",
|
|
"131\n",
|
|
"成就感 82\n",
|
|
"愉快心境 39\n",
|
|
"放松程度 50\n",
|
|
"压力应对 42\n",
|
|
"体力充沛 12\n",
|
|
"情感充沛度 50\n",
|
|
"{1: 35, 4: 8, 3: 8, 2: 7, 5: 8, 6: 5}\n",
|
|
"9\n",
|
|
"成就感 100\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 28\n",
|
|
"压力应对 28\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 35, 4: 7, 3: 8, 2: 7, 5: 8, 6: 6}\n",
|
|
"132\n",
|
|
"成就感 100\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 28\n",
|
|
"压力应对 25\n",
|
|
"体力充沛 100\n",
|
|
"情感充沛度 100\n",
|
|
"{1: 35, 4: 12, 3: 9, 2: 8, 5: 6, 6: 5}\n",
|
|
"134\n",
|
|
"成就感 100\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 32\n",
|
|
"压力应对 42\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 20, 4: 9, 3: 10, 2: 8, 5: 6, 6: 3}\n",
|
|
"133\n",
|
|
"成就感 57\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 35\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 50\n",
|
|
"{1: 32, 4: 11, 3: 11, 2: 8, 5: 7, 6: 5}\n",
|
|
"3\n",
|
|
"成就感 91\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 39\n",
|
|
"压力应对 39\n",
|
|
"体力充沛 87\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 27, 4: 7, 3: 8, 2: 7, 5: 6, 6: 5}\n",
|
|
"71\n",
|
|
"成就感 77\n",
|
|
"愉快心境 25\n",
|
|
"放松程度 28\n",
|
|
"压力应对 25\n",
|
|
"体力充沛 75\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 23, 4: 9, 3: 9, 2: 8, 5: 7, 6: 5}\n",
|
|
"6\n",
|
|
"成就感 65\n",
|
|
"愉快心境 28\n",
|
|
"放松程度 32\n",
|
|
"压力应对 32\n",
|
|
"体力充沛 87\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 24, 4: 22, 3: 12, 2: 10, 5: 4, 6: 5}\n",
|
|
"135\n",
|
|
"成就感 68\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 42\n",
|
|
"压力应对 78\n",
|
|
"体力充沛 50\n",
|
|
"情感充沛度 83\n",
|
|
"{1: 23, 4: 14, 3: 12, 2: 10, 5: 2, 6: 1}\n",
|
|
"48\n",
|
|
"成就感 65\n",
|
|
"愉快心境 35\n",
|
|
"放松程度 42\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 25\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 25, 4: 14, 3: 14, 2: 13, 5: 0, 6: 1}\n",
|
|
"53\n",
|
|
"成就感 71\n",
|
|
"愉快心境 46\n",
|
|
"放松程度 50\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 0\n",
|
|
"情感充沛度 16\n",
|
|
"{1: 20, 4: 14, 3: 9, 2: 16, 5: 3, 6: 3}\n",
|
|
"138\n",
|
|
"成就感 57\n",
|
|
"愉快心境 57\n",
|
|
"放松程度 32\n",
|
|
"压力应对 50\n",
|
|
"体力充沛 37\n",
|
|
"情感充沛度 50\n",
|
|
"{1: 32, 4: 13, 3: 12, 2: 11, 5: 4, 6: 2}\n",
|
|
"139\n",
|
|
"成就感 91\n",
|
|
"愉快心境 39\n",
|
|
"放松程度 42\n",
|
|
"压力应对 46\n",
|
|
"体力充沛 50\n",
|
|
"情感充沛度 33\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"list2 = ['成就感','愉快心境','放松程度','压力应对','体力充沛','情感充沛度']\n",
|
|
"list3 = [[5,7],[7,4],[7,4],[7,4],[8,1],[6,1]]\n",
|
|
"qb = [\n",
|
|
" 1, 1, 1, 1, 1,\n",
|
|
" 4, 3, 2, 3, 2, 4, 3,\n",
|
|
" 4, 3, 2, 4, 4, 2, 4,\n",
|
|
" 3, 2, 2, 4, 3, 3, 2,\n",
|
|
" 5, 5, 5, 5, 5, 5, 5, 5,\n",
|
|
" 6, 6, 6, 6, 6, 6\n",
|
|
" ]\n",
|
|
"filename = 'data/result_青海2025-1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'psy' in v.keys():\n",
|
|
" psy=v['psy']\n",
|
|
" for i in range(26,40):\n",
|
|
" new_valve = psy[i]-1\n",
|
|
" psy[i] = new_valve\n",
|
|
" dict3 = {}\n",
|
|
" \n",
|
|
" i = 0\n",
|
|
" for item in qb:\n",
|
|
" dict3.setdefault(item,0)\n",
|
|
" dict3[item] +=psy[i]\n",
|
|
" i+=1\n",
|
|
" print(dict3)\n",
|
|
" print(k)\n",
|
|
" for i in range(0,6):\n",
|
|
" score = int(dict3[i+1]/list3[i][0]/list3[i][1]*100)\n",
|
|
" print(list2[i],score)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "74f5837d-c6ea-4be7-bfca-eeb720d63436",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 计算脊柱"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "67c19da3-5e06-480b-94a4-76659517d3c3",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-11T01:40:28.861789Z",
|
|
"iopub.status.busy": "2025-04-11T01:40:28.861091Z",
|
|
"iopub.status.idle": "2025-04-11T01:40:28.876024Z",
|
|
"shell.execute_reply": "2025-04-11T01:40:28.874924Z",
|
|
"shell.execute_reply.started": "2025-04-11T01:40:28.861726Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"5 颈椎 20\n",
|
|
"5 胸椎 28\n",
|
|
"5 腰椎 66\n",
|
|
"5 骶尾椎 100\n",
|
|
"99 颈椎 80\n",
|
|
"99 胸椎 100\n",
|
|
"99 腰椎 83\n",
|
|
"99 骶尾椎 50\n",
|
|
"101 颈椎 30\n",
|
|
"101 胸椎 28\n",
|
|
"101 腰椎 83\n",
|
|
"101 骶尾椎 100\n",
|
|
"100 颈椎 60\n",
|
|
"100 胸椎 100\n",
|
|
"100 腰椎 83\n",
|
|
"100 骶尾椎 100\n",
|
|
"102 颈椎 80\n",
|
|
"102 胸椎 100\n",
|
|
"102 腰椎 100\n",
|
|
"102 骶尾椎 100\n",
|
|
"105 颈椎 60\n",
|
|
"105 胸椎 42\n",
|
|
"105 腰椎 83\n",
|
|
"105 骶尾椎 100\n",
|
|
"104 颈椎 90\n",
|
|
"104 胸椎 57\n",
|
|
"104 腰椎 100\n",
|
|
"104 骶尾椎 100\n",
|
|
"103 颈椎 60\n",
|
|
"103 胸椎 71\n",
|
|
"103 腰椎 100\n",
|
|
"103 骶尾椎 100\n",
|
|
"18 颈椎 10\n",
|
|
"18 胸椎 57\n",
|
|
"18 腰椎 16\n",
|
|
"18 骶尾椎 50\n",
|
|
"28 颈椎 70\n",
|
|
"28 胸椎 100\n",
|
|
"28 腰椎 100\n",
|
|
"28 骶尾椎 100\n",
|
|
"33 颈椎 90\n",
|
|
"33 胸椎 71\n",
|
|
"33 腰椎 100\n",
|
|
"33 骶尾椎 100\n",
|
|
"107 颈椎 40\n",
|
|
"107 胸椎 100\n",
|
|
"107 腰椎 100\n",
|
|
"107 骶尾椎 100\n",
|
|
"39 颈椎 60\n",
|
|
"39 胸椎 85\n",
|
|
"39 腰椎 83\n",
|
|
"39 骶尾椎 100\n",
|
|
"15 颈椎 100\n",
|
|
"15 胸椎 100\n",
|
|
"15 腰椎 100\n",
|
|
"15 骶尾椎 100\n",
|
|
"108 颈椎 60\n",
|
|
"108 胸椎 71\n",
|
|
"108 腰椎 100\n",
|
|
"108 骶尾椎 100\n",
|
|
"36 颈椎 70\n",
|
|
"36 胸椎 100\n",
|
|
"36 腰椎 83\n",
|
|
"36 骶尾椎 100\n",
|
|
"43 颈椎 60\n",
|
|
"43 胸椎 57\n",
|
|
"43 腰椎 66\n",
|
|
"43 骶尾椎 100\n",
|
|
"24 颈椎 90\n",
|
|
"24 胸椎 100\n",
|
|
"24 腰椎 83\n",
|
|
"24 骶尾椎 100\n",
|
|
"61 颈椎 60\n",
|
|
"61 胸椎 28\n",
|
|
"61 腰椎 83\n",
|
|
"61 骶尾椎 100\n",
|
|
"40 颈椎 70\n",
|
|
"40 胸椎 100\n",
|
|
"40 腰椎 50\n",
|
|
"40 骶尾椎 100\n",
|
|
"113 颈椎 90\n",
|
|
"113 胸椎 71\n",
|
|
"113 腰椎 100\n",
|
|
"113 骶尾椎 100\n",
|
|
"114 颈椎 70\n",
|
|
"114 胸椎 85\n",
|
|
"114 腰椎 100\n",
|
|
"114 骶尾椎 100\n",
|
|
"55 颈椎 100\n",
|
|
"55 胸椎 100\n",
|
|
"55 腰椎 100\n",
|
|
"55 骶尾椎 100\n",
|
|
"57 颈椎 50\n",
|
|
"57 胸椎 42\n",
|
|
"57 腰椎 83\n",
|
|
"57 骶尾椎 100\n",
|
|
"69 颈椎 90\n",
|
|
"69 胸椎 85\n",
|
|
"69 腰椎 100\n",
|
|
"69 骶尾椎 100\n",
|
|
"50 颈椎 60\n",
|
|
"50 胸椎 85\n",
|
|
"50 腰椎 100\n",
|
|
"50 骶尾椎 100\n",
|
|
"118 颈椎 50\n",
|
|
"118 胸椎 42\n",
|
|
"118 腰椎 50\n",
|
|
"118 骶尾椎 100\n",
|
|
"20 颈椎 50\n",
|
|
"20 胸椎 85\n",
|
|
"20 腰椎 66\n",
|
|
"20 骶尾椎 100\n",
|
|
"35 颈椎 80\n",
|
|
"35 胸椎 100\n",
|
|
"35 腰椎 83\n",
|
|
"35 骶尾椎 100\n",
|
|
"44 颈椎 90\n",
|
|
"44 胸椎 100\n",
|
|
"44 腰椎 83\n",
|
|
"44 骶尾椎 100\n",
|
|
"41 颈椎 20\n",
|
|
"41 胸椎 28\n",
|
|
"41 腰椎 33\n",
|
|
"41 骶尾椎 100\n",
|
|
"131 颈椎 70\n",
|
|
"131 胸椎 57\n",
|
|
"131 腰椎 100\n",
|
|
"131 骶尾椎 100\n",
|
|
"9 颈椎 100\n",
|
|
"9 胸椎 100\n",
|
|
"9 腰椎 83\n",
|
|
"9 骶尾椎 100\n",
|
|
"132 颈椎 90\n",
|
|
"132 胸椎 100\n",
|
|
"132 腰椎 100\n",
|
|
"132 骶尾椎 100\n",
|
|
"134 颈椎 60\n",
|
|
"134 胸椎 100\n",
|
|
"134 腰椎 66\n",
|
|
"134 骶尾椎 100\n",
|
|
"133 颈椎 90\n",
|
|
"133 胸椎 100\n",
|
|
"133 腰椎 100\n",
|
|
"133 骶尾椎 100\n",
|
|
"3 颈椎 60\n",
|
|
"3 胸椎 57\n",
|
|
"3 腰椎 83\n",
|
|
"3 骶尾椎 100\n",
|
|
"71 颈椎 100\n",
|
|
"71 胸椎 100\n",
|
|
"71 腰椎 100\n",
|
|
"71 骶尾椎 100\n",
|
|
"6 颈椎 80\n",
|
|
"6 胸椎 71\n",
|
|
"6 腰椎 83\n",
|
|
"6 骶尾椎 100\n",
|
|
"135 颈椎 70\n",
|
|
"135 胸椎 85\n",
|
|
"135 腰椎 66\n",
|
|
"135 骶尾椎 100\n",
|
|
"48 颈椎 60\n",
|
|
"48 胸椎 57\n",
|
|
"48 腰椎 100\n",
|
|
"48 骶尾椎 100\n",
|
|
"53 颈椎 20\n",
|
|
"53 胸椎 71\n",
|
|
"53 腰椎 50\n",
|
|
"53 骶尾椎 100\n",
|
|
"138 颈椎 80\n",
|
|
"138 胸椎 100\n",
|
|
"138 腰椎 83\n",
|
|
"138 骶尾椎 100\n",
|
|
"139 颈椎 80\n",
|
|
"139 胸椎 100\n",
|
|
"139 腰椎 66\n",
|
|
"139 骶尾椎 100\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n",
|
|
"list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]\n",
|
|
"filename = 'data/result_青海2025-1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"for k, v in dict1.items():\n",
|
|
" if 'spine' in v.keys():\n",
|
|
" spine = v['spine']\n",
|
|
" for i in range(0,4):\n",
|
|
" score = 0\n",
|
|
" for ii in range(list5[i][0],list5[i][1]):\n",
|
|
" score+= spine[ii]\n",
|
|
" print(k,list4[i],int(score/list5[i][2]*100)-100)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "40ff33f6-5fd3-423e-bf52-ac16327e8f82",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2025-04-11T01:40:39.471601Z",
|
|
"iopub.status.busy": "2025-04-11T01:40:39.470919Z",
|
|
"iopub.status.idle": "2025-04-11T01:40:39.687705Z",
|
|
"shell.execute_reply": "2025-04-11T01:40:39.687184Z",
|
|
"shell.execute_reply.started": "2025-04-11T01:40:39.471535Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
|
|
"filename = 'data/result_青海2025-1.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"data_list = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" list6 = []\n",
|
|
" list6.append(str(k).rjust(4,'0'))\n",
|
|
" list6.append(v['name'])\n",
|
|
" list6.append(v['sex'])\n",
|
|
" list6.append(v['unit'])\n",
|
|
" list6.append(v['age'])\n",
|
|
" if 'bmi' in v.keys():\n",
|
|
" bmi = v['bmi']['成绩']\n",
|
|
" list6.append(bmi.split(',')[0]+' 厘米')\n",
|
|
" list6.append(bmi.split(',')[1]+' 千克')\n",
|
|
" list6.append(v['bmi']['score'])\n",
|
|
" else:\n",
|
|
" list6.append('')\n",
|
|
" list6.append('')\n",
|
|
" list6.append('')\n",
|
|
" for xm in list_item:\n",
|
|
" if xm in v.keys():\n",
|
|
" list6.append(v[xm]['成绩'])\n",
|
|
" list6.append(v[xm]['score'])\n",
|
|
" else:\n",
|
|
" list6.append('')\n",
|
|
" list6.append('')\n",
|
|
" \n",
|
|
" if 'tcm' in v.keys():\n",
|
|
" list1 = []\n",
|
|
" tcm =v['tcm']\n",
|
|
" for item in tcm:\n",
|
|
" list1.append(item)\n",
|
|
" score = tcm_calc(list1)\n",
|
|
"\n",
|
|
" result = tcm_kind(score)\n",
|
|
" kind = result['kind']\n",
|
|
" near = result['near']\n",
|
|
" #print(k,kinds[kind], near, score)\n",
|
|
" list6.append(kinds[kind])\n",
|
|
" if near:\n",
|
|
" list6.append('是')\n",
|
|
" else:\n",
|
|
" list6.append('')\n",
|
|
" for item in score:\n",
|
|
" list6.append(item)\n",
|
|
" else:\n",
|
|
" for i in range(0,11):\n",
|
|
" list6.append('')\n",
|
|
" i+=1\n",
|
|
" if 'psy' in v.keys():\n",
|
|
" psy=v['psy']\n",
|
|
" for i in range(26,40):\n",
|
|
" new_valve = psy[i]-1\n",
|
|
" psy[i] = new_valve\n",
|
|
" dict3 = {}\n",
|
|
" \n",
|
|
" i = 0\n",
|
|
" for item in qb:\n",
|
|
" dict3.setdefault(item,0)\n",
|
|
" dict3[item] +=psy[i]\n",
|
|
" i+=1\n",
|
|
" \n",
|
|
" for i in range(0,6):\n",
|
|
" score = int(dict3[i+1]/list3[i][0]/list3[i][1]*100)\n",
|
|
" list6.append(score)\n",
|
|
" else:\n",
|
|
" for i in range(0,6):\n",
|
|
" list6.append('')\n",
|
|
" i+=1\n",
|
|
" if 'spine' in v.keys():\n",
|
|
" spine = v['spine']\n",
|
|
" for i in range(0,4):\n",
|
|
" score = 0\n",
|
|
" for ii in range(list5[i][0],list5[i][1]):\n",
|
|
" score+= spine[ii]\n",
|
|
" list6.append(int(score/list5[i][2]*100)-100)\n",
|
|
" else:\n",
|
|
" for i in range(0,4):\n",
|
|
" list6.append('')\n",
|
|
" i+=1\n",
|
|
" data_list.append(list6)\n",
|
|
"filename = 'data/青海测试情况表2025.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"#sheet.append(title)\n",
|
|
"for row in data_list:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename) \n",
|
|
" \n",
|
|
" \n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 113,
|
|
"id": "5aefec37-8db4-49c0-bb73-56906f3510ec",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2024-07-25T15:31:51.204580Z",
|
|
"iopub.status.busy": "2024-07-25T15:31:51.203825Z",
|
|
"iopub.status.idle": "2024-07-25T15:31:51.226327Z",
|
|
"shell.execute_reply": "2024-07-25T15:31:51.225747Z",
|
|
"shell.execute_reply.started": "2024-07-25T15:31:51.204509Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"filename = 'data/result_青海all_2.json'\n",
|
|
"list4 = ['颈椎','胸椎','腰椎','骶尾椎']\n",
|
|
"list5 = [[0,10,10],[10,17,7],[17,24,6],[24,26,2]]\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"data_list = []\n",
|
|
"for k, v in dict1.items():\n",
|
|
" \n",
|
|
" if 'spine' in v.keys():\n",
|
|
" list6 = []\n",
|
|
" list6.append(str(k).rjust(4,'0'))\n",
|
|
" list6.append(v['name'])\n",
|
|
" list6.append(v['sex'])\n",
|
|
" list6.append(v['unit'])\n",
|
|
" list6.append(v['age']) \n",
|
|
" spine = v['spine']\n",
|
|
" for i in range(0,4):\n",
|
|
" score = 0\n",
|
|
" for ii in range(list5[i][0],list5[i][1]):\n",
|
|
" score+= spine[ii]\n",
|
|
" list6.append(int(score/list5[i][2]*100)-100)\n",
|
|
" for item in spine:\n",
|
|
" list6.append(item)\n",
|
|
" data_list.append(list6)\n",
|
|
" \n",
|
|
"filename = 'data/青海脊椎情况表.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"#sheet.append(title)\n",
|
|
"for row in data_list:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "df0dc1d9-ad92-44b5-9214-14d433a877f1",
|
|
"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
|
|
}
|