20251124
This commit is contained in:
1 parent
4f0f65a076
commit
aff0303bc9
5 files changed
+2192
-1715
No files matched your search
+1889
-151
File diff suppressed because it is too large.
Load diff
+75
-22
@@ -3413,15 +3413,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 24,
|
||||
"id": "c101eccb-a2f3-4404-9583-682cec049160",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-10T10:34:09.617871Z",
|
||||
"iopub.status.busy": "2025-11-10T10:34:09.617343Z",
|
||||
"iopub.status.idle": "2025-11-10T10:34:10.297071Z",
|
||||
"shell.execute_reply": "2025-11-10T10:34:10.296491Z",
|
||||
"shell.execute_reply.started": "2025-11-10T10:34:09.617822Z"
|
||||
"iopub.execute_input": "2025-11-21T13:09:40.491935Z",
|
||||
"iopub.status.busy": "2025-11-21T13:09:40.491689Z",
|
||||
"iopub.status.idle": "2025-11-21T13:09:41.068111Z",
|
||||
"shell.execute_reply": "2025-11-21T13:09:41.067547Z",
|
||||
"shell.execute_reply.started": "2025-11-21T13:09:40.491915Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -3429,7 +3429,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"5053 ok\n"
|
||||
"5057 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -3521,15 +3521,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 25,
|
||||
"id": "52de3ba0-f430-444b-87e9-1f13c3e2dcc2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-19T10:29:58.335947Z",
|
||||
"iopub.status.busy": "2025-11-19T10:29:58.335228Z",
|
||||
"iopub.status.idle": "2025-11-19T10:29:58.415390Z",
|
||||
"shell.execute_reply": "2025-11-19T10:29:58.414784Z",
|
||||
"shell.execute_reply.started": "2025-11-19T10:29:58.335884Z"
|
||||
"iopub.execute_input": "2025-11-21T13:09:49.032705Z",
|
||||
"iopub.status.busy": "2025-11-21T13:09:49.032208Z",
|
||||
"iopub.status.idle": "2025-11-21T13:09:49.211933Z",
|
||||
"shell.execute_reply": "2025-11-21T13:09:49.211382Z",
|
||||
"shell.execute_reply.started": "2025-11-21T13:09:49.032662Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -3537,7 +3537,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1138\n"
|
||||
"1898\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -3551,7 +3551,7 @@
|
||||
"filename = 'data/天津石化人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/marks_20251119.csv'\n",
|
||||
"filename = 'data/marks_20251121.csv'\n",
|
||||
"re_ta = My.get_result(filename,dict1)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -3623,15 +3623,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 26,
|
||||
"id": "fcb3c816-5260-4807-9536-b8203680ed1c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-19T10:23:38.619220Z",
|
||||
"iopub.status.busy": "2025-11-19T10:23:38.618501Z",
|
||||
"iopub.status.idle": "2025-11-19T10:23:38.645291Z",
|
||||
"shell.execute_reply": "2025-11-19T10:23:38.644881Z",
|
||||
"shell.execute_reply.started": "2025-11-19T10:23:38.619162Z"
|
||||
"iopub.execute_input": "2025-11-21T13:10:04.169431Z",
|
||||
"iopub.status.busy": "2025-11-21T13:10:04.168764Z",
|
||||
"iopub.status.idle": "2025-11-21T13:10:04.215983Z",
|
||||
"shell.execute_reply": "2025-11-21T13:10:04.215442Z",
|
||||
"shell.execute_reply.started": "2025-11-21T13:10:04.169372Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -3669,7 +3669,7 @@
|
||||
" list2 = [k,v['人数'],v['体测人数']]\n",
|
||||
" list1.append(list2)\n",
|
||||
"\n",
|
||||
"filename = 'data/天津石化部门测试情况(20241119).xlsx'\n",
|
||||
"filename = 'data/天津石化部门测试情况(截至20241121).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(title)\n",
|
||||
@@ -3679,6 +3679,59 @@
|
||||
"wb.save(filename)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "386e1cf1-74d4-4aad-a228-b30e65ffd710",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计未体测人员明细表"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"id": "df8b9405-a2d9-413d-bcf4-205704b0243a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-21T13:10:36.807855Z",
|
||||
"iopub.status.busy": "2025-11-21T13:10:36.807222Z",
|
||||
"iopub.status.idle": "2025-11-21T13:10:37.013652Z",
|
||||
"shell.execute_reply": "2025-11-21T13:10:37.013094Z",
|
||||
"shell.execute_reply.started": "2025-11-21T13:10:36.807795Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = 'data/result_天津石化2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/天津石化人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"\n",
|
||||
"i = 1\n",
|
||||
"for k, v in dict2.items(): \n",
|
||||
" if k not in dict1.keys():\n",
|
||||
" list2 = [i,k,v['name'],v['unit']]\n",
|
||||
" i+=1\n",
|
||||
" list1.append(list2)\n",
|
||||
"#print(list1)\n",
|
||||
"filename = f'data/天津石化未测试人员名单(截至20251121).xlsx'\n",
|
||||
"title = ['序号','员工编号','姓名','部门']\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": "85a03b00-9624-4ae9-aa6d-386798d457df",
|
||||
|
||||
+142
-138
@@ -1142,7 +1142,7 @@
|
||||
"\n",
|
||||
"title = []\n",
|
||||
"\n",
|
||||
"filename = 'data/surveys_records_宁夏能化.json'\n",
|
||||
"filename = 'data/surveys_records_2025-11-24.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
@@ -1156,17 +1156,18 @@
|
||||
" else:\n",
|
||||
" list2.append('')\n",
|
||||
" for xm in data_title:\n",
|
||||
" if xm in item['data'].keys():\n",
|
||||
" data = json.loads(item['data'])\n",
|
||||
" if xm in data.keys():\n",
|
||||
" if xm =='sport_type':\n",
|
||||
" list2.append(','.join(item['data'][xm]))\n",
|
||||
" list2.append(','.join(data[xm]))\n",
|
||||
" else:\n",
|
||||
" list2.append(item['data'][xm])\n",
|
||||
" list2.append(data[xm])\n",
|
||||
" else:\n",
|
||||
" list2.append('')\n",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"all_title = ['id', 'date_created','name', 'gender', 'birth', 'code', 'unit', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷(20251114).xlsx'\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷(20251123).xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"sheet.append(all_title)\n",
|
||||
@@ -1218,7 +1219,7 @@
|
||||
" password=\"songyi\"\n",
|
||||
")\n",
|
||||
"cur = conn.cursor()\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251114).xlsx',data_only=True)\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251123).xlsx',data_only=True)\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
@@ -1251,6 +1252,80 @@
|
||||
"conn.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d266379b-4797-4f60-a83d-dc2349a48f0b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 核对新增人员"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import psycopg2\n",
|
||||
"\n",
|
||||
"conn = psycopg2.connect(\n",
|
||||
" host=\"localhost\",\n",
|
||||
" database=\"tice\",\n",
|
||||
" user=\"mydata\",\n",
|
||||
" password=\"songyi\"\n",
|
||||
")\n",
|
||||
"cur = conn.cursor()\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251123).xlsx',data_only=True)\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"org_id = 1\n",
|
||||
"event_id = 1\n",
|
||||
"sql = \"SELECT code from fitness_person where org_id = %s\"\n",
|
||||
"params = (org_id,)\n",
|
||||
"cur.execute(sql, params)\n",
|
||||
"rows = cur.fetchall()\n",
|
||||
"codes = []\n",
|
||||
"for row in rows:\n",
|
||||
" codes.append(row[0])\n",
|
||||
"\n",
|
||||
"person = {}\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" code = str(sheet.cell(n, 6).value)\n",
|
||||
" if code not in codes:\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 3).value\n",
|
||||
" sex = sheet.cell(n, 4).value\n",
|
||||
" if sex =='male':\n",
|
||||
" dict1['sex'] = '男'\n",
|
||||
" else:\n",
|
||||
" dict1['sex'] = '女'\n",
|
||||
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
|
||||
" if len(birth)==7:\n",
|
||||
" dict1['birth'] = birth+'-01'\n",
|
||||
" else:\n",
|
||||
" dict1['birth'] = birth\n",
|
||||
" dict1['unit'] = sheet.cell(n, 7).value\n",
|
||||
" person[code] = dict1\n",
|
||||
"org_id = 1\n",
|
||||
"data1 = []\n",
|
||||
"for k,v in person.items():\n",
|
||||
" tuple1 = (v['name'],v['sex'],v['unit'],v['birth'],k,org_id)\n",
|
||||
" print(tuple1)\n",
|
||||
" data1.append(tuple1)\n",
|
||||
"sql = \"INSERT INTO fitness_person ( name, sex,unit,birth,code,org_id) VALUES (%s, %s, %s,%s, %s, %s)\" \n",
|
||||
"#print(data1)\n",
|
||||
"cur.executemany(sql, data1)\n",
|
||||
"conn.commit()\n",
|
||||
"\n",
|
||||
"# 关闭连接\n",
|
||||
"cur.close()\n",
|
||||
"conn.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5c2a37a0-18d3-4c89-8dd9-283a417b5c60",
|
||||
@@ -1329,15 +1404,31 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 106,
|
||||
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-24T05:18:02.990193Z",
|
||||
"iopub.status.busy": "2025-11-24T05:18:02.989559Z",
|
||||
"iopub.status.idle": "2025-11-24T05:18:03.293675Z",
|
||||
"shell.execute_reply": "2025-11-24T05:18:03.293166Z",
|
||||
"shell.execute_reply.started": "2025-11-24T05:18:02.990132Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"483 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251114).xlsx',data_only=True)\n",
|
||||
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251123).xlsx',data_only=True)\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
@@ -1356,21 +1447,23 @@
|
||||
" person[code] = dict1\n",
|
||||
"#print(person)\n",
|
||||
"\n",
|
||||
"filename = 'data/surveys_records_宁夏能化.json'\n",
|
||||
"filename = 'data/surveys_records_2025-11-24.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"set1 = set()\n",
|
||||
"title = ['date_created', 'height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose_Comment', 'last_recipe_Comment', 'last_lose_weight', 'last_sport_Comment', 'sport_type_Comment']\n",
|
||||
"data_title = ['height', 'weight', 'next_weight', 'waist', 'hip', 'level4', 'level3', 'level2', 'recipe', 'level1', 'last_level4', 'last_level3', 'last_level2', 'last_level1', 'last_recipe', 'last_lose', 'last_sport', 'sport_type', 'sport_duration', 'last_sport_time', 'last_lose-Comment', 'last_recipe-Comment', 'last_lose_weight', 'last_sport-Comment', 'sport_type-Comment']\n",
|
||||
"for item in dict1: \n",
|
||||
" dict2 = {}\n",
|
||||
" code = item['data']['code']\n",
|
||||
" data = json.loads(item['data'])\n",
|
||||
" code = data['code']\n",
|
||||
" rq = item['date_created'].split()[0]\n",
|
||||
" dict2['height'] = str('%.2f' % item['data']['height'])\n",
|
||||
" dict2['weight'] = str('%.2f' %item['data']['weight'])\n",
|
||||
" dict2['next_weight'] = str('%.2f' %(item['data']['weight']-item['data']['next_weight']))\n",
|
||||
" dict2['bmi'] = str('%.2f' %((item['data']['weight']/item['data']['height'])/item['data']['height']*10000))\n",
|
||||
" bmi = (item['data']['weight']/item['data']['height'])/item['data']['height']*10000\n",
|
||||
" dict2['height'] = str('%.2f' % data['height'])\n",
|
||||
" dict2['weight'] = str('%.2f' %data['weight'])\n",
|
||||
" dict2['next_weight'] = str('%.2f' %(data['weight']-data['next_weight']))\n",
|
||||
" dict2['bmi'] = str('%.2f' %((data['weight']/data['height'])/data['height']*10000))\n",
|
||||
" bmi = (data['weight']/data['height'])/data['height']*10000\n",
|
||||
" if bmi<18.5:\n",
|
||||
" bmi_zt = '体重偏轻'\n",
|
||||
" elif bmi >=18.5 and bmi <24.0:\n",
|
||||
@@ -1380,39 +1473,39 @@
|
||||
" else:\n",
|
||||
" bmi_zt = '体重肥胖'\n",
|
||||
" dict2['bmi_zt'] = bmi_zt\n",
|
||||
" dict2['waist'] = str('%.2f' %item['data']['waist'])\n",
|
||||
" dict2['hip'] = str('%.2f' %item['data']['hip'])\n",
|
||||
" whr = item['data']['waist']/item['data']['hip']\n",
|
||||
" if item['data']['gender'] =='male' and whr > 0.9:\n",
|
||||
" dict2['waist'] = str('%.2f' %data['waist'])\n",
|
||||
" dict2['hip'] = str('%.2f' %data['hip'])\n",
|
||||
" whr = data['waist']/data['hip']\n",
|
||||
" if data['gender'] =='male' and whr > 0.9:\n",
|
||||
" whr_zt = '超标'\n",
|
||||
" elif item['data']['gender'] =='female' and whr > 0.85:\n",
|
||||
" elif data['gender'] =='female' and whr > 0.85:\n",
|
||||
" whr_zt = '超标'\n",
|
||||
" else:\n",
|
||||
" whr_zt = '正常'\n",
|
||||
" dict2['whr'] = str('%.2f' %whr)\n",
|
||||
" dict2['whr_zt'] = whr_zt\n",
|
||||
" if 'sport_type' in item['data'].keys(): \n",
|
||||
" dict2['sport_type'] = ','.join(item['data']['sport_type']).replace('other','其他')\n",
|
||||
" dict2['sport_duration'] = str(item['data']['sport_duration'])\n",
|
||||
" dict2['recipe'] = item['data']['recipe']\n",
|
||||
" if 'last_sport' in item['data'].keys(): \n",
|
||||
" dict2['last_sport'] = item['data']['last_sport']\n",
|
||||
" if 'last_sport_time' in item['data'].keys():\n",
|
||||
" dict2['last_sport_time'] = str(item['data']['last_sport_time'])\n",
|
||||
" if 'last_sport-Comment' in item['data'].keys():\n",
|
||||
" dict2['last_sport-Comment'] = item['data']['last_sport-Comment']\n",
|
||||
" dict2['last_recipe'] = item['data']['last_recipe']\n",
|
||||
" if 'last_recipe-Comment' in item['data'].keys(): \n",
|
||||
" dict2['last_recipe-Comment'] = item['data']['last_recipe-Comment']\n",
|
||||
" if 'last_lose' in item['data'].keys(): \n",
|
||||
" dict2['last_lose'] = item['data']['last_lose']\n",
|
||||
" if 'last_lose_weight' in item['data'].keys():\n",
|
||||
" dict2['last_lose_weight'] = str('%.2f' %item['data']['last_lose_weight'])\n",
|
||||
" if 'last_lose-Comment' in item['data'].keys(): \n",
|
||||
" dict2['last_lose-Comment'] = item['data']['last_lose-Comment']\n",
|
||||
" if 'sport_type' in data.keys(): \n",
|
||||
" dict2['sport_type'] = ','.join(data['sport_type']).replace('other','其他')\n",
|
||||
" dict2['sport_duration'] = str(data['sport_duration'])\n",
|
||||
" dict2['recipe'] = data['recipe']\n",
|
||||
" if 'last_sport' in data.keys(): \n",
|
||||
" dict2['last_sport'] = data['last_sport']\n",
|
||||
" if 'last_sport_time' in data.keys():\n",
|
||||
" dict2['last_sport_time'] = str(data['last_sport_time'])\n",
|
||||
" if 'last_sport-Comment' in data.keys():\n",
|
||||
" dict2['last_sport-Comment'] = data['last_sport-Comment']\n",
|
||||
" dict2['last_recipe'] = data['last_recipe']\n",
|
||||
" if 'last_recipe-Comment' in data.keys(): \n",
|
||||
" dict2['last_recipe-Comment'] = data['last_recipe-Comment']\n",
|
||||
" if 'last_lose' in data.keys(): \n",
|
||||
" dict2['last_lose'] = data['last_lose']\n",
|
||||
" if 'last_lose_weight' in data.keys():\n",
|
||||
" dict2['last_lose_weight'] = str('%.2f' %data['last_lose_weight'])\n",
|
||||
" if 'last_lose-Comment' in data.keys(): \n",
|
||||
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
|
||||
" if code in person.keys():\n",
|
||||
" person[code][rq] = dict2\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷情况(20251124).json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||
@@ -1516,15 +1609,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 77,
|
||||
"execution_count": 107,
|
||||
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-19T10:42:23.125996Z",
|
||||
"iopub.status.busy": "2025-11-19T10:42:23.125745Z",
|
||||
"iopub.status.idle": "2025-11-19T10:42:25.142922Z",
|
||||
"shell.execute_reply": "2025-11-19T10:42:25.142275Z",
|
||||
"shell.execute_reply.started": "2025-11-19T10:42:23.125974Z"
|
||||
"iopub.execute_input": "2025-11-24T05:21:09.966817Z",
|
||||
"iopub.status.busy": "2025-11-24T05:21:09.966532Z",
|
||||
"iopub.status.idle": "2025-11-24T05:21:11.798693Z",
|
||||
"shell.execute_reply": "2025-11-24T05:21:11.798041Z",
|
||||
"shell.execute_reply.started": "2025-11-24T05:21:09.966796Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -1543,7 +1636,7 @@
|
||||
"cur = conn.cursor()\n",
|
||||
"event_id = 1\n",
|
||||
"org_id = 1\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷情况(20251124).json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = ['name','sex','birth','unit']\n",
|
||||
@@ -1612,95 +1705,6 @@
|
||||
"conn.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a068cd21-d751-46f9-9c95-f26cf14ddeb8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"import psycopg2\n",
|
||||
"\n",
|
||||
"conn = psycopg2.connect(\n",
|
||||
" host=\"localhost\",\n",
|
||||
" database=\"tice\",\n",
|
||||
" user=\"mydata\",\n",
|
||||
" password=\"songyi\"\n",
|
||||
")\n",
|
||||
"cur = conn.cursor()\n",
|
||||
"event_id = 1\n",
|
||||
"org_id = 1\n",
|
||||
"filename = 'data/宁夏能化干预人员问卷情况-1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = ['name','sex','birth','unit']\n",
|
||||
"xm = ['height','weight','next_weight','bmi','bmi_zt','waist', 'hip','whr','whr_zt' ]\n",
|
||||
"data2 = []\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" list2 = []\n",
|
||||
" \n",
|
||||
" for k1,v1 in v.items():\n",
|
||||
" #list2 = []\n",
|
||||
" if k1 not in list1:\n",
|
||||
" list2.append(k1)\n",
|
||||
" list2.sort()\n",
|
||||
" \n",
|
||||
" for rq in list2:\n",
|
||||
" for k1, v1 in v[rq].items():\n",
|
||||
" code = k\n",
|
||||
" \n",
|
||||
" sql = \"SELECT id from fitness_person where code = %s and org_id = %s\"\n",
|
||||
" params = (code,org_id)\n",
|
||||
" cur.execute(sql, params)\n",
|
||||
" rows = cur.fetchone()\n",
|
||||
" if rows:\n",
|
||||
" data1 = []\n",
|
||||
" data1.append(event_id)\n",
|
||||
" data1.append(rows[0])\n",
|
||||
" data1.append(datetime.strptime(rq,'%Y-%m-%d'))\n",
|
||||
" data1.append(k)\n",
|
||||
" for item in xm:\n",
|
||||
" data1.append(v[rq][item])\n",
|
||||
" if 'sport_type' in v[rq].keys():\n",
|
||||
" data1.append(v[rq]['sport_type'])\n",
|
||||
" else:\n",
|
||||
" data1.append('')\n",
|
||||
" if 'sport_type' in v[rq].keys():\n",
|
||||
" data1.append(v[rq]['sport_type'])\n",
|
||||
" else:\n",
|
||||
" data1.append('')\n",
|
||||
" \n",
|
||||
" if 'sport_duration' in v[rq].keys():\n",
|
||||
" data1.append(v[rq]['sport_duration'])\n",
|
||||
" else:\n",
|
||||
" data1.append('')\n",
|
||||
" if v[rq]['recipe']=='free':\n",
|
||||
" data1.append('自行控制')\n",
|
||||
" else:\n",
|
||||
" data1.append('减脂餐')\n",
|
||||
" if v[rq]['last_sport']=='是':\n",
|
||||
" data1.append('运动时长:'+str(v[rq]['last_sport_time'])+'分钟')\n",
|
||||
" else:\n",
|
||||
" data1.append('未运动,'+v[rq]['last_sport-Comment'])\n",
|
||||
" if v[rq]['last_recipe']=='是':\n",
|
||||
" data1.append('是')\n",
|
||||
" else:\n",
|
||||
" data1.append('否。'+v[rq]['last_recipe-Comment'])\n",
|
||||
" if v[rq]['last_lose']=='是':\n",
|
||||
" data1.append('是,减重'+str(v[rq]['last_lose_weight'])+'公斤。')\n",
|
||||
" elif 'last_lose-Comment' in v[rq].keys():\n",
|
||||
" data1.append('否。'+v[rq]['last_lose-Comment'])\n",
|
||||
" else:\n",
|
||||
" data1.append('否。')\n",
|
||||
" print(data1)\n",
|
||||
" sql = \"INSERT INTO fitness_record_data (event_id,user_id,date_created, height, weight, next_weight, bmi,bmi_zt,waist, hip, whr,whr_zt, sport_type, sport_duration, recipe, last_sport, last_recipe, last_lose, last_lose_comment)\" \n",
|
||||
"sql = sql + \" VALUES (%s,%s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s, %s, %s, %s, %s)\"\n",
|
||||
"cur.executemany(sql, data2)\n",
|
||||
"conn.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
+63
-39
@@ -80,17 +80,25 @@
|
||||
"print(len(person),'ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2ce125a6-a42f-4dd1-8c9c-a6a4ebcfce65",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 体测人员导入(2025年11月)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 6,
|
||||
"id": "cac3736a-56da-403b-9e62-5caaf989a6d4",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T14:38:09.521433Z",
|
||||
"iopub.status.busy": "2025-11-17T14:38:09.520770Z",
|
||||
"iopub.status.idle": "2025-11-17T14:38:11.569824Z",
|
||||
"shell.execute_reply": "2025-11-17T14:38:11.569224Z",
|
||||
"shell.execute_reply.started": "2025-11-17T14:38:09.521373Z"
|
||||
"iopub.execute_input": "2025-11-21T02:48:24.228686Z",
|
||||
"iopub.status.busy": "2025-11-21T02:48:24.228035Z",
|
||||
"iopub.status.idle": "2025-11-21T02:48:26.022844Z",
|
||||
"shell.execute_reply": "2025-11-21T02:48:26.022393Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:48:24.228627Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -98,7 +106,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"82 ok\n"
|
||||
"96 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -195,15 +203,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 8,
|
||||
"id": "925f7152-b365-4df8-8d98-73569aef68f8",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T14:38:34.526723Z",
|
||||
"iopub.status.busy": "2025-11-17T14:38:34.525935Z",
|
||||
"iopub.status.idle": "2025-11-17T14:38:34.542026Z",
|
||||
"shell.execute_reply": "2025-11-17T14:38:34.541025Z",
|
||||
"shell.execute_reply.started": "2025-11-17T14:38:34.526661Z"
|
||||
"iopub.execute_input": "2025-11-21T02:51:03.993610Z",
|
||||
"iopub.status.busy": "2025-11-21T02:51:03.993034Z",
|
||||
"iopub.status.idle": "2025-11-21T02:51:04.009834Z",
|
||||
"shell.execute_reply": "2025-11-21T02:51:04.008842Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:51:03.993560Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -211,7 +219,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"40\n"
|
||||
"48\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -225,7 +233,7 @@
|
||||
"filename = 'data/新疆油田采油工艺研究院-202511.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"filename = 'data/marks_20251117-3.csv'\n",
|
||||
"filename = 'data/marks_20251121-1.csv'\n",
|
||||
"re_ta = My.get_result(filename,dict1)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -245,10 +253,26 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"id": "0905ad6a-f7e4-43ed-ae29-c4850deb946b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-21T02:51:14.528104Z",
|
||||
"iopub.status.busy": "2025-11-21T02:51:14.527417Z",
|
||||
"iopub.status.idle": "2025-11-21T02:51:14.544192Z",
|
||||
"shell.execute_reply": "2025-11-21T02:51:14.543168Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:51:14.528044Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import time\n",
|
||||
@@ -287,15 +311,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 11,
|
||||
"id": "0e71f6b8-e17e-49f8-a577-7a2eb6f5e994",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T14:38:58.670424Z",
|
||||
"iopub.status.busy": "2025-11-17T14:38:58.669763Z",
|
||||
"iopub.status.idle": "2025-11-17T14:38:58.683725Z",
|
||||
"shell.execute_reply": "2025-11-17T14:38:58.682758Z",
|
||||
"shell.execute_reply.started": "2025-11-17T14:38:58.670352Z"
|
||||
"iopub.execute_input": "2025-11-21T02:54:29.164196Z",
|
||||
"iopub.status.busy": "2025-11-21T02:54:29.163638Z",
|
||||
"iopub.status.idle": "2025-11-21T02:54:29.182035Z",
|
||||
"shell.execute_reply": "2025-11-21T02:54:29.181011Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:54:29.164147Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -664,15 +688,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 10,
|
||||
"id": "83872322-129c-410d-a9a3-ef6f4fe8dcde",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T14:41:08.300902Z",
|
||||
"iopub.status.busy": "2025-11-17T14:41:08.300597Z",
|
||||
"iopub.status.idle": "2025-11-17T14:41:08.314893Z",
|
||||
"shell.execute_reply": "2025-11-17T14:41:08.314440Z",
|
||||
"shell.execute_reply.started": "2025-11-17T14:41:08.300875Z"
|
||||
"iopub.execute_input": "2025-11-21T02:53:17.422865Z",
|
||||
"iopub.status.busy": "2025-11-21T02:53:17.422300Z",
|
||||
"iopub.status.idle": "2025-11-21T02:53:17.441843Z",
|
||||
"shell.execute_reply": "2025-11-21T02:53:17.441201Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:53:17.422814Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -680,7 +704,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"40\n"
|
||||
"48\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -692,7 +716,7 @@
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/sql_20251117-1.csv'\n",
|
||||
"filename = 'data/sql_20251121.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -823,15 +847,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 12,
|
||||
"id": "694ad38e-755e-4885-94a9-c157ddc96564",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-11-17T14:42:09.546636Z",
|
||||
"iopub.status.busy": "2025-11-17T14:42:09.546054Z",
|
||||
"iopub.status.idle": "2025-11-17T14:42:32.426068Z",
|
||||
"shell.execute_reply": "2025-11-17T14:42:32.424869Z",
|
||||
"shell.execute_reply.started": "2025-11-17T14:42:09.546580Z"
|
||||
"iopub.execute_input": "2025-11-21T02:55:17.019680Z",
|
||||
"iopub.status.busy": "2025-11-21T02:55:17.019091Z",
|
||||
"iopub.status.idle": "2025-11-21T02:55:45.001413Z",
|
||||
"shell.execute_reply": "2025-11-21T02:55:45.000749Z",
|
||||
"shell.execute_reply.started": "2025-11-21T02:55:17.019625Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@@ -839,7 +863,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"40\n"
|
||||
"48\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
+23
-1365
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user