250251215

This commit is contained in:
512song committed 2025-12-15 08:11:54 +08:00
1 parent c19ca272d7
commit 6803e6fff6
6 files changed
+1464 -620

No files matched your search

@@ -90,26 +90,10 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"id": "cac3736a-56da-403b-9e62-5caaf989a6d4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T13:46:10.295376Z",
"iopub.status.busy": "2025-12-03T13:46:10.294744Z",
"iopub.status.idle": "2025-12-03T13:46:13.043043Z",
"shell.execute_reply": "2025-12-03T13:46:13.042530Z",
"shell.execute_reply.started": "2025-12-03T13:46:10.295324Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"190 ok\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -211,26 +195,10 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"id": "925f7152-b365-4df8-8d98-73569aef68f8",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T14:07:05.330354Z",
"iopub.status.busy": "2025-12-03T14:07:05.329571Z",
"iopub.status.idle": "2025-12-03T14:07:05.346870Z",
"shell.execute_reply": "2025-12-03T14:07:05.345950Z",
"shell.execute_reply.started": "2025-12-03T14:07:05.330293Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"95\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import datetime\n",
@@ -261,26 +229,10 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T13:55:35.038083Z",
"iopub.status.busy": "2025-12-03T13:55:35.036944Z",
"iopub.status.idle": "2025-12-03T13:55:35.052613Z",
"shell.execute_reply": "2025-12-03T13:55:35.051549Z",
"shell.execute_reply.started": "2025-12-03T13:55:35.038026Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -319,26 +271,10 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"id": "0e71f6b8-e17e-49f8-a577-7a2eb6f5e994",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T14:07:15.401160Z",
"iopub.status.busy": "2025-12-03T14:07:15.400541Z",
"iopub.status.idle": "2025-12-03T14:07:15.419441Z",
"shell.execute_reply": "2025-12-03T14:07:15.418453Z",
"shell.execute_reply.started": "2025-12-03T14:07:15.401101Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -492,6 +428,49 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "44d5a1bf-b208-4a50-bea3-1019e737b7ab",
"metadata": {},
"source": [
"## 统计体测日期"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "f4fc0e48-5c8a-4ad9-817e-dd8dd1bf7b55",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-15T00:10:27.023346Z",
"iopub.status.busy": "2025-12-15T00:10:27.023028Z",
"iopub.status.idle": "2025-12-15T00:10:27.028151Z",
"shell.execute_reply": "2025-12-15T00:10:27.027670Z",
"shell.execute_reply.started": "2025-12-15T00:10:27.023320Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2025-07-03 2025-08-18\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/result_新疆油田采油工艺研究院1-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"for k,v in dict1.items():\n",
" if 'rq' in v.keys():\n",
" list1.append(v['rq'])\n",
"print(min(list1),max(list1))"
]
},
{
"cell_type": "markdown",
"id": "699c6a40-a6ae-4300-9646-708cb85aa5e8",
@@ -629,7 +608,7 @@
" phone[v['phone']] = k\n",
"\n",
"list1 = []\n",
"filename = 'data/survey_records_20250813.csv'\n",
"filename = 'data/survey_records_20251214.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -639,8 +618,7 @@
"\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" \n",
"for item in list1: \n",
" if int(item[3]) in phone.keys():\n",
" code = phone[int(item[3])]\n",
" tcm = []\n",
@@ -686,6 +664,93 @@
"print(nn)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9a92b29-7112-459b-8c5a-4edd7e72457d",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"dict1 = {}\n",
"\n",
"filename = 'data/result_新疆油田采油工艺研究院1.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"filename = 'data/新疆油田采油工艺研究院-1.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
"phone = {}\n",
"for k,v in dict3.items():\n",
" if 'phone' in v.keys():\n",
" phone[v['phone']] = k\n",
"print(phone)\n",
"list1 = []\n",
"filename = 'data/survey_records_20250813.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" list1.append(line)\n",
"\n",
"\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" content = json.loads(item[4])\n",
" print(content)\n",
" if 'phone' in content.keys() and int(content['phone']) in phone.keys():\n",
" code = phone[int(content['phone'])] \n",
" print(code)\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" \n",
" \n",
" if code not in dict1.keys():\n",
" dict1[code] = dict3[code]\n",
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
" dict1[code]['rq'] = item[5].replace('/','-').split(' ')[0]\n",
" for k, v in content.items():\n",
" \n",
" if 'tcm' in k:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" if 'spine' in k:\n",
" i = int(k[5:])\n",
" spine[i-1] = int(v)\n",
" \n",
" if 'tcm' in item[4]:\n",
" \n",
" dict1[code]['tcm'] = tcm\n",
" if 'spine' in item[4]:\n",
" for ii in range(25,23,-1):\n",
" spine[ii] = spine[ii-1]\n",
" spine[22] = 0 \n",
" dict1[code]['spine'] = spine\n",
" birth = date.fromisoformat(dict3[code]['birth'].replace('/','-'))\n",
" rq = date.fromisoformat(item[5].replace('/','-').split(' ')[0])\n",
" days = (rq-birth).days \n",
" dict1[code]['age'] = int(days/365)\n",
" dict1[code]['month'] = int(days/365*12)\n",
" #print(phone[item[2]])\n",
" nn+=1\n",
"filename = 'data/result_新疆油田采油工艺研究院1-1.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(nn)"
]
},
{
"cell_type": "markdown",
"id": "6eea20f8-b457-455e-8409-5c8cdaa1efb6",
@@ -696,26 +761,10 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": null,
"id": "83872322-129c-410d-a9a3-ef6f4fe8dcde",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T14:07:28.969613Z",
"iopub.status.busy": "2025-12-03T14:07:28.969043Z",
"iopub.status.idle": "2025-12-03T14:07:28.992695Z",
"shell.execute_reply": "2025-12-03T14:07:28.991843Z",
"shell.execute_reply.started": "2025-12-03T14:07:28.969559Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"95\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
@@ -855,26 +904,10 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"id": "694ad38e-755e-4885-94a9-c157ddc96564",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-24T11:08:24.326077Z",
"iopub.status.busy": "2025-11-24T11:08:24.325551Z",
"iopub.status.idle": "2025-11-24T11:08:55.094267Z",
"shell.execute_reply": "2025-11-24T11:08:55.093154Z",
"shell.execute_reply.started": "2025-11-24T11:08:24.326028Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"53\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
@@ -939,26 +972,10 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": null,
"id": "28790176-7666-4b2d-83a5-9207cb8ad757",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-03T14:08:59.269168Z",
"iopub.status.busy": "2025-12-03T14:08:59.268598Z",
"iopub.status.idle": "2025-12-03T14:09:06.148725Z",
"shell.execute_reply": "2025-12-03T14:09:06.148173Z",
"shell.execute_reply.started": "2025-12-03T14:08:59.269114Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"14\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
@@ -1098,26 +1115,10 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "73d28b6a-91be-47bb-bf76-1b8c26faafb5",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-11T04:31:28.041103Z",
"iopub.status.busy": "2025-11-11T04:31:28.040413Z",
"iopub.status.idle": "2025-11-11T04:31:28.055394Z",
"shell.execute_reply": "2025-11-11T04:31:28.054740Z",
"shell.execute_reply.started": "2025-11-11T04:31:28.041040Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"27\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
@@ -1186,26 +1187,10 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"id": "cdbeb2f8-2784-4688-806a-6506799941cb",
"metadata": {
"execution": {
"iopub.execute_input": "2025-11-11T04:31:58.919201Z",
"iopub.status.busy": "2025-11-11T04:31:58.918605Z",
"iopub.status.idle": "2025-11-11T04:32:06.150780Z",
"shell.execute_reply": "2025-11-11T04:32:06.149803Z",
"shell.execute_reply.started": "2025-11-11T04:31:58.919144Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"27\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
@@ -1268,10 +1253,157 @@
"print(i)"
]
},
{
"cell_type": "markdown",
"id": "03a98563-9dc9-4faf-97c0-d504f00f2dc3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T08:18:47.657261Z",
"iopub.status.busy": "2025-12-14T08:18:47.656588Z",
"iopub.status.idle": "2025-12-14T08:18:47.662530Z",
"shell.execute_reply": "2025-12-14T08:18:47.661420Z",
"shell.execute_reply.started": "2025-12-14T08:18:47.657196Z"
}
},
"source": [
"## 生成体质检测报告"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8564de3a-1511-4a79-9ec3-32aea03595c7",
"id": "7791e71a-6eb0-4943-9aa4-9a2a0ebe6c43",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_新疆油田采油工艺研究院-1.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'] = 60\n",
" mydata['fits'] = {}\n",
" #survey_list = ['tcm','psy57','spine']\n",
" survey_list = ['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",
" \n",
" if 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": "a24a10c2-bc1c-4675-b49d-b6e208190c61",
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_新疆油田采油工艺研究院-1.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(8,\"0\")\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": "code",
"execution_count": null,
"id": "e50769a2-cf7b-4019-a5b9-f9d83e0bc374",
"metadata": {},
"outputs": [],
"source": []