create_cxf.sql 12 KB

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