-- 安灯消息通知脚本
-- 字典
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, is_deleted) VALUES (1604714362783469569, 1526794939694256129, 'notify-business-key', 'andon-call', '安灯呼叫', 1, '', 0, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, is_deleted) VALUES (1604714889718075394, 1604714362783469569, 'notify-business-key', 'andon-take-over', '发起安灯呼叫', 0, '', 0, 0);
-- 消息通知
INSERT INTO blade_business_notify (id, business_name, business_key, notify_type, notify_id, notify_template_id, create_user, create_dept, create_time, update_user, update_time, status, tenant_id, is_deleted) VALUES (1604721601443336194, '发起安灯呼叫', 'andon-take-over', 'dingTalk', '1001', '1604721601422364674', 1123598821738675201, 1123598813738675201, '2022-12-19 14:13:39', 1123598821738675201, '2022-12-20 13:50:21', 1, '000000', 0);
INSERT INTO blade_business_notify (id, business_name, business_key, notify_type, notify_id, notify_template_id, create_user, create_dept, create_time, update_user, update_time, status, tenant_id, is_deleted) VALUES (1604722688263000066, '发起安灯呼叫', 'andon-take-over', 'weiXinQY', '1002', '1604722688250417153', 1123598821738675201, 1123598813738675201, '2022-12-19 14:17:58', 1123598821738675201, '2022-12-20 13:50:22', 1, '000000', 0);
INSERT INTO blade_business_notify (id, business_name, business_key, notify_type, notify_id, notify_template_id, create_user, create_dept, create_time, update_user, update_time, status, tenant_id, is_deleted) VALUES (1604723433200750593, '发起安灯呼叫', 'andon-take-over', 'internalMessage', '1', '1604723433183973378', 1123598821738675201, 1123598813738675201, '2022-12-19 14:20:55', 1123598821738675201, '2022-12-19 14:20:55', 1, '000000', 0);
INSERT INTO blade_business_notify (id, business_name, business_key, notify_type, notify_id, notify_template_id, create_user, create_dept, create_time, update_user, update_time, status, tenant_id, is_deleted) VALUES (1604724291489566722, '发起安灯呼叫', 'andon-take-over', 'email', '1003', '1604724291476983810', 1123598821738675201, 1123598813738675201, '2022-12-19 14:24:20', 1123598821738675201, '2022-12-19 14:24:20', 1, '000000', 0);
-- 消息模板
INSERT INTO blade_notify_template (id, name, provider, type, business, template, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, tenant_id) VALUES ('1604721601422364674', '安灯呼叫', 'dingTalkMessage', 'dingTalk', 'andon-take-over', '{"agentId":"","title":"呼叫","message":"新的消息  \n  ***  \n  您有一条<font color=#509a9a>安灯呼叫</font>通知,请及时处理。  \n  <font color=#999999>工位</font>&emsp;&emsp;&emsp;**${#workstationName}**  \n  <font color=#999999>呼叫类型</font>&emsp;**${#typeName}**  \n  <font color=#999999>呼叫原因</font>&emsp;**${#reasons}**  \n  <font color=#999999>呼叫人员</font>&emsp;**${#callEmpName}**  \n  <font color=#999999>呼叫时间</font>&emsp;**${#callTime}**  \n  ***  \n  [<font color=#509a9a>立即查看</font>]()"}', 1123598821738675201, 1123598813738675201, '2022-12-19 14:13:39', 1123598821738675201, '2022-12-20 14:07:06', 1, 0, '000000');
INSERT INTO blade_notify_template (id, name, provider, type, business, template, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, tenant_id) VALUES ('1604722688250417153', '安灯呼叫', 'qyTextMessage', 'weiXinQY', 'andon-take-over', '{"content":"您有一条安灯呼叫通知,请及时处理。<br/>工位        ${#workstationName} <br/>呼叫类型 ${#typeName}<br/>呼叫原因 ${#reasons}<br/>呼叫人员 ${#callEmpName}<br/>呼叫时间 ${#callTime}"}', 1123598821738675201, 1123598813738675201, '2022-12-19 14:17:58', 1123598821738675201, '2022-12-20 11:27:18', 0, 0, '000000');
INSERT INTO blade_notify_template (id, name, provider, type, business, template, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, tenant_id) VALUES ('1604723433183973378', '安灯呼叫', 'systemDefault', 'internalMessage', 'andon-take-over', '{"subject":"安灯呼叫","content":"<p>尊敬的客户：</p><p>&nbsp; &nbsp;您有一条<font color=\"#8baa4a\">安灯呼叫</font>通知，请及时处理。</p><p>${#andonCallTable}</p>","attachments":[{"name":"","location":""}]}', 1123598821738675201, 1123598813738675201, '2022-12-19 14:20:55', 1123598821738675201, '2022-12-20 11:38:25', 1, 0, '000000');
INSERT INTO blade_notify_template (id, name, provider, type, business, template, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, tenant_id) VALUES ('1604724291476983810', '安灯呼叫', 'embedded', 'email', 'andon-take-over', '{"subject":"安灯呼叫","content":"<p>尊敬的客户：</p><p>&nbsp; &nbsp;您有一条<font color=\"#8baa4a\">安灯呼叫</font>通知，请及时处理。</p><p>${#andonCallTable}</p>","attachments":[{"name":"","location":""}]}', 1123598821738675201, 1123598813738675201, '2022-12-19 14:24:20', 1123598821738675201, '2022-12-20 11:38:28', 1, 0, '000000');

CREATE TABLE "blade_andon_reason"
(
    "id" BIGINT NOT NULL,
    "status" TINYINT,
    "is_deleted" INT DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "andon_type_id" BIGINT,
    "code" VARCHAR(200),
    "name" VARCHAR(200),
    "remark" VARCHAR(200),
    NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "blade_andon_reason" IS '安灯原因表';
COMMENT ON COLUMN "blade_andon_reason"."andon_type_id" IS '安灯类型id';
COMMENT ON COLUMN "blade_andon_reason"."code" IS '安灯原因编号';
COMMENT ON COLUMN "blade_andon_reason"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_andon_reason"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_andon_reason"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_andon_reason"."id" IS '主键';
COMMENT ON COLUMN "blade_andon_reason"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT ON COLUMN "blade_andon_reason"."name" IS '安灯原因名称';
COMMENT ON COLUMN "blade_andon_reason"."remark" IS '安灯原因备注';
COMMENT ON COLUMN "blade_andon_reason"."status" IS '状态';
COMMENT ON COLUMN "blade_andon_reason"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_andon_reason"."update_user" IS '更新人';


CREATE UNIQUE  INDEX "INDEX1444344908200" ON "blade_andon_reason"("id" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

CREATE TABLE "blade_andon_record_reason"
(
    "id" BIGINT NOT NULL,
    "status" TINYINT,
    "is_deleted" INT DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "record_id" BIGINT,
    "reason_id" BIGINT,
    "reason_code" VARCHAR(200),
    "reason_name" VARCHAR(200),
    NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "blade_andon_record_reason" IS '记录关联原因表';
COMMENT ON COLUMN "blade_andon_record_reason"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_andon_record_reason"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_andon_record_reason"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_andon_record_reason"."id" IS '主键';
COMMENT ON COLUMN "blade_andon_record_reason"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT ON COLUMN "blade_andon_record_reason"."reason_code" IS '安灯原因编号';
COMMENT ON COLUMN "blade_andon_record_reason"."reason_id" IS '安灯原因id';
COMMENT ON COLUMN "blade_andon_record_reason"."reason_name" IS '安灯原因名称';
COMMENT ON COLUMN "blade_andon_record_reason"."record_id" IS '安灯记录id';
COMMENT ON COLUMN "blade_andon_record_reason"."status" IS '状态';
COMMENT ON COLUMN "blade_andon_record_reason"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_andon_record_reason"."update_user" IS '更新人';


CREATE UNIQUE  INDEX "INDEX1444272853800" ON "blade_andon_record_reason"("id" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

CREATE TABLE "blade_andon_type"
(
    "id" BIGINT NOT NULL,
    "status" TINYINT,
    "is_deleted" INT DEFAULT 0,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "code" VARCHAR(64),
    "name" VARCHAR(64),
    "remark" VARCHAR(64),
    NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "blade_andon_type" IS '安灯类型表';
COMMENT ON COLUMN "blade_andon_type"."code" IS '安灯类型编号';
COMMENT ON COLUMN "blade_andon_type"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_andon_type"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_andon_type"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_andon_type"."id" IS '主键';
COMMENT ON COLUMN "blade_andon_type"."is_deleted" IS '删除状态：0-未删除，1-已删除';
COMMENT ON COLUMN "blade_andon_type"."name" IS '安灯类型名称';
COMMENT ON COLUMN "blade_andon_type"."remark" IS '安灯类型备注';
COMMENT ON COLUMN "blade_andon_type"."status" IS '状态';
COMMENT ON COLUMN "blade_andon_type"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_andon_type"."update_user" IS '更新人';


CREATE UNIQUE  INDEX "INDEX1444251465400" ON "blade_andon_type"("id" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

-- 安灯菜单
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1602111145162227714, 0, 'andon', '安灯呼叫', 'andon', '', 'iconfont saber-andenghujiao1', 13, 0, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1602111671861952513, 1602111145162227714, 'andon_type', '安灯类型及原因', 'andon_type', '/andon/type/index', '', 1, 1, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1602112490741088257, 1602111145162227714, 'andon_receive', '安灯接收', 'andon_receive', '/andon/receive/index', '', 2, 1, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1602113671727071233, 1602111145162227714, 'andon_record', '安灯确认记录', 'andon_record', '/andon/record/index', '', 4, 1, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1602864491879800833, 0, 'hmi_andon', '安灯呼叫', 'him_andon', '/andon', '', 3, 1, 0, 1, '', 0, 'HMI', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092010330398721, 1602111671861952513, 'andon_type_create', '安灯类型新建', 'andon_type_create', '', '', 1, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092147387670530, 1602111671861952513, 'andon_type_update', '安灯类型编辑', 'andon_type_update', '', '', 2, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092308927094786, 1602111671861952513, 'andon_type_delete', '安灯类型删除', 'andon_type_delete', '', '', 3, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092495254855681, 1602111671861952513, 'andon_reason_create', '安灯原因新建', 'andon_reason_create', '', '', 4, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092634002432001, 1602111671861952513, 'andon_reason_update', '安灯原因编辑', 'andon_reason_update', '', '', 5, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605092837174517761, 1602111671861952513, 'andon_reason_delete', '安灯原因删除', 'andon_reason_delete', '', '', 6, 2, 0, 1, '', 0, 'CPS', 1);
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted, belong_application, keep_alive) VALUES (1605100621270065153, 1602113671727071233, 'andon_record_export', '安灯记录导出', 'andon_record_export', '', '', 1, 2, 0, 1, '', 0, 'CPS', 1);

-- 安灯呼叫 权限
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398104164126722, 1605092010330398721, 'andon_type.save_andon_type', '新增安灯类型', '/blade-andon/andon-type', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201, '2022-12-21 11:01:50', 1123598821738675201, '2022-12-21 11:01:50', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398140197392386, 1605092147387670530, 'andon_type.update_andon_type', '修改安灯类型', '/blade-andon/andon-type', NULL, NULL, 'PUT', 1123598821738675201, 1123598813738675201, '2022-12-21 11:01:58', 1123598821738675201, '2022-12-21 11:01:58', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398195218272257, 1605092308927094786, 'andon_type.remove_andon_type', '删除安灯类型', '/blade-andon/andon-type', NULL, NULL, 'DELETE', 1123598821738675201, 1123598813738675201, '2022-12-21 11:02:11', 1123598821738675201, '2022-12-21 11:02:11', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398272020172801, 1605092495254855681, 'andon_reason.add_reason', '新增安灯呼叫原因', '/blade-andon/andon-reason/add', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201, '2022-12-21 11:02:30', 1123598821738675201, '2022-12-21 11:02:30', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398307009056770, 1605092634002432001, 'andon_reason.update_reason', '编辑安灯呼叫原因', '/blade-andon/andon-reason/update', NULL, NULL, 'PUT', 1123598821738675201, 1123598813738675201, '2022-12-21 11:02:38', 1123598821738675201, '2022-12-21 11:02:38', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605398401993265153, 1605092837174517761, 'andon_reason.remove_reason', '删除呼叫原因', '/blade-andon/andon-reason', NULL, NULL, 'DELETE', 1123598821738675201, 1123598813738675201, '2022-12-21 11:03:01', 1123598821738675201, '2022-12-21 11:03:01', 1, 0);
INSERT INTO blade_scope_api (id, menu_id, resource_code, scope_name, scope_path, scope_type, remark, http_method, create_user, create_dept, create_time, update_user, update_time, status, is_deleted) VALUES (1605401019445858306, 1605100621270065153, 'andon_record.export_record', '导出安灯呼叫确认记录', '/blade-andon/andon-record/export-record', NULL, NULL, 'POST', 1123598821738675201, 1123598813738675201, '2022-12-21 11:13:25', 1123598821738675201, '2022-12-21 11:13:25', 1, 0);

-- 安灯呼叫编码规则
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, is_deleted) VALUES (1603265689953021954, 1456091305266442242, 'code_rule_for_biz_objects', 'Andon', '安灯呼叫', 37, '', 0, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, is_deleted) VALUES (1603266236370169857, 1603265689953021954, 'code_rule_for_biz_objects', 'AndonType', '安灯类型', 0, '', 0, 0);
INSERT INTO blade_dict (id, parent_id, code, dict_key, dict_value, sort, remark, is_sealed, is_deleted) VALUES (1605083882327089153, 1603265689953021954, 'code_rule_for_biz_objects', 'AndonReson', '安灯原因', 0, '', 0, 0);
INSERT INTO blade_bas_coderule (id, name, remark, bill_form_id, system_default, auto_billno, repair_billno, const_length, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, rule_field_dict_key, preview) VALUES (1603267927865864194, '安灯类型', '安灯类型编码', 'AndonType', 1, 0, 0, NULL, 1123598821738675201, 1123598813738675201, '2022-12-15 13:57:16', 1123598821738675201, '2022-12-15 13:57:18', 1, 0, NULL, 'AD2022121501');
INSERT INTO blade_bas_coderule_entry (id, rule_id, seq, element_type, element_source, source_property, length, format, element_value, seed, increment_step, separator_char, re_char, add_char, cut_style, add_style, code_only_by, code_element) VALUES (1603267927891030018, 1603267927865864194, 1, 1, '', NULL, 2, '', 'AD', 1, 1, '', '', '', 1, 0, 0, 1);
INSERT INTO blade_bas_coderule_entry (id, rule_id, seq, element_type, element_source, source_property, length, format, element_value, seed, increment_step, separator_char, re_char, add_char, cut_style, add_style, code_only_by, code_element) VALUES (1603267927899418626, 1603267927865864194, 2, 2, 'create_time', NULL, 8, 'yyyyMMdd', '', 1, 1, '', '', '', 1, 0, 0, 1);
INSERT INTO blade_bas_coderule_entry (id, rule_id, seq, element_type, element_source, source_property, length, format, element_value, seed, increment_step, separator_char, re_char, add_char, cut_style, add_style, code_only_by, code_element) VALUES (1603267927899418627, 1603267927865864194, 3, 0, '', NULL, 2, '', '', 1, 1, '', '', '0', 1, 0, 0, 1);
INSERT INTO blade_bas_coderule (id, name, remark, bill_form_id, system_default, auto_billno, repair_billno, const_length, create_user, create_dept, create_time, update_user, update_time, status, is_deleted, rule_field_dict_key, preview) VALUES (1605085317328510978, '安灯原因编码', '安灯原因编码', 'AndonReson', 1, 0, 0, NULL, 1123598821738675201, 1123598813738675201, '2022-12-20 14:18:55', 1123598821738675201, '2022-12-20 14:19:04', 1, 0, NULL, '01');
INSERT INTO blade_bas_coderule_entry (id, rule_id, seq, element_type, element_source, source_property, length, format, element_value, seed, increment_step, separator_char, re_char, add_char, cut_style, add_style, code_only_by, code_element) VALUES (1605085317353676801, 1605085317328510978, 1, 5, 'andon_type_id', 1, 0, '', '', 1, 1, '', '', '', 1, 0, 0, 1);
INSERT INTO blade_bas_coderule_entry (id, rule_id, seq, element_type, element_source, source_property, length, format, element_value, seed, increment_step, separator_char, re_char, add_char, cut_style, add_style, code_only_by, code_element) VALUES (1605085317353676802, 1605085317328510978, 2, 0, '', NULL, 2, '', '', 1, 1, '', '', '0', 1, 0, 0, 1);
-- 安灯编码规则脚本
INSERT INTO blade_meta_ref_object_type (object_type_id, ref_object_type_id, field_name, id) VALUES ('AndonReson', 'AndonType', 'andon_type_id', 1605085049543172097);
INSERT INTO blade_meta_object_type_field (id, object_id, f_code, f_name, field, element_type, enum_type, seq) VALUES (1603266904938033153, 'AndonType', 'create_time', '创建时间', 'createTime', '2', NULL, 0);
INSERT INTO blade_meta_object_type_field (id, object_id, f_code, f_name, field, element_type, enum_type, seq) VALUES (1605085049522200577, 'AndonReson', 'andon_type_id', '安灯类型', 'andonTypeId', '5', NULL, 0);
INSERT INTO blade_meta_object_type (f_id, name, model_type_id, subsys_id, table_name, ref_code, ref_name, primary_key, rule_field, rule_dict_code, code) VALUES ('AndonReson', '安灯原因', NULL, 'Andon', 'blade_andon_reason', 'id', 'code', 'id', NULL, NULL, NULL);
INSERT INTO blade_meta_object_type (f_id, name, model_type_id, subsys_id, table_name, ref_code, ref_name, primary_key, rule_field, rule_dict_code, code) VALUES ('AndonType', '安灯类型', NULL, 'Andon', 'blade_andon_type', 'id', 'code', 'id', NULL, NULL, NULL);
