20251021
This commit is contained in:
1 parent
ba6f6b413a
commit
a10492f0ad
6 files changed
+1705
-151
No files matched your search
+168
-25
@@ -10,15 +10,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 8,
|
||||
"id": "d6449ec6-54af-4f68-8c32-69372e390acf",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-22T03:30:37.564857Z",
|
||||
"iopub.status.busy": "2025-09-22T03:30:37.564250Z",
|
||||
"iopub.status.idle": "2025-09-22T03:30:37.781384Z",
|
||||
"shell.execute_reply": "2025-09-22T03:30:37.780531Z",
|
||||
"shell.execute_reply.started": "2025-09-22T03:30:37.564798Z"
|
||||
"iopub.execute_input": "2025-09-22T12:07:43.029162Z",
|
||||
"iopub.status.busy": "2025-09-22T12:07:43.028847Z",
|
||||
"iopub.status.idle": "2025-09-22T12:07:43.046141Z",
|
||||
"shell.execute_reply": "2025-09-22T12:07:43.045652Z",
|
||||
"shell.execute_reply.started": "2025-09-22T12:07:43.029136Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -45,7 +45,7 @@
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||
" #dict1['sex'] = sheet.cell(n, 5).value\n",
|
||||
" dict1['sex'] = sheet.cell(n, 6).value\n",
|
||||
" dict1['unit'] = sheet.cell(n, 4).value \n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 3).value).replace('/','-').split(' ')[0]\n",
|
||||
" dict1['phone'] = sheet.cell(n, 5).value \n",
|
||||
@@ -66,15 +66,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 15,
|
||||
"id": "c24c957e-6cc5-4cab-81e2-cec86a7498c7",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-22T03:48:21.444109Z",
|
||||
"iopub.status.busy": "2025-09-22T03:48:21.443422Z",
|
||||
"iopub.status.idle": "2025-09-22T03:48:21.472961Z",
|
||||
"shell.execute_reply": "2025-09-22T03:48:21.472454Z",
|
||||
"shell.execute_reply.started": "2025-09-22T03:48:21.444045Z"
|
||||
"iopub.execute_input": "2025-09-22T12:49:46.218013Z",
|
||||
"iopub.status.busy": "2025-09-22T12:49:46.217356Z",
|
||||
"iopub.status.idle": "2025-09-22T12:49:46.243578Z",
|
||||
"shell.execute_reply": "2025-09-22T12:49:46.242996Z",
|
||||
"shell.execute_reply.started": "2025-09-22T12:49:46.217955Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -82,7 +82,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"33\n"
|
||||
"31\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -144,11 +144,61 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 16,
|
||||
"id": "a64ad6b7-b1dd-42ca-9619-3adcb8e0674e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-22T12:49:52.460408Z",
|
||||
"iopub.status.busy": "2025-09-22T12:49:52.459655Z",
|
||||
"iopub.status.idle": "2025-09-22T12:49:52.470790Z",
|
||||
"shell.execute_reply": "2025-09-22T12:49:52.469571Z",
|
||||
"shell.execute_reply.started": "2025-09-22T12:49:52.460338Z"
|
||||
}
|
||||
},
|
||||
"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_通用技术中国医药.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(str(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_通用技术中国医药.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -160,15 +210,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 17,
|
||||
"id": "020be101-938b-427e-918d-faf2e74b5b7e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-22T03:57:31.502714Z",
|
||||
"iopub.status.busy": "2025-09-22T03:57:31.501987Z",
|
||||
"iopub.status.idle": "2025-09-22T03:57:31.516781Z",
|
||||
"shell.execute_reply": "2025-09-22T03:57:31.515780Z",
|
||||
"shell.execute_reply.started": "2025-09-22T03:57:31.502649Z"
|
||||
"iopub.execute_input": "2025-09-22T12:49:55.871938Z",
|
||||
"iopub.status.busy": "2025-09-22T12:49:55.871204Z",
|
||||
"iopub.status.idle": "2025-09-22T12:49:55.886755Z",
|
||||
"shell.execute_reply": "2025-09-22T12:49:55.885950Z",
|
||||
"shell.execute_reply.started": "2025-09-22T12:49:55.871866Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -244,10 +294,103 @@
|
||||
" json.dump(dict1, fl, ensure_ascii=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7ec62459-2938-4c0c-b35a-f4341630f1c6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成报告"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"id": "17dd5667-d970-46d2-b241-27338dbba4bb",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-09-22T12:51:00.278870Z",
|
||||
"iopub.status.busy": "2025-09-22T12:51:00.278200Z",
|
||||
"iopub.status.idle": "2025-09-22T12:51:14.234951Z",
|
||||
"shell.execute_reply": "2025-09-22T12:51:14.233971Z",
|
||||
"shell.execute_reply.started": "2025-09-22T12:51:00.278810Z"
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"31\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_通用技术中国医药-1.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'] = 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 = str(v[item]['成绩']).split()[0].split('.')[0]\n",
|
||||
" else:\n",
|
||||
" mark = str(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": "9560d0ca-4d39-400b-b054-214e243ca4e5",
|
||||
"id": "4297b542-206e-4f0e-9339-ba88e712443e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user