create_cxf.sql 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. create table iot_device
  2. (
  3. id bigint unsigned auto_increment primary key,
  4. company_id bigint unsigned not null default 0 comment '所属客户id',
  5. guid varchar(255) not null default '' comment '唯一标识[暂时保留]',
  6. device_code varchar(255) not null default '' comment '设备编号',
  7. sn varchar(255) not null default '' comment 'sn通常是:IMEI',
  8. mod_code varchar(255) not null default '' comment '物联网模型码值',
  9. device_name varchar(255) not null default '' comment '设备名称[旧系统的title]',
  10. brand varchar(255) not null default '' comment '设备品牌名称',
  11. model_code varchar(255) not null default '' comment '型号',
  12. description varchar(1024) not null default '' comment '最后一次设备更新信息值[旧系统的desc]',
  13. remarks varchar(255) charset utf8mb4 not null default '' comment '备注',
  14. status tinyint unsigned not null default 1 comment '1在线2离线3异常',
  15. longitude varchar(40) not null default '' comment '经度[lng]',
  16. latitude varchar(40) not null default '' comment '纬度[lat]',
  17. high varchar(40) not null default '' comment '高度',
  18. create_time datetime not null default current_timestamp comment '创建时间',
  19. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
  20. create_user varchar(255) not null default '' comment '创建人',
  21. update_user varchar(255) not null default '' comment '更新人',
  22. del_flag tinyint not null default 0 comment '0-未删除,1-删除',
  23. eg_id bigint not null default -1 comment '设备类别',
  24. tenant_id varchar(128) not null default '' comment '租户id',
  25. constraint guid unique (guid)
  26. ) comment '设备表';
  27. create table iot_device_group
  28. (
  29. id bigint unsigned auto_increment primary key,
  30. device_group_code varchar(255) not null default '' comment '设备分组码值',
  31. company_id bigint not null default 0 comment '所属客户id',
  32. title varchar(255) not null default '' comment '设备分组名称',
  33. large_type tinyint unsigned not null default 0 comment '[有点晕?]1-12(车辆、装载机、矿卡、人员、水表、电表、边坡监控、视频监控、皮带称重、环境监测、无人地磅、排放监测)',
  34. del_flag tinyint not null default 0 comment '0-未删除,1-删除',
  35. create_time datetime not null default CURRENT_TIMESTAMP comment '创建时间',
  36. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
  37. create_user varchar(255) not null default '' comment '创建人',
  38. update_user varchar(255) not null default '' comment '更新人',
  39. tenant_id varchar(255) not null default '' comment '租户id'
  40. ) comment '设备分组表';
  41. create table iot_mod_group
  42. (
  43. id bigint unsigned auto_increment primary key,
  44. company_id bigint unsigned not null default 0 comment '所属客户id',
  45. mode_group_code varchar(255) not null default '' comment '物理模型分组码值唯一标识',
  46. name varchar(255) not null default '' comment '物模型分组名称',
  47. create_time datetime not null default CURRENT_TIMESTAMP comment '创建时间',
  48. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP,
  49. del_flag tinyint not null default 0 comment '0-未删除,1-删除',
  50. create_user varchar(255) not null default '' comment '创建人',
  51. update_user varchar(255) not null default '' comment '修改人',
  52. tenant_id varchar(255) not null default '' comment '租户id',
  53. constraint name unique (mode_group_code)
  54. ) comment '物理模型分组表';
  55. create table iot_mod
  56. (
  57. id bigint unsigned auto_increment primary key,
  58. mod_code varchar(255) not null default '' comment '物理模型码值',
  59. company_id bigint unsigned not null default 0 comment '所属客户id',
  60. mode_group_code varchar(255) not null default '' comment '物模型分组码值',
  61. guid varchar(255) collate utf8mb4_general_ci not null default '' comment '唯一标识',
  62. name varchar(255) not null default '' comment '物模型名称',
  63. description varchar(255) not null default '' comment '最后一次更新值[原来字段 desc]',
  64. remarks varchar(255) not null default '' comment '备注',
  65. tsl_json text null comment '包含JSON',
  66. version int unsigned not null default 1 comment '版本[原来字段 tsl_ver]',
  67. num int unsigned not null default 0 comment '设备数',
  68. del_flag tinyint not null default 0 comment '0-未删除,1-删除',
  69. create_user varchar(255) not null default '' comment '创建人',
  70. update_user varchar(255) not null default '' comment '更新人',
  71. create_time datetime not null default current_timestamp comment '创建时间',
  72. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
  73. tenant_id varchar(255) not null default '' comment '租户id'
  74. )comment '物模型lot表' ;
  75. create table iot_device_error
  76. (
  77. id bigint unsigned auto_increment primary key,
  78. device_code varchar(255) not null default '' comment '设备编号',
  79. guid varchar(255) not null default '' comment '唯一标识[暂时保留]',
  80. error_reason text null comment '设备异常原因',
  81. create_time datetime not null default current_timestamp comment '创建时间',
  82. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间'
  83. )comment '设备异常记录表';
  84. create table iot_mod_error
  85. (
  86. id bigint unsigned auto_increment primary key,
  87. mod_code varchar(255) not null default '' comment '物理模型编号',
  88. error_reason text null comment '设备异常原因',
  89. create_time datetime not null default current_timestamp comment '创建时间',
  90. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间'
  91. )comment '物理模型设备异常记录表';
  92. create table time_Series_database_mapping
  93. (
  94. id bigint unsigned auto_increment primary key,
  95. time_Series_table_name varchar(255) not null default '' comment '时序数据库子表名称',
  96. time_Series_super_name varchar(255) not null default '' comment '时序数据库超级表名称',
  97. guid varchar(255) not null default '' comment 'guid',
  98. create_time datetime not null default current_timestamp comment '创建时间',
  99. update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
  100. tenant_id varchar(255) not null default '' comment '租户id'
  101. )comment '时序数据库和关系型数据库映射表';
  102. create table saas_equipment_manage
  103. (
  104. id int unsigned auto_increment primary key,
  105. device_name varchar(60) not null default '' comment '设备名称',
  106. equipment_type varchar(100) not null default '' comment '设备类型',
  107. energy_type tinyint(1) not null default 1 comment '能源形式',
  108. equipment_guid varchar(40) not null default '' comment '设备GUID',
  109. mod_guid varchar(40) not null default '' comment '物联网模型GUID',
  110. pay_time datetime not null default '1000-01-01 00:00:00' comment '购买时间',
  111. depreciation_period int not null default -1 comment '折旧年限',
  112. total_depreciation_value decimal(15, 2) not null default 0.00 comment '折旧总值',
  113. create_time datetime not null default current_timestamp comment '创建时间',
  114. update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间'
  115. )comment '设备基础管理表(关联物联网ID)';
  116. create index energy_type
  117. on saas_equipment_manage (energy_type);
  118. create index guid
  119. on saas_equipment_manage (mod_guid);
  120. create index type
  121. on saas_equipment_manage (equipment_type);
  122. -- create table iot_device_history
  123. -- (
  124. -- id int unsigned auto_increment
  125. -- primary key,
  126. -- guid varchar(255) not null default '' comment '设备guid标识',
  127. -- sn varchar(255) not null default '' comment '设备唯一sn码标识',
  128. -- value varchar(20) not null default '' comment '某天最后一条值',
  129. -- large_type tinyint not null default -1 comment '1-12(车辆、装载机、矿卡、人员、水表、电表、边坡监控、视频监控、皮带称重、环境监测、无人地磅、排放监测)',
  130. -- unit varchar(10) not null default '' comment '单位',
  131. -- create_time datetime not null default current_timestamp comment '对应某天时间'
  132. -- )comment '设备归档表';
  133. --
  134. --
  135. --
  136. --
  137. --
  138. --
  139. --
  140. --
  141. --
  142. -- create table saas_point_position_device
  143. -- (
  144. -- id bigint unsigned auto_increment
  145. -- primary key,
  146. -- p_id bigint not null default -1 comment '点位表id',
  147. -- guid varchar(120) not null default '' comment '设备id',
  148. -- device_group_code varchar(255) not null default '' comment '物联网设备的分组id或摄像头设备的标签id',
  149. -- category tinyint unsigned not null default 2 comment '1-iot ,2-device',
  150. -- create_time datetime not null default current_timestamp comment '创建时间',
  151. -- update_time datetime not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
  152. -- del_flag tinyint not null default 0 comment '0-未删除,1-删除',
  153. -- status tinyint unsigned not null default 1 comment '1启用,2禁用',
  154. -- constraint p_id_2
  155. -- unique (p_id, guid, category)
  156. -- ) comment '大屏点位设备关系表';
  157. --
  158. -- create index guid
  159. -- on saas_point_position_device (guid);
  160. --
  161. -- create index p_id
  162. -- on saas_point_position_device (p_id);
  163. --
  164. --
  165. --
  166. --
  167. --
  168. -- create index guid
  169. -- on iot_device_history (guid);
  170. --
  171. -- create index guid_2
  172. -- on iot_device_history (guid, create_time);