✏️ 正在编辑: 240.sql
路径:
/srv/systems_dir/yuppiecred-bkp/data/database/240.sql
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Author: yuppie * Created: 22/11/2017 */ INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('CPF', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('RG[frente]', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('RG[verso]', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Contra cheque', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Ficha cadastral', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Benefício', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Comprovante de residência', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Termo de adesão', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Autorização saque', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Arrogo/Testemunha', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Capa do contrato', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Formulário digitalizado', 'ANEXO_CONTRATO', '0', '0', '0'); INSERT INTO `tb_tipos` (`descricao`, `tipo`, `bloquear`, `excluido`, `desativar_cliente_callcenter`) VALUES ('Outros documentos', 'ANEXO_CONTRATO', '0', '0', '0'); CREATE TABLE `tb_contratos_anexos` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `contrato_id` INT(11) NULL, `tipo_id` INT(11) NOT NULL, `descricao` VARCHAR(45) NOT NULL, `arquivo` VARCHAR(255) NOT NULL, `excluido` TINYINT(2) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_cpf' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "CPF") AS `tipo_id`, `anexo_cpf` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_cpf` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_rg' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "RG[frente]") AS `tipo_id`, `anexo_rg` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_rg` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_contra_cheque' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Contra cheque") AS `tipo_id`, `anexo_contra_cheque` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_contra_cheque` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_ficha_cadastral' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Ficha cadastral") AS `tipo_id`, `anexo_ficha_cadastral` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_ficha_cadastral` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_beneficio' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Benefício") AS `tipo_id`, `anexo_beneficio` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_beneficio` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_comprovante_residencia' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Comprovante de residência") AS `tipo_id`, `anexo_comprovante_residencia` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_comprovante_residencia` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_termo_adesao' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Termo de adesão") AS `tipo_id`, `anexo_termo_adesao` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_termo_adesao` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_autorizacao_saque' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Autorização saque") AS `tipo_id`, `anexo_autorizacao_saque` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_autorizacao_saque` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_arrogo_testemunha' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Arrogo/Testemunha") AS `tipo_id`, `anexo_autorizacao_saque` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_autorizacao_saque` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_capa' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Capa do contrato") AS `tipo_id`, `anexo_capa` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_capa` IS NOT NULL; /* IMPORTACAO DE ANEXOS DO CAMPO 'anexo_formulario' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `arquivo`) SELECT `id` AS `contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Formulário digitalizado") AS `tipo_id`, `anexo_formulario` AS `arquivo` FROM `tb_contratos` WHERE `excluido` <> 1 AND `anexo_formulario` IS NOT NULL; /* IMPORTACAO DE ANEXOS DA TABELA 'tb_propostas_documentos' */ INSERT INTO `tb_contratos_anexos`(`contrato_id`, `tipo_id`, `descricao` , `arquivo`) SELECT `propostas_anexos`.`contrato_id`, (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Outros documentos") AS `tipo_id`, `propostas_anexos`.`descricao`, `propostas_anexos`.`anexo` AS `arquivo` FROM `tb_propostas_documentos` AS `propostas_anexos` INNER JOIN `tb_contratos` AS `contratos` ON `propostas_anexos`.`contrato_id` = `contratos`.`id` WHERE `propostas_anexos`.`excluido` <> 1 AND `contratos`.`excluido` <> 1; SET NAMES 'utf8'; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_beneficio SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Benefício") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_comprovante_residencia SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Comprovante de residência") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_termo_adesao SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Termo de adesão") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_autorizacao_saque SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Autorização saque") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_formulario SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Formulário digitalizado") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_rg SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "RG[frente]") WHERE tipo_id = 0; UPDATE tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id AND a.arquivo = c.anexo_contra_cheque SET tipo_id = (SELECT `id` FROM `tb_tipos` WHERE `tipo` = "ANEXO_CONTRATO" AND `descricao` = "Contra cheque") WHERE tipo_id = 0; SELECT a.contrato_id, a.tipo_id, a.arquivo FROM tb_contratos_anexos as a INNER JOIN tb_contratos as c ON c.id = a.contrato_id WHERE tipo_id = 0;
💾 保存文件
← 返回文件管理器