2022111304

This commit is contained in:
512song committed 2022-11-03 21:25:04 +08:00
1 parent 21177e0b5a
commit 5513061137
1 file changed
+58 -17
+58 -17
View File
@@ -255,12 +255,6 @@
" m_depart = v['unit']\n", " m_depart = v['unit']\n",
" depart.append(m_depart) \n", " depart.append(m_depart) \n",
" dict2[int(k)] = [m_name,m_depart]\n", " dict2[int(k)] = [m_name,m_depart]\n",
"# 创建部门办公室 \n",
"m_path = os.getcwd()+'/file/137/new'\n",
"for pn in depart:\n",
" if not os.path.exists(m_path + '/' + pn):\n",
" os.mkdir(m_path + '/' + pn)\n",
"#print(dict1)\n",
"\n", "\n",
"\n", "\n",
"fl=os.listdir(fi_path)\n", "fl=os.listdir(fi_path)\n",
@@ -273,8 +267,9 @@
" #print(str(nfn)+'.pdf')\n", " #print(str(nfn)+'.pdf')\n",
"\n", "\n",
"for n in old: \n", "for n in old: \n",
" \n",
" o_name = f'{fi_path}/{n}.pdf'\n", " o_name = f'{fi_path}/{n}.pdf'\n",
" if not os.path.exists(f'{fi_path}/new/{dict2[n][1]}'):\n",
" os.mkdir(f'{fi_path}/new/{dict2[n][1]}') \n",
" n_name = f'{fi_path}/new/{dict2[n][1]}/{str(n).rjust(5,\"0\")}-{dict2[n][0]}.pdf'\n", " n_name = f'{fi_path}/new/{dict2[n][1]}/{str(n).rjust(5,\"0\")}-{dict2[n][0]}.pdf'\n",
" if not os.path.exists(n_name):\n", " if not os.path.exists(n_name):\n",
" shutil.copyfile(o_name,n_name)\n", " shutil.copyfile(o_name,n_name)\n",
@@ -291,16 +286,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"id": "22836727-9658-453a-99db-4d270c3253d4", "id": "22836727-9658-453a-99db-4d270c3253d4",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2022-11-02T03:09:46.184215Z",
"iopub.status.busy": "2022-11-02T03:09:46.183065Z",
"iopub.status.idle": "2022-11-02T03:09:46.407389Z",
"shell.execute_reply": "2022-11-02T03:09:46.404489Z",
"shell.execute_reply.started": "2022-11-02T03:09:46.184107Z"
},
"tags": [] "tags": []
}, },
"outputs": [], "outputs": [],
@@ -322,7 +310,7 @@
" list2 = [code.rjust(5,\"0\"),dict1[code]['name'],dict1[code]['unit']]\n", " list2 = [code.rjust(5,\"0\"),dict1[code]['name'],dict1[code]['unit']]\n",
" list1.append(list2)\n", " list1.append(list2)\n",
"title = ['编号','姓名','部门'] \n", "title = ['编号','姓名','部门'] \n",
"filename = 'data/巴陵十五部门人员体测情况表(截至20221101).xlsx'\n", "filename = 'data/巴陵二部门人员体测情况表(截至20221103).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",
@@ -332,10 +320,63 @@
"wb.save(filename)" "wb.save(filename)"
] ]
}, },
{
"cell_type": "markdown",
"id": "2f392a9a-0ffd-48c2-a9d7-7af99ca0f5f6",
"metadata": {},
"source": [
"### 统计部门测试人员情况"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "b5c817af-a77e-4968-9a9e-680675f4a646", "id": "e8e04af4-978a-463f-83e3-c015e1e72938",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"title = ['部门','部门人数','已测人数','未测人数']\n",
"filename = 'data/巴陵石化人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"filename = 'data/result_巴陵.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"\n",
"dict3 = {}\n",
"for k, v in dict1.items():\n",
" dict3.setdefault(v['unit'],{})\n",
" dict3[v['unit']].setdefault('人数',0)\n",
" dict3[v['unit']].setdefault('已测人数',0)\n",
" dict3[v['unit']]['人数'] = dict3[v['unit']]['人数']+1\n",
"for k, v in dict2.items():\n",
" if len(v.keys())>5: \n",
" dict3[v['unit']]['已测人数'] = dict3[v['unit']]['已测人数'] + 1\n",
"list1 = []\n",
"\n",
"for k, v in dict3.items():\n",
" list2 = []\n",
" list2 = [k,v['人数'],v['已测人数'],v['人数']-v['已测人数']]\n",
" \n",
" list1.append(list2)\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": "9cfed761-0251-47b5-831b-e005b6675452",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []