This commit is contained in:
512song committed 2025-06-23 18:07:05 +08:00
1 parent 926edeed0a
commit 678a2c983d
4 files changed
+733 -198

No files matched your search

+229 -25
View File
@@ -3,7 +3,9 @@
{
"cell_type": "markdown",
"id": "b6ce4321-f82a-4d9d-a110-44a23b95970b",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"# 2023年体质检测"
]
@@ -1295,15 +1297,15 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"id": "3e6da1e5-4b4e-448a-9663-815372da636b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T03:27:04.981862Z",
"iopub.status.busy": "2025-06-13T03:27:04.981235Z",
"iopub.status.idle": "2025-06-13T03:27:05.072701Z",
"shell.execute_reply": "2025-06-13T03:27:05.072214Z",
"shell.execute_reply.started": "2025-06-13T03:27:04.981836Z"
"iopub.execute_input": "2025-06-20T07:00:42.285453Z",
"iopub.status.busy": "2025-06-20T07:00:42.285034Z",
"iopub.status.idle": "2025-06-20T07:00:42.566814Z",
"shell.execute_reply": "2025-06-20T07:00:42.566337Z",
"shell.execute_reply.started": "2025-06-20T07:00:42.285425Z"
}
},
"outputs": [
@@ -1405,15 +1407,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"id": "d07d132b-dd74-458d-af0c-6a6ae005ad3a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T03:27:18.479485Z",
"iopub.status.busy": "2025-06-13T03:27:18.478877Z",
"iopub.status.idle": "2025-06-13T03:27:18.509731Z",
"shell.execute_reply": "2025-06-13T03:27:18.509101Z",
"shell.execute_reply.started": "2025-06-13T03:27:18.479432Z"
"iopub.execute_input": "2025-06-20T07:01:09.689108Z",
"iopub.status.busy": "2025-06-20T07:01:09.688292Z",
"iopub.status.idle": "2025-06-20T07:01:09.724466Z",
"shell.execute_reply": "2025-06-20T07:01:09.724012Z",
"shell.execute_reply.started": "2025-06-20T07:01:09.689036Z"
}
},
"outputs": [
@@ -1455,15 +1457,15 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"id": "971d592d-9ff5-4758-af68-2f60a986c2a2",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-13T03:27:29.624787Z",
"iopub.status.busy": "2025-06-13T03:27:29.623200Z",
"iopub.status.idle": "2025-06-13T03:27:29.651956Z",
"shell.execute_reply": "2025-06-13T03:27:29.651402Z",
"shell.execute_reply.started": "2025-06-13T03:27:29.624721Z"
"iopub.execute_input": "2025-06-20T07:01:12.924286Z",
"iopub.status.busy": "2025-06-20T07:01:12.923570Z",
"iopub.status.idle": "2025-06-20T07:01:12.944059Z",
"shell.execute_reply": "2025-06-20T07:01:12.943647Z",
"shell.execute_reply.started": "2025-06-20T07:01:12.924217Z"
}
},
"outputs": [
@@ -1582,6 +1584,123 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "1fb920d9-2a09-45cf-80e8-0e2dfe7da4c2",
"metadata": {},
"source": [
"## 导入问卷信息"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "9108c394-577f-451a-975c-e1e1cf8b4daf",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-23T03:24:33.496466Z",
"iopub.status.busy": "2025-06-23T03:24:33.495720Z",
"iopub.status.idle": "2025-06-23T03:24:33.522545Z",
"shell.execute_reply": "2025-06-23T03:24:33.522082Z",
"shell.execute_reply.started": "2025-06-23T03:24:33.496392Z"
}
},
"outputs": [],
"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_records_20250623.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,44):\n",
" psy.append(0)\n",
"\n",
"for i in range(0,60):\n",
" tcm.append(0)\n",
"for i in range(0,26):\n",
" spine.append(0)\n",
"i= 1\n",
"for item in list1:\n",
" if item[3] in phone.keys():\n",
" psy =[]\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,44):\n",
" psy.append(0)\n",
" psy.append([])\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" \n",
" content = json.loads(item[4])\n",
" if phone[item[3]] not in dict1.keys():\n",
" dict1[phone[item[3]]] = dict3[phone[item[3]]]\n",
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
" else:\n",
" rq = date.fromisoformat('2025-06-23')\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[4]:\n",
" #for i in range(5,26):\n",
" # new_valve = 5-psy[i]\n",
" # psy[i] = new_valve\n",
" \n",
" \n",
" dict1[phone[item[3]]]['psy'] = psy\n",
" if 'tcm' in item[4]:\n",
" dict1[phone[item[3]]]['tcm'] = tcm\n",
" if 'spine' in item[4]:\n",
" dict1[phone[item[3]]]['spine'] = spine\n",
" birth = date.fromisoformat(dict3[phone[item[3]]]['birth'].replace('/','-'))\n",
" \n",
" days = (rq-birth).days \n",
" dict1[phone[item[3]]]['age'] = int(days/365)\n",
" dict1[phone[item[3]]]['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": "1f2c3e94-e14b-4c68-b5c7-a71b95fc2f86",
@@ -1596,11 +1715,11 @@
"id": "cf15813a-02de-4dc9-95fe-912d9a5d9025",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-09T08:14:41.869403Z",
"iopub.status.busy": "2025-06-09T08:14:41.868754Z",
"iopub.status.idle": "2025-06-09T08:16:55.156384Z",
"shell.execute_reply": "2025-06-09T08:16:55.155379Z",
"shell.execute_reply.started": "2025-06-09T08:14:41.869343Z"
"iopub.execute_input": "2025-06-20T07:01:28.279760Z",
"iopub.status.busy": "2025-06-20T07:01:28.279048Z",
"iopub.status.idle": "2025-06-20T07:03:42.883383Z",
"shell.execute_reply": "2025-06-20T07:03:42.882115Z",
"shell.execute_reply.started": "2025-06-20T07:01:28.279692Z"
}
},
"outputs": [
@@ -1676,8 +1795,93 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "a7eb6a67-a31d-43cf-a44b-8c36c4686de4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-06-23T03:24:39.379408Z",
"iopub.status.busy": "2025-06-23T03:24:39.378752Z",
"iopub.status.idle": "2025-06-23T03:24:40.314206Z",
"shell.execute_reply": "2025-06-23T03:24:40.313653Z",
"shell.execute_reply.started": "2025-06-23T03:24:39.379350Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'path': './东营石油设计院2025-1/0263-周翠娟.pdf', 'title': '东营石油设计院', 'subtitle': '档案管理中心', 'id': '0263', 'name': '周翠娟', 'gender': 'female', 'month': 468, 'fits': {'lung': {'mark': '2737', 'score': 4}, 'grip': {'mark': '26.4', 'score': 2}, 'flexion': {'mark': '18.6', 'score': 4}, 'jump': {'mark': '22.8', 'score': 4}, 'balance': {'mark': '66.8', 'score': 5}, 'reaction': {'mark': '0.423', 'score': 5}, 'situp': {'mark': '25', 'score': 5}, 'bmi': {'mark': '166.3,57.1', 'score': 5}}, 'surveys': {'tcm': [4, 4, 1, 3, 1, 5, 2, 2, 2, 1, 3, 1, 3, 3, 3, 3, 1, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 2, 2, 1, 4, 1, 3, 2, 2, 3, 1, 1, 1, 1, 4, 4, 1, 3], 'psy': [6, 7, 7, 7, 7, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, []], 'spine': [2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 0, 2, 1, 2, 2]}}\n",
"1\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 'surveys' in mydata.keys():\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": "be1fbc81-363c-41cc-8ede-63100002ef1c",
"metadata": {},
"outputs": [],
"source": []