diff --git a/体测单位/燕山石化.ipynb b/体测单位/燕山石化.ipynb index 1af7b56..1676de4 100644 --- a/体测单位/燕山石化.ipynb +++ b/体测单位/燕山石化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 17, "id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16", "metadata": { "execution": { - "iopub.execute_input": "2023-04-16T09:15:26.090819Z", - "iopub.status.busy": "2023-04-16T09:15:26.089924Z", - "iopub.status.idle": "2023-04-16T09:15:28.536339Z", - "shell.execute_reply": "2023-04-16T09:15:28.535561Z", - "shell.execute_reply.started": "2023-04-16T09:15:26.090779Z" + "iopub.execute_input": "2023-04-17T12:35:15.468795Z", + "iopub.status.busy": "2023-04-17T12:35:15.467942Z", + "iopub.status.idle": "2023-04-17T12:35:17.788780Z", + "shell.execute_reply": "2023-04-17T12:35:17.787971Z", + "shell.execute_reply.started": "2023-04-17T12:35:15.468765Z" }, "tags": [] }, @@ -75,10 +75,270 @@ "print('ok')" ] }, + { + "cell_type": "markdown", + "id": "f5c73dff-697d-4ba5-a90c-9bed68eaf4b3", + "metadata": {}, + "source": [ + "## 每日成绩导入" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "71e1ec6a-6797-4496-969a-1d1461b9ea58", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-17T12:58:30.871865Z", + "iopub.status.busy": "2023-04-17T12:58:30.870992Z", + "iopub.status.idle": "2023-04-17T12:58:30.978471Z", + "shell.execute_reply": "2023-04-17T12:58:30.977610Z", + "shell.execute_reply.started": "2023-04-17T12:58:30.871824Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "343\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/燕山石化人员名单.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "filename = 'data/places_result_20230417.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]['工作单位']\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_燕山石化(20230417).json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "79147ba8-4b90-40ba-81a9-e6062600c239", + "metadata": {}, + "source": [ + "## 每日成绩导出" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "c24880ad-bbbd-4ad8-a894-cbcea389e822", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-17T12:58:35.966367Z", + "iopub.status.busy": "2023-04-17T12:58:35.965948Z", + "iopub.status.idle": "2023-04-17T12:58:36.125657Z", + "shell.execute_reply": "2023-04-17T12:58:36.124946Z", + "shell.execute_reply.started": "2023-04-17T12:58:35.966339Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "filename = 'data/result_燕山石化(20230417).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(5,'0'))\n", + " list2.append(v['name']) \n", + " list2.append(dict2[k]['sex'])\n", + " list2.append(dict2[k]['工作单位']) \n", + " list2.append(dict2[k]['车间'])\n", + " list2.append(dict2[k]['班组'])\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/燕山石化体测情况表(20230417).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": "6d431fc1-b743-467c-91b3-9788e245becb", + "metadata": {}, + "source": [ + "## 统计部门测试人数" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "68454877-f1fe-4eed-8a48-265e428f892e", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-17T12:58:42.418562Z", + "iopub.status.busy": "2023-04-17T12:58:42.418127Z", + "iopub.status.idle": "2023-04-17T12:58:42.446368Z", + "shell.execute_reply": "2023-04-17T12:58:42.445328Z", + "shell.execute_reply.started": "2023-04-17T12:58:42.418533Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'行政事务中心(离退中心)工会': 83, '机关工会': 80, '消防中心工会': 44, '生产运行保障中心': 85, '教育培训中心工会': 19, '烯烃厂工会': 2, '物装中心工会': 29, '有机化工厂工会': 1}\n" + ] + } + ], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "filename = 'data/result_燕山石化(20230417).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/燕山石化部门测试人数情况表(20230417).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": "8becc0af-d22b-46a2-b35e-9122942515d4", + "metadata": {}, + "source": [ + "## 每日未测试人员情况表" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "7085bf6f-7465-44fb-bddb-38130fbe5618", + "metadata": { + "execution": { + "iopub.execute_input": "2023-04-17T12:58:45.236098Z", + "iopub.status.busy": "2023-04-17T12:58:45.235274Z", + "iopub.status.idle": "2023-04-17T12:58:46.270936Z", + "shell.execute_reply": "2023-04-17T12:58:46.270191Z", + "shell.execute_reply.started": "2023-04-17T12:58:45.236059Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "import json\n", + "import openpyxl\n", + "\n", + "\n", + "title = ['编号','姓名','性别','单位','车间','班组']\n", + "filename = 'data/result_燕山石化(20230417).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", + "list1 = []\n", + "for k, v in dict2.items():\n", + " list2 = []\n", + " if k not in dict1.keys():\n", + " list2.append(str(k).rjust(5,'0'))\n", + " list2.append(v['name']) \n", + " list2.append(dict2[k]['sex'])\n", + " list2.append(dict2[k]['工作单位']) \n", + " list2.append(dict2[k]['车间'])\n", + " list2.append(dict2[k]['班组'])\n", + " list1.append(list2)\n", + "filename = 'data/燕山石化未体测人员名单(20230417).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": null, - "id": "cccb9f2d-3d3a-4292-9204-55310e2c56d1", + "id": "6e1dda56-541b-4afe-8ae7-2a8dd7ec5eac", "metadata": {}, "outputs": [], "source": []