20250623
This commit is contained in:
1 parent
926edeed0a
commit
678a2c983d
4 files changed
+733
-198
No files matched your search
+195
-111
@@ -10,33 +10,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"id": "bbba6efc-73cd-4db6-bae7-014724fee731",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-19T04:09:25.167271Z",
|
||||
"iopub.status.busy": "2025-06-19T04:09:25.166662Z",
|
||||
"iopub.status.idle": "2025-06-19T04:09:25.402923Z",
|
||||
"shell.execute_reply": "2025-06-19T04:09:25.402331Z",
|
||||
"shell.execute_reply.started": "2025-06-19T04:09:25.167211Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1697 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化人员.xlsx')\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化人员.xlsx',data_only=True)\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
@@ -55,7 +40,7 @@
|
||||
" else:\n",
|
||||
" dict1['unit'] = sheet.cell(n, 9).value\n",
|
||||
" \n",
|
||||
" dict1['birth'] = sheet.cell(n,5).value\n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0] \n",
|
||||
" person[code] = dict1\n",
|
||||
"filename = 'data/宁夏能化人员.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
@@ -111,27 +96,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": null,
|
||||
"id": "970e171e-1360-448f-a28c-520ccb8f314a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-19T04:10:33.526593Z",
|
||||
"iopub.status.busy": "2025-06-19T04:10:33.525876Z",
|
||||
"iopub.status.idle": "2025-06-19T04:10:33.640312Z",
|
||||
"shell.execute_reply": "2025-06-19T04:10:33.639700Z",
|
||||
"shell.execute_reply.started": "2025-06-19T04:10:33.526529Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1690\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import datetime\n",
|
||||
@@ -162,26 +132,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-19T04:10:36.891162Z",
|
||||
"iopub.status.busy": "2025-06-19T04:10:36.890453Z",
|
||||
"iopub.status.idle": "2025-06-19T04:10:36.986179Z",
|
||||
"shell.execute_reply": "2025-06-19T04:10:36.985655Z",
|
||||
"shell.execute_reply.started": "2025-06-19T04:10:36.891096Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
@@ -228,16 +182,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"id": "867ad6b0-9e9d-48bc-a10a-3b9cb6125890",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-18T01:41:10.410077Z",
|
||||
"iopub.status.busy": "2025-06-18T01:41:10.409472Z",
|
||||
"iopub.status.idle": "2025-06-18T01:41:10.837219Z",
|
||||
"shell.execute_reply": "2025-06-18T01:41:10.836678Z",
|
||||
"shell.execute_reply.started": "2025-06-18T01:41:10.410021Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -301,17 +248,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 64,
|
||||
"execution_count": null,
|
||||
"id": "c4b71b0f-0f0c-4962-a540-611cbab51bfa",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-17T10:59:19.218357Z",
|
||||
"iopub.status.busy": "2025-06-17T10:59:19.217982Z",
|
||||
"iopub.status.idle": "2025-06-17T10:59:19.259352Z",
|
||||
"shell.execute_reply": "2025-06-17T10:59:19.258768Z",
|
||||
"shell.execute_reply.started": "2025-06-17T10:59:19.218320Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
@@ -359,16 +298,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 66,
|
||||
"execution_count": null,
|
||||
"id": "def3f47a-24ef-4815-b63b-2a16b79b4c15",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-17T11:02:38.842412Z",
|
||||
"iopub.status.busy": "2025-06-17T11:02:38.841860Z",
|
||||
"iopub.status.idle": "2025-06-17T11:02:38.879864Z",
|
||||
"shell.execute_reply": "2025-06-17T11:02:38.879320Z",
|
||||
"shell.execute_reply.started": "2025-06-17T11:02:38.842360Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -417,17 +349,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 65,
|
||||
"execution_count": null,
|
||||
"id": "61dde8c3-844a-4016-8952-cb726ab5f61d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-17T11:01:30.219475Z",
|
||||
"iopub.status.busy": "2025-06-17T11:01:30.218747Z",
|
||||
"iopub.status.idle": "2025-06-17T11:01:30.259871Z",
|
||||
"shell.execute_reply": "2025-06-17T11:01:30.259320Z",
|
||||
"shell.execute_reply.started": "2025-06-17T11:01:30.219409Z"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
@@ -482,26 +406,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": null,
|
||||
"id": "23ffd115-72a3-4f90-9e64-ffa6420df8a4",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-19T04:34:04.657964Z",
|
||||
"iopub.status.busy": "2025-06-19T04:34:04.657683Z",
|
||||
"iopub.status.idle": "2025-06-19T04:48:50.472054Z",
|
||||
"shell.execute_reply": "2025-06-19T04:48:50.471179Z",
|
||||
"shell.execute_reply.started": "2025-06-19T04:34:04.657939Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1690\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
@@ -567,7 +475,183 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "87556725-f68a-484b-827c-f6735155e940",
|
||||
"id": "9ffec868-3851-42f6-8431-c5c5d3d15424",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"headers = {\n",
|
||||
" \"Content-Type\": \"application/json; charset=UTF-8\"\n",
|
||||
" }\n",
|
||||
"filename = 'data/result_宁夏能化人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"file_path ='./宁夏能化人员/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=0\n",
|
||||
"list2 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list1 = []\n",
|
||||
" mydata = {}\n",
|
||||
" if str(k) =='2019945':\n",
|
||||
" \n",
|
||||
" id = str(k).rjust(4,\"0\")\n",
|
||||
" mydata['path'] = file_path+id+'-'+ v['name']+'.pdf'\n",
|
||||
" mydata['title'] = '中石化宁夏能化公司'\n",
|
||||
" mydata['subtitle'] = v['unit']\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
" mydata['gender'] = 'male'\n",
|
||||
" else:\n",
|
||||
" mydata['gender'] = 'female'\n",
|
||||
" \n",
|
||||
" mydata['month'] = v['month']\n",
|
||||
" mydata['fits'] = {}\n",
|
||||
" survey_list = ['tcm','psy57','spine']\n",
|
||||
" for item in survey_list:\n",
|
||||
" if item in v.keys():\n",
|
||||
" mydata.setdefault('surveys',{})\n",
|
||||
" mydata['surveys'][item] = v[item]\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" #mydata['fits'] = {}\n",
|
||||
" for item in list_item:\n",
|
||||
" if item in v.keys():\n",
|
||||
" mydata.setdefault('fits',{})\n",
|
||||
" if item in ['lung','pushup','step','situp']:\n",
|
||||
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||
" else:\n",
|
||||
" mark = v[item]['成绩'].split()[0]\n",
|
||||
" mydata['fits'][item] = {'mark':mark,'score':v[item]['score']}\n",
|
||||
" #if len(mydata['fits']) >2 or len(mydata['surveys']) >0:\n",
|
||||
" if len(mydata['fits']) >2 : \n",
|
||||
" list1.append(mydata)\n",
|
||||
" list2.append([k,v['name']])\n",
|
||||
" i+=1\n",
|
||||
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" #print(id,v['name'],x.text)\n",
|
||||
" #print(mydata)\n",
|
||||
" #x.close()\n",
|
||||
"print(i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a056e973-b5d2-4130-85bf-1b1f21f53e48",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 体测报告按部门分类"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "59f69be9-ab27-4308-8641-927dbcfda87e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os,sys,shutil\n",
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"fi_path = '/home/songyi/pdf-typescript-old2/宁夏能化人员'\n",
|
||||
"new_path = 'file/宁夏能化'\n",
|
||||
"old = []\n",
|
||||
"dict2 = {}\n",
|
||||
"\n",
|
||||
"filename = 'data/result_宁夏能化人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"print(len(fls))\n",
|
||||
"for fn in fls:\n",
|
||||
" fi_name =Path(fn).stem.split('-')[0]\n",
|
||||
" code = int(fi_name) \n",
|
||||
" unit_path = Path(new_path,dict1[str(code)]['unit'])\n",
|
||||
" unit_path.mkdir(parents = True, exist_ok = True)\n",
|
||||
" n_name = Path(unit_path,Path(fn).stem+'.pdf')\n",
|
||||
" #if not os.path.exists(n_name):\n",
|
||||
" shutil.copyfile(fn,n_name)\n",
|
||||
" #print(fn)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e4d3abe9-707d-4edd-92df-95a5b0fea941",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 生成体测报告打印明细表"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "896955ac-351a-4914-94a6-56e6d1ae9e6e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-06-23T09:48:19.322071Z",
|
||||
"iopub.status.busy": "2025-06-23T09:48:19.321505Z",
|
||||
"iopub.status.idle": "2025-06-23T09:48:19.482488Z",
|
||||
"shell.execute_reply": "2025-06-23T09:48:19.482024Z",
|
||||
"shell.execute_reply.started": "2025-06-23T09:48:19.322019Z"
|
||||
}
|
||||
},
|
||||
"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 openpyxl\n",
|
||||
"\n",
|
||||
"fi_path = '/home/songyi/pdf-typescript-old2/宁夏能化人员'\n",
|
||||
"\n",
|
||||
"filename = 'data/result_宁夏能化人员.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
||||
"list1 = []\n",
|
||||
"title = ['测试编号','姓名','性别','部门']\n",
|
||||
"for fn in fls:\n",
|
||||
" list2 = []\n",
|
||||
" fi_name =Path(fn).stem.split('-')[0] \n",
|
||||
" code = int(fi_name)\n",
|
||||
" sex = dict1[str(code)]['sex']\n",
|
||||
" unit = dict1[str(code)]['unit']\n",
|
||||
" list2 = [fi_name,Path(fn).stem.split('-')[1],sex,unit]\n",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"\n",
|
||||
"filename = 'data/宁夏能化体测报告明细表.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) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a1907b6f-3ba7-4773-8f6e-6559af18131e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user