This commit is contained in:
512song committed 2024-12-24 22:56:49 +08:00
1 parent 82372feb99
commit c801f150ae
6 files changed
+1787 -626

No files matched your search

+324 -167
View File
@@ -2309,26 +2309,10 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"id": "610b20f3-9fd8-46fc-b8ee-d48c4c854289",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-09T09:22:38.802119Z",
"iopub.status.busy": "2024-12-09T09:22:38.801372Z",
"iopub.status.idle": "2024-12-09T09:22:38.835995Z",
"shell.execute_reply": "2024-12-09T09:22:38.835477Z",
"shell.execute_reply.started": "2024-12-09T09:22:38.802047Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import openpyxl\n",
"import json\n",
@@ -2368,26 +2352,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a6dc8ae7-5a51-4eb1-954e-19c17b6062cd",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-05T01:26:00.236419Z",
"iopub.status.busy": "2024-12-05T01:26:00.235845Z",
"iopub.status.idle": "2024-12-05T01:26:00.282366Z",
"shell.execute_reply": "2024-12-05T01:26:00.281825Z",
"shell.execute_reply.started": "2024-12-05T01:26:00.236362Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
@@ -2416,27 +2384,10 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": null,
"id": "1e2d586e-6ff5-4fd1-a909-278d23e54561",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-09T09:26:07.189575Z",
"iopub.status.busy": "2024-12-09T09:26:07.187969Z",
"iopub.status.idle": "2024-12-09T09:26:07.219642Z",
"shell.execute_reply": "2024-12-09T09:26:07.219013Z",
"shell.execute_reply.started": "2024-12-09T09:26:07.189495Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"207\n",
"207\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -2486,27 +2437,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "0cad0490-5199-4ca3-bf6f-a206829d702e",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:57:46.853287Z",
"iopub.status.busy": "2024-12-11T06:57:46.852519Z",
"iopub.status.idle": "2024-12-11T06:57:46.874391Z",
"shell.execute_reply": "2024-12-11T06:57:46.873811Z",
"shell.execute_reply.started": "2024-12-11T06:57:46.853199Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\n",
"78\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -2556,27 +2490,10 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "dd681c34-dba9-434b-9cd3-ed12fefcce0f",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T07:10:57.109817Z",
"iopub.status.busy": "2024-12-11T07:10:57.109051Z",
"iopub.status.idle": "2024-12-11T07:10:57.134829Z",
"shell.execute_reply": "2024-12-11T07:10:57.134208Z",
"shell.execute_reply.started": "2024-12-11T07:10:57.109746Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"78\n",
"78\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import datetime\n",
@@ -2669,17 +2586,9 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"id": "64c6e1e3-801c-4573-b78f-5a9e842597a9",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-09T09:23:41.690512Z",
"iopub.status.busy": "2024-12-09T09:23:41.689765Z",
"iopub.status.idle": "2024-12-09T09:23:41.726298Z",
"shell.execute_reply": "2024-12-09T09:23:41.725869Z",
"shell.execute_reply.started": "2024-12-09T09:23:41.690440Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -2732,17 +2641,9 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"id": "933f3eb1-8463-4782-ae45-8a1628abbb2b",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-09T09:29:03.983785Z",
"iopub.status.busy": "2024-12-09T09:29:03.983528Z",
"iopub.status.idle": "2024-12-09T09:29:04.043514Z",
"shell.execute_reply": "2024-12-09T09:29:04.042868Z",
"shell.execute_reply.started": "2024-12-09T09:29:03.983761Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"import json\n",
@@ -2798,40 +2699,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "dd7557bf-6f1e-4d01-aa93-5a4ad46a57a5",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:12:49.795632Z",
"iopub.status.busy": "2024-12-11T06:12:49.794818Z",
"iopub.status.idle": "2024-12-11T06:12:49.967842Z",
"shell.execute_reply": "2024-12-11T06:12:49.967393Z",
"shell.execute_reply.started": "2024-12-11T06:12:49.795561Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3437581 李成伟\n",
"3526193 李可\n",
"3464205 胡雨丹\n",
"1010 邱亮\n",
"1012 吴磊\n",
"3464081 刘权\n",
"3125625 宋霰\n",
"1020 贾俊\n",
"1022 徐敬\n",
"1023 彭一夫\n",
"1024 刘至清\n",
"1053 刘志刚\n",
"1058 杨红\n",
"1069 李鑫\n",
"1144 黄英杰\n"
]
}
],
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
@@ -2857,17 +2728,25 @@
" print(k,v['name'])"
]
},
{
"cell_type": "markdown",
"id": "26582cc3-4675-4f4f-8c22-4fc499e70481",
"metadata": {},
"source": [
"## 汇总三组人员"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ded0ac64-9ba2-4d64-9617-e0961b437d4e",
"execution_count": 25,
"id": "952bbc05-afee-4247-810b-49f37b7fe939",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-11T06:33:09.011061Z",
"iopub.status.busy": "2024-12-11T06:33:09.010467Z",
"iopub.status.idle": "2024-12-11T06:33:09.030379Z",
"shell.execute_reply": "2024-12-11T06:33:09.029760Z",
"shell.execute_reply.started": "2024-12-11T06:33:09.011010Z"
"iopub.execute_input": "2024-12-12T07:15:24.337351Z",
"iopub.status.busy": "2024-12-12T07:15:24.336594Z",
"iopub.status.idle": "2024-12-12T07:15:24.363321Z",
"shell.execute_reply": "2024-12-12T07:15:24.362508Z",
"shell.execute_reply.started": "2024-12-12T07:15:24.337276Z"
}
},
"outputs": [
@@ -2875,15 +2754,48 @@
"name": "stdout",
"output_type": "stream",
"text": [
"29\n",
"29\n"
"305\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"\n",
"filename = 'data/result_长炼医院人员2024(0417前).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/result_长炼医院人员2024(湖南青年).json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"filename = 'data/result_长炼医院人员2024(非湖南青年).json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl) \n",
"\n",
"for k, v in dict2.items():\n",
" dict1[k] = v\n",
"\n",
"for k, v in dict3.items():\n",
" dict1[k] = v\n",
"\n",
"filename = 'data/result_长炼医院人员2024(汇总).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) \n",
"print(len(dict1))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ded0ac64-9ba2-4d64-9617-e0961b437d4e",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"\n",
"filename = '../item1.json'\n",
"item = {}\n",
@@ -2892,6 +2804,19 @@
" dict1 = json.load(fl) \n",
"for k,v in dict1.items():\n",
" item[k] = v\n",
"item['1']['en'] = 'lung'\n",
"item['2']['en'] = 'grip'\n",
"item['3']['en'] = 'flexion'\n",
"item['4']['en'] = 'jump'\n",
"item['5']['en'] = 'pushup'\n",
"item['6']['en'] = 'balance'\n",
"item['7']['en'] = 'reaction'\n",
"item['8']['en'] = 'step'\n",
"item['9']['en'] = 'situp'\n",
"item['10']['en'] = 'height'\n",
"item['11']['en'] = 'weight'\n",
"\n",
"\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
@@ -2909,16 +2834,35 @@
"#print(list1)\n",
"for result in list1:\n",
" user = str(result[2])\n",
" if user in dict1.keys(): \n",
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
" if user in dict1.keys():\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]['sex'] = dict1[user]['sex']\n",
" if dict1[user]['sex'] == '男':\n",
" l_xm = ['weight','height','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
" else:\n",
" l_xm = ['weight','height','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
" re_ta[user]['unit'] = dict1[user]['unit']\n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
" #birth = date.fromisoformat(dict1[user]['birth'])\n",
" #nian = int(birth[0].strip())\n",
" #yue = int(birth[1].strip())\n",
" #ri = int(birth[2].strip())\n",
" #print(k,nian,yue,ri)\n",
" item_name = item[m_item]['en'] \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[6]\n",
"\n",
"\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[4])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
"print(len(re_ta))\n",
"filename = 'data/result_长炼医院人员2024(0417前).json'\n",
"\n",
@@ -2933,6 +2877,219 @@
"id": "7583ad54-3e66-4ef8-ae51-f01eda2bf647",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import time\n",
"\n",
"filename = '../item1.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl) \n",
"for k,v in dict3.items():\n",
" item[k] = v\n",
"item['1']['en'] = 'lung'\n",
"item['2']['en'] = 'grip'\n",
"item['3']['en'] = 'flexion'\n",
"item['4']['en'] = 'jump'\n",
"item['5']['en'] = 'pushup'\n",
"item['6']['en'] = 'balance'\n",
"item['7']['en'] = 'reaction'\n",
"item['8']['en'] = 'step'\n",
"item['9']['en'] = 'situp'\n",
"item['10']['en'] = 'height'\n",
"item['11']['en'] = 'weight'\n",
"\n",
"filename = 'data/体质检测标准 (1).json' \n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"\n",
"\n",
"def cal_score(data1):\n",
" #data = {'name':'张三','sex':'M','age':37,'item':'StepExperiment','result':46} \n",
" person = dict1['person']\n",
" criteria = dict1['criteria']\n",
" if data1['age'] >59:\n",
" data1['age'] = 59\n",
" if data1['age'] <20:\n",
" data1['age'] = 20\n",
" info = data1['sex']+str(data1['age'])\n",
" bz = person[info]\n",
" mx = criteria[bz][data1['item']]\n",
" result = data1['result'] \n",
" if data1['item'] == 'reaction':\n",
" for bz1 in mx:\n",
" if result > bz1:\n",
" #print(bz1)\n",
" score = mx.index(bz1,0)\n",
" break\n",
" else:\n",
" score = 5\n",
" else:\n",
" for bz1 in mx:\n",
" if result < bz1:\n",
" #print(bz1)\n",
" score = mx.index(bz1,0)\n",
" break\n",
" else:\n",
" score = 5\n",
" return(score)\n",
"filename = 'data/体质检测标准_BMI.json'\n",
"with open(filename,'r') as fl:\n",
" dict4 = json.load(fl) \n",
" \n",
"def cal_bmi(data1):\n",
" # data = {'name':'张三','sex':'M','age':37,'item':'HeightWeight','result':'177.7,97.0'}\n",
" person = dict4['person']\n",
" criteria = dict4['criteria']\n",
" if data1['age'] > 59:\n",
" data1['age'] = 59\n",
" if data1['age'] <20:\n",
" data1['age'] = 20\n",
" info = data1['sex']+str(data1['age'])\n",
" bz = person[info]\n",
" #print(bz)\n",
" result = data1['result']\n",
" #print(data1['code'],result)\n",
" height = int(float(result.split(',')[0]))\n",
" weight = float(result.split(',')[1])\n",
" if str(height) not in criteria[bz]:\n",
" score = 1\n",
" else: \n",
" mx = criteria[bz][str(height)]\n",
" if weight < mx[0]:\n",
" score = 1\n",
" elif weight < mx[1]:\n",
" score = 3\n",
" elif weight < mx[2]:\n",
" score = 5 \n",
" elif weight <= mx[3]:\n",
" score = 3 \n",
" elif weight > mx[3]:\n",
" score = 1\n",
" return score\n",
" \n",
" \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_长炼医院人员2024(0417前).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 'height' in v.keys() and 'weight' in v.keys():\n",
" bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\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'] = 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",
" dict2[k][item_en]['score'] = cal_score(data1)\n",
" #print(k,v[item_en]['成绩'],cal_score(data1))\n",
"filename = f'data/result_长炼医院人员2024(0417前).json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "dda61f0c-d789-491e-a5b3-c15122bc35be",
"metadata": {
"execution": {
"iopub.execute_input": "2024-12-12T07:17:38.512812Z",
"iopub.status.busy": "2024-12-12T07:17:38.512027Z",
"iopub.status.idle": "2024-12-12T07:20:00.155132Z",
"shell.execute_reply": "2024-12-12T07:20:00.154082Z",
"shell.execute_reply.started": "2024-12-12T07:17:38.512739Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"302\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_长炼医院人员2024(汇总).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
"file_path ='./长炼医院2024/'\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(7,\"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": "9415e7a4-0d4c-4d7e-bdd0-4ec7be9006fb",
"metadata": {},
"outputs": [],
"source": []
}
],