250251215

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

No files matched your search

+296 -19
View File
@@ -63,6 +63,59 @@
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "27a49c91-b122-47cf-806a-6b252787b2db",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:13:24.043753Z",
"iopub.status.busy": "2025-12-12T13:13:24.042051Z",
"iopub.status.idle": "2025-12-12T13:13:24.065063Z",
"shell.execute_reply": "2025-12-12T13:13:24.064583Z",
"shell.execute_reply.started": "2025-12-12T13:13:24.043682Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12\n",
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\n",
"\n",
"wb = openpyxl.load_workbook('data/东营油田老年大学体质检测名单(2512).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",
" code = int(sheet.cell(n, 1).value)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 2).value\n",
" dict1['sex'] = sheet.cell(n, 3).value\n",
" dict1['unit'] = ''\n",
" dict1['birth'] = str(sheet.cell(n, 4).value).replace('/','-').split(' ')[0]\n",
" #dict1['age'] = sheet.cell(n, 6).value\n",
" if sheet.cell(n,5).value is not None:\n",
" dict1['phone'] = str(sheet.cell(n,5).value) \n",
" person[code] = dict1\n",
"filename = 'data/油田老年大学2025年度体质复测.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person))\n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": 88,
@@ -341,6 +394,85 @@
"print(len(re_ta))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "dcc5a261-35ef-48c2-b4dd-618f417e45dc",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:13:33.184367Z",
"iopub.status.busy": "2025-12-12T13:13:33.183622Z",
"iopub.status.idle": "2025-12-12T13:13:33.204374Z",
"shell.execute_reply": "2025-12-12T13:13:33.203788Z",
"shell.execute_reply.started": "2025-12-12T13:13:33.184296Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"12\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_20251212.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",
" #print(user)\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",
" re_ta[user]['birth'] = dict1[user]['birth']\n",
" re_ta[user]['unit'] = dict1[user]['unit']\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_油田老年大学年度体质复测.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": "74ec60b7-b1d9-488d-95fa-4ddd020c2a4c",
@@ -351,15 +483,15 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 26,
"id": "c3b99428-00d5-45ea-9803-261194525fa4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-07T12:39:35.778154Z",
"iopub.status.busy": "2025-04-07T12:39:35.777362Z",
"iopub.status.idle": "2025-04-07T12:39:35.793555Z",
"shell.execute_reply": "2025-04-07T12:39:35.792548Z",
"shell.execute_reply.started": "2025-04-07T12:39:35.778096Z"
"iopub.execute_input": "2025-12-12T13:13:35.809342Z",
"iopub.status.busy": "2025-12-12T13:13:35.808036Z",
"iopub.status.idle": "2025-12-12T13:13:35.820106Z",
"shell.execute_reply": "2025-12-12T13:13:35.818957Z",
"shell.execute_reply.started": "2025-12-12T13:13:35.809273Z"
}
},
"outputs": [
@@ -378,7 +510,7 @@
"\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_陈庄检测人员-2.json'\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",
@@ -401,7 +533,7 @@
" dict2[k][item_en]['score'] = My.cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"\n",
"filename = f'data/result_陈庄检测人员-2.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
@@ -874,6 +1006,142 @@
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "0ba2e1a3-78c8-44d9-ab7d-b17b52b0a99f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-12T13:38:13.857680Z",
"iopub.status.busy": "2025-12-12T13:38:13.856977Z",
"iopub.status.idle": "2025-12-12T13:38:13.880423Z",
"shell.execute_reply": "2025-12-12T13:38:13.879532Z",
"shell.execute_reply.started": "2025-12-12T13:38:13.857614Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"15684378667\n",
"15684378667\n",
"13699180673\n",
"15105461296\n",
"13012909096\n",
"13954605763\n",
"13287350839\n",
"13561090015\n",
"13287336162\n",
"13963396946\n",
"15105461298\n",
"13864739068\n",
"13013569039\n",
"13864757610\n",
"15725185717\n"
]
}
],
"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_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
"\n",
"\n",
"list1 = []\n",
"filename = 'data/sql_20251212.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",
"\n",
"for item in list1:\n",
" psy = []\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,30):\n",
" psy.append(0)\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" phone = item[0][2:]\n",
" print(phone)\n",
" for k1, v1 in dict3.items():\n",
" if 'phone' in v1.keys() and phone ==v1['phone']: \n",
" dict1[k1] = dict3[k1]\n",
" #dict1[k1]['month'] = dict1[k1]['age'] *12\n",
"for item in list1:\n",
" #print(item)\n",
" psy = []\n",
" tcm = []\n",
" spine = []\n",
" for i in range(0,30):\n",
" psy.append(0)\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for i in range(0,26):\n",
" spine.append(0)\n",
" phone = item[0][2:]\n",
" for k1, v1 in dict1.items():\n",
" #print((k1,v1))\n",
" if 'phone' in v1.keys() and phone ==v1['phone']: \n",
" content = json.loads(item[1])\n",
" #print(content)\n",
" \n",
" rq = date.fromisoformat(item[2].replace('/','-').split(' ')[0])\n",
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
" for k, v in json.loads(content).items():\n",
" #print('k:',k,'v:',v)\n",
" if 'psyOld' in k: \n",
" i = int(k[6:])\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 'psyOld' in item[1]:\n",
" \n",
" dict1[k1]['psy_yangmiao_old'] = psy\n",
" if 'tcm' in item[1]:\n",
" \n",
" dict1[k1]['tcm'] = tcm\n",
" if 'spine' in item[1]:\n",
" for ii in range(25,23,-1):\n",
" \n",
" spine[ii] = spine[ii-1]\n",
" \n",
" spine[22] = 0\n",
" \n",
" \n",
" \n",
" dict1[k1]['spine'] = spine\n",
" #birth = date.fromisoformat(dict3[k1]['birth'].replace('/','-'))\n",
"\n",
" #days = (rq-birth).days \n",
" #dict1[k1]['age'] = int(days/365)\n",
" \n",
" dict1[k1]['rq'] = item[2].replace('/','-').split(' ')[0]\n",
"#print(dict1)\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "85d087e3-c469-409e-893b-a22789d73613",
@@ -1037,15 +1305,15 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 36,
"id": "7ee80847-2bc0-4cbe-9534-c5dcf97c2833",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-07T12:40:25.086716Z",
"iopub.status.busy": "2025-04-07T12:40:25.086178Z",
"iopub.status.idle": "2025-04-07T12:40:51.228212Z",
"shell.execute_reply": "2025-04-07T12:40:51.227012Z",
"shell.execute_reply.started": "2025-04-07T12:40:25.086666Z"
"iopub.execute_input": "2025-12-12T13:38:35.200844Z",
"iopub.status.busy": "2025-12-12T13:38:35.200220Z",
"iopub.status.idle": "2025-12-12T13:38:42.941941Z",
"shell.execute_reply": "2025-12-12T13:38:42.941270Z",
"shell.execute_reply.started": "2025-12-12T13:38:35.200787Z"
}
},
"outputs": [
@@ -1053,7 +1321,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"56\n"
"12\n"
]
}
],
@@ -1066,11 +1334,11 @@
"headers = {\n",
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
" }\n",
"filename = 'data/result_陈庄检测人员-2.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./东营陈庄2/'\n",
"file_path ='./油田老年大学年度体质复测/'\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=0\n",
"list2 = []\n",
@@ -1080,7 +1348,7 @@
" \n",
" id = str(k).rjust(4,\"0\")\n",
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
" mydata['title'] = '山东东营陈庄镇'\n",
" mydata['title'] = '油田老年大学年度体质复测'\n",
" mydata['subtitle'] = v['unit']\n",
" mydata['id'] = id\n",
" mydata['name'] = v['name']\n",
@@ -1090,7 +1358,15 @@
" mydata['gender'] = 'female'\n",
" \n",
" mydata['month'] = v['month']\n",
" mydata['fits'] = {}\n",
" survey_list = ['tcm','psy_yangmiao_old','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",
@@ -1100,7 +1376,8 @@
" 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",
" #if len(mydata['fits']) >2 : \n",
" if len(mydata['fits']) >2 or 'surveys' in mydata.keys():\n",
" list1.append(mydata)\n",
" list2.append([k,v['name']])\n",
" i+=1\n",
+27 -15
View File
@@ -2310,15 +2310,15 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "6f9768ce-2ef5-4253-9fc6-49dbdcf00a19",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-04T01:12:54.320249Z",
"iopub.status.busy": "2025-12-04T01:12:54.319633Z",
"iopub.status.idle": "2025-12-04T01:12:54.339019Z",
"shell.execute_reply": "2025-12-04T01:12:54.337721Z",
"shell.execute_reply.started": "2025-12-04T01:12:54.320195Z"
"iopub.execute_input": "2025-12-12T13:17:17.795264Z",
"iopub.status.busy": "2025-12-12T13:17:17.794719Z",
"iopub.status.idle": "2025-12-12T13:17:17.805357Z",
"shell.execute_reply": "2025-12-12T13:17:17.804292Z",
"shell.execute_reply.started": "2025-12-12T13:17:17.795214Z"
}
},
"outputs": [],
@@ -2672,23 +2672,35 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "9ecd3ad8-c8af-4f3e-90e5-1618fea905a4",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-04T01:13:55.931481Z",
"iopub.status.busy": "2025-12-04T01:13:55.930100Z",
"iopub.status.idle": "2025-12-04T01:13:55.996588Z",
"shell.execute_reply": "2025-12-04T01:13:55.996041Z",
"shell.execute_reply.started": "2025-12-04T01:13:55.931411Z"
"iopub.execute_input": "2025-12-12T13:46:10.803542Z",
"iopub.status.busy": "2025-12-12T13:46:10.802812Z",
"iopub.status.idle": "2025-12-12T13:46:10.973193Z",
"shell.execute_reply": "2025-12-12T13:46:10.972533Z",
"shell.execute_reply.started": "2025-12-12T13:46:10.803460Z"
}
},
"outputs": [],
"outputs": [
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 57\u001b[0m\n\u001b[1;32m 55\u001b[0m psy\u001b[38;5;241m=\u001b[39mv[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpsy_yangmiao_old\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 56\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m26\u001b[39m,\u001b[38;5;241m40\u001b[39m):\n\u001b[0;32m---> 57\u001b[0m new_valve \u001b[38;5;241m=\u001b[39m \u001b[43mpsy\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[1;32m 58\u001b[0m psy[i] \u001b[38;5;241m=\u001b[39m new_valve\n\u001b[1;32m 59\u001b[0m dict3 \u001b[38;5;241m=\u001b[39m {}\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"source": [
"import openpyxl\n",
"\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp']\n",
"filename = 'data/result_新疆油田采油工艺研究院2511.json'\n",
"filename = 'data/result_油田老年大学年度体质复测.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"data_list = []\n",
@@ -2770,7 +2782,7 @@
" list6.append('')\n",
" i+=1\n",
" data_list.append(list6)\n",
"filename = 'data/新疆油田采油工艺研究院体质检测明细表(2025年11月).xlsx'\n",
"filename = 'data/油田老年大学年度体质复测体质检测明细表(2025年11月).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '身高', '体重', 'bmi', '肺活量', '得分', '握力', '得分', '坐位体前屈', '得分', '纵跳', '得分', '俯卧撑', '得分', '单脚站立', '得分', '选择反应时', '得分', '台阶指数', '得分', '一分钟仰卧起坐', '得分', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀', '成就感', '愉快心理', '放松程度', '压力应对', '体力充沛', '情感充沛度', '颈椎', '胸椎', '腰椎', '骶尾椎']\n",
File diff suppressed because it is too large. Load diff
+293 -40
View File
@@ -991,17 +991,16 @@
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" code = int(sheet.cell(n, 2).value)\n",
" code = str(int(sheet.cell(n, 2).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, 6).value\n",
" \n",
" \n",
" dict1['unit'] = sheet.cell(n, 6).value \n",
" dict1['age'] = int(sheet.cell(n, 5).value)\n",
" dict1['symptoms'] = sheet.cell(n, 8).value\n",
" person[code] = dict1\n",
"filename = 'data/宁夏能化干预人员.json'\n",
"filename = 'data/宁夏能化高危风险干预人员.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print(len(person),'ok')"
@@ -1017,21 +1016,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "f60e8194-7ef6-49d8-8538-9b79f35bb64d",
"metadata": {},
"outputs": [],
"execution_count": 28,
"id": "7261e146-03f5-4943-8a3a-479d0e4a025d",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:50:57.787016Z",
"iopub.status.busy": "2025-12-09T09:50:57.786321Z",
"iopub.status.idle": "2025-12-09T09:50:57.827675Z",
"shell.execute_reply": "2025-12-09T09:50:57.827125Z",
"shell.execute_reply.started": "2025-12-09T09:50:57.786958Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"204 ok\n"
]
}
],
"source": [
"import json\n",
"##### import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"\n",
"filename = 'data/宁夏能化高危风险干预人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
" \n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251009.csv'\n",
"filename = 'data/sql_20251209.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
@@ -1041,10 +1059,10 @@
"nn = 0\n",
"for item in list1:\n",
" dict2 = {}\n",
" name = item[1]\n",
" phone = str(item[2])[2:]\n",
" birth = str(item[4])\n",
" content = json.loads(item[0])\n",
" name = item[2]\n",
" phone = str(item[3])[2:]\n",
" birth = str(item[5])\n",
" content = json.loads(item[1])\n",
" tcm = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
@@ -1055,7 +1073,8 @@
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" \n",
" code = int(dict2['code'])\n",
" code = str(int(dict2['code']))\n",
" if code in dict3.keys():\n",
" dict1.setdefault(code,{})\n",
" dict1[code]['name'] = dict2['name']\n",
" if dict2['gender'] == 'm':\n",
@@ -1064,17 +1083,167 @@
" dict1[code]['sex'] = '女'\n",
" dict1[code]['birth'] = str(item[4])\n",
" dict1[code]['unit'] = dict2['unit']\n",
" dict1[code]['age'] = dict3[code]['age']\n",
" dict1[code]['phone'] = phone\n",
" dict1[code]['waist'] = dict2['waist']\n",
" dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm\n",
"filename = 'data/survey_宁夏能化干预人员.json'\n",
"filename = 'data/survey_宁夏能化高危风险干预人员.json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1),'ok')"
]
},
{
"cell_type": "markdown",
"id": "c4486c37-d1a4-460f-9997-6405c51b805c",
"metadata": {},
"source": [
"## 常用参数及自定义函数"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "34cb26d7-cd7b-4ad5-bb7b-71cfcce16c24",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:51:13.116856Z",
"iopub.status.busy": "2025-12-09T09:51:13.116051Z",
"iopub.status.idle": "2025-12-09T09:51:13.133080Z",
"shell.execute_reply": "2025-12-09T09:51:13.132231Z",
"shell.execute_reply.started": "2025-12-09T09:51:13.116787Z"
}
},
"outputs": [],
"source": [
"import json\n",
"\n",
"questions = [[1],[-1, 2],[-1, 2],[-1, 8],[-1, 3],[1],[-1],[-1, 7],[2],[2],[2],[2, 3],[2],[2],[3],[3],[3],[3],[3],[4],[4],[4],[4],[4],[4],[4],[4],[5], [5],[5],[5],[5],[5],[5],[5],[6],[6],[6],[6],[6],[6],[7],[7],[7],[7],[7],[7],[8],[8],[8],[8],[8],[8],[9],[9],[9],[9],[9],[9],[9]]\n",
"\n",
"kinds = ['平和','气虚','阳虚','阴虚','痰湿','湿热','血瘀','气郁','特禀']\n",
"\n",
"def tcm_calc(arr):\n",
" qa = [8, 8, 7, 8, 8, 6, 7, 7, 7]\n",
" s = [0] * 9\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]]\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",
" ]"
]
},
{
"cell_type": "markdown",
"id": "f0bae0b0-2edb-4d3e-a2ae-154d23fea48b",
"metadata": {},
"source": [
"## 导出问卷监测情况表"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "d78c0f3f-cd1a-4c6c-9f5b-b1b874a95fe3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:52:01.947920Z",
"iopub.status.busy": "2025-12-09T09:52:01.947633Z",
"iopub.status.idle": "2025-12-09T09:52:01.999096Z",
"shell.execute_reply": "2025-12-09T09:52:01.998620Z",
"shell.execute_reply.started": "2025-12-09T09:52:01.947897Z"
}
},
"outputs": [],
"source": [
"import openpyxl\n",
"\n",
"\n",
"filename = 'data/survey_宁夏能化高危风险干预人员.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",
" list6.append(v['waist'])\n",
" list6.append(v['hip'])\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",
" \n",
" data_list.append(list6)\n",
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251209).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '腰围', '臀围', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
"sheet.append(title)\n",
"for row in data_list:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) "
]
},
{
"cell_type": "markdown",
"id": "93a9b31e-49ea-45cd-bb0b-5c3db19bbb54",
@@ -1121,6 +1290,14 @@
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "4b0cd38c-d14c-48e7-83cb-8afc7665b060",
"metadata": {},
"source": [
"# 体重管理系统"
]
},
{
"cell_type": "markdown",
"id": "98de56de-95fe-4f21-be25-896fb1bda175",
@@ -1131,9 +1308,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:21.978932Z",
"iopub.status.busy": "2025-12-14T23:43:21.978409Z",
"iopub.status.idle": "2025-12-14T23:43:22.273147Z",
"shell.execute_reply": "2025-12-14T23:43:22.272647Z",
"shell.execute_reply.started": "2025-12-14T23:43:21.978883Z"
}
},
"outputs": [],
"source": [
"import json\n",
@@ -1142,7 +1327,7 @@
"\n",
"title = []\n",
"\n",
"filename = 'data/surveys_records_2025-12-07.json'\n",
"filename = 'data/surveys_records_2025-12-15.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1167,7 +1352,7 @@
" \n",
" list1.append(list2)\n",
"all_title = ['id', 'date_created','name', 'gender', 'birth', 'code', 'unit', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
"filename = 'data/宁夏能化干预人员问卷(20251207).xlsx'\n",
"filename = 'data/宁夏能化干预人员问卷(20251215).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(all_title)\n",
@@ -1203,10 +1388,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:35.251673Z",
"iopub.status.busy": "2025-12-14T23:43:35.251057Z",
"iopub.status.idle": "2025-12-14T23:43:35.339896Z",
"shell.execute_reply": "2025-12-14T23:43:35.339186Z",
"shell.execute_reply.started": "2025-12-14T23:43:35.251623Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('梁正武', '男', '电气仪表中心', '1984-05-01', '02018801', 1)\n",
"('张艳萍', '女', '公用工程运行部', '1978-09-01', '02020548', 1)\n",
"('叶云飞', '男', '公用工程运行部', '1985-11-01', '02019460', 1)\n",
"('李效龙', '男', 'BDO运行部', '1987-09-01', '0201968', 1)\n",
"('何富来', '男', '宁夏能化', '1983-03-01', '02019507', 1)\n",
"('马荣', '女', '公用工程运行部', '1984-03-01', '02020205', 1)\n",
"('刘永清', '男', '热电运行部', '1968-10-01', '02019958', 1)\n",
"('马学锋', '男', '热电运行部', '1974-12-01', '02020025', 1)\n",
"('段庆霖', '男', '热电运行部', '1990-02-01', '02020062', 1)\n",
"('周卫星', '男', '热电运行部', '1970-05-01', '02019986', 1)\n",
"('姚户昌', '男', '热电运行部', '1970-12-01', '02019968', 1)\n",
"('姜德溪', '男', '热电运行部', '1970-01-01', '2019970', 1)\n",
"('陈海宝', '男', '乙炔运行部', '1990-07-01', '02019346', 1)\n",
"('丁红忠', '男', '热电运行部', '1990-09-01', '02020160', 1)\n",
"('孙柏', '男', '环保建材运行部', '1982-03-01', '02020446', 1)\n",
"('黄博', '男', '物资采购中心', '1995-12-01', '03391681', 1)\n",
"('王正东', '男', '热电运行部', '1990-01-01', '03428864', 1)\n",
"17\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
@@ -1219,7 +1437,7 @@
" password=\"songyi\"\n",
")\n",
"cur = conn.cursor()\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251207).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"org_id = 1\n",
@@ -1245,8 +1463,15 @@
" else:\n",
" dict1['sex'] = '女'\n",
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
" if len(birth)==7:\n",
" dict1['birth'] = birth+'-01'\n",
" \n",
" if len(birth)<10:\n",
" nian = birth.split('-')[0]\n",
" yue = birth.split('-')[1].rjust(2,'0')\n",
" if len(birth.split('-')[0]) ==3:\n",
" ri = birth.split('-')[2].rjust(2,'0')\n",
" else:\n",
" ri = '01' \n",
" dict1['birth'] = nian+'-'+ yue + '-'+ ri\n",
" else:\n",
" dict1['birth'] = birth\n",
" dict1['unit'] = sheet.cell(n, 7).value\n",
@@ -1346,15 +1571,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
"metadata": {},
"outputs": [],
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:56.303850Z",
"iopub.status.busy": "2025-12-14T23:43:56.303555Z",
"iopub.status.idle": "2025-12-14T23:43:56.413335Z",
"shell.execute_reply": "2025-12-14T23:43:56.412897Z",
"shell.execute_reply.started": "2025-12-14T23:43:56.303825Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"108 ok\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251207).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
@@ -1365,15 +1606,19 @@
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
" if len(birth)==7:\n",
" dict1['birth'] = birth+'-01'\n",
" if len(birth)<10:\n",
" nian = birth.split('-')[0]\n",
" yue = birth.split('-')[1].rjust(2,'0')\n",
" if len(birth.split('-')[0]) ==3:\n",
" ri = birth.split('-')[2].rjust(2,'0')\n",
" else:\n",
" dict1['birth'] = birth\n",
" ri = '01' \n",
" dict1['birth'] = nian+'-'+ yue + '-'+ ri\n",
" dict1['unit'] = sheet.cell(n, 7).value\n",
" person[code] = dict1\n",
"#print(person)\n",
"\n",
"filename = 'data/surveys_records_2025-12-07.json'\n",
"filename = 'data/surveys_records_2025-12-10.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1431,7 +1676,7 @@
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
" if code in person.keys():\n",
" person[code][rq] = dict2\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251207).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
@@ -1449,9 +1694,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
"metadata": {},
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:44:12.601625Z",
"iopub.status.busy": "2025-12-14T23:44:12.600884Z",
"iopub.status.idle": "2025-12-14T23:44:12.741676Z",
"shell.execute_reply": "2025-12-14T23:44:12.741060Z",
"shell.execute_reply.started": "2025-12-14T23:44:12.601562Z"
}
},
"outputs": [],
"source": [
"import json\n",
@@ -1468,7 +1721,7 @@
"cur = conn.cursor()\n",
"event_id = 1\n",
"org_id = 1\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251207).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = ['name','sex','birth','unit']\n",
@@ -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": []
+40 -2
View File
@@ -1456,7 +1456,7 @@
],
"source": [
"import pdfplumber\n",
"name = 'file/01730823-邵希强.pdf'\n",
"name = 'file/03499391-宋文路.pdf'\n",
"pdf = pdfplumber.open(name)\n",
"text = pdf.pages[1].extract_text()#######页码从0开始计数\n",
"#print(text)\n",
@@ -1474,8 +1474,46 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 35,
"id": "ac034bf9-cba9-4a72-87ba-d77721cc7097",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-08T01:54:24.900658Z",
"iopub.status.busy": "2025-12-08T01:54:24.900121Z",
"iopub.status.idle": "2025-12-08T01:54:24.960757Z",
"shell.execute_reply": "2025-12-08T01:54:24.960174Z",
"shell.execute_reply.started": "2025-12-08T01:54:24.900608Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['北体乾元健康管理中心', '姓名 宋文路', '中石化(天津)石油化工 编号 03499391', '有限公司 性别 男', '年龄 26', '国民体质检测结果与健康处方', '握力', '纵跳 身高体重指数', '选择反应时', '测试标准 国民体质测定标准', '身高体重指数 33.68 20分', '握力 38.6 千克 55分', '纵跳 22.8 厘米 30分', '选择反应时 0.466 秒 90分', '腰臀比 0.95 正常', '请注意:以上测试项目及格线为60分。列表中红色项目需重点关注,建议在专家指导下进行科学锻炼,', '减少潜在的运动风险。', '感谢您完成测试,因为您未完成肺活量、台阶指数、俯卧撑、1分钟仰卧起坐、坐位体前屈、闭眼单脚', '站立,无法以《国民体质测定标准》综合评级,改为以平均分作为综合评级参考。您的平均得分为53,等级', '为四级(不合格),仅供参考。', '北体乾元体质监测报告']\n",
"感谢您完成测试,因为您未完成肺活量、台阶指数、俯卧撑、1分钟仰卧起坐、坐位体前屈、闭眼单脚站立,无法以《国民体质测定标准》综合评级,改为以平均分作为综合评级参考。您的平均得分为53,等级为四级(不合格),仅供参考。北体乾元体质监测报告\n"
]
}
],
"source": [
"import pdfplumber\n",
"name = 'file/03499391-宋文路.pdf'\n",
"pdf = pdfplumber.open(name)\n",
"text = pdf.pages[1].extract_text()#######页码从0开始计数\n",
"#print(text)\n",
"list1 = text.split('\\n')\n",
"print(list1)\n",
"for item in list1:\n",
" if '感谢您完成测试' in item:\n",
" i = list1.index(item)\n",
" ss = ''.join(list1[i:])\n",
" print(ss)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "41177ae9-d7ae-45c2-90b5-94578699215e",
"metadata": {},
"outputs": [],
"source": []