This commit is contained in:
512song committed 2023-12-03 15:04:51 +08:00
1 parent b33bbbd408
commit de6a5be703
3 files changed
+1026 -71

No files matched your search

+351 -62
View File
@@ -506,47 +506,6 @@
"print('ok!') " "print('ok!') "
] ]
}, },
{
"cell_type": "markdown",
"id": "cf8f168e-4161-4fbb-bf5f-f9d1cb9bbb6f",
"metadata": {},
"source": [
"### 生成报告清单"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f20224aa-2131-473d-a0ec-0743482ed58e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/result_天津231017.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"dict2 = {}\n",
"list2 = []\n",
"i= 1\n",
"p= 1\n",
"for k, v in dict1.items():\n",
" list2.append(k)\n",
" i+=1\n",
" if i>200:\n",
" dict2[p] = list2\n",
" p+=1\n",
" i = 1\n",
" list2 = []\n",
"dict2[p] = list2\n",
"filename = f'data/报告清单.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "ceef0742-f62a-4a7d-b0d5-be7ae7abb741", "id": "ceef0742-f62a-4a7d-b0d5-be7ae7abb741",
@@ -640,6 +599,130 @@
"print(i)" "print(i)"
] ]
}, },
{
"cell_type": "markdown",
"id": "4642faf7-52bf-40e9-9af3-7555d4eef10b",
"metadata": {},
"source": [
"## 体测报告按部门分类"
]
},
{
"cell_type": "code",
"execution_count": 91,
"id": "d913a531-51b3-4795-adc3-f4fc858d7401",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-03T05:44:37.781259Z",
"iopub.status.busy": "2023-12-03T05:44:37.780816Z",
"iopub.status.idle": "2023-12-03T05:44:37.997978Z",
"shell.execute_reply": "2023-12-03T05:44:37.997477Z",
"shell.execute_reply.started": "2023-12-03T05:44:37.781224Z"
},
"tags": []
},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import glob\n",
"from pathlib import Path\n",
"\n",
"fi_path = '/home/songyi/pdf-typescript/北海炼化2023'\n",
"new_path = 'file/北海炼化2023'\n",
"old = []\n",
"dict2 = {}\n",
"\n",
"filename = 'data/北海炼化2023年.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
"for fn in fls:\n",
" fi_name =Path(fn).stem.split('-')[0]\n",
" code = int(fi_name)\n",
" unit_path = Path(new_path,dict1[str(code)]['unit'])\n",
" unit_path.mkdir(parents = True, exist_ok = True)\n",
" n_name = Path(unit_path,Path(fn).stem+'.pdf')\n",
" if not os.path.exists(n_name):\n",
" shutil.copyfile(fn,n_name)"
]
},
{
"cell_type": "markdown",
"id": "1e6ece92-7845-49df-a84c-88a2befee570",
"metadata": {},
"source": [
"## 生成体测报告打印明细表"
]
},
{
"cell_type": "code",
"execution_count": 93,
"id": "02319955-7fb6-4791-ae45-55b03bdadd54",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-03T05:54:39.061703Z",
"iopub.status.busy": "2023-12-03T05:54:39.061244Z",
"iopub.status.idle": "2023-12-03T05:54:39.128729Z",
"shell.execute_reply": "2023-12-03T05:54:39.128308Z",
"shell.execute_reply.started": "2023-12-03T05:54:39.061649Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[['0325', '邱建明', '男', '炼油一部'], ['0175', '季彩平', '女', '检验计量中心'], ['0818', '刘潮辉', '男', '新上岗'], ['0396', '邓桂雄', '男', '炼油一部'], ['0780', '邓施艳', '女', '财务资产部'], ['0372', '李哲宇', '男', '炼油一部'], ['0340', '张宏智', '男', '炼油一部'], ['0403', '卫恒', '男', '炼油一部'], ['0090', '黄鑫', '女', '炼油三部'], ['0082', '董澄林', '男', '炼油三部'], ['0817', '封帆', '女', '新上岗'], ['0807', '张惜光', '男', '行政事务中心'], ['0433', '李晋渊', '男', '储运部'], ['0717', '杨梦春', '男', '生产技术部'], ['0386', '盛国娟', '女', '炼油一部'], ['0313', '李志永', '男', '炼油一部'], ['0561', '杨微', '女', '炼油二部'], ['0473', '王晓甫', '男', '储运部'], ['0643', '王梓润', '男', '炼油二部'], ['0453', '李志雄', '男', '储运部'], ['0010', '蓝志君', '男', '炼油三部'], ['0747', '吴文强', '男', '设备工程部'], ['0256', '马祥光', '男', '电气仪表中心'], ['0625', '郭卫富', '男', '炼油二部'], ['0475', '刘利', '男', '储运部'], ['0283', '魏建民', '男', '炼油一部'], ['0134', '赵小丽', '女', '公用工程部'], ['0057', '苗光浩', '男', '炼油三部'], ['0162', '李林', '男', '检验计量中心'], ['0092', '刘鸿亮', '男', '炼油三部'], ['0614', '张金斗', '男', '炼油二部'], ['0452', '江荣明', '男', '储运部'], ['0437', '张琪静', '女', '储运部'], ['0239', '陈孔兰', '女', '检验计量中心'], ['0622', '陆锡健', '男', '炼油二部'], ['0595', '李孩峄', '男', '炼油二部'], ['0246', '苏晓东', '男', '电气仪表中心'], ['0532', '王威', '男', '炼油二部'], ['0266', '刘建功', '男', '电气仪表中心'], ['0320', '涂莉', '女', '炼油一部'], ['0091', '冼冠宇', '男', '炼油三部'], ['0062', '刘天宇', '男', '炼油三部'], ['0432', '梁波', '男', '储运部'], ['0339', '王继政', '男', '炼油一部'], ['0683', '于洋', '女', '党群工作部'], ['0581', '王建鑫', '男', '炼油二部'], ['0011', '刘前程', '男', '炼油三部'], ['0610', '李忠', '男', '炼油二部'], ['0375', '聂珊珊', '女', '炼油一部'], ['0118', '苏远雄', '男', '公用工程部'], ['0801', '杨敏', '女', '物资采购中心'], ['0042', '赵欣野', '男', '炼油三部'], ['0496', '李晗', '男', '储运部'], ['0308', '田铮铮', '男', '炼油一部'], ['0772', '杨坤妮', '女', '安全环保部'], ['0400', '王海林', '男', '炼油一部'], ['0441', '郑志强', '男', '储运部'], ['0594', '陈达', '男', '炼油二部'], ['0563', '朱鑫', '男', '炼油二部'], ['0334', '黎镇杰', '男', '炼油一部'], ['0781', '文星', '男', '财务资产部'], ['0307', '黄春湖', '女', '炼油一部'], ['0686', '黄洁', '女', '党委组织部'], ['0564', '符龙', '男', '炼油二部'], ['0401', '陈福培', '男', '炼油一部'], ['0371', '张中升', '男', '炼油一部'], ['0109', '李红武', '男', '公用工程部'], ['0569', '张健尧', '男', '炼油二部'], ['0820', '苏铭', '男', '新上岗'], ['0815', '杨尊', '男', '新上岗'], ['0124', '曹炳锋', '男', '公用工程部'], ['0526', '吴德立', '男', '炼油二部'], ['0707', '徐业卫', '女', '发展计划部'], ['0143', '崔路巧', '男', '公用工程部'], ['0247', '许俊雄', '男', '电气仪表中心'], ['0830', '张原', '男', '新上岗'], ['0618', '王增利', '男', '炼油二部'], ['0600', '刘业宇', '男', '炼油二部'], ['0766', '翟璟峰', '男', '安全环保部'], ['0637', '阎千兵', '男', '炼油二部'], ['0730', '莫有先', '男', '生产技术部'], ['0026', '刘志', '男', '炼油三部'], ['0423', '罗海', '男', '储运部'], ['0348', '黎福营', '男', '炼油一部'], ['0177', '张健', '女', '检验计量中心'], ['0218', '杨植文', '男', '检验计量中心'], ['0560', '张健', '男', '炼油二部'], ['0367', '冯福', '男', '炼油一部'], ['0306', '杨水珍', '女', '炼油一部'], ['0787', '李建英', '女', '财务资产部'], ['0330', '王鹏', '男', '炼油一部'], ['0612', '默鑫晔', '男', '炼油二部'], ['0557', '梁本康', '男', '炼油二部'], ['0052', '张鹏', '男', '炼油三部'], ['0087', '张仕尧', '男', '炼油三部'], ['0216', '宁碧玉', '女', '检验计量中心'], ['0617', '张升坚', '男', '炼油二部'], ['0501', '谭力允', '男', '储运部'], ['0756', '文鹏', '男', '设备工程部'], ['0504', '李扩生', '男', '储运部'], ['0718', '谭德', '男', '生产技术部'], ['0466', '黄钰智', '男', '储运部'], ['0567', '王勇', '男', '炼油二部'], ['0763', '王健', '男', '安全环保部'], ['0095', '韦增铝', '男', '炼油三部'], ['0611', '韦汉团', '男', '炼油二部'], ['0314', '柏可军', '男', '炼油一部'], ['0506', '陆进生', '男', '储运部'], ['0085', '叶广兵', '男', '炼油三部'], [Line truncated
"ok\n"
]
}
],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import glob\n",
"from pathlib import Path\n",
"import openpyxl\n",
"\n",
"fi_path = '/home/songyi/pdf-typescript/北海炼化2023'\n",
"\n",
"filename = 'data/北海炼化2023年.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
"list1 = []\n",
"title = ['测试编号','姓名','性别','部门']\n",
"for fn in fls:\n",
" list2 = []\n",
" fi_name =Path(fn).stem.split('-')[0] \n",
" code = int(fi_name)\n",
" sex = dict1[str(code)]['sex']\n",
" unit = dict1[str(code)]['unit']\n",
" list2 = [fi_name,Path(fn).stem.split('-')[1],sex,unit]\n",
" \n",
" list1.append(list2)\n",
"\n",
"filename = 'data/北海炼化体测报告打印明细表.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename) \n",
"print('ok')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "849ccf0c-374c-4915-98ae-78156203ed59",
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "732161bb-98f2-4861-ab66-7a374678bcd8", "id": "732161bb-98f2-4861-ab66-7a374678bcd8",
@@ -1325,15 +1408,32 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 80,
"id": "63edd636-f034-4aa6-8575-63d5cdb84adb", "id": "63edd636-f034-4aa6-8575-63d5cdb84adb",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:38:38.431850Z",
"iopub.status.busy": "2023-12-02T09:38:38.431525Z",
"iopub.status.idle": "2023-12-02T09:38:38.446189Z",
"shell.execute_reply": "2023-12-02T09:38:38.445802Z",
"shell.execute_reply.started": "2023-12-02T09:38:38.431810Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"平均成绩:2.8593分,男性:327人\n",
"平均成绩:3.1506分,女性:77人\n",
"平均成绩:2.9148分,总体:404人\n"
]
}
],
"source": [ "source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"\n", "filename = 'data/data_长炼医院.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"i = 1\n", "i = 1\n",
@@ -1367,18 +1467,38 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 81,
"id": "1b4a3f02-9b2e-41fc-ac6c-8163907a07f1", "id": "1b4a3f02-9b2e-41fc-ac6c-8163907a07f1",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:38:42.982840Z",
"iopub.status.busy": "2023-12-02T09:38:42.982381Z",
"iopub.status.idle": "2023-12-02T09:38:43.037289Z",
"shell.execute_reply": "2023-12-02T09:38:43.036187Z",
"shell.execute_reply.started": "2023-12-02T09:38:42.982802Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0~255分人数:92人,男性:84人,女性:8人\n",
"256~332分人数:217人,男性:178人,女性:39人\n",
"333~367分人数:72人,男性:50人,女性:22人\n",
"368~500分人数:23人,男性:15人,女性:8人\n",
"404\n",
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n", "\n",
"filename = 'data/data_北海炼化2023.json'\n", "filename = 'data/data_长炼医院.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"dict2 = {}\n", "dict2 = {}\n",
@@ -1418,12 +1538,34 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 82,
"id": "2d661ca6-6129-4da1-ac25-51d0156babb2", "id": "2d661ca6-6129-4da1-ac25-51d0156babb2",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:38:46.862847Z",
"iopub.status.busy": "2023-12-02T09:38:46.862403Z",
"iopub.status.idle": "2023-12-02T09:38:46.885423Z",
"shell.execute_reply": "2023-12-02T09:38:46.884184Z",
"shell.execute_reply.started": "2023-12-02T09:38:46.862811Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20-24 {'合格': 11, '不合格': 4, '良好': 2, '优秀': 1}\n",
"25-29 {'不合格': 0, '合格': 2, '良好': 3, '优秀': 1}\n",
"30-34 {'合格': 3, '不合格': 0, '良好': 1, '优秀': 0}\n",
"35-39 {'合格': 1, '不合格': 0, '良好': 1, '优秀': 1}\n",
"40-44 {'合格': 4, '不合格': 0, '良好': 0, '优秀': 0}\n",
"45-49 {'不合格': 3, '良好': 13, '合格': 17, '优秀': 5}\n",
"50-54 {'不合格': 1, '合格': 1, '良好': 2, '优秀': 0}\n",
"55-80 {'合格': 0, '不合格': 0}\n"
]
}
],
"source": [ "source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"\n", "\n",
@@ -1463,12 +1605,34 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 83,
"id": "fc97df37-34ff-4a02-9d26-b5d81b706e46", "id": "fc97df37-34ff-4a02-9d26-b5d81b706e46",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:38:49.264932Z",
"iopub.status.busy": "2023-12-02T09:38:49.264452Z",
"iopub.status.idle": "2023-12-02T09:38:49.286566Z",
"shell.execute_reply": "2023-12-02T09:38:49.285493Z",
"shell.execute_reply.started": "2023-12-02T09:38:49.264866Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20-24 {'合格': 34, '不合格': 19, '良好': 10, '优秀': 1}\n",
"25-29 {'不合格': 9, '合格': 17, '良好': 3, '优秀': 0}\n",
"30-34 {'合格': 24, '不合格': 12, '良好': 6, '优秀': 3}\n",
"35-39 {'合格': 20, '不合格': 6, '良好': 4, '优秀': 3}\n",
"40-44 {'合格': 14, '不合格': 5, '良好': 8, '优秀': 1}\n",
"45-49 {'不合格': 15, '良好': 13, '合格': 27, '优秀': 2}\n",
"50-54 {'不合格': 12, '合格': 31, '良好': 6, '优秀': 5}\n",
"55-80 {'合格': 11, '不合格': 6}\n"
]
}
],
"source": [ "source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"\n", "\n",
@@ -1508,12 +1672,34 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 84,
"id": "dafb86f8-5ee0-4c87-a98f-c7ff0f631fe5", "id": "dafb86f8-5ee0-4c87-a98f-c7ff0f631fe5",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:38:53.375671Z",
"iopub.status.busy": "2023-12-02T09:38:53.375130Z",
"iopub.status.idle": "2023-12-02T09:38:53.396164Z",
"shell.execute_reply": "2023-12-02T09:38:53.394885Z",
"shell.execute_reply.started": "2023-12-02T09:38:53.375634Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"16~24岁平均成绩:2.82分,人数:82人,男性:64人\n",
"25~29岁平均成绩:2.84分,人数:35人,男性:29人\n",
"30~34岁平均成绩:2.84分,人数:49人,男性:45人\n",
"35~39岁平均成绩:3.03分,人数:36人,男性:33人\n",
"40~44岁平均成绩:2.95分,人数:32人,男性:28人\n",
"45~49岁平均成绩:3.03分,人数:95人,男性:57人\n",
"50~54岁平均成绩:2.95分,人数:58人,男性:54人\n",
"55~69岁平均成绩:2.72分,人数:17人,男性:17人\n"
]
}
],
"source": [ "source": [
"nld = [[16,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n", "nld = [[16,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n",
"\n", "\n",
@@ -1548,12 +1734,34 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 89,
"id": "347703a1-501b-4800-bd29-16e94f4a6793", "id": "347703a1-501b-4800-bd29-16e94f4a6793",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T15:15:48.243512Z",
"iopub.status.busy": "2023-12-02T15:15:48.243065Z",
"iopub.status.idle": "2023-12-02T15:15:48.263263Z",
"shell.execute_reply": "2023-12-02T15:15:48.262071Z",
"shell.execute_reply.started": "2023-12-02T15:15:48.243476Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.8分,人数:64人\n",
"25~29岁平均成绩:2.74分,人数:29人\n",
"30~34岁平均成绩:2.82分,人数:45人\n",
"35~39岁平均成绩:2.96分,人数:33人\n",
"40~44岁平均成绩:2.96分,人数:28人\n",
"45~49岁平均成绩:2.89分,人数:57人\n",
"50~54岁平均成绩:2.94分,人数:54人\n",
"55~80岁平均成绩:2.72分,人数:17人\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -1588,10 +1796,34 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 90,
"id": "5900d1c7-2f8c-4dfa-a60e-a577fb90f22d", "id": "5900d1c7-2f8c-4dfa-a60e-a577fb90f22d",
"metadata": {}, "metadata": {
"outputs": [], "execution": {
"iopub.execute_input": "2023-12-02T15:15:53.325620Z",
"iopub.status.busy": "2023-12-02T15:15:53.325175Z",
"iopub.status.idle": "2023-12-02T15:15:53.345673Z",
"shell.execute_reply": "2023-12-02T15:15:53.344765Z",
"shell.execute_reply.started": "2023-12-02T15:15:53.325577Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.9分,人数:18人\n",
"25~29岁平均成绩:3.32分,人数:6人\n",
"30~34岁平均成绩:3.08分,人数:4人\n",
"35~39岁平均成绩:3.74分,人数:3人\n",
"40~44岁平均成绩:2.91分,人数:4人\n",
"45~49岁平均成绩:3.23分,人数:38人\n",
"50~54岁平均成绩:3.11分,人数:4人\n",
"55~80岁平均成绩:0分,人数:0人\n"
]
}
],
"source": [ "source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
"\n", "\n",
@@ -1624,12 +1856,36 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 87,
"id": "ad69c45d-3f62-42df-894d-47424e759029", "id": "ad69c45d-3f62-42df-894d-47424e759029",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:39:03.145078Z",
"iopub.status.busy": "2023-12-02T09:39:03.144630Z",
"iopub.status.idle": "2023-12-02T09:39:03.164888Z",
"shell.execute_reply": "2023-12-02T09:39:03.163659Z",
"shell.execute_reply.started": "2023-12-02T09:39:03.145041Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BMI 3.73 397\n",
"肺活量 3.44 394\n",
"握力 1.95 365\n",
"坐位体前屈 3.19 249\n",
"纵跳 2.73 377\n",
"俯卧撑 2.24 248\n",
"一分钟仰卧起坐 3.34 67\n",
"单脚站立 2.75 378\n",
"选择反应时 3.22 386\n",
"台阶指数 2.78 331\n"
]
}
],
"source": [ "source": [
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
@@ -1654,12 +1910,45 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 88,
"id": "dcf152e7-bbcc-47d1-9c5f-83854db35412", "id": "dcf152e7-bbcc-47d1-9c5f-83854db35412",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:39:08.338346Z",
"iopub.status.busy": "2023-12-02T09:39:08.337893Z",
"iopub.status.idle": "2023-12-02T09:39:08.356987Z",
"shell.execute_reply": "2023-12-02T09:39:08.355926Z",
"shell.execute_reply.started": "2023-12-02T09:39:08.338309Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"行政事务中心 2.46 12\n",
"储运部 2.79 58\n",
"长炼医院外二科 2.5 1\n",
"设备工程部 3.22 2\n",
"群众工作部 3.71 4\n",
"纪委(监督部) 3.33 2\n",
"IT服务中心 3.67 1\n",
"计量站 2.87 3\n",
"热电部 2.88 84\n",
"生产部 3.38 1\n",
"炼油一部 2.96 39\n",
"安全环保部 2.35 2\n",
"化工部 2.95 143\n",
"财务资产部 2.67 1\n",
"计划经营部 3.22 1\n",
"炼油二部 3.02 44\n",
"消防中心 3.0 1\n",
"港口部 2.77 4\n",
"水务部 3.11 1\n"
]
}
],
"source": [ "source": [
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
+143 -1
View File
@@ -1915,10 +1915,152 @@
" print(k,v['name'])" " print(k,v['name'])"
] ]
}, },
{
"cell_type": "markdown",
"id": "e7e0e29c-0f12-4478-b687-a03486adc85e",
"metadata": {},
"source": [
"## 报告按部门分类"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "a362768f-a67f-4c64-a830-b6a745ab35e4", "id": "3ff8ad3c-7868-4eb2-b879-4e8da19407ff",
"metadata": {},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import glob\n",
"from pathlib import Path\n",
"\n",
"fi_path = '/home/songyi/pdf-typescript/134'\n",
"new_path = 'file/134'\n",
"old = []\n",
"dict2 = {}\n",
"\n",
"filename = 'data/天津石化人员名单2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
"for fn in fls:\n",
" fi_name =Path(fn).stem.split('-')[0]\n",
" code = int(fi_name)\n",
" unit_path = Path(new_path,dict1[str(code)]['unit'])\n",
" unit_path.mkdir(parents = True, exist_ok = True)\n",
" n_name = Path(unit_path,Path(fn).stem+'.pdf')\n",
" if not os.path.exists(n_name):\n",
" shutil.copyfile(fn,n_name)\n",
" #print(n_name)"
]
},
{
"cell_type": "markdown",
"id": "abe43620-c456-43a0-905a-b29aad8b2e3c",
"metadata": {},
"source": [
"## 核对新部门分类人员"
]
},
{
"cell_type": "code",
"execution_count": 140,
"id": "a3f1476d-5f70-45c4-aa04-ebc6558033b8",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:58:33.152532Z",
"iopub.status.busy": "2023-12-02T09:58:33.152132Z",
"iopub.status.idle": "2023-12-02T09:58:33.270132Z",
"shell.execute_reply": "2023-12-02T09:58:33.269673Z",
"shell.execute_reply.started": "2023-12-02T09:58:33.152500Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"787\n",
"1 吴强\n",
"2 李丹\n",
"3 王勃\n",
"4 史海燕\n",
"5 周美琴\n",
"6 钟丽\n",
"7 徐玉清\n",
"8 苏洪梅\n",
"9 张杰\n",
"10 杨植文\n",
"11 张梦瑶\n",
"12 韩晓舒\n",
"13 栗晓娜\n",
"14 陈继杨\n",
"15 陈雪梅\n",
"16 林宏锟\n",
"17 汝晴\n",
"18 庞珺珊\n",
"19 姚子翔\n",
"20 罗泽伟\n",
"21 吴子巍\n",
"22 史策\n",
"23 赵婷婷\n",
"24 韦州全\n",
"25 代迪\n",
"26 傅志成\n",
"27 刘国旭\n",
"28 宋燕\n",
"29 侯海霞\n",
"30 刘慧\n",
"31 古富兰\n",
"32 范和文\n",
"33 冯鸥\n",
"34 王依然\n",
"35 田长利\n",
"36 杜苹苹\n",
"37 姜涛\n",
"38 王晓松\n",
"39 雷文秀\n",
"40 徐月\n",
"41 李凤燕\n",
"42 尹莎\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/result_北海炼化2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/北海炼化新名单.xlsx')\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"list1 = []\n",
"\n",
"for n in range(5, sheet.max_row+1):\n",
" if sheet.cell(n,2).value is not None:\n",
" list1.append(sheet.cell(n,2).value)\n",
"print(len(list1)) \n",
"i = 1\n",
"for k, v in dict1.items():\n",
" name = v['name']\n",
" if name not in list1:\n",
" print(i,name)\n",
" i+=1"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e30031dc-3597-4594-8c32-693a958ae171",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
+532 -8
View File
@@ -4,7 +4,6 @@
"cell_type": "markdown", "cell_type": "markdown",
"id": "55644860-57e6-466b-b6e9-e6fdd807498d", "id": "55644860-57e6-466b-b6e9-e6fdd807498d",
"metadata": { "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [] "tags": []
}, },
"source": [ "source": [
@@ -14,7 +13,9 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "d4d999fe-4890-4a14-b1e8-52dbd6d42e73", "id": "d4d999fe-4890-4a14-b1e8-52dbd6d42e73",
"metadata": {}, "metadata": {
"tags": []
},
"source": [ "source": [
"## 导入人员信息" "## 导入人员信息"
] ]
@@ -250,12 +251,28 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 76,
"id": "033cc564-4aa9-4e88-b38b-ec62a02b1661", "id": "033cc564-4aa9-4e88-b38b-ec62a02b1661",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:09:44.065510Z",
"iopub.status.busy": "2023-12-02T09:09:44.065032Z",
"iopub.status.idle": "2023-12-02T09:09:44.126813Z",
"shell.execute_reply": "2023-12-02T09:09:44.126202Z",
"shell.execute_reply.started": "2023-12-02T09:09:44.065472Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"436\n",
"436\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import datetime\n", "import datetime\n",
@@ -289,7 +306,7 @@
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"\n", "\n",
"filename = 'data/places_result_20230830.csv'\n", "filename = 'data/places_result_20231202.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n", "with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n", " fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n", " header = next(fl) \n",
@@ -300,7 +317,9 @@
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n", "#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
"for result in list1:\n", "for result in list1:\n",
" user = str(result[2])\n", " user = str(result[2])\n",
" if user in dict1.keys():\n", " item_id = int(result[3])\n",
" performance = int(result[4])\n",
" if user in dict1.keys() and (item_id!=3 and performance>0):\n",
" l_xm = []\n", " l_xm = []\n",
" m_item = str(result[3]) \n", " m_item = str(result[3]) \n",
" re_ta.setdefault(user,{}) \n", " re_ta.setdefault(user,{}) \n",
@@ -850,6 +869,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"id": "b07923fd-94da-4b86-8902-523d3ebc3d1b", "id": "b07923fd-94da-4b86-8902-523d3ebc3d1b",
"metadata": { "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [] "tags": []
}, },
"source": [ "source": [
@@ -860,6 +880,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"id": "6ba73ead-6715-46a6-b4a9-3a00b733b151", "id": "6ba73ead-6715-46a6-b4a9-3a00b733b151",
"metadata": { "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [] "tags": []
}, },
"source": [ "source": [
@@ -1540,7 +1561,10 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "6cd42cb2-37a4-44e8-87cb-afd71b32e81f", "id": "6cd42cb2-37a4-44e8-87cb-afd71b32e81f",
"metadata": {}, "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [ "source": [
"# 教师体测" "# 教师体测"
] ]
@@ -1958,10 +1982,510 @@
" print(f'{item}平均成绩:{round(t_score/(f+m),4)}分,总体:{f+m}人')" " print(f'{item}平均成绩:{round(t_score/(f+m),4)}分,总体:{f+m}人')"
] ]
}, },
{
"cell_type": "markdown",
"id": "78942564-c286-4f4e-8d89-515a2b4b4c86",
"metadata": {},
"source": [
"# 员工数据分析"
]
},
{
"cell_type": "markdown",
"id": "ee99edaa-700f-4eb3-bcf9-1366d4fefd76",
"metadata": {},
"source": [
"## 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 89,
"id": "48f91581-2556-40d0-b0fe-ee98edb3983f",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:37:33.794840Z",
"iopub.status.busy": "2023-12-02T09:37:33.794387Z",
"iopub.status.idle": "2023-12-02T09:37:33.887950Z",
"shell.execute_reply": "2023-12-02T09:37:33.887437Z",
"shell.execute_reply.started": "2023-12-02T09:37:33.794797Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"436\n",
"436\n"
]
}
],
"source": [
"import json\n",
"import datetime\n",
"import csv\n",
"from datetime import date\n",
"\n",
"filename = '../item.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" 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",
"filename = 'data/长炼医院人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20231202.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",
"#f_item = ['lung','grip','flexion','jump','balance','reaction','step','situp']\n",
"#m_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
"for result in list1:\n",
" user = str(result[2])\n",
" item_id = int(result[3])\n",
" performance = int(result[4])\n",
" rq = date.fromisoformat(result[6].replace('/','-'))\n",
" if user in dict1.keys() and (item_id!=3 or performance>0):\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",
" 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",
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\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_长炼医院.json'\n",
"\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": "35f5c65e-0efb-4870-9981-6f7a0b910ac2",
"metadata": {},
"source": [
"## 计算项目成绩"
]
},
{
"cell_type": "code",
"execution_count": 90,
"id": "160841a0-a092-4457-8ce0-fe39910c5da5",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:37:41.993070Z",
"iopub.status.busy": "2023-12-02T09:37:41.992677Z",
"iopub.status.idle": "2023-12-02T09:37:42.024279Z",
"shell.execute_reply": "2023-12-02T09:37:42.023829Z",
"shell.execute_reply.started": "2023-12-02T09:37:41.993038Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"\n",
"filename = '../item.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",
"#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_长炼医院.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",
"\n",
"filename = f'data/result_长炼医院.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{
"cell_type": "markdown",
"id": "bdded0c9-7616-4cf1-9788-8bb008944bee",
"metadata": {},
"source": [
"## 清理报告数据"
]
},
{
"cell_type": "code",
"execution_count": 91,
"id": "ed4c5a19-1c9e-4c63-8fdd-30b36ecc047a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:37:46.266558Z",
"iopub.status.busy": "2023-12-02T09:37:46.266103Z",
"iopub.status.idle": "2023-12-02T09:37:46.337714Z",
"shell.execute_reply": "2023-12-02T09:37:46.336373Z",
"shell.execute_reply.started": "2023-12-02T09:37:46.266521Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"404\n",
"ok!\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"\n",
"filename = 'data/result_长炼医院.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
" \n",
"#items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"items = {}\n",
"items['lung'] = '肺活量'\n",
"items['grip'] ='握力'\n",
"items['flexion'] ='坐位体前屈'\n",
"items['jump'] ='纵跳'\n",
"items['pushup'] ='俯卧撑'\n",
"items['balance'] ='单脚站立'\n",
"items['reaction'] ='选择反应时'\n",
"items['step'] ='台阶指数'\n",
"items['situp'] ='一分钟仰卧起坐'\n",
"items['bmi'] ='BMI'\n",
"\n",
"\n",
"list1 = []\n",
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
"i=1\n",
"list2 = []\n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" list1 = []\n",
" mydata = {}\n",
" \n",
" id = str(k).rjust(8,\"0\")\n",
" mydata['unit'] = v['unit']\n",
" mydata['name'] = v['name']\n",
" mydata['sex'] = v['sex']\n",
" mydata['month'] = v['month']\n",
" age = int(v['month']/12)\n",
" if age <20:\n",
" mydata['age'] = 20\n",
" else:\n",
" mydata['age'] = int(v['month']/12)\n",
" \n",
" mydata['fits'] = {}\n",
" score = 0\n",
" for item in list_item:\n",
" if item in v.keys():\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'][items[item]] = {'mark':mark,'score':v[item]['score']}\n",
" score = score + v[item]['score']\n",
" if len(mydata['fits'])>0:\n",
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
" if len(mydata['fits']) >2:\n",
" dict2[str(k)] = mydata\n",
"print(len(dict2))\n",
"filename = f'data/data_长炼医院.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2,fl , ensure_ascii=False) \n",
"print('ok!') "
]
},
{
"cell_type": "markdown",
"id": "a802ad72-494f-4db5-93a0-9e2cd88a65fe",
"metadata": {},
"source": [
"## 计算测试等级"
]
},
{
"cell_type": "code",
"execution_count": 87,
"id": "14788ff3-0f3d-4ba2-b162-1f0663389a9d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:30:14.828302Z",
"iopub.status.busy": "2023-12-02T09:30:14.827804Z",
"iopub.status.idle": "2023-12-02T09:30:14.849786Z",
"shell.execute_reply": "2023-12-02T09:30:14.848591Z",
"shell.execute_reply.started": "2023-12-02T09:30:14.828264Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0~255分人数:96人,男性:88人,女性:8人\n",
"256~332分人数:217人,男性:175人,女性:42人\n",
"333~367分人数:62人,男性:43人,女性:19人\n",
"368~500分人数:27人,男性:19人,女性:8人\n",
"402\n"
]
}
],
"source": [
"import json\n",
"\n",
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/data_长炼医院.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"dict2['不合格'] = [0,255]\n",
"dict2['合格'] = [256,332]\n",
"dict2['良好'] = [333,367]\n",
"dict2['优秀'] = [368,500]\n",
"\n",
"for k1, v1 in dict2.items():\n",
" di = v1[0]\n",
" gao = v1[1]\n",
" i = 0 \n",
" m = 0\n",
" f = 0\n",
" for k,v in dict1.items():\n",
" if int(v['score']*100) in range(di,gao+1):\n",
" dict1[k]['level'] = k1\n",
" i+=1\n",
" if v['sex'] == '男':\n",
" m = m +1\n",
" else:\n",
" f = f+1\n",
" print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n",
"print(len(dict1))"
]
},
{
"cell_type": "markdown",
"id": "ca9b178d-bcdc-40ff-afa4-15718f10a24a",
"metadata": {},
"source": [
"## 根据年龄汇总人员信息及成绩"
]
},
{
"cell_type": "code",
"execution_count": 88,
"id": "257917a2-5b29-4cd9-a798-4fd8e75ffe9c",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-02T09:30:49.967886Z",
"iopub.status.busy": "2023-12-02T09:30:49.967396Z",
"iopub.status.idle": "2023-12-02T09:30:49.987381Z",
"shell.execute_reply": "2023-12-02T09:30:49.986279Z",
"shell.execute_reply.started": "2023-12-02T09:30:49.967848Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.79分,人数:81人,男性:63人\n",
"25~29岁平均成绩:2.76分,人数:35人,男性:29人\n",
"30~34岁平均成绩:2.76分,人数:49人,男性:45人\n",
"35~39岁平均成绩:2.94分,人数:36人,男性:33人\n",
"40~44岁平均成绩:2.88分,人数:32人,男性:28人\n",
"45~49岁平均成绩:2.99分,人数:95人,男性:57人\n",
"50~54岁平均成绩:2.83分,人数:57人,男性:53人\n",
"55~69岁平均成绩:2.52分,人数:17人,男性:17人\n"
]
}
],
"source": [
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n",
"\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"for item in nld:\n",
" di = item[0]\n",
" gao = item[1]\n",
" i = 1\n",
" score = 0\n",
" m = 0\n",
" f = 0\n",
" for k,v in dict1.items():\n",
" if v['age'] in range(di,gao+1):\n",
" score = score+v['score']\n",
" i+=1\n",
" if v['sex'] == '男':\n",
" m = m +1\n",
" \n",
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人,男性:{m}人')"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "bb9c6bf3-8f84-4290-a60c-710517a399d5", "id": "dcf80c81-907f-4397-8ebf-7b9234e63af1",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []