From 95bf9fd7dca10be0f6f74bbb3b468d675dbde5d8 Mon Sep 17 00:00:00 2001 From: 512song Date: Mon, 24 Apr 2023 10:20:14 +0000 Subject: [PATCH] 20230424 --- 体测单位/燕山石化.ipynb | 70 +++---- 体测单位/石家庄石化.ipynb | 421 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 456 insertions(+), 35 deletions(-) create mode 100644 体测单位/石家庄石化.ipynb diff --git a/体测单位/燕山石化.ipynb b/体测单位/燕山石化.ipynb index d687a2a..0f59805 100644 --- a/体测单位/燕山石化.ipynb +++ b/体测单位/燕山石化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 106, "id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16", "metadata": { "execution": { - "iopub.execute_input": "2023-04-23T14:28:28.286159Z", - "iopub.status.busy": "2023-04-23T14:28:28.285377Z", - "iopub.status.idle": "2023-04-23T14:28:30.884454Z", - "shell.execute_reply": "2023-04-23T14:28:30.883613Z", - "shell.execute_reply.started": "2023-04-23T14:28:28.286119Z" + "iopub.execute_input": "2023-04-24T10:05:01.926272Z", + "iopub.status.busy": "2023-04-24T10:05:01.925417Z", + "iopub.status.idle": "2023-04-24T10:05:04.468748Z", + "shell.execute_reply": "2023-04-24T10:05:04.467687Z", + "shell.execute_reply.started": "2023-04-24T10:05:01.926232Z" }, "tags": [] }, @@ -85,15 +85,15 @@ }, { "cell_type": "code", - "execution_count": 103, + "execution_count": 107, "id": "71e1ec6a-6797-4496-969a-1d1461b9ea58", "metadata": { "execution": { - "iopub.execute_input": "2023-04-23T14:40:40.245318Z", - "iopub.status.busy": "2023-04-23T14:40:40.244479Z", - "iopub.status.idle": "2023-04-23T14:40:40.427554Z", - "shell.execute_reply": "2023-04-23T14:40:40.426732Z", - "shell.execute_reply.started": "2023-04-23T14:40:40.245276Z" + "iopub.execute_input": "2023-04-24T10:06:37.571983Z", + "iopub.status.busy": "2023-04-24T10:06:37.571077Z", + "iopub.status.idle": "2023-04-24T10:06:37.786825Z", + "shell.execute_reply": "2023-04-24T10:06:37.785861Z", + "shell.execute_reply.started": "2023-04-24T10:06:37.571941Z" }, "tags": [] }, @@ -102,10 +102,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "427\n", - "4207 王新刚 已测试!\n", - "427\n", - "2223\n" + "423\n", + "5593 刘安全 已测试!\n", + "423\n", + "2645\n" ] } ], @@ -128,7 +128,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20230423.csv'\n", + "filename = 'data/places_result_20230424.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -161,7 +161,7 @@ " else:\n", " for k1,v1 in v.items():\n", " dict2[k][k1] = v1\n", - "filename = 'data/result_燕山石化(20230423).json'\n", + "filename = 'data/result_燕山石化(20230424).json'\n", "with open(filename,'w') as fl:\n", " json.dump(re_ta, fl, ensure_ascii=False) \n", "print(len(re_ta))\n", @@ -181,15 +181,15 @@ }, { "cell_type": "code", - "execution_count": 104, + "execution_count": 108, "id": "c24880ad-bbbd-4ad8-a894-cbcea389e822", "metadata": { "execution": { - "iopub.execute_input": "2023-04-23T14:42:25.680289Z", - "iopub.status.busy": "2023-04-23T14:42:25.679890Z", - "iopub.status.idle": "2023-04-23T14:42:25.850582Z", - "shell.execute_reply": "2023-04-23T14:42:25.849877Z", - "shell.execute_reply.started": "2023-04-23T14:42:25.680261Z" + "iopub.execute_input": "2023-04-24T10:08:16.575368Z", + "iopub.status.busy": "2023-04-24T10:08:16.574601Z", + "iopub.status.idle": "2023-04-24T10:08:16.751333Z", + "shell.execute_reply": "2023-04-24T10:08:16.750617Z", + "shell.execute_reply.started": "2023-04-24T10:08:16.575338Z" }, "tags": [] }, @@ -200,7 +200,7 @@ "\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", - "filename = 'data/result_燕山石化(20230423).json'\n", + "filename = 'data/result_燕山石化(20230424).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", @@ -225,7 +225,7 @@ " else:\n", " list2.append('') \n", " list1.append(list2)\n", - "filename = 'data/燕山石化体测情况表(20230423).xlsx'\n", + "filename = 'data/燕山石化体测情况表(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -245,15 +245,15 @@ }, { "cell_type": "code", - "execution_count": 105, + "execution_count": 109, "id": "68454877-f1fe-4eed-8a48-265e428f892e", "metadata": { "execution": { - "iopub.execute_input": "2023-04-23T14:48:24.388302Z", - "iopub.status.busy": "2023-04-23T14:48:24.387468Z", - "iopub.status.idle": "2023-04-23T14:48:24.424034Z", - "shell.execute_reply": "2023-04-23T14:48:24.422941Z", - "shell.execute_reply.started": "2023-04-23T14:48:24.388269Z" + "iopub.execute_input": "2023-04-24T10:08:30.444506Z", + "iopub.status.busy": "2023-04-24T10:08:30.444058Z", + "iopub.status.idle": "2023-04-24T10:08:30.475858Z", + "shell.execute_reply": "2023-04-24T10:08:30.474801Z", + "shell.execute_reply.started": "2023-04-24T10:08:30.444476Z" }, "tags": [] }, @@ -262,7 +262,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'行政事务中心(离退中心)工会': 7, '检验计量中心工会': 140, '炼油厂工会': 35, '合成橡胶厂工会': 138, '有机化工厂工会': 10, '热电厂工会': 63, '消防中心工会': 2, '化学品厂工会': 6, '机关工会': 10, '烯烃厂工会': 8, '生产运行保障中心': 6, '物装中心工会': 1, '储运厂工会': 1}\n" + "{'行政事务中心(离退中心)工会': 8, '热电厂工会': 1, '化学品厂工会': 55, '高科公司工会': 102, '炼油厂工会': 51, '有机化工厂工会': 131, '检验计量中心工会': 32, '物装中心工会': 2, '生产运行保障中心': 2, '烯烃厂工会': 6, '机关工会': 8, '合成树脂厂': 14, '消防中心工会': 2, '合成橡胶厂工会': 8, '储运厂工会': 1}\n" ] } ], @@ -270,7 +270,7 @@ "import json\n", "import openpyxl\n", "\n", - "filename = 'data/result_燕山石化(20230423).json'\n", + "filename = 'data/result_燕山石化(20230424).json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "dict2 = {}\n", @@ -285,7 +285,7 @@ " list2 = []\n", " list2 = [k,v]\n", " list1.append(list2)\n", - "filename = 'data/燕山石化部门测试人数情况表(20230423).xlsx'\n", + "filename = 'data/燕山石化部门测试人数情况表(20230424).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", diff --git a/体测单位/石家庄石化.ipynb b/体测单位/石家庄石化.ipynb new file mode 100644 index 0000000..0532432 --- /dev/null +++ b/体测单位/石家庄石化.ipynb @@ -0,0 +1,421 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "021f4ec4-47cd-433a-9d0a-91176b398f32", + "metadata": {}, + "source": [ + "## 导入人员信息" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "9bd78072-29e5-4c98-8bbe-97f525cf9e4a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-21T09:29:30.178602Z", + "iopub.status.busy": "2023-04-21T09:29:30.177717Z", + "iopub.status.idle": "2023-04-21T09:29:30.928850Z", + "shell.execute_reply": "2023-04-21T09:29:30.927826Z", + "shell.execute_reply.started": "2023-04-21T09:29:30.178561Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "\n", + "wb = openpyxl.load_workbook('data/student_20140922(石家庄监测花名册2023年).xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "person = {}\n", + "\n", + "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,1).value is not None:\n", + " code = int(sheet.cell(n, 4).value)\n", + " person.setdefault(code, {})\n", + " dict1 = {}\n", + " dict1['name'] = sheet.cell(n, 6).value\n", + " if sheet.cell(n, 7).value ==1:\n", + " sex = '男'\n", + " else:\n", + " sex = '女'\n", + " dict1['sex'] = sex\n", + " dict1['unit'] = sheet.cell(n, 3).value\n", + "\n", + "\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": "cb4e0b2a-a17a-470c-afcd-2a532c00f6d0", + "metadata": {}, + "source": [ + "## 每日成绩导入" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "dd3c65ea-cc8a-4f1b-8698-d1799f99e101", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-24T09:55:49.171204Z", + "iopub.status.busy": "2023-04-24T09:55:49.170336Z", + "iopub.status.idle": "2023-04-24T09:55:49.259229Z", + "shell.execute_reply": "2023-04-24T09:55:49.258337Z", + "shell.execute_reply.started": "2023-04-24T09:55:49.171161Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "478\n", + "ok\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/石家庄2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20230424-sjz.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", + " \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]['部门'] = dict1[user]['unit']\n", + " item_name = item[m_item]['name']\n", + " re_ta[user].setdefault(item_name,{}) \n", + " score = int(result[4])/item[m_item]['divisor'] \n", + " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", + "print(len(re_ta))\n", + "filename = 'data/result_石家庄(20230424).json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "a2127ef7-230f-434e-a817-3d4948ed0ca4", + "metadata": {}, + "source": [ + "## 每日成绩导出" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "97d86ce2-6664-41a1-89d2-ddaa0611bac1", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-24T09:56:59.802126Z", + "iopub.status.busy": "2023-04-24T09:56:59.801454Z", + "iopub.status.idle": "2023-04-24T09:57:00.013623Z", + "shell.execute_reply": "2023-04-24T09:57:00.012990Z", + "shell.execute_reply.started": "2023-04-24T09:56:59.802093Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "filename = 'data/result_石家庄(20230424).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", + " \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/石家庄石化体测情况表(20230424).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": "6fae0c4a-f0f6-4abe-bd3a-ea9fef87f2c6", + "metadata": {}, + "source": [ + "## 总成绩导入" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "e2b68cb1-3a6f-4b51-afbd-d6c9634348b1", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-24T09:40:17.019067Z", + "iopub.status.busy": "2023-04-24T09:40:17.018180Z", + "iopub.status.idle": "2023-04-24T09:40:17.154594Z", + "shell.execute_reply": "2023-04-24T09:40:17.153693Z", + "shell.execute_reply.started": "2023-04-24T09:40:17.019024Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1200\n", + "ok\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/石家庄2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20230424-sjz.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", + " \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]['部门'] = dict1[user]['unit']\n", + " item_name = item[m_item]['name']\n", + " re_ta[user].setdefault(item_name,{}) \n", + " score = int(result[4])/item[m_item]['divisor'] \n", + " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", + "print(len(re_ta))\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": "e5de157c-18e2-4a6a-bae8-3db88822b88f", + "metadata": {}, + "source": [ + "## 统计部门测试情况" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "57b22a08-554b-4b23-b98c-002b4608729f", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-24T09:40:43.681959Z", + "iopub.status.busy": "2023-04-24T09:40:43.681329Z", + "iopub.status.idle": "2023-04-24T09:40:43.726717Z", + "shell.execute_reply": "2023-04-24T09:40:43.725677Z", + "shell.execute_reply.started": "2023-04-24T09:40:43.681925Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'综合办公室(党委办公室)': 16, '销运管理部': 36, '企业管理部(法律事务部)': 12, '合资运行部': 22, '消防支队': 30, '设备工程部': 43, '党群文化部(宣传工团)': 9, '检验计量中心': 107, '发展计划部计划组': 8, '物资采购中心': 31, '炼油运行一部': 61, '审计管理部': 6, '发展计划部发展规划组': 11, '财务管理部': 16, '生产技术部': 26, '党委组织部(资源管理部)': 7, '安全环保部': 20, '储运运行部': 95, '化工运行部': 126, '信息中心': 14, '热电运行部': 48, '炼油运行三部': 52, '行政事务中心': 24, '电气仪表中心': 76, '炼油运行五部': 59, '水务运行部': 82, '编组站': 22, '炼油运行二部': 52, '炼油运行四部': 87, '纪委(监督部)': 2}\n" + ] + } + ], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "filename = 'data/result_石家庄.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "dict2 = {}\n", + "for k, v in dict1.items():\n", + " unit = v['部门']\n", + " dict2.setdefault(unit,0)\n", + " dict2[unit] = dict2[unit] + 1\n", + "print(dict2)\n", + "title =['单位','体测人数']\n", + "list1 = [] \n", + "for k, v in dict2.items():\n", + " list2 = []\n", + " list2 = [k,v]\n", + " list1.append(list2)\n", + "filename = 'data/石家庄测试名单部门情况(20230424).xlsx'\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": "187fc3c8-46f6-4d32-9b52-38efbf2403b4", + "metadata": {}, + "source": [ + "## 统计未测试人员名单" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "0001a577-3d89-4e3d-be07-51cc74e3640f", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-24T09:41:20.642552Z", + "iopub.status.busy": "2023-04-24T09:41:20.641713Z", + "iopub.status.idle": "2023-04-24T09:41:20.758674Z", + "shell.execute_reply": "2023-04-24T09:41:20.757988Z", + "shell.execute_reply.started": "2023-04-24T09:41:20.642510Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "filename = 'data/result_石家庄.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "list1 = []\n", + "filename = 'data/石家庄2023.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", + "for k, v in dict2.items():\n", + " if k not in dict1.keys():\n", + " list1.append([k,v['name'],v['unit']])\n", + "filename = 'data/石家庄未测试名单(截至20230424).xlsx'\n", + "wb = openpyxl.Workbook()\n", + "sheet = wb.active\n", + "title =['测试编号','姓名','单位']\n", + "sheet.append(title)\n", + "for row in list1:\n", + " sheet.append(row)\n", + "wb.save(filename)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c4b4bfc-6112-4e39-9188-32934479952b", + "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.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}