diff --git a/体测单位/体测数据管理.ipynb b/体测单位/体测数据管理.ipynb index a2c41a7..6d5ff58 100644 --- a/体测单位/体测数据管理.ipynb +++ b/体测单位/体测数据管理.ipynb @@ -503,12 +503,12 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "c3b4d384-9f83-4c91-98aa-0bb1f0e1d4ed", + "cell_type": "markdown", + "id": "0664fc9b-ad7c-4553-a2ab-e4997420c364", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "## 获取json文件内容" + ] }, { "cell_type": "code", @@ -516,6 +516,21 @@ "id": "68f838e6-5c5c-4b7a-ae78-c2117455d5ed", "metadata": {}, "outputs": [], + "source": [ + "import json\n", + "\n", + "filename = 'data/result_镇海2025-1.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "print(json.dumps(dict1,ensure_ascii=False))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "308fbfe8-0fcc-4ae9-8491-49c2f3cfb8ea", + "metadata": {}, + "outputs": [], "source": [] } ], diff --git a/体测单位/北海炼化.ipynb b/体测单位/北海炼化.ipynb index 1cb0ceb..6c87833 100644 --- a/体测单位/北海炼化.ipynb +++ b/体测单位/北海炼化.ipynb @@ -3215,15 +3215,15 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 22, "id": "2d7f5a24-f247-4199-a84d-dcf611dbeef6", "metadata": { "execution": { - "iopub.execute_input": "2025-11-06T09:49:25.694191Z", - "iopub.status.busy": "2025-11-06T09:49:25.693476Z", - "iopub.status.idle": "2025-11-06T09:49:25.720613Z", - "shell.execute_reply": "2025-11-06T09:49:25.719806Z", - "shell.execute_reply.started": "2025-11-06T09:49:25.694101Z" + "iopub.execute_input": "2025-11-09T03:44:07.995486Z", + "iopub.status.busy": "2025-11-09T03:44:07.994757Z", + "iopub.status.idle": "2025-11-09T03:44:08.011078Z", + "shell.execute_reply": "2025-11-09T03:44:08.010474Z", + "shell.execute_reply.started": "2025-11-09T03:44:07.995415Z" } }, "outputs": [ @@ -3231,12 +3231,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "864 杨小波 \n", - "865 宋舒波 炼油一部\n", - "866 黄耀 公用工程部\n", - "867 陈永佳 炼油一部\n", - "868 欧阳惠婕 检验计量中心\n", - "868 ok\n" + "880 熊峰 公用工程部\n", + "879 ok\n" ] } ], @@ -3276,15 +3272,15 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 23, "id": "7b79c7bb-ce87-44b2-95b1-01e9cb66d5f0", "metadata": { "execution": { - "iopub.execute_input": "2025-11-06T09:50:07.068317Z", - "iopub.status.busy": "2025-11-06T09:50:07.067538Z", - "iopub.status.idle": "2025-11-06T09:50:07.100869Z", - "shell.execute_reply": "2025-11-06T09:50:07.100391Z", - "shell.execute_reply.started": "2025-11-06T09:50:07.068246Z" + "iopub.execute_input": "2025-11-09T03:44:19.407046Z", + "iopub.status.busy": "2025-11-09T03:44:19.406684Z", + "iopub.status.idle": "2025-11-09T03:44:19.448052Z", + "shell.execute_reply": "2025-11-09T03:44:19.447526Z", + "shell.execute_reply.started": "2025-11-09T03:44:19.407015Z" } }, "outputs": [ @@ -3292,7 +3288,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "333\n" + "558\n" ] } ], @@ -3306,7 +3302,7 @@ "filename = 'data/北海炼化人员2025.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", - "filename = 'data/marks_20251106.csv'\n", + "filename = 'data/marks_20251109.csv'\n", "re_ta = My.get_result(filename,dict1)\n", "\n", "\n", @@ -3326,15 +3322,15 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 24, "id": "ca079428-2df9-4f15-b141-2c83cd0efaf5", "metadata": { "execution": { - "iopub.execute_input": "2025-11-06T09:50:13.734766Z", - "iopub.status.busy": "2025-11-06T09:50:13.734508Z", - "iopub.status.idle": "2025-11-06T09:50:13.753135Z", - "shell.execute_reply": "2025-11-06T09:50:13.752583Z", - "shell.execute_reply.started": "2025-11-06T09:50:13.734739Z" + "iopub.execute_input": "2025-11-09T03:44:28.010017Z", + "iopub.status.busy": "2025-11-09T03:44:28.009339Z", + "iopub.status.idle": "2025-11-09T03:44:28.035577Z", + "shell.execute_reply": "2025-11-09T03:44:28.035016Z", + "shell.execute_reply.started": "2025-11-09T03:44:28.009952Z" } }, "outputs": [], @@ -3372,7 +3368,7 @@ " list2 = [k,v['人数'],v['体测人数']]\n", " list1.append(list2)\n", "\n", - "filename = 'data/北海炼化部门测试情况(截至20251105).xlsx'\n", + "filename = 'data/北海炼化部门测试情况(截至20251109).xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "sheet.append(title)\n", @@ -3382,10 +3378,63 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "c3df2ac7-1ef3-4f76-a4ed-a2e8f9ecafcc", + "metadata": {}, + "source": [ + "## 统计未体测人员明细表" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "482a3a46-31a6-433b-88a8-7cad228f853a", + "metadata": { + "execution": { + "iopub.execute_input": "2025-11-09T03:44:34.970909Z", + "iopub.status.busy": "2025-11-09T03:44:34.970151Z", + "iopub.status.idle": "2025-11-09T03:44:35.005510Z", + "shell.execute_reply": "2025-11-09T03:44:35.005025Z", + "shell.execute_reply.started": "2025-11-09T03:44:34.970841Z" + } + }, + "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/北海炼化未测试人员名单(截至20251109).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": "78f2737d-97e7-4ded-994a-86818119597a", + "id": "38024bd4-7d11-43df-956a-a62ee6bf176e", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/沧州炼化.ipynb b/体测单位/沧州炼化.ipynb index d820104..c772f99 100644 --- a/体测单位/沧州炼化.ipynb +++ b/体测单位/沧州炼化.ipynb @@ -10,15 +10,15 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 18, "id": "270e8c57-36d3-476c-8c50-4d8bc38a918a", "metadata": { "execution": { - "iopub.execute_input": "2025-11-07T02:09:01.530591Z", - "iopub.status.busy": "2025-11-07T02:09:01.529883Z", - "iopub.status.idle": "2025-11-07T02:09:01.667299Z", - "shell.execute_reply": "2025-11-07T02:09:01.666813Z", - "shell.execute_reply.started": "2025-11-07T02:09:01.530529Z" + "iopub.execute_input": "2025-11-09T05:35:45.149501Z", + "iopub.status.busy": "2025-11-09T05:35:45.148976Z", + "iopub.status.idle": "2025-11-09T05:35:45.291101Z", + "shell.execute_reply": "2025-11-09T05:35:45.290596Z", + "shell.execute_reply.started": "2025-11-09T05:35:45.149453Z" } }, "outputs": [ @@ -26,7 +26,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "1287 ok\n" + "1299 ok\n" ] } ], @@ -58,18 +58,26 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "id": "829d9460-a14e-4689-a7c4-d00bbd8c2e32", "metadata": { "execution": { - "iopub.execute_input": "2025-11-07T02:21:14.683211Z", - "iopub.status.busy": "2025-11-07T02:21:14.682609Z", - "iopub.status.idle": "2025-11-07T02:21:14.839810Z", - "shell.execute_reply": "2025-11-07T02:21:14.839319Z", - "shell.execute_reply.started": "2025-11-07T02:21:14.683158Z" + "iopub.execute_input": "2025-11-07T08:37:47.436725Z", + "iopub.status.busy": "2025-11-07T08:37:47.435955Z", + "iopub.status.idle": "2025-11-07T08:37:47.582958Z", + "shell.execute_reply": "2025-11-07T08:37:47.582377Z", + "shell.execute_reply.started": "2025-11-07T08:37:47.436655Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[['1553904', '孙建国', '物资采购中心'], ['1553904', '张巍', '应急救援中心']]\n" + ] + } + ], "source": [ "import openpyxl\n", "import json\n", @@ -93,6 +101,7 @@ " if code in list2:\n", " list4 = [code,sheet.cell(n, 4).value,sheet.cell(n, 3).value]\n", " list3.append(list4)\n", + "print(list3)\n", "filename = 'data/沧州炼化编号重复人员.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", @@ -110,6 +119,58 @@ "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "7b6c8cb8-50ab-4b59-ac9a-6afb3db61476", + "metadata": { + "execution": { + "iopub.execute_input": "2025-11-09T05:35:48.182110Z", + "iopub.status.busy": "2025-11-09T05:35:48.181365Z", + "iopub.status.idle": "2025-11-09T05:35:48.197106Z", + "shell.execute_reply": "2025-11-09T05:35:48.196434Z", + "shell.execute_reply.started": "2025-11-09T05:35:48.182041Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1297 ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "filename = 'data/沧州炼化人员.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_沧州炼化人员.json\", \"w\",encoding = 'utf-8') as file:\n", + " file.write(json_data) \n", + "print(len(list1),'ok')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9148dcb7-ccaf-46f5-8390-ebe702ed4c02", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/体测单位/镇海.ipynb b/体测单位/镇海.ipynb index 4fde9ab..a86cab8 100644 --- a/体测单位/镇海.ipynb +++ b/体测单位/镇海.ipynb @@ -2225,10 +2225,112 @@ "wb.save(filename)" ] }, + { + "cell_type": "markdown", + "id": "3e0e3b48-12f1-42f0-ba3c-f949857d29f7", + "metadata": {}, + "source": [ + "## 体测报告导入数据库" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "46fe8d42-e6cc-48aa-a398-2de65aa40d5d", + "id": "8c929073-2c32-4ecf-93fa-f3bf224bcb31", + "metadata": {}, + "outputs": [], + "source": [ + "import openpyxl\n", + "import os,sys,shutil\n", + "import json\n", + "import math\n", + "import glob\n", + "import random\n", + "from pathlib import Path\n", + "import pymongo\n", + "\n", + "myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n", + "mydb = myclient[\"baogao\"]\n", + "\n", + "place_id = 1\n", + "place_code = \"20\"\n", + "\n", + "fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n", + "fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n", + "\n", + "\n", + "for fn in fls:\n", + " dict2 = {}\n", + " fi_name =Path(fn).stem.split('-')[0]\n", + " #fi_name =Path(fn).stem\n", + " code = int(fi_name)\n", + " dxm = list1[i]\n", + " dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name}\n", + " list2.append(dict2)\n", + " i +=1\n", + "x = mycol.insert_many(list2)\n", + "print(len(list2),'ok') " + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "3b73e071-62ad-41fb-8b9d-57893dbf8a6f", + "metadata": { + "execution": { + "iopub.execute_input": "2025-11-09T05:50:17.521854Z", + "iopub.status.busy": "2025-11-09T05:50:17.521109Z", + "iopub.status.idle": "2025-11-09T05:50:17.537693Z", + "shell.execute_reply": "2025-11-09T05:50:17.536539Z", + "shell.execute_reply.started": "2025-11-09T05:50:17.521785Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{'place_id': 1, 'code': '016368', 'fn': '016368-陈兴旺.pdf'}, {'place_id': 1, 'code': '013403', 'fn': '013403-孙震.pdf'}, {'place_id': 1, 'code': '008553', 'fn': '008553-张国栋.pdf'}, {'place_id': 1, 'code': '015775', 'fn': '015775-张永战.pdf'}, {'place_id': 1, 'code': '015867', 'fn': '015867-高再玲.pdf'}, {'place_id': 1, 'code': '015770', 'fn': '015770-许丹萍.pdf'}, {'place_id': 1, 'code': '021574', 'fn': '021574-杨子敬.pdf'}, {'place_id': 1, 'code': '013141', 'fn': '013141-何文丰.pdf'}, {'place_id': 1, 'code': '015635', 'fn': '015635-王宇光.pdf'}, {'place_id': 1, 'code': '016224', 'fn': '016224-方丽华.pdf'}, {'place_id': 1, 'code': '014081', 'fn': '014081-谢希杭.pdf'}, {'place_id': 1, 'code': '019323', 'fn': '019323-赖佳奇.pdf'}, {'place_id': 1, 'code': '020747', 'fn': '020747-贺海鹏.pdf'}, {'place_id': 1, 'code': '014609', 'fn': '014609-靳贤锐.pdf'}, {'place_id': 1, 'code': '016309', 'fn': '016309-张鹏宇.pdf'}, {'place_id': 1, 'code': '015206', 'fn': '015206-王贺永.pdf'}, {'place_id': 1, 'code': '015184', 'fn': '015184-彭志涛.pdf'}, {'place_id': 1, 'code': '018706', 'fn': '018706-陈佳欣.pdf'}, {'place_id': 1, 'code': '021568', 'fn': '021568-张峻哲.pdf'}, {'place_id': 1, 'code': '016402', 'fn': '016402-石晓雨.pdf'}, {'place_id': 1, 'code': '016023', 'fn': '016023-何正楠.pdf'}, {'place_id': 1, 'code': '008319', 'fn': '008319-陈文近.pdf'}, {'place_id': 1, 'code': '014701', 'fn': '014701-陈顺.pdf'}, {'place_id': 1, 'code': '013564', 'fn': '013564-徐凯华.pdf'}, {'place_id': 1, 'code': '015014', 'fn': '015014-赵刚.pdf'}, {'place_id': 1, 'code': '010481', 'fn': '010481-徐旭东.pdf'}, {'place_id': 1, 'code': '016354', 'fn': '016354-张婕.pdf'}]\n" + ] + } + ], + "source": [ + "\n", + "import os,sys,shutil\n", + "import json\n", + "import math\n", + "import glob\n", + "import random\n", + "from pathlib import Path\n", + "import pymongo\n", + "\n", + "myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n", + "mydb = myclient[\"baogao\"]\n", + "\n", + "place_id = 1\n", + "place_code = \"20\"\n", + "\n", + "#fi_path = '/root/data/flask/pdf/files'\n", + "#fi_path = '/home/songyi/python/mycrm/flask/pdf/files'\n", + "fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')\n", + "\n", + "list2 = []\n", + "for fn in fls:\n", + " dict2 = {}\n", + " fi_name =Path(fn).stem.split('-')[0]\n", + " #fi_name =Path(fn).stem\n", + " code = fi_name\n", + " dict2 = {'place_id':place_id,'code':code,'fn':Path(fn).name}\n", + " list2.append(dict2)\n", + " i +=1\n", + "x = mycol.insert_many(list2)\n", + "print(len(list2),'ok') " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c0380a6e-fdfe-4df1-b235-652e605ac312", "metadata": {}, "outputs": [], "source": []