4149 lines
132 KiB
Plaintext
4149 lines
132 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "e764be85-0ddf-4055-abd6-de2990e75db8",
|
||
"metadata": {
|
||
"tags": [],
|
||
"toc-hr-collapsed": true
|
||
},
|
||
"source": [
|
||
"# 第一次体测"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "ae533fe9-e20e-4e44-b9bb-030c4fa4e714",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"## 体测人员导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "1144aaac-92a0-4bcf-aba7-096f7dd3ad3b",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/天津石化员工检测花名册 (20221014).xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"\n",
|
||
"for n in range(2, sheet.max_row+1):\n",
|
||
" code = int(sheet.cell(n, 6).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, 1).value\n",
|
||
" dict1['sub_unit'] = sheet.cell(n, 2).value\n",
|
||
" if sheet.cell(n,5).value is not None:\n",
|
||
" dict1['id_num'] = sheet.cell(n,5).value\n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "93b9bfba-5404-4c9b-ac8f-48a3bf296669",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 合并人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "d5171966-95ae-47ae-a75e-db08de772348",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"\n",
|
||
"for k, v in dict2.items():\n",
|
||
" if k not in dict1.keys():\n",
|
||
" dict1.setdefault(k,{})\n",
|
||
" dict1[k]['name'] = dict2[k]['name']\n",
|
||
" dict1[k]['sex'] = dict2[k]['sex']\n",
|
||
" dict1[k]['unit'] = dict2[k]['name']\n",
|
||
" dict1[k]['sub_unit'] = dict2[k]['sub_unit']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "5e648b69-40bf-4494-9079-e4e2b6ab8866",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 获取人员测试成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "a57ebb22-543c-4804-8d44-89984058ec1d",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\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",
|
||
"#SQL语句为:\n",
|
||
"#SELECT a.item_id,a.performance,a.score,a.date AS DATE1,a.avatar_id,b.unit,b.name,a.date_joined FROM places_result AS a,_tianjin AS b WHERE a.place_id=134 AND a.avatar_id=b.id\n",
|
||
"\n",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"#print(\"\\n运动项目信息:\")\n",
|
||
"filename = '体测单位/data/20230428_134.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",
|
||
"#print(list1)\n",
|
||
"for result in list1:\n",
|
||
" user = str(result[4])\n",
|
||
" m_item = str(result[0]) \n",
|
||
" re_ta.setdefault(user,{}) \n",
|
||
" re_ta[user]['name'] = str(result[6])\n",
|
||
" re_ta[user]['unit'] = str(result[5]) \n",
|
||
" item_name = item[m_item]['name']\n",
|
||
" re_ta[user].setdefault(item_name,{}) \n",
|
||
" score = int(result[1])/item[m_item]['divisor'] \n",
|
||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||
" re_ta[user][item_name]['得分'] =result[2]\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "55d961e5-a512-44b2-808e-7c55d7000d52",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导出测试成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "38397ad4-2bb3-4b5e-8ece-9ea11e801890",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(8,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['unit'])\n",
|
||
" list2.append(dict2[k]['sub_unit'])\n",
|
||
" \n",
|
||
" for item in items:\n",
|
||
" if item in v.keys():\n",
|
||
" list2.append(v[item]['成绩'])\n",
|
||
" \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(v[item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" \n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/天津石化体测情况表(截至20221122).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "239ceb76-f690-4dae-991c-62c38d617c85",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导出测试成绩(带得分)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "27529013-f3de-4e23-980d-f62203e4df88",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室','身高','','体重','','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"del dict1['1730253']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items(): #print(k,dict2[str(k)]['name'])\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(dict2[k]['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['unit']) \n",
|
||
" list2.append(dict2[k]['sub_unit']) \n",
|
||
" for item in items:\n",
|
||
" if item in dict1[k].keys():\n",
|
||
" list2.append(dict1[k][item]['成绩'])\n",
|
||
" list2.append(dict1[k][item]['得分']) \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(dict1[k][item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list2.append('') \n",
|
||
" list1.append(list2)\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": "markdown",
|
||
"id": "1c7b219f-43cd-4bf0-971f-2c398f8db8ed",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 按照日期进行报告分类"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "3d57ff66-69c3-4c13-811b-f1e13b404077",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 按照体测明细分类"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "29c0f15b-1345-4b46-ac1d-b45ddede9641",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"import os,sys,shutil\n",
|
||
"import glob\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/134_2210.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",
|
||
"for result in list1:\n",
|
||
" user = str(result[4])\n",
|
||
" dict1.setdefault(user,'2022-10-01')\n",
|
||
" m_date = result[7]\n",
|
||
" if m_date> dict1[user]:\n",
|
||
" dict1[user] = m_date\n",
|
||
"\n",
|
||
"m_path = 'file/134'\n",
|
||
"\n",
|
||
"fls = glob.glob(f'file/new/*.pdf')\n",
|
||
"for fn in fls:\n",
|
||
" #old = os.path.basename(fn).split('.')[0].rjust(8,'0') \n",
|
||
" old = os.path.basename(fn).split('.')[0]\n",
|
||
" mrq = str(dict1[old]).split(' ')[0].replace('-', '', 2)\n",
|
||
" if not os.path.exists(m_path + '/new/' + mrq):\n",
|
||
" os.mkdir(m_path + '/new/' + mrq)\n",
|
||
" n_name = f'{m_path}/new/{mrq}/{str(old).rjust(8,\"0\")}_{mrq}.pdf'\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(fn,n_name)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "ae2b17bd-38b9-4809-affb-01441a5581eb",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 按照报告生成日期分类"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "eb24c1be-b5d3-4e61-a432-854a887746d4",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"import os,sys,shutil\n",
|
||
"import glob\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"\n",
|
||
"m_path = 'file/134'\n",
|
||
"mrq = '20221028'\n",
|
||
"if not os.path.exists(m_path + '/' + mrq):\n",
|
||
" os.mkdir(m_path + '/' + mrq)\n",
|
||
"fls = glob.glob(f'file/new/*.pdf')\n",
|
||
"for fn in fls:\n",
|
||
" #old = os.path.basename(fn).split('.')[0].rjust(8,'0') \n",
|
||
" old = os.path.basename(fn).split('.')[0] \n",
|
||
" n_name = f'{m_path}/{mrq}/{str(old).rjust(8,\"0\")}_{mrq}.pdf'\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(fn,n_name)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d9061d26-b09b-4bff-af24-a14adda3d83f",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 按照部门报告分组"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "7ea2541f-461f-4eb5-860d-4b56d6be74ab",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import os,sys,shutil\n",
|
||
"import json\n",
|
||
"import math\n",
|
||
"import glob\n",
|
||
"from pathlib import Path\n",
|
||
"\n",
|
||
"fi_path = './file'\n",
|
||
"old = []\n",
|
||
"dict2 = {}\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" m_name = v['name']\n",
|
||
" m_depart = v['unit'] \n",
|
||
" dict2[int(k)] = [m_name,m_depart]\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"fls = glob.glob(f'./file/*.pdf')\n",
|
||
"\n",
|
||
"for fn in fls:\n",
|
||
" old.append(os.path.basename(fn).split('.')[0])\n",
|
||
" #print(fn)\n",
|
||
"\n",
|
||
"\n",
|
||
"for n in old: \n",
|
||
" o_name = f'{fi_path}/{n}.pdf'\n",
|
||
" if not os.path.exists(f'{fi_path}/new/{dict2[int(n)][1]}'):\n",
|
||
" os.mkdir(f'{fi_path}/new/{dict2[int(n)][1]}') \n",
|
||
" n_name = f'{fi_path}/new/{dict2[int(n)][1]}/{str(n).rjust(5,\"0\")}-{dict2[int(n)][0]}.pdf'\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(o_name,n_name)\n",
|
||
" print(n_name)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "63eb8a23-4876-4be6-8800-1a67df8773ff",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import os,sys,shutil\n",
|
||
"import json\n",
|
||
"import math\n",
|
||
"import glob\n",
|
||
"from pathlib import Path\n",
|
||
"\n",
|
||
"fi_path = './file'\n",
|
||
"old = []\n",
|
||
"dict2 = {}\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" m_name = v['name']\n",
|
||
" m_depart = v['unit'] \n",
|
||
" dict2[int(k)] = [m_name,m_depart]\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"fls = glob.glob(f'./file/*.pdf')\n",
|
||
"\n",
|
||
"for fn in fls:\n",
|
||
" old.append(os.path.basename(fn).split('.')[0])\n",
|
||
"\n",
|
||
"for n in old: \n",
|
||
" o_name = f'{fi_path}/{n}.pdf'\n",
|
||
" new_path = Path('file/new',dict1[n]['unit'],dict1[n]['sub_unit'])\n",
|
||
" new_path.mkdir(parents = True, exist_ok = True)\n",
|
||
" n_name = Path(new_path,f'{str(n).rjust(7,\"0\")}-{dict2[int(n)][0]}.pdf')\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(o_name,n_name)\n",
|
||
" print(n_name)\n",
|
||
" \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "e4590323-6645-450a-8055-756a5bf35b34",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计报告人员信息表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "ed681a0d-4ee8-48ec-ab05-23da7156a44e",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"import os\n",
|
||
"import glob\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"m_path ='./file'\n",
|
||
"fls = glob.glob(f'file/*.pdf')\n",
|
||
"list1 = []\n",
|
||
"for fn in fls:\n",
|
||
" list2 = []\n",
|
||
" code = os.path.basename(fn).split('.')[0]\n",
|
||
" list2 = [code.rjust(7,\"0\"),dict1[code]['name'],dict1[code]['unit'],dict1[code]['sub_unit']]\n",
|
||
" list1.append(list2)\n",
|
||
"title = ['编号','姓名','单位/部门','车间/科室',] \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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "838ec7d3-137c-4ccd-9f16-7b6312d1ffa6",
|
||
"metadata": {},
|
||
"source": [
|
||
"## PDF文件压缩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "a6ab0943-b018-4dd6-9176-85a762f9f60c",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import fitz\n",
|
||
"from pdf2image import convert_from_path, convert_from_bytes\n",
|
||
"import os,sys\n",
|
||
"import tempfile\n",
|
||
"from pdf2image.exceptions import (\n",
|
||
" PDFInfoNotInstalledError,\n",
|
||
" PDFPageCountError,\n",
|
||
" PDFSyntaxError\n",
|
||
")\n",
|
||
"import img2pdf \n",
|
||
"import glob\n",
|
||
"import shutil\n",
|
||
"\n",
|
||
"def covert2pic(old_fn):\n",
|
||
" if os.path.exists('.pdf'): # 临时文件,需为空\n",
|
||
" shutil.rmtree('.pdf')\n",
|
||
" os.mkdir('.pdf')\n",
|
||
" with tempfile.TemporaryDirectory() as path:\n",
|
||
" images_from_path = convert_from_path(old_fn, dpi=100,fmt='jpg', output_folder='.pdf')\n",
|
||
"\n",
|
||
"def pic2pdf(new_fn):\n",
|
||
" fl1=glob.glob('.pdf/*.jpg')\n",
|
||
" fl1.sort()\n",
|
||
" a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))\n",
|
||
" layout_fun = img2pdf.get_layout_fun(a4inpt)\n",
|
||
" with open(new_fn,\"wb\") as f:\n",
|
||
" f.write(img2pdf.convert(fl1,layout_fun=layout_fun))\n",
|
||
" print(f'{new_fn}转换成功!')\n",
|
||
" \n",
|
||
"\n",
|
||
"\n",
|
||
"def pdfz(sor, obj, zoom): \n",
|
||
" covert2pic(zoom)\n",
|
||
" pic2pdf(obj)\n",
|
||
" \n",
|
||
"fi_path = 'file/134/20221122/'\n",
|
||
"fl = glob.glob(f'{fi_path}*.pdf')\n",
|
||
"\n",
|
||
"for fn in fl:\n",
|
||
" new_fn = fi_path+'new/'+os.path.basename(fn)\n",
|
||
" covert2pic(fn)\n",
|
||
" pic2pdf(new_fn)\n",
|
||
" shutil.rmtree('.pdf')\n",
|
||
"print('ok!')\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "a0cc9662-4171-4c2a-828d-f58c327ec8c1",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计未测试人员名单"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "daef91be-1b58-4fb1-b182-64f43c07c90f",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" if k not in dict2.keys(): \n",
|
||
" list2 = [k,dict1[k]['name'],dict1[k]['sex'],dict1[k]['unit'],dict1[k]['sub_unit'],] \n",
|
||
" list1.append(list2)\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": "markdown",
|
||
"id": "72c693e1-dd7c-40fa-8948-4fd6fbea8ddc",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 区分新文件"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "9d06d4f0-364b-438c-844b-7d5badaf3496",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import os,sys,shutil\n",
|
||
"import glob\n",
|
||
"import time\n",
|
||
"\n",
|
||
"fi_path = 'file/'\n",
|
||
"fls = glob.glob(f'{fi_path}*.pdf')\n",
|
||
"m_date = time.strptime('2022-10-28','%Y-%m-%d')\n",
|
||
"for fn in fls:\n",
|
||
" c_time = time.gmtime(os.path.getctime(fn))\n",
|
||
" if c_time > m_date:\n",
|
||
" n_name = f'{fi_path}new/{os.path.basename(fn)}'\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(fn,n_name)\n",
|
||
" print(n_name)\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "32b61559-4495-4fbe-8eb6-2614e6225b5c",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"print(len(dict2),len(dict1),)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "47015abe-4cb8-436b-afa5-9ffd78d4a628",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 心理测试情况统计"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "c21efc40-2639-4b22-851f-925cd3f12d3a",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'data/134_xinli.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[4])\n",
|
||
"list3 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" if k not in list1: \n",
|
||
" list2 = [k,dict1[k]['name'],dict1[k]['sex'],dict1[k]['unit'],dict1[k]['sub_unit'],] \n",
|
||
" list3.append(list2)\n",
|
||
"filename = 'data/天津石化未参加心理测试人数统计表.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list3:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "6b8ae75d-71a3-4cbe-a216-03c28d78156c",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位/部门','车间/科室']\n",
|
||
"filename = 'data/天津石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/134_xinli.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",
|
||
" print(line[4])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "20e98f0d-61ea-43a5-8993-9656fed23099",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 体检报告统计分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "0436a3a2-6230-43b3-beae-bc89e789b285",
|
||
"metadata": {},
|
||
"source": [
|
||
"### excel数据导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "7bb2e3aa-591d-4fce-983a-cde5d4c30e56",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"import re\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/体检结果(模板)化工.xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"dict1 = {}\n",
|
||
"\n",
|
||
"for n in range(11, sheet.max_row+1):\n",
|
||
" code = sheet.cell(n, 1).value\n",
|
||
" name = sheet.cell(n, 8).value\n",
|
||
" txt = sheet[f'DT{str(n)}'].value \n",
|
||
" txt = re.sub(r'\\n', \"\", txt)\n",
|
||
" txt = re.sub(r'\\t', \"\", txt)\n",
|
||
" txt = re.sub(r'二、尊敬的顾客您好,您本次体检的建议信息如下:', \"\", txt)\n",
|
||
" ss = r'三、温馨提示: 鉴于医学技术发展的局限性,个体间可能存在的生物差异性以及您选择的检查项目的局限性,任何一次医学检查的手段和方法都不具备绝对的特异性和灵敏度,对于疾病筛检仍有其盲点,因此,我们建议您对本次检查的异常结果进行随诊复查和其他相关检查,以获得更可靠的医学证据建立准确地医学判断。'\n",
|
||
" txt1 = re.sub(r'三、温馨提示.*', \"\", txt,re.S)\n",
|
||
" dict1.setdefault(code, {})\n",
|
||
" dict1[code]['name'] = name\n",
|
||
" dict1[code]['xb'] = sheet.cell(n, 9).value\n",
|
||
" #dict1[code]['birth'] = sheet.cell(n, 10).value\n",
|
||
" dict1[code]['report'] = txt1\n",
|
||
"filename = 'data/体检结果.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "227a1c0b-fc78-4951-97ab-5664b59edd1d",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 体检结果分解"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "b38aef28-5d1b-4762-9c7e-70a531594fa4",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"import re\n",
|
||
"\n",
|
||
"mo1 = r'[0-9]、'\n",
|
||
"mo2 = '【.*】'\n",
|
||
"filename = 'data/体检结果.json'\n",
|
||
"list3 = []\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"for k, v in dict1.items():\n",
|
||
" \n",
|
||
" ss = v['report']\n",
|
||
" list1 = re.split(mo1,ss)\n",
|
||
" if len(list1) ==1:\n",
|
||
" continue\n",
|
||
" else:\n",
|
||
" list1.remove('')\n",
|
||
" #print(list1)\n",
|
||
" for item in list1:\n",
|
||
" list2 = re.search( mo2, item)\n",
|
||
" xm =list2.group()\n",
|
||
" \n",
|
||
" txt = item.replace(xm,'').strip()\n",
|
||
" list3.append([k,v['name'],v['xb'],xm,txt])\n",
|
||
"filename = 'data/症状表.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list3:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "964526bc-9c9c-4b63-9300-67b02d2608f5",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 天津人员制卡"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "83f02525-fd26-41ba-8b6a-c3cd584825e6",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import binascii\n",
|
||
"import openpyxl\n",
|
||
"gbs = 'C2EDC1A2D1C7'\n",
|
||
"bs = binascii.a2b_hex(gbs)\n",
|
||
"#print('bs', bs)\n",
|
||
"#print('decode-bs:', bs.decode('gb2312'))\n",
|
||
"\n",
|
||
"s = '马立亚'\n",
|
||
"gbcode = s.encode('gb2312') # 先转成 bytes格式\n",
|
||
"#print('gbcode:', gbcode)\n",
|
||
"gbs = \"\".join([hex(ch)[2:] for ch in gbcode]) #\n",
|
||
"#print('gbs:', gbs)\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/联合六车间体质测定人员名单.xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"list1 = []\n",
|
||
"for n in range(3, sheet.max_row+1):\n",
|
||
" name = sheet.cell(n, 3).value\n",
|
||
" code = sheet.cell(n, 2).value\n",
|
||
" gbcode = code.encode('gbk')\n",
|
||
" code = \"\".join([hex(ch)[2:] for ch in gbcode])\n",
|
||
" gbcode = name.encode('gbk')\n",
|
||
" name = \"\".join([hex(ch)[2:] for ch in gbcode])\n",
|
||
" #for s in code:\n",
|
||
" # print(ord(s))\n",
|
||
" \n",
|
||
" list1.append([sheet.cell(n, 1).value,sheet.cell(n, 2).value,sheet.cell(n, 3).value,code.ljust(32,'0'),name.ljust(32,'0')])\n",
|
||
" print(code.ljust(32,'0'),name.ljust(32,'0'))\n",
|
||
"\n",
|
||
"filename = 'data/联合六车间体质测定人员制卡名单.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "638bbe8e-3770-40e1-b884-ceeeec5a053c",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "9e25a7f2-0571-438b-9aa4-e3337d9fd840",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 清除修改测试项目"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "6e6f6a63-b297-42e8-a9ba-b2636fda5d09",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"code = '1734094'\n",
|
||
"items = ['身高','体重']\n",
|
||
"for item in items:\n",
|
||
" del dict1[code][item]\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "f96b3aeb-bf37-4a8b-bf18-d0ae8f7df653",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 人员情况导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "4d77ec9b-c561-4355-98af-b18c42c1f3ca",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/员工个人基础信息20230113.xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"\n",
|
||
"for n in range(4, sheet.max_row+1):\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'] = sheet.cell(n, 6).value\n",
|
||
" dict1['sub_unit'] = sheet.cell(n, 7).value\n",
|
||
" if sheet.cell(n,10).value is not None:\n",
|
||
" dict1['daoban'] = '是'\n",
|
||
" else:\n",
|
||
" dict1['daoban'] = '否'\n",
|
||
" dict1['age'] = sheet.cell(n, 13).value\n",
|
||
" dict1['gl'] = sheet.cell(n, 14).value\n",
|
||
" dict1['jhgl'] = sheet.cell(n, 15).value \n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/天津石化人员231113.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "a5c58b77-69b6-4d76-8927-6e734556e848",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 人员体测得分导入合并"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "db473c01-7e1a-48c4-a0d7-e44cdeb9e24b",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"for k, v in dict2.items():\n",
|
||
" if k in dict1.keys():\n",
|
||
" for item in dict1[k].keys():\n",
|
||
" dict2[k][item] = dict1[k][item]\n",
|
||
"filename = 'data/天津石化人员231113.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||
"print('ok')\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "cc53ec68-cfc4-449a-9905-095a079dc8ab",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 筛选体测人员,计算得分"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "224cdee4-153f-424a-aaaa-92ef58943edb",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_天津.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"dict3 = {}\n",
|
||
"for k, v in dict2.items():\n",
|
||
" if k in dict1.keys():\n",
|
||
" dict3[k] = dict2[k]\n",
|
||
" i = 0\n",
|
||
" score =0\n",
|
||
" for item in dict2[k].keys(): \n",
|
||
" if item in items:\n",
|
||
" score = score + int(dict2[k][item]['得分'])\n",
|
||
" i+=1\n",
|
||
" dict3[k]['score'] = score\n",
|
||
" dict3[k]['item_num'] = i\n",
|
||
" dict3[k]['avg'] = round(score/i,2)\n",
|
||
"filename = 'data/天津石化线上测试结果.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"for k, v in dict2.items():\n",
|
||
" if k in dict1.keys():\n",
|
||
" dict3[k] = dict2[k]\n",
|
||
" dict3[k]['zhongyi'] = dict1[k]['中医体质']\n",
|
||
" \n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "dd014e41-18f2-44e7-9f20-1190df4e7b45",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "c63bca31-f003-49e9-a20d-1931c050c740",
|
||
"metadata": {},
|
||
"source": [
|
||
"#### 倒班因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "2a964412-8408-4039-a788-8cc1fc7cd518",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(dict1[k]['unit'])\n",
|
||
"#print(unit)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" dict2.setdefault(v['unit'],{})\n",
|
||
" dict2[v['unit']].setdefault('是',{})\n",
|
||
" dict2[v['unit']].setdefault('否',{})\n",
|
||
" dict2[v['unit']]['是'].setdefault('num',0)\n",
|
||
" dict2[v['unit']]['否'].setdefault('num',0)\n",
|
||
" dict2[v['unit']]['是'].setdefault('score',0)\n",
|
||
" dict2[v['unit']]['否'].setdefault('score',0)\n",
|
||
" dict2[v['unit']]['是'].setdefault('zhongyi',0)\n",
|
||
" dict2[v['unit']]['否'].setdefault('zhongyi',0) \n",
|
||
" dict2[v['unit']]['是'].setdefault('pianpo',0)\n",
|
||
" dict2[v['unit']]['否'].setdefault('pianpo',0) \n",
|
||
" if 'avg' in v.keys():\n",
|
||
" dict2[v['unit']][v['daoban']]['num'] = dict2[v['unit']][v['daoban']]['num'] + 1\n",
|
||
" dict2[v['unit']][v['daoban']]['score'] = dict2[v['unit']][v['daoban']]['score'] + v['avg']\n",
|
||
" if 'zhongyi' in v.keys() :\n",
|
||
" dict2[v['unit']][v['daoban']]['zhongyi'] = dict2[v['unit']][v['daoban']]['zhongyi'] + 1\n",
|
||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||
" dict2[v['unit']][v['daoban']]['pianpo'] = dict2[v['unit']][v['daoban']]['pianpo'] + 1\n",
|
||
" \n",
|
||
" \n",
|
||
"for k, v in dict2.items(): \n",
|
||
" if v['是']['num'] > 0:\n",
|
||
" dict2[k]['是']['avg'] = round(v['是']['score']/v['是']['num'],2)\n",
|
||
" else:\n",
|
||
" dict2[k]['是']['avg'] = 0\n",
|
||
" if v['否']['num'] > 0:\n",
|
||
" dict2[k]['否']['avg'] = round(v['否']['score']/v['否']['num'],2)\n",
|
||
" else:\n",
|
||
" dict2[k]['否']['avg'] = 0\n",
|
||
"list1 = [] \n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" unit = k\n",
|
||
" for k1, v1 in v.items():\n",
|
||
" daoban = k1\n",
|
||
" num = v1['num']\n",
|
||
" avg = v1['avg']\n",
|
||
" zhongyi = v1['zhongyi']\n",
|
||
" pianpo = v1['pianpo']\n",
|
||
" list2 = [k,daoban,num,avg,zhongyi,pianpo]\n",
|
||
" list1.append(list2)\n",
|
||
" \n",
|
||
"filename = 'data/天津倒班因素分析表.xlsx' \n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "2ccc4f6c-9cde-42d5-b41d-5b35ad86f042",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 工龄因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "695b4933-b8c3-4be6-a024-742a982f0abb",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(dict1[k]['unit'])\n",
|
||
"#print(unit)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" gld = int(int(v['gl'])/10)\n",
|
||
" dict2.setdefault(gld,{})\n",
|
||
" dict2[gld].setdefault(v['sex'],{})\n",
|
||
" dict2[gld][v['sex']].setdefault('num',0)\n",
|
||
" dict2[gld][v['sex']].setdefault('score',0)\n",
|
||
" dict2[gld][v['sex']].setdefault('zhongyi',0)\n",
|
||
" dict2[gld][v['sex']].setdefault('pianpo',0) \n",
|
||
" if 'avg' in v.keys():\n",
|
||
" dict2[gld][v['sex']]['num'] = dict2[gld][v['sex']]['num'] + 1\n",
|
||
" dict2[gld][v['sex']]['score'] = dict2[gld][v['sex']]['score'] + v['avg']\n",
|
||
" if 'zhongyi' in v.keys() :\n",
|
||
" dict2[gld][v['sex']]['zhongyi'] = dict2[gld][v['sex']]['zhongyi'] + 1\n",
|
||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||
" dict2[gld][v['sex']]['pianpo'] = dict2[gld][v['sex']]['pianpo'] + 1\n",
|
||
"nl = {}\n",
|
||
"nl[0] = '工龄0-9年'\n",
|
||
"nl[1] = '工龄10-19年'\n",
|
||
"nl[2] = '工龄20-29年'\n",
|
||
"nl[3] = '工龄30-39年'\n",
|
||
"nl[4] = '工龄40-49年'\n",
|
||
"nl[5] = '工龄50年以上'\n",
|
||
"list1 = [] \n",
|
||
"for k, v in nl.items():\n",
|
||
" list2 = []\n",
|
||
" gld = v\n",
|
||
" for k1, v1 in dict2[k].items():\n",
|
||
" num = v1['num']\n",
|
||
" score = v1['score']\n",
|
||
" zhongyi = v1['zhongyi']\n",
|
||
" pianpo = v1['pianpo']\n",
|
||
" list2 = [k,daoban,num,avg,zhongyi,pianpo]\n",
|
||
" list1.append(list2)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "181ff60b-3372-441a-8cd7-29e8de66ceb8",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(dict1[k]['unit'])\n",
|
||
"#print(unit)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" gld = int(int(v['gl'])/10)\n",
|
||
" dict2.setdefault(gld,{}) \n",
|
||
" dict2[gld].setdefault('num',0)\n",
|
||
" dict2[gld].setdefault('score',0)\n",
|
||
" dict2[gld].setdefault('zhongyi',0)\n",
|
||
" dict2[gld].setdefault('pianpo',0) \n",
|
||
" if 'avg' in v.keys():\n",
|
||
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||
" if 'zhongyi' in v.keys() :\n",
|
||
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||
"print(dict2)\n",
|
||
"nl = {}\n",
|
||
"nl[0] = '工龄0-9年'\n",
|
||
"nl[1] = '工龄10-19年'\n",
|
||
"nl[2] = '工龄20-29年'\n",
|
||
"nl[3] = '工龄30-39年'\n",
|
||
"nl[4] = '工龄40-49年'\n",
|
||
"nl[5] = '工龄50年以上'\n",
|
||
"list1 = [] \n",
|
||
"for k, v in nl.items():\n",
|
||
" list2 = []\n",
|
||
" gld = v\n",
|
||
" \n",
|
||
" num = dict2[k]['num']\n",
|
||
" score = dict2[k]['score']\n",
|
||
" if num > 0:\n",
|
||
" avg = round(score/num,2)\n",
|
||
" else:\n",
|
||
" avg = 0\n",
|
||
" zhongyi = dict2[k]['zhongyi']\n",
|
||
" pianpo = dict2[k]['pianpo']\n",
|
||
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/天津倒班因素分析表(工龄).xlsx' \n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "f8fa3027-c88a-43a1-88c8-c6e9b7e94f91",
|
||
"metadata": {},
|
||
"source": [
|
||
"#### 年龄因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "d5ab1a99-cb3e-4905-8c05-a6122ea09913",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(dict1[k]['unit'])\n",
|
||
"#print(unit)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" gld = int(int(v['age'])/10)\n",
|
||
" dict2.setdefault(gld,{}) \n",
|
||
" dict2[gld].setdefault('num',0)\n",
|
||
" dict2[gld].setdefault('score',0)\n",
|
||
" dict2[gld].setdefault('zhongyi',0)\n",
|
||
" dict2[gld].setdefault('pianpo',0) \n",
|
||
" if 'avg' in v.keys():\n",
|
||
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||
" if 'zhongyi' in v.keys() :\n",
|
||
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||
"nl = {}\n",
|
||
"\n",
|
||
"nl[2] = '20-29岁'\n",
|
||
"nl[3] = '30-39岁'\n",
|
||
"nl[4] = '40-49岁'\n",
|
||
"nl[5] = '50-59岁'\n",
|
||
"nl[6] = '60岁及以上'\n",
|
||
"list1 = [] \n",
|
||
"for k, v in nl.items():\n",
|
||
" list2 = []\n",
|
||
" gld = v\n",
|
||
" \n",
|
||
" num = dict2[k]['num']\n",
|
||
" score = dict2[k]['score']\n",
|
||
" if num > 0:\n",
|
||
" avg = round(score/num,2)\n",
|
||
" else:\n",
|
||
" avg = 0\n",
|
||
" zhongyi = dict2[k]['zhongyi']\n",
|
||
" pianpo = dict2[k]['pianpo']\n",
|
||
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/天津倒班因素分析表(年龄).xlsx' \n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "42e4ef5b-9aa8-4098-8f33-df9787dd34ab",
|
||
"metadata": {},
|
||
"source": [
|
||
"#### 倒班时间因素分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "255b5649-fb85-424d-9fad-0f3e1dff2be3",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(dict1[k]['unit'])\n",
|
||
"#print(unit)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" if v['daoban'] == '是':\n",
|
||
" \n",
|
||
" gld = int(int(v['gl'])/10)\n",
|
||
" dict2.setdefault(gld,{}) \n",
|
||
" dict2[gld].setdefault('num',0)\n",
|
||
" dict2[gld].setdefault('score',0)\n",
|
||
" dict2[gld].setdefault('zhongyi',0)\n",
|
||
" dict2[gld].setdefault('pianpo',0) \n",
|
||
" if 'avg' in v.keys():\n",
|
||
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||
" if 'zhongyi' in v.keys() :\n",
|
||
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||
"print(dict2)\n",
|
||
"nl = {}\n",
|
||
"nl[0] = '倒班工龄0-9年'\n",
|
||
"nl[1] = '倒班工龄10-19年'\n",
|
||
"nl[2] = '倒班工龄20-29年'\n",
|
||
"nl[3] = '倒班工龄30-39年'\n",
|
||
"nl[4] = '倒班工龄40-49年'\n",
|
||
"list1 = [] \n",
|
||
"for k, v in nl.items():\n",
|
||
" list2 = []\n",
|
||
" gld = v\n",
|
||
" \n",
|
||
" num = dict2[k]['num']\n",
|
||
" score = dict2[k]['score']\n",
|
||
" if num > 0:\n",
|
||
" avg = round(score/num,2)\n",
|
||
" else:\n",
|
||
" avg = 0\n",
|
||
" zhongyi = dict2[k]['zhongyi']\n",
|
||
" pianpo = dict2[k]['pianpo']\n",
|
||
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/天津倒班因素分析表(倒班工龄).xlsx' \n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "73524e7f-4262-46d3-a733-74ac18e43855",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"# 第二次体测"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "1be2bf2c-b1c8-494b-bc6b-681b9e75d18d",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 体测人员导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "25283932-c03a-4a34-a59d-314fc64d8fbd",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/天津石化员工检测花名册(20230915).xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"\n",
|
||
"for n in range(2, sheet.max_row+1):\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'] = sheet.cell(n, 5).value\n",
|
||
" dict1['sub_unit'] = sheet.cell(n, 6).value\n",
|
||
" dict1['birth'] = sheet.cell(n,4).value\n",
|
||
" person[code] = dict1\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "b758be8c-c9e2-46d4-b646-88403bb41e29",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生产读卡系统文件"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "c908e5e7-c014-4b8d-a583-a8c2f7115a96",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" dict2 = {}\n",
|
||
" #if dict1['sex'] =='男':\n",
|
||
" # sex = 1\n",
|
||
" \n",
|
||
" dict2 = {'id':k,'name':v['name'],'gender':v['sex'],'birth':v['birth'],'unit':v['unit']}\n",
|
||
" list1.append(dict2)\n",
|
||
"json_data = json.dumps(list1,ensure_ascii=False, indent=4) \n",
|
||
"\n",
|
||
"# 将 json 数据写入文件\n",
|
||
"with open(\"data/data1.json\", \"w\",encoding = 'utf-8') as file:\n",
|
||
" file.write(json_data) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "60f4831c-b44e-40d2-ad8a-d79079c071f9",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 获取人员测试成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "e26b88fc-c75b-4c1e-82ea-5017370afa9b",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\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",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20231017.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",
|
||
"#print(list1)\n",
|
||
"for result in list1:\n",
|
||
" user = str(result[2])\n",
|
||
" if user in dict1.keys(): \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]['unit'] = dict1[user]['unit']\n",
|
||
" re_ta[user]['sub_unit'] = dict1[user]['sub_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",
|
||
"print(len(re_ta))\n",
|
||
"filename = 'data/result_天津2023.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": "43bd1127-fa76-4c1e-8890-4bb47b28ecdf",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导出测试人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "0a6ea33d-c112-4ed8-9366-3376e55a5731",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_天津2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['unit'])\n",
|
||
" list2.append(dict2[k]['sub_unit'])\n",
|
||
" for item in items:\n",
|
||
" if item in v.keys():\n",
|
||
" list2.append(v[item]['成绩']) \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(v[item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/天津石化体测情况(截至20231017).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "4a53db48-365e-4056-8468-bbc829e83682",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计各部门测试情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "589a5d44-605d-41a1-a981-7ec7258305ed",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/result_天津2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"\n",
|
||
"dict3 = {}\n",
|
||
"for k, v in dict2.items():\n",
|
||
" unit = v['unit']\n",
|
||
" #sub_unit = v['sub_unit']\n",
|
||
" dict3.setdefault(unit,{})\n",
|
||
" dict3[unit].setdefault('人数',0)\n",
|
||
" #dict3[unit].setdefault(sub_unit,0)\n",
|
||
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] + 1\n",
|
||
" dict3[unit]['人数'] = dict3[unit]['人数'] + 1\n",
|
||
"\n",
|
||
"title =['单位','体测人数']\n",
|
||
"list1 = []\n",
|
||
"for k,v in dict1.items(): \n",
|
||
" unit = v['unit']\n",
|
||
" #sub_unit = v['sub_unit']\n",
|
||
" #dict3[unit][sub_unit] = dict3[unit][sub_unit] - 1\n",
|
||
" dict3[unit]['人数'] = dict3[unit]['人数'] - 1\n",
|
||
"for k, v in dict3.items():\n",
|
||
" list2 = [k,v['人数']]\n",
|
||
" list1.append(list2)\n",
|
||
"\n",
|
||
"filename = 'data/天津部门未测试情况(截至20231013).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d8e4038d-8ba0-48e7-b101-d30539cc2c2a",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计单一部门未体测人员明细表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "2f7c9847-f283-4a09-b385-2c7559be7c7e",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_天津2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"unit_name = '炼油部'\n",
|
||
"rq = '20231008'\n",
|
||
"list1 = []\n",
|
||
"\n",
|
||
"i = 1\n",
|
||
"for k, v in dict2.items():\n",
|
||
" unit = v['unit']\n",
|
||
" if unit == unit_name and k not in dict1.keys():\n",
|
||
" list2 = [i,k,v['name'],unit,v['sub_unit']]\n",
|
||
" i+=1\n",
|
||
" list1.append(list2)\n",
|
||
"filename = f'data/天津石化{unit_name}未测试人员名单(截至{rq}).xlsx'\n",
|
||
"title = ['序号','员工编号','姓名','部门','车间(科室)']\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row) \n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "a0754a83-0b8e-4bd8-9deb-b7d70a850f43",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计所有部门未体测人员明细表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "e47c361d-a047-4932-b24e-fdcf65cb8a73",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_天津2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"unit = set()\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit.add(v['unit'])\n",
|
||
"rq = '20231013'\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"for unit_name in unit:\n",
|
||
" list1 = []\n",
|
||
"\n",
|
||
" i = 1\n",
|
||
" for k, v in dict2.items():\n",
|
||
" unit = v['unit']\n",
|
||
" if unit == unit_name and k not in dict1.keys():\n",
|
||
" list2 = [i,k,v['name'],unit,v['sub_unit']]\n",
|
||
" i+=1\n",
|
||
" list1.append(list2)\n",
|
||
" filename = f'data/天津石化{unit_name}未测试人员名单(截至{rq}).xlsx'\n",
|
||
" title = ['序号','员工编号','姓名','部门','车间(科室)']\n",
|
||
" wb = openpyxl.Workbook()\n",
|
||
" sheet = wb.active\n",
|
||
" sheet.append(title)\n",
|
||
" for row in list1:\n",
|
||
" sheet.append(row) \n",
|
||
" wb.save(filename)\n",
|
||
" wb.close\n",
|
||
" print(f'{unit_name}未测试人员名单(截至{rq})生产成功!')\n",
|
||
"\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6246f8b0-d9fc-4c9a-8ffa-07bd8dcdc3ed",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计未体测人员明细表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "b7f62515-c45d-4d10-8e94-b5f9a9a98e3f",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_天津2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"\n",
|
||
"i = 1\n",
|
||
"for k, v in dict2.items():\n",
|
||
" \n",
|
||
" if k not in dict1.keys():\n",
|
||
" list2 = [i,k,v['name'],unit,v['sub_unit']]\n",
|
||
" i+=1\n",
|
||
" list1.append(list2)\n",
|
||
"filename = f'data/天津石化未测试人员名单.xlsx'\n",
|
||
"title = ['序号','员工编号','姓名','部门','车间(科室)']\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row) \n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "ed2a999f-47b9-4f36-88e2-354a0e37243b",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 转换报告格式"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "678ce52b-5368-4ec8-8b9e-0567895d856a",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20231017.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",
|
||
" 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",
|
||
" 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_天津231017.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": "code",
|
||
"execution_count": null,
|
||
"id": "17a9248a-18b3-4696-a895-dde38f7f88a5",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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",
|
||
"\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_天津231017.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_天津231017.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||
"print('ok!') "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "c1c98895-27e7-41c8-a43b-a63ebfa1c5e2",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成报告"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "f6171872-6b48-480a-b2c7-cf368d6cc6d8",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"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_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"fiie_path ='./134/'\n",
|
||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||
"i=1\n",
|
||
"list2 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list1 = []\n",
|
||
" mydata = {}\n",
|
||
" \n",
|
||
" id = str(k).rjust(8,\"0\")\n",
|
||
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
||
" mydata['title'] = '中石化(天津)石油化工\\n有限公司'\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",
|
||
" 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'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||
" if len(mydata['fits']) >2:\n",
|
||
" \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",
|
||
" #x.close()\n",
|
||
"print(i)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "489fdbe1-30ed-4630-b2fa-d926e41bdcc9",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 核对报告人数"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "906fa6c6-3446-4176-a443-fe16e52a8a3a",
|
||
"metadata": {
|
||
"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-old2/134'\n",
|
||
"\n",
|
||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||
"\n",
|
||
"filename = 'data/result_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"for fn in fls:\n",
|
||
" fi_name =Path(fn).stem.split('-')[0]\n",
|
||
" code = int(fi_name)\n",
|
||
" list1.append(str(code))\n",
|
||
"for k, v in dict1.items():\n",
|
||
" if k not in list1:\n",
|
||
" print(k,v['name'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "cb587095-1a0c-4ab1-b9e5-e9e5b0d52cee",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 报告按部门分类"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "3fa6a1a9-63af-4f4e-9d30-b94f4357f7dc",
|
||
"metadata": {
|
||
"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/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": "code",
|
||
"execution_count": null,
|
||
"id": "3f75763f-79bd-4a8c-9612-2eba89ce32f1",
|
||
"metadata": {
|
||
"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/134'\n",
|
||
"new_path = 'file/134_2'\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",
|
||
" if dict1[str(code)]['sex'] =='男': \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": "fdcd8ea1-21ab-48ab-b7cc-0dad65b06bf2",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成体测报告打印明细表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "623671be-cef0-4a2c-bf1a-889ab159760f",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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/134'\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",
|
||
"for fn in fls:\n",
|
||
" list2 = []\n",
|
||
" fi_name =Path(fn).stem.split('-')[0] \n",
|
||
" code = int(fi_name)\n",
|
||
" unit = dict1[str(code)]['unit']\n",
|
||
" list2 = [fi_name,Path(fn).stem.split('-')[1],unit]\n",
|
||
" \n",
|
||
" list1.append(list2)\n",
|
||
"print(list1)\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": "91fbc553-da7c-4c1e-bcf3-944dc59204b6",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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/134'\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",
|
||
"for fn in fls:\n",
|
||
" list2 = []\n",
|
||
" fi_name =Path(fn).stem.split('-')[0] \n",
|
||
" code = int(fi_name)\n",
|
||
" if dict1[str(code)]['sex'] =='男':\n",
|
||
" unit = dict1[str(code)]['unit']\n",
|
||
" list2 = [fi_name,Path(fn).stem.split('-')[1],unit]\n",
|
||
" \n",
|
||
" list1.append(list2)\n",
|
||
"print(list1)\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": "markdown",
|
||
"id": "4a075c1b-41d9-4ff5-8f0a-115127e5e155",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成体测成绩明细表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "b363792b-cbc6-46a7-b87f-1e122bcb116e",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||
"bmi = ['height','weight']\n",
|
||
"title = ['编号','姓名','性别','单位/部门','身高','体重','bmi','肺活量','','握力','','坐位体前屈','','纵跳','','俯卧撑','','一分钟仰卧起坐','','单脚站立','','选择反应时','','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items(): #print(k,dict2[str(k)]['name'])\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(dict1[k]['name']) \n",
|
||
" list2.append(dict1[k]['sex'])\n",
|
||
" list2.append(dict1[k]['unit'])\n",
|
||
" i = 0\n",
|
||
" if 'bmi' in dict1[k].keys():\n",
|
||
" list2.append(dict1[k]['height']['成绩'])\n",
|
||
" list2.append(dict1[k]['weight']['成绩'])\n",
|
||
" list2.append(dict1[k]['bmi']['score'])\n",
|
||
" i+=1\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list2.append('') \n",
|
||
" list2.append('') \n",
|
||
" \n",
|
||
" \n",
|
||
" for item in items:\n",
|
||
" if item in dict1[k].keys():\n",
|
||
" list2.append(dict1[k][item]['成绩'])\n",
|
||
" list2.append(dict1[k][item]['score']) \n",
|
||
" i+=1\n",
|
||
" elif item =='name':\n",
|
||
" list2.append(dict1[k][item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list2.append('') \n",
|
||
" if i>2:\n",
|
||
" list1.append(list2)\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": "markdown",
|
||
"id": "5608369a-f33f-4c02-a68f-f4f7bb410069",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 生成新格式文件"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "8397633f-fddb-4cfa-b9bd-e38f3fe6772c",
|
||
"metadata": {
|
||
"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/134'\n",
|
||
"new_path = 'file/134_1'\n",
|
||
"old = []\n",
|
||
"filename = 'data/result_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||
"i =0\n",
|
||
"for fn in fls:\n",
|
||
" code =str(int(Path(fn).stem.split('-')[0]))\n",
|
||
" if code in dict1.keys():\n",
|
||
" i+=1\n",
|
||
" #print(i,code,dict1[code]['rq'].replace('-',''))\n",
|
||
" \n",
|
||
" n_name = Path(new_path,code.rjust(8,'0')+'_'+dict1[code]['rq'].replace('-','')+'.pdf')\n",
|
||
" #print(i,n_name)\n",
|
||
" if not os.path.exists(n_name):\n",
|
||
" shutil.copyfile(fn,n_name)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "5facc164-841c-4866-8a2c-2d54f72d6a0b",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导入网上问卷内容"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "35d1738a-1ec1-4764-bcbd-c1333fac6bfd",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"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/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict3 = json.load(fl)\n",
|
||
"\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/Survey_20231116.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",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"for item in list1:\n",
|
||
" psy = []\n",
|
||
" tcm = []\n",
|
||
" spine = []\n",
|
||
" for i in range(0,45):\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",
|
||
" print(item)\n",
|
||
" content = json.loads(item[5])\n",
|
||
" if str(item[4]) not in dict1.keys():\n",
|
||
" dict1[str(item[4])] = dict3[str(item[4])]\n",
|
||
" rq = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||
" #dict1[phone[item[2]]]['rq'] = date.fromisoformat(item[6].replace('/','-').split(' ')[0])\n",
|
||
" for k, v in content.items():\n",
|
||
" if 'psy' in k:\n",
|
||
" i = int(k[3:])\n",
|
||
" psy[i-1] = int(v)\n",
|
||
" if 'tcm' in k:\n",
|
||
" i = int(k[3:])\n",
|
||
" tcm[i-1] = int(v)\n",
|
||
" if 'spine' in k:\n",
|
||
" i = int(k[5:])\n",
|
||
" spine[i-1] = int(v)\n",
|
||
" if 'psy' in item[5]:\n",
|
||
" for i in range(5,26):\n",
|
||
" new_valve = 5-psy[i]\n",
|
||
" psy[i] = new_valve\n",
|
||
" for i in range(26,40):\n",
|
||
" new_valve = 1+psy[i]\n",
|
||
" psy[i] = new_valve\n",
|
||
" psy[44] = []\n",
|
||
" dict1[str(item[4])]['psy'] = psy\n",
|
||
" if 'tcm' in item[5]:\n",
|
||
" dict1[str(item[4])]['tcm'] = tcm\n",
|
||
" if 'spine' in item[5]:\n",
|
||
" dict1[str(item[4])]['spine'] = spine\n",
|
||
" birth = date.fromisoformat(dict3[str(item[4])]['birth'].replace('/','-'))\n",
|
||
"\n",
|
||
" days = (rq-birth).days \n",
|
||
" dict1[str(item[4])]['age'] = int(days/365)\n",
|
||
" dict1[str(item[4])]['month'] = int(days/365*12)\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": "code",
|
||
"execution_count": null,
|
||
"id": "d842c189-dcc2-4e31-9bc2-e272c929e6af",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "cc9e1717-f445-49a9-a770-c103da603434",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import requests\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"\n",
|
||
"headers = {\n",
|
||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||
" }\n",
|
||
"filename = 'data/result_天津问卷.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"fiie_path ='./政法委1/'\n",
|
||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||
"i = 27\n",
|
||
"list2 = []\n",
|
||
"#list1 = []\n",
|
||
"for k,v in dict1.items(): \n",
|
||
" list1 = []\n",
|
||
" mydata = {} \n",
|
||
" id = k.rjust(3,\"0\")\n",
|
||
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
||
" mydata['title'] = '中石化(天津)石油化工\\n有限公司'\n",
|
||
" #mydata['subtitle'] = ''\n",
|
||
" mydata['id'] = id\n",
|
||
" mydata['name'] = v['name']\n",
|
||
" if v['sex'] == '男':\n",
|
||
" mydata['gender'] = 'male'\n",
|
||
" else:\n",
|
||
" mydata['gender'] = 'female' \n",
|
||
" mydata['month'] = v['month']\n",
|
||
" \n",
|
||
" if 'tcm' in v.keys():\n",
|
||
" mydata.setdefault('surveys',{})\n",
|
||
" mydata['surveys']['tcm'] = v['tcm']\n",
|
||
" if 'psy' in v.keys():\n",
|
||
" mydata.setdefault('surveys',{})\n",
|
||
" mydata['surveys']['psy'] = v['psy']\n",
|
||
" if 'tcm' in v.keys():\n",
|
||
" mydata.setdefault('surveys',{})\n",
|
||
" mydata['surveys']['spine'] = v['spine']\n",
|
||
" \n",
|
||
" \n",
|
||
" \n",
|
||
" list1.append(mydata)\n",
|
||
" #list2.append([k,dict1[k]['name']])\n",
|
||
"\n",
|
||
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||
" print(id,dict1[k]['name'],x.text)\n",
|
||
" x.close()\n",
|
||
" #print(mydata)\n",
|
||
"#filename = 'data/data_天津问卷.json'\n",
|
||
"\n",
|
||
"#with open(filename,'w') as fl:\n",
|
||
"# json.dump(list1, fl, ensure_ascii=False) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-10-25T02:50:56.997544Z",
|
||
"iopub.status.busy": "2023-10-25T02:50:56.995911Z",
|
||
"iopub.status.idle": "2023-10-25T02:50:57.006678Z",
|
||
"shell.execute_reply": "2023-10-25T02:50:57.004773Z",
|
||
"shell.execute_reply.started": "2023-10-25T02:50:56.997463Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"# 体测数据分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "dca06570-73e6-4f60-8cf9-b3f9da64f1c4",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 清理报告数据"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "f9fee64f-41ff-4453-8a32-a33df086022e",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/result_天津231017.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",
|
||
"fiie_path ='./134/'\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",
|
||
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
|
||
" if len(mydata['fits']) >2:\n",
|
||
" dict2[str(k)] = mydata\n",
|
||
"filename = f'data/data_天津231017.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||
"print('ok!') "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "bd1f8f42-c14a-4bb7-8656-14a0f7968cfc",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 计算测试等级"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "006afc6c-2b1f-4edf-be1b-5f60e2029ee8",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017_非倒班.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": "ed3c0653-087a-4a9d-ba21-8cf5f48515d9",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 根据年龄汇总人员信息及成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "949e4c3c-023d-44a4-b99e-c5460da61161",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"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": "markdown",
|
||
"id": "6a967a44-7c12-4e82-827b-d75926c09e77",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 根据年龄汇总人员信息及成绩(男)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "721977d3-5816-4bf6-82fc-26fd170e5454",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\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) and v['sex'] == '男':\n",
|
||
" score = score+v['score']\n",
|
||
" i+=1\n",
|
||
" \n",
|
||
" \n",
|
||
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "3a8f747e-aacd-45bf-b94a-b505cfd31922",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 根据年龄汇总人员信息及成绩(女)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "f493dc0a-d3cd-4dbd-ad35-e06eb96afbc5",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\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) and v['sex'] == '女':\n",
|
||
" score = score+v['score']\n",
|
||
" i+=1\n",
|
||
" \n",
|
||
" \n",
|
||
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "e9c6bd2e-b6ac-4a6f-ba28-aafcabb40c0d",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 计算平均成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "7155f2c2-0719-4558-aa3b-629fb70194d6",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n",
|
||
"#filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"i = 1\n",
|
||
"m = 0\n",
|
||
"f = 0\n",
|
||
"score = 0\n",
|
||
"t_score = 0\n",
|
||
"for k,v in dict1.items():\n",
|
||
" if v['sex'] == '男':\n",
|
||
" m = m +1\n",
|
||
" score = score+v['score']\n",
|
||
"print(f'平均成绩:{round(score/m,4)}分,男性:{m}人')\n",
|
||
"t_score = t_score + score\n",
|
||
"score = 0\n",
|
||
"for k,v in dict1.items():\n",
|
||
" if v['sex'] == '女':\n",
|
||
" f = f +1\n",
|
||
" score = score+v['score']\n",
|
||
"print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')\n",
|
||
"t_score = t_score + score\n",
|
||
"print(f'平均成绩:{round(t_score/3657,4)}分,总体:3657人')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "9a544eec-ec58-47dc-aa36-d890b0b309c2",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 计算测试等级"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "a0bbb339-ee4e-4dc1-83ec-b2055e3c670e",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"\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",
|
||
"#filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "92103efb-a3e4-43ec-acfb-e4cb0b07c2fb",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 计算各年龄段测试等级(女)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "f8949993-7501-4359-aa7c-2cd5de348056",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"\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",
|
||
"#filename = 'data/result_石家庄.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "194217e0-f1cf-4945-ad5a-52304ed2f943",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 计算各项目成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "5ed284c6-1a1c-43ab-92a8-b3c411cd77a1",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"for item in items:\n",
|
||
" score = 0\n",
|
||
" n = 0\n",
|
||
" for k, v in dict1.items(): \n",
|
||
" if item in v['fits'].keys():\n",
|
||
" n = n + 1\n",
|
||
" score =score + int(v['fits'][item]['score'])\n",
|
||
" print(item,round(score/n,2),n)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "5a130857-4dd1-4b5e-b21b-42fe32b367cf",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 按部门统计"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "cb1e13ae-3eba-4f6e-b70a-2bf87168ef1a",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 计算部门完成情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "5e7c1c49-75bf-4238-9bd7-b8511687f639",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"dict3 = {}\n",
|
||
"\n",
|
||
"for k, v in dict2.items():\n",
|
||
" unit = v['unit']\n",
|
||
" dict3.setdefault(unit,{})\n",
|
||
" dict3[unit].setdefault('应测',0)\n",
|
||
" dict3[unit].setdefault('已测',0)\n",
|
||
" dict3[unit]['应测']+=1\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['unit']\n",
|
||
" \n",
|
||
" dict3[unit]['已测']+=1\n",
|
||
" \n",
|
||
"print(dict3)\n",
|
||
"for k ,v in dict3.items():\n",
|
||
" print(k,v['应测'],v['已测'])\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "e83941b9-b2b5-41db-b08a-a619f07c2487",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-08T13:52:50.838712Z",
|
||
"iopub.status.busy": "2023-11-08T13:52:50.838249Z",
|
||
"iopub.status.idle": "2023-11-08T13:52:50.844168Z",
|
||
"shell.execute_reply": "2023-11-08T13:52:50.843014Z",
|
||
"shell.execute_reply.started": "2023-11-08T13:52:50.838676Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 计算部门合格率"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "d023724c-46b7-4b4e-bbcc-8b4f171590c5",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['unit']\n",
|
||
" dict3[unit].setdefault(v['level'],0)\n",
|
||
" dict3[unit][v['level']]+=1\n",
|
||
"print(dict3)\n",
|
||
"for k ,v in dict3.items():\n",
|
||
" print(k,v['已测'],v['不合格'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "4b996a8a-70e7-4c95-8b14-0f8fa89df7a4",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 计算部门成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 313,
|
||
"id": "1d93d58e-115a-44a4-988f-fa5353c5fd0e",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-30T08:51:59.424777Z",
|
||
"iopub.status.busy": "2023-11-30T08:51:59.424310Z",
|
||
"iopub.status.idle": "2023-11-30T08:51:59.549563Z",
|
||
"shell.execute_reply": "2023-11-30T08:51:59.548780Z",
|
||
"shell.execute_reply.started": "2023-11-30T08:51:59.424741Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"{'化验计量部': {'BMI': {'score': 1724, 'count': 464}, '肺活量': {'score': 1482, 'count': 447}, '握力': {'score': 546, 'count': 445}, '坐位体前屈': {'score': 969, 'count': 373}, '纵跳': {'score': 659, 'count': 375}, '俯卧撑': {'score': 408, 'count': 165}, '一分钟仰卧起坐': {'score': 486, 'count': 131}, '单脚站立': {'score': 896, 'count': 443}, '选择反应时': {'score': 1266, 'count': 447}, '台阶指数': {'score': 366, 'count': 143}}, '南港烯烃部': {'BMI': {'score': 2220, 'count': 680}, '肺活量': {'score': 2389, 'count': 674}, '握力': {'score': 753, 'count': 664}, '坐位体前屈': {'score': 1747, 'count': 631}, '纵跳': {'score': 1324, 'count': 630}, '俯卧撑': {'score': 1140, 'count': 444}, '一分钟仰卧起坐': {'score': 548, 'count': 144}, '单脚站立': {'score': 1189, 'count': 665}, '选择反应时': {'score': 1770, 'count': 678}, '台阶指数': {'score': 802, 'count': 381}}, '消防支队': {'BMI': {'score': 258, 'count': 72}, '肺活量': {'score': 228, 'count': 72}, '握力': {'score': 92, 'count': 71}, '坐位体前屈': {'score': 169, 'count': 60}, '纵跳': {'score': 86, 'count': 62}, '俯卧撑': {'score': 154, 'count': 51}, '一分钟仰卧起坐': {'score': 22, 'count': 7}, '单脚站立': {'score': 129, 'count': 67}, '选择反应时': {'score': 213, 'count': 70}, '台阶指数': {'score': 69, 'count': 26}}, '炼油部': {'BMI': {'score': 4052, 'count': 1178}, '肺活量': {'score': 3865, 'count': 1181}, '握力': {'score': 2106, 'count': 1184}, '坐位体前屈': {'score': 3324, 'count': 1075}, '纵跳': {'score': 2208, 'count': 1044}, '俯卧撑': {'score': 1730, 'count': 761}, '一分钟仰卧起坐': {'score': 778, 'count': 210}, '单脚站立': {'score': 2154, 'count': 1155}, '选择反应时': {'score': 3554, 'count': 1175}, '台阶指数': {'score': 1441, 'count': 542}}, '化工部': {'BMI': {'score': 1824, 'count': 516}, '肺活量': {'score': 1578, 'count': 508}, '握力': {'score': 630, 'count': 517}, '坐位体前屈': {'score': 1323, 'count': 431}, '纵跳': {'score': 822, 'count': 430}, '俯卧撑': {'score': 699, 'count': 295}, '一分钟仰卧起坐': {'score': 367, 'count': 94}, '单脚站立': {'score': 1030, 'count': 499}, '选择反应时': {'score': 1535, 'count': 512}, '台阶指数': {'score': 508, 'count': 175}}, '电仪部': {'BMI': {'score': 1088, 'count': 322}, '肺活量': {'score': 1054, 'count': 317}, '握力': {'score': 394, 'count': 319}, '坐位体前屈': {'score': 734, 'count': 284}, '纵跳': {'score': 500, 'count': 299}, '俯卧撑': {'score': 561, 'count': 223}, '一分钟仰卧起坐': {'score': 183, 'count': 50}, '单脚站立': {'score': 575, 'count': 319}, '选择反应时': {'score': 827, 'count': 318}, '台阶指数': {'score': 452, 'count': 178}}, '物资采购中心': {'BMI': {'score': 289, 'count': 83}, '肺活量': {'score': 280, 'count': 83}, '握力': {'score': 93, 'count': 82}, '坐位体前屈': {'score': 207, 'count': 69}, '纵跳': {'score': 143, 'count': 79}, '俯卧撑': {'score': 96, 'count': 36}, '一分钟仰卧起坐': {'score': 108, 'count': 26}, '单脚站立': {'score': 184, 'count': 77}, '选择反应时': {'score': 260, 'count': 81}, '台阶指数': {'score': 76, 'count': 27}}, '水务部': {'BMI': {'score': 1381, 'count': 395}, '肺活量': {'score': 1242, 'count': 386}, '握力': {'score': 488, 'count': 394}, '坐位体前屈': {'score': 876, 'count': 313}, '纵跳': {'score': 556, 'count': 315}, '俯卧撑': {'score': 522, 'count': 199}, '一分钟仰卧起坐': {'score': 257, 'count': 65}, '单脚站立': {'score': 788, 'count': 382}, '选择反应时': {'score': 1182, 'count': 391}, '台阶指数': {'score': 305, 'count': 116}}, '运输销售部': {'BMI': {'score': 723, 'count': 197}, '肺活量': {'score': 570, 'count': 186}, '握力': {'score': 249, 'count': 192}, '坐位体前屈': {'score': 401, 'count': 138}, '纵跳': {'score': 236, 'count': 158}, '俯卧撑': {'score': 263, 'count': 123}, '一分钟仰卧起坐': {'score': 97, 'count': 23}, '单脚站立': {'score': 328, 'count': 183}, '选择反应时': {'score': 584, 'count': 195}, '台阶指数': {'score': 68, 'count': 24}}, '原油储运部': {'BMI': {'score': 600, 'count': 176}, '肺活量': {'score': 574, 'count': 175}, '握力': {'score': 215, 'count': 176}, '坐位体前屈': {'score': 378, 'count': 146}, '纵跳': {'score': 291, 'count': 154}, '俯卧撑': {'score': 268, 'count': 105}, '一分钟仰卧起坐': {'score': 133, 'count': 37}, '单脚站立': {'score': 355, 'count': 174}, '选择反应时': {'score': 503, 'count': 177}, '台阶指数': {'score': 193, 'count': 79}}, '聚醚部': {'BMI': {'score': 407, 'count': 109}, '肺活量': {'score': 378, 'count': 107}, '握力': {'score': 149, 'count': 109}, '坐位体前屈': {'score': 280, 'count': 100}, '纵跳': {'score': 176, 'count': 100}, '俯卧撑': {'score': 136, 'count': 56}, '一分钟仰卧起坐': {'score': 114, 'count': 27}, '单脚站立': {'score': 209, 'count': 108}, '选择反应时': {'score': 345, 'count': 110}, '台阶指数': {'score': 105, 'count': 36}}, '公司机关': {'BMI': {'score': 416, 'count': 112}, '肺活量': {'score': 381, 'count': 112}, '握力': {'score': 125, 'count': 108}, '坐位体前屈': {'score': 272, 'count': 101}, '纵跳': {'score': 220, 'count': 100}, '俯卧撑': {'score': 160, 'count': 53}, '一分钟仰卧起坐': {'score': 120, 'count': 30}, '单脚站立': {'score': 225, 'count': 106}, '选择反应时': {'score': 310, 'count': 110}, '台阶指数': {'score': 135, 'count': 51}}, '南港乙烯项目管理部': {'BMI': {'score': 65, 'count': 15}, '肺活量': {'score': 58, 'count': 15}, '握力': {'score': 13, 'count': 13}, '坐位体前屈': {'score': 34, 'count': 13}, '纵跳': {'score': 27, 'count': 15}, '俯卧撑': {'score': 39, 'count': 13}, '一分钟仰卧起坐': {'score': 0, 'count': 0}, '单脚站立': {'score': 20, 'count': 15}, '选择反应时': {'score': 40, 'count': 15}, '台阶指数': {'score': 29, 'count': 10}}, '党委党校(培训中心)': {'BMI': {'score': 192, 'count': 48}, '肺活量': {'score': 161, 'count': 44}, '握力': {'score': 43, 'count': 43}, '坐位体前屈': {'score': 119, 'count': 40}, '纵跳': {'score': 80, 'count': 44}, '俯卧撑': {'score': 44, 'count': 18}, '一分钟仰卧起坐': {'score': 59, 'count': 15}, '单脚站立': {'score': 101, 'count': 42}, '选择反应时': {'score': 159, 'count': 48}, '台阶指数': {'score': 53, 'count': 18}}, '装备研究院': {'BMI': {'score': 202, 'count': 48}, '肺活量': {'score': 175, 'count': 48}, '握力': {'score': 57, 'count': 48}, '坐位体前屈': {'score': 122, 'count': 46}, '纵跳': {'score': 93, 'count': 45}, '俯卧撑': {'score': 57, 'count': 25}, '一分钟仰卧起坐': {'score': 45, 'count': 10}, '单脚站立': {'score': 99, 'count': 47}, '选择反应时': {'score': 145, 'count': 48}, '台阶指数': {'score': 33, 'count': 13}}, '热电部': {'BMI': {'score': 1457, 'count': 411}, '肺活量': {'score': 1332, 'count': 404}, '握力': {'score': 593, 'count': 407}, '坐位体前屈': {'score': 932, 'count': 333}, '纵跳': {'score': 693, 'count': 335}, '俯卧撑': {'score': 689, 'count': 255}, '一分钟仰卧起坐': {'score': 164, 'count': 42}, '单脚站立': {'score': 781, 'count': 390}, '选择反应时': {'score': 1231, 'count': 407}, '台阶指数': {'score': 386, 'count': 135}}, '烯烃部': {'BMI': {'score': 1173, 'count': 317}, '肺活量': {'score': 993, 'count': 318}, '握力': {'score': 426, 'count': 318}, '坐位体前屈': {'score': 779, 'count': 256}, '纵跳': {'score': 509, 'count': 266}, '俯卧撑': {'score': 409, 'count': 165}, '一分钟仰卧起坐': {'score': 257, 'count': 65}, '单脚站立': {'score': 647, 'count': 311}, '选择反应时': {'score': 983, 'count': 317}, '台阶指数': {'score': 332, 'count': 117}}, '行政事务中心': {'BMI': {'score': 157, 'count': 41}, '肺活量': {'score': 111, 'count': 36}, '握力': {'score': 53, 'count': 40}, '坐位体前屈': {'score': 78, 'count': 32}, '纵跳': {'score': 68, 'count': 40}, '俯卧撑': {'score': 65, 'count': 19}, '一分钟仰卧起坐': {'score': 64, 'count': 15}, '单脚站立': {'score': 83, 'count': 39}, '选择反应时': {'score': 121, 'count': 41}, '台阶指数': {'score': 51, 'count': 19}}, '信息档案管理中心': {'BMI': {'score': 245, 'count': 59}, '肺活量': {'score': 219, 'count': 59}, '握力': {'score': 63, 'count': 60}, '坐位体前屈': {'score': 162, 'count': 53}, '纵跳': {'score': 103, 'count': 56}, '俯卧撑': {'score': 73, 'count': 25}, '一分钟仰卧起坐': {'score': 86, 'count': 21}, '单脚站立': {'score': 146, 'count': 59}, '选择反应时': {'score': 189, 'count': 59}, '台阶指数': {'score': 98, 'count': 34}}, '研究院': {'BMI': {'score': 405, 'count': 101}, '肺活量': {'score': 346, 'count': 98}, '握力': {'score': 132, 'count': 101}, '坐位体前屈': {'score': 245, 'count': 87}, '纵跳': {'score': 166, 'count': 85}, '俯卧撑': {'score': 170, 'count': 54}, '一分钟仰卧起坐': {'score': 92, 'count': 22}, '单脚站立': {'score': 213, 'count': 99}, '选择反应时': {'score': 337, 'count': 101}, '台阶指数': {'score': 119, 'count': 40}}}\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
|
||
"filename = 'data/data_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/天津石化人员名单2023.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"dict3 = {}\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['unit']\n",
|
||
" dict3.setdefault(unit,{})\n",
|
||
" for item in items:\n",
|
||
" dict3[unit].setdefault(item,{})\n",
|
||
" dict3[unit][item].setdefault('score',0)\n",
|
||
" dict3[unit][item].setdefault('count',0)\n",
|
||
" for k1,v1 in v['fits'].items():\n",
|
||
" if k1 in items:\n",
|
||
" dict3[unit][k1]['score']+=v1['score']\n",
|
||
" dict3[unit][k1]['count']+=1\n",
|
||
"print(dict3)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "23a654a2-69f1-41cb-b3dc-23bc7dc7e294",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 显示部门成绩"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 314,
|
||
"id": "0cb7ff83-69a9-4c03-a539-bde7ffd4a8a8",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-30T08:52:12.537328Z",
|
||
"iopub.status.busy": "2023-11-30T08:52:12.536920Z",
|
||
"iopub.status.idle": "2023-11-30T08:52:12.543150Z",
|
||
"shell.execute_reply": "2023-11-30T08:52:12.542704Z",
|
||
"shell.execute_reply.started": "2023-11-30T08:52:12.537297Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"化验计量部\n",
|
||
"BMI 3.7155\n",
|
||
"肺活量 3.3154\n",
|
||
"握力 1.227\n",
|
||
"坐位体前屈 2.5979\n",
|
||
"纵跳 1.7573\n",
|
||
"俯卧撑 2.4727\n",
|
||
"一分钟仰卧起坐 3.7099\n",
|
||
"单脚站立 2.0226\n",
|
||
"选择反应时 2.8322\n",
|
||
"台阶指数 2.5594\n",
|
||
"\n",
|
||
"南港烯烃部\n",
|
||
"BMI 3.2647\n",
|
||
"肺活量 3.5445\n",
|
||
"握力 1.134\n",
|
||
"坐位体前屈 2.7686\n",
|
||
"纵跳 2.1016\n",
|
||
"俯卧撑 2.5676\n",
|
||
"一分钟仰卧起坐 3.8056\n",
|
||
"单脚站立 1.788\n",
|
||
"选择反应时 2.6106\n",
|
||
"台阶指数 2.105\n",
|
||
"\n",
|
||
"消防支队\n",
|
||
"BMI 3.5833\n",
|
||
"肺活量 3.1667\n",
|
||
"握力 1.2958\n",
|
||
"坐位体前屈 2.8167\n",
|
||
"纵跳 1.3871\n",
|
||
"俯卧撑 3.0196\n",
|
||
"一分钟仰卧起坐 3.1429\n",
|
||
"单脚站立 1.9254\n",
|
||
"选择反应时 3.0429\n",
|
||
"台阶指数 2.6538\n",
|
||
"\n",
|
||
"炼油部\n",
|
||
"BMI 3.4397\n",
|
||
"肺活量 3.2727\n",
|
||
"握力 1.7787\n",
|
||
"坐位体前屈 3.0921\n",
|
||
"纵跳 2.1149\n",
|
||
"俯卧撑 2.2733\n",
|
||
"一分钟仰卧起坐 3.7048\n",
|
||
"单脚站立 1.8649\n",
|
||
"选择反应时 3.0247\n",
|
||
"台阶指数 2.6587\n",
|
||
"\n",
|
||
"化工部\n",
|
||
"BMI 3.5349\n",
|
||
"肺活量 3.1063\n",
|
||
"握力 1.2186\n",
|
||
"坐位体前屈 3.0696\n",
|
||
"纵跳 1.9116\n",
|
||
"俯卧撑 2.3695\n",
|
||
"一分钟仰卧起坐 3.9043\n",
|
||
"单脚站立 2.0641\n",
|
||
"选择反应时 2.998\n",
|
||
"台阶指数 2.9029\n",
|
||
"\n",
|
||
"电仪部\n",
|
||
"BMI 3.3789\n",
|
||
"肺活量 3.3249\n",
|
||
"握力 1.2351\n",
|
||
"坐位体前屈 2.5845\n",
|
||
"纵跳 1.6722\n",
|
||
"俯卧撑 2.5157\n",
|
||
"一分钟仰卧起坐 3.66\n",
|
||
"单脚站立 1.8025\n",
|
||
"选择反应时 2.6006\n",
|
||
"台阶指数 2.5393\n",
|
||
"\n",
|
||
"物资采购中心\n",
|
||
"BMI 3.4819\n",
|
||
"肺活量 3.3735\n",
|
||
"握力 1.1341\n",
|
||
"坐位体前屈 3.0\n",
|
||
"纵跳 1.8101\n",
|
||
"俯卧撑 2.6667\n",
|
||
"一分钟仰卧起坐 4.1538\n",
|
||
"单脚站立 2.3896\n",
|
||
"选择反应时 3.2099\n",
|
||
"台阶指数 2.8148\n",
|
||
"\n",
|
||
"水务部\n",
|
||
"BMI 3.4962\n",
|
||
"肺活量 3.2176\n",
|
||
"握力 1.2386\n",
|
||
"坐位体前屈 2.7987\n",
|
||
"纵跳 1.7651\n",
|
||
"俯卧撑 2.6231\n",
|
||
"一分钟仰卧起坐 3.9538\n",
|
||
"单脚站立 2.0628\n",
|
||
"选择反应时 3.023\n",
|
||
"台阶指数 2.6293\n",
|
||
"\n",
|
||
"运输销售部\n",
|
||
"BMI 3.6701\n",
|
||
"肺活量 3.0645\n",
|
||
"握力 1.2969\n",
|
||
"坐位体前屈 2.9058\n",
|
||
"纵跳 1.4937\n",
|
||
"俯卧撑 2.1382\n",
|
||
"一分钟仰卧起坐 4.2174\n",
|
||
"单脚站立 1.7923\n",
|
||
"选择反应时 2.9949\n",
|
||
"台阶指数 2.8333\n",
|
||
"\n",
|
||
"原油储运部\n",
|
||
"BMI 3.4091\n",
|
||
"肺活量 3.28\n",
|
||
"握力 1.2216\n",
|
||
"坐位体前屈 2.589\n",
|
||
"纵跳 1.8896\n",
|
||
"俯卧撑 2.5524\n",
|
||
"一分钟仰卧起坐 3.5946\n",
|
||
"单脚站立 2.0402\n",
|
||
"选择反应时 2.8418\n",
|
||
"台阶指数 2.443\n",
|
||
"\n",
|
||
"聚醚部\n",
|
||
"BMI 3.7339\n",
|
||
"肺活量 3.5327\n",
|
||
"握力 1.367\n",
|
||
"坐位体前屈 2.8\n",
|
||
"纵跳 1.76\n",
|
||
"俯卧撑 2.4286\n",
|
||
"一分钟仰卧起坐 4.2222\n",
|
||
"单脚站立 1.9352\n",
|
||
"选择反应时 3.1364\n",
|
||
"台阶指数 2.9167\n",
|
||
"\n",
|
||
"公司机关\n",
|
||
"BMI 3.7143\n",
|
||
"肺活量 3.4018\n",
|
||
"握力 1.1574\n",
|
||
"坐位体前屈 2.6931\n",
|
||
"纵跳 2.2\n",
|
||
"俯卧撑 3.0189\n",
|
||
"一分钟仰卧起坐 4.0\n",
|
||
"单脚站立 2.1226\n",
|
||
"选择反应时 2.8182\n",
|
||
"台阶指数 2.6471\n",
|
||
"\n",
|
||
"南港乙烯项目管理部\n",
|
||
"BMI 4.3333\n",
|
||
"肺活量 3.8667\n",
|
||
"握力 1.0\n",
|
||
"坐位体前屈 2.6154\n",
|
||
"纵跳 1.8\n",
|
||
"俯卧撑 3.0\n",
|
||
"单脚站立 1.3333\n",
|
||
"选择反应时 2.6667\n",
|
||
"台阶指数 2.9\n",
|
||
"\n",
|
||
"党委党校(培训中心)\n",
|
||
"BMI 4.0\n",
|
||
"肺活量 3.6591\n",
|
||
"握力 1.0\n",
|
||
"坐位体前屈 2.975\n",
|
||
"纵跳 1.8182\n",
|
||
"俯卧撑 2.4444\n",
|
||
"一分钟仰卧起坐 3.9333\n",
|
||
"单脚站立 2.4048\n",
|
||
"选择反应时 3.3125\n",
|
||
"台阶指数 2.9444\n",
|
||
"\n",
|
||
"装备研究院\n",
|
||
"BMI 4.2083\n",
|
||
"肺活量 3.6458\n",
|
||
"握力 1.1875\n",
|
||
"坐位体前屈 2.6522\n",
|
||
"纵跳 2.0667\n",
|
||
"俯卧撑 2.28\n",
|
||
"一分钟仰卧起坐 4.5\n",
|
||
"单脚站立 2.1064\n",
|
||
"选择反应时 3.0208\n",
|
||
"台阶指数 2.5385\n",
|
||
"\n",
|
||
"热电部\n",
|
||
"BMI 3.545\n",
|
||
"肺活量 3.297\n",
|
||
"握力 1.457\n",
|
||
"坐位体前屈 2.7988\n",
|
||
"纵跳 2.0687\n",
|
||
"俯卧撑 2.702\n",
|
||
"一分钟仰卧起坐 3.9048\n",
|
||
"单脚站立 2.0026\n",
|
||
"选择反应时 3.0246\n",
|
||
"台阶指数 2.8593\n",
|
||
"\n",
|
||
"烯烃部\n",
|
||
"BMI 3.7003\n",
|
||
"肺活量 3.1226\n",
|
||
"握力 1.3396\n",
|
||
"坐位体前屈 3.043\n",
|
||
"纵跳 1.9135\n",
|
||
"俯卧撑 2.4788\n",
|
||
"一分钟仰卧起坐 3.9538\n",
|
||
"单脚站立 2.0804\n",
|
||
"选择反应时 3.1009\n",
|
||
"台阶指数 2.8376\n",
|
||
"\n",
|
||
"行政事务中心\n",
|
||
"BMI 3.8293\n",
|
||
"肺活量 3.0833\n",
|
||
"握力 1.325\n",
|
||
"坐位体前屈 2.4375\n",
|
||
"纵跳 1.7\n",
|
||
"俯卧撑 3.4211\n",
|
||
"一分钟仰卧起坐 4.2667\n",
|
||
"单脚站立 2.1282\n",
|
||
"选择反应时 2.9512\n",
|
||
"台阶指数 2.6842\n",
|
||
"\n",
|
||
"信息档案管理中心\n",
|
||
"BMI 4.1525\n",
|
||
"肺活量 3.7119\n",
|
||
"握力 1.05\n",
|
||
"坐位体前屈 3.0566\n",
|
||
"纵跳 1.8393\n",
|
||
"俯卧撑 2.92\n",
|
||
"一分钟仰卧起坐 4.0952\n",
|
||
"单脚站立 2.4746\n",
|
||
"选择反应时 3.2034\n",
|
||
"台阶指数 2.8824\n",
|
||
"\n",
|
||
"研究院\n",
|
||
"BMI 4.0099\n",
|
||
"肺活量 3.5306\n",
|
||
"握力 1.3069\n",
|
||
"坐位体前屈 2.8161\n",
|
||
"纵跳 1.9529\n",
|
||
"俯卧撑 3.1481\n",
|
||
"一分钟仰卧起坐 4.1818\n",
|
||
"单脚站立 2.1515\n",
|
||
"选择反应时 3.3366\n",
|
||
"台阶指数 2.975\n",
|
||
"\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"\n",
|
||
"for k ,v in dict3.items():\n",
|
||
" print(k)\n",
|
||
" for k1,v1 in v.items():\n",
|
||
" if v1['count']>0:\n",
|
||
" print(k1,round(v1['score']/v1['count'],4))\n",
|
||
" print()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d3d9d517-61e5-4c4c-bddb-1f386a518d99",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 倒班人员数据分析"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6b0b8d09-ce15-4a36-9421-251ab50ae706",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 倒班员工数据导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "518a1e40-d383-4d78-a4ea-224ddab49b79",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017.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",
|
||
"dict2 = {}\n",
|
||
"i = 1\n",
|
||
"for n in range(4, sheet.max_row+1):\n",
|
||
" if sheet.cell(n, 1).value is not None:\n",
|
||
" code = int(sheet.cell(n, 1).value)\n",
|
||
" daoban = sheet.cell(n, 6).value\n",
|
||
" if str(code) in dict1.keys() and daoban == '倒班':\n",
|
||
" dict2[str(code)] = dict1[str(code)]\n",
|
||
"print(len(dict2))\n",
|
||
"filename = 'data/data_天津231017_倒班.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2, fl) \n",
|
||
"dict3 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" if k not in dict2.keys():\n",
|
||
" dict3[k] = dict1[k]\n",
|
||
"print(len(dict3))\n",
|
||
" \n",
|
||
"filename = 'data/data_天津231017_非倒班.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict3, fl) \n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "cf45ba36-896d-4d28-ae4a-08c512ff1ddb",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 核对倒班员工信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "08167b05-8719-41c9-a71d-57906a55eb63",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017_非倒班.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",
|
||
"dict2 = {}\n",
|
||
"i = 0\n",
|
||
"for n in range(4, sheet.max_row+1):\n",
|
||
" if sheet.cell(n, 1).value is not None:\n",
|
||
" code = int(sheet.cell(n, 1).value)\n",
|
||
" daoban = sheet.cell(n, 6).value\n",
|
||
" if str(code) in dict1.keys():# and daoban != '倒班':\n",
|
||
" dict2[str(code)] = dict1[str(code)]\n",
|
||
"for k,v in dict1.items():\n",
|
||
" if str(k) not in dict2.keys():\n",
|
||
" i+=1\n",
|
||
" print(i,k,v['name'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "dc51915d-7593-411c-8730-4ee9445ebd51",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 对比倒班及非倒班人员得分"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 312,
|
||
"id": "096bb641-c000-490b-bd77-296fb0395dc8",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-28T12:54:35.962454Z",
|
||
"iopub.status.busy": "2023-11-28T12:54:35.961990Z",
|
||
"iopub.status.idle": "2023-11-28T12:54:36.084684Z",
|
||
"shell.execute_reply": "2023-11-28T12:54:36.084138Z",
|
||
"shell.execute_reply.started": "2023-11-28T12:54:35.962418Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"南港烯烃部 {'非倒班': [13882, 681, 5591], '倒班': [0, 0, 0]}\n",
|
||
"消防支队 {'非倒班': [1420, 72, 558], '倒班': [0, 0, 0]}\n",
|
||
"化工部 {'非倒班': [9833, 498, 3792], '倒班': [483, 24, 185]}\n",
|
||
"炼油部 {'非倒班': [12059, 548, 4459], '倒班': [13153, 643, 5046]}\n",
|
||
"电仪部 {'非倒班': [2162, 110, 885], '倒班': [4206, 212, 1744]}\n",
|
||
"物资采购中心 {'非倒班': [1736, 84, 643], '倒班': [0, 0, 0]}\n",
|
||
"化验计量部 {'非倒班': [3561, 185, 1368], '倒班': [5241, 284, 2065]}\n",
|
||
"运输销售部 {'非倒班': [3316, 188, 1341], '倒班': [203, 11, 78]}\n",
|
||
"原油储运部 {'非倒班': [2561, 125, 1002], '倒班': [949, 53, 397]}\n",
|
||
"公司机关 {'非倒班': [2364, 112, 883], '倒班': [0, 0, 0]}\n",
|
||
"南港乙烯项目管理部 {'非倒班': [325, 15, 124], '倒班': [0, 0, 0]}\n",
|
||
"党委党校(培训中心) {'非倒班': [1011, 48, 360], '倒班': [0, 0, 0]}\n",
|
||
"聚醚部 {'非倒班': [2036, 96, 744], '倒班': [263, 16, 118]}\n",
|
||
"装备研究院 {'非倒班': [1028, 48, 378], '倒班': [0, 0, 0]}\n",
|
||
"热电部 {'非倒班': [3849, 187, 1419], '倒班': [4409, 225, 1700]}\n",
|
||
"行政事务中心 {'非倒班': [851, 41, 322], '倒班': [0, 0, 0]}\n",
|
||
"烯烃部 {'非倒班': [3501, 165, 1268], '倒班': [3007, 155, 1182]}\n",
|
||
"水务部 {'非倒班': [5790, 293, 2196], '倒班': [1807, 103, 760]}\n",
|
||
"信息档案管理中心 {'非倒班': [1384, 60, 485], '倒班': [0, 0, 0]}\n",
|
||
"研究院 {'非倒班': [2225, 101, 788], '倒班': [0, 0, 0]}\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017_非倒班.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"dict3 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['unit']\n",
|
||
" dict3.setdefault(unit,{})\n",
|
||
" dict3[unit].setdefault('非倒班',[0,0,0])\n",
|
||
" dict3[unit].setdefault('倒班',[0,0,0])\n",
|
||
" for k1,v1 in v['fits'].items():\n",
|
||
" if k1 in items:\n",
|
||
" dict3[unit]['非倒班'][0] = dict3[unit]['非倒班'][0]+ v1['score']\n",
|
||
" dict3[unit]['非倒班'][2]+=1\n",
|
||
" dict3[unit]['非倒班'][1] +=1\n",
|
||
"filename = 'data/data_天津231017_倒班.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['unit']\n",
|
||
" dict3.setdefault(unit,{})\n",
|
||
" dict3[unit].setdefault('非倒班',[0,0])\n",
|
||
" dict3[unit].setdefault('倒班',[0,0])\n",
|
||
" for k1,v1 in v['fits'].items():\n",
|
||
" if k1 in items:\n",
|
||
" dict3[unit]['倒班'][0] = dict3[unit]['倒班'][0]+ v1['score']\n",
|
||
" dict3[unit]['倒班'][2] +=1\n",
|
||
" dict3[unit]['倒班'][1] +=1\n",
|
||
"\n",
|
||
"for k ,v in dict3.items():\n",
|
||
" print(k,v)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "ce2c7879-308c-45aa-aaeb-2323b3a060be",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 划分年龄段"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "c1b68d99-e8c1-455a-973f-20f4c1fd58a2",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/data_天津231017.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"nld ={'20':[20,29],'30':[30,39],'40':[40,49],'50':[50,69]}\n",
|
||
"for k,v in nld.items():\n",
|
||
" age_min = v[0]\n",
|
||
" age_max = v[1]\n",
|
||
" for k1,v1 in dict1.items():\n",
|
||
" if v1['age'] >=v[0] and v1['age']<=v[1]:\n",
|
||
" dict1[k1]['nld'] = k\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "eb35716c-cd5a-476b-95d0-b326bfa04963",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 上肢、下肢力量分析(男)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "6a8cfab1-c99b-4376-9ad2-4ae096dd4866",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = ['20','30','40','50']\n",
|
||
"shangzhi = ['握力','俯卧撑']\n",
|
||
"xiazhi = ['纵跳','闭眼单脚站立']\n",
|
||
"zongrenshu = 0\n",
|
||
"ruo = 0\n",
|
||
"for item in list1:\n",
|
||
" print(item)\n",
|
||
" renshu = 0\n",
|
||
" ruo = 0\n",
|
||
" \n",
|
||
" for k, v in dict1.items():\n",
|
||
" if v['nld'] == item and v['sex']=='男':\n",
|
||
" renshu+=1\n",
|
||
" n =0\n",
|
||
" defen = 0\n",
|
||
" for k1, v1 in v['fits'].items():\n",
|
||
" if k1 in xiazhi:\n",
|
||
" n+=1\n",
|
||
" defen =defen+v1['score']\n",
|
||
" if n>0 and (defen/n)<3:\n",
|
||
" ruo+=1\n",
|
||
" print(renshu,ruo)\n",
|
||
" \n",
|
||
" \n",
|
||
" \n",
|
||
" \n",
|
||
" \n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6f83db87-9844-41dc-bf43-789c3367f411",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 上肢、下肢力量分析(女)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 295,
|
||
"id": "2cb586f9-cdf1-4b51-8900-50416b5f0ae5",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-28T11:55:13.064209Z",
|
||
"iopub.status.busy": "2023-11-28T11:55:13.063792Z",
|
||
"iopub.status.idle": "2023-11-28T11:55:13.118894Z",
|
||
"shell.execute_reply": "2023-11-28T11:55:13.118359Z",
|
||
"shell.execute_reply.started": "2023-11-28T11:55:13.064179Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"20\n",
|
||
"506 301\n",
|
||
"30\n",
|
||
"222 97\n",
|
||
"40\n",
|
||
"583 305\n",
|
||
"50\n",
|
||
"284 169\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = ['20','30','40','50']\n",
|
||
"shangzhi = ['握力']\n",
|
||
"xiazhi = ['纵跳','闭眼单脚站立']\n",
|
||
"zongrenshu = 0\n",
|
||
"ruo = 0\n",
|
||
"for item in list1:\n",
|
||
" print(item)\n",
|
||
" renshu = 0\n",
|
||
" ruo = 0\n",
|
||
" \n",
|
||
" for k, v in dict1.items():\n",
|
||
" if v['nld'] == item and v['sex']=='女':\n",
|
||
" renshu+=1\n",
|
||
" n =0\n",
|
||
" defen = 0\n",
|
||
" for k1, v1 in v['fits'].items():\n",
|
||
" if k1 in xiazhi:\n",
|
||
" n+=1\n",
|
||
" defen =defen+v1['score']\n",
|
||
" if n>0 and (defen/n)<3:\n",
|
||
" ruo+=1\n",
|
||
" print(renshu,ruo)\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "dd822864-0226-40c1-b385-cd146f6972c9",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"for k ,v in dict1.items():\n",
|
||
" if v['sex'] == '男' and '握力' in v['fits'].keys():\n",
|
||
" print(v['name'],v['nld'],v['fits']['握力']['mark'],v['fits']['握力']['score'])\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "1015b957-448a-4029-827f-3abc3c0e9173",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 弱项分析(男)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 302,
|
||
"id": "d3ea1ddb-db7a-4b4f-a23c-6951e88df2ff",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-28T12:15:45.478108Z",
|
||
"iopub.status.busy": "2023-11-28T12:15:45.477633Z",
|
||
"iopub.status.idle": "2023-11-28T12:15:45.604185Z",
|
||
"shell.execute_reply": "2023-11-28T12:15:45.603612Z",
|
||
"shell.execute_reply.started": "2023-11-28T12:15:45.478072Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"20\n",
|
||
"BMI 3.0\n",
|
||
"肺活量 3.65\n",
|
||
"握力 1.25\n",
|
||
"坐位体前屈 2.65\n",
|
||
"纵跳 2.29\n",
|
||
"俯卧撑 2.51\n",
|
||
"单脚站立 1.76\n",
|
||
"选择反应时 2.53\n",
|
||
"台阶指数 2.2\n",
|
||
"30\n",
|
||
"BMI 2.85\n",
|
||
"肺活量 3.44\n",
|
||
"握力 1.17\n",
|
||
"坐位体前屈 2.54\n",
|
||
"纵跳 2.57\n",
|
||
"俯卧撑 2.77\n",
|
||
"单脚站立 1.9\n",
|
||
"选择反应时 2.84\n",
|
||
"台阶指数 2.59\n",
|
||
"40\n",
|
||
"BMI 3.31\n",
|
||
"肺活量 3.13\n",
|
||
"握力 1.39\n",
|
||
"坐位体前屈 2.72\n",
|
||
"纵跳 1.83\n",
|
||
"俯卧撑 2.64\n",
|
||
"单脚站立 1.93\n",
|
||
"选择反应时 3.15\n",
|
||
"台阶指数 2.79\n",
|
||
"50\n",
|
||
"BMI 3.71\n",
|
||
"肺活量 2.99\n",
|
||
"握力 1.52\n",
|
||
"坐位体前屈 3.05\n",
|
||
"纵跳 1.18\n",
|
||
"俯卧撑 2.27\n",
|
||
"单脚站立 1.73\n",
|
||
"选择反应时 3.18\n",
|
||
"台阶指数 3.04\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = ['20','30','40','50']\n",
|
||
"\n",
|
||
"for nld in list1:\n",
|
||
" \n",
|
||
" print(nld)\n",
|
||
" for item in items:\n",
|
||
" n =0\n",
|
||
" defen = 0\n",
|
||
" for k, v in dict1.items():\n",
|
||
" \n",
|
||
" if v['nld'] == nld and v['sex']=='男' and item in v['fits'].keys():\n",
|
||
" n+=1\n",
|
||
" defen =defen+ v['fits'][item]['score']\n",
|
||
" if n>0:\n",
|
||
" print(item,round(defen/n,2)) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "727fda65-7268-44f5-b953-285c86602254",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 弱项分析(女)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 303,
|
||
"id": "723b50a1-60f1-4001-8b30-6f77c6a4b460",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-11-28T12:18:25.287183Z",
|
||
"iopub.status.busy": "2023-11-28T12:18:25.286772Z",
|
||
"iopub.status.idle": "2023-11-28T12:18:25.407362Z",
|
||
"shell.execute_reply": "2023-11-28T12:18:25.406892Z",
|
||
"shell.execute_reply.started": "2023-11-28T12:18:25.287153Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"20\n",
|
||
"BMI 3.82\n",
|
||
"肺活量 3.43\n",
|
||
"握力 1.38\n",
|
||
"坐位体前屈 3.08\n",
|
||
"纵跳 2.21\n",
|
||
"一分钟仰卧起坐 3.66\n",
|
||
"单脚站立 1.87\n",
|
||
"选择反应时 2.41\n",
|
||
"台阶指数 2.47\n",
|
||
"30\n",
|
||
"BMI 4.05\n",
|
||
"肺活量 3.57\n",
|
||
"握力 1.25\n",
|
||
"坐位体前屈 3.0\n",
|
||
"纵跳 2.62\n",
|
||
"一分钟仰卧起坐 4.18\n",
|
||
"单脚站立 2.22\n",
|
||
"选择反应时 2.96\n",
|
||
"台阶指数 2.92\n",
|
||
"40\n",
|
||
"BMI 4.18\n",
|
||
"肺活量 3.38\n",
|
||
"握力 1.37\n",
|
||
"坐位体前屈 3.0\n",
|
||
"纵跳 2.07\n",
|
||
"一分钟仰卧起坐 3.99\n",
|
||
"单脚站立 2.58\n",
|
||
"选择反应时 3.13\n",
|
||
"台阶指数 2.93\n",
|
||
"50\n",
|
||
"BMI 4.13\n",
|
||
"肺活量 3.22\n",
|
||
"握力 1.28\n",
|
||
"坐位体前屈 3.22\n",
|
||
"纵跳 1.48\n",
|
||
"一分钟仰卧起坐 3.71\n",
|
||
"单脚站立 2.79\n",
|
||
"选择反应时 3.4\n",
|
||
"台阶指数 3.71\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数'] \n",
|
||
"\n",
|
||
"\n",
|
||
"filename = 'data/data_天津_nld.json' \n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"list1 = ['20','30','40','50']\n",
|
||
"\n",
|
||
"for nld in list1:\n",
|
||
" \n",
|
||
" print(nld)\n",
|
||
" for item in items:\n",
|
||
" n =0\n",
|
||
" defen = 0\n",
|
||
" for k, v in dict1.items():\n",
|
||
" \n",
|
||
" if v['nld'] == nld and v['sex']=='女' and item in v['fits'].keys():\n",
|
||
" n+=1\n",
|
||
" defen =defen+ v['fits'][item]['score']\n",
|
||
" if n>0:\n",
|
||
" print(item,round(defen/n,2))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "62278ae0-be57-4f7c-85d6-cfb9cf61e341",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3 (ipykernel)",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.10.12"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|