20250407
This commit is contained in:
1 parent
b030391f58
commit
f6dd5f0da5
7 files changed
+744
-1120
No files matched your search
+289
-6
@@ -1433,6 +1433,72 @@
|
||||
"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",
|
||||
@@ -1443,15 +1509,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 2,
|
||||
"id": "f3d39079-fa3a-400c-990e-75a8a0a7b42d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:12:49.821141Z",
|
||||
"iopub.status.busy": "2025-01-20T01:12:49.820394Z",
|
||||
"iopub.status.idle": "2025-01-20T01:12:49.854877Z",
|
||||
"shell.execute_reply": "2025-01-20T01:12:49.854327Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:12:49.821069Z"
|
||||
"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": [],
|
||||
@@ -1504,6 +1570,131 @@
|
||||
"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",
|
||||
@@ -1716,6 +1907,98 @@
|
||||
"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",
|
||||
|
||||
Reference in new issue
Block a user