This commit is contained in:
512song committed 2023-05-22 17:33:01 +08:00
1 parent 2e7d800503
commit 91ae3fce79
3 files changed
+598 -128

No files matched your search

+232
View File
@@ -0,0 +1,232 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "4b3853d4-d30f-4b1d-99de-fa52777ce65c",
"metadata": {},
"source": [
"## 体质指标问卷导入"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "202a0266-f578-4d75-b04c-5ae9957391bf",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-22T08:51:23.135343Z",
"iopub.status.busy": "2023-05-22T08:51:23.134459Z",
"iopub.status.idle": "2023-05-22T08:51:23.150352Z",
"shell.execute_reply": "2023-05-22T08:51:23.149334Z",
"shell.execute_reply.started": "2023-05-22T08:51:23.135304Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = 'data/淄博交警体质指标问卷.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"for items in dict1['pages']:\n",
" for item in items['elements']:\n",
" #print(item)\n",
" dict2.setdefault(item['name'],{})\n",
" name = item['name']\n",
" dict2[name]['type'] = item['type']\n",
" dict2[name]['title'] = item['title']['zh-cn']\n",
" if 'isRequired' in item.keys():\n",
" dict2[name]['isRequired'] = item['isRequired']\n",
" else:\n",
" dict2[name]['isRequired'] = False\n",
" if item['type'] == 'text':\n",
" dict2[name]['inputType'] = item['inputType']\n",
" else:\n",
" dict2[name]['choices'] = item['choices']\n",
"filename = 'data/淄博交警体质问卷参数.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "d7ab7cfd-3448-45a6-abb4-04e7f317b843",
"metadata": {},
"source": [
"## 问卷数据分析"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "e05bb84b-e649-4201-95d7-f9fee7b1a254",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-22T09:31:19.028959Z",
"iopub.status.busy": "2023-05-22T09:31:19.028116Z",
"iopub.status.idle": "2023-05-22T09:31:19.043637Z",
"shell.execute_reply": "2023-05-22T09:31:19.042568Z",
"shell.execute_reply.started": "2023-05-22T09:31:19.028917Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"13718887655\n",
"您的性别 女性\n",
"您的年龄 39\n",
"您的身高(cm) 160\n",
"您的体重(kg) 52\n",
"您的血压(BP) 临界偏低(收缩压90-94mmHg和/或舒张压60-65mmHg)\n",
"您的空腹血糖(FPG) 正常(3.89-6.1mmol/L)\n",
"您的白细胞计数(WBC) 临界偏高(9.6-10×10^9/L)\n",
"您的血红蛋白(HGB) 临界偏低(110-114g/L)\n",
"您的血小板(PLT) 正常(125-350×10^9/L)\n",
"您的低密度脂蛋白(LDL-C) 临界偏高(5.18-6.19mmol/L)\n",
"您的甘油三酯(TG) 正常(0.45-1.69mmol/L)\n",
"您的尿酸(UA) 正常(155.00- 350.00 μmol/L)\n",
"您的肌酐(Cr) 正常(44.00- 73.00μmol/L)\n",
"您的谷丙转氨酶(ALT) 正常(7.00- 19.00U/L)\n",
"您的谷草转氨酶(AST) 正常(13.00- 35.00U/L)\n",
"您的甲状腺功能 正常\n",
"您的尿蛋白 阴性\n",
"您的便潜血 阴性\n",
"您的幽门螺旋杆菌 阴性\n",
"囊肿(选做题,没有囊肿问题的请跳过) ['卵巢囊肿']\n",
"结节(选做题,没有结节问题的请跳过) ['肺结节']\n",
"息肉(选做题,没有息肉问题的请跳过) ['其他息肉']\n",
"您的其他问题(选做题,没有这些问题的请跳过) ['过敏性鼻炎']\n",
"您的饮食口味 ['清淡']\n",
"您吸烟吗 不吸烟\n",
"您喝酒吗 不喝\n",
"您参加规律的体育锻炼吗 不参加\n",
"您的睡眠状况如何 非常好\n",
"您的排便频率如何 2天一次\n",
"您的职业 管理人员\n",
"您的父母或兄弟姐妹是否患有明确诊断的疾病?(选做题,没有遗传病史的请跳过) ['高血压', '冠心病', '脑卒中']\n",
"15210715398\n",
"您的性别 女性\n",
"您的年龄 36\n",
"您的身高(cm) 162\n",
"您的体重(kg) 56\n",
"您的血压(BP) 正常(收缩压95-130mmHg和舒张压65-85mmHg)\n",
"您的空腹血糖(FPG) 正常(3.89-6.1mmol/L)\n",
"您的白细胞计数(WBC) 正常(4-9.5×10^9/L)\n",
"您的血红蛋白(HGB) 正常(115-145g/L)\n",
"您的血小板(PLT) 正常(125-350×10^9/L)\n",
"您的低密度脂蛋白(LDL-C) 正常(3.1-5.18mmol/L)\n",
"您的甘油三酯(TG) 正常(0.45-1.69mmol/L)\n",
"您的尿酸(UA) 正常(155.00- 350.00 μmol/L)\n",
"您的肌酐(Cr) 正常(44.00- 73.00μmol/L)\n",
"您的谷丙转氨酶(ALT) 正常(7.00- 19.00U/L)\n",
"您的谷草转氨酶(AST) 正常(13.00- 35.00U/L)\n",
"您的甲状腺功能 正常\n",
"您的尿蛋白 阴性\n",
"您的便潜血 阴性\n",
"您的幽门螺旋杆菌 阴性\n",
"您的心脏(选做题,没有心脏问题的请跳过) ['窦性心律不齐']\n",
"您的饮食口味 ['辛辣']\n",
"您吸烟吗 不吸烟\n",
"您喝酒吗 不喝\n",
"您参加规律的体育锻炼吗 经常参加(平均每周锻炼3次及以上,每次锻炼>30分钟)\n",
"您的睡眠状况如何 非常好\n",
"您的排便频率如何 2天一次\n",
"您的职业 行政工作\n",
"您的父母或兄弟姐妹是否患有明确诊断的疾病?(选做题,没有遗传病史的请跳过) ['高血压']\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"filename = 'data/淄博交警体质问卷参数.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/Survey_20230522.json'\n",
"item = {}\n",
"unit = {}\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for items in dict2['Survey']:\n",
" #print(items)\n",
" phone = items['phone']\n",
" print(phone)\n",
" data = json.loads(items['data'])\n",
" for k, v in data.items():\n",
" if dict1[k]['type'] == 'radiogroup':\n",
" title = dict1[k]['title']\n",
" for item in dict1[k]['choices']:\n",
" if item['value'] == v:\n",
" value = item['text']\n",
" \n",
" if dict1[k]['type'] == 'text':\n",
" title = dict1[k]['title']\n",
" value = v\n",
" if dict1[k]['type'] == 'checkbox':\n",
" title = dict1[k]['title']\n",
" value = []\n",
" for choice in v:\n",
" for item in dict1[k]['choices']:\n",
" if item['value'] == choice:\n",
" value.append(item['text'])\n",
"\n",
" print(title,value) \n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f5c6a39a-3e3e-4844-8ff8-b9ebb7e8f8af",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
+244 -61
View File
@@ -350,9 +350,9 @@
" data_list.append((int(k),v['name'])) \n", " data_list.append((int(k),v['name'])) \n",
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n", "conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
"cursor = conn.cursor()\n", "cursor = conn.cursor()\n",
"sql = 'insert into tianjin_item (id,name) values %s'\n", "sql = 'insert into shijiazhuang_item (id,name) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"conn.commit()\n", "#conn.commit()\n",
"cursor.close()\n", "cursor.close()\n",
"conn.close()\n", "conn.close()\n",
"print('ok!')" "print('ok!')"
@@ -381,7 +381,7 @@
"\n", "\n",
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n", "conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
"cursor = conn.cursor()\n", "cursor = conn.cursor()\n",
"filename = 'data/天津石化人员名单.json'\n", "filename = 'data/result_石家庄.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"unit = set()\n", "unit = set()\n",
@@ -399,9 +399,9 @@
"for k, v in dict2.items():\n", "for k, v in dict2.items():\n",
" data_list.append((v,k)) \n", " data_list.append((v,k)) \n",
" \n", " \n",
"sql = 'insert into tianjin_unit (id,name) values %s'\n", "sql = 'insert into shijiazhuang_unit (id,name) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"conn.commit()\n", "#conn.commit()\n",
"cursor.close()\n", "cursor.close()\n",
"conn.close()\n", "conn.close()\n",
"print('ok!')" "print('ok!')"
@@ -457,7 +457,7 @@
" i+=1\n", " i+=1\n",
"sql = 'insert into tianjin_sub_unit (id,name,unit_id) values %s'\n", "sql = 'insert into tianjin_sub_unit (id,name,unit_id) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"conn.commit()\n", "#conn.commit()\n",
"cursor.close()\n", "cursor.close()\n",
"conn.close()\n", "conn.close()\n",
"print('ok!')" "print('ok!')"
@@ -484,7 +484,7 @@
"import csv\n", "import csv\n",
"\n", "\n",
"dict1 = {}\n", "dict1 = {}\n",
"filename = 'data/unit_134.csv'\n", "filename = 'data/shijiazhuang_unit_20230517.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n", "with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n", " fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl)\n", " header = next(fl)\n",
@@ -511,6 +511,36 @@
"print(len(dict1)) " "print(len(dict1)) "
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "5e57329d-a0ef-47b2-9866-fe2a911ff01d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import csv\n",
"\n",
"dict1 = {}\n",
"filename = 'data/shijiazhuang_unit_20230517.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl)\n",
" list1 = []\n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append({'id':int(line[0]),'name':line[1]})\n",
" dict1[int(line[0])] = line[1]\n",
"\n",
"\n",
"filename = 'data/石家庄石化部门.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False) \n",
"print(len(dict1)) "
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "53bf98fe-0ae9-402f-b8d8-495e8f31df3d", "id": "53bf98fe-0ae9-402f-b8d8-495e8f31df3d",
@@ -538,15 +568,10 @@
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" person = json.load(fl)\n", " person = json.load(fl)\n",
" \n", " \n",
"filename = 'data/天津石化人员名单.json'\n", "filename = 'data/石家庄石化部门.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"unit = set()\n", "\n",
"for k, v in dict1.items():\n",
" #if 'sub_unit' not in v.keys():\n",
" # print(k,v['name'])\n",
" unit.add(v['unit'])\n",
"print(unit) \n",
"i = 1\n", "i = 1\n",
"dict2 = {}\n", "dict2 = {}\n",
"for item in unit:\n", "for item in unit:\n",
@@ -591,13 +616,54 @@
" data_list.append((id,name,sex,birth,unit))\n", " data_list.append((id,name,sex,birth,unit))\n",
"sql = 'insert into tianjin_person (id,name,sex,birth,unit_id) values %s'\n", "sql = 'insert into tianjin_person (id,name,sex,birth,unit_id) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"conn.commit()\n", "#conn.commit()\n",
"cursor.close()\n", "cursor.close()\n",
"conn.close()\n", "conn.close()\n",
"print('ok!') \n", "print('ok!') \n",
" " " "
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "c2007c46-38c8-4a20-9917-b0b8743fe2a9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import psycopg2\n",
"from psycopg2 import extras as ex\n",
"\n",
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
"cursor = conn.cursor()\n",
" \n",
"filename = 'data/石家庄石化部门.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"dict3 = {}\n",
"for k,v in dict1.items():\n",
" dict3[v] = int(k)\n",
"filename = 'data/result_石家庄.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl)\n",
"data_list = []\n",
"for k, v in dict2.items():\n",
" id = int(k)\n",
" name = dict2[k]['name']\n",
" sex = dict2[k]['sex']\n",
" birth = dict2[k]['birth'] \n",
" unit = dict3[dict2[k]['unit']]\n",
" data_list.append((id,name,sex,birth,unit))\n",
"sql = 'insert into shijiazhuang_person (id,name,sex,birth,unit_id) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"#conn.commit()\n",
"cursor.close()\n",
"conn.close()\n",
"print('ok!') "
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "fd95a45a-c6df-47c3-9941-2d0579b2c5d9", "id": "fd95a45a-c6df-47c3-9941-2d0579b2c5d9",
@@ -607,28 +673,23 @@
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": 84, "id": "c989de3f-a8ab-47dc-9662-544e4b6a0e2f",
"id": "360e61e9-7895-484b-a9d6-333bdefa1a86",
"metadata": { "metadata": {
"execution": {
"iopub.execute_input": "2023-05-01T04:48:05.728955Z",
"iopub.status.busy": "2023-05-01T04:48:05.728103Z",
"iopub.status.idle": "2023-05-01T04:48:08.066386Z",
"shell.execute_reply": "2023-05-01T04:48:08.065262Z",
"shell.execute_reply.started": "2023-05-01T04:48:05.728912Z"
},
"tags": [] "tags": []
}, },
"outputs": [ "source": [
{ "#### 二级部门导入"
"name": "stdout",
"output_type": "stream",
"text": [
"ok!\n"
] ]
} },
], {
"cell_type": "code",
"execution_count": null,
"id": "360e61e9-7895-484b-a9d6-333bdefa1a86",
"metadata": {
"tags": []
},
"outputs": [],
"source": [ "source": [
"import json\n", "import json\n",
"import psycopg2\n", "import psycopg2\n",
@@ -685,13 +746,21 @@
" \n", " \n",
"sql = 'insert into tianjin_records (performance,score,avatar_id_id,item_id_id,unit_id_id,sub_unit_id_id) values %s'\n", "sql = 'insert into tianjin_records (performance,score,avatar_id_id,item_id_id,unit_id_id,sub_unit_id_id) values %s'\n",
"ex.execute_values(cursor, sql, data_list, page_size=10000)\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
"conn.commit()\n", "#conn.commit()\n",
"cursor.close()\n", "cursor.close()\n",
"conn.close()\n", "conn.close()\n",
"print('ok!') \n", "print('ok!') \n",
" " " "
] ]
}, },
{
"cell_type": "markdown",
"id": "4aeabbbc-5b51-4dd0-b428-83e2012e63c4",
"metadata": {},
"source": [
"#### 一级部门导入"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -712,47 +781,37 @@
"for k, v in dict1.items():\n", "for k, v in dict1.items():\n",
" dict2[v['name']] = int(k)\n", " dict2[v['name']] = int(k)\n",
"\n", "\n",
"filename = 'data/天津石化部门.json'\n", "filename = 'data/石家庄石化部门.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"unit = {}\n",
"for item in dict1['unit']:\n",
" unit[item['name']] = item['id']\n",
"\n",
"sub_unit = {}\n",
"for item in dict1['sub_unit']:\n",
" sub_unit.setdefault(item['unit_id'],[])\n",
" sub_unit[item['unit_id']].append({'id':item['id'],'name':item['name']})\n",
" \n",
"filename = 'data/天津石化人员名单.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"person = {}\n", "dict3 = {}\n",
"for k, v in dict1.items():\n", "for k,v in dict1.items():\n",
" person[k] = {'unit':v['unit'],'sub_unit':v['sub_unit']}\n", " dict3[v] = int(k)\n",
"\n",
" \n", " \n",
"\n",
"conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n", "conn = psycopg2.connect(database=\"mycrm\", user=\"postgres\", password=\"songyi\", host=\"localhost\", port=\"5432\")\n",
"cursor = conn.cursor()\n", "cursor = conn.cursor()\n",
"data_list = []\n", "data_list = []\n",
"filename = 'data/result_天津.json'\n", "filename = 'data/result_石家庄.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"for k, v in dict1.items():\n", "for k, v in dict1.items():\n",
" for item in v.keys():\n", " for item in v.keys():\n",
" if item in dict2.keys():\n", " if item in dict2.keys():\n",
" item_id = dict2[item]\n", " item_id = dict2[item] \n",
" if v[item]['得分'] == '\\\\N':\n", " if v[item]['得分'] == '':\n",
" score = None\n", " score = None\n",
" else:\n", " else:\n",
" score = int(v[item]['得分'])\n", " score = int(v[item]['得分'])\n",
" unit_name = person[k]['unit'] \n", " unit_name = v['unit']\n",
" sub_unit_name = person[k]['sub_unit']\n", " unit_id = dict3[unit_name]\n",
" unit_id = unit[unit_name]\n", " data_list.append((v[item]['成绩'],score,int(k),item_id,unit_id))\n",
" for items in sub_unit[unit_id]:\n", "sql = 'insert into shijiazhuang_records (performance,score,avatar_id_id,item_id_id,unit_id_id) values %s'\n",
" if items['name'] ==sub_unit_name:\n", "ex.execute_values(cursor, sql, data_list, page_size=10000)\n",
" sub_id = items['id'] \n", "#conn.commit()\n",
" print(unit_id,sub_id)" "cursor.close()\n",
"conn.close()\n",
"print('ok!')"
] ]
}, },
{ {
@@ -781,6 +840,130 @@
" unit[item['name']] = item['id']\n", " unit[item['name']] = item['id']\n",
"print(unit)" "print(unit)"
] ]
},
{
"cell_type": "markdown",
"id": "bdb81e20-32ec-4e0e-b2ac-13dac2060068",
"metadata": {
"tags": []
},
"source": [
"# 体质报告在线管理"
]
},
{
"cell_type": "markdown",
"id": "1485fc89-4fc2-437d-a29e-b4a0aab12aa0",
"metadata": {},
"source": [
"## 新增体测单位"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "cf345bf0-f11b-459e-9b69-b2843836f6f3",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-19T08:30:41.861658Z",
"iopub.status.busy": "2023-05-19T08:30:41.860765Z",
"iopub.status.idle": "2023-05-19T08:30:42.006745Z",
"shell.execute_reply": "2023-05-19T08:30:42.006220Z",
"shell.execute_reply.started": "2023-05-19T08:30:41.861616Z"
},
"tags": []
},
"outputs": [],
"source": [
"import pymongo\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"baogao\"]\n",
"mycol = mydb[\"place\"]\n",
"\n",
"mydict = { \"id\": \"714309\",\"name\": \"中国石化石家庄炼化公司\", }\n",
" \n",
"x = mycol.insert_one(mydict) "
]
},
{
"cell_type": "markdown",
"id": "df2d18e2-d2e4-499e-876a-59d8550a8201",
"metadata": {},
"source": [
"## 新增报告信息"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "1acaf159-637e-4101-9881-f6bb79400136",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-19T09:08:35.287714Z",
"iopub.status.busy": "2023-05-19T09:08:35.286693Z",
"iopub.status.idle": "2023-05-19T09:08:35.304177Z",
"shell.execute_reply": "2023-05-19T09:08:35.303461Z",
"shell.execute_reply.started": "2023-05-19T09:08:35.287667Z"
},
"tags": []
},
"outputs": [],
"source": [
"import pymongo\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"baogao\"]\n",
"mycol = mydb[\"pdf\"]\n",
"\n",
"mydict = { \"place\": \"714309\",\"code\":\"4\",\"name\": \"朱维\", }\n",
" \n",
"x = mycol.insert_one(mydict) "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ad3078ac-ae53-4bb4-95bd-387631092bf1",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-20T04:06:02.667541Z",
"iopub.status.busy": "2023-05-20T04:06:02.667013Z",
"iopub.status.idle": "2023-05-20T04:06:02.681377Z",
"shell.execute_reply": "2023-05-20T04:06:02.680428Z",
"shell.execute_reply.started": "2023-05-20T04:06:02.667502Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'_id': ObjectId('64673c9319e8481e9c0ad1a3'), 'place': '714309', 'code': '4', 'name': '朱维'}\n"
]
}
],
"source": [
"import pymongo\n",
"\n",
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
"mydb = myclient[\"baogao\"]\n",
"mycol = mydb[\"pdf\"]\n",
"\n",
"mydict = { \"place\": \"714309\",\"code\":\"4\",\"name\": \"朱维\", }\n",
" \n",
"x = mycol.find_one(mydict) \n",
"print(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cc0571b6-1da5-4bcc-96ad-5613cd1198e3",
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
+122 -67
View File
@@ -10,15 +10,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32, "execution_count": 10,
"id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16", "id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-16T06:27:55.181932Z", "iopub.execute_input": "2023-05-18T12:36:59.824733Z",
"iopub.status.busy": "2023-05-16T06:27:55.181018Z", "iopub.status.busy": "2023-05-18T12:36:59.824148Z",
"iopub.status.idle": "2023-05-16T06:27:57.546786Z", "iopub.status.idle": "2023-05-18T12:37:02.051168Z",
"shell.execute_reply": "2023-05-16T06:27:57.545822Z", "shell.execute_reply": "2023-05-18T12:37:02.050045Z",
"shell.execute_reply.started": "2023-05-16T06:27:55.181895Z" "shell.execute_reply.started": "2023-05-18T12:36:59.824691Z"
}, },
"tags": [] "tags": []
}, },
@@ -27,9 +27,9 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"8206\n", "8208\n",
"8171\n", "8208\n",
"8109\n", "8208\n",
"ok\n" "ok\n"
] ]
} }
@@ -76,19 +76,19 @@
" if sheet.cell(n,12).value is not None:\n", " if sheet.cell(n,12).value is not None:\n",
" dict1['工作性质'] = sheet.cell(n, 11).value\n", " dict1['工作性质'] = sheet.cell(n, 11).value\n",
" person[code] = dict1\n", " person[code] = dict1\n",
"jianyuan = [6484,7110,6441,6541,6543,6549,6555,6600,2958,2981,3033,3231,3249,3287,3228,7741,7749,7794,7799,7806,7837,7863,7870,7880,7894,7895,7904,7936,7947,7953,7958,7968,7969,7974,8086,8114]\n", "#jianyuan = [6484,7110,6441,6541,6543,6549,6555,6600,2958,2981,3033,3231,3249,3287,3228,7741,7749,7794,7799,7806,7837,7863,7870,7880,7894,7895,7904,7936,7947,7953,7958,7968,7969,7974,8086,8114]\n",
"\n", "\n",
"print(len(person))\n", "print(len(person))\n",
"for k in jianyuan:\n", "#for k in jianyuan:\n",
" if k in person.keys():\n", "# if k in person.keys():\n",
" del person[k]\n", "# del person[k]\n",
"print(len(person))\n", "print(len(person))\n",
"bianwai =[449,6839]\n", "#bianwai =[449,6839]\n",
"for i in range(7139,7200):\n", "#for i in range(7139,7200):\n",
" bianwai.append(i)\n", "# bianwai.append(i)\n",
"for k in bianwai:\n", "#for k in bianwai:\n",
" if k in person.keys():\n", "# if k in person.keys():\n",
" del person[k]\n", "# del person[k]\n",
"print(len(person))\n", "print(len(person))\n",
"filename = 'data/燕山石化人员名单.json'\n", "filename = 'data/燕山石化人员名单.json'\n",
"with open(filename, 'w') as fl:\n", "with open(filename, 'w') as fl:\n",
@@ -106,15 +106,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 33, "execution_count": 4,
"id": "71e1ec6a-6797-4496-969a-1d1461b9ea58", "id": "71e1ec6a-6797-4496-969a-1d1461b9ea58",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-16T08:36:31.303752Z", "iopub.execute_input": "2023-05-17T08:58:25.400000Z",
"iopub.status.busy": "2023-05-16T08:36:31.302937Z", "iopub.status.busy": "2023-05-17T08:58:25.399131Z",
"iopub.status.idle": "2023-05-16T08:36:31.711617Z", "iopub.status.idle": "2023-05-17T08:58:25.810982Z",
"shell.execute_reply": "2023-05-16T08:36:31.710715Z", "shell.execute_reply": "2023-05-17T08:58:25.810241Z",
"shell.execute_reply.started": "2023-05-16T08:36:31.303711Z" "shell.execute_reply.started": "2023-05-17T08:58:25.399960Z"
}, },
"tags": [] "tags": []
}, },
@@ -123,12 +123,10 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"214\n", "133\n",
"8151 赵春先 已测试!\n", "2004 刘鹏 已测试!\n",
"999 张术申 已测试!\n", "133\n",
"2709 刘巍 已测试!\n", "7730\n"
"214\n",
"7598\n"
] ]
} }
], ],
@@ -151,7 +149,7 @@
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"\n", "\n",
"filename = 'data/places_result_20230516.csv'\n", "filename = 'data/places_result_20230517.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n", "with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n", " fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n", " header = next(fl) \n",
@@ -184,7 +182,7 @@
" else:\n", " else:\n",
" for k1,v1 in v.items():\n", " for k1,v1 in v.items():\n",
" dict2[k][k1] = v1\n", " dict2[k][k1] = v1\n",
"filename = 'data/result_燕山石化(20230516).json'\n", "filename = 'data/result_燕山石化(20230517).json'\n",
"with open(filename,'w') as fl:\n", "with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl, ensure_ascii=False) \n", " json.dump(re_ta, fl, ensure_ascii=False) \n",
"print(len(re_ta))\n", "print(len(re_ta))\n",
@@ -204,15 +202,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 5,
"id": "c24880ad-bbbd-4ad8-a894-cbcea389e822", "id": "c24880ad-bbbd-4ad8-a894-cbcea389e822",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-16T08:37:27.708591Z", "iopub.execute_input": "2023-05-17T09:00:37.129834Z",
"iopub.status.busy": "2023-05-16T08:37:27.707778Z", "iopub.status.busy": "2023-05-17T09:00:37.129418Z",
"iopub.status.idle": "2023-05-16T08:37:27.839300Z", "iopub.status.idle": "2023-05-17T09:00:37.212119Z",
"shell.execute_reply": "2023-05-16T08:37:27.838623Z", "shell.execute_reply": "2023-05-17T09:00:37.211419Z",
"shell.execute_reply.started": "2023-05-16T08:37:27.708561Z" "shell.execute_reply.started": "2023-05-17T09:00:37.129806Z"
}, },
"tags": [] "tags": []
}, },
@@ -224,7 +222,7 @@
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n", "\n",
"filename = 'data/result_燕山石化(20230516).json'\n", "filename = 'data/result_燕山石化(20230517).json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"\n", "\n",
@@ -249,7 +247,7 @@
" else:\n", " else:\n",
" list2.append('') \n", " list2.append('') \n",
" list1.append(list2)\n", " list1.append(list2)\n",
"filename = 'data/燕山石化体测情况表(20230516).xlsx'\n", "filename = 'data/燕山石化体测情况表(20230517).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",
@@ -269,15 +267,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 198, "execution_count": 12,
"id": "79c9c728-12e9-4107-bc5a-8c3e3d8b64a6", "id": "79c9c728-12e9-4107-bc5a-8c3e3d8b64a6",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-08T00:52:23.460649Z", "iopub.execute_input": "2023-05-18T12:37:39.026994Z",
"iopub.status.busy": "2023-05-08T00:52:23.459824Z", "iopub.status.busy": "2023-05-18T12:37:39.026072Z",
"iopub.status.idle": "2023-05-08T00:52:25.090804Z", "iopub.status.idle": "2023-05-18T12:37:41.214470Z",
"shell.execute_reply": "2023-05-08T00:52:25.090044Z", "shell.execute_reply": "2023-05-18T12:37:41.213773Z",
"shell.execute_reply.started": "2023-05-08T00:52:23.460608Z" "shell.execute_reply.started": "2023-05-18T12:37:39.026953Z"
}, },
"tags": [] "tags": []
}, },
@@ -289,7 +287,7 @@
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"\n", "\n",
"filename = 'data/result_燕山石化.json'\n", "filename = 'data/result_燕山石化-all.json'\n",
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n", " dict1 = json.load(fl)\n",
"\n", "\n",
@@ -314,7 +312,7 @@
" else:\n", " else:\n",
" list2.append('') \n", " list2.append('') \n",
" list1.append(list2)\n", " list1.append(list2)\n",
"filename = 'data/燕山石化体测情况表(截至20230506).xlsx'\n", "filename = 'data/燕山石化体测情况表.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",
@@ -523,15 +521,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 3,
"id": "641863ef-324f-4c33-a0a9-699031afb6f1", "id": "641863ef-324f-4c33-a0a9-699031afb6f1",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-11T04:50:37.384699Z", "iopub.execute_input": "2023-05-17T01:34:11.475000Z",
"iopub.status.busy": "2023-05-11T04:50:37.383858Z", "iopub.status.busy": "2023-05-17T01:34:11.474266Z",
"iopub.status.idle": "2023-05-11T04:50:37.543557Z", "iopub.status.idle": "2023-05-17T01:34:11.673023Z",
"shell.execute_reply": "2023-05-11T04:50:37.542638Z", "shell.execute_reply": "2023-05-17T01:34:11.672256Z",
"shell.execute_reply.started": "2023-05-11T04:50:37.384657Z" "shell.execute_reply.started": "2023-05-17T01:34:11.474959Z"
}, },
"tags": [] "tags": []
}, },
@@ -540,7 +538,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"[['4025', '马珺', '教育培训中心工会', '身高,体重,选择反应时'], ['7790', '吴志鹏', '生产运行保障中心', '身高,体重,握力'], ['8151', '赵春先', '合成树脂厂', '身高,体重,握力'], ['7682', '孙宏林', '有机化工厂工会', '肺活量,身高,体重'], ['2004', '刘鹏', '合成树脂厂', '身高,体重,握力'], ['3125', '李志斌', '化学品厂工会', '身高,体重,握力']]\n" "[['4025', '马珺', '教育培训中心工会', '身高,体重,选择反应时'], ['7790', '吴志鹏', '生产运行保障中心', '身高,体重,握力'], ['3377', '安明海', '检验计量中心工会', '俯卧撑,纵跳'], ['3520', '于海军', '检验计量中心工会', '握力'], ['3125', '李志斌', '化学品厂工会', '身高,体重,握力'], ['5690', '胡勇', '热电厂工会', '身高,体重'], ['4551', '韩立江', '炼油厂工会', '身高,体重'], ['8150', '王重荃', '高科公司工会', '台阶指数']]\n"
] ]
} }
], ],
@@ -566,7 +564,7 @@
" dict3[k] = list1\n", " dict3[k] = list1\n",
"list1 = []\n", "list1 = []\n",
"for k, v in dict3.items():\n", "for k, v in dict3.items():\n",
" if len(v)<4 and '身高' in v and '体重' in v:\n", " if len(v)<4 and '身高' in v and '体重' in v or ((len(v)<3 and '身高' not in v and '体重' not in v)):\n",
" list2 = []\n", " list2 = []\n",
" xm = ','.join(v)\n", " xm = ','.join(v)\n",
" list2.append(k)\n", " list2.append(k)\n",
@@ -575,7 +573,7 @@
" list2.append(xm)\n", " list2.append(xm)\n",
" list1.append(list2)\n", " list1.append(list2)\n",
"print(list1)\n", "print(list1)\n",
"filename = 'data/燕山石化测试项目不足人员(截止5月11日).xlsx'\n", "filename = 'data/燕山石化测试项目不足人员(截止5月16日).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",
@@ -595,15 +593,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 11,
"id": "b735248a-c1b0-4e90-8df4-37cd7625cb1a", "id": "b735248a-c1b0-4e90-8df4-37cd7625cb1a",
"metadata": { "metadata": {
"execution": { "execution": {
"iopub.execute_input": "2023-05-14T14:16:50.290820Z", "iopub.execute_input": "2023-05-18T12:37:18.648377Z",
"iopub.status.busy": "2023-05-14T14:16:50.290016Z", "iopub.status.busy": "2023-05-18T12:37:18.647570Z",
"iopub.status.idle": "2023-05-14T14:16:51.077768Z", "iopub.status.idle": "2023-05-18T12:37:19.435077Z",
"shell.execute_reply": "2023-05-14T14:16:51.076992Z", "shell.execute_reply": "2023-05-18T12:37:19.434303Z",
"shell.execute_reply.started": "2023-05-14T14:16:50.290789Z" "shell.execute_reply.started": "2023-05-18T12:37:18.648344Z"
}, },
"tags": [] "tags": []
}, },
@@ -612,8 +610,8 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"7117\n", "7734\n",
"7117\n" "7734\n"
] ]
} }
], ],
@@ -636,7 +634,7 @@
"with open(filename,'r') as fl:\n", "with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n", " dict1 = json.load(fl) \n",
"\n", "\n",
"filename = 'data/places_result_20230514.csv'\n", "filename = 'data/places_result_20230518.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n", "with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n", " fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n", " header = next(fl) \n",
@@ -664,6 +662,63 @@
"print(len(re_ta))" "print(len(re_ta))"
] ]
}, },
{
"cell_type": "markdown",
"id": "fbdf2c54-7303-43ad-bbec-0fbcd033603a",
"metadata": {},
"source": [
"## 统计测试人数"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "6d10738f-8da8-4f18-970b-e67433a06661",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-18T12:55:07.441554Z",
"iopub.status.busy": "2023-05-18T12:55:07.440708Z",
"iopub.status.idle": "2023-05-18T12:55:07.819534Z",
"shell.execute_reply": "2023-05-18T12:55:07.818801Z",
"shell.execute_reply.started": "2023-05-18T12:55:07.441512Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7734\n"
]
}
],
"source": [
"import json\n",
"import time\n",
"import csv\n",
"\n",
"person = set()\n",
"filename = 'data/places_result_20230518.csv'\n",
"with open(filename,'r',newline='') as csv_file:\n",
" fl = csv.reader(csv_file,delimiter=',')\n",
" header = next(fl) \n",
" for line in fl:\n",
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
" list1.append(line)\n",
"#print(list1)\n",
"filename = 'data/燕山石化人员名单.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"for result in list1:\n",
" user = str(result[2])\n",
" if user in dict1.keys():\n",
" person.add(user)\n",
"\n",
"print(len(person))"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "5bdcad97-309f-4d29-82c4-b53c68b9ee22", "id": "5bdcad97-309f-4d29-82c4-b53c68b9ee22",