861 lines
26 KiB
Plaintext
861 lines
26 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4626da6c-d228-4270-8d8d-c98784a106ad",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 第一次体测"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ba2deee7-9c63-4115-bcee-ad341175fc02",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 人员信息导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "dea5e486-6927-469f-aa57-e5efac4670be",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"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, 2).value)\n",
|
|
" person.setdefault(code, {})\n",
|
|
" dict1 = {}\n",
|
|
" dict1['name'] = sheet.cell(n, 3).value\n",
|
|
" if sheet.cell(n, 4).value ==1:\n",
|
|
" sex = '男'\n",
|
|
" else:\n",
|
|
" sex = '女'\n",
|
|
" dict1['sex'] = sex\n",
|
|
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
|
|
" dict1['birth'] = birth\n",
|
|
" dict1['unit'] = sheet.cell(n, 1).value\n",
|
|
" if sheet.cell(n,10).value is not None:\n",
|
|
" dict1['phone'] = sheet.cell(n, 10).value \n",
|
|
" person[code] = dict1\n",
|
|
"\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": "1c00e1e4-101a-4e9f-a7ed-9c65200d19df",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 成绩导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "fd73b8be-d3fe-49aa-99d2-3cc6df4a3eb0",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"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_20230521.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]['unit'] = dict1[user]['unit']\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",
|
|
"\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": "928790e6-d8a4-4b2b-852a-3c323380a80f",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 成绩导出"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b870bd6e-f972-4073-b13d-5fda8cc92bb7",
|
|
"metadata": {
|
|
"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]['unit'])\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/北京农行体测情况.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": "dd2034ca-fe8b-4322-b06d-8c5eaf96373d",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 报告按部门分类更名"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "04967ec6-b9a0-4097-9e1f-8beaf8a9e75f",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os,sys,shutil\n",
|
|
"import json\n",
|
|
"import math\n",
|
|
"import glob\n",
|
|
"from pathlib import Path\n",
|
|
"\n",
|
|
"fi_path = 'file/2023-05-23'\n",
|
|
"old = []\n",
|
|
"dict2 = {}\n",
|
|
"\n",
|
|
"filename = 'data/result_北京农行.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"\n",
|
|
"for k, v in dict1.items():\n",
|
|
" m_name = v['name']\n",
|
|
" m_depart = v['unit'] \n",
|
|
" dict2[int(k)] = [m_name,m_depart]\n",
|
|
"\n",
|
|
"fls = glob.glob(f'{fi_path}/*.pdf')\n",
|
|
"\n",
|
|
"for fn in fls:\n",
|
|
" old.append(os.path.basename(fn).split('.')[0])\n",
|
|
"\n",
|
|
"for n in old: \n",
|
|
" o_name = f'{fi_path}/{n}.pdf'\n",
|
|
" new_path = Path(fi_path,'new',dict1[n]['unit'])\n",
|
|
" new_path.mkdir(parents = True, exist_ok = True)\n",
|
|
" n_name = Path(new_path,f'{str(n).rjust(5,\"0\")}-{dict2[int(n)][0]}.pdf')\n",
|
|
" if not os.path.exists(n_name):\n",
|
|
" shutil.copyfile(o_name,n_name)\n",
|
|
" print(n_name)\n",
|
|
" \n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "515bc854-5745-4c38-8633-f56a078ea9a8",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-05-25T09:28:28.615647Z",
|
|
"iopub.status.busy": "2023-05-25T09:28:28.614774Z",
|
|
"iopub.status.idle": "2023-05-25T09:28:28.619865Z",
|
|
"shell.execute_reply": "2023-05-25T09:28:28.618821Z",
|
|
"shell.execute_reply.started": "2023-05-25T09:28:28.615607Z"
|
|
}
|
|
},
|
|
"source": [
|
|
"## 生成人员电话信息表"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c925d850-ff06-4be5-bf9f-31f4385c37c0",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"wb = openpyxl.load_workbook('data/农业银行测试手机号码统计表.xlsx')\n",
|
|
"sheet = wb.active\n",
|
|
"# sheets = wb.sheetnames\n",
|
|
"dict1 = {}\n",
|
|
"\n",
|
|
"for n in range(2, sheet.max_row+1):\n",
|
|
" if sheet.cell(n,5).value is not None:\n",
|
|
" phone = str(sheet.cell(n, 5).value)\n",
|
|
" dict1.setdefault(phone,{})\n",
|
|
" code = str(sheet.cell(n, 2).value)\n",
|
|
" unit = sheet.cell(n, 1).value\n",
|
|
" name = sheet.cell(n, 3).value\n",
|
|
" sex = sheet.cell(n, 4).value\n",
|
|
" dict1[phone]['code'] = code\n",
|
|
" dict1[phone]['name'] = name\n",
|
|
" #dict1[phone]['unit'] = unit\n",
|
|
" #dict1[phone]['sex'] = sex\n",
|
|
"filename = 'data/农业银行测试手机号码.json'\n",
|
|
"\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) \n",
|
|
"print(len(dict1))\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0f13e837-15d9-4dc6-b356-78b79bbb5b17",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成验证码"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a87384c6-dc46-4d09-b757-b42462ed818d",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import random\n",
|
|
"import json\n",
|
|
"\n",
|
|
"code_list = []\n",
|
|
"for i in range(10): # 0~9\n",
|
|
" code_list.append(str(i))\n",
|
|
" \n",
|
|
"list1 = []\n",
|
|
"#print(code_num)\n",
|
|
"i = 1\n",
|
|
"while i < 165:\n",
|
|
" code = random.sample(code_list,6) #随机取6位数\n",
|
|
" code_num = ''.join(code)\n",
|
|
" if code_num not in list1:\n",
|
|
" list1.append(code_num)\n",
|
|
" i +=1\n",
|
|
"print(len(list1))\n",
|
|
"print(list1)\n",
|
|
"i = 0\n",
|
|
"filename = 'data/农业银行测试手机号码.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict1[k]['yzm'] = list1[i]\n",
|
|
" i +=1\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict1, fl, ensure_ascii=False) "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "6efc1c2b-7af1-49ec-9b48-8930a8dd2801",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 生成下载链接"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "10845b90-48b4-4418-9dac-dd4a6f0147c0",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"filename = 'data/农业银行测试手机号码.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"dict2 = {}\n",
|
|
"for k, v in dict1.items():\n",
|
|
" dict2.setdefault(v['yzm'],{})\n",
|
|
" dict2[v['yzm']]['code'] = v['code']\n",
|
|
" dict2[v['yzm']]['name'] = v['name']\n",
|
|
"print(len(dict2))\n",
|
|
"filename = 'data/yzm.json'\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(dict2, fl, ensure_ascii=False) \n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "fba0a0c4-edf2-45c2-9199-c6a86919f191",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 发送短信"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "62733f52-62c1-43aa-964a-232eab8b5251",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"from tencentcloud.common import credential\n",
|
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
|
"try: \n",
|
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
|
" cred = credential.Credential(secretId, secretKey) \n",
|
|
" httpProfile = HttpProfile()\n",
|
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
|
" httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)\n",
|
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
|
" clientProfile = ClientProfile()\n",
|
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
|
" clientProfile.language = \"en-US\"\n",
|
|
" clientProfile.httpProfile = httpProfile\n",
|
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
|
" req = models.SendSmsRequest()\n",
|
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
|
" req.SignName = \"坤铭教育\"\n",
|
|
" req.TemplateId = \"1875765\" \n",
|
|
" req.TemplateParamSet = [\"北京石油分公司体测者\",\"01740518\"]\n",
|
|
" req.PhoneNumberSet = [\"+8613793180751\"]\n",
|
|
" req.SessionContext = \"\"\n",
|
|
" req.ExtendCode = \"\"\n",
|
|
" req.SenderId = \"\"\n",
|
|
" resp = client.SendSms(req)\n",
|
|
" print(resp.to_json_string(indent=2))\n",
|
|
"except TencentCloudSDKException as err:\n",
|
|
" print(err)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e924a0a9-65a5-49c4-bdf2-b9152d278ad5",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"dict1 = json.loads(resp.to_json_string(indent=2))\n",
|
|
"print(dict1['SendStatusSet'][0][\"Message\"])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c55a8af0-4e4d-4bd4-b5b1-0a7d9170958c",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 批量发送短信(测试)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "910d1881-d090-48dc-ac87-685ccaaf9553",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"from tencentcloud.common import credential\n",
|
|
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
|
|
"from tencentcloud.sms.v20210111 import sms_client, models\n",
|
|
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
|
|
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
|
|
"import json\n",
|
|
"\n",
|
|
"filename = 'data/短信测试手机号码.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" phone = '+86'+str(k)\n",
|
|
" yzm = v['yzm']\n",
|
|
" try: \n",
|
|
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
|
|
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
|
|
" cred = credential.Credential(secretId, secretKey) \n",
|
|
" httpProfile = HttpProfile()\n",
|
|
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
|
|
" httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)\n",
|
|
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
|
|
" clientProfile = ClientProfile()\n",
|
|
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
|
|
" clientProfile.language = \"en-US\"\n",
|
|
" clientProfile.httpProfile = httpProfile\n",
|
|
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
|
|
" req = models.SendSmsRequest()\n",
|
|
" req.SmsSdkAppId = \"1400140089\"\n",
|
|
" req.SignName = \"坤铭教育\"\n",
|
|
" req.TemplateId = \"1808914\" \n",
|
|
" req.TemplateParamSet = [yzm]\n",
|
|
" req.PhoneNumberSet = [phone]\n",
|
|
" req.SessionContext = \"\"\n",
|
|
" req.ExtendCode = \"\"\n",
|
|
" req.SenderId = \"\"\n",
|
|
" #resp = client.SendSms(req)\n",
|
|
" dict2 = json.loads(resp.to_json_string(indent=2))\n",
|
|
"\n",
|
|
" print(v['name'],dict2['SendStatusSet'][0][\"Message\"])\n",
|
|
" except TencentCloudSDKException as err:\n",
|
|
" print(v['name'],err)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "59d38404-e097-4f08-a3fd-565e351f09bb",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 第二次体测"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "deeb7606-5752-4337-9117-4ba9edc762e9",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 人员信息导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d803a2b2-4a61-42ba-84a3-e9846e3e9f5c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"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, 3).value\n",
|
|
" if sheet.cell(n, 4).value ==1:\n",
|
|
" sex = '男'\n",
|
|
" else:\n",
|
|
" sex = '女'\n",
|
|
" dict1['sex'] = sex\n",
|
|
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
|
|
" dict1['birth'] = birth\n",
|
|
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
|
" if sheet.cell(n,6).value is not None:\n",
|
|
" dict1['phone'] = sheet.cell(n, 6).value \n",
|
|
" person[code] = dict1\n",
|
|
"\n",
|
|
"filename = 'data/北京农行人员名单2308.json'\n",
|
|
"with open(filename, 'w') as fl:\n",
|
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
|
"print('ok')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ff97823f-fd67-45ae-bd78-f209317be6b9",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 成绩导入"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4adf86dd-addf-490a-9954-5dcac4693868",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"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/北京农行人员名单2308.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20230825.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]['unit'] = dict1[user]['unit']\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_北京农行0825.json'\n",
|
|
"\n",
|
|
"with open(filename,'w') as fl:\n",
|
|
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
|
"print(len(re_ta))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "bb01b9a9-418d-4a1b-8ea9-1215af0b8285",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"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/北京农行人员名单2308.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"\n",
|
|
"filename = 'data/places_result_20230825.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]['unit'] = dict1[user]['unit']\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_北京农行0825.json'\n",
|
|
"\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": "4d2a0d63-4124-4063-96a7-a02478b9eabe",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 查看项目不足人员"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b26857af-5fa3-42d0-bf79-bc33d9f5e4a8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import time\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"filename = 'data/result_北京农行0825.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
"i= 0\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if len(v.keys())< 8:\n",
|
|
" print(k,v['name'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1966307c-4161-4c5b-b19a-b8a143972223",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 导出测试人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "288e39fb-b7e3-4566-ac13-ba98d7e72edb",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import openpyxl\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/result_北京农行0825.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"list1 =[]\n",
|
|
"for k, v in dict1.items():\n",
|
|
" list2 = []\n",
|
|
" list2 = [k,v['name'],v['sex'],v['unit']]\n",
|
|
" list1.append(list2)\n",
|
|
"filename = 'data/北京农行测试人员202308.xlsx'\n",
|
|
"wb = openpyxl.Workbook()\n",
|
|
"sheet = wb.active\n",
|
|
"\n",
|
|
"for row in list1:\n",
|
|
" sheet.append(row)\n",
|
|
" \n",
|
|
"wb.save(filename)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a42cb587-8673-4655-8943-3cbd63f22b73",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 检查性别"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6352b95c-0e19-4943-9e99-218138213060",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/result_北京农行0825.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl)\n",
|
|
"for k, v in dict1.items():\n",
|
|
" if v['sex'] == '男' and '一分钟仰卧起坐' in v.keys():\n",
|
|
" print(k,'应为女性!')\n",
|
|
" if v['sex'] == '女' and '俯卧撑' in v.keys():\n",
|
|
" print(k,'应为男性!')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "fddd68cd-b20c-4cf9-b503-5d59f52e3c1b",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 手工数据生成SQL"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "372294de-5370-41c0-9883-b18de9d8ef7e",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import openpyxl\n",
|
|
"import json\n",
|
|
"\n",
|
|
"\n",
|
|
"wb = openpyxl.load_workbook('data/北京农行测试人员202308.xlsx')\n",
|
|
"sheet = wb.active\n",
|
|
"# sheets = wb.sheetnames\n",
|
|
"dict1 = {}\n",
|
|
"\n",
|
|
"data1 =list(sheet.values)\n",
|
|
"del data1[0]\n",
|
|
"list1 = []\n",
|
|
"for item in data1:\n",
|
|
" code = int(item[0])\n",
|
|
" list1.append((309118,code,5,item[4],'2023-08-23','2023-08-23 22:00:00'))\n",
|
|
"print(list1)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c32bdb5c-d987-4b0f-98e3-9ce4e3ef3671",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 核对问卷人员信息"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "c1b187e0-f566-43fa-88d8-090deb9ead19",
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-09-13T07:58:04.130282Z",
|
|
"iopub.status.busy": "2023-09-13T07:58:04.129816Z",
|
|
"iopub.status.idle": "2023-09-13T07:58:04.144786Z",
|
|
"shell.execute_reply": "2023-09-13T07:58:04.143845Z",
|
|
"shell.execute_reply.started": "2023-09-13T07:58:04.130228Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"import csv\n",
|
|
"\n",
|
|
"\n",
|
|
"filename = 'data/北京农行人员名单2308.json'\n",
|
|
"with open(filename,'r') as fl:\n",
|
|
" dict1 = json.load(fl) \n",
|
|
" \n",
|
|
"filename = 'data/Survey_20230913.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",
|
|
" code = str(line[4])\n",
|
|
" name = line[3]\n",
|
|
" \n",
|
|
" if code not in dict1.keys() or name!= dict1[code]['name']:\n",
|
|
" print(code,name)\n",
|
|
" \n",
|
|
" "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8c89b12a-0ab5-4792-94b6-456e352a00ce",
|
|
"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.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|