971 lines
32 KiB
Plaintext
971 lines
32 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "bf152e7d-6a36-4877-98d9-f11e3a73792e",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 导入人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 32,
|
||
"id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T06:27:55.181932Z",
|
||
"iopub.status.busy": "2023-05-16T06:27:55.181018Z",
|
||
"iopub.status.idle": "2023-05-16T06:27:57.546786Z",
|
||
"shell.execute_reply": "2023-05-16T06:27:57.545822Z",
|
||
"shell.execute_reply.started": "2023-05-16T06:27:55.181895Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"8206\n",
|
||
"8171\n",
|
||
"8109\n",
|
||
"ok\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"\n",
|
||
"wb = openpyxl.load_workbook('data/燕山石化人员情况表.xlsx')\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"person = {}\n",
|
||
"\n",
|
||
"for n in range(2, sheet.max_row+1):\n",
|
||
" if sheet.cell(n,1).value is not None:\n",
|
||
" code = int(sheet.cell(n, 1).value)\n",
|
||
" person.setdefault(code, {})\n",
|
||
" dict1 = {}\n",
|
||
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||
" if sheet.cell(n, 7).value ==1:\n",
|
||
" sex = '男'\n",
|
||
" else:\n",
|
||
" sex = '女'\n",
|
||
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||
" birth = str(sheet.cell(n, 6).value).split()[0]\n",
|
||
" dict1['birth'] = birth\n",
|
||
" if sheet.cell(n,5).value is not None:\n",
|
||
" dict1['phone'] = sheet.cell(n, 5).value\n",
|
||
" if sheet.cell(n,7).value is not None:\n",
|
||
" dict1['id_num'] = sheet.cell(n, 7).value\n",
|
||
" if sheet.cell(n,8).value is not None:\n",
|
||
" dict1['SAP'] = sheet.cell(n, 8).value\n",
|
||
" if sheet.cell(n,9).value is not None:\n",
|
||
" dict1['工作单位'] = sheet.cell(n, 9).value\n",
|
||
" if sheet.cell(n,10).value is not None:\n",
|
||
" dict1['车间'] = sheet.cell(n, 10).value\n",
|
||
" else:\n",
|
||
" dict1['车间'] =''\n",
|
||
" if sheet.cell(n,11).value is not None:\n",
|
||
" dict1['班组'] = sheet.cell(n, 11).value\n",
|
||
" else:\n",
|
||
" dict1['班组'] =''\n",
|
||
" if sheet.cell(n,12).value is not None:\n",
|
||
" dict1['工作性质'] = sheet.cell(n, 11).value\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",
|
||
"\n",
|
||
"print(len(person))\n",
|
||
"for k in jianyuan:\n",
|
||
" if k in person.keys():\n",
|
||
" del person[k]\n",
|
||
"print(len(person))\n",
|
||
"bianwai =[449,6839]\n",
|
||
"for i in range(7139,7200):\n",
|
||
" bianwai.append(i)\n",
|
||
"for k in bianwai:\n",
|
||
" if k in person.keys():\n",
|
||
" del person[k]\n",
|
||
"print(len(person))\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename, 'w') as fl:\n",
|
||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||
"print('ok')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "f5c73dff-697d-4ba5-a90c-9bed68eaf4b3",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 每日成绩导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 33,
|
||
"id": "71e1ec6a-6797-4496-969a-1d1461b9ea58",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T08:36:31.303752Z",
|
||
"iopub.status.busy": "2023-05-16T08:36:31.302937Z",
|
||
"iopub.status.idle": "2023-05-16T08:36:31.711617Z",
|
||
"shell.execute_reply": "2023-05-16T08:36:31.710715Z",
|
||
"shell.execute_reply.started": "2023-05-16T08:36:31.303711Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"214\n",
|
||
"8151 赵春先 已测试!\n",
|
||
"999 张术申 已测试!\n",
|
||
"2709 刘巍 已测试!\n",
|
||
"214\n",
|
||
"7598\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"\n",
|
||
"filename = '../item.json'\n",
|
||
"item = {}\n",
|
||
"unit = {}\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"for k,v in dict1.items():\n",
|
||
" item[k] = v\n",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20230516.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",
|
||
"for result in list1:\n",
|
||
" user = str(result[2])\n",
|
||
" if user in dict1.keys(): \n",
|
||
" m_item = str(result[3]) \n",
|
||
" re_ta.setdefault(user,{}) \n",
|
||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||
" re_ta[user]['部门'] = dict1[user]['工作单位']\n",
|
||
" item_name = item[m_item]['name']\n",
|
||
" re_ta[user].setdefault(item_name,{}) \n",
|
||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||
"print(len(re_ta))\n",
|
||
"filename = 'data/result_燕山石化.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"for k in re_ta.keys():\n",
|
||
" if k in dict2.keys():\n",
|
||
" print(k,dict2[k]['name'],'已测试!')\n",
|
||
"for k, v in re_ta.items():\n",
|
||
" if k not in dict2.keys():\n",
|
||
" dict2[k] = v\n",
|
||
" else:\n",
|
||
" for k1,v1 in v.items():\n",
|
||
" dict2[k][k1] = v1\n",
|
||
"filename = 'data/result_燕山石化(20230516).json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||
"print(len(re_ta))\n",
|
||
"filename = 'data/result_燕山石化.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict2, fl, ensure_ascii=False) \n",
|
||
"print(len(dict2))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "79147ba8-4b90-40ba-81a9-e6062600c239",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 每日成绩导出"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 34,
|
||
"id": "c24880ad-bbbd-4ad8-a894-cbcea389e822",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T08:37:27.708591Z",
|
||
"iopub.status.busy": "2023-05-16T08:37:27.707778Z",
|
||
"iopub.status.idle": "2023-05-16T08:37:27.839300Z",
|
||
"shell.execute_reply": "2023-05-16T08:37:27.838623Z",
|
||
"shell.execute_reply.started": "2023-05-16T08:37:27.708561Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_燕山石化(20230516).json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['工作单位']) \n",
|
||
" list2.append(dict2[k]['车间'])\n",
|
||
" list2.append(dict2[k]['班组'])\n",
|
||
" for item in items:\n",
|
||
" if item in v.keys():\n",
|
||
" list2.append(v[item]['成绩']) \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(v[item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/燕山石化体测情况表(20230516).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "1cd93a0e-8340-4bd0-a8fd-747f149b256d",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 总成绩导出"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 198,
|
||
"id": "79c9c728-12e9-4107-bc5a-8c3e3d8b64a6",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-08T00:52:23.460649Z",
|
||
"iopub.status.busy": "2023-05-08T00:52:23.459824Z",
|
||
"iopub.status.idle": "2023-05-08T00:52:25.090804Z",
|
||
"shell.execute_reply": "2023-05-08T00:52:25.090044Z",
|
||
"shell.execute_reply.started": "2023-05-08T00:52:23.460608Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"\n",
|
||
"filename = 'data/result_燕山石化.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
" \n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['工作单位']) \n",
|
||
" list2.append(dict2[k]['车间'])\n",
|
||
" list2.append(dict2[k]['班组'])\n",
|
||
" for item in items:\n",
|
||
" if item in v.keys():\n",
|
||
" list2.append(v[item]['成绩']) \n",
|
||
" elif item =='name':\n",
|
||
" list2.append(v[item])\n",
|
||
" else:\n",
|
||
" list2.append('') \n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/燕山石化体测情况表(截至20230506).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "6d431fc1-b743-467c-91b3-9788e245becb",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计部门测试人数"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 35,
|
||
"id": "68454877-f1fe-4eed-8a48-265e428f892e",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T08:37:50.893472Z",
|
||
"iopub.status.busy": "2023-05-16T08:37:50.892954Z",
|
||
"iopub.status.idle": "2023-05-16T08:37:50.917547Z",
|
||
"shell.execute_reply": "2023-05-16T08:37:50.916456Z",
|
||
"shell.execute_reply.started": "2023-05-16T08:37:50.893441Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"{'储运厂工会': 9, '热电厂工会': 65, '炼油厂工会': 48, '合成橡胶厂工会': 31, '检验计量中心工会': 34, '烯烃厂工会': 4, '化学品厂工会': 8, '合成树脂厂': 4, '生产运行保障中心': 1, '高科公司工会': 3, '有机化工厂工会': 3, '机关工会': 4}\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'data/result_燕山石化(20230516).json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['部门']\n",
|
||
" dict2.setdefault(unit,0)\n",
|
||
" dict2[unit] = dict2[unit] + 1\n",
|
||
"print(dict2)\n",
|
||
"title =['单位','体测人数']\n",
|
||
"list1 = [] \n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" list2 = [k,v]\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/燕山石化部门测试人数情况表(20230516).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)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "8becc0af-d22b-46a2-b35e-9122942515d4",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 每日未测试人员情况表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 26,
|
||
"id": "7085bf6f-7465-44fb-bddb-38130fbe5618",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-17T12:58:45.236098Z",
|
||
"iopub.status.busy": "2023-04-17T12:58:45.235274Z",
|
||
"iopub.status.idle": "2023-04-17T12:58:46.270936Z",
|
||
"shell.execute_reply": "2023-04-17T12:58:46.270191Z",
|
||
"shell.execute_reply.started": "2023-04-17T12:58:45.236059Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位','车间','班组']\n",
|
||
"filename = 'data/result_燕山石化(20230417).json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" if k not in dict1.keys():\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['工作单位']) \n",
|
||
" list2.append(dict2[k]['车间'])\n",
|
||
" list2.append(dict2[k]['班组'])\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/燕山石化未体测人员名单(20230417).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) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "3231f52d-776f-4d29-b6f5-c28f6a0c30a9",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 汇总未测试人员情况表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 37,
|
||
"id": "eddf7dab-b28d-402a-aeaf-27c120048ecb",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T08:44:33.173111Z",
|
||
"iopub.status.busy": "2023-05-16T08:44:33.172278Z",
|
||
"iopub.status.idle": "2023-05-16T08:44:33.373625Z",
|
||
"shell.execute_reply": "2023-05-16T08:44:33.372928Z",
|
||
"shell.execute_reply.started": "2023-05-16T08:44:33.173071Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"\n",
|
||
"title = ['编号','姓名','性别','单位','车间','班组']\n",
|
||
"filename = 'data/result_燕山石化.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"# 筛选重名剔除名单\n",
|
||
"chongming = []\n",
|
||
"filename = 'data/燕山石化重名人员测试情况(20230515).xlsx'\n",
|
||
"wb = openpyxl.load_workbook(filename)\n",
|
||
"sheet = wb.active\n",
|
||
"for n in range(1, sheet.max_row+1,2):\n",
|
||
" if sheet.cell(n,1).value is not None:\n",
|
||
" code1 = int(sheet.cell(n, 1).value)\n",
|
||
" code2 = int(sheet.cell(n+1, 1).value)\n",
|
||
" bz1 = sheet.cell(n, 4).value\n",
|
||
" bz2 = sheet.cell(n+1, 4).value\n",
|
||
" if bz1 =='否' and bz2 =='否':\n",
|
||
" chongming.append(max(code1,code2))\n",
|
||
" else:\n",
|
||
" chongming.append(code1)\n",
|
||
" chongming.append(code2)\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" if k not in dict1.keys() and int(k) not in chongming:\n",
|
||
" list2.append(str(k).rjust(5,'0'))\n",
|
||
" list2.append(v['name']) \n",
|
||
" list2.append(dict2[k]['sex'])\n",
|
||
" list2.append(dict2[k]['工作单位']) \n",
|
||
" list2.append(dict2[k]['车间'])\n",
|
||
" list2.append(dict2[k]['班组'])\n",
|
||
" list1.append(list2)\n",
|
||
"filename = 'data/燕山石化未体测人员名单(截至20230516).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet.append(title)\n",
|
||
"for row in list1:\n",
|
||
" sheet.append(row)\n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "4dd9b2b7-bd3d-4d5b-ac84-3a49bcada8b5",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计测试项目不足人员"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 8,
|
||
"id": "641863ef-324f-4c33-a0a9-699031afb6f1",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-11T04:50:37.384699Z",
|
||
"iopub.status.busy": "2023-05-11T04:50:37.383858Z",
|
||
"iopub.status.idle": "2023-05-11T04:50:37.543557Z",
|
||
"shell.execute_reply": "2023-05-11T04:50:37.542638Z",
|
||
"shell.execute_reply.started": "2023-05-11T04:50:37.384657Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"[['4025', '马珺', '教育培训中心工会', '身高,体重,选择反应时'], ['7790', '吴志鹏', '生产运行保障中心', '身高,体重,握力'], ['8151', '赵春先', '合成树脂厂', '身高,体重,握力'], ['7682', '孙宏林', '有机化工厂工会', '肺活量,身高,体重'], ['2004', '刘鹏', '合成树脂厂', '身高,体重,握力'], ['3125', '李志斌', '化学品厂工会', '身高,体重,握力']]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||
"filename = 'data/result_燕山石化-all.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"dict3 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" list1 = []\n",
|
||
" for item in v.keys():\n",
|
||
" if item in items:\n",
|
||
" list1.append(item)\n",
|
||
" dict3[k] = list1\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict3.items():\n",
|
||
" if len(v)<4 and '身高' in v and '体重' in v:\n",
|
||
" list2 = []\n",
|
||
" xm = ','.join(v)\n",
|
||
" list2.append(k)\n",
|
||
" list2.append(dict2[k]['name'])\n",
|
||
" list2.append(dict2[k]['工作单位'])\n",
|
||
" list2.append(xm)\n",
|
||
" list1.append(list2)\n",
|
||
"print(list1)\n",
|
||
"filename = 'data/燕山石化测试项目不足人员(截止5月11日).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"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "d3a69840-29fc-434d-af47-ad864f9e511c",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 汇总成绩导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"id": "b735248a-c1b0-4e90-8df4-37cd7625cb1a",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-14T14:16:50.290820Z",
|
||
"iopub.status.busy": "2023-05-14T14:16:50.290016Z",
|
||
"iopub.status.idle": "2023-05-14T14:16:51.077768Z",
|
||
"shell.execute_reply": "2023-05-14T14:16:51.076992Z",
|
||
"shell.execute_reply.started": "2023-05-14T14:16:50.290789Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"7117\n",
|
||
"7117\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"\n",
|
||
"filename = '../item.json'\n",
|
||
"item = {}\n",
|
||
"unit = {}\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"for k,v in dict1.items():\n",
|
||
" item[k] = v\n",
|
||
"re_ta = {}\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"\n",
|
||
"filename = 'data/places_result_20230514.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",
|
||
"for result in list1:\n",
|
||
" user = str(result[2])\n",
|
||
" if user in dict1.keys(): \n",
|
||
" m_item = str(result[3]) \n",
|
||
" re_ta.setdefault(user,{}) \n",
|
||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||
" re_ta[user]['sex'] = dict1[user]['sex'] \n",
|
||
" re_ta[user]['部门'] = dict1[user]['工作单位']\n",
|
||
" item_name = item[m_item]['name']\n",
|
||
" re_ta[user].setdefault(item_name,{}) \n",
|
||
" score = int(result[4])/item[m_item]['divisor'] \n",
|
||
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
|
||
"print(len(re_ta))\n",
|
||
"\n",
|
||
"filename = 'data/result_燕山石化-all.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||
"print(len(re_ta))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "5bdcad97-309f-4d29-82c4-b53c68b9ee22",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计重复人员信息"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 132,
|
||
"id": "0dd5da15-92e0-45c2-b9e9-11417210974e",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-04-27T07:22:33.663659Z",
|
||
"iopub.status.busy": "2023-04-27T07:22:33.662808Z",
|
||
"iopub.status.idle": "2023-04-27T07:22:35.472369Z",
|
||
"shell.execute_reply": "2023-04-27T07:22:35.471662Z",
|
||
"shell.execute_reply.started": "2023-04-27T07:22:33.663618Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"list2 = set()\n",
|
||
"filename = 'data/燕山石化人员名单.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl) \n",
|
||
"filename = 'data/result_燕山石化-all.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl) \n",
|
||
"\n",
|
||
"for k,v in dict1.items():\n",
|
||
" name = v['name']\n",
|
||
" if name in list1:\n",
|
||
" list2.add(name)\n",
|
||
" list1.append(name)\n",
|
||
"list3 = []\n",
|
||
"for item in list2:\n",
|
||
" for k,v in dict1.items():\n",
|
||
" if v['name'] == item:\n",
|
||
" list3.append([k,v['name'],v['sex'],v['birth']])\n",
|
||
"filename = 'data/燕山石化重名人员名单.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"#sheet.append(title)\n",
|
||
"for row in list3:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "96375506-0cca-4a9b-b0da-162460d25e51",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 重复人员测试情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 36,
|
||
"id": "5df8eb8f-3594-40be-a491-b4d750bbd554",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-16T08:44:02.431464Z",
|
||
"iopub.status.busy": "2023-05-16T08:44:02.430604Z",
|
||
"iopub.status.idle": "2023-05-16T08:44:02.587531Z",
|
||
"shell.execute_reply": "2023-05-16T08:44:02.586608Z",
|
||
"shell.execute_reply.started": "2023-05-16T08:44:02.431421Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"ename": "KeyError",
|
||
"evalue": "'7160'",
|
||
"output_type": "error",
|
||
"traceback": [
|
||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
|
||
"Cell \u001b[0;32mIn[36], line 27\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sheet\u001b[38;5;241m.\u001b[39mcell(n,\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mvalue \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 26\u001b[0m code \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(sheet\u001b[38;5;241m.\u001b[39mcell(n, \u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mvalue)\n\u001b[0;32m---> 27\u001b[0m name \u001b[38;5;241m=\u001b[39m \u001b[43mdict1\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcode\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 28\u001b[0m unit \u001b[38;5;241m=\u001b[39m dict1[\u001b[38;5;28mstr\u001b[39m(code)][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m工作单位\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(code) \u001b[38;5;129;01min\u001b[39;00m dict2\u001b[38;5;241m.\u001b[39mkeys():\n",
|
||
"\u001b[0;31mKeyError\u001b[0m: '7160'"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import time\n",
|
||
"import csv\n",
|
||
"\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"list2 = set()\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",
|
||
"\n",
|
||
"list3 = []\n",
|
||
"\n",
|
||
"filename = 'data/燕山石化重名人员名单.xlsx'\n",
|
||
"wb = openpyxl.load_workbook(filename)\n",
|
||
"sheet = wb.active\n",
|
||
"# sheets = wb.sheetnames\n",
|
||
"\n",
|
||
"\n",
|
||
"for n in range(1, sheet.max_row+1):\n",
|
||
" if sheet.cell(n,1).value is not None:\n",
|
||
" code = int(sheet.cell(n, 1).value)\n",
|
||
" name = dict1[str(code)]['name']\n",
|
||
" unit = dict1[str(code)]['工作单位']\n",
|
||
" if str(code) in dict2.keys():\n",
|
||
" ce = '是'\n",
|
||
" else:\n",
|
||
" ce = '否'\n",
|
||
" list3.append([code,name,unit,ce])\n",
|
||
"filename = 'data/燕山石化重名人员测试情况(20230516).xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"#sheet.append(title)\n",
|
||
"for row in list3:\n",
|
||
" sheet.append(row)\n",
|
||
" \n",
|
||
"wb.save(filename) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "0513a787-f2e2-4ee6-9c67-c94c50e62393",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 统计部门测试情况"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 193,
|
||
"id": "48a0b2b8-c069-4d2d-9813-d65474749000",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-06T12:38:29.815090Z",
|
||
"iopub.status.busy": "2023-05-06T12:38:29.814674Z",
|
||
"iopub.status.idle": "2023-05-06T12:38:29.943125Z",
|
||
"shell.execute_reply": "2023-05-06T12:38:29.942309Z",
|
||
"shell.execute_reply.started": "2023-05-06T12:38:29.815063Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"[['机关工会', 446, 365], ['储运厂工会', 997, 780], ['高科公司工会', 311, 292], ['合成树脂厂', 464, 317], ['合成橡胶厂工会', 770, 310], ['化学品厂工会', 378, 296], ['检验计量中心工会', 635, 297], ['教育培训中心工会', 73, 72], ['炼油厂工会', 1043, 640], ['热电厂工会', 710, 121], ['物装中心工会', 182, 182], ['烯烃厂工会', 433, 287], ['消防中心工会', 221, 214], ['行政事务中心(离退中心)工会', 675, 503], ['有机化工厂工会', 454, 435], ['生产运行保障中心', 398, 367]]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\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",
|
||
" dict3 = json.load(fl)\n",
|
||
"dict2 = {}\n",
|
||
"for k, v in dict1.items():\n",
|
||
" unit = v['工作单位']\n",
|
||
" dict2.setdefault(unit,0)\n",
|
||
" dict2[unit] = dict2[unit] + 1\n",
|
||
"dict4 = {}\n",
|
||
"for k, v in dict3.items():\n",
|
||
" unit = v['部门']\n",
|
||
" dict4.setdefault(unit,0)\n",
|
||
" dict4[unit] = dict4[unit] + 1\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict2.items():\n",
|
||
" list2 = []\n",
|
||
" list2.append(k)\n",
|
||
" list2.append(v)\n",
|
||
" if k in dict4.keys():\n",
|
||
" list2.append(dict4[k])\n",
|
||
" else:\n",
|
||
" list2.append(0)\n",
|
||
" list1.append(list2)\n",
|
||
"print(list1)\n",
|
||
"filename = 'data/燕山石化部门测试情况(截止5月6日).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"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 217,
|
||
"id": "c294db76-adc4-41bf-9ee6-811dde1905e8",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-09T02:59:10.544101Z",
|
||
"iopub.status.busy": "2023-05-09T02:59:10.543244Z",
|
||
"iopub.status.idle": "2023-05-09T02:59:10.550360Z",
|
||
"shell.execute_reply": "2023-05-09T02:59:10.549157Z",
|
||
"shell.execute_reply.started": "2023-05-09T02:59:10.544059Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"bs b'\\xc2\\xed\\xc1\\xa2\\xd1\\xc7'\n",
|
||
"decode-bs: 马立亚\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"#C2EDC1A2D1C7\n",
|
||
"gbs = 'C2EDC1A2D1C7'\n",
|
||
"import binascii\n",
|
||
"bs = binascii.a2b_hex(gbs)\n",
|
||
"print('bs', bs)\n",
|
||
"print('decode-bs:', bs.decode('gb2312'))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 219,
|
||
"id": "9924d06a-8753-4856-9ccc-f3d5f8956bb2",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-05-09T03:06:42.922674Z",
|
||
"iopub.status.busy": "2023-05-09T03:06:42.921808Z",
|
||
"iopub.status.idle": "2023-05-09T03:06:42.929473Z",
|
||
"shell.execute_reply": "2023-05-09T03:06:42.928345Z",
|
||
"shell.execute_reply.started": "2023-05-09T03:06:42.922633Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"gbcode: b'\\xc2\\xed\\xc1\\xa2\\xd1\\xc7'\n",
|
||
"gbs: c2edc1a2d1c7\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"s = '马立亚'\n",
|
||
"gbcode = s.encode('gb2312') # 先转成 bytes格式\n",
|
||
"print('gbcode:', gbcode)\n",
|
||
"gbs = \"\".join([hex(ch)[2:] for ch in gbcode]) #\n",
|
||
"print('gbs:', gbs)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "930f3a2c-e39b-4d2c-916e-c99588e90274",
|
||
"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
|
||
}
|