This commit is contained in:
512song committed 2024-10-21 21:56:27 +08:00
1 parent 1473d61c69
commit b62d5d2af0
4 files changed
+1391 -191

No files matched your search

+371 -1
View File
@@ -1492,6 +1492,7 @@
"cell_type": "markdown",
"id": "73524e7f-4262-46d3-a733-74ac18e43855",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -2850,6 +2851,374 @@
" "
]
},
{
"cell_type": "markdown",
"id": "08bcbf58-4356-4f30-850f-0d0ff0e2528b",
"metadata": {},
"source": [
"# 第三次体测(2024年10月)"
]
},
{
"cell_type": "markdown",
"id": "e439892b-fd46-4264-8f3c-202bc6388384",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "2fdbadd7-e9b1-45bf-ae95-52b4d65e03e8",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-21T10:06:26.974537Z",
"iopub.status.busy": "2024-10-21T10:06:26.973770Z",
"iopub.status.idle": "2024-10-21T10:06:27.568893Z",
"shell.execute_reply": "2024-10-21T10:06:27.568360Z",
"shell.execute_reply.started": "2024-10-21T10:06:26.974467Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"\n",
"\n",
"wb = openpyxl.load_workbook('data/天津石化名单(2024年).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, 4).value\n",
" dict1['sex'] = sheet.cell(n, 6).value\n",
" dict1['unit'] = sheet.cell(n, 2).value\n",
" dict1['sub_unit'] = sheet.cell(n, 3).value\n",
" dict1['birth'] = str(sheet.cell(n, 7).value).replace('/','-').split(' ')[0] \n",
" #dict1['id'] = sheet.cell(n,5).value\n",
" person[code] = dict1\n",
"filename = 'data/天津石化人员2024.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "df164df9-66b9-44bf-871b-d137f2322648",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ddb84188-aafb-49b3-836d-79d9b13dfe35",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-14T05:51:16.063432Z",
"iopub.status.busy": "2024-10-14T05:51:16.062897Z",
"iopub.status.idle": "2024-10-14T05:51:16.111372Z",
"shell.execute_reply": "2024-10-14T05:51:16.110782Z",
"shell.execute_reply.started": "2024-10-14T05:51:16.063381Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"\n",
"filename = 'data/天津石化人员2024.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/data_天津石化人员2024.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "8222893c-b6e6-47bf-9daa-81b8b7a1952c",
"metadata": {},
"source": [
"## 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "f922ad6a-e7ff-4ff9-923f-3e7aa8ea112b",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-21T10:06:44.171412Z",
"iopub.status.busy": "2024-10-21T10:06:44.170650Z",
"iopub.status.idle": "2024-10-21T10:06:44.271785Z",
"shell.execute_reply": "2024-10-21T10:06:44.271220Z",
"shell.execute_reply.started": "2024-10-21T10:06:44.171341Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1500\n",
"1500\n"
]
}
],
"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/天津石化人员2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/places_result_20241021.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_天津2024.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": "618e765d-c75d-4a46-9097-557e3c568123",
"metadata": {},
"source": [
"## 导出测试人员信息"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "f59cf12c-d409-4de8-80f9-8264e4a2d221",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-21T10:06:58.056883Z",
"iopub.status.busy": "2024-10-21T10:06:58.056217Z",
"iopub.status.idle": "2024-10-21T10:06:58.205426Z",
"shell.execute_reply": "2024-10-21T10:06:58.204917Z",
"shell.execute_reply.started": "2024-10-21T10:06:58.056824Z"
}
},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n",
"filename = 'data/result_天津2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/天津石化人员2024.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",
" list1.append(list2)\n",
"filename = 'data/天津石化体测情况(截至20241021).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": "12837ccf-90a5-43cd-8201-2777aa6d3dd4",
"metadata": {},
"source": [
"## 统计各部门测试情况"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "8301201e-43fc-4d24-94a0-9c554ca39dfb",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-21T10:07:07.304706Z",
"iopub.status.busy": "2024-10-21T10:07:07.303931Z",
"iopub.status.idle": "2024-10-21T10:07:07.344670Z",
"shell.execute_reply": "2024-10-21T10:07:07.344247Z",
"shell.execute_reply.started": "2024-10-21T10:07:07.304631Z"
}
},
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/result_天津2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/天津石化人员2024.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/天津部门未测试情况(截至20241021).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": "code",
"execution_count": 8,
"id": "efff43f0-a5f8-4de8-9f79-9564bf4fbb63",
"metadata": {
"execution": {
"iopub.execute_input": "2024-10-17T09:21:23.875202Z",
"iopub.status.busy": "2024-10-17T09:21:23.874694Z",
"iopub.status.idle": "2024-10-17T09:21:23.909617Z",
"shell.execute_reply": "2024-10-17T09:21:23.908972Z",
"shell.execute_reply.started": "2024-10-17T09:21:23.875155Z"
}
},
"outputs": [],
"source": [
"import json\n",
"\n",
"filename = 'data/result_天津2024.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/天津石化人员2024.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",
"\n",
"for k, v in dict3.items():\n",
" list2 = [k,v['人数']]\n",
" list1.append(list2)\n",
"\n",
"filename = 'data/天津部门人员情况.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",
@@ -2861,6 +3230,7 @@
"shell.execute_reply": "2023-10-25T02:50:57.004773Z",
"shell.execute_reply.started": "2023-10-25T02:50:56.997463Z"
},
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
@@ -3866,7 +4236,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.3"
}
},
"nbformat": 4,