This commit is contained in:
512song committed 2025-11-03 17:24:57 +08:00
1 parent 9ec7907bde
commit 45b176e01e
2 files changed
+249 -161

No files matched your search

+122 -2
View File
@@ -4,6 +4,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1", "id": "1c72f0cf-165b-4025-af9d-6771e4a0a5d1",
"metadata": { "metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [] "tags": []
}, },
"source": [ "source": [
@@ -2180,7 +2181,9 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc", "id": "76c5c17a-462d-4a7b-95a5-6b895f5a25dc",
"metadata": {}, "metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [ "source": [
"# 2024年体质检测" "# 2024年体质检测"
] ]
@@ -3085,10 +3088,127 @@
"print('ok') " "print('ok') "
] ]
}, },
{
"cell_type": "markdown",
"id": "75ee44f4-2874-44eb-b071-7666f52a60f1",
"metadata": {},
"source": [
"# 2025年体质检测"
]
},
{
"cell_type": "markdown",
"id": "78f7f826-1f38-4c8d-8483-ddde43dce321",
"metadata": {},
"source": [
"## 体测人员导入"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "58f6dbab-9ea2-4295-ae78-36951b67c2d3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-31T04:59:33.610242Z",
"iopub.status.busy": "2025-10-31T04:59:33.609508Z",
"iopub.status.idle": "2025-10-31T04:59:33.725719Z",
"shell.execute_reply": "2025-10-31T04:59:33.725272Z",
"shell.execute_reply.started": "2025-10-31T04:59:33.610173Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"854 ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"from datetime import date\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 = 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['birth'] = str(sheet.cell(n, 7).value).replace('/','-').split(' ')[0] \n",
" dict1['unit'] = sheet.cell(n, 6).value\n",
" dict1['phone'] = str(sheet.cell(n, 5).value)\n",
" dict1['id'] = sheet.cell(n, 4).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(len(person),'ok')"
]
},
{
"cell_type": "markdown",
"id": "ae6b80a0-fe84-42eb-9fb6-c7844b0aa268",
"metadata": {},
"source": [
"## 生成读卡系统文件"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "dbe52ce7-f801-44c6-b675-f0a84867c4d9",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-31T04:59:36.768146Z",
"iopub.status.busy": "2025-10-31T04:59:36.767582Z",
"iopub.status.idle": "2025-10-31T04:59:36.787010Z",
"shell.execute_reply": "2025-10-31T04:59:36.786336Z",
"shell.execute_reply.started": "2025-10-31T04:59:36.768082Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"854 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/card_北海炼化2025.json\", \"w\",encoding = 'utf-8') as file:\n",
" file.write(json_data) \n",
"print(len(list1),'ok')"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "712572b1-7a9b-4022-93de-13166508a307", "id": "8ac3a30f-002f-49b4-bbb0-c63ac37037f9",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []
+127 -159
View File
@@ -63,26 +63,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": null,
"id": "63ab2d5b-3a0a-4ac7-a3e7-b3a34e621e98", "id": "63ab2d5b-3a0a-4ac7-a3e7-b3a34e621e98",
"metadata": { "metadata": {},
"execution": { "outputs": [],
"iopub.execute_input": "2025-10-27T12:38:36.648112Z",
"iopub.status.busy": "2025-10-27T12:38:36.647778Z",
"iopub.status.idle": "2025-10-27T12:38:36.692128Z",
"shell.execute_reply": "2025-10-27T12:38:36.691382Z",
"shell.execute_reply.started": "2025-10-27T12:38:36.648082Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -1710,26 +1694,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"id": "da037e81-96a8-475e-9ad7-21ab92285b85", "id": "da037e81-96a8-475e-9ad7-21ab92285b85",
"metadata": { "metadata": {},
"execution": { "outputs": [],
"iopub.execute_input": "2025-10-27T12:41:31.242485Z",
"iopub.status.busy": "2025-10-27T12:41:31.240445Z",
"iopub.status.idle": "2025-10-27T12:41:31.282456Z",
"shell.execute_reply": "2025-10-27T12:41:31.281601Z",
"shell.execute_reply.started": "2025-10-27T12:41:31.242428Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1383 ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
@@ -1762,15 +1730,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 27,
"id": "505fce63-ed92-4f63-82da-7207b015dab4", "id": "505fce63-ed92-4f63-82da-7207b015dab4",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2025-10-29T08:42:44.713490Z", "iopub.execute_input": "2025-11-01T07:31:37.856873Z",
"iopub.status.busy": "2025-10-29T08:42:44.709542Z", "iopub.status.busy": "2025-11-01T07:31:37.856270Z",
"iopub.status.idle": "2025-10-29T08:42:44.770204Z", "iopub.status.idle": "2025-11-01T07:31:37.883335Z",
"shell.execute_reply": "2025-10-29T08:42:44.769358Z", "shell.execute_reply": "2025-11-01T07:31:37.882723Z",
"shell.execute_reply.started": "2025-10-29T08:42:44.713433Z" "shell.execute_reply.started": "2025-11-01T07:31:37.856814Z"
} }
}, },
"outputs": [ "outputs": [
@@ -1778,61 +1746,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"019698 张毅 公用工程二部\n", "1596 ok\n"
"019210 张雨婷 公用工程二部\n",
"022238 赵若程 电气中心\n",
"019810 孟玫 油库中心\n",
"021551 朱浩 炼油一部\n",
"010517 胡明 烯烃一部\n",
"015967 牛姗 烯烃一部\n",
"012920 娄形宇 电气中心\n",
"019130 魏巍 电气中心\n",
"012233 方健 烯烃一部\n",
"014585 杨恒平 质管中心\n",
"012785 乐幸 烯烃一部\n",
"021124 吴焕妍 炼油二部\n",
"021532 范展鹏 储运一部\n",
"011878 王可 公用工程一部\n",
"020838 王安东 电气中心\n",
"021429 张博伟 电气中心\n",
"016333 姜媚媚 公司机关\n",
"015474 万忠荣 化学制品部\n",
"015869 李萌萌 炼油四部\n",
"007608 汪海渊 储运一部\n",
"010250 王国维 氢能制造部\n",
"019332 严偲浩 公司机关\n",
"015859 罗信 采购中心\n",
"018940 李云鹏 炼油四部\n",
"012240 邵晓 采购中心\n",
"010536 陈炜敏 采购中心\n",
"015693 邵金燕 公司机关\n",
"019268 邹兆宁 公司机关\n",
"020208 孙书伟 采购中心\n",
"019167 吴涵华 新材料研究院\n",
"012067 阮继春 炼油五部\n",
"021192 舒润发 化学制品部\n",
"015086 王东伟 公司机关\n",
"019042 李刚 储运一部\n",
"011455 任奇伟 炼油四部\n",
"014748 王静 公用工程一部\n",
"015669 周慧芬 公用工程一部\n",
"021804 蓝海涛 储运一部\n",
"020138 牛丙波 新材料研究院\n",
"023552 李宇 烯烃二部\n",
"012802 胡庆球 公司机关\n",
"019017 周靖 烯烃一部\n",
"016056 于海 储运一部\n",
"015919 冯辉 烯烃二部\n",
"019764 曹华林 油库中心\n",
"019668 覃江宜 电气中心\n",
"023169 王武 电气中心\n",
"018979 林冠宇 合成材料部\n",
"023027 邓孜瑶 炼油一部\n",
"015512 王娜 烯烃一部\n",
"020194 徐梦莹 油库中心\n",
"019760 常亚男 油库中心\n",
"020801 陈冲 炼油三部\n",
"1464 ok\n"
] ]
} }
], ],
@@ -1862,33 +1776,47 @@
"print(len(dict1),'ok')" "print(len(dict1),'ok')"
] ]
}, },
{
"cell_type": "markdown",
"id": "0e9316d6-7f54-4c12-898f-11d635377059",
"metadata": {},
"source": [
"## 规范人员编号"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 28,
"id": "7f4df663-4767-4a1b-9e2f-14c97a2926f7", "id": "f1aefe1c-150d-4a55-98b5-3a72e9510e5d",
"metadata": {}, "metadata": {
"outputs": [], "execution": {
"iopub.execute_input": "2025-11-01T07:33:40.360278Z",
"iopub.status.busy": "2025-11-01T07:33:40.359732Z",
"iopub.status.idle": "2025-11-01T07:33:40.384531Z",
"shell.execute_reply": "2025-11-01T07:33:40.383953Z",
"shell.execute_reply.started": "2025-11-01T07:33:40.360223Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1596 ok\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"\n", "\n",
"filename = 'data/镇海人员2025.json'\n", "filename = 'data/镇海人员2025.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"dict2 = {}\n", "\n",
"for k, v in dict1.items():\n", "filename = 'data/data_镇海2025.json'\n",
" new_k = k.lower()\n", "with open(filename,'r') as fl:\n",
" dict2[new_k] = v\n", " list1 = json.load(fl)\n",
"for item in list1:\n",
" code = item['id'].lower()\n",
" dict1[code]['name'] = item['name']\n",
" dict1[code]['sex'] = item['gender']\n",
" dict1[code]['unit'] = item['unit']\n",
" dict1[code]['birth'] = item['birth']\n",
"filename = 'data/镇海人员2025-1.json'\n", "filename = 'data/镇海人员2025-1.json'\n",
"with open(filename, 'w') as fl:\n", "with open(filename, 'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False)\n", " json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1),'ok')" "print(len(dict1),'ok')"
] ]
}, },
@@ -1902,26 +1830,10 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"id": "289e4e1d-c80d-46f9-9015-fc4c139bc99d", "id": "289e4e1d-c80d-46f9-9015-fc4c139bc99d",
"metadata": { "metadata": {},
"execution": { "outputs": [],
"iopub.execute_input": "2025-10-29T08:50:32.458008Z",
"iopub.status.busy": "2025-10-29T08:50:32.455735Z",
"iopub.status.idle": "2025-10-29T08:50:32.674774Z",
"shell.execute_reply": "2025-10-29T08:50:32.672087Z",
"shell.execute_reply.started": "2025-10-29T08:50:32.457968Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1025\n"
]
}
],
"source": [ "source": [
"import json\n", "import json\n",
"import datetime\n", "import datetime\n",
@@ -1932,7 +1844,7 @@
"filename = 'data/镇海人员2025.json'\n", "filename = 'data/镇海人员2025.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"filename = 'data/marks_20251029.csv'\n", "filename = 'data/marks_20251031.csv'\n",
"re_ta = My.get_result(filename,dict1)\n", "re_ta = My.get_result(filename,dict1)\n",
"\n", "\n",
"\n", "\n",
@@ -1966,13 +1878,11 @@
"filename = 'data/镇海人员2025.json'\n", "filename = 'data/镇海人员2025.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"filename = 'data/marks_20251027-1.csv'\n", "filename = 'data/marks_20251030-1.csv'\n",
"re_ta = My.get_result(filename,dict1)\n", "re_ta = My.get_result(filename,dict1)\n",
"\n", "\n",
"\n", "\n",
"filename = 'data/result_镇海2025.json'\n", "\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))" "print(len(re_ta))"
] ]
}, },
@@ -2036,22 +1946,30 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 29,
"id": "8ed6705e-b4f6-419e-b94b-4c391fed4551", "id": "8ed6705e-b4f6-419e-b94b-4c391fed4551",
"metadata": {}, "metadata": {
"execution": {
"iopub.execute_input": "2025-11-01T07:33:54.641236Z",
"iopub.status.busy": "2025-11-01T07:33:54.640521Z",
"iopub.status.idle": "2025-11-01T07:33:55.013934Z",
"shell.execute_reply": "2025-11-01T07:33:55.013388Z",
"shell.execute_reply.started": "2025-11-01T07:33:54.641173Z"
}
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import json\n", "import json\n",
"import openpyxl\n", "import openpyxl\n",
"\n", "\n",
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
"title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','部门','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n", "\n",
"filename = 'data/result_镇海2025.json'\n", "filename = 'data/result_镇海2025.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"\n", "\n",
"filename = 'data/镇海人员2025.json'\n", "filename = 'data/镇海人员2025-1.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n", " dict2 = json.load(fl)\n",
" \n", " \n",
@@ -2062,6 +1980,20 @@
" list2.append(v['name']) \n", " list2.append(v['name']) \n",
" list2.append(dict2[k]['sex'])\n", " list2.append(dict2[k]['sex'])\n",
" list2.append(dict2[k]['unit'])\n", " list2.append(dict2[k]['unit'])\n",
" list2.append(dict2[k]['birth'])\n",
" if 'phone' in v.keys():\n",
" list2.append(dict2[k]['phone'])\n",
" else:\n",
" list2.append('')\n",
" \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", " for item in items:\n",
" if item in v.keys():\n", " if item in v.keys():\n",
" list2.append(v[item]['成绩']) \n", " list2.append(v[item]['成绩']) \n",
@@ -2069,10 +2001,9 @@
" list2.append(v[item])\n", " list2.append(v[item])\n",
" else:\n", " else:\n",
" list2.append('')\n", " list2.append('')\n",
" #list2.append(dict2[k]['gwxl'])\n", " \n",
" #list2.append(dict2[k]['gzz'])\n",
" list1.append(list2)\n", " list1.append(list2)\n",
"filename = 'data/镇海体测情况表(截至20251027)-1.xlsx'\n", "filename = 'data/镇海体测情况表(截至20251031).xlsx'\n",
"wb = openpyxl.Workbook()\n", "wb = openpyxl.Workbook()\n",
"sheet = wb.active\n", "sheet = wb.active\n",
"sheet.append(title)\n", "sheet.append(title)\n",
@@ -2092,17 +2023,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": null,
"id": "a0c85107-7c75-462c-8f77-aea787d2100f", "id": "a0c85107-7c75-462c-8f77-aea787d2100f",
"metadata": { "metadata": {},
"execution": {
"iopub.execute_input": "2025-10-29T08:51:39.051506Z",
"iopub.status.busy": "2025-10-29T08:51:39.048537Z",
"iopub.status.idle": "2025-10-29T08:51:39.126940Z",
"shell.execute_reply": "2025-10-29T08:51:39.122609Z",
"shell.execute_reply.started": "2025-10-29T08:51:39.051458Z"
}
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import json\n", "import json\n",
@@ -2138,7 +2061,7 @@
" list2 = [k,v['人数'],v['体测人数']]\n", " list2 = [k,v['人数'],v['体测人数']]\n",
" list1.append(list2)\n", " list1.append(list2)\n",
"\n", "\n",
"filename = 'data/镇海部门测试情况(截至20251029).xlsx'\n", "filename = 'data/镇海部门测试情况(截至20251031).xlsx'\n",
"wb = openpyxl.Workbook()\n", "wb = openpyxl.Workbook()\n",
"sheet = wb.active\n", "sheet = wb.active\n",
"sheet.append(title)\n", "sheet.append(title)\n",
@@ -2165,10 +2088,55 @@
" i+=1" " i+=1"
] ]
}, },
{
"cell_type": "markdown",
"id": "0d7d8dd1-45f7-455d-8db3-38febc2a2395",
"metadata": {},
"source": [
"## 统计未体测人员明细表"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "7b538b1b-9f02-4f77-82bf-f8084066003f", "id": "cc39720e-3be5-482f-a8d1-4495cf103b4f",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"filename = 'data/result_镇海2025.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"\n",
"filename = 'data/镇海人员2025.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",
" if k not in dict1.keys():\n",
" list2 = [i,k,v['name'],v['unit']]\n",
" i+=1\n",
" list1.append(list2)\n",
"#print(list1)\n",
"filename = f'data/镇海未测试人员名单(截至20251031).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": "code",
"execution_count": null,
"id": "46fe8d42-e6cc-48aa-a398-2de65aa40d5d",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []