新增体测单位管理
This commit is contained in:
512song committed 2021-10-12 16:17:34 +08:00
1 parent 2e32e0b99c
commit 1ed92be02b
1 file changed
+131 -16
+131 -16
View File
@@ -18,18 +18,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "c5a0568c-3833-4335-a4b9-600310e1a541", "id": "c5a0568c-3833-4335-a4b9-600310e1a541",
"metadata": {}, "metadata": {
"outputs": [ "tags": []
{ },
"name": "stdout", "outputs": [],
"output_type": "stream",
"text": [
"['综合办公室(党委办公室)', '销运管理部', '财务资产部', '财务管理部', '企业管理部(法律事务部)', '发展计划部', '生产技术部', '设备工程部', '安全环保部', '党委组织部(资源管理部)', '审计管理部', '党群文化部(党委宣传部、工会、团委)', '纪委(监督部)', '检验计量中心', '物资采购中心', '信息中心', '行政事务中心', '消防救援支队', '电气仪表中心', '炼油运行一部', '炼油运行二部', '炼油运行三部', '炼油运行四部', '炼油运行五部', '化工运行部', '热电运行部', '水务运行部', '储运运行部', '编组站']\n"
]
}
],
"source": [ "source": [
"import openpyxl\n", "import openpyxl\n",
"import json\n", "import json\n",
@@ -38,25 +32,146 @@
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n", "myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"tice\"]\n", "mydb = myclient[\"tice\"]\n",
"mycol = mydb[\"unit\"]\n", "mycol = mydb[\"unit\"]\n",
"wb = openpyxl.load_workbook('./data/shijiazhuang.xlsx')\n", "\n",
"name = '中国石油化工股份有限公司安庆炼化分公司'\n",
"short_name = '安庆炼化'\n",
"myquery = { \"name\": name}\n",
"if mycol.find_one(myquery) is None: \n",
" wb = openpyxl.load_workbook('data/中国石油化工股份有限公司安庆炼化分公司员工在职人员名单.xlsx')\n",
" sheet = wb.active\n", " sheet = wb.active\n",
" #sheets = wb.sheetnames\n", " #sheets = wb.sheetnames\n",
" depart = []\n", " depart = []\n",
" dict1 = {}\n", " dict1 = {}\n",
" new_code = []\n", " new_code = []\n",
" for n in range(2,sheet.max_row+1):\n", " for n in range(2,sheet.max_row+1):\n",
" m_depart = sheet.cell(n,3).value\n", " m_depart = sheet.cell(n,5).value\n",
" if m_depart not in depart:\n", " if m_depart not in depart:\n",
" depart.append(sheet.cell(n,3).value)\n", " depart.append(sheet.cell(n,5).value)\n",
" #print(sheet.cell(n,5).value)\n", " #print(sheet.cell(n,5).value)\n",
"print(depart)\n", "\n",
" dict1['name'] = '中国石油化工股份有限公司安庆炼化分公司'\n",
" dict1['short_name'] = '安庆炼化'\n",
" dict1['depart'] = depart\n",
" mycol.insert_one(dict1)\n",
" print('ok!')\n",
"else:\n",
" print('该单位已存在!') \n",
" " " "
] ]
}, },
{
"cell_type": "markdown",
"id": "bf42e8af-a506-4e60-a661-b4281e3fef54",
"metadata": {},
"source": [
"## 录入体测信息"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "91a8f4f4-c417-4db7-94ba-2d3404e5c2c9",
"metadata": {
"execution": {
"iopub.execute_input": "2021-10-12T07:52:26.950635Z",
"iopub.status.busy": "2021-10-12T07:52:26.949701Z",
"iopub.status.idle": "2021-10-12T07:52:27.307490Z",
"shell.execute_reply": "2021-10-12T07:52:27.304804Z",
"shell.execute_reply.started": "2021-10-12T07:52:26.950528Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
]
}
],
"source": [
"import pymongo\n",
"from bson.objectid import ObjectId\n",
"from dateutil import parser\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"tice\"]\n",
"mycol = mydb[\"unit\"]\n",
"mycol1 = mydb[\"event\"]\n",
"dict1 = {}\n",
"\n",
"name = '中国石油化工股份有限公司安庆炼化分公司'\n",
"myquery = { \"name\": name}\n",
"dict1['code'] = 120\n",
"dict1['unit'] = '中国石油化工股份有限公司安庆炼化分公司'\n",
"dict1['address'] = '安徽安庆'\n",
"dict1['date_begin'] ='2021-09-08'\n",
"dict1['date_end'] = '2021-09-30'\n",
"if mycol.find_one(myquery) is None: \n",
" print('体测单位不存在!')\n",
"else:\n",
" myquery1 = { \"code\": dict1['code']}\n",
" if mycol1.find_one(myquery1) is None:\n",
" mycol1.insert_one(dict1)\n",
" print('ok!')\n",
" else:\n",
" print('该体测信息已经存在!')"
]
},
{
"cell_type": "markdown",
"id": "0c144068-4f2d-4901-bd28-725ecb260fd4",
"metadata": {},
"source": [
"## 导入单位员工信息"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "d80c482d-aee2-45cf-8ac8-c357171f17f7",
"metadata": {
"execution": {
"iopub.execute_input": "2021-10-12T06:40:29.318503Z",
"iopub.status.busy": "2021-10-12T06:40:29.317557Z",
"iopub.status.idle": "2021-10-12T06:40:29.351278Z",
"shell.execute_reply": "2021-10-12T06:40:29.348925Z",
"shell.execute_reply.started": "2021-10-12T06:40:29.318396Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'_id': ObjectId('6164fc343d39c8cdd2d97179'), 'name': '中国石油化工股份有限公司安庆炼化分公司', 'short_name': '安庆炼化', 'depart': ['办公室', '会议中心', '生产计划部', '设备工程部', '发展规划部', '安全环保部', '消防支队', '财务资产部', '企业管理部', '企业发展研究会', '审计部', '党委组织部', '党群工作部', '纪委监督部', '销售中心', '信息中心', '行政事务中心', '炼油一部', '炼油二部', '化工一部', '化工二部', '腈纶部', '热电部', '储运部', '水务部', '运输部', '电气仪表中心', '质管中心', '物资采购中心', '华成公司', '项目管理部', 'AQ基地', '调研']}\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
"import pymongo\n",
"from bson.objectid import ObjectId\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"tice\"]\n",
"mycol = mydb[\"unit\"]\n",
"\n",
"myquery = { \"_id\": ObjectId(\"6164fc343d39c8cdd2d97179\")}\n",
" \n",
"mydoc = mycol.find(myquery)\n",
" \n",
"for x in mydoc:\n",
" print(x)"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "aab6612f-4aad-46f0-89cd-0384ae7ac0c9", "id": "bfed373e-500d-4618-8344-9b8ddd0c5e8c",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": []