From ca3c5280849a153b2f44d5861f9d5f0a5a0fb23c Mon Sep 17 00:00:00 2001 From: 512song Date: Mon, 26 Feb 2024 17:48:10 +0800 Subject: [PATCH] 20240226 --- 体测单位/东营杨庙202307.ipynb | 38 ++++++++-- 体测单位/安庆石化.ipynb | 139 ++++++++++++++++++++++++++++++++-- 2 files changed, 165 insertions(+), 12 deletions(-) diff --git a/体测单位/东营杨庙202307.ipynb b/体测单位/东营杨庙202307.ipynb index 735426d..f35859c 100644 --- a/体测单位/东营杨庙202307.ipynb +++ b/体测单位/东营杨庙202307.ipynb @@ -610,9 +610,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "id": "6f69631c-e2d7-431b-8114-c4bb45e394e7", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-01-18T11:50:16.920972Z", + "iopub.status.busy": "2024-01-18T11:50:16.920504Z", + "iopub.status.idle": "2024-01-18T11:50:17.016239Z", + "shell.execute_reply": "2024-01-18T11:50:17.015740Z", + "shell.execute_reply.started": "2024-01-18T11:50:16.920935Z" + } + }, "outputs": [], "source": [ "import json\n", @@ -621,15 +629,19 @@ "filename = 'data/result_杨庙230801.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", - "\n", + "filename = 'data/杨庙社区人员信息2307.json'\n", + "with open(filename,'r') as fl:\n", + " dict2 = json.load(fl)\n", "\n", "list1 = []\n", "for k, v in dict1.items():\n", " id = str(k).rjust(5,\"0\")\n", " \n", " name = v['name']\n", - " list1.append([id,name])\n", - "filename = 'data/杨庙测试2023年8月报告明细表.xlsx'\n", + " sex = dict2[k]['sex']\n", + " birth = dict2[k]['birth']\n", + " list1.append([id,name,sex,birth])\n", + "filename = 'data/杨庙测试2023年8月人员明细表.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "\n", @@ -638,6 +650,22 @@ "wb.save(filename)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "d46d6331-dc3a-4ed5-b2cd-995e467f8ac0", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8d2be337-20e9-47e1-a8fa-6a35350b37bb", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "id": "aa34d7f2-9b6c-42c8-b777-60cc0c48a3a3", diff --git a/体测单位/安庆石化.ipynb b/体测单位/安庆石化.ipynb index 04936ca..d6d253e 100644 --- a/体测单位/安庆石化.ipynb +++ b/体测单位/安庆石化.ipynb @@ -1306,6 +1306,8 @@ " psy[44] = []\n", " dict1[k1]['psy'] = psy\n", " if 'tcm' in item[1]:\n", + " if tcm[40] ==0:\n", + " tcm[40] =1\n", " dict1[k1]['tcm'] = tcm\n", " if 'spine' in item[1]:\n", " dict1[k1]['spine'] = spine\n", @@ -1485,15 +1487,15 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 31, "id": "49880f85-6cda-44a6-a77f-3abd10672d7a", "metadata": { "execution": { - "iopub.execute_input": "2024-01-17T04:40:13.175154Z", - "iopub.status.busy": "2024-01-17T04:40:13.174675Z", - "iopub.status.idle": "2024-01-17T04:40:29.104763Z", - "shell.execute_reply": "2024-01-17T04:40:29.103968Z", - "shell.execute_reply.started": "2024-01-17T04:40:13.175118Z" + "iopub.execute_input": "2024-01-17T05:24:47.910905Z", + "iopub.status.busy": "2024-01-17T05:24:47.910416Z", + "iopub.status.idle": "2024-01-17T05:25:11.510859Z", + "shell.execute_reply": "2024-01-17T05:25:11.510166Z", + "shell.execute_reply.started": "2024-01-17T05:24:47.910864Z" } }, "outputs": [ @@ -1558,10 +1560,133 @@ "print(i)" ] }, + { + "cell_type": "markdown", + "id": "56a753ee-461e-47de-bf36-58e0bb8971e1", + "metadata": {}, + "source": [ + "### 报告添加水印" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "fc195748-7e7e-4484-9f86-a430e1da79ad", + "metadata": { + "execution": { + "iopub.execute_input": "2024-02-26T08:58:53.318141Z", + "iopub.status.busy": "2024-02-26T08:58:53.317932Z", + "iopub.status.idle": "2024-02-26T08:58:57.023478Z", + "shell.execute_reply": "2024-02-26T08:58:57.023026Z", + "shell.execute_reply.started": "2024-02-26T08:58:53.318126Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok!\n" + ] + } + ], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import glob\n", + "from pathlib import Path\n", + "import PyPDF2\n", + "import openpyxl\n", + "\n", + "pdfWriter = PyPDF2.PdfWriter() \n", + "\n", + "fi_path = '/home/songyi/pdf-typescript/安庆职工健康提升'\n", + "new_path = 'file/安庆健康志愿者'\n", + "\n", + "dict1 ={}\n", + "wb = openpyxl.load_workbook('data/安庆健康志愿者分组情况表.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "\n", + "for n in range(2, sheet.max_row+1):\n", + " code = str(sheet.cell(n, 1).value)\n", + " dict1[code] = sheet.cell(n, 3).value\n", + " \n", + " \n", + "\n", + "\n", + "fls = glob.glob(f'{fi_path}/*.pdf')\n", + "for fn in fls:\n", + " reader = PyPDF2.PdfReader(fn)\n", + " writer = PyPDF2.PdfWriter()\n", + " num = len(reader.pages)\n", + " code =str(int(Path(fn).stem.split('-')[0]))\n", + " if code in dict1.keys():\n", + " sy_fn = 'data/water/'+dict1[code]+'.pdf'\n", + " water = PyPDF2.PdfReader(sy_fn).pages[0]\n", + " for i in range(num):\n", + " page = reader.pages[i]\n", + " if i == num -1:\n", + " page.merge_page(water)\n", + " writer.add_page(page)\n", + " with open(f'file/安庆健康志愿者/{Path(fn).stem}.pdf', 'wb') as target_file:\n", + " writer.write(target_file)\n", + " \n", + "print('ok!') " + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "c3026771-202b-44ed-b94c-7c8a57089cd2", + "metadata": { + "execution": { + "iopub.execute_input": "2024-02-26T08:53:24.880683Z", + "iopub.status.busy": "2024-02-26T08:53:24.880275Z", + "iopub.status.idle": "2024-02-26T08:53:24.904212Z", + "shell.execute_reply": "2024-02-26T08:53:24.902898Z", + "shell.execute_reply.started": "2024-02-26T08:53:24.880652Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'0016': '平和', '0017': '平和', '0047': '平和', '0072': '平和', '0080': '平和', '0099': '平和', '0019': '气虚', '0021': '气虚', '0025': '气虚', '0039': '气虚', '0044': '气虚', '0046': '气虚', '0051': '气虚', '0053': '气虚', '0064': '气虚', '0066': '气虚', '0068': '气虚', '0069': '气虚', '0074': '气虚', '0084': '气虚', '0036': '气郁', '0048': '气郁', '0050': '气郁', '0056': '气郁', '0062': '气郁', '0065': '气郁', '0070': '气郁', '0073': '气郁', '0097': '气郁', '0001': '湿热', '0008': '湿热', '0011': '湿热', '0014': '湿热', '0038': '湿热', '0057': '湿热', '0058': '湿热', '0090': '湿热', '0093': '湿热', '0095': '湿热', '0100': '湿热', '0009': '痰湿', '0012': '痰湿', '0015': '痰湿', '0020': '痰湿', '0026': '痰湿', '0030': '痰湿', '0041': '痰湿', '0077': '痰湿', '0079': '痰湿', '0083': '痰湿', '0085': '痰湿', '0089': '痰湿', '0094': '痰湿', '0101': '痰湿', '0010': '特禀', '0023': '特禀', '0055': '特禀', '0013': '特禀', '0022': '特禀', '0035': '特禀', '0049': '特禀', '0081': '特禀', '0082': '特禀', '0004': '阳虚', '0005': '阳虚', '0006': '阳虚', '0018': '阳虚', '0028': '阳虚', '0029': '阳虚', '0032': '阳虚', '0033': '阳虚', '0034': '阳虚', '0037': '阳虚', '0040': '阳虚', '0045': '阳虚', '0052': '阳虚', '0054': '阳虚', '0059': '阳虚', '0060': '阳虚', '0061': '阳虚', '0063': '阳虚', '0071': '阳虚', '0075': '阳虚', '0076': '阳虚', '0086': '阳虚', '0091': '阳虚', '0092': '阳虚', '0096': '阳虚', '0002': '阴虚', '0003': '阴虚', '0007': '阴虚', '0027': '阴虚', '0031': '阴虚', '0042': '阴虚', '0078': '阴虚', '0088': '阴虚'}\n" + ] + } + ], + "source": [ + "import os,sys,shutil\n", + "import json\n", + "import glob\n", + "from pathlib import Path\n", + "import PyPDF2\n", + "import openpyxl\n", + "\n", + "pdfWriter = PyPDF2.PdfWriter() \n", + "\n", + "fi_path = '/home/songyi/python/mycrm/flask/pdf/files/309118_1'\n", + "new_path = 'file/309118_sy'\n", + "\n", + "dict1 ={}\n", + "wb = openpyxl.load_workbook('data/安庆健康志愿者分组情况表.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "\n", + "for n in range(2, sheet.max_row+1):\n", + " code = str(sheet.cell(n, 1).value).rjust(4,\"0\")\n", + " dict1[code] = sheet.cell(n, 3).value\n", + "print(dict1)" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "319df381-b4fc-4795-8769-df9cd25bd04a", + "id": "cac96c1b-62a6-4301-af95-9200a283f4b4", "metadata": {}, "outputs": [], "source": []