This commit is contained in:
512song committed 2025-12-22 21:13:47 +08:00
1 parent 6803e6fff6
commit b894e793a5
5 files changed
+1705 -202

No files matched your search

+451 -69
View File
@@ -1037,7 +1037,7 @@
}
],
"source": [
"##### import json\n",
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
@@ -1095,6 +1095,79 @@
"print(len(dict1),'ok')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "02d82c2a-2319-4c0b-be58-0a1b107fdc35",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-22T07:38:35.217789Z",
"iopub.status.busy": "2025-12-22T07:38:35.217210Z",
"iopub.status.idle": "2025-12-22T07:38:35.238667Z",
"shell.execute_reply": "2025-12-22T07:38:35.238165Z",
"shell.execute_reply.started": "2025-12-22T07:38:35.217760Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"111 ok\n"
]
}
],
"source": [
"import json\n",
"import csv\n",
"import openpyxl\n",
"import time\n",
"from datetime import date\n",
"\n",
"filename = 'data/宁夏能化高危风险干预人员.json'\n",
"with open(filename,'r') as fl:\n",
" dict3 = json.load(fl)\n",
" \n",
"dict1 = {}\n",
"list1 = []\n",
"filename = 'data/sql_20251222.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",
" list1.append(line)\n",
"\n",
"nn = 0\n",
"for item in list1:\n",
" dict2 = {}\n",
" \n",
" phone = str(item[0])[2:]\n",
" content = json.loads(json.loads(item[1]))\n",
" tcm = []\n",
" for i in range(0,60):\n",
" tcm.append(0)\n",
" for k, v in content.items(): \n",
" if 'tcm' not in k:\n",
" dict2[k] = v\n",
" else:\n",
" i = int(k[3:])\n",
" tcm[i-1] = int(v)\n",
" \n",
" code = str(int(dict2['code']))\n",
" if code in dict3.keys():\n",
" dict1[code] = dict3[code]\n",
" dict1[code]['waist'] = dict2['waist']\n",
" dict1[code]['hip'] = dict2['hip']\n",
" dict1[code]['tcm'] = tcm \n",
" \n",
"\n",
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl, ensure_ascii=False)\n",
"print(len(dict1),'ok')"
]
},
{
"cell_type": "markdown",
"id": "c4486c37-d1a4-460f-9997-6405c51b805c",
@@ -1105,15 +1178,15 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 26,
"id": "34cb26d7-cd7b-4ad5-bb7b-71cfcce16c24",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:51:13.116856Z",
"iopub.status.busy": "2025-12-09T09:51:13.116051Z",
"iopub.status.idle": "2025-12-09T09:51:13.133080Z",
"shell.execute_reply": "2025-12-09T09:51:13.132231Z",
"shell.execute_reply.started": "2025-12-09T09:51:13.116787Z"
"iopub.execute_input": "2025-12-22T07:39:25.697010Z",
"iopub.status.busy": "2025-12-22T07:39:25.696512Z",
"iopub.status.idle": "2025-12-22T07:39:25.707108Z",
"shell.execute_reply": "2025-12-22T07:39:25.706358Z",
"shell.execute_reply.started": "2025-12-22T07:39:25.696961Z"
}
},
"outputs": [],
@@ -1179,15 +1252,15 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 27,
"id": "d78c0f3f-cd1a-4c6c-9f5b-b1b874a95fe3",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-09T09:52:01.947920Z",
"iopub.status.busy": "2025-12-09T09:52:01.947633Z",
"iopub.status.idle": "2025-12-09T09:52:01.999096Z",
"shell.execute_reply": "2025-12-09T09:52:01.998620Z",
"shell.execute_reply.started": "2025-12-09T09:52:01.947897Z"
"iopub.execute_input": "2025-12-22T07:40:30.226248Z",
"iopub.status.busy": "2025-12-22T07:40:30.225697Z",
"iopub.status.idle": "2025-12-22T07:40:30.260291Z",
"shell.execute_reply": "2025-12-22T07:40:30.259853Z",
"shell.execute_reply.started": "2025-12-22T07:40:30.226194Z"
}
},
"outputs": [],
@@ -1195,7 +1268,7 @@
"import openpyxl\n",
"\n",
"\n",
"filename = 'data/survey_宁夏能化高危风险干预人员.json'\n",
"filename = 'data/survey_宁夏能化高危风险干预人员(202512).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"data_list = []\n",
@@ -1233,7 +1306,7 @@
" i+=1\n",
" \n",
" data_list.append(list6)\n",
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251209).xlsx'\n",
"filename = 'data/宁夏能化高危风险干预人员体质问卷明细表(20251222).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"title = ['编号', '姓名', '性别', '单位/部门', '年龄', '腰围', '臀围', '中医体质', '是否倾向', '平和', '气虚', '阳虚', '阴虚', '痰湿', '湿热', '血瘀', '气郁', '特禀']\n",
@@ -1308,15 +1381,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 15,
"id": "22be8f39-afbb-448a-8ae6-c825c7d38757",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:21.978932Z",
"iopub.status.busy": "2025-12-14T23:43:21.978409Z",
"iopub.status.idle": "2025-12-14T23:43:22.273147Z",
"shell.execute_reply": "2025-12-14T23:43:22.272647Z",
"shell.execute_reply.started": "2025-12-14T23:43:21.978883Z"
"iopub.execute_input": "2025-12-22T03:43:54.245786Z",
"iopub.status.busy": "2025-12-22T03:43:54.245059Z",
"iopub.status.idle": "2025-12-22T03:43:54.418251Z",
"shell.execute_reply": "2025-12-22T03:43:54.417770Z",
"shell.execute_reply.started": "2025-12-22T03:43:54.245721Z"
}
},
"outputs": [],
@@ -1327,7 +1400,7 @@
"\n",
"title = []\n",
"\n",
"filename = 'data/surveys_records_2025-12-15.json'\n",
"filename = 'data/surveys_records_2025-12-22.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1352,7 +1425,7 @@
" \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/宁夏能化干预人员问卷(20251215).xlsx'\n",
"filename = 'data/宁夏能化干预人员问卷(20251222).xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(all_title)\n",
@@ -1388,15 +1461,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 16,
"id": "91c53866-3725-4ceb-b0eb-23fb14e20561",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:35.251673Z",
"iopub.status.busy": "2025-12-14T23:43:35.251057Z",
"iopub.status.idle": "2025-12-14T23:43:35.339896Z",
"shell.execute_reply": "2025-12-14T23:43:35.339186Z",
"shell.execute_reply.started": "2025-12-14T23:43:35.251623Z"
"iopub.execute_input": "2025-12-22T03:44:05.908310Z",
"iopub.status.busy": "2025-12-22T03:44:05.907768Z",
"iopub.status.idle": "2025-12-22T03:44:06.062310Z",
"shell.execute_reply": "2025-12-22T03:44:06.061610Z",
"shell.execute_reply.started": "2025-12-22T03:44:05.908261Z"
}
},
"outputs": [
@@ -1404,24 +1477,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
"('梁正武', '男', '电气仪表中心', '1984-05-01', '02018801', 1)\n",
"('张艳萍', '女', '公用工程运行部', '1978-09-01', '02020548', 1)\n",
"('叶云飞', '男', '公用工程运行部', '1985-11-01', '02019460', 1)\n",
"('李效龙', '男', 'BDO运行部', '1987-09-01', '0201968', 1)\n",
"('何富来', '男', '宁夏能化', '1983-03-01', '02019507', 1)\n",
"('马荣', '女', '公用工程运行部', '1984-03-01', '02020205', 1)\n",
"('刘永清', '男', '热电运行部', '1968-10-01', '02019958', 1)\n",
"('马学锋', '男', '热电运行部', '1974-12-01', '02020025', 1)\n",
"('段庆霖', '男', '热电运行部', '1990-02-01', '02020062', 1)\n",
"('周卫星', '男', '热电运行部', '1970-05-01', '02019986', 1)\n",
"('姚户昌', '男', '热电运行部', '1970-12-01', '02019968', 1)\n",
"('姜德溪', '男', '热电运行部', '1970-01-01', '2019970', 1)\n",
"('陈海宝', '男', '乙炔运行部', '1990-07-01', '02019346', 1)\n",
"('丁红忠', '男', '热电运行部', '1990-09-01', '02020160', 1)\n",
"('孙柏', '男', '环保建材运行部', '1982-03-01', '02020446', 1)\n",
"('黄博', '男', '物资采购中心', '1995-12-01', '03391681', 1)\n",
"('王正东', '男', '热电运行部', '1990-01-01', '03428864', 1)\n",
"17\n"
"('汪晖', '男', '销售中心', '1971-02-01', '02019646', 1)\n",
"('马燕金', '男', '销售中心', '1983-04-01', '02018528', 1)\n",
"('孙皓', '男', '销售中心', '1990-10-01', '02019111', 1)\n",
"('李润良', '男', '环保建材运行部', '1992-06-01', '03427471', 1)\n",
"('王春光', '男', '环保建材运行部', '1969-12-01', '02020528', 1)\n",
"('户利平', '男', '环保建材运行部', '1969-08-01', '02020512', 1)\n",
"('马婉婷', '女', '公用工程运行部', '2001-11-01', '03561578', 1)\n",
"('储方伟', '男', '环保建材运行部', '1976-01-01', '02020483', 1)\n",
"('马斯勇', '男', '环保建材运行部', '1987-08-01', '02020525', 1)\n",
"('康磊', '男', '公用工程运行部', '1987-07-01', '02020289', 1)\n",
"('王涛', '男', '环保建材运行部', '1982-07-01', '00000521', 1)\n",
"('杨德忠', '男', '公用工程运行部', '1972-11-01', '02020306', 1)\n",
"('杨思国', '男', '电气仪表中心', '1981-04-01', '02018877', 1)\n",
"('党金广', '男', '电气仪表中心', '1987-08-01', '02018839', 1)\n",
"('张锋', '男', '电气仪表中心', '1971-05-01', '02020003', 1)\n",
"('张磊', '男', '电气仪表中心', '1989-12-01', '02018949', 1)\n",
"('秦国振', '男', '电气仪表中心', '1997-07-01', '03462294', 1)\n",
"('陈龙', '男', '电气仪表中心', '1981-05-01', '02018914', 1)\n",
"('朱岳峰', '男', '电气仪表中心', '1988-02-01', '02018865', 1)\n",
"19\n"
]
}
],
@@ -1437,7 +1512,7 @@
" password=\"songyi\"\n",
")\n",
"cur = conn.cursor()\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"org_id = 1\n",
@@ -1571,15 +1646,15 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 20,
"id": "b7133988-213c-4b52-8d6b-17b56b8ea310",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:43:56.303850Z",
"iopub.status.busy": "2025-12-14T23:43:56.303555Z",
"iopub.status.idle": "2025-12-14T23:43:56.413335Z",
"shell.execute_reply": "2025-12-14T23:43:56.412897Z",
"shell.execute_reply.started": "2025-12-14T23:43:56.303825Z"
"iopub.execute_input": "2025-12-22T03:49:22.646173Z",
"iopub.status.busy": "2025-12-22T03:49:22.645514Z",
"iopub.status.idle": "2025-12-22T03:49:22.842656Z",
"shell.execute_reply": "2025-12-22T03:49:22.842110Z",
"shell.execute_reply.started": "2025-12-22T03:49:22.646116Z"
}
},
"outputs": [
@@ -1587,7 +1662,313 @@
"name": "stdout",
"output_type": "stream",
"text": [
"108 ok\n"
"02019646\n",
"2018434\n",
"02018586\n",
"02018444\n",
"02020443\n",
"02020415\n",
"02018446\n",
"2018447\n",
"03533284\n",
"02020243\n",
"02019374\n",
"02020238\n",
"02019952\n",
"03497967\n",
"02018709\n",
"02019342\n",
"02019620\n",
"02020203\n",
"02018528\n",
"02019111\n",
"02018482\n",
"02018481\n",
"02018628\n",
"02018498\n",
"02018499\n",
"964089\n",
"0214545\n",
"02020481\n",
"2018609\n",
"01348929\n",
"02020526\n",
"03427471\n",
"02020196\n",
"02020528\n",
"2019094\n",
"02020512\n",
"02020476\n",
"03561578\n",
"0003533364\n",
"02019294\n",
"02020483\n",
"02020527\n",
"02020467\n",
"02020296\n",
"02020525\n",
"02020289\n",
"03434760\n",
"02018435\n",
"2019094\n",
"02019688\n",
"02019688\n",
"03561564\n",
"02020346\n",
"02020458\n",
"00000521\n",
"02020306\n",
"02019655\n",
"02020189\n",
"02019787\n",
"02019787\n",
"02018611\n",
"02018566\n",
"02018645\n",
"02019485\n",
"02020127\n",
"02019054\n",
"2019006\n",
"028415\n",
"03462271\n",
"02028323\n",
"02020492\n",
"02018794\n",
"02018877\n",
"02018926\n",
"02018809\n",
"02018938\n",
"02020083\n",
"02018839\n",
"2018985\n",
"02019866\n",
"02018793\n",
"03428863\n",
"02019017\n",
"02018981\n",
"02020003\n",
"03462285\n",
"02018626\n",
"02018604\n",
"02018892\n",
"02018827\n",
"02018949\n",
"02019599\n",
"02019622\n",
"02018575\n",
"2018438\n",
"02019613\n",
"03363370\n",
"01702447\n",
"020186\n",
"02018709\n",
"03497967\n",
"0201968\n",
"02019641\n",
"02018709\n",
"02019697\n",
"02019021\n",
"0435\n",
"02018685\n",
"02018772\n",
"02019620\n",
"03497960\n",
"02019888\n",
"02019682\n",
"03391642\n",
"03462294\n",
"02018914\n",
"2019961\n",
"02018859\n",
"02019377\n",
"02017961\n",
"02018607\n",
"02018865\n",
"02020277\n",
"02020251\n",
"02020321\n",
"03391661\n",
"02020276\n",
"02019062\n",
"02019887\n",
"03148213\n",
"2019822\n",
"02019840\n",
"02019790\n",
"02019819\n",
"02019754\n",
"03437945\n",
"02019749\n",
"02019111\n",
"03418292\n",
"02019764\n",
"02019744\n",
"02019734\n",
"02019374\n",
"02019778\n",
"02019788\n",
"02019725\n",
"02017961\n",
"02019751\n",
"02020282\n",
"02019856\n",
"02019832\n",
"02019848\n",
"03437965\n",
"02019954\n",
"02020052\n",
"02019820\n",
"02019893\n",
"02019752\n",
"02019784\n",
"02020343\n",
"02019810\n",
"2019735\n",
"02019023\n",
"02020327\n",
"02019852\n",
"02018538\n",
"02018977\n",
"2018942\n",
"02019898\n",
"02019794\n",
"02019805\n",
"02019342\n",
"02019895\n",
"02019154\n",
"02019775\n",
"3391687\n",
"02019917\n",
"02018754\n",
"03418302\n",
"02019738\n",
"03462274\n",
"03561561\n",
"02019783\n",
"02018967\n",
"2019324\n",
"02019355\n",
"02019003\n",
"02019377\n",
"02019803\n",
"02019311\n",
"02019346\n",
"02019525\n",
"02020502\n",
"03497957\n",
"02020242\n",
"02019347\n",
"3418215\n",
"02019340\n",
"02019773\n",
"0219181\n",
"02019336\n",
"02019340\n",
"02018999\n",
"02019357\n",
"02019100\n",
"02019430\n",
"02019356\n",
"03418230\n",
"03437952\n",
"03437952\n",
"02019231\n",
"03497937\n",
"03497917\n",
"02019318\n",
"03462262\n",
"02019110\n",
"2019919\n",
"02019382\n",
"03497562\n",
"02019369\n",
"03391686\n",
"02019736\n",
"02019786\n",
"02019411\n",
"3391674\n",
"02018727\n",
"02019035\n",
"02019350\n",
"02019414\n",
"2019353\n",
"2019353\n",
"2019493\n",
"02019903\n",
"02019825\n",
"02019802\n",
"03394941\n",
"02020243\n",
"2019914\n",
"02019164\n",
"02019467\n",
"03437937\n",
"02019366\n",
"02019344\n",
"2019930\n",
"02019910\n",
"02019647\n",
"02019843\n",
"01825596\n",
"02019882\n",
"03409694\n",
"02019391\n",
"02019389\n",
"02019301\n",
"02020005\n",
"02019920\n",
"02019498\n",
"02019373\n",
"02019733\n",
"2019998\n",
"02020000\n",
"02019401\n",
"02019901\n",
"03418242\n",
"02019383\n",
"02019438\n",
"02019871\n",
"02019193\n",
"02019635\n",
"02020203\n",
"02019098\n",
"02019459\n",
"02018996\n",
"02019499\n",
"02019687\n",
"02018674\n",
"02019059\n",
"02019059\n",
"2019845\n",
"2018609\n",
"02019379\n",
"02020006\n",
"2019923\n",
"02019774\n",
"02019068\n",
"020294\n",
"03403228\n",
"3019337\n",
"02018711\n",
"03462315\n",
"02019739\n",
"02019278\n",
"02019416\n",
"2018973\n",
"02019256\n",
"02019878\n",
"02019664\n",
"02019404\n",
"02019058\n",
"02019504\n",
"02019361\n",
"02019600\n",
"02019381\n",
"02019248\n",
"02019543\n",
"02019648\n",
"02020260\n",
"287 ok\n"
]
}
],
@@ -1595,22 +1976,23 @@
"import json\n",
"import openpyxl\n",
"\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251215).xlsx',data_only=True)\n",
"wb = openpyxl.load_workbook('data/宁夏能化干预人员问卷(20251222).xlsx',data_only=True)\n",
"sheet = wb.active\n",
"# sheets = wb.sheetnames\n",
"person = {}\n",
"for n in range(2, sheet.max_row+1):\n",
" code = str(sheet.cell(n, 6).value)\n",
" print(code)\n",
" person.setdefault(code, {})\n",
" dict1 = {}\n",
" dict1['name'] = sheet.cell(n, 3).value\n",
" dict1['sex'] = sheet.cell(n, 4).value\n",
" birth = str(sheet.cell(n, 5).value).split()[0]\n",
" if len(birth)<10:\n",
" nian = birth.split('-')[0]\n",
" yue = birth.split('-')[1].rjust(2,'0')\n",
" if len(birth.split('-')[0]) ==3:\n",
" ri = birth.split('-')[2].rjust(2,'0')\n",
" nian = birth.replace('/','-').split('-')[0]\n",
" yue = birth.replace('/','-').split('-')[1].rjust(2,'0')\n",
" if len(birth.replace('/','-').split('-')[0]) ==3:\n",
" ri = birth.replace('/','-').split('-')[2].rjust(2,'0')\n",
" else:\n",
" ri = '01' \n",
" dict1['birth'] = nian+'-'+ yue + '-'+ ri\n",
@@ -1618,7 +2000,7 @@
" person[code] = dict1\n",
"#print(person)\n",
"\n",
"filename = 'data/surveys_records_2025-12-10.json'\n",
"filename = 'data/surveys_records_2025-12-22.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = []\n",
@@ -1676,7 +2058,7 @@
" dict2['last_lose-Comment'] = data['last_lose-Comment']\n",
" if code in person.keys():\n",
" person[code][rq] = dict2\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
"\n",
"with open(filename,'w') as fl:\n",
" json.dump(person, fl, ensure_ascii=False)\n",
@@ -1694,15 +2076,15 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 21,
"id": "55b20059-ae36-493e-b0c5-c7e35473efc7",
"metadata": {
"execution": {
"iopub.execute_input": "2025-12-14T23:44:12.601625Z",
"iopub.status.busy": "2025-12-14T23:44:12.600884Z",
"iopub.status.idle": "2025-12-14T23:44:12.741676Z",
"shell.execute_reply": "2025-12-14T23:44:12.741060Z",
"shell.execute_reply.started": "2025-12-14T23:44:12.601562Z"
"iopub.execute_input": "2025-12-22T03:49:42.115930Z",
"iopub.status.busy": "2025-12-22T03:49:42.114895Z",
"iopub.status.idle": "2025-12-22T03:49:43.037249Z",
"shell.execute_reply": "2025-12-22T03:49:43.036729Z",
"shell.execute_reply.started": "2025-12-22T03:49:42.115872Z"
}
},
"outputs": [],
@@ -1721,7 +2103,7 @@
"cur = conn.cursor()\n",
"event_id = 1\n",
"org_id = 1\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251215).json'\n",
"filename = 'data/宁夏能化干预人员问卷情况(20251222).json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"list1 = ['name','sex','birth','unit']\n",