From c2b6f9b6757bf0f2294c17e9a40473e5579d345f Mon Sep 17 00:00:00 2001 From: 512song Date: Fri, 30 May 2025 18:21:50 +0800 Subject: [PATCH] 20250530 --- 体测单位/my_module.py | 2 +- 体测单位/东营石油工程设计院.ipynb | 119 +++++++++++++++++- 体测单位/党建出版社.ipynb | 203 ++++++++++++++++-------------- 体测单位/农工党延庆支部.ipynb | 88 +------------ 4 files changed, 234 insertions(+), 178 deletions(-) diff --git a/体测单位/my_module.py b/体测单位/my_module.py index f242340..da9dfb1 100644 --- a/体测单位/my_module.py +++ b/体测单位/my_module.py @@ -138,7 +138,7 @@ def get_result(filename,dict1): list1.append(line) for result in list1: - user = str(result[2]) + user = str(int(result[2])) rq = date.fromisoformat(result[5].replace('/','-')) if user in dict1.keys(): l_xm = [] diff --git a/体测单位/东营石油工程设计院.ipynb b/体测单位/东营石油工程设计院.ipynb index 5715f90..a61cf6a 100644 --- a/体测单位/东营石油工程设计院.ipynb +++ b/体测单位/东营石油工程设计院.ipynb @@ -1277,10 +1277,127 @@ "print('ok') " ] }, + { + "cell_type": "markdown", + "id": "4c2bb4c7-a884-4ade-a6a5-b080dc0a3d7a", + "metadata": {}, + "source": [ + "# 2025年体质检测" + ] + }, + { + "cell_type": "markdown", + "id": "553ccd00-fcaa-40af-a7fc-fbd157196023", + "metadata": {}, + "source": [ + "## 体测人员导入" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3e6da1e5-4b4e-448a-9663-815372da636b", + "metadata": { + "execution": { + "iopub.execute_input": "2025-05-30T06:30:09.042788Z", + "iopub.status.busy": "2025-05-30T06:30:09.041974Z", + "iopub.status.idle": "2025-05-30T06:30:09.102061Z", + "shell.execute_reply": "2025-05-30T06:30:09.101519Z", + "shell.execute_reply.started": "2025-05-30T06:30:09.042708Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "\n", + "wb = openpyxl.load_workbook('data/石油工程设计有限公司人员2025.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, 3).value\n", + " dict1['sex'] = sheet.cell(n, 4).value\n", + " dict1['unit'] = sheet.cell(n, 6).value\n", + " dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n", + " dict1['phone'] = sheet.cell(n,7).value\n", + " dict1['id'] = str(sheet.cell(n,2).value)\n", + " person[code] = dict1\n", + "filename = 'data/东营石油工程设计院2025.json'\n", + "with open(filename, 'w') as fl:\n", + " json.dump(person, fl, ensure_ascii=False)\n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "bdd3dec8-e443-4365-a03a-7db2e698061e", + "metadata": {}, + "source": [ + "## 生成读卡系统文件" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "93610ae6-098d-434a-a19a-6071aaa65500", + "metadata": { + "execution": { + "iopub.execute_input": "2025-05-30T06:32:05.818838Z", + "iopub.status.busy": "2025-05-30T06:32:05.818215Z", + "iopub.status.idle": "2025-05-30T06:32:05.831425Z", + "shell.execute_reply": "2025-05-30T06:32:05.830336Z", + "shell.execute_reply.started": "2025-05-30T06:32:05.818778Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "filename = 'data/东营石油工程设计院2025.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_东营石油工程设计院2025.json\", \"w\",encoding = 'utf-8') as file:\n", + " file.write(json_data) \n", + "print('ok')" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "b089745c-504b-4593-a6be-5d1da1321c95", + "id": "d7bcbeb2-2e6e-40a4-b1ef-35b95462dc44", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/党建出版社.ipynb b/体测单位/党建出版社.ipynb index 70baec2..784aefc 100644 --- a/体测单位/党建出版社.ipynb +++ b/体测单位/党建出版社.ipynb @@ -166,15 +166,15 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "id": "970e171e-1360-448f-a28c-520ccb8f314a", "metadata": { "execution": { - "iopub.execute_input": "2023-11-26T12:31:39.094899Z", - "iopub.status.busy": "2023-11-26T12:31:39.094370Z", - "iopub.status.idle": "2023-11-26T12:31:39.114981Z", - "shell.execute_reply": "2023-11-26T12:31:39.114071Z", - "shell.execute_reply.started": "2023-11-26T12:31:39.094860Z" + "iopub.execute_input": "2025-05-30T06:04:13.081538Z", + "iopub.status.busy": "2025-05-30T06:04:13.080855Z", + "iopub.status.idle": "2025-05-30T06:04:13.108682Z", + "shell.execute_reply": "2025-05-30T06:04:13.107978Z", + "shell.execute_reply.started": "2025-05-30T06:04:13.081474Z" }, "tags": [] }, @@ -183,56 +183,94 @@ "name": "stdout", "output_type": "stream", "text": [ - "16\n", - "16\n" + "60\n" + ] + } + ], + "source": [ + "import json\n", + "import datetime\n", + "import csv\n", + "from datetime import date\n", + "import my_module as My\n", + "\n", + "filename = 'data/党建出版社2025.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "filename = 'data/marks_20250530.csv'\n", + "re_ta = My.get_result(filename,dict1)\n", + "\n", + "filename = 'data/result_党建出版社2025.json'\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": "699c6a40-a6ae-4300-9646-708cb85aa5e8", + "metadata": {}, + "source": [ + "## 生成测试得分" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "def3f47a-24ef-4815-b63b-2a16b79b4c15", + "metadata": { + "execution": { + "iopub.execute_input": "2025-05-30T06:06:04.468199Z", + "iopub.status.busy": "2025-05-30T06:06:04.467495Z", + "iopub.status.idle": "2025-05-30T06:06:04.482491Z", + "shell.execute_reply": "2025-05-30T06:06:04.481540Z", + "shell.execute_reply.started": "2025-05-30T06:06:04.468131Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok!\n" ] } ], "source": [ "import json\n", "import time\n", - "import csv\n", + "import my_module as My\n", "\n", - "filename = '../item.json'\n", - "item = {}\n", - "unit = {}\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_党建出版社2025.json'\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_20231126.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", - " 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_北京党校20231126.json'\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 'bmi' in v.keys():\n", + " #bmi_data = v['height']['成绩'].split()[0]+','+ v['weight']['成绩'].split()[0]\n", + " bmi_data = v['bmi']['成绩']\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'] = My.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", + " #print(k,v['name'])\n", + " dict2[k][item_en]['score'] = My.cal_score(data1)\n", + " #print(k,v[item_en]['成绩'],cal_score(data1))\n", "\n", + "filename = f'data/result_党建出版社2025.json'\n", "with open(filename,'w') as fl:\n", - " json.dump(re_ta, fl, ensure_ascii=False) \n", - "print(len(re_ta))" + " json.dump(dict2,fl , ensure_ascii=False) \n", + "print('ok!') " ] }, { @@ -245,24 +283,30 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890", + "execution_count": 3, + "id": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b", "metadata": { - "tags": [] + "execution": { + "iopub.execute_input": "2025-05-30T06:07:24.191486Z", + "iopub.status.busy": "2025-05-30T06:07:24.190813Z", + "iopub.status.idle": "2025-05-30T06:07:24.386100Z", + "shell.execute_reply": "2025-05-30T06:07:24.385612Z", + "shell.execute_reply.started": "2025-05-30T06:07:24.191424Z" + } }, "outputs": [], "source": [ "import json\n", "import openpyxl\n", "\n", - "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", - "title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n", + "title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "\n", - "filename = 'data/result_北京党校.json'\n", + "filename = 'data/result_党建出版社2025.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", - "filename = 'data/北京党校.json'\n", + "filename = 'data/党建出版社2025.json'\n", "with open(filename,'r') as fl:\n", " dict2 = json.load(fl)\n", " \n", @@ -273,15 +317,24 @@ " list2.append(v['name']) \n", " list2.append(dict2[k]['sex'])\n", " list2.append(dict2[k]['unit'])\n", + " if 'bmi' in v.keys():\n", + " height = v['bmi']['成绩'].split(',')[0]\n", + " weight = v['bmi']['成绩'].split(',')[1]\n", + " list2.append(height)\n", + " list2.append(weight)\n", + " else:\n", + " list2.append('')\n", + " list2.append('')\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", + " list2.append('')\n", + " \n", " list1.append(list2)\n", - "filename = 'data/北京党校.xlsx'\n", + "filename = 'data/党建出版社测试情况表2025.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -291,48 +344,10 @@ "wb.save(filename)" ] }, - { - "cell_type": "markdown", - "id": "699c6a40-a6ae-4300-9646-708cb85aa5e8", - "metadata": {}, - "source": [ - "## 手工数据导入数据库" - ] - }, { "cell_type": "code", "execution_count": null, - "id": "def3f47a-24ef-4815-b63b-2a16b79b4c15", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import openpyxl\n", - "import json\n", - "\n", - "filename = 'data/北京党校.json'\n", - "with open(filename,'r') as fl:\n", - " dict2 = json.load(fl)\n", - "wb = openpyxl.load_workbook('data/北京党校手工数据.xlsx')\n", - "sheet = wb.active\n", - "# sheets = wb.sheetnames\n", - "dict1 = {}\n", - "dict3 = {1:10,2:11,3:7,4:2,5:6,6:3,7:1}\n", - "sheet = wb.active\n", - "data1 =list(sheet.values)\n", - "del data1[0]\n", - "list1 = []\n", - "for item in data1:\n", - " code = int(item[0])\n", - " list1.append((496534,code,item[2],item[1],'2023-10-15','2023-10-15 14:00:00'))\n", - "print(list1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "67e63f07-3f20-4e0e-9c07-7bf6024eeb4b", + "id": "0db73bab-bd7b-4446-ab8e-432f918288b7", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/农工党延庆支部.ipynb b/体测单位/农工党延庆支部.ipynb index 038f072..1e83b2f 100644 --- a/体测单位/农工党延庆支部.ipynb +++ b/体测单位/农工党延庆支部.ipynb @@ -53,27 +53,12 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "id": "dc0a78bb-ce82-4f6d-ba53-8bd9655f39af", "metadata": { - "execution": { - "iopub.execute_input": "2023-12-12T04:25:43.981437Z", - "iopub.status.busy": "2023-12-12T04:25:43.980663Z", - "iopub.status.idle": "2023-12-12T04:25:44.029168Z", - "shell.execute_reply": "2023-12-12T04:25:44.026384Z", - "shell.execute_reply.started": "2023-12-12T04:25:43.981364Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "32\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import csv\n", @@ -131,27 +116,12 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "id": "5b646b5d-c4f6-4d37-9510-30fcbef44855", "metadata": { - "execution": { - "iopub.execute_input": "2023-12-12T04:25:52.599199Z", - "iopub.status.busy": "2023-12-12T04:25:52.598384Z", - "iopub.status.idle": "2023-12-12T04:25:52.621363Z", - "shell.execute_reply": "2023-12-12T04:25:52.618548Z", - "shell.execute_reply.started": "2023-12-12T04:25:52.599125Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "13910270600 袁正东\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import csv\n", @@ -220,58 +190,12 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "id": "ab9b8e0c-53dd-4b93-a42a-7d1952b0423a", "metadata": { - "execution": { - "iopub.execute_input": "2023-12-12T04:36:12.507368Z", - "iopub.status.busy": "2023-12-12T04:36:12.507004Z", - "iopub.status.idle": "2023-12-12T04:36:18.957893Z", - "shell.execute_reply": "2023-12-12T04:36:18.955648Z", - "shell.execute_reply.started": "2023-12-12T04:36:12.507335Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15010721720 吕毅夫 {\"errmsg\":\"ok\"}\n", - "13911532480 王若云 {\"errmsg\":\"ok\"}\n", - "15810430182 赵凤龙 {\"errmsg\":\"ok\"}\n", - "17778112523 蔡丽娟 {\"errmsg\":\"ok\"}\n", - "15910393682 吴晨晨 {\"errmsg\":\"ok\"}\n", - "13241607620 韦树鹏 {\"errmsg\":\"ok\"}\n", - "15201130595 刘均平 {\"errmsg\":\"ok\"}\n", - "18500858558 张超 {\"errmsg\":\"ok\"}\n", - "13911692169 郑文凯 {\"errmsg\":\"ok\"}\n", - "15910799757 王贝 {\"errmsg\":\"ok\"}\n", - "13911816920 王欣 {\"errmsg\":\"ok\"}\n", - "13621168106 赵颖 {\"errmsg\":\"ok\"}\n", - "13683643617 周娟 {\"errmsg\":\"ok\"}\n", - "15010369810 黄俊平 {\"errmsg\":\"ok\"}\n", - "13810927023 高丽 {\"errmsg\":\"ok\"}\n", - "15210546702 杨海燕 {\"errmsg\":\"ok\"}\n", - "15010601650 于永华 {\"errmsg\":\"ok\"}\n", - "15910799750 韩骐 {\"errmsg\":\"ok\"}\n", - "13784086161 霍莉媛 {\"errmsg\":\"ok\"}\n", - "15810404851 王建斌 {\"errmsg\":\"ok\"}\n", - "15810830119 奚晓亮 {\"errmsg\":\"ok\"}\n", - "13651123781 马海涛 {\"errmsg\":\"ok\"}\n", - "17310308917 刘凡 {\"errmsg\":\"ok\"}\n", - "13651357627 高桂所 {\"errmsg\":\"ok\"}\n", - "13718793001 乔金梅 {\"errmsg\":\"ok\"}\n", - "15501167098 马宇 {\"errmsg\":\"ok\"}\n", - "13601312169 白华 {\"errmsg\":\"ok\"}\n", - "13901363461 陈学军 {\"errmsg\":\"ok\"}\n", - "13501017663 李志玖 {\"errmsg\":\"ok\"}\n", - "13911795921 祁向东 {\"errmsg\":\"ok\"}\n", - "18600419150 鲁兴隆 {\"errmsg\":\"ok\"}\n", - "13501017366 程大庆 {\"errmsg\":\"ok\"}\n" - ] - } - ], + "outputs": [], "source": [ "import requests\n", "import json\n",