数据表转换echarts数据格式录入数据库,方便查询使用。

表格: tp_table_analysis

备注: 表格分析 创建对某个表格进行分析的任务列表

索引:

名称 类型 属性 备注
主索引 id unique

字段:

名称 类型 默认值 属性 备注
id int(10) unsigned <auto_increment>
title varchar(255) 任务的标题
description varchar(255) 任务的描述(比如:某某的用户的某某表的分析)
uuid char(32) 任务的唯一参数
table_name varchar(255) 当前任务要分析的表格名称
table_analy_where varchar(255) deleted_at=0 分析任务表格的查询条件如:deleted_at=0&status=1
table_analy_field varchar(255) updated_at 对这个表格中的这个字段进行分析拆分数据(年月日时分)
table_analy_field_type tinyint(3) unsigned 0 数据类型:0 int ; 1 datetime ;表中table_analy_field的数据类型是哪一种时间格式
table_calculate_field varchar(255) id 表格中的某个字段(用于数据分析使用的字段)默认使用id 如统计总数时使用count('id')
table_calculate_method varchar(255) count 使用mysql的计算方式 对table_calculate_field进行处理 如count('id')、sum('score') 等等
analy_type tinyint(3) unsigned 2 【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年
drag_sort numeric(16,6) 82980478.000000 排序值:拖拽排序可用;建议值为使用2051年减去今天的时间得到的数字
status tinyint(3) unsigned 1 是否可用
delete_time int(11) unsigned 0 软删除时间
update_time int(11) unsigned 0 更新时间
create_time int(11) unsigned 0 上传时间
id title description uuid table_name table_analy_where table_analy_field table_analy_field_type table_calculate_field table_calculate_method analy_type drag_sort status delete_time update_time create_time
1 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 e56d241c518a4f2adc9015098c4e605f tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="化学纯" and drug_id=242 create_time 0 wastage sum 2 1106154643.175800 1 0 0 1643098395
2 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 5e39c8faedc3e0f2f1bac00d1dcfc3ff tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1106154643.175800 1 0 0 1643098395
3 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 2d14561eb124130e0c68e5b252282823 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1106154643.175800 1 0 0 1643098395
4 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 e298ee5cb0c8ca121b6d0ec8f6f5da21 tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1106154643.175800 1 0 0 1643098395
5 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 c775e33792189dc43c08142f1c535704 tp_drug_weigh_list delete_time=0 and specs="100ml" and purification="化学纯" and drug_id=153 create_time 0 wastage sum 2 1106154627.966800 1 0 0 1643098411
6 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 1106154627.966800 1 0 0 1643098411
7 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 1106154627.966800 1 0 0 1643098411
8 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 e47d03af3d74726369a52d4cd43b0224 tp_drug_in_list delete_time=0 and status!=0 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 1106154627.966800 1 0 0 1643098411
9 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 cdd4b8c51ac13bb1d0d64df095a1d0cd tp_drug_weigh_list delete_time=0 and specs="100ml" and purification="高纯试剂" and drug_id=153 create_time 0 wastage sum 2 1106154626.296900 1 0 0 1643098412
10 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 a5f3218439aabc3feb05ec47641e0478 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 1106154626.296900 1 0 0 1643098412
11 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 630f393f118960e1ad7188d1312a5528 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 1106154626.296900 1 0 0 1643098412
12 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 0aac29dd1b01ee67c8747d34f216c4bf tp_drug_in_list delete_time=0 and status!=0 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 1106154626.296900 1 0 0 1643098412
13 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 3f522b89069e57f4dc0df9e446e6147f tp_drug_weigh_list delete_time=0 and specs="100ml" and purification="化学纯" and drug_id=278 create_time 0 wastage sum 2 1106154623.646700 1 0 0 1643098415
14 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 b261955bc5d0f081020c8abb902c8803 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=278 create_time 0 id count 2 1106154623.646700 1 0 0 1643098415
15 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 32b4b20998146e5f8f2ec27cd58b90d4 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=278 create_time 0 id count 2 1106154623.646700 1 0 0 1643098415
16 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 2d94eafb90a5bcf22a9208ca30f80bdf tp_drug_in_list delete_time=0 and status!=0 and specs= "100ml" and purification="化学纯" and drug_id=278 create_time 0 id count 2 1106154623.646700 1 0 0 1643098415
17 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 09546e9fd4b5f53e0eb460d45303f740 tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="化学纯" and drug_id=154 create_time 0 wastage sum 2 1106154622.777400 1 0 0 1643098416
18 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 583c89f15cacb12b4d2cc2005dc5f99b tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=154 create_time 0 id count 2 1106154622.777400 1 0 0 1643098416
19 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 887af62c5fe492268e12b686c2fff577 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=154 create_time 0 id count 2 1106154622.777400 1 0 0 1643098416
20 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 2cff8ab417e27dfaf5ed4e05a6020676 tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="化学纯" and drug_id=154 create_time 0 id count 2 1106154622.777400 1 0 0 1643098416
21 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 a5f3218439aabc3feb05ec47641e0478 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 1106154621.825400 1 0 0 1643098417
22 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 630f393f118960e1ad7188d1312a5528 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 1106154621.825400 1 0 0 1643098417
23 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 1106154619.770400 1 0 0 1643098419
24 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 1106154619.770400 1 0 0 1643098419
25 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 5e39c8faedc3e0f2f1bac00d1dcfc3ff tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1106154613.823700 1 0 0 1643098425
26 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 2d14561eb124130e0c68e5b252282823 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1106154613.823700 1 0 0 1643098425
27 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 5e39c8faedc3e0f2f1bac00d1dcfc3ff tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1105162714.447800 1 0 0 1643182364
28 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 2d14561eb124130e0c68e5b252282823 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 1105162714.447800 1 0 0 1643182364
29 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 6a84a40a2e227c345235a0455e83897a tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 wastage sum 2 1104163400.634100 1 0 0 1643268358
30 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 e4868005cca5645fb7b6432ae1b30a5f tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 1104163400.634100 1 0 0 1643268358
31 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33ea492b4c878480fd1a632dd19bdef5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 1104163400.634100 1 0 0 1643268358
32 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 fd0cecf4bd836e8a6eff61bb8f70fff2 tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 1104163400.634100 1 0 0 1643268358
33 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 9e5fda7932d1c336516a3de7da247324 tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="分析纯" and drug_id=9 create_time 0 wastage sum 2 943002253.556740 1 0 0 1644677745
34 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 8668bea4a4b30842121c5edad6586505 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 943002253.556740 1 0 0 1644677745
35 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 309df9ff3e4df8caa112f7b8779aa506 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 943002253.556740 1 0 0 1644677745
36 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 55f3a76e198fe34dba521eb6b7a778c0 tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 943002253.556740 1 0 0 1644677745
37 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 943002243.291190 1 0 0 1644677755
38 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 943002243.291190 1 0 0 1644677755
39 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 8668bea4a4b30842121c5edad6586505 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942791029.770730 1 0 0 1644888969
40 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 309df9ff3e4df8caa112f7b8779aa506 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942791029.770730 1 0 0 1644888969
41 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 e4868005cca5645fb7b6432ae1b30a5f tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942790999.761950 1 0 0 1644888999
42 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33ea492b4c878480fd1a632dd19bdef5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942790999.761950 1 0 0 1644888999
43 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942790996.731660 1 0 0 1644889002
44 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942790996.731660 1 0 0 1644889002
45 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 8668bea4a4b30842121c5edad6586505 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942787611.271720 1 0 0 1644892387
46 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 309df9ff3e4df8caa112f7b8779aa506 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942787611.271720 1 0 0 1644892387
47 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 06281463ee6024f7cb509fb92f299ee6 tp_drug_weigh_list delete_time=0 and specs="100ml" and purification="实验纯" and drug_id=43 create_time 0 wastage sum 2 942787605.565160 1 0 0 1644892393
48 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 084f7fd183522838990f9473fbf1c2dd tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="实验纯" and drug_id=43 create_time 0 id count 2 942787605.565160 1 0 0 1644892393
49 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33210a1538049da22b4b96f605b02bf5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="实验纯" and drug_id=43 create_time 0 id count 2 942787605.565160 1 0 0 1644892393
50 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 e8a05fa14eecd4a8cac75153231c7d54 tp_drug_in_list delete_time=0 and status!=0 and specs= "100ml" and purification="实验纯" and drug_id=43 create_time 0 id count 2 942787605.565160 1 0 0 1644892393
51 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 e4868005cca5645fb7b6432ae1b30a5f tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942787601.819860 1 0 0 1644892397
52 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33ea492b4c878480fd1a632dd19bdef5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942787601.819860 1 0 0 1644892397
53 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 5e39c8faedc3e0f2f1bac00d1dcfc3ff tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 942787597.524450 1 0 0 1644892401
54 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 2d14561eb124130e0c68e5b252282823 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=242 create_time 0 id count 2 942787597.524450 1 0 0 1644892401
55 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942787530.793790 1 0 0 1644892468
56 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942787530.793790 1 0 0 1644892468
57 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 4da0ae7a47a17fc0d4d152ed51ee0199 tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="丁真很纯" and drug_id=242 create_time 0 wastage sum 2 942686640.142860 1 0 0 1644993358
58 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 096e770d3ea2aa50a7d7ce909db2b38c tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=242 create_time 0 id count 2 942686640.142860 1 0 0 1644993358
59 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 3416f9f3c2f21c763a185d24241913ef tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=242 create_time 0 id count 2 942686640.142860 1 0 0 1644993358
60 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 e108f874b2b0369c1b74f0a4531da16a tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="丁真很纯" and drug_id=242 create_time 0 id count 2 942686640.142860 1 0 0 1644993358
61 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 8668bea4a4b30842121c5edad6586505 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942686635.361480 1 0 0 1644993363
62 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 309df9ff3e4df8caa112f7b8779aa506 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=9 create_time 0 id count 2 942686635.361480 1 0 0 1644993363
63 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 e4868005cca5645fb7b6432ae1b30a5f tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942686631.452160 1 0 0 1644993367
64 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33ea492b4c878480fd1a632dd19bdef5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942686631.452160 1 0 0 1644993367
65 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 b261955bc5d0f081020c8abb902c8803 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=278 create_time 0 id count 2 942686602.631230 1 0 0 1644993396
66 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 32b4b20998146e5f8f2ec27cd58b90d4 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=278 create_time 0 id count 2 942686602.631230 1 0 0 1644993396
67 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 e4868005cca5645fb7b6432ae1b30a5f tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942686495.301010 1 0 0 1644993503
68 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 33ea492b4c878480fd1a632dd19bdef5 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=2884 create_time 0 id count 2 942686495.301010 1 0 0 1644993503
69 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 096e770d3ea2aa50a7d7ce909db2b38c tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=242 create_time 0 id count 2 942686406.870580 1 0 0 1644993592
70 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 3416f9f3c2f21c763a185d24241913ef tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="丁真很纯" and drug_id=242 create_time 0 id count 2 942686406.870580 1 0 0 1644993592
71 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686346.366140 1 0 0 1644993652
72 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686346.366140 1 0 0 1644993652
73 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686298.831530 1 0 0 1644993700
74 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686298.831530 1 0 0 1644993700
75 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 a5f3218439aabc3feb05ec47641e0478 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 942686293.638680 1 0 0 1644993705
76 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 630f393f118960e1ad7188d1312a5528 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 942686293.638680 1 0 0 1644993705
77 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 583c89f15cacb12b4d2cc2005dc5f99b tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=154 create_time 0 id count 2 942686289.154060 1 0 0 1644993709
78 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 887af62c5fe492268e12b686c2fff577 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="化学纯" and drug_id=154 create_time 0 id count 2 942686289.154060 1 0 0 1644993709
79 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 a5f3218439aabc3feb05ec47641e0478 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 942686286.406440 1 0 0 1644993712
80 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 630f393f118960e1ad7188d1312a5528 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="高纯试剂" and drug_id=153 create_time 0 id count 2 942686286.406440 1 0 0 1644993712
81 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686283.311340 1 0 0 1644993715
82 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686283.311340 1 0 0 1644993715
83 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686233.110110 1 0 0 1644993765
84 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686233.110110 1 0 0 1644993765
85 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 67d8bc9af14b07139c7b275eee76707a tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686171.243040 1 0 0 1644993827
86 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 1e4bb6d697711f9316114565c101add7 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "100ml" and purification="化学纯" and drug_id=153 create_time 0 id count 2 942686171.243040 1 0 0 1644993827
87 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 8e395041be9c84aafc5eec4204a35bd6 tp_drug_weigh_list delete_time=0 and specs="50ml" and purification="化学纯" and drug_id=1 create_time 0 wastage sum 2 941662604.522440 1 0 0 1646017394
88 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 a9f5571e872b03c3335d5928ab905bf6 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "50ml" and purification="化学纯" and drug_id=1 create_time 0 id count 2 941662604.522440 1 0 0 1646017394
89 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 311967fc2391aeaad94004b7fa1e8d36 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "50ml" and purification="化学纯" and drug_id=1 create_time 0 id count 2 941662604.522440 1 0 0 1646017394
90 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 bcefef0c487726fce856c23b5ca0995c tp_drug_in_list delete_time=0 and status!=0 and specs= "50ml" and purification="化学纯" and drug_id=1 create_time 0 id count 2 941662604.522440 1 0 0 1646017394
91 药品消耗统计任务 称重表(tp_drug_weigh_list)-药品消耗统计 7fc3985772db79b3061e75a0f3332937 tp_drug_weigh_list delete_time=0 and specs="500ml" and purification="分析纯" and drug_id=17 create_time 0 wastage sum 2 941662601.072010 1 0 0 1646017397
92 药品交接出库(预废弃A=>B)统计任务 入库表(tp_drug_out_list)-药品入库统计 0a5d568c7f8b7f9f271e530e8f146af9 tp_drug_out_list delete_time=0 and order_type=1 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=17 create_time 0 id count 2 941662601.072010 1 0 0 1646017397
93 药品交接出库(预废弃AB=>C)统计任务 入库表(tp_drug_out_list)-药品入库统计 b96e941fa5ab2796c833e55fe4db8c33 tp_drug_out_list delete_time=0 and order_type=2 and status=7 and specs= "500ml" and purification="分析纯" and drug_id=17 create_time 0 id count 2 941662601.072010 1 0 0 1646017397
94 药品入库统计任务 入库表(tp_drug_in_list)-药品入库统计 1f125ba371448563fc9e9c1546db9661 tp_drug_in_list delete_time=0 and status!=0 and specs= "500ml" and purification="分析纯" and drug_id=17 create_time 0 id count 2 941662601.072010 1 0 0 1646017397

表格: tp_table_statistic

备注: 通过分析表的任务生成的统计数据

索引:

名称 类型 属性 备注
主索引 id unique

字段:

名称 类型 默认值 属性 备注
id int(10) unsigned <auto_increment>
analy_uuid char(32) 对应分析任务的参数
time_periods char(16) 1970/01/01 08:00 时间周期:格式如: 【1970/01/01 08:00】表示从1970/01/01 08:00到1970/01/01 08:01的时段;【1970/01/01】:表示从1970/01/01的0点到1970/01/02的0点
time_type char(1) y time_periods的类型
count_num int(10) unsigned 0 对应时间段的 统计数据值
delete_time int(11) unsigned 0 软删除时间
update_time int(11) unsigned 0 更新时间
create_time int(11) unsigned 0 上传时间
data_last_time varchar(255) 0 最后一条数据的时间(可以是字符串):用于排序【任务表的table_calculate_field】

数据: (例子数据生成)

id analy_uuid time_periods time_type count_num delete_time update_time create_time
1 e298ee5cb0c8ca121b6d0ec8f6f5da21 2022 y 5 0 1644892401 1643098396
2 e298ee5cb0c8ca121b6d0ec8f6f5da21 2022/01 m 5 0 1644892401 1643098396
3 e298ee5cb0c8ca121b6d0ec8f6f5da21 2022/01/21 d 5 0 1644892401 1643098396
4 5e39c8faedc3e0f2f1bac00d1dcfc3ff 2022 y 3 0 1644892401 1643098396
5 5e39c8faedc3e0f2f1bac00d1dcfc3ff 2022/01 m 3 0 1644892401 1643098396
6 5e39c8faedc3e0f2f1bac00d1dcfc3ff 2022/01/24 d 3 0 1644892401 1643098396
7 e47d03af3d74726369a52d4cd43b0224 2022 y 10 0 1644993828 1643098411
8 e47d03af3d74726369a52d4cd43b0224 2022/01 m 10 0 1644993828 1643098411
9 e47d03af3d74726369a52d4cd43b0224 2022/01/20 d 10 0 1644993828 1643098411
10 67d8bc9af14b07139c7b275eee76707a 2022 y 9 0 1644993828 1643098411
11 67d8bc9af14b07139c7b275eee76707a 2022/01 m 1 0 1644677755 1643098411
12 67d8bc9af14b07139c7b275eee76707a 2022/01/24 d 1 0 1644677755 1643098411
13 67d8bc9af14b07139c7b275eee76707a 2022/01/25 d 0 0 0 1644677755
14 67d8bc9af14b07139c7b275eee76707a 2022/01/26 d 0 0 0 1644677755
15 67d8bc9af14b07139c7b275eee76707a 2022/01/27 d 0 0 0 1644677755
16 67d8bc9af14b07139c7b275eee76707a 2022/01/28 d 0 0 0 1644677755
17 67d8bc9af14b07139c7b275eee76707a 2022/01/29 d 0 0 0 1644677755
18 67d8bc9af14b07139c7b275eee76707a 2022/01/30 d 0 0 0 1644677755
19 67d8bc9af14b07139c7b275eee76707a 2022/01/31 d 0 0 0 1644677755
20 67d8bc9af14b07139c7b275eee76707a 2022/02 m 8 0 1644993828 1644677755
21 67d8bc9af14b07139c7b275eee76707a 2022/02/01 d 0 0 0 1644677755
22 67d8bc9af14b07139c7b275eee76707a 2022/02/02 d 0 0 0 1644677755
23 67d8bc9af14b07139c7b275eee76707a 2022/02/03 d 0 0 0 1644677755
24 67d8bc9af14b07139c7b275eee76707a 2022/02/04 d 0 0 0 1644677755
25 67d8bc9af14b07139c7b275eee76707a 2022/02/05 d 0 0 0 1644677755
26 67d8bc9af14b07139c7b275eee76707a 2022/02/06 d 0 0 0 1644677755
27 67d8bc9af14b07139c7b275eee76707a 2022/02/07 d 0 0 0 1644677755
28 67d8bc9af14b07139c7b275eee76707a 2022/02/08 d 0 0 0 1644677755
29 67d8bc9af14b07139c7b275eee76707a 2022/02/09 d 0 0 0 1644677755
30 67d8bc9af14b07139c7b275eee76707a 2022/02/10 d 0 0 0 1644677755
31 67d8bc9af14b07139c7b275eee76707a 2022/02/11 d 5 0 1644889002 1644677755
32 67d8bc9af14b07139c7b275eee76707a 2022/02/12 d 0 0 0 1644889002
33 67d8bc9af14b07139c7b275eee76707a 2022/02/13 d 0 0 0 1644889002
34 67d8bc9af14b07139c7b275eee76707a 2022/02/14 d 3 0 1644993828 1644889002
35 1f125ba371448563fc9e9c1546db9661 2022 y 5 0 0 1646017398
36 1f125ba371448563fc9e9c1546db9661 2022/02 m 5 0 0 1646017398
37 1f125ba371448563fc9e9c1546db9661 2022/02/24 d 5 0 0 1646017398
38 0a5d568c7f8b7f9f271e530e8f146af9 2022 y 3 0 0 1646017398
39 0a5d568c7f8b7f9f271e530e8f146af9 2022/02 m 3 0 0 1646017398
40 0a5d568c7f8b7f9f271e530e8f146af9 2022/02/24 d 3 0 0 1646017398
 /*** 数据量不能过多,过多的时候需要考虑按照查询大表中数据的按照每年的数据进行分开查询数据写入,再不行就分月 分日 * 需要参数uuid* 1.获取分析数据的配置* 2.查询统计表table_statistic中是否存在已有的分析数据,获取最后的分析数据的最新【(年)数据、(年月)数据、(年月日)数据、(年月日时)、(年月日时分)】的数据各一条(这几个数据需要重新修改(因为有可能不是最新的了))* 3.根据第1点和第2点得到数据--生成sql语句* 4.执行sql语句--查询* 5.将查询到数据封装成二维数组--* 6.写入到统计表中table_statistic*/public function analyTable($analyUuid = ''){//第1步:根据uuid,获取分析数据的配置$analyData = $this->getDataByUUID();if($analyData['code'] !== 0){return $analyData;}if(empty($analyUuid)){$analyUuid = input('get.uuid');}// dump($analyData);//第2步:根据analy_uuid获取最新的数据$statisticData = $this->findByAnalyUUIDWithLastData(input('get.uuid'));if($statisticData['code'] !== 0){return $statisticData;}// dump($statisticData);//第3步:根据配置数据生成sql语句$sql = '';if($analyData['data']['table_analy_field_type'] == 1){$analyData['data']['table_analy_where'] = !empty($analyData['data']['table_analy_where'])?(($statisticData['data']['time_periods_int'] == 0)?$analyData['data']['table_analy_where']:$analyData['data']['table_analy_where']." and TO_DAYS(".$analyData['data']['table_analy_field'] . ") >= TO_DAYS('" .$statisticData['data']['time_periods']."')"):$analyData['data']['table_analy_where'];$sql = $sql."select UNIX_TIMESTAMP(".$analyData['data']['table_analy_field'].") as ".$analyData['data']['table_analy_field'].",".$analyData['data']['table_calculate_field']. " from ".$analyData['data']['table_name']." where ".$analyData['data']['table_analy_where'] ." order by ".$analyData['data']['table_analy_field'] ." asc";}else{$analyData['data']['table_analy_where'] = !empty($analyData['data']['table_analy_where'])?$analyData['data']['table_analy_where']." and ".$analyData['data']['table_analy_field'] . ">=" .$statisticData['data']['time_periods_int']:$analyData['data']['table_analy_where'];$sql = $sql."select ".$analyData['data']['table_analy_field'].",".$analyData['data']['table_calculate_field']. " from ".$analyData['data']['table_name']." where ".$analyData['data']['table_analy_where'] ." order by ".$analyData['data']['table_analy_field'] ." asc";}// dump($sql);// dump("第二步的数据需要拼至sql的where中,未完成");if(empty($sql)){return app('api_result')->returnArray(3,['msg'=>'sql语句不能为空!']);}//第4步:执行sql语句--如果数据过大- 下面的其他步骤就需要修改-- 解决方案是:将表进行拆分查询 然后再写入--比如将上面一步的查询数据修改为只查1万条数据即可,然后再重新进行分析// query方法用于执行SQL查询操作,如果数据非法或者查询错误则返回false,否则返回查询结果数据集(同select方法)。// Db::query("select * from think_user where status=1");// execute用于更新和写入数据的sql操作,如果数据非法或者查询错误则返回false,否则返回影响的记录数。// Db::execute("update think_user set name='thinkphp' where status=1");$dbData =  Db::query($sql);// dump($sql);if(empty($dbData)){return app('api_result')->returnArray(0,['msg'=>'执行sql语句,查询不到任何数据']);}// dump($dbData);// die;//第5步:封装数据//第一条数据为最开始的数据,最后一条数据为最新的数据$totalLength = count($dbData);$firstIndexData = $dbData[0];$lastIndexData = $dbData[count($dbData)-1];$firstYear = date("Y",$firstIndexData[$analyData['data']['table_analy_field']]);//最开始的年$firstMonth = date("m",$firstIndexData[$analyData['data']['table_analy_field']]);//最开始的月$firstDate = date("d",$firstIndexData[$analyData['data']['table_analy_field']]);//最开始的日$firstHour = date("H",$firstIndexData[$analyData['data']['table_analy_field']]);//最开始的小时$firstMinute = date("i",$firstIndexData[$analyData['data']['table_analy_field']]);//最开始的分钟$lastYear = date("Y",$lastIndexData[$analyData['data']['table_analy_field']]);//最后的年$lastMonth = date("m",$lastIndexData[$analyData['data']['table_analy_field']]);//最后的的月$lastDate = date("d",$lastIndexData[$analyData['data']['table_analy_field']]);//最后的的日$lastHour = date("H",$lastIndexData[$analyData['data']['table_analy_field']]);//最后的的小时$lastMinute = date("i",$lastIndexData[$analyData['data']['table_analy_field']]);//最后的的分钟// dump(date("Y-m-d h:i:s"),$firstIndexData);// dump(date("Y-m-d h:i:s"),$lastIndexData);// dump( $dbData);die;$data = []; //直接写入的数据$updateData = []; //直接更新的数据$backData = []; //需要重新计算的数据$startYear = $firstYear;//生成数据-从年-月-日-小时-分钟逐一开始for($y=$startYear; $y<=$lastYear;$y++){$yearNum = 0;//当前年数据for($j=0; $j<$totalLength; $j++){if(date("Y",$dbData[$j][$analyData['data']['table_analy_field']])==$y){if($analyData['data']['table_calculate_method'] == 'count'){$yearNum +=1;//加1}if($analyData['data']['table_calculate_method'] == 'sum'){$yearNum += $dbData[$j][$analyData['data']['table_calculate_field']];//按照字段的值进行加}}}//等于当前年的时候,需要写到更新数据中if($statisticData['data']['year'] == $y){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年if($analyData['data']['analy_type'] == 4){//更新的数据需要重新查询  === 等于当前年时 只需要更新即可$updateData = array_merge($updateData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y,'count_num'=>$yearNum,'time_type'=>'y','update_time'=>time()]]);}else{//这个年份需要重新计算-- 正年的数据--- 包含历史数据和现在的数据 //count_num == 按照分析任务的类型; 比如 年月 那么计算当前年的所有的月的总数据sum ; 年月日 则就算当前年的所有的日的总数据sum 其他的类比$backData = array_merge($backData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y,'count_num'=>0, // 需重算--- 'update_time'=>time(),'time_type'=>'y','analy_type'=>$analyData['data']['analy_type']]]);}}else{$data = array_merge($data,[['analy_uuid'=>$analyUuid,'time_periods'=>$y,'time_type'=>'y','count_num'=>$yearNum,'create_time'=>time()]]);}//analy_type的值有0,1,2,3,4 ---其中0是计算到分钟,1是计算到小时;2是计算到天,3是计算到月份,4计算到年if($analyData['data']['analy_type'] > 3){continue;}//月数据开始$startMonth = $y == $firstYear?$firstMonth:1;//最开始的一年,计算最开始的月份,其他的从1月份开始$lastMonthLength = $y == $lastYear?$lastMonth:12;//如果是最后一年,那么就计算到数据的最后一个月,其他的年份都是到12月for($m=$startMonth;$m<=$lastMonthLength;$m++){$monthNum = 0; //当前月数据for($j=0; $j<$totalLength; $j++){if(date("Y/m",$dbData[$j][$analyData['data']['table_analy_field']]) == $y."/".sprintf('%02d',$m)){if($analyData['data']['table_calculate_method'] == 'count'){$monthNum +=1;//加1}if($analyData['data']['table_calculate_method'] == 'sum'){$monthNum += $dbData[$j][$analyData['data']['table_calculate_field']];//按照字段的值进行加}}}//等于当前年当前月的时候,需要写到更新数据中if($statisticData['data']['year'] == $y && $statisticData['data']['month'] == sprintf('%02d',$m)){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年if($analyData['data']['analy_type'] == 3){//更新的数据需要重新查询  === 等于当前年月时 只需要更新即可$updateData = array_merge($updateData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m),'count_num'=>$monthNum,'time_type'=>'m','update_time'=>time()]]);}else{//这个年份需要重新计算-- 正年的数据--- 包含历史数据和现在的数据 //count_num == 按照分析任务的类型; 比如 年月 那么计算当前年的所有的月的总数据sum ; 年月日 则就算当前年的所有的日的总数据sum 其他的类比$backData = array_merge($backData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m),'count_num'=>0,'update_time'=>time(),'time_type'=>'m','analy_type'=>$analyData['data']['analy_type']]]);}}else{$data = array_merge($data,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m),'time_type'=>'m','count_num'=>$monthNum,'create_time'=>time()]]);}//analy_type的值有0,1,2,3,4 ---其中0是计算到分钟,1是计算到小时;2是计算到天,3是计算到月份,4计算到年if($analyData['data']['analy_type'] > 2){continue;}//日数据开始$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数// $dateLength = date('t', strtotime($m."-".$y));//计算当前月份中的天数 --- 如果没有装 $startDate = ($y == $firstYear && sprintf('%02d',$m) == $firstMonth)?$firstDate:1;//如果是最开始的一年的那个月,则计算最开始的一天的当天开始算$lastDateLength = ($y == $lastYear && sprintf('%02d',$m) == $lastMonth)?$lastDate:$dateLength;//如果是最后一年,那么就只计算到最后一天,否则就是当月的总天数for($d=$startDate;$d<=$lastDateLength;$d++){$dateNum = 0;//当前日数据for($j=0; $j<$totalLength; $j++){if(date("Y/m/d",$dbData[$j][$analyData['data']['table_analy_field']]) == $y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)){if($analyData['data']['table_calculate_method'] == 'count'){$dateNum +=1;//加1}if($analyData['data']['table_calculate_method'] == 'sum'){$dateNum += $dbData[$j][$analyData['data']['table_calculate_field']];//按照字段的值进行加}}}//等于当前年当前月当前日的时候,需要写到更新数据中if($statisticData['data']['year'] == $y && $statisticData['data']['month'] == sprintf('%02d',$m) && $statisticData['data']['date'] == sprintf('%02d',$d)){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年if($analyData['data']['analy_type'] == 2){//更新的数据需要重新查询  === 等于当前年月时 只需要更新即可$updateData = array_merge($updateData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d),'count_num'=>$dateNum,'time_type'=>'d','update_time'=>time()]]);}else{//这个年份需要重新计算-- 正年的数据--- 包含历史数据和现在的数据 //count_num == 按照分析任务的类型; 比如 年月 那么计算当前年的所有的月的总数据sum ; 年月日 则就算当前年的所有的日的总数据sum 其他的类比$backData = array_merge($backData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d),'count_num'=>0,'update_time'=>time(),'time_type'=>'d','analy_type'=>$analyData['data']['analy_type']]]);}}else{$data = array_merge($data,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d),'time_type'=>'d','count_num'=>$dateNum,'create_time'=>time()]]);}//analy_type的值有0,1,2,3,4 ---其中0是计算到分钟,1是计算到小时;2是计算到天,3是计算到月份,4计算到年if($analyData['data']['analy_type'] > 1){continue;}//小时数据开始$startHour = ($y == $firstYear && sprintf('%02d',$m) == $firstMonth && sprintf('%02d',$d) == $firstDate)?$firstHour:0;//如果是最开始的一年的那个月那一天,则计算最开始的一天的当天开始算$lastHourLength = ($y == $lastYear && sprintf('%02d',$m) == $lastMonth && sprintf('%02d',$d) == $lastDate)?$lastHour:23;//如果是最后一年,那么就只计算到最后一天,否则就是当月的当天的当前小时for($h=$startHour;$h<=$lastHourLength;$h++){$hourNum = 0;//当前小时数据for($j=0; $j<$totalLength; $j++){if(date("Y/m/d H",$dbData[$j][$analyData['data']['table_analy_field']]) == $y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h)){if($analyData['data']['table_calculate_method'] == 'count'){$hourNum +=1;//加1}if($analyData['data']['table_calculate_method'] == 'sum'){$hourNum += $dbData[$j][$analyData['data']['table_calculate_field']];//按照字段的值进行加}}}//等于当前年当前月当前日当前小时的时候,需要写到更新数据中if($statisticData['data']['year'] == $y && $statisticData['data']['month'] == sprintf('%02d',$m) && $statisticData['data']['date'] == sprintf('%02d',$d) && $statisticData['data']['hour'] == sprintf('%02d',$h)){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年if($analyData['data']['analy_type'] == 1){//更新的数据需要重新查询  === 等于当前年月时 只需要更新即可$updateData = array_merge($updateData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h),'count_num'=>$hourNum,'time_type'=>'h','update_time'=>time()]]);}else{//这个年份需要重新计算-- 正年的数据--- 包含历史数据和现在的数据 //count_num == 按照分析任务的类型; 比如 年月 那么计算当前年的所有的月的总数据sum ; 年月日 则就算当前年的所有的日的总数据sum 其他的类比$backData = array_merge($backData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h),'count_num'=>$hourNum,'update_time'=>time(),'time_type'=>'h','analy_type'=>$analyData['data']['analy_type']]]);}}else{$data = array_merge($data,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h),'time_type'=>'h','count_num'=>$hourNum,'create_time'=>time()]]);}    //analy_type的值有0,1,2,3,4 ---其中0是计算到分钟,1是计算到小时;2是计算到天,3是计算到月份,4计算到年if($analyData['data']['analy_type'] > 0){continue;}//分钟数据开始$startMinute = ($y == $firstYear && sprintf('%02d',$m) == $firstMonth && sprintf('%02d',$d) == $firstDate && sprintf('%02d',$h) == $firstHour)?$firstMinute:0;//如果是最开始的一年的那个月那一天那一小时,则计算最开始的一天的当天开始算$lastMinuteLength = ($y == $lastYear && sprintf('%02d',$m) == $lastMonth && sprintf('%02d',$d) == $lastDate && sprintf('%02d',$h) == $lastHour)?$lastMinute:59;//如果是最后一年,那么就只计算到最后一天,否则就是当月的当天的当前小时for($minute = $startMinute; $minute<=$lastMinuteLength;$minute++){$minuteNum = 0;//当前小时数据for($j=0; $j<$totalLength; $j++){if(date("Y/m/d H",$dbData[$j][$analyData['data']['table_analy_field']]) == $y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute)){if($analyData['data']['table_calculate_method'] == 'count'){$minuteNum +=1;//加1}if($analyData['data']['table_calculate_method'] == 'sum'){$minuteNum += $dbData[$j][$analyData['data']['table_calculate_field']];//按照字段的值进行加}}}//等于当前年当前月当前日当前小时的时候,需要写到更新数据中if($statisticData['data']['year'] == $y && $statisticData['data']['month'] == sprintf('%02d',$m) && $statisticData['data']['date'] == sprintf('%02d',$d) && $statisticData['data']['hour'] == sprintf('%02d',$h) && $statisticData['data']['minute'] == sprintf('%02d',$minute)){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年if($analyData['data']['analy_type'] == 0){//更新的数据需要重新查询  === 等于当前年月时 只需要更新即可$updateData = array_merge($updateData,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute),'count_num'=>$minuteNum,'time_type'=>'i','update_time'=>time()]]);}else{//这里应该没有作用  因为我的任务只计算到分钟 没有秒钟  但是保留代码//这个年份需要重新计算-- 正年的数据--- 包含历史数据和现在的数据 //count_num == 按照分析任务的类型; 比如 年月 那么计算当前年的所有的月的总数据sum ; 年月日 则就算当前年的所有的日的总数据sum 其他的类比// $backData = array_merge($backData,[[//     'analy_uuid'=>$analyUuid,//     'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute),//     'count_num'=>0,//     'update_time'=>time(),//     'time_type'=>'i',//     'analy_type'=>$analyData['data']['analy_type']// ]]);}}else{$data = array_merge($data,[['analy_uuid'=>$analyUuid,'time_periods'=>$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute),'time_type'=>'i','count_num'=>$minuteNum,'create_time'=>time()]]);}}//分钟-end      }//小时-end}//天-end}//月-end}//年-endreturn $this->saveStatistic($data,$updateData,$backData,$analyUuid);}/*** 写入统计数据* @param $data 批量写入的数据* @param $updateData 批量要更新的数据 没有主键id* @param $backData 需要重新计算的数组* @param $analy_type 分析任务的类型*/public function saveStatistic($data=[],$updateData=[],$backData = [],$analy_uuid=''){Db::startTrans();try {// dump($data);die;if(!empty($data)){// 分批写入 每次最多100条数据$list = Db::name('table_statistic')->limit(100)->insertAll($data);}//更新这一块数据 -- 只更新最后一条数据if(!empty($updateData)){for($i=0; $i<count($updateData); $i++){Db::name('table_statistic') ->where([['analy_uuid','eq',$updateData[$i]['analy_uuid']],['time_periods','eq',$updateData[$i]['time_periods']]]) ->update($updateData[$i]);}}  $wheres = [];if(!empty($backData)){$wheres = $this->createBackDataWhere($backData);for($i=0; $i<count($backData); $i++){$updateBackData = ['analy_uuid'=>$backData[$i]['analy_uuid'],'time_periods'=>$backData[$i]['time_periods'],'time_type'=>$backData[$i]['time_type'],'count_num'=>Db::name('table_statistic')->where($wheres[$i])->sum('count_num'),'update_time'=>time()];Db::name('table_statistic')->where([['analy_uuid','eq',$backData[$i]['analy_uuid']],['time_periods','eq',$backData[$i]['time_periods']]])->update($updateBackData);}}// 提交事务Db::commit();return app('api_result')->echoJson(0,['uuid'=>$analy_uuid,'msg'=>'任务成功']);} catch (\Exception $e) {// 回滚事务Db::rollback();return app('api_result')->echoJson(3,['uuid'=>$analy_uuid,'msg'=>'任务失败!']);}}/*** 返回 构造的查询条件*/public function createBackDataWhere($backData){$wheres = [];for($i=0; $i<count($backData); $i++){$wheres[$i] = [];if(isset($backData[$i]['analy_type']) && isset($backData[$i]['time_type'])){//【分析类型-分析包含的数据】0 :按照年,月,日,时,分;1:按照年,月,日,时;2:按照年,月,日;3:按照年,月;4:按照年switch ($backData[$i]['time_type']) {case 'y':switch ($backData[$i]['analy_type']) {case 0:$y = substr($backData[$i]['time_periods'],0,4);for($m = 1; $m <= 12; $m++){$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){for($h = 0; $h< 24; $h++){for($minute = 0; $minute<60; $minute++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute)]);}}}}break;case 1:$y = substr($backData[$i]['time_periods'],0,4);for($m = 1; $m <= 12; $m++){$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){for($h = 0; $h< 24; $h++){$$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h)]);}}}break;case 2:$y = substr($backData[$i]['time_periods'],0,4);for($m = 1; $m <= 12; $m++){$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)]);}}break;case 3:$y = substr($backData[$i]['time_periods'],0,4);for($m = 1; $m <= 12; $m++){$wheres[$i] = array_merge($wheres[$i],$y."/".sprintf('%02d',$m));}break;case 4://年分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;default:break;}//end-switchbreak;case 'm':switch ($backData[$i]['analy_type']) {case 0:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){for($h = 0; $h< 24; $h++){for($minute = 0; $minute<60; $minute++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute)]);}}}break;case 1:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){for($h = 0; $h< 24; $h++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h)]);}}break;case 2:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$dateLength = cal_days_in_month(CAL_GREGORIAN, $m, $y);//计算当前月份中的天数for($d = 1; $d<= $dateLength; $d++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)]);}break;case 3://月分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 4://年分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;default:break;}//end-switch  break;case "d":switch ($backData[$i]['analy_type']) {case 0:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$d = substr($backData[$i]['time_periods'],8,2);for($h = 0; $h< 24; $h++){for($minute = 0; $minute<60; $minute++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute)]);}}break;case 1:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$d = substr($backData[$i]['time_periods'],8,2);for($h = 0; $h< 24; $h++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h)]);}break;case 2://日分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 3://月分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 4://年分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;default:break;}//end-switch break;case "h":switch ($backData[$i]['analy_type']) {case 0:$y = substr($backData[$i]['time_periods'],0,4);$m = substr($backData[$i]['time_periods'],5,2);$d = substr($backData[$i]['time_periods'],8,2);$h = substr($backData[$i]['time_periods'],11,2);for($minute = 0; $minute<60; $minute++){$wheres[$i] = array_merge($wheres[$i],[$y."/".sprintf('%02d',$m)."/".sprintf('%02d',$d)." ".sprintf('%02d',$h).":".sprintf('%02d',$minute)]);}break;case 1://时分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 2://日分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 3://月分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;case 4://年分析任务的话 此时不需要重算了 在上面的更新数据中,即statistic中的最后一条数据是使用更新 不需要重新计算break;default:break;}//end-switch break;default:# code...break;}//end-switch $where = [['analy_uuid','eq',$backData[$i]['analy_uuid']]];  $wheres[$i] = !empty($wheres[$i])?array($where,[['time_periods','in',$wheres[$i]]]):$where;}//end-if}//end-forreturn $wheres;}

测试图:这里分析了最近12个月的数据,由于只有一个月的数据,其他月份数据为0,所以柱状图比较大 。

将mysql数据表的数据转成百度ECharts可用的数据相关推荐

  1. 用DevExpress.Xpo 直接维护后台的 数据表,在这四列中录入的数据,即时插入或更新到关联的数据表中

    用DevExpress.Xpo 直接维护后台的 数据表,在这四列中录入的数据,即时插入或更新到关联的数据表中. 步骤: 1.引入DevExpress.Xpo.DLL服务 2.加入这些 using De ...

  2. 推荐系统-排序层:主流CTR模型综述【Click-Through-Rate,点击率预估,指精排层的排序】【CTR 模型的输入(即训练数据)是:大量成对的 (features, label)数据】

    一.CTR 模型建模 在讲 CTR 模型之前,我们首先要清楚 CTR 模型是什么,用来解决什么问题.所以我们先描述 CTR 问题,并对其进行数学建模. 一个典型的推荐系统架构如下图所示: 一般会划分为 ...

  3. 百度ECharts地图GeoJson数据在线下载 2021

    百度ECharts地图GeoJson数据在线下载 项目中使用到了百度的图表插件ECharts,不得不说是真的好用,但是用到地图部分时,竟然没有地图的json数据包,网上.GitHub搜索,找到的离线包 ...

  4. 假设mysql数据表t1有字段_使用ROMA Connect集成数据

    概述 ROMA Connect支持接入多种类型的数据源,并通过数据集成任务实现源端到目标端的数据集成转换.ROMA Connect支持相同结构数据之间进行集成转换,也支持异构数据之间进行集成转换. 本 ...

  5. MySQL 数据表优化设计(九):如何设计统计数据表?

    有些时候,改进数据表查询性能的最佳方式是在同一张数据表中冗余一些继承的数据.然而,有些时候需要新建完全独立的统计或缓存数据表,尤其是在需要反复查询的需求情况下.如果业务允许一些时间上的误差的话,那么这 ...

  6. mysql主键自增 insert_MySQL数据表中有自增长主键时如何插入数据

    https://jingyan.baidu.com/article/fcb5aff7b3a025edaa4a7130.html 设置自增列 phpmyadmin 把A_I选中 就是AUTO_INCRE ...

  7. echarts tab切换_Python 数据可视化实战:使用 PyQt5 和 Echarts 打造股票数据看板

    月小水长一个编码者.思考者在一篇论文中,最吸引审稿人目光的莫过于枯燥的文字间精美的图表在一份项目路演ppt 中,酷炫的财务报表往往是打动投资人的最后一剂强心剂作为数据分析最后也是最直接的一环,数据可视 ...

  8. python制作股票图表怎么看_Python 数据可视化实战:使用 PyQt5 和 Echarts 打造股票数据看板...

    在一篇论文中,最吸引审稿人目光的莫过于枯燥的文字间精美的图表 在一份项目路演 ppt 中,酷炫的财务报表往往是打动投资人的最后一剂强心剂 作为数据分析最后也是最直接的一环,数据可视化的重要性不言而喻 ...

  9. “大数据时代下的地理信息可视化:ECharts地图和数据面板实践“

    数据可视化是一种数据分析技术,它通过将数据转化为图形或图表等可视化方式,以便更好地理解和解释数据.在实际应用中,数据可视化被广泛用于数据监控.业务分析.决策支持等领域.而ECharts是一款优秀的数据 ...

最新文章

  1. 蓝云公布2019云生态战略,如何解决企业上云关键问题?
  2. NSAutoReleasePool使用中drain和release的区别
  3. linux 环境下配置ftp服务器
  4. 「Sqlserver」数据分析师有理由爱Sqlserver-好用的插件工具推荐
  5. linux futex 进程同步,Linux的新式线程同步原语——Futex
  6. 中国现磨咖啡行业白皮书
  7. 批量部署Linux操作系统的一场革命----Cobbler
  8. 支付业务与技术架构学习总结(4)——对账相关业务知识及对账系统总结
  9. utilities(matlab)—— mat2imgcell
  10. Android打包使用自有证书认证
  11. python语音转文字源码_python文字转语音实现过程解析
  12. [Qualcomm][MSM8909]APQ8009基线上编写一个OpenGl测试程序
  13. RPG游戏制作-03-人物行走及A*寻路算法
  14. Rviz显示不出数据了之一文搞懂Qos
  15. 【论文笔记】基于强化学习的机器人手臂仿人运动规划方法
  16. android支付宝支付接口申请,支付宝分享SDK接入指南—Android
  17. VBS脚本病毒总结与分析
  18. 对着Java性能调优,艿艿也很无奈···
  19. 8684网站航班数据获取
  20. 从1G说到5G:全球通信

热门文章

  1. 如何禁用Maya的Output window
  2. 如何把mac照片导入u盘_苹果电脑怎么拷贝文件到u盘_苹果电脑拷贝文件到u盘的方法-系统城...
  3. swoole服务的重启方式
  4. 宇视视频水印如何查看
  5. Magic Live智慧引擎发力,荣耀吹响智慧服务变革号角
  6. MySQL更换主键 删除主键 增加主键
  7. [PythonCode]扫描局域网的alive ip地址
  8. Photoshop临摹
  9. 手机AI芯片的诸神之争
  10. 网站课设——壁纸网站+留言板(PHP+wamp)