<?xml version="1.0" encoding="utf-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

    <changeSet author="suhuiguang" id="1587349916716-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_source" columnName="ue4_location"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column ue4_location</comment>
        <sql>
            alter table `f_risk_source` add column `ue4_location` text default null  comment 'ue4位置' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587349916716-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_source" columnName="ue4_rotation"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column ue4_rotation</comment>
        <sql>
            alter table `f_risk_source` add column `ue4_rotation` text default null  comment 'ue4旋转' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587349916716-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_source" columnName="ue4_extent"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column ue4_extent</comment>
        <sql>
            alter table `f_risk_source` add column `ue4_extent` text default null  comment 'ue4缩放' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587351415717-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_equipment" columnName="ue4_location"/>
            </not>
        </preConditions>
        <comment>f_equipment add column ue4_location</comment>
        <sql>
            alter table `f_equipment` add column `ue4_location` text default null  comment 'ue4位置' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587351415717-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_equipment" columnName="ue4_rotation"/>
            </not>
        </preConditions>
        <comment>f_equipment add column ue4_rotation</comment>
        <sql>
            alter table `f_equipment` add column `ue4_rotation` text default null  comment 'ue4旋转' after `position3d`;
        </sql>
    </changeSet>

    <changeSet author="suhuiguang" id="1587350552716-1">
    <preConditions onFail="MARK_RAN">
        <not>
            <columnExists tableName="f_fire_equipment" columnName="ue4_location"/>
        </not>
    </preConditions>
    <comment>f_fire_equipment add column ue4_location</comment>
    <sql>
        alter table `f_fire_equipment` add column `ue4_location` text default null  comment 'ue4位置' after `position3d`;
    </sql>
</changeSet>
    <changeSet author="suhuiguang" id="1587350552716-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_fire_equipment" columnName="ue4_rotation"/>
            </not>
        </preConditions>
        <comment>f_fire_equipment add column ue4_rotation</comment>
        <sql>
            alter table `f_fire_equipment` add column `ue4_rotation` text default null  comment 'ue4旋转' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587350593716-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_fire_station" columnName="ue4_location"/>
            </not>
        </preConditions>
        <comment>f_fire_station add column ue4_location</comment>
        <sql>
            alter table `f_fire_station` add column `ue4_location` text default null  comment 'ue4位置' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587350593716-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_fire_station" columnName="ue4_rotation"/>
            </not>
        </preConditions>
        <comment>f_fire_station add column ue4_rotation</comment>
        <sql>
            alter table `f_fire_station` add column `ue4_rotation` text default null  comment 'ue4旋转' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587350759717-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_water_resource" columnName="ue4_location"/>
            </not>
        </preConditions>
        <comment>f_water_resource add column ue4_location</comment>
        <sql>
            alter table `f_water_resource` add column `ue4_location` text default null  comment 'ue4位置' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587350759717-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_water_resource" columnName="ue4_rotation"/>
            </not>
        </preConditions>
        <comment>f_water_resource add column ue4_rotation</comment>
        <sql>
            alter table `f_water_resource` add column `ue4_rotation` text default null  comment 'ue4旋转' after `position3d`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1587350860716-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="f_safety_index_change_log"/>
            </not>
        </preConditions>
        <comment>create f_safety_index_change_log</comment>
        <sql>
            create table f_safety_index_change_log
            (
            id                   bigint(20) not null auto_increment comment '物理主键',
            safety_index         decimal(4,1) comment '安全指数',
            collect_date         date comment '统计日期',
            org_code             varchar(100) comment '机构',
            remark               varchar(255) comment '备注',
            primary key (id)
            );
            alter table f_safety_index_change_log comment '安全指数日流水';
            create index Index_org_code on f_safety_index_change_log
            (
            org_code
            );
        </sql>
    </changeSet>

    <changeSet id="1587882668719-1" author="suhuiguang">
    	 <preConditions onFail="MARK_RAN">
            <not>
            	<indexExists indexName="idx_type"/>
            </not>
        </preConditions>
        <createIndex
                indexName="idx_type"
                tableName="f_fire_station"
                tablespace="A String"
                unique="false">
            <column name="type"/>
        </createIndex>
    </changeSet>
    <changeSet author="shanqiyun" id="1588067351000-1">
        <preConditions onFail="MARK_RAN">
        	<not>
            	<columnExists tableName="f_risk_source" columnName="route_path"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column route_path </comment>
        <sql>
            alter table f_risk_source add column `route_path` varchar(2000) DEFAULT NULL COMMENT '路径坐标' after `position3d`;
 		</sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1588140925893-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_safety_index_change_log" columnName="create_date"/>
            </not>
        </preConditions>
        <comment>f_safety_index_change_log add column create_date</comment>
        <sql>
            alter table `f_safety_index_change_log` add column `create_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间';
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1588990926789-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_level " columnName="manage_level"/>
            </not>
        </preConditions>
        <comment>f_risk_level add column manage_level 管控级别</comment>
        <sql>
            ALTER TABLE `f_risk_level`
            add COLUMN `manage_level` tinyint(4) DEFAULT NULL COMMENT '管控级别';
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1589165258908-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_rpn_change_log " columnName="trigger_type"/>
            </not>
        </preConditions>
        <comment>f_rpn_change_log add column trigger_type 触发类型</comment>
        <sql>
            ALTER TABLE `f_rpn_change_log`
            add COLUMN `trigger_type` varchar(20) DEFAULT NULL COMMENT '触发类型：巡检、告警、评价、删除' after `trigger_by`;
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1589165258908-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_source " columnName="flicker_frequency"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column flicker_frequency 闪烁频率</comment>
        <sql>
            ALTER TABLE `f_risk_source`
            add COLUMN `flicker_frequency` int(11) DEFAULT 0 COMMENT '闪烁频率' after `status`;
        </sql>
    </changeSet>
    <changeSet author="zhouyi" id="1589444792916-1">
        <preConditions onFail="MARK_RAN">
            <tableExists tableName="f_station_info"/>
        </preConditions>
        <comment>create table f_station_info</comment>
        <sql>
            DROP TABLE IF EXISTS f_station_info;
            CREATE TABLE `f_station_info` (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
            `name` varchar(20) DEFAULT NULL COMMENT '名称',
            `station_code` varchar(32) NOT NULL COMMENT '环流站编码',
            `code` varchar(10) DEFAULT NULL COMMENT '后三位编码',
            `elec_type` tinyint(4) DEFAULT NULL COMMENT '换流站类型：1-发电类型；2-收电类型',
            `use_type` tinyint(4) NOT NULL COMMENT '用途类型:1-电厂升压变电站；2-公用普通变电站；3-公用换流变电站；4-企业自备变电站；5-其他',
            `province_code` varchar(32) DEFAULT NULL COMMENT '省份编码',
            `city_code` varchar(32) DEFAULT NULL COMMENT '市区编码',
            `district_code` varchar(32) DEFAULT NULL COMMENT '区县编码',
            `address` varchar(255) DEFAULT NULL COMMENT '详细地址',
            `status` bit(1) NOT NULL DEFAULT b'0' COMMENT '0-启用；1-停用',
            `longitude` double DEFAULT NULL COMMENT '经度',
            `latitude` double DEFAULT NULL COMMENT '纬度',
            `station_charge_user_id` varchar(50) DEFAULT NULL COMMENT '换流站负责人',
            `safety_charge_user_id` varchar(50) DEFAULT NULL COMMENT '安全负责人',
            `create_date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建日期',
            `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
            `remark` varchar(255) DEFAULT NULL COMMENT '备注',
            PRIMARY KEY (`id`),
            UNIQUE KEY `f_station_info_uniq` (`station_code`)
            ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COMMENT='站端信息表';
        </sql>
    </changeSet>
    <changeSet author="suhuiguang" id="1589769364577-1">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="f_risk_level " columnName="manage_level"/>
        </preConditions>
        <comment>f_risk_level 增加管控级别 初始化数据</comment>
        <sql>
            update f_risk_level set manage_level = 1 where level = '1';
            update f_risk_level set manage_level = 2 where level = '2';
            update f_risk_level set manage_level = 3 where level = '3';
            update f_risk_level set manage_level = 4 where level = '4';
        </sql>
    </changeSet>

	<changeSet author="maoying" id="11590390304001-1">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="f_fire_equipment_point " columnName="fire_equipment_id"/>
        </preConditions>
        <comment>修改fire_equipment_id可为空</comment>
        <sql>
          	 ALTER TABLE `f_fire_equipment_point`
			MODIFY COLUMN `fire_equipment_id`  bigint(20) NULL COMMENT '消防装备id' AFTER `code`;
        </sql>
    </changeSet>

    <changeSet author="shanqiyun" id="1591672147780-1">
        <preConditions onFail="MARK_RAN">
             <viewExists viewName="toip_biz_message"/>
        </preConditions>
        <comment>create view toip_biz_message</comment>
        <sql>
            DROP VIEW IF EXISTS toip_biz_message;
            CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `toip_biz_message` AS SELECT
				`m`.`id` AS `id`,
				`m`.`time` AS `time`,
				`m`.`content` AS `content`,
				`m`.`title` AS `title`,
				`m`.`type` AS `type`,
				`m`.`sender` AS `sender`,
				`m`.`receiver` AS `receiver`,
				`m`.`reader` AS `reader`,
				`m`.`biz_id` AS `biz_id`,
				`m`.`bizclass_name` AS `bizclass_name`,
				`n`.`org_code` AS `org_code`
				FROM
					( `toip_sys_message` `m` JOIN `f_equipment` `n` )
				WHERE
					( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.FireEquimentDataRo' ) ) UNION ALL
				SELECT
					`m`.`id` AS `id`,
					`m`.`time` AS `time`,
					`m`.`content` AS `content`,
					`m`.`title` AS `title`,
					`m`.`type` AS `type`,
					`m`.`sender` AS `sender`,
					`m`.`receiver` AS `receiver`,
					`m`.`reader` AS `reader`,
					`m`.`biz_id` AS `biz_id`,
					`m`.`bizclass_name` AS `bizclass_name`,
					`n`.`org_code` AS `org_code`
				FROM
					( `toip_sys_message` `m` JOIN `p_point` `n` )
				WHERE
					( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.ProtalDataRo' ) ) UNION ALL
				SELECT
					`m`.`id` AS `id`,
					`m`.`time` AS `time`,
					`m`.`content` AS `content`,
					`m`.`title` AS `title`,
					`m`.`type` AS `type`,
					`m`.`sender` AS `sender`,
					`m`.`receiver` AS `receiver`,
					`m`.`reader` AS `reader`,
					`m`.`biz_id` AS `biz_id`,
					`m`.`bizclass_name` AS `bizclass_name`,
					`n`.`org_code` AS `org_code`
				FROM
					( `toip_sys_message` `m` JOIN `f_risk_source` `n` )
				WHERE
					( ( `n`.`id` = `m`.`biz_id` ) AND ( `m`.`bizclass_name` = 'class com.yeejoin.amos.fas.business.service.model.RiskSourceRuleRo' ) );
       </sql>
    </changeSet>

	<changeSet author="shanqiyun" id="1593309428780-1">
		<preConditions onFail="MARK_RAN">
			<not>
				<tableExists tableName="contingency_original_data" />
			</not>
		</preConditions>
		<comment>create table contingency_original_data</comment>
		<sql>
			DROP TABLE IF EXISTS contingency_original_data;
			CREATE TABLE `contingency_original_data` (
			  `id` varchar(36) NOT NULL COMMENT 'rule',
			  `fire_Equipment_Name` varchar(32) NOT NULL COMMENT '记录类型：消息MESSAGE，操作OPERATE',
			  `fire_Equipment_Id` varchar(500) NOT NULL COMMENT '记录内容：文本信息或者json数据',
			  `layer` int(11) NOT NULL COMMENT '一级分类',
			  `fire_Equipment_Layer` int(11) NOT NULL COMMENT '二级分类',
			  `fire_Equipment_Position` varchar(255) DEFAULT NULL COMMENT '图标,url，或者文件名',
			  `equipment_Id` int(11) NOT NULL COMMENT '排序',
			  `equipment_Name` varchar(255) DEFAULT NULL,
			  `mobile` varchar(255) DEFAULT NULL,
			  `admin_Name` varchar(255) DEFAULT NULL,
			  `camera_Codes` varchar(255) DEFAULT NULL,
			  `camera_Ids` varchar(255) DEFAULT NULL,
			  `fire_Count` int(11) DEFAULT NULL,
			  `confirm` varchar(255) DEFAULT NULL,
			  `create_date` datetime DEFAULT NULL,
			  `create_user` varchar(50) DEFAULT NULL,
			  `update_date` datetime DEFAULT NULL,
			  `update_user` varchar(50) DEFAULT NULL,
			  `is_delete` bit(1) DEFAULT NULL,
			  `batch_No` varchar(36) NOT NULL,
			  `picture1` varchar(255) DEFAULT NULL,
			  `picture2` varchar(255) DEFAULT NULL,
			  `picture4` varchar(255) DEFAULT NULL,
			  `picture3` varchar(255) DEFAULT NULL,
			  `fire_Truck_Route` varchar(2000) DEFAULT NULL,
			  `runstep` bit(1) DEFAULT NULL,
			  `step_state` varchar(255) DEFAULT NULL,
			  `step` varchar(255) DEFAULT NULL,
			  `equipment_position3d` varchar(255) DEFAULT NULL,
			  PRIMARY KEY (`id`),
			  UNIQUE KEY `INDEX_BATCH_NO` (`batch_No`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义';
		</sql>
    </changeSet>

    <changeSet author="shanqiyun" id="1593309428780-2">
		<preConditions onFail="MARK_RAN">
			<not>
				<tableExists tableName="contingency_plan" />
			</not>
		</preConditions>
		<comment>create table contingency_plan</comment>
		<sql>
			DROP TABLE IF EXISTS contingency_plan;
			CREATE TABLE `contingency_plan` (
			  `id` varchar(36) NOT NULL COMMENT 'rule',
			  `record_type` varchar(32) NOT NULL COMMENT '记录类型：消息MESSAGE，操作OPERATE',
			  `content` varchar(500) NOT NULL COMMENT '记录内容：文本信息或者json数据',
			  `category` varchar(36) NOT NULL COMMENT '一级分类',
			  `sub_category` varchar(36) NOT NULL COMMENT '二级分类',
			  `icon` varchar(255) DEFAULT NULL COMMENT '图标,url，或者文件名',
			  `sort` int(11) NOT NULL COMMENT '排序',
			  PRIMARY KEY (`id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案信息节点定义';
		</sql>
    </changeSet>

    <changeSet author="shanqiyun" id="1593309428780-3">
		<preConditions onFail="MARK_RAN">
			<not>
				<tableExists tableName="contingency_plan_instance" />
			</not>
		</preConditions>
		<comment>create table contingency_plan_instance</comment>
		<sql>
			DROP TABLE IF EXISTS contingency_plan_instance;
			CREATE TABLE `contingency_plan_instance` (
			  `id` varchar(36) NOT NULL COMMENT 'rule',
			  `record_type` varchar(32) NOT NULL COMMENT '记录类型：消息MESSAGE，操作OPERATE',
			  `category` varchar(36) DEFAULT NULL COMMENT '一级分类',
			  `content` varchar(2000) NOT NULL COMMENT '记录内容：文本信息或者json数据',
			  `icon` varchar(255) DEFAULT NULL COMMENT '图标,url，或者文件名',
			  `sort` int(11) DEFAULT NULL COMMENT '所有节点一起的排序号',
			  `sequence_num` int(11) DEFAULT NULL COMMENT '用于显示的序号',
			  `batch_no` varchar(36) NOT NULL COMMENT '预案实例编号,暂时无法区分多个火灾，暂时存储报警设备id',
			  `create_date` datetime DEFAULT NULL,
			  `create_user` varchar(50) DEFAULT NULL,
			  `update_date` datetime DEFAULT NULL,
			  `update_user` varchar(50) DEFAULT NULL,
			  `is_delete` bit(1) DEFAULT NULL,
			  `tips` varchar(255) DEFAULT NULL,
			  `runstate` bit(1) DEFAULT NULL,
			  PRIMARY KEY (`id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='应急预案执行记录实例';
		</sql>
    </changeSet>

    <changeSet author="keyong" id="1605924681-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="station_charge_user_name" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `station_charge_user_name` varchar(20) NULL COMMENT '换流站负责人姓名';
        </sql>
    </changeSet>

    <changeSet author="keyong" id="1605924681-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="safety_charge_user_name" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `safety_charge_user_name` varchar(20) NULL COMMENT '安全负责人姓名';
        </sql>
    </changeSet>

    <changeSet author="keyong" id="1605924681-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="create_user_name" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `create_user_name` varchar(20) NULL COMMENT '创建人姓名';
        </sql>
    </changeSet>

    <changeSet author="keyong" id="1606290088-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="create_user_phone_num" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `create_user_phone_num` varchar(20) NULL COMMENT '创建人联系方式';
        </sql>
    </changeSet>

    <changeSet author="keyong" id="1606290088-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="station_user_phone_num" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `station_user_phone_num` varchar(20) NULL COMMENT '换流站负责人联系方式';
        </sql>
    </changeSet>

    <changeSet author="keyong" id="1606290088-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="safety_user_phone_num" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `safety_user_phone_num` varchar(20) NULL COMMENT '安全负责人联系方式';
        </sql>
    </changeSet>
    <changeSet author="keyong" id="1608279637-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="fire_captain_name" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_name` varchar(20) NULL COMMENT '驻站消防队队长姓名';
        </sql>
    </changeSet>
    <changeSet author="keyong" id="1608279637-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="fire_captain_phone_num" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_phone_num` varchar(20) NULL COMMENT '驻站消防队队长电话';
        </sql>
    </changeSet>
    <changeSet author="keyong" id="1608279637-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_station_info" columnName="fire_captain_user_id" />
            </not>
        </preConditions>
        <comment>修改f_station_info表结构</comment>
        <sql>
            ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长';
        </sql>
    </changeSet>
    <changeSet author="shg" id="1609226808866-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_risk_source" columnName="source_id"/>
            </not>
        </preConditions>
        <comment>f_risk_source add column source_id</comment>
        <sql>
            alter table `f_risk_source` add column `source_id` bigint(20) DEFAULT NULL AFTER `status`;
        </sql>
    </changeSet>
    <changeSet author="shg" id="1609226808866-2">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="f_risk_source" columnName="source_id"/>
        </preConditions>
        <comment>f_risk_source add UNIQUE source_id</comment>
        <sql>
            ALTER TABLE `f_risk_source` ADD UNIQUE unique_idx_source_id(source_id);
             </sql>
    </changeSet>
    <changeSet author="gaojianqiang" id="1609989898-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="f_equipment" columnName="status" />
            </not>
        </preConditions>
        <comment>修改f_equipment表结构</comment>
        <sql>
            ALTER TABLE `f_equipment` ADD COLUMN `status` tinyint(4) NULL DEFAULT 0 COMMENT '预案状态：1-启动，0-未启动';
            ALTER TABLE `f_equipment` ADD COLUMN `start_time` datetime(0) NULL DEFAULT NULL COMMENT '预案开始时间';
            ALTER TABLE `f_equipment` ADD COLUMN `end_time` datetime(0) NULL DEFAULT NULL COMMENT '预案结束时间';
            ALTER TABLE `f_equipment` ADD COLUMN `reserve_source` tinyint(4) NULL DEFAULT 0 COMMENT '预案来源：1-手动触发，0-自动触发（默认）';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_classify_tree" />
            </not>
        </preConditions>
        <comment>create table c_plan_classify_tree</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_classify_tree;
            CREATE TABLE `c_plan_classify_tree` (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
            `classify_name` varchar(255) DEFAULT NULL COMMENT '预案分类名称',
            `parent_id` bigint(20) DEFAULT NULL COMMENT '父类id',
            `create_date` datetime DEFAULT NULL COMMENT '创建时间',
            `creator` varchar(255) DEFAULT NULL COMMENT '创建人',
            `org_code` varchar(255) DEFAULT NULL COMMENT '组织机构',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='预案分类树';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_detail" />
            </not>
        </preConditions>
        <comment>create table c_plan_detail</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_detail;
            CREATE TABLE `c_plan_detail` (
            `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '数字预案ID',
            `plan_name` varchar(255) DEFAULT NULL COMMENT '预案名称',
            `code` varchar(255) DEFAULT NULL COMMENT '预案编号',
            `classify_id` bigint(20) DEFAULT NULL COMMENT '预案类型',
            `plan_range` varchar(255) DEFAULT NULL COMMENT '适用范围',
            `edit_org_name` varchar(255) DEFAULT NULL COMMENT '编写部门',
            `edition` varchar(255) DEFAULT NULL COMMENT '版次',
            `implementation_time` datetime DEFAULT NULL COMMENT '实施时间',
            `create_date` datetime NOT NULL COMMENT '录入时间',
            `remark` text COMMENT '备注',
            `status` int(255) DEFAULT NULL COMMENT '预案状态',
            `creator` varchar(255) DEFAULT NULL COMMENT '创建人',
            `reviser` varchar(255) DEFAULT NULL COMMENT '修改人',
            `update_time` datetime DEFAULT NULL COMMENT '修改时间',
            `org_code` varchar(255) DEFAULT NULL COMMENT '部门code',
            `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除状态（0、正常，1、删除）',
            `input_time` datetime DEFAULT NULL COMMENT '录入时间',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='预案详情表';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_doc" />
            </not>
        </preConditions>
        <comment>create table c_plan_doc</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_doc;
            CREATE TABLE `c_plan_doc` (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
            `plan_id` bigint(20) DEFAULT NULL COMMENT '预案ID',
            `doc_id` bigint(20) DEFAULT NULL COMMENT '文档ID',
            `create_date` datetime NOT NULL COMMENT '创建时间',
            `is_delete` tinyint(1) DEFAULT NULL COMMENT '删除状态',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COMMENT='预案文档关系表';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-4">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_equipment" />
            </not>
        </preConditions>
        <comment>create table c_plan_equipment</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_equipment;
            CREATE TABLE `c_plan_equipment` (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
            `plan_id` bigint(20) DEFAULT NULL COMMENT '预案ID',
            `fire_equipment_id` bigint(20) DEFAULT NULL COMMENT '电力装备ID',
            `create_date` datetime NOT NULL COMMENT '创建时间',
            `is_delete` tinyint(1) DEFAULT NULL COMMENT '删除状态',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COMMENT='预案电力设备关系表';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-5">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_operation_record" />
            </not>
        </preConditions>
        <comment>create table c_plan_operation_record</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_operation_record;
            CREATE TABLE `c_plan_operation_record` (
            `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
            `plan_id` bigint(20) DEFAULT NULL COMMENT '预案ID',
            `plan_pattern` tinyint(4) DEFAULT NULL COMMENT '运行模式（4、模拟，5、自动）',
            `status` tinyint(4) DEFAULT NULL COMMENT '运行状态（0、运行中，1、完毕，3、中断）',
            `execution_type` tinyint(4) DEFAULT NULL COMMENT '执行方式（0、预案验证 1、火灾处置）',
            `start_time` datetime DEFAULT NULL COMMENT '开始时间',
            `end_time` datetime DEFAULT NULL COMMENT '结束时间',
            `create_date` datetime DEFAULT NULL COMMENT '创建时间',
            `batch_no` varchar(255) DEFAULT NULL COMMENT '批次号',
            `is_delete` tinyint(1) DEFAULT NULL COMMENT '是否删除',
            `start_user_name` varchar(255) DEFAULT NULL COMMENT '启动人名称',
            `start_user_id` varchar(255) DEFAULT NULL COMMENT '启动人id',
            `equipment_code` varchar(20) DEFAULT NULL COMMENT '装备code',
            `equipment_name` varchar(255) DEFAULT NULL COMMENT '装备名称',
            `equipment_id` bigint(11) DEFAULT NULL COMMENT '装备ID',
            `fire_equipment_id` bigint(255) DEFAULT NULL COMMENT '电力设备ID',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8mb4 COMMENT='预案运行记录表';
        </sql>
    </changeSet>
    <changeSet author="wujunkai" id="1612272587000-6">
        <preConditions onFail="MARK_RAN">
            <not>
                <tableExists tableName="c_plan_rule" />
            </not>
        </preConditions>
        <comment>create table c_plan_rule</comment>
        <sql>
            DROP TABLE IF EXISTS c_plan_rule;
            CREATE TABLE `c_plan_rule` (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
            `rule_id` varchar(32) DEFAULT NULL COMMENT '规则ID',
            `plan_id` bigint(20) DEFAULT NULL COMMENT '预案ID',
            `create_date` datetime DEFAULT NULL COMMENT '创建时间',
            `is_delete` tinyint(1) DEFAULT NULL COMMENT '是否删除',
            `rule_name` varchar(100) DEFAULT NULL COMMENT '规则名称',
            `pic_url` varchar(100) DEFAULT NULL COMMENT '规则树形图路径',
            PRIMARY KEY (`id`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4;
        </sql>
    </changeSet>
    <changeSet author="maoying" id="1612272587000-7">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="c_plan_operation_record" columnName="equipment_code" />
        </preConditions>
        <comment>c_plan_operation_record table equipment_code MODIFY</comment>
         <sql>
		    ALTER TABLE `c_plan_operation_record`
			MODIFY COLUMN `equipment_code`  varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '装备code' ;
   		</sql>
    </changeSet>
</databaseChangeLog>