--
-- Set character set the client will use to send SQL statements to the server
--

--
-- Set default database
--
USE appros;

--
-- Create table `r67_tmp_import`
--
CREATE TABLE r67_tmp_import (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(10) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures_groupe varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  contexte_groupe varchar(255) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  idMotifReleve varchar(20) DEFAULT NULL,
  libelleMotifReleve varchar(255) DEFAULT NULL,
  grandeur_groupe varchar(10) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  calendrier_groupe varchar(10) DEFAULT NULL,
  libelleGrille varchar(50) DEFAULT NULL,
  libelleCalendrier varchar(50) DEFAULT NULL,
  classeTemporelle_groupe varchar(10) DEFAULT NULL,
  idClasseTemporelle varchar(20) DEFAULT NULL,
  libelleClasseTemporelle varchar(255) DEFAULT NULL,
  quantite_groupe varchar(10) DEFAULT NULL,
  dateCreation datetime DEFAULT NULL,
  dbtMesure datetime DEFAULT NULL,
  finMesure datetime DEFAULT NULL,
  quantite bigint DEFAULT NULL,
  libelleNature varchar(50) DEFAULT NULL,
  libelleStatut varchar(50) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE67 varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 216,
AVG_ROW_LENGTH = 303,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c67_tmp_import_CLE67` on table `r67_tmp_import`
--
ALTER TABLE r67_tmp_import
ADD INDEX IDX_c67_tmp_import_CLE67 (CLE67);

--
-- Create view `vue_sys_demande_r67_log`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_r67_log
AS
SELECT
  `r67_tmp_import`.`idDemande` AS `idDemande`,
  `r67_tmp_import`.`idPrm` AS `idPrm`,
  MAX(`r67_tmp_import`.`date_creation`) AS `date_creation`,
  MIN(`r67_tmp_import`.`dbtMesure`) AS `dateDebut`,
  MAX(`r67_tmp_import`.`finMesure`) AS `dateFin`,
  COUNT(`r67_tmp_import`.`idPrm`) AS `Nbre`
FROM `r67_tmp_import`
GROUP BY `r67_tmp_import`.`idDemande`,
         `r67_tmp_import`.`idPrm`;

--
-- Create table `c68_tmp_import`
--
CREATE TABLE c68_tmp_import (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  numeroNomVoie varchar(255) DEFAULT NULL,
  codePostal varchar(255) DEFAULT NULL,
  commune varchar(255) DEFAULT NULL,
  batiment varchar(255) DEFAULT NULL,
  escalierEtageAppartement varchar(255) DEFAULT NULL,
  lieuDit varchar(255) DEFAULT NULL,
  domaineTension varchar(255) DEFAULT NULL,
  prs_valeur int DEFAULT NULL,
  prs_unite varchar(10) DEFAULT NULL,
  phc_libelle varchar(255) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  gfc_code varchar(50) DEFAULT NULL,
  ps_unite varchar(20) DEFAULT NULL,
  ps_valeur int DEFAULT NULL,
  segment varchar(10) DEFAULT NULL,
  filiereProduction varchar(255) DEFAULT NULL,
  technologie varchar(255) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE68 varchar(255) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 8,
AVG_ROW_LENGTH = 212,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `vue_sys_demande_c68_log`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_c68_log
AS
SELECT
  `c68_tmp_import`.`idDemande` AS `idDemande`,
  `c68_tmp_import`.`idPrm` AS `idPrm`,
  MAX(`c68_tmp_import`.`date_creation`) AS `date_creation`,
  COUNT(`c68_tmp_import`.`idPrm`) AS `Nbre`
FROM `c68_tmp_import`
GROUP BY `c68_tmp_import`.`idDemande`,
         `c68_tmp_import`.`idPrm`;

--
-- Create table `tbl_gpt`
--
CREATE TABLE tbl_gpt (
  ID_GPT_mere int DEFAULT NULL,
  TYPE_GPT varchar(255) DEFAULT NULL,
  ID_GPT int UNSIGNED NOT NULL AUTO_INCREMENT,
  GPT varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT NULL,
  date_update datetime DEFAULT NULL,
  date_deleted datetime DEFAULT NULL,
  PRIMARY KEY (ID_GPT)
)
ENGINE = INNODB,
AUTO_INCREMENT = 151,
AVG_ROW_LENGTH = 330,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `GPT` on table `tbl_gpt`
--
ALTER TABLE tbl_gpt
ADD UNIQUE INDEX GPT (GPT);

--
-- Create table `tbl_gpt_societe_site`
--
CREATE TABLE tbl_gpt_societe_site (
  ID_SOCIETE int DEFAULT NULL,
  ID_SITE_PRM int UNSIGNED NOT NULL,
  ID_SITE int UNSIGNED NOT NULL AUTO_INCREMENT,
  site_NOM varchar(255) DEFAULT NULL,
  site_ADRESSE varchar(255) DEFAULT NULL,
  site_CP double DEFAULT NULL,
  site_VILLE varchar(255) DEFAULT NULL,
  site_COMMENTAIRE mediumtext DEFAULT NULL,
  date_add datetime DEFAULT NULL,
  date_update datetime DEFAULT NULL,
  date_delete datetime DEFAULT NULL,
  TYPE_ETABLISSEMENT varchar(255) DEFAULT NULL,
  SIRET varchar(255) DEFAULT NULL,
  PRIMARY KEY (ID_SITE)
)
ENGINE = INNODB,
AUTO_INCREMENT = 1513,
AVG_ROW_LENGTH = 178,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `site_NOM` on table `tbl_gpt_societe_site`
--
ALTER TABLE tbl_gpt_societe_site
ADD UNIQUE INDEX site_NOM (site_NOM);

--
-- Create table `tbl_gpt_societe`
--
CREATE TABLE tbl_gpt_societe (
  id_societe_migration int DEFAULT NULL,
  id_contact_PAY int DEFAULT NULL,
  id_contact_TECH int DEFAULT NULL,
  id_contact_SIGN int DEFAULT NULL,
  REF_TYPE varchar(255) DEFAULT NULL,
  REF_STATUT varchar(255) DEFAULT NULL,
  TYPE_ENERGIE varchar(255) DEFAULT NULL,
  TYPE_ETABLISSEMENT varchar(255) DEFAULT NULL,
  `FACTURATION_O/N` int DEFAULT NULL,
  ID_GPT int DEFAULT NULL,
  ID_SOCIETE_MERE int DEFAULT NULL,
  ID_SOCIETE int UNSIGNED NOT NULL AUTO_INCREMENT,
  SOCIETE varchar(255) DEFAULT NULL,
  SIREN varchar(255) DEFAULT NULL,
  SIRET varchar(255) DEFAULT NULL,
  pap_FORME_JURIDIQUE varchar(255) DEFAULT NULL,
  pap_RCS varchar(255) DEFAULT NULL,
  `pap_NAF-APE` varchar(255) DEFAULT NULL,
  pap_DATE_CREATION_ENTREPRISE varchar(255) DEFAULT NULL,
  `pap_OBJET _SOCIAL` varchar(255) DEFAULT NULL,
  pap_CAPITAL_SOCIAL varchar(255) DEFAULT NULL,
  pap_TVA_INTRA varchar(255) DEFAULT NULL,
  ADRESSE varchar(255) DEFAULT NULL,
  CP varchar(255) DEFAULT NULL,
  VILLE varchar(255) DEFAULT NULL,
  INSEE varchar(255) DEFAULT NULL,
  COMPTE_COMPTABLE varchar(255) DEFAULT NULL,
  RIB_etab varchar(255) DEFAULT NULL,
  RIB_guichet varchar(255) DEFAULT NULL,
  RIB_compte varchar(255) DEFAULT NULL,
  RIB_titulaire varchar(255) DEFAULT NULL,
  RIB_cle varchar(255) DEFAULT NULL,
  RIB_domiciliation varchar(255) DEFAULT NULL,
  RIB_IBAN varchar(255) DEFAULT NULL,
  RIB_BIC varchar(255) DEFAULT NULL,
  PAIEMENT_mode varchar(255) DEFAULT NULL,
  PAIEMENT_date int DEFAULT NULL,
  PAIEMENT_Nbre_Jour int DEFAULT NULL,
  PAIEMENT_Remarque varchar(200) DEFAULT NULL,
  PAIEMENT_CODE_CONDITION varchar(255) DEFAULT NULL,
  _ID_PRM_tmp varchar(255) DEFAULT NULL,
  date_update datetime DEFAULT NULL,
  date_add datetime DEFAULT NULL,
  date_delete datetime DEFAULT NULL,
  MENTION_LEGALES text DEFAULT NULL,
  CHEMIN_JSON varchar(255) DEFAULT NULL,
  PRIMARY KEY (ID_SOCIETE)
)
ENGINE = INNODB,
AUTO_INCREMENT = 329,
AVG_ROW_LENGTH = 376,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_tbl_gpt_societe_ID_GPT` on table `tbl_gpt_societe`
--
ALTER TABLE tbl_gpt_societe
ADD INDEX IDX_tbl_gpt_societe_ID_GPT (ID_GPT);

--
-- Create index `SIREN` on table `tbl_gpt_societe`
--
ALTER TABLE tbl_gpt_societe
ADD UNIQUE INDEX SIREN (SIREN);

--
-- Create view `vue_source_societe_recherche`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_source_societe_recherche
AS
SELECT
  `tbl_gpt_societe`.`ID_SOCIETE` AS `ID_SOCIETE`,
  `tbl_gpt`.`GPT` AS `GPT`,
  `tbl_gpt_societe`.`SOCIETE` AS `SOCIETE`,
  `tbl_gpt_societe`.`SIREN` AS `SIREN`,
  `tbl_gpt_societe_site`.`site_NOM` AS `site_NOM`
FROM ((`tbl_gpt_societe`
  LEFT JOIN `tbl_gpt_societe_site`
    ON ((`tbl_gpt_societe`.`ID_SOCIETE` = `tbl_gpt_societe_site`.`ID_SOCIETE`)))
  LEFT JOIN `tbl_gpt`
    ON ((`tbl_gpt_societe`.`ID_GPT` = `tbl_gpt`.`ID_GPT`)))
ORDER BY `tbl_gpt_societe`.`SOCIETE`;

--
-- Create view `vue_source_societe_light_recherche`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_source_societe_light_recherche
AS
SELECT
  `tbl_gpt_societe`.`ID_SOCIETE` AS `ID_SOCIETE`,
  `tbl_gpt`.`GPT` AS `GPT`,
  `tbl_gpt_societe`.`SOCIETE` AS `SOCIETE`,
  `tbl_gpt_societe`.`SIREN` AS `SIREN`,
  `tbl_gpt_societe`.`pap_NAF-APE` AS `pap_NAF-APE`
FROM (`tbl_gpt_societe`
  LEFT JOIN `tbl_gpt`
    ON ((`tbl_gpt_societe`.`ID_GPT` = `tbl_gpt`.`ID_GPT`)))
ORDER BY `tbl_gpt_societe`.`SOCIETE`;

--
-- Create view `vue_source_site_recherche`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_source_site_recherche
AS
SELECT
  `tbl_gpt_societe`.`ID_SOCIETE` AS `ID_SOCIETE`,
  `tbl_gpt`.`GPT` AS `GPT`,
  `tbl_gpt_societe`.`SOCIETE` AS `SOCIETE`,
  `tbl_gpt_societe`.`SIREN` AS `SIREN`,
  `tbl_gpt_societe_site`.`site_NOM` AS `site_NOM`
FROM ((`tbl_gpt_societe`
  LEFT JOIN `tbl_gpt_societe_site`
    ON ((`tbl_gpt_societe`.`ID_SOCIETE` = `tbl_gpt_societe_site`.`ID_SOCIETE`)))
  LEFT JOIN `tbl_gpt`
    ON ((`tbl_gpt_societe`.`ID_GPT` = `tbl_gpt`.`ID_GPT`)))
ORDER BY `tbl_gpt_societe`.`SOCIETE`;

--
-- Create table `param_query`
--
CREATE TABLE param_query (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  vDATEDEB date DEFAULT NULL,
  vDATEFIN date DEFAULT NULL,
  vIDPRM varchar(255) DEFAULT NULL,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `r63_import_test_rafa_p60`
--
CREATE TABLE r63_import_test_rafa_p60 (
  idPrm varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  `An-Mois` varchar(255) DEFAULT NULL,
  Mois int DEFAULT NULL,
  Dates datetime DEFAULT NULL,
  Heures datetime DEFAULT NULL,
  Heures_INT int DEFAULT NULL,
  CT varchar(20) DEFAULT NULL,
  REACTIF varchar(255) DEFAULT NULL,
  ACTIF varchar(255) DEFAULT NULL,
  SAISON varchar(255) DEFAULT NULL,
  FERIE varchar(255) DEFAULT NULL,
  JOURS varchar(255) DEFAULT NULL,
  DIMANCHE varchar(255) DEFAULT NULL,
  HP_infos varchar(255) DEFAULT NULL,
  HC_infos varchar(255) DEFAULT NULL,
  PTE_infos varchar(255) DEFAULT NULL,
  PTE varchar(255) DEFAULT NULL,
  HPH varchar(255) DEFAULT NULL,
  HCH varchar(255) DEFAULT NULL,
  HPE varchar(255) DEFAULT NULL,
  HCE varchar(255) DEFAULT NULL,
  PTE_int varchar(255) DEFAULT NULL,
  HPH_int varchar(255) DEFAULT NULL,
  HCH_int varchar(255) DEFAULT NULL,
  HPE_int varchar(255) DEFAULT NULL,
  HCE_int varchar(255) DEFAULT NULL,
  PTE_EA varchar(255) DEFAULT NULL,
  HPH_EA varchar(255) DEFAULT NULL,
  HCH_EA varchar(255) DEFAULT NULL,
  HPE_EA varchar(255) DEFAULT NULL,
  HCE_EA varchar(255) DEFAULT NULL,
  PTE_ER varchar(255) DEFAULT NULL,
  HPH_ER varchar(255) DEFAULT NULL,
  HCH_ER varchar(255) DEFAULT NULL,
  HPE_ER varchar(255) DEFAULT NULL,
  HCE_ER varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 131398,
AVG_ROW_LENGTH = 337,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `vue_r67_an_mois_rafa`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_r67_an_mois_rafa
AS
SELECT
  `r63_import_test_rafa_p60`.`idPrm` AS `idPrm`,
  YEAR(`r63_import_test_rafa_p60`.`Dates`) AS `AN`,
  MONTH(`r63_import_test_rafa_p60`.`Dates`) AS `MOIS`,
  `r63_import_test_rafa_p60`.`CT` AS `CT`,
  SUM(`r63_import_test_rafa_p60`.`REACTIF`) AS `TOTAL_reactif`,
  SUM(`r63_import_test_rafa_p60`.`ACTIF`) AS `TOTAL_actif`
FROM `r63_import_test_rafa_p60`
GROUP BY `r63_import_test_rafa_p60`.`idPrm`,
         YEAR(`r63_import_test_rafa_p60`.`Dates`),
         MONTH(`r63_import_test_rafa_p60`.`Dates`),
         `r63_import_test_rafa_p60`.`CT`
ORDER BY YEAR(`r63_import_test_rafa_p60`.`Dates`), MONTH(`r63_import_test_rafa_p60`.`Dates`);

--
-- Create table `param_changements_heure`
--
CREATE TABLE param_changements_heure (
  annee int NOT NULL,
  heure_ete datetime DEFAULT NULL,
  heure_ete_reboot datetime DEFAULT NULL,
  heure_hiver datetime DEFAULT NULL,
  heure_hiver_reboot datetime DEFAULT NULL,
  PRIMARY KEY (annee)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `r63_tmp_import`
--
CREATE TABLE r63_tmp_import (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE63 varchar(255) NOT NULL,
  CLE63_indice varchar(2) DEFAULT NULL,
  nom_fic varchar(255) DEFAULT NULL,
  num_demande varchar(255) DEFAULT NULL,
  PRIMARY KEY (id, CLE63)
)
ENGINE = INNODB,
AUTO_INCREMENT = 320020,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_tmp_import_CLE63` on table `r63_tmp_import`
--
ALTER TABLE r63_tmp_import
ADD INDEX IDX_c63_tmp_import_CLE63 (CLE63);

--
-- Create view `vue_sys_demande_r63_log`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_r63_log
AS
SELECT
  `r63_tmp_import`.`idDemande` AS `idDemande`,
  `r63_tmp_import`.`idPrm` AS `idPrm`,
  MAX(`r63_tmp_import`.`date_creation`) AS `date_creation`,
  MIN(`r63_tmp_import`.`d`) AS `dateDebut`,
  MAX(`r63_tmp_import`.`d`) AS `dateFin`,
  COUNT(`r63_tmp_import`.`idPrm`) AS `Nbre`
FROM `r63_tmp_import`
GROUP BY `r63_tmp_import`.`idDemande`,
         `r63_tmp_import`.`idPrm`;

--
-- Create view `vue_r63_heure_hiver`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_r63_heure_hiver
AS
SELECT
  `r63_tmp_import`.`id` AS `id`,
  `r63_tmp_import`.`idPrm` AS `idPrm`,
  `r63_tmp_import`.`d` AS `d`,
  `param_changements_heure`.`heure_ete` AS `heure_ete`,
  `param_changements_heure`.`heure_hiver` AS `heure_hiver`,
  `r63_tmp_import`.`CLE63` AS `CLE63`,
  `r63_tmp_import`.`v` AS `v`
FROM (`r63_tmp_import`
  JOIN `param_changements_heure`
    ON (((`r63_tmp_import`.`d` <= `param_changements_heure`.`heure_hiver`)
    AND (`r63_tmp_import`.`d` > `param_changements_heure`.`heure_hiver_reboot`))))
ORDER BY `r63_tmp_import`.`idPrm`;

--
-- Create table `r63_archives`
--
CREATE TABLE r63_archives (
  id int UNSIGNED NOT NULL,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE63 varchar(255) NOT NULL,
  CLE63_indice varchar(255) DEFAULT NULL,
  PRIMARY KEY (CLE63)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_CLE63` on table `r63_archives`
--
ALTER TABLE r63_archives
ADD INDEX IDX_c63_CLE63 (CLE63);

--
-- Create index `IDX_c63_etapeMetier` on table `r63_archives`
--
ALTER TABLE r63_archives
ADD INDEX IDX_c63_etapeMetier (etapeMetier);

--
-- Create index `IDX_c63_idPrm` on table `r63_archives`
--
ALTER TABLE r63_archives
ADD INDEX IDX_c63_idPrm (idPrm, CLE63);

--
-- Create index `IDX_c63_tmp_idPrm` on table `r63_archives`
--
ALTER TABLE r63_archives
ADD INDEX IDX_c63_tmp_idPrm (idPrm);

--
-- Create view `vue_ctrl_prm_day_archives`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_ctrl_prm_day_archives
AS
SELECT
  `r63_archives`.`idPrm` AS `idPrm`,
  COUNT(`r63_archives`.`id`) AS `NBRE_MESURES`,
  `r63_archives`.`etapeMetier` AS `etapeMetier`,
  DAYOFMONTH(`r63_archives`.`d`) AS `JOUR`,
  MONTH(`r63_archives`.`d`) AS `MOIS`,
  YEAR(`r63_archives`.`d`) AS `AN`
FROM `r63_archives`
WHERE (`r63_archives`.`idPrm` = 30000741763749)
GROUP BY `r63_archives`.`idPrm`,
         DAYOFMONTH(`r63_archives`.`d`),
         MONTH(`r63_archives`.`d`),
         YEAR(`r63_archives`.`d`),
         `r63_archives`.`etapeMetier`;

--
-- Create table `calendar_dates`
--
CREATE TABLE calendar_dates (
  idPRM varchar(50) DEFAULT NULL,
  dbtMesure date DEFAULT NULL,
  MOIS int DEFAULT NULL,
  AN int DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 89,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `calendrier_mois`
--
CREATE TABLE calendrier_mois (
  DATE_JOUR_DEB int DEFAULT NULL,
  DATE_JOUR_FIN int DEFAULT NULL,
  SEGMENT varchar(255) DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  Mois double DEFAULT NULL,
  PTE_Etat varchar(255) DEFAULT NULL,
  HP_Type varchar(255) DEFAULT NULL,
  HC_Type varchar(255) DEFAULT NULL,
  CT_type varchar(1) DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 107,
AVG_ROW_LENGTH = 341,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `vue_calendrier_pte`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_calendrier_pte
AS
SELECT
  `calendrier_mois`.`ID` AS `ID`,
  `calendrier_mois`.`Mois` AS `Mois`,
  `calendrier_mois`.`PTE_Etat` AS `PTE_Etat`,
  `calendrier_mois`.`HP_Type` AS `HP_Type`,
  `calendrier_mois`.`HC_Type` AS `HC_Type`
FROM `calendrier_mois`
WHERE (`calendrier_mois`.`PTE_Etat` <> 'Pas_PTE');

--
-- Create table `r63_p05_mp`
--
CREATE TABLE r63_p05_mp (
  idPrm varchar(50) DEFAULT NULL,
  segment varchar(255) DEFAULT NULL,
  id_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  vDATE date DEFAULT NULL,
  vDATE_HEURE datetime DEFAULT NULL,
  vJOUR int DEFAULT NULL,
  vHEURE int DEFAULT NULL,
  vMINUTE int DEFAULT NULL,
  vVALEUR int DEFAULT NULL,
  CLE63PXX varchar(255) DEFAULT NULL,
  CT varchar(10) DEFAULT NULL,
  CT_type varchar(1) DEFAULT NULL,
  CT_origine varchar(255) DEFAULT NULL,
  PRIMARY KEY (id_ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 105121,
AVG_ROW_LENGTH = 85,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_p10_idPrm_MP2` on table `r63_p05_mp`
--
ALTER TABLE r63_p05_mp
ADD INDEX IDX_c63_p10_idPrm_MP2 (idPrm, vDATE, vHEURE);

--
-- Create index `IDX_r63_p05_vDATE_HEURE_MP2` on table `r63_p05_mp`
--
ALTER TABLE r63_p05_mp
ADD INDEX IDX_r63_p05_vDATE_HEURE_MP2 (vDATE_HEURE);

--
-- Create table `c68_compteurs`
--
CREATE TABLE c68_compteurs (
  id int NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  compteur_serie varchar(255) DEFAULT NULL,
  ct_1 varchar(255) DEFAULT NULL,
  ph_1 varchar(255) DEFAULT NULL,
  ct_2 varchar(255) DEFAULT NULL,
  ph_2 varchar(255) DEFAULT NULL,
  CLE68CO varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 35000,
AVG_ROW_LENGTH = 243,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `vue_c68_compteurs_distinct_unique`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_c68_compteurs_distinct_unique
AS
SELECT
  MAX(`c68_compteurs`.`id`) AS `MAXid`,
  `c68_compteurs`.`idPrm` AS `idPrm`
FROM `c68_compteurs`
GROUP BY `c68_compteurs`.`idPrm`;

--
-- Create view `test_c68_compteurs_50078665580693`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_c68_compteurs_50078665580693
AS
SELECT DISTINCT
  `c68_compteurs`.`id` AS `id`,
  `c68_compteurs`.`idPrm` AS `idPrm`,
  `c68_compteurs`.`compteur_serie` AS `compteur_serie`,
  `c68_compteurs`.`ct_1` AS `ct_1`,
  `c68_compteurs`.`ph_1` AS `ph_1`,
  `c68_compteurs`.`ct_2` AS `ct_2`,
  `c68_compteurs`.`ph_2` AS `ph_2`,
  `c68_compteurs`.`CLE68CO` AS `CLE68CO`
FROM `c68_compteurs`
WHERE (`c68_compteurs`.`idPrm` = '50078665580693');

--
-- Create table `c68_compteurs_col`
--
CREATE TABLE c68_compteurs_col (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  compteur_serie varchar(255) DEFAULT NULL,
  CLE68CO varchar(255) DEFAULT NULL,
  HEURE_deb int DEFAULT NULL,
  MIN_deb int DEFAULT NULL,
  HEURE_fin int DEFAULT NULL,
  MIN_fin int DEFAULT NULL,
  CT_col varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 49,
AVG_ROW_LENGTH = 341,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `vue_c68_compteurs_col_pte`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_c68_compteurs_col_pte
AS
SELECT
  `c68_compteurs_col`.`id` AS `id`,
  `c68_compteurs_col`.`idPrm` AS `idPrm`,
  `c68_compteurs_col`.`compteur_serie` AS `compteur_serie`,
  `c68_compteurs_col`.`CLE68CO` AS `CLE68CO`,
  `c68_compteurs_col`.`HEURE_deb` AS `HEURE_deb`,
  `c68_compteurs_col`.`HEURE_fin` AS `HEURE_fin`,
  `c68_compteurs_col`.`MIN_deb` AS `MIN_deb`,
  `c68_compteurs_col`.`MIN_fin` AS `MIN_fin`,
  `c68_compteurs_col`.`CT_col` AS `CT_col`
FROM `c68_compteurs_col`
WHERE ((`c68_compteurs_col`.`CT_col` = 'PTE')
OR (`c68_compteurs_col`.`CT_col` = 'P'));

--
-- Create table `r63_p05`
--
CREATE TABLE r63_p05 (
  idPrm varchar(50) DEFAULT NULL,
  segment varchar(255) DEFAULT NULL,
  id_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  vDATE date DEFAULT NULL,
  vDATE_HEURE datetime DEFAULT NULL,
  vJOUR int DEFAULT NULL,
  vHEURE int DEFAULT NULL,
  vMINUTE int DEFAULT NULL,
  vVALEUR int DEFAULT NULL,
  vP05 int DEFAULT NULL,
  vP10 int DEFAULT NULL,
  vP15 int DEFAULT NULL,
  vP30 int DEFAULT NULL,
  vP60 int DEFAULT NULL,
  MOY int DEFAULT NULL,
  CLE63PXX varchar(255) NOT NULL,
  CT varchar(10) DEFAULT NULL,
  CT_type varchar(1) DEFAULT NULL,
  CT_origine varchar(255) DEFAULT NULL,
  grandeurMetier varchar(255) DEFAULT NULL,
  etapeMetier varchar(255) DEFAULT NULL,
  PRIMARY KEY (id_ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 16241824,
AVG_ROW_LENGTH = 85,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_p10_idPrm` on table `r63_p05`
--
ALTER TABLE r63_p05
ADD INDEX IDX_c63_p10_idPrm (idPrm, vDATE, vHEURE);

--
-- Create index `IDX_r63_p05_vDATE_HEURE` on table `r63_p05`
--
ALTER TABLE r63_p05
ADD INDEX IDX_r63_p05_vDATE_HEURE (vDATE_HEURE);

--
-- Create view `vue_r63_p05_crosstab`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_r63_p05_crosstab
AS
SELECT
  `r63_p05`.`idPrm` AS `idPrm`,
  `r63_p05`.`vAN` AS `vAN`,
  `r63_p05`.`vMOIS` AS `vMOIS`,
  `r63_p05`.`vDATE` AS `vDATE`,
  `r63_p05`.`vHEURE` AS `vHeure`,
  `r63_p05`.`vMINUTE` AS `vMinute`,
  SUM((CASE WHEN (`r63_p05`.`CT` = 'PTE') THEN (`r63_p05`.`vP05` / 1000) ELSE 0 END)) AS `PTE`,
  SUM((CASE WHEN (`r63_p05`.`CT` = 'HPH') THEN (`r63_p05`.`vP05` / 1000) ELSE 0 END)) AS `HPH`,
  SUM((CASE WHEN (`r63_p05`.`CT` = 'HCH') THEN (`r63_p05`.`vP05` / 1000) ELSE 0 END)) AS `HCH`,
  SUM((CASE WHEN (`r63_p05`.`CT` = 'HPE') THEN (`r63_p05`.`vP05` / 1000) ELSE 0 END)) AS `HPE`,
  SUM((CASE WHEN (`r63_p05`.`CT` = 'HCE') THEN (`r63_p05`.`vP05` / 1000) ELSE 0 END)) AS `HCE`
FROM `r63_p05`
GROUP BY `r63_p05`.`idPrm`,
         `r63_p05`.`vHEURE`,
         `r63_p05`.`vMINUTE`,
         `r63_p05`.`vDATE`,
         `r63_p05`.`vMOIS`,
         `r63_p05`.`vAN`;

--
-- Create view `vue_calendrier_mois_pte`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_calendrier_mois_pte
AS
SELECT
  `r63_p05`.`idPrm` AS `idPrm`,
  `c68_compteurs_col`.`CT_col` AS `CT_col`,
  `calendrier_mois`.`PTE_Etat` AS `PTE_Etat`,
  `calendrier_mois`.`HP_Type` AS `HP_Type`,
  `calendrier_mois`.`HC_Type` AS `HC_Type`,
  (CASE WHEN (`calendrier_mois`.`PTE_Etat` = 'Pas_PTE') THEN `calendrier_mois`.`HP_Type` ELSE `calendrier_mois`.`PTE_Etat` END) AS `VRESULT_CT`
FROM ((`r63_p05`
  JOIN `c68_compteurs_col`
    ON (((`r63_p05`.`vHEURE` <= `c68_compteurs_col`.`HEURE_fin`)
    AND (`r63_p05`.`vHEURE` >= `c68_compteurs_col`.`HEURE_deb`)
    AND (`r63_p05`.`vMINUTE` >= `c68_compteurs_col`.`MIN_deb`)
    AND (`r63_p05`.`vMINUTE` <= `c68_compteurs_col`.`MIN_fin`)
    AND (`r63_p05`.`idPrm` = `c68_compteurs_col`.`idPrm`))))
  JOIN `calendrier_mois`
    ON ((`r63_p05`.`vMOIS` = `calendrier_mois`.`Mois`)))
WHERE ((`r63_p05`.`CT` IS NULL)
AND ((`c68_compteurs_col`.`CT_col` = 'PTE')
OR (`c68_compteurs_col`.`CT_col` = 'P'))
AND (`r63_p05`.`idPrm` = '30000741763749'));

--
-- Create view `vue_calendrier_mois_p05`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_calendrier_mois_p05
AS
SELECT
  `r63_p05`.`idPrm` AS `idPrm`,
  `r63_p05`.`id_ligne` AS `id_ligne`,
  `r63_p05`.`vAN` AS `vAN`,
  `r63_p05`.`vMOIS` AS `vMOIS`,
  `r63_p05`.`vDATE` AS `vDATE`,
  `r63_p05`.`vDATE_HEURE` AS `vDATE_HEURE`,
  `r63_p05`.`vJOUR` AS `vJOUR`,
  `r63_p05`.`vHEURE` AS `vHEURE`,
  `r63_p05`.`vMINUTE` AS `vMINUTE`,
  `r63_p05`.`vVALEUR` AS `vVALEUR`,
  `r63_p05`.`vP05` AS `vP05`,
  `r63_p05`.`vP10` AS `vP10`,
  `r63_p05`.`vP30` AS `vP30`,
  `r63_p05`.`vP60` AS `vP60`,
  `r63_p05`.`MOY` AS `MOY`,
  `r63_p05`.`CLE63PXX` AS `CLE63PXX`,
  `r63_p05`.`CT` AS `CT`,
  `calendrier_mois`.`ID` AS `ID`,
  `calendrier_mois`.`Mois` AS `Mois`,
  `calendrier_mois`.`PTE_Etat` AS `PTE_Etat`,
  `calendrier_mois`.`HP_Type` AS `HP_Type`,
  `calendrier_mois`.`HC_Type` AS `HC_Type`,
  DAYOFWEEK(`r63_p05`.`vDATE`) AS `vDIMANCHE`
FROM (`r63_p05`
  JOIN `calendrier_mois`
    ON ((`r63_p05`.`vMOIS` = `calendrier_mois`.`Mois`)))
WHERE ((DAYOFWEEK(`r63_p05`.`vDATE`) = 1)
AND (`r63_p05`.`idPrm` = 30000741763749));

--
-- Create view `test_cdc_histo_ct_pte`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_cdc_histo_ct_pte
AS
SELECT DISTINCT
  `r63_p05`.`vDATE` AS `vDATE`,
  `c68_compteurs_col`.`CT_col` AS `CT_col`,
  `calendrier_mois`.`DATE_JOUR_DEB` AS `DATE_JOUR_DEB`,
  `calendrier_mois`.`DATE_JOUR_FIN` AS `DATE_JOUR_FIN`,
  `calendrier_mois`.`SEGMENT` AS `SEGMENT`,
  `calendrier_mois`.`ID` AS `ID`,
  `calendrier_mois`.`Mois` AS `Mois`,
  `calendrier_mois`.`PTE_Etat` AS `PTE_Etat`,
  `calendrier_mois`.`HP_Type` AS `HP_Type`,
  `calendrier_mois`.`HC_Type` AS `HC_Type`,
  `calendrier_mois`.`CT_type` AS `CT_type`,
  (CASE WHEN (`calendrier_mois`.`PTE_Etat` = 'Pas_PTE') THEN `calendrier_mois`.`HP_Type` ELSE `calendrier_mois`.`PTE_Etat` END) AS `CT_calculated`,
  'PTE' AS `CT_origine_calculated`
FROM ((`r63_p05`
  JOIN `c68_compteurs_col`
    ON (((`r63_p05`.`vHEURE` <= `c68_compteurs_col`.`HEURE_fin`)
    AND (`r63_p05`.`vHEURE` >= `c68_compteurs_col`.`HEURE_deb`)
    AND (`r63_p05`.`vMINUTE` >= `c68_compteurs_col`.`MIN_deb`)
    AND (`r63_p05`.`vMINUTE` <= `c68_compteurs_col`.`MIN_fin`)
    AND (`r63_p05`.`idPrm` = `c68_compteurs_col`.`idPrm`))))
  JOIN `calendrier_mois`
    ON (((`r63_p05`.`vMOIS` = `calendrier_mois`.`Mois`)
    AND (`r63_p05`.`vJOUR` >= `calendrier_mois`.`DATE_JOUR_DEB`)
    AND (`r63_p05`.`vJOUR` <= `calendrier_mois`.`DATE_JOUR_FIN`))))
WHERE ((`r63_p05`.`idPrm` = '30000741763749')
AND (`calendrier_mois`.`Mois` = 1)
AND (`calendrier_mois`.`SEGMENT` = 'C2')
AND ((`c68_compteurs_col`.`CT_col` = 'PTE')
OR (`c68_compteurs_col`.`CT_col` = 'P')));

--
-- Create view `test_cdc_histo_ct`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_cdc_histo_ct
AS
SELECT
  `r63_p05`.`vDATE` AS `PAM_vDATE`,
  `r63_p05_mp`.`vDATE` AS `vDATE`,
  `r63_p05`.`vMINUTE` AS `PAM_vMINUTE`,
  `r63_p05_mp`.`vMINUTE` AS `vMINUTE`,
  `r63_p05`.`CT` AS `PAM_CT`,
  `r63_p05_mp`.`CT` AS `CT`,
  `r63_p05`.`CT_type` AS `PAM_CT_type`,
  `r63_p05_mp`.`CT_type` AS `CT_type`,
  `r63_p05`.`CT_origine` AS `PAM_CT_origine`,
  `r63_p05_mp`.`CT_origine` AS `CT_origine`,
  `r63_p05`.`vP05` AS `PAM_valeur`,
  `r63_p05_mp`.`vVALEUR` AS `vVALEUR`,
  `r63_p05_mp`.`CLE63PXX` AS `CLE63PXX`,
  `r63_p05`.`idPrm` AS `idPrm`
FROM (`r63_p05`
  JOIN `r63_p05_mp`
    ON (((`r63_p05`.`CLE63PXX` = `r63_p05_mp`.`CLE63PXX`)
    AND (`r63_p05`.`CT` <> `r63_p05_mp`.`CT`))))
WHERE (`r63_p05`.`idPrm` = 30000741763749);

--
-- Create view `test_cdc_histo`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_cdc_histo
AS
SELECT
  `r63_p05`.`vDATE` AS `PAM_vDATE`,
  `r63_p05_mp`.`vDATE` AS `vDATE`,
  `r63_p05`.`vMINUTE` AS `PAM_vMINUTE`,
  `r63_p05_mp`.`vMINUTE` AS `vMINUTE`,
  `r63_p05`.`CT` AS `PAM_CT`,
  `r63_p05_mp`.`CT` AS `CT`,
  `r63_p05`.`CT_type` AS `PAM_CT_type`,
  `r63_p05_mp`.`CT_type` AS `CT_type`,
  `r63_p05`.`CT_origine` AS `PAM_CT_origine`,
  `r63_p05_mp`.`CT_origine` AS `CT_origine`,
  `r63_p05`.`vP05` AS `PAM_valeur`,
  `r63_p05_mp`.`vVALEUR` AS `vVALEUR`,
  `r63_p05_mp`.`CLE63PXX` AS `CLE63PXX`
FROM (`r63_p05`
  JOIN `r63_p05_mp`
    ON ((`r63_p05`.`CLE63PXX` = `r63_p05_mp`.`CLE63PXX`)));

--
-- Create view `dw_r63_an_mois_jour_from_p05`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r63_an_mois_jour_from_p05
AS
SELECT
  `r63_p05`.`idPrm` AS `idPrm`,
  `r63_p05`.`vAN` AS `AN`,
  `r63_p05`.`vMOIS` AS `MOIS`,
  `r63_p05`.`CT` AS `CT`,
  SUM((`r63_p05`.`vP05` / 1000)) AS `TOTAL`,
  `r63_p05`.`grandeurMetier` AS `grandeurMetier`,
  `r63_p05`.`etapeMetier` AS `etapeMetier`
FROM `r63_p05`
GROUP BY `r63_p05`.`idPrm`,
         `r63_p05`.`vAN`,
         `r63_p05`.`vMOIS`,
         `r63_p05`.`CT`,
         `r63_p05`.`grandeurMetier`,
         `r63_p05`.`etapeMetier`
ORDER BY `r63_p05`.`vAN`, `r63_p05`.`vMOIS`;

--
-- Create view `dw_r63_an_mois_from_p05`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r63_an_mois_from_p05
AS
SELECT
  `r63_p05`.`idPrm` AS `idPrm`,
  `r63_p05`.`vAN` AS `AN`,
  `r63_p05`.`vMOIS` AS `MOIS`,
  `r63_p05`.`CT` AS `CT`,
  SUM((`r63_p05`.`vP05` / 1000)) AS `TOTAL`,
  `r63_p05`.`grandeurMetier` AS `grandeurMetier`,
  `r63_p05`.`etapeMetier` AS `etapeMetier`
FROM `r63_p05`
GROUP BY `r63_p05`.`idPrm`,
         `r63_p05`.`vAN`,
         `r63_p05`.`vMOIS`,
         `r63_p05`.`CT`,
         `r63_p05`.`grandeurMetier`,
         `r63_p05`.`etapeMetier`
ORDER BY `r63_p05`.`vAN`, `r63_p05`.`vMOIS`;

--
-- Create table `r63_hour_p05`
--
CREATE TABLE r63_hour_p05 (
  CLE63PXX varchar(255) DEFAULT NULL,
  segment varchar(255) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  vDATE date DEFAULT NULL,
  vDATE_HEURE datetime DEFAULT NULL,
  vJOUR int DEFAULT NULL,
  vHEURE int DEFAULT NULL,
  vVALEUR int DEFAULT NULL,
  CT varchar(10) DEFAULT NULL,
  CT_type varchar(1) DEFAULT NULL,
  CT_origine varchar(50) DEFAULT NULL,
  `0_min_5` int DEFAULT NULL,
  `5_min_10` int DEFAULT NULL,
  `10_min_15` int DEFAULT NULL,
  `15_min_20` int DEFAULT NULL,
  `20_min_25` int DEFAULT NULL,
  `25_min_30` int DEFAULT NULL,
  `30_min_35` int DEFAULT NULL,
  `35_min_40` int DEFAULT NULL,
  `40_min_45` int DEFAULT NULL,
  `45_min_50` int DEFAULT NULL,
  `50_min_55` int DEFAULT NULL,
  `55_min_60` int DEFAULT NULL,
  vP05x5 int DEFAULT NULL,
  vP10x10 int DEFAULT NULL,
  vP10x20 int DEFAULT NULL,
  vP10x30 int DEFAULT NULL,
  vP10x40 int DEFAULT NULL,
  vP10x50 int DEFAULT NULL,
  vP10x60 int DEFAULT NULL,
  vP15x15 int DEFAULT NULL,
  vP15x30 int DEFAULT NULL,
  vP15x45 int DEFAULT NULL,
  vP15x60 int DEFAULT NULL,
  vP30x30 int DEFAULT NULL,
  vP30x60 int DEFAULT NULL,
  vP60x60 int DEFAULT NULL,
  vP05_MAX int DEFAULT NULL,
  vP05_AVG double DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 156,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `dw_r63_an_mois_jour from_hour`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW `dw_r63_an_mois_jour from_hour`
AS
SELECT
  `r63_hour_p05`.`idPrm` AS `idPrm`,
  `r63_hour_p05`.`vAN` AS `AN`,
  `r63_hour_p05`.`vMOIS` AS `MOIS`,
  `r63_hour_p05`.`vDATE` AS `date_deb`,
  `r63_hour_p05`.`vDATE` AS `date_fin`,
  `r63_hour_p05`.`grandeurMetier` AS `grandeurMetier`,
  `r63_hour_p05`.`etapeMetier` AS `etapeMetier`,
  `r63_hour_p05`.`CT` AS `CT`,
  SUM(`r63_hour_p05`.`vP05_AVG`) AS `TOTAL`
FROM `r63_hour_p05`
GROUP BY `r63_hour_p05`.`idPrm`,
         `r63_hour_p05`.`vAN`,
         `r63_hour_p05`.`vMOIS`,
         `r63_hour_p05`.`vDATE`,
         `r63_hour_p05`.`vDATE`,
         `r63_hour_p05`.`grandeurMetier`,
         `r63_hour_p05`.`etapeMetier`,
         `r63_hour_p05`.`CT`
ORDER BY `r63_hour_p05`.`vAN`, `r63_hour_p05`.`vMOIS`;

--
-- Create view `dw_r63_an_mois_from_hour`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r63_an_mois_from_hour
AS
SELECT
  `r63_hour_p05`.`idPrm` AS `idPrm`,
  `r63_hour_p05`.`vAN` AS `AN`,
  `r63_hour_p05`.`vMOIS` AS `MOIS`,
  `r63_hour_p05`.`grandeurMetier` AS `grandeurMetier`,
  `r63_hour_p05`.`etapeMetier` AS `etapeMetier`,
  `r63_hour_p05`.`CT` AS `CT`,
  SUM(`r63_hour_p05`.`vP05_AVG`) AS `TOTAL`
FROM `r63_hour_p05`
GROUP BY `r63_hour_p05`.`idPrm`,
         `r63_hour_p05`.`vAN`,
         `r63_hour_p05`.`vMOIS`,
         `r63_hour_p05`.`grandeurMetier`,
         `r63_hour_p05`.`etapeMetier`,
         `r63_hour_p05`.`CT`
ORDER BY `r63_hour_p05`.`vAN`, `r63_hour_p05`.`vMOIS`;

--
-- Create table `param_rafa_select`
--
CREATE TABLE param_rafa_select (
  idPrm varchar(50) NOT NULL,
  flag_actif int DEFAULT NULL,
  CONS int DEFAULT NULL,
  PROD int DEFAULT NULL,
  PRIMARY KEY (idPrm)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2340,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `rafa_ctrl_c68`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW rafa_ctrl_c68
AS
SELECT
  `c68_compteurs_col`.`id` AS `id`,
  `c68_compteurs_col`.`idPrm` AS `idPrm`,
  `c68_compteurs_col`.`compteur_serie` AS `compteur_serie`,
  `c68_compteurs_col`.`CLE68CO` AS `CLE68CO`,
  `c68_compteurs_col`.`HEURE_deb` AS `HEURE_deb`,
  `c68_compteurs_col`.`MIN_deb` AS `MIN_deb`,
  `c68_compteurs_col`.`HEURE_fin` AS `HEURE_fin`,
  `c68_compteurs_col`.`MIN_fin` AS `MIN_fin`,
  `c68_compteurs_col`.`CT_col` AS `CT_col`
FROM (`param_rafa_select`
  JOIN `c68_compteurs_col`
    ON ((`param_rafa_select`.`idPrm` = `c68_compteurs_col`.`idPrm`)));

--
-- Create table `r63`
--
CREATE TABLE r63 (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE63 varchar(255) NOT NULL,
  CLE63_indice varchar(255) DEFAULT NULL,
  nom_fic varchar(255) DEFAULT NULL,
  num_demande varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 13407017,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `CLE63` on table `r63`
--
ALTER TABLE r63
ADD UNIQUE INDEX CLE63 (CLE63);

--
-- Create index `IDX_c63_CLE63_prod` on table `r63`
--
ALTER TABLE r63
ADD UNIQUE INDEX IDX_c63_CLE63_prod (CLE63);

--
-- Create index `IDX_c63_etapeMetier_prod` on table `r63`
--
ALTER TABLE r63
ADD INDEX IDX_c63_etapeMetier_prod (etapeMetier);

--
-- Create index `IDX_c63_idPrm_prod` on table `r63`
--
ALTER TABLE r63
ADD INDEX IDX_c63_idPrm_prod (idPrm, CLE63);

--
-- Create index `IDX_c63_tmp_idPrm_prod` on table `r63`
--
ALTER TABLE r63
ADD INDEX IDX_c63_tmp_idPrm_prod (idPrm);

--
-- Create view `vue_sys_demande_r63_liste`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_r63_liste
AS
SELECT DISTINCT
  `r63`.`idDemande` AS `idDemande`,
  `r63`.`idPrm` AS `idPrm`,
  `r63`.`date_creation` AS `date_creation`
FROM `r63`
ORDER BY `r63`.`date_creation` DESC;

--
-- Create view `vue_sys_demande_r63`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_r63
AS
SELECT
  `r63`.`idDemande` AS `idDemande`,
  `r63`.`idPrm` AS `idPrm`,
  MAX(`r63`.`date_creation`) AS `date_creation`,
  MIN(`r63`.`d`) AS `dateDebut`,
  MAX(`r63`.`d`) AS `dateFin`,
  COUNT(`r63`.`idPrm`) AS `Nbre`
FROM `r63`
GROUP BY `r63`.`idDemande`,
         `r63`.`idPrm`;

--
-- Create view `vue_select_r63`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_select_r63
AS
SELECT
  `r63`.`id` AS `id`,
  `r63`.`header` AS `header`,
  `r63`.`siDemandeur` AS `siDemandeur`,
  `r63`.`typeDestinataire` AS `typeDestinataire`,
  `r63`.`idDestinataire` AS `idDestinataire`,
  `r63`.`codeFlux` AS `codeFlux`,
  `r63`.`idDemande` AS `idDemande`,
  `r63`.`modePublication` AS `modePublication`,
  `r63`.`idCanalContact` AS `idCanalContact`,
  `r63`.`publicationCrp` AS `publicationCrp`,
  `r63`.`format` AS `format`,
  `r63`.`mesures` AS `mesures`,
  `r63`.`idPrm` AS `idPrm`,
  `r63`.`etapeMetier` AS `etapeMetier`,
  `r63`.`periode` AS `periode`,
  `r63`.`dateDebut` AS `dateDebut`,
  `r63`.`dateFin` AS `dateFin`,
  `r63`.`modeCalcul` AS `modeCalcul`,
  `r63`.`grandeur` AS `grandeur`,
  `r63`.`grandeurMetier` AS `grandeurMetier`,
  `r63`.`grandeurPhysique` AS `grandeurPhysique`,
  `r63`.`unite` AS `unite`,
  `r63`.`points` AS `points`,
  `r63`.`v` AS `v`,
  `r63`.`d` AS `d`,
  `r63`.`p` AS `p`,
  `r63`.`n` AS `n`,
  `r63`.`iv` AS `iv`,
  `r63`.`ec` AS `ec`,
  `r63`.`fichier` AS `fichier`,
  `r63`.`date_creation` AS `date_creation`
FROM (`r63`
  JOIN `param_query`
    ON (((`r63`.`idPrm` = `param_query`.`vIDPRM`)
    AND (`r63`.`d` >= `param_query`.`vDATEDEB`)
    AND (`r63`.`d` <= `param_query`.`vDATEFIN`))));

--
-- Create view `vue_r63_prefac`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_r63_prefac
AS
SELECT
  `c`.`idPrm` AS `idPrm`,
  `c`.`periode` AS `periode`,
  `c`.`dateDebut` AS `dateDebut`,
  `c`.`dateFin` AS `dateFin`,
  `c`.`modeCalcul` AS `modeCalcul`,
  `c`.`grandeur` AS `grandeur`,
  `c`.`grandeurMetier` AS `grandeurMetier`,
  `c`.`grandeurPhysique` AS `grandeurPhysique`,
  `c`.`unite` AS `unite`,
  `c`.`points` AS `points`,
  `c`.`v` AS `v`,
  `c`.`d` AS `d`,
  `c`.`p` AS `p`,
  `c`.`n` AS `n`,
  `c`.`iv` AS `iv`,
  `c`.`ec` AS `ec`,
  `c`.`fichier` AS `fichier`,
  `c`.`date_creation` AS `date_creation`,
  `c`.`CLE63` AS `CLE63`
FROM `r63` `c`
WHERE ((`c`.`idPrm` = '30001510181742')
AND (`c`.`etapeMetier` = 'BEST')
AND (`c`.`d` <= '2023-01-01')
AND (`c`.`d` < '2023-01-31'));

--
-- Create view `vue_r63_p05`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_r63_p05
AS
SELECT
  `r63`.`idPrm` AS `idPrm`,
  `r63`.`grandeurMetier` AS `grandeurMetier`,
  `r63`.`grandeurPhysique` AS `grandeurPhysique`,
  `r63`.`d` AS `vDATE_HEURE`,
  CAST(`r63`.`d` AS date) AS `vDATE`,
  DAYOFMONTH(`r63`.`d`) AS `vJOUR`,
  HOUR(`r63`.`d`) AS `vHEURE`,
  MINUTE(`r63`.`d`) AS `vMINUTE`,
  MONTH(`r63`.`d`) AS `vMOIS`,
  YEAR(`r63`.`d`) AS `vAN`,
  `r63`.`v` AS `vValeur`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 5) = 0) THEN `r63`.`v` ELSE NULL END) AS `vP05`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 10) = 0) THEN `r63`.`v` ELSE NULL END) AS `vp10`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 30) = 0) THEN `r63`.`v` ELSE NULL END) AS `vP30`,
  (CASE WHEN (MINUTE(`r63`.`d`) = 0) THEN `r63`.`v` ELSE NULL END) AS `vP60`,
  `r63`.`CLE63` AS `CLE63`
FROM (`r63`
  LEFT JOIN `r63_p05`
    ON ((`r63`.`CLE63` = `r63_p05`.`CLE63PXX`)))
WHERE ((`r63`.`idPrm` = 30002340232071)
AND (`r63_p05`.`CLE63PXX` IS NULL))
GROUP BY `r63`.`idPrm`,
         `r63`.`grandeurMetier`,
         `r63`.`grandeurPhysique`,
         `r63`.`v`,
         `r63`.`d`,
         (`r63`.`v` / 1000),
         MONTH(`r63`.`d`),
         YEAR(`r63`.`d`),
         `r63_p05`.`CLE63PXX`
ORDER BY `r63`.`d`, HOUR(`r63`.`d`);

--
-- Create view `vue_r63_moyenne_src_zero`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_r63_moyenne_src_zero
AS
SELECT
  `r63`.`idPrm` AS `idPrm`,
  `r63`.`grandeurMetier` AS `grandeurMetier`,
  `r63`.`grandeurPhysique` AS `grandeurPhysique`,
  (`r63`.`v` / 1000) AS `vValeur`,
  CAST(`r63`.`d` AS date) AS `vDATE`,
  DAYOFMONTH(`r63`.`d`) AS `vJour`,
  HOUR(`r63`.`d`) AS `vHeure`,
  MINUTE(`r63`.`d`) AS `vMinute`,
  (MINUTE(`r63`.`d`) / 5) AS `vP10`,
  MONTH(`r63`.`d`) AS `vMOIS`,
  YEAR(`r63`.`d`) AS `vAN`
FROM `r63`
GROUP BY `r63`.`idPrm`,
         `r63`.`grandeurMetier`,
         `r63`.`grandeurPhysique`,
         `r63`.`v`,
         `r63`.`d`,
         (`r63`.`v` / 1000),
         MONTH(`r63`.`d`),
         YEAR(`r63`.`d`)
ORDER BY `r63`.`d`, HOUR(`r63`.`d`);

--
-- Create view `vue_r63_moyenne_src_p05_zero`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_r63_moyenne_src_p05_zero
AS
SELECT
  `r63`.`idPrm` AS `idPRM`,
  YEAR(`r63`.`d`) AS `AN`,
  MONTH(`r63`.`d`) AS `MOIS`,
  CAST(`r63`.`d` AS date) AS `JOUR`,
  HOUR(`r63`.`d`) AS `date_heure`,
  (FLOOR((MINUTE(`r63`.`d`) / 10)) * 10) AS `minute`,
  (FLOOR((MINUTE(`r63`.`d`) / 30)) * 30) AS `demi`,
  (`r63`.`v` / 1000) AS `valeur`,
  `r63`.`CLE63` AS `CLE63`
FROM `r63`
WHERE ((YEAR(`r63`.`d`) = 2023)
AND (MONTH(`r63`.`d`) = 1))
GROUP BY `r63`.`idPrm`,
         YEAR(`r63`.`d`),
         MONTH(`r63`.`d`),
         CAST(`r63`.`d` AS date),
         `r63`.`d`,
         HOUR(`r63`.`d`),
         FLOOR((MINUTE(`r63`.`d`) / 30)),
         FLOOR((MINUTE(`r63`.`d`) / 10)),
         `r63`.`CLE63`
ORDER BY CAST(`r63`.`d` AS date), HOUR(`r63`.`d`), (FLOOR((MINUTE(`r63`.`d`) / 30)) * 30), (FLOOR((MINUTE(`r63`.`d`) / 10)) * 10);

--
-- Create view `vue_delta_r63_import`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_delta_r63_import
AS
SELECT
  `r63_tmp_import`.`id` AS `id`,
  `r63_tmp_import`.`header` AS `header`,
  `r63_tmp_import`.`siDemandeur` AS `siDemandeur`,
  `r63_tmp_import`.`typeDestinataire` AS `typeDestinataire`,
  `r63_tmp_import`.`idDestinataire` AS `idDestinataire`,
  `r63_tmp_import`.`codeFlux` AS `codeFlux`,
  `r63_tmp_import`.`idDemande` AS `idDemande`,
  `r63_tmp_import`.`modePublication` AS `modePublication`,
  `r63_tmp_import`.`idCanalContact` AS `idCanalContact`,
  `r63_tmp_import`.`publicationCrp` AS `publicationCrp`,
  `r63_tmp_import`.`format` AS `format`,
  `r63_tmp_import`.`mesures` AS `mesures`,
  `r63_tmp_import`.`idPrm` AS `idPrm`,
  `r63_tmp_import`.`etapeMetier` AS `etapeMetier`,
  `r63_tmp_import`.`periode` AS `periode`,
  `r63_tmp_import`.`dateDebut` AS `dateDebut`,
  `r63_tmp_import`.`dateFin` AS `dateFin`,
  `r63_tmp_import`.`modeCalcul` AS `modeCalcul`,
  `r63_tmp_import`.`grandeur` AS `grandeur`,
  `r63_tmp_import`.`grandeurMetier` AS `grandeurMetier`,
  `r63_tmp_import`.`grandeurPhysique` AS `grandeurPhysique`,
  `r63_tmp_import`.`unite` AS `unite`,
  `r63_tmp_import`.`points` AS `points`,
  `r63_tmp_import`.`v` AS `v`,
  `r63_tmp_import`.`d` AS `d`,
  `r63_tmp_import`.`p` AS `p`,
  `r63_tmp_import`.`n` AS `n`,
  `r63_tmp_import`.`iv` AS `iv`,
  `r63_tmp_import`.`ec` AS `ec`,
  `r63_tmp_import`.`fichier` AS `fichier`,
  `r63_tmp_import`.`date_creation` AS `date_creation`
FROM (`r63_tmp_import`
  LEFT JOIN `r63`
    ON (((`r63_tmp_import`.`idPrm` = `r63`.`idPrm`)
    AND (`r63_tmp_import`.`dateDebut` = `r63`.`dateDebut`)
    AND (`r63_tmp_import`.`dateFin` = `r63`.`dateFin`)
    AND (`r63_tmp_import`.`grandeur` = `r63`.`grandeur`)
    AND (`r63_tmp_import`.`grandeurPhysique` = `r63`.`grandeurPhysique`)
    AND (`r63_tmp_import`.`grandeurMetier` = `r63`.`grandeurMetier`))))
WHERE (`r63`.`idPrm` IS NULL);

--
-- Create view `vue_ctrl_prm_day`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_ctrl_prm_day
AS
SELECT
  `r63`.`idPrm` AS `idPrm`,
  COUNT(`r63`.`id`) AS `NBRE_MESURES`,
  `r63`.`etapeMetier` AS `etapeMetier`,
  DAYOFMONTH(`r63`.`d`) AS `JOUR`,
  MONTH(`r63`.`d`) AS `MOIS`,
  YEAR(`r63`.`d`) AS `AN`
FROM `r63`
GROUP BY `r63`.`idPrm`,
         DAYOFMONTH(`r63`.`d`),
         MONTH(`r63`.`d`),
         YEAR(`r63`.`d`),
         `r63`.`etapeMetier`;

--
-- Create view `view1`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW view1
AS
SELECT
  `r63`.`idPrm` AS `idPrm`,
  YEAR(`r63`.`d`) AS `vAN`,
  MONTH(`r63`.`d`) AS `vMOIS`,
  CAST(`r63`.`d` AS date) AS `vDATE`,
  `r63`.`d` AS `vDATE_HEURE`,
  DAYOFMONTH(`r63`.`d`) AS `vJOUR`,
  HOUR(`r63`.`d`) AS `vHEURE`,
  MINUTE(`r63`.`d`) AS `vMINUTE`,
  `r63`.`v` AS `vValeur`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 5) = 0) THEN `r63`.`v` ELSE 0 END) AS `vP05`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 10) = 0) THEN `r63`.`v` ELSE 0 END) AS `vp10`,
  (CASE WHEN ((MINUTE(`r63`.`d`) % 30) = 0) THEN `r63`.`v` ELSE 0 END) AS `vP30`,
  (CASE WHEN (MINUTE(`r63`.`d`) = 0) THEN `r63`.`v` ELSE 0 END) AS `vP60`,
  `r63`.`CLE63` AS `CLE63`,
  `calendrier_mois`.`CT_type` AS `CT_type`
FROM ((`r63`
  LEFT JOIN `r63_p05`
    ON ((`r63`.`CLE63` = `r63_p05`.`CLE63PXX`)))
  LEFT JOIN `calendrier_mois`
    ON ((`r63_p05`.`vMOIS` = `calendrier_mois`.`Mois`)))
WHERE (`r63_p05`.`CLE63PXX` IS NULL)
GROUP BY `r63`.`idPrm`,
         `r63`.`grandeurMetier`,
         `r63`.`grandeurPhysique`,
         `r63`.`v`,
         `r63`.`d`,
         (`r63`.`v` / 1000),
         MONTH(`r63`.`d`),
         YEAR(`r63`.`d`),
         `r63_p05`.`CLE63PXX`,
         `calendrier_mois`.`CT_type`
ORDER BY `r63`.`d`, HOUR(`r63`.`d`);

--
-- Create view `ctrl_r63_rafa`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW ctrl_r63_rafa
AS
SELECT DISTINCT
  `r63`.`idPrm` AS `idPrm`,
  `r63`.`dateDebut` AS `dateDebut`,
  `r63`.`dateFin` AS `dateFin`
FROM (`r63`
  JOIN `param_rafa_select`
    ON ((`r63`.`idPrm` = `param_rafa_select`.`idPrm`)));

--
-- Create table `tarif_turpe_col_union`
--
CREATE TABLE tarif_turpe_col_union (
  TYPE_TARIF varchar(255) DEFAULT NULL,
  CLASSE_TEMPORELLE varchar(255) DEFAULT NULL,
  FTA_TURPE varchar(255) DEFAULT NULL,
  AN_TURPE int DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  Composante_gestion double DEFAULT NULL,
  ANNEE datetime DEFAULT NULL,
  Composante_comptage double DEFAULT NULL,
  Prime_Fixe double DEFAULT NULL,
  SOUTIRAGE double DEFAULT NULL,
  Depassements_Coef double DEFAULT NULL,
  CTA_Pourcentage double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 226,
AVG_ROW_LENGTH = 218,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `prefac_bloc_04_tmp`
--
CREATE TABLE prefac_bloc_04_tmp (
  vDate datetime DEFAULT NULL,
  vHeure int DEFAULT NULL,
  vAN_TUPRE bigint DEFAULT NULL,
  TYPE_TARIF varchar(255) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  vP10 int DEFAULT NULL,
  vP10_attendu int DEFAULT NULL,
  CLASSE_TEMPORELLE varchar(255) DEFAULT NULL,
  MOY int DEFAULT NULL,
  FTA_TURPE varchar(50) DEFAULT NULL,
  DELTA_CARRE double DEFAULT NULL,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `bloc_04_calendrier_fta_turpe_power_mois`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW bloc_04_calendrier_fta_turpe_power_mois
AS
SELECT
  `prefac_bloc_04_tmp`.`idPrm` AS `idPrm`,
  `prefac_bloc_04_tmp`.`vAN` AS `vAN`,
  `prefac_bloc_04_tmp`.`vMOIS` AS `vMOIS`,
  `prefac_bloc_04_tmp`.`FTA_TURPE` AS `vFTA`,
  `prefac_bloc_04_tmp`.`CLASSE_TEMPORELLE` AS `idClasseTemporelle`,
  SUM((`prefac_bloc_04_tmp`.`DELTA_CARRE` * `tarif_turpe_col_union`.`Depassements_Coef`)) AS `TOTAL_depassement_PONDERE`
FROM (`prefac_bloc_04_tmp`
  JOIN `tarif_turpe_col_union`
    ON (((`prefac_bloc_04_tmp`.`CLASSE_TEMPORELLE` = `tarif_turpe_col_union`.`CLASSE_TEMPORELLE`)
    AND (`prefac_bloc_04_tmp`.`FTA_TURPE` = `tarif_turpe_col_union`.`FTA_TURPE`))))
GROUP BY `prefac_bloc_04_tmp`.`vAN`,
         `prefac_bloc_04_tmp`.`vMOIS`,
         `prefac_bloc_04_tmp`.`CLASSE_TEMPORELLE`,
         `prefac_bloc_04_tmp`.`FTA_TURPE`,
         `prefac_bloc_04_tmp`.`idPrm`;

--
-- Create table `c68_classestemporelles`
--
CREATE TABLE c68_classestemporelles (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  ct_code varchar(10) DEFAULT NULL,
  ct_unite varchar(10) DEFAULT NULL,
  ct_valeur int DEFAULT NULL,
  CLE68CPT varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 3898,
AVG_ROW_LENGTH = 111,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create view `test_c68_classestemporelles_50078665580693`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_c68_classestemporelles_50078665580693
AS
SELECT DISTINCT
  `c68_classestemporelles`.`id` AS `id`,
  `c68_classestemporelles`.`idPrm` AS `idPrm`,
  `c68_classestemporelles`.`fta_code` AS `fta_code`,
  `c68_classestemporelles`.`ct_code` AS `ct_code`,
  `c68_classestemporelles`.`ct_unite` AS `ct_unite`,
  `c68_classestemporelles`.`ct_valeur` AS `ct_valeur`,
  `c68_classestemporelles`.`CLE68CPT` AS `CLE68CPT`
FROM `c68_classestemporelles`
WHERE (`c68_classestemporelles`.`idPrm` = '50078665580693');

--
-- Create table `c68`
--
CREATE TABLE c68 (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  numeroNomVoie varchar(255) DEFAULT NULL,
  codePostal varchar(255) DEFAULT NULL,
  commune varchar(255) DEFAULT NULL,
  batiment varchar(255) DEFAULT NULL,
  escalierEtageAppartement varchar(255) DEFAULT NULL,
  lieuDit varchar(255) DEFAULT NULL,
  domaineTension varchar(255) DEFAULT NULL,
  prs_valeur int DEFAULT NULL,
  prs_unite varchar(10) DEFAULT NULL,
  phc_libelle varchar(255) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  gfc_code varchar(50) DEFAULT NULL,
  ps_unite varchar(20) DEFAULT NULL,
  ps_valeur int DEFAULT NULL,
  segment varchar(10) DEFAULT NULL,
  filiereProduction varchar(255) DEFAULT NULL,
  technologie varchar(255) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE68 varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT CURRENT_TIMESTAMP,
  idDemande varchar(50) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2219,
AVG_ROW_LENGTH = 262,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c68_idPrm` on table `c68`
--
ALTER TABLE c68
ADD INDEX IDX_c68_idPrm (idPrm);

--
-- Create view `vue_sys_demande_c68`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_c68
AS
SELECT
  `c68`.`idDemande` AS `idDemande`,
  `c68`.`idPrm` AS `idPrm`,
  MAX(`c68`.`date_creation`) AS `date_creation`,
  COUNT(`c68`.`idPrm`) AS `Nbre`
FROM `c68`
GROUP BY `c68`.`idDemande`,
         `c68`.`idPrm`;

--
-- Create view `test_c68_50078665580693`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW test_c68_50078665580693
AS
SELECT DISTINCT
  `c68`.`id` AS `id`,
  `c68`.`idPrm` AS `idPrm`,
  `c68`.`numeroNomVoie` AS `numeroNomVoie`,
  `c68`.`codePostal` AS `codePostal`,
  `c68`.`commune` AS `commune`,
  `c68`.`batiment` AS `batiment`,
  `c68`.`escalierEtageAppartement` AS `escalierEtageAppartement`,
  `c68`.`lieuDit` AS `lieuDit`,
  `c68`.`domaineTension` AS `domaineTension`,
  `c68`.`prs_valeur` AS `prs_valeur`,
  `c68`.`prs_unite` AS `prs_unite`,
  `c68`.`phc_libelle` AS `phc_libelle`,
  `c68`.`fta_code` AS `fta_code`,
  `c68`.`gfc_code` AS `gfc_code`,
  `c68`.`ps_unite` AS `ps_unite`,
  `c68`.`ps_valeur` AS `ps_valeur`,
  `c68`.`segment` AS `segment`,
  `c68`.`filiereProduction` AS `filiereProduction`,
  `c68`.`technologie` AS `technologie`,
  `c68`.`fichier` AS `fichier`,
  `c68`.`date_creation` AS `date_creation`,
  `c68`.`CLE68` AS `CLE68`
FROM `c68`
WHERE (`c68`.`idPrm` = '50078665580693');

--
-- Create view `bloc_02_c68`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW bloc_02_c68
AS
SELECT DISTINCT
  `c68`.`idPrm` AS `idPrm`,
  `c68`.`fta_code` AS `fta_code`,
  `c68_classestemporelles`.`ct_code` AS `ct_code`,
  `c68_classestemporelles`.`ct_unite` AS `ct_unite`,
  `c68_classestemporelles`.`ct_valeur` AS `ct_valeur`
FROM (`c68`
  JOIN `c68_classestemporelles`
    ON (((`c68`.`idPrm` = `c68_classestemporelles`.`idPrm`)
    AND (`c68`.`fta_code` = `c68_classestemporelles`.`fta_code`))));

--
-- Create table `r67`
--
CREATE TABLE r67 (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(10) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures_groupe varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  contexte_groupe varchar(255) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  idMotifReleve varchar(20) DEFAULT NULL,
  libelleMotifReleve varchar(255) DEFAULT NULL,
  grandeur_groupe varchar(10) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  calendrier_groupe varchar(10) DEFAULT NULL,
  libelleGrille varchar(50) DEFAULT NULL,
  libelleCalendrier varchar(50) DEFAULT NULL,
  classeTemporelle_groupe varchar(10) DEFAULT NULL,
  idClasseTemporelle varchar(20) DEFAULT NULL,
  libelleClasseTemporelle varchar(255) DEFAULT NULL,
  quantite_groupe varchar(10) DEFAULT NULL,
  dateCreation datetime DEFAULT NULL,
  dbtMesure datetime DEFAULT NULL,
  finMesure datetime DEFAULT NULL,
  quantite bigint DEFAULT NULL,
  libelleNature varchar(50) DEFAULT NULL,
  libelleStatut varchar(50) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE67 varchar(255) NOT NULL,
  dbtMesure_FIN_mois date DEFAULT NULL,
  dbtMesure_NBRE_jour int DEFAULT NULL,
  finMesure_DEB_mois date DEFAULT NULL,
  finMesure_NBRE_jour int DEFAULT NULL,
  AN_date int DEFAULT NULL,
  MOIS_date int DEFAULT NULL,
  R63_mesure double DEFAULT NULL,
  PRIMARY KEY (id, CLE67)
)
ENGINE = INNODB,
AUTO_INCREMENT = 667918,
AVG_ROW_LENGTH = 303,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c67_CLE67` on table `r67`
--
ALTER TABLE r67
ADD INDEX IDX_c67_CLE67 (CLE67);

--
-- Create index `IDX_c67_dbtMesure` on table `r67`
--
ALTER TABLE r67
ADD INDEX IDX_c67_dbtMesure (dbtMesure);

--
-- Create view `vue_sys_demande_r67`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_sys_demande_r67
AS
SELECT
  `r67`.`idDemande` AS `idDemande`,
  `r67`.`idPrm` AS `idPrm`,
  MAX(`r67`.`date_creation`) AS `date_creation`,
  MIN(`r67`.`dbtMesure`) AS `dateDebut`,
  MAX(`r67`.`finMesure`) AS `dateFin`,
  COUNT(`r67`.`idPrm`) AS `Nbre`
FROM `r67`
GROUP BY `r67`.`idDemande`,
         `r67`.`idPrm`;

--
-- Create view `vue_select_r67`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_select_r67
AS
SELECT
  `r67`.`id` AS `id`,
  `r67`.`header` AS `header`,
  `r67`.`siDemandeur` AS `siDemandeur`,
  `r67`.`typeDestinataire` AS `typeDestinataire`,
  `r67`.`idDestinataire` AS `idDestinataire`,
  `r67`.`codeFlux` AS `codeFlux`,
  `r67`.`idDemande` AS `idDemande`,
  `r67`.`modePublication` AS `modePublication`,
  `r67`.`idCanalContact` AS `idCanalContact`,
  `r67`.`publicationCrp` AS `publicationCrp`,
  `r67`.`format` AS `format`,
  `r67`.`mesures_groupe` AS `mesures_groupe`,
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`periode` AS `periode`,
  `r67`.`dateDebut` AS `dateDebut`,
  `r67`.`dateFin` AS `dateFin`,
  `r67`.`contexte_groupe` AS `contexte_groupe`,
  `r67`.`etapeMetier` AS `etapeMetier`,
  `r67`.`idMotifReleve` AS `idMotifReleve`,
  `r67`.`libelleMotifReleve` AS `libelleMotifReleve`,
  `r67`.`grandeur_groupe` AS `grandeur_groupe`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  `r67`.`calendrier_groupe` AS `calendrier_groupe`,
  `r67`.`libelleGrille` AS `libelleGrille`,
  `r67`.`libelleCalendrier` AS `libelleCalendrier`,
  `r67`.`classeTemporelle_groupe` AS `classeTemporelle_groupe`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`,
  `r67`.`libelleClasseTemporelle` AS `libelleClasseTemporelle`,
  `r67`.`quantite_groupe` AS `quantite_groupe`,
  `r67`.`dateCreation` AS `dateCreation`,
  `r67`.`dbtMesure` AS `dbtMesure`,
  `r67`.`finMesure` AS `finMesure`,
  `r67`.`quantite` AS `quantite`,
  `r67`.`libelleNature` AS `libelleNature`,
  `r67`.`libelleStatut` AS `libelleStatut`,
  `r67`.`fichier` AS `fichier`,
  `r67`.`date_creation` AS `date_creation`
FROM (`r67`
  JOIN `param_query`
    ON (((`r67`.`idPrm` = `param_query`.`vIDPRM`)
    AND (`r67`.`dateDebut` >= `param_query`.`vDATEDEB`)
    AND (`r67`.`dateFin` <= `param_query`.`vDATEFIN`))));

--
-- Create view `vue_ctrll_calendar_r67_natif`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW vue_ctrll_calendar_r67_natif
AS
SELECT
  `c`.`idPrm` AS `idPRM`,
  YEAR(`c`.`dbtMesure`) AS `AN`,
  MONTH(`c`.`dbtMesure`) AS `MOIS`,
  `c`.`grandeurPhysique` AS `grandeurPhysique`,
  COUNT(`c`.`dbtMesure`) AS `Nbre_DbtMesure`
FROM `r67` `c`
GROUP BY `c`.`idPrm`,
         YEAR(`c`.`dbtMesure`),
         MONTH(`c`.`dbtMesure`),
         `c`.`grandeurPhysique`
ORDER BY YEAR(`c`.`dbtMesure`), MONTH(`c`.`dbtMesure`);

--
-- Create view `vue_ctrll_calendar_r67`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW vue_ctrll_calendar_r67
AS
SELECT DISTINCT
  `c`.`idPRM` AS `idPRM`,
  `c`.`dbtMesure` AS `dbtMesure`,
  `c`.`MOIS` AS `MOIS`,
  `c`.`AN` AS `AN`,
  `d`.`dbtMesure` AS `expr1`
FROM (`calendar_dates` `c`
  LEFT JOIN `r67` `d`
    ON ((`c`.`dbtMesure` = `d`.`dbtMesure`)))
WHERE (`d`.`dbtMesure` IS NULL)
ORDER BY `c`.`dbtMesure`;

--
-- Create view `rafa_ctrl_r67`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW rafa_ctrl_r67
AS
SELECT
  `r67`.`id` AS `id`,
  `r67`.`header` AS `header`,
  `r67`.`siDemandeur` AS `siDemandeur`,
  `r67`.`typeDestinataire` AS `typeDestinataire`,
  `r67`.`idDestinataire` AS `idDestinataire`,
  `r67`.`codeFlux` AS `codeFlux`,
  `r67`.`idDemande` AS `idDemande`,
  `r67`.`modePublication` AS `modePublication`,
  `r67`.`idCanalContact` AS `idCanalContact`,
  `r67`.`publicationCrp` AS `publicationCrp`,
  `r67`.`format` AS `format`,
  `r67`.`mesures_groupe` AS `mesures_groupe`,
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`periode` AS `periode`,
  `r67`.`dateDebut` AS `dateDebut`,
  `r67`.`dateFin` AS `dateFin`,
  `r67`.`contexte_groupe` AS `contexte_groupe`,
  `r67`.`etapeMetier` AS `etapeMetier`,
  `r67`.`idMotifReleve` AS `idMotifReleve`,
  `r67`.`libelleMotifReleve` AS `libelleMotifReleve`,
  `r67`.`grandeur_groupe` AS `grandeur_groupe`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  `r67`.`calendrier_groupe` AS `calendrier_groupe`,
  `r67`.`libelleGrille` AS `libelleGrille`,
  `r67`.`libelleCalendrier` AS `libelleCalendrier`,
  `r67`.`classeTemporelle_groupe` AS `classeTemporelle_groupe`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`,
  `r67`.`libelleClasseTemporelle` AS `libelleClasseTemporelle`,
  `r67`.`quantite_groupe` AS `quantite_groupe`,
  `r67`.`dateCreation` AS `dateCreation`,
  `r67`.`dbtMesure` AS `dbtMesure`,
  `r67`.`finMesure` AS `finMesure`,
  `r67`.`quantite` AS `quantite`,
  `r67`.`libelleNature` AS `libelleNature`,
  `r67`.`libelleStatut` AS `libelleStatut`,
  `r67`.`fichier` AS `fichier`,
  `r67`.`date_creation` AS `date_creation`,
  `r67`.`CLE67` AS `CLE67`
FROM (`param_rafa_select`
  JOIN `r67`
    ON ((`param_rafa_select`.`idPrm` = `r67`.`idPrm`)));

--
-- Create view `dw_r67_an_mois_jour_cx`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_mois_jour_cx
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`AN_date` AS `AN`,
  `r67`.`MOIS_date` AS `MOIS`,
  `r67`.`dbtMesure` AS `date_deb`,
  `r67`.`finMesure` AS `date_fin`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  SUM((`r67`.`quantite` / 1000)) AS `TOTAL`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         `r67`.`AN_date`,
         `r67`.`MOIS_date`,
         `r67`.`dbtMesure`,
         `r67`.`finMesure`,
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`,
         `r67`.`idClasseTemporelle`
HAVING (SUM(`r67`.`quantite`) > 0);

--
-- Create view `dw_r67_an_mois_jour_c2`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_mois_jour_c2
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  YEAR(`r67`.`dbtMesure`) AS `AN`,
  MONTH(`r67`.`dbtMesure`) AS `MOIS`,
  `r67`.`dbtMesure` AS `JOUR`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`,
  `r67`.`unite` AS `unite`,
  SUM((`r67`.`quantite` / 1000)) AS `TOTAL`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         YEAR(`r67`.`dbtMesure`),
         MONTH(`r67`.`dbtMesure`),
         `r67`.`dbtMesure`,
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`,
         `r67`.`idClasseTemporelle`
HAVING (SUM(`r67`.`quantite`) > 0)
ORDER BY YEAR(`r67`.`dbtMesure`), MONTH(`r67`.`dbtMesure`);

--
-- Create view `dw_r67_an_mois_cx`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_mois_cx
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`AN_date` AS `AN`,
  `r67`.`MOIS_date` AS `MOIS`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  SUM((`r67`.`quantite` / 1000)) AS `TOTAL`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         `r67`.`AN_date`,
         `r67`.`MOIS_date`,
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`,
         `r67`.`idClasseTemporelle`
HAVING (SUM(`r67`.`quantite`) > 0);

--
-- Create view `dw_r67_an_mois_c2`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_mois_c2
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  YEAR(`r67`.`dbtMesure`) AS `AN`,
  MONTH(`r67`.`dbtMesure`) AS `MOIS`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`,
  `r67`.`unite` AS `unite`,
  SUM((`r67`.`quantite` / 1000)) AS `TOTAL`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         YEAR(`r67`.`dbtMesure`),
         MONTH(`r67`.`dbtMesure`),
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`,
         `r67`.`idClasseTemporelle`
HAVING (SUM(`r67`.`quantite`) > 0)
ORDER BY YEAR(`r67`.`dbtMesure`), MONTH(`r67`.`dbtMesure`);

--
-- Create view `dw_r67_an_cx`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_cx
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`AN_date` AS `AN`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  SUM(`r67`.`quantite`) AS `TOTAL`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         `r67`.`AN_date`,
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`
HAVING (SUM(`r67`.`quantite`) > 0);

--
-- Create view `dw_r67_an_c2`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW dw_r67_an_c2
AS
SELECT
  `r67`.`idPrm` AS `idPrm`,
  YEAR(`r67`.`dbtMesure`) AS `AN`,
  `r67`.`grandeurMetier` AS `grandeurMetier`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`unite` AS `unite`,
  SUM(`r67`.`quantite`) AS `TOTAL`
FROM `r67`
GROUP BY `r67`.`idPrm`,
         YEAR(`r67`.`dbtMesure`),
         `r67`.`grandeurMetier`,
         `r67`.`grandeurPhysique`,
         `r67`.`unite`,
         `r67`.`dbtMesure`
HAVING (SUM(`r67`.`quantite`) > 0);

--
-- Create view `bloc_01_r67`
--
CREATE
DEFINER = 'user_odbc'@'%'
VIEW bloc_01_r67
AS
SELECT DISTINCT
  `r67`.`idPrm` AS `idPrm`,
  `r67`.`dbtMesure` AS `dateDebut`,
  `r67`.`finMesure` AS `dateFin`,
  `r67`.`grandeurPhysique` AS `grandeurPhysique`,
  `r67`.`idClasseTemporelle` AS `idClasseTemporelle`,
  (`r67`.`quantite` / 1000) AS `quantite`,
  YEAR(`r67`.`dbtMesure`) AS `AN`,
  MONTH(`r67`.`dbtMesure`) AS `MOIS`
FROM `r67`
WHERE ((`r67`.`grandeurPhysique` IN ('EA', 'PA', 'DQ'))
AND (`r67`.`idClasseTemporelle` IN ('Pointe', 'HPH', 'HCH', 'HPE', 'HCE')));

--
-- Create table `___ ref_tarif_turpe`
--
CREATE TABLE `___ ref_tarif_turpe` (
  id_ligne int DEFAULT NULL,
  ID int DEFAULT NULL,
  CLASSE_TEMPORELLE varchar(255) DEFAULT NULL,
  redevance_CG double DEFAULT NULL,
  redevance_CC double DEFAULT NULL,
  redevance_PF double DEFAULT NULL,
  soutirage_PTE double DEFAULT NULL,
  soutirage_HPH double DEFAULT NULL,
  soutirage_HPD varchar(255) DEFAULT NULL,
  soutirage_HCH double DEFAULT NULL,
  soutirage_HCD varchar(255) DEFAULT NULL,
  soutirage_HPE double DEFAULT NULL,
  soutirage_HCE double DEFAULT NULL,
  soutirage_JA varchar(255) DEFAULT NULL,
  depassement_PTE double DEFAULT NULL,
  depassement_HPH double DEFAULT NULL,
  depassement_HPD double DEFAULT NULL,
  depassement_HCH double DEFAULT NULL,
  depassement_HCD double DEFAULT NULL,
  depassement_HPE double DEFAULT NULL,
  depassement_HCE double DEFAULT NULL,
  depassement_JA double DEFAULT NULL,
  coeficient_PTE double DEFAULT NULL,
  coeficient_HPH double DEFAULT NULL,
  coeficient_HPD double DEFAULT NULL,
  coeficient_HCH double DEFAULT NULL,
  coeficient_HCD double DEFAULT NULL,
  coeficient_HPE double DEFAULT NULL,
  coeficient_HCE double DEFAULT NULL,
  coeficient_JA double DEFAULT NULL,
  CTA double DEFAULT NULL,
  REACTIF double DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2730,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `__ r63_day_p5`
--
CREATE TABLE `__ r63_day_p5` (
  idPrm varchar(50) DEFAULT NULL,
  dateDebut date DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  heure_0_min_0 int DEFAULT NULL,
  heure_0_min_5 int DEFAULT NULL,
  heure_0_min_10 int DEFAULT NULL,
  heure_0_min_15 int DEFAULT NULL,
  heure_0_min_20 int DEFAULT NULL,
  heure_0_min_25 int DEFAULT NULL,
  heure_0_min_30 int DEFAULT NULL,
  heure_0_min_35 int DEFAULT NULL,
  heure_0_min_40 int DEFAULT NULL,
  heure_0_min_45 int DEFAULT NULL,
  heure_0_min_50 int DEFAULT NULL,
  heure_0_min_55 int DEFAULT NULL,
  heure_0_min_60 int DEFAULT NULL,
  heure_1_min_0 int DEFAULT NULL,
  heure_1_min_5 int DEFAULT NULL,
  heure_1_min_10 int DEFAULT NULL,
  heure_1_min_15 int DEFAULT NULL,
  heure_1_min_20 int DEFAULT NULL,
  heure_1_min_25 int DEFAULT NULL,
  heure_1_min_30 int DEFAULT NULL,
  heure_1_min_35 int DEFAULT NULL,
  heure_1_min_40 int DEFAULT NULL,
  heure_1_min_45 int DEFAULT NULL,
  heure_1_min_50 int DEFAULT NULL,
  heure_1_min_55 int DEFAULT NULL,
  heure_1_min_60 int DEFAULT NULL,
  heure_2_min_0 int DEFAULT NULL,
  heure_2_min_5 int DEFAULT NULL,
  heure_2_min_10 int DEFAULT NULL,
  heure_2_min_15 int DEFAULT NULL,
  heure_2_min_20 int DEFAULT NULL,
  heure_2_min_25 int DEFAULT NULL,
  heure_2_min_30 int DEFAULT NULL,
  heure_2_min_35 int DEFAULT NULL,
  heure_2_min_40 int DEFAULT NULL,
  heure_2_min_45 int DEFAULT NULL,
  heure_2_min_50 int DEFAULT NULL,
  heure_2_min_55 int DEFAULT NULL,
  heure_2_min_60 int DEFAULT NULL,
  heure_3_min_0 int DEFAULT NULL,
  heure_3_min_5 int DEFAULT NULL,
  heure_3_min_10 int DEFAULT NULL,
  heure_3_min_15 int DEFAULT NULL,
  heure_3_min_20 int DEFAULT NULL,
  heure_3_min_25 int DEFAULT NULL,
  heure_3_min_30 int DEFAULT NULL,
  heure_3_min_35 int DEFAULT NULL,
  heure_3_min_40 int DEFAULT NULL,
  heure_3_min_45 int DEFAULT NULL,
  heure_3_min_50 int DEFAULT NULL,
  heure_3_min_55 int DEFAULT NULL,
  heure_3_min_60 int DEFAULT NULL,
  heure_4_min_0 int DEFAULT NULL,
  heure_4_min_5 int DEFAULT NULL,
  heure_4_min_10 int DEFAULT NULL,
  heure_4_min_15 int DEFAULT NULL,
  heure_4_min_20 int DEFAULT NULL,
  heure_4_min_25 int DEFAULT NULL,
  heure_4_min_30 int DEFAULT NULL,
  heure_4_min_35 int DEFAULT NULL,
  heure_4_min_40 int DEFAULT NULL,
  heure_4_min_45 int DEFAULT NULL,
  heure_4_min_50 int DEFAULT NULL,
  heure_4_min_55 int DEFAULT NULL,
  heure_4_min_60 int DEFAULT NULL,
  heure_5_min_0 int DEFAULT NULL,
  heure_5_min_5 int DEFAULT NULL,
  heure_5_min_10 int DEFAULT NULL,
  heure_5_min_15 int DEFAULT NULL,
  heure_5_min_20 int DEFAULT NULL,
  heure_5_min_25 int DEFAULT NULL,
  heure_5_min_30 int DEFAULT NULL,
  heure_5_min_35 int DEFAULT NULL,
  heure_5_min_40 int DEFAULT NULL,
  heure_5_min_45 int DEFAULT NULL,
  heure_5_min_50 int DEFAULT NULL,
  heure_5_min_55 int DEFAULT NULL,
  heure_5_min_60 int DEFAULT NULL,
  heure_6_min_0 int DEFAULT NULL,
  heure_6_min_5 int DEFAULT NULL,
  heure_6_min_10 int DEFAULT NULL,
  heure_6_min_15 int DEFAULT NULL,
  heure_6_min_20 int DEFAULT NULL,
  heure_6_min_25 int DEFAULT NULL,
  heure_6_min_30 int DEFAULT NULL,
  heure_6_min_35 int DEFAULT NULL,
  heure_6_min_40 int DEFAULT NULL,
  heure_6_min_45 int DEFAULT NULL,
  heure_6_min_50 int DEFAULT NULL,
  heure_6_min_55 int DEFAULT NULL,
  heure_6_min_60 int DEFAULT NULL,
  heure_7_min_0 int DEFAULT NULL,
  heure_7_min_5 int DEFAULT NULL,
  heure_7_min_10 int DEFAULT NULL,
  heure_7_min_15 int DEFAULT NULL,
  heure_7_min_20 int DEFAULT NULL,
  heure_7_min_25 int DEFAULT NULL,
  heure_7_min_30 int DEFAULT NULL,
  heure_7_min_35 int DEFAULT NULL,
  heure_7_min_40 int DEFAULT NULL,
  heure_7_min_45 int DEFAULT NULL,
  heure_7_min_50 int DEFAULT NULL,
  heure_7_min_55 int DEFAULT NULL,
  heure_7_min_60 int DEFAULT NULL,
  heure_8_min_0 int DEFAULT NULL,
  heure_8_min_5 int DEFAULT NULL,
  heure_8_min_10 int DEFAULT NULL,
  heure_8_min_15 int DEFAULT NULL,
  heure_8_min_20 int DEFAULT NULL,
  heure_8_min_25 int DEFAULT NULL,
  heure_8_min_30 int DEFAULT NULL,
  heure_8_min_35 int DEFAULT NULL,
  heure_8_min_40 int DEFAULT NULL,
  heure_8_min_45 int DEFAULT NULL,
  heure_8_min_50 int DEFAULT NULL,
  heure_8_min_55 int DEFAULT NULL,
  heure_8_min_60 int DEFAULT NULL,
  heure_9_min_0 int DEFAULT NULL,
  heure_9_min_5 int DEFAULT NULL,
  heure_9_min_10 int DEFAULT NULL,
  heure_9_min_15 int DEFAULT NULL,
  heure_9_min_20 int DEFAULT NULL,
  heure_9_min_25 int DEFAULT NULL,
  heure_9_min_30 int DEFAULT NULL,
  heure_9_min_35 int DEFAULT NULL,
  heure_9_min_40 int DEFAULT NULL,
  heure_9_min_45 int DEFAULT NULL,
  heure_9_min_50 int DEFAULT NULL,
  heure_9_min_55 int DEFAULT NULL,
  heure_9_min_60 int DEFAULT NULL,
  heure_10_min_0 int DEFAULT NULL,
  heure_10_min_5 int DEFAULT NULL,
  heure_10_min_10 int DEFAULT NULL,
  heure_10_min_15 int DEFAULT NULL,
  heure_10_min_20 int DEFAULT NULL,
  heure_10_min_25 int DEFAULT NULL,
  heure_10_min_30 int DEFAULT NULL,
  heure_10_min_35 int DEFAULT NULL,
  heure_10_min_40 int DEFAULT NULL,
  heure_10_min_45 int DEFAULT NULL,
  heure_10_min_50 int DEFAULT NULL,
  heure_10_min_55 int DEFAULT NULL,
  heure_10_min_60 int DEFAULT NULL,
  heure_11_min_0 int DEFAULT NULL,
  heure_11_min_5 int DEFAULT NULL,
  heure_11_min_10 int DEFAULT NULL,
  heure_11_min_15 int DEFAULT NULL,
  heure_11_min_20 int DEFAULT NULL,
  heure_11_min_25 int DEFAULT NULL,
  heure_11_min_30 int DEFAULT NULL,
  heure_11_min_35 int DEFAULT NULL,
  heure_11_min_40 int DEFAULT NULL,
  heure_11_min_45 int DEFAULT NULL,
  heure_11_min_50 int DEFAULT NULL,
  heure_11_min_55 int DEFAULT NULL,
  heure_11_min_60 int DEFAULT NULL,
  heure_12_min_0 int DEFAULT NULL,
  heure_12_min_5 int DEFAULT NULL,
  heure_12_min_10 int DEFAULT NULL,
  heure_12_min_15 int DEFAULT NULL,
  heure_12_min_20 int DEFAULT NULL,
  heure_12_min_25 int DEFAULT NULL,
  heure_12_min_30 int DEFAULT NULL,
  heure_12_min_35 int DEFAULT NULL,
  heure_12_min_40 int DEFAULT NULL,
  heure_12_min_45 int DEFAULT NULL,
  heure_12_min_50 int DEFAULT NULL,
  heure_12_min_55 int DEFAULT NULL,
  heure_12_min_60 int DEFAULT NULL,
  heure_13_min_0 int DEFAULT NULL,
  heure_13_min_5 int DEFAULT NULL,
  heure_13_min_10 int DEFAULT NULL,
  heure_13_min_15 int DEFAULT NULL,
  heure_13_min_20 int DEFAULT NULL,
  heure_13_min_25 int DEFAULT NULL,
  heure_13_min_30 int DEFAULT NULL,
  heure_13_min_35 int DEFAULT NULL,
  heure_13_min_40 int DEFAULT NULL,
  heure_13_min_45 int DEFAULT NULL,
  heure_13_min_50 int DEFAULT NULL,
  heure_13_min_55 int DEFAULT NULL,
  heure_13_min_60 int DEFAULT NULL,
  heure_14_min_0 int DEFAULT NULL,
  heure_14_min_5 int DEFAULT NULL,
  heure_14_min_10 int DEFAULT NULL,
  heure_14_min_15 int DEFAULT NULL,
  heure_14_min_20 int DEFAULT NULL,
  heure_14_min_25 int DEFAULT NULL,
  heure_14_min_30 int DEFAULT NULL,
  heure_14_min_35 int DEFAULT NULL,
  heure_14_min_40 int DEFAULT NULL,
  heure_14_min_45 int DEFAULT NULL,
  heure_14_min_50 int DEFAULT NULL,
  heure_14_min_55 int DEFAULT NULL,
  heure_14_min_60 int DEFAULT NULL,
  heure_15_min_0 int DEFAULT NULL,
  heure_15_min_5 int DEFAULT NULL,
  heure_15_min_10 int DEFAULT NULL,
  heure_15_min_15 int DEFAULT NULL,
  heure_15_min_20 int DEFAULT NULL,
  heure_15_min_25 int DEFAULT NULL,
  heure_15_min_30 int DEFAULT NULL,
  heure_15_min_35 int DEFAULT NULL,
  heure_15_min_40 int DEFAULT NULL,
  heure_15_min_45 int DEFAULT NULL,
  heure_15_min_50 int DEFAULT NULL,
  heure_15_min_55 int DEFAULT NULL,
  heure_15_min_60 int DEFAULT NULL,
  heure_16_min_0 int DEFAULT NULL,
  heure_16_min_5 int DEFAULT NULL,
  heure_16_min_10 int DEFAULT NULL,
  heure_16_min_15 int DEFAULT NULL,
  heure_16_min_20 int DEFAULT NULL,
  heure_16_min_25 int DEFAULT NULL,
  heure_16_min_30 int DEFAULT NULL,
  heure_16_min_35 int DEFAULT NULL,
  heure_16_min_40 int DEFAULT NULL,
  heure_16_min_45 int DEFAULT NULL,
  heure_16_min_50 int DEFAULT NULL,
  heure_16_min_55 int DEFAULT NULL,
  heure_16_min_60 int DEFAULT NULL,
  heure_17_min_0 int DEFAULT NULL,
  heure_17_min_5 int DEFAULT NULL,
  heure_17_min_10 int DEFAULT NULL,
  heure_17_min_15 int DEFAULT NULL,
  heure_17_min_20 int DEFAULT NULL,
  heure_17_min_25 int DEFAULT NULL,
  heure_17_min_30 int DEFAULT NULL,
  heure_17_min_35 int DEFAULT NULL,
  heure_17_min_40 int DEFAULT NULL,
  heure_17_min_45 int DEFAULT NULL,
  heure_17_min_50 int DEFAULT NULL,
  heure_17_min_55 int DEFAULT NULL,
  heure_17_min_60 int DEFAULT NULL,
  heure_18_min_0 int DEFAULT NULL,
  heure_18_min_5 int DEFAULT NULL,
  heure_18_min_10 int DEFAULT NULL,
  heure_18_min_15 int DEFAULT NULL,
  heure_18_min_20 int DEFAULT NULL,
  heure_18_min_25 int DEFAULT NULL,
  heure_18_min_30 int DEFAULT NULL,
  heure_18_min_35 int DEFAULT NULL,
  heure_18_min_40 int DEFAULT NULL,
  heure_18_min_45 int DEFAULT NULL,
  heure_18_min_50 int DEFAULT NULL,
  heure_18_min_55 int DEFAULT NULL,
  heure_18_min_60 int DEFAULT NULL,
  heure_19_min_0 int DEFAULT NULL,
  heure_19_min_5 int DEFAULT NULL,
  heure_19_min_10 int DEFAULT NULL,
  heure_19_min_15 int DEFAULT NULL,
  heure_19_min_20 int DEFAULT NULL,
  heure_19_min_25 int DEFAULT NULL,
  heure_19_min_30 int DEFAULT NULL,
  heure_19_min_35 int DEFAULT NULL,
  heure_19_min_40 int DEFAULT NULL,
  heure_19_min_45 int DEFAULT NULL,
  heure_19_min_50 int DEFAULT NULL,
  heure_19_min_55 int DEFAULT NULL,
  heure_19_min_60 int DEFAULT NULL,
  heure_20_min_0 int DEFAULT NULL,
  heure_20_min_5 int DEFAULT NULL,
  heure_20_min_10 int DEFAULT NULL,
  heure_20_min_15 int DEFAULT NULL,
  heure_20_min_20 int DEFAULT NULL,
  heure_20_min_25 int DEFAULT NULL,
  heure_20_min_30 int DEFAULT NULL,
  heure_20_min_35 int DEFAULT NULL,
  heure_20_min_40 int DEFAULT NULL,
  heure_20_min_45 int DEFAULT NULL,
  heure_20_min_50 int DEFAULT NULL,
  heure_20_min_55 int DEFAULT NULL,
  heure_20_min_60 int DEFAULT NULL,
  heure_21_min_0 int DEFAULT NULL,
  heure_21_min_5 int DEFAULT NULL,
  heure_21_min_10 int DEFAULT NULL,
  heure_21_min_15 int DEFAULT NULL,
  heure_21_min_20 int DEFAULT NULL,
  heure_21_min_25 int DEFAULT NULL,
  heure_21_min_30 int DEFAULT NULL,
  heure_21_min_35 int DEFAULT NULL,
  heure_21_min_40 int DEFAULT NULL,
  heure_21_min_45 int DEFAULT NULL,
  heure_21_min_50 int DEFAULT NULL,
  heure_21_min_55 int DEFAULT NULL,
  heure_21_min_60 int DEFAULT NULL,
  heure_22_min_0 int DEFAULT NULL,
  heure_22_min_5 int DEFAULT NULL,
  heure_22_min_10 int DEFAULT NULL,
  heure_22_min_15 int DEFAULT NULL,
  heure_22_min_20 int DEFAULT NULL,
  heure_22_min_25 int DEFAULT NULL,
  heure_22_min_30 int DEFAULT NULL,
  heure_22_min_35 int DEFAULT NULL,
  heure_22_min_40 int DEFAULT NULL,
  heure_22_min_45 int DEFAULT NULL,
  heure_22_min_50 int DEFAULT NULL,
  heure_22_min_55 int DEFAULT NULL,
  heure_22_min_60 int DEFAULT NULL,
  heure_23_min_0 int DEFAULT NULL,
  heure_23_min_5 int DEFAULT NULL,
  heure_23_min_10 int DEFAULT NULL,
  heure_23_min_15 int DEFAULT NULL,
  heure_23_min_20 int DEFAULT NULL,
  heure_23_min_25 int DEFAULT NULL,
  heure_23_min_30 int DEFAULT NULL,
  heure_23_min_35 int DEFAULT NULL,
  heure_23_min_40 int DEFAULT NULL,
  heure_23_min_45 int DEFAULT NULL,
  heure_23_min_50 int DEFAULT NULL,
  heure_23_min_55 int DEFAULT NULL,
  heure_23_min_60 int DEFAULT NULL
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `__ r63_day`
--
CREATE TABLE `__ r63_day` (
  idPrm varchar(50) DEFAULT NULL,
  dateDebut date DEFAULT NULL,
  dateFin date DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  heure_0 int DEFAULT NULL,
  heure_1 int DEFAULT NULL,
  heure_2 int DEFAULT NULL,
  heure_3 int DEFAULT NULL,
  heure_4 int DEFAULT NULL,
  heure_5 int DEFAULT NULL,
  heure_6 int DEFAULT NULL,
  heure_7 int DEFAULT NULL,
  heure_8 int DEFAULT NULL,
  heure_9 int DEFAULT NULL,
  heure_10 int DEFAULT NULL,
  heure_11 int DEFAULT NULL,
  heure_12 int DEFAULT NULL,
  heure_13 int DEFAULT NULL,
  heure_14 int DEFAULT NULL,
  heure_15 int DEFAULT NULL,
  heure_16 int DEFAULT NULL,
  heure_17 int DEFAULT NULL,
  heure_18 int DEFAULT NULL,
  heure_19 int DEFAULT NULL,
  heure_20 int DEFAULT NULL,
  heure_21 int DEFAULT NULL,
  heure_22 int DEFAULT NULL,
  heure_23 int DEFAULT NULL,
  heure_24 int DEFAULT NULL
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `__ r63_archive`
--
CREATE TABLE `__ r63_archive` (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE63 varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 57281481,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `__ calendrier_enedis`
--
CREATE TABLE `__ calendrier_enedis` (
  Calendrier_TYPE varchar(255) DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  vDATE datetime DEFAULT NULL,
  vHEURE int DEFAULT NULL,
  PTE double DEFAULT NULL,
  HPH double DEFAULT NULL,
  HCH double DEFAULT NULL,
  HPE double DEFAULT NULL,
  HCE double DEFAULT NULL,
  ARENH double DEFAULT NULL,
  Peak double DEFAULT NULL,
  `Off-Peak` double DEFAULT NULL,
  PP1 double DEFAULT NULL,
  PP2 double DEFAULT NULL,
  `OP SEM` double DEFAULT NULL,
  `OP WE` double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 157777,
AVG_ROW_LENGTH = 144,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_param`
--
CREATE TABLE tbl_param (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  code varchar(10) DEFAULT NULL,
  valeur varchar(255) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 4,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_log`
--
CREATE TABLE tbl_log (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  message varchar(255) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 3461,
AVG_ROW_LENGTH = 91,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_site_prm_ref`
--
CREATE TABLE tbl_gpt_societe_site_prm_ref (
  id_ligne int DEFAULT NULL,
  idprm mediumtext DEFAULT NULL,
  ref_type varchar(255) DEFAULT NULL,
  ref_valeur varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_site_prm_ps`
--
CREATE TABLE tbl_gpt_societe_site_prm_ps (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  id_site_migration int DEFAULT NULL,
  ID_SITE int DEFAULT NULL,
  ID_PRM_PS int DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  ct_code varchar(10) DEFAULT NULL,
  ps_unite varchar(10) DEFAULT NULL,
  ps_valeur int DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2024,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_site_prm_controle`
--
CREATE TABLE tbl_gpt_societe_site_prm_controle (
  segment varchar(255) DEFAULT NULL,
  idPRM varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  AN int DEFAULT NULL,
  MOIS int DEFAULT NULL,
  Nbre_C68 int DEFAULT NULL,
  Nbre_R67 int DEFAULT NULL,
  Nbre_R63_BRUT int DEFAULT NULL,
  Nbre_R63_BEST int DEFAULT NULL,
  Nbre_R63_p05 int DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 256,
AVG_ROW_LENGTH = 201,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_site_prm_compteurs`
--
CREATE TABLE tbl_gpt_societe_site_prm_compteurs (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  id_site_migration int DEFAULT NULL,
  ID_SITE int DEFAULT NULL,
  ID_PRM_compteur int DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  compteur_serie varchar(255) DEFAULT NULL,
  ct_1 varchar(255) DEFAULT NULL,
  ph_1 varchar(255) DEFAULT NULL,
  ct_2 varchar(255) DEFAULT NULL,
  ph_2 varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 847,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_site_prm`
--
CREATE TABLE tbl_gpt_societe_site_prm (
  TYPE_SPE varchar(20) DEFAULT NULL,
  TYPE_PDL varchar(20) DEFAULT NULL,
  ID_PRM_DEF int DEFAULT NULL,
  ID_SITE int DEFAULT NULL,
  REF_GRD varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  flag_desactif int DEFAULT NULL,
  date_desactif date DEFAULT NULL,
  id_site_migration int DEFAULT NULL,
  idPrm varchar(50) NOT NULL,
  numeroNomVoie varchar(255) DEFAULT NULL,
  codePostal varchar(255) DEFAULT NULL,
  commune varchar(255) DEFAULT NULL,
  batiment varchar(255) DEFAULT NULL,
  escalierEtageAppartement varchar(255) DEFAULT NULL,
  lieuDit varchar(255) DEFAULT NULL,
  domaineTension varchar(255) DEFAULT NULL,
  prs_valeur int DEFAULT NULL,
  prs_unite varchar(10) DEFAULT NULL,
  phc_libelle varchar(255) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  gfc_code varchar(50) DEFAULT NULL,
  ps_unite varchar(20) DEFAULT NULL,
  ps_valeur int DEFAULT NULL,
  segment varchar(10) DEFAULT NULL,
  filiereProduction varchar(255) DEFAULT NULL,
  technologie varchar(255) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime DEFAULT NULL,
  flag_calcul int DEFAULT 1,
  flag_envoi int DEFAULT 1,
  Ref_1 varchar(255) DEFAULT NULL,
  Ref_2 varchar(255) DEFAULT NULL,
  Ref_3 varchar(255) DEFAULT NULL,
  Ref_4 varchar(255) DEFAULT NULL,
  Ref_5 varchar(255) DEFAULT NULL,
  Id_1 varchar(255) DEFAULT NULL,
  Id_2 varchar(255) DEFAULT NULL,
  Id_3 varchar(255) DEFAULT NULL,
  Id_4 varchar(255) DEFAULT NULL,
  Id_5 varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT CURRENT_TIMESTAMP,
  date_update datetime DEFAULT NULL,
  date_delete datetime DEFAULT NULL,
  ref_certifie varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2505,
AVG_ROW_LENGTH = 136,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `idPrm` on table `tbl_gpt_societe_site_prm`
--
ALTER TABLE tbl_gpt_societe_site_prm
ADD UNIQUE INDEX idPrm (idPrm);

--
-- Create table `tbl_gpt_societe_papers`
--
CREATE TABLE tbl_gpt_societe_papers (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  REF_STATUT varchar(255) DEFAULT NULL,
  REF_TYPE varchar(255) DEFAULT NULL,
  TYPE_ETABLISSEMENT varchar(255) DEFAULT NULL,
  TYPE_ENERGIE varchar(255) DEFAULT NULL,
  ID_GPT int DEFAULT NULL,
  ID_SOCIETE_tmp int DEFAULT NULL,
  SOCIETE varchar(255) DEFAULT NULL,
  SOCIETE_SITE varchar(255) DEFAULT NULL,
  SIREN varchar(255) DEFAULT NULL,
  SIRET varchar(255) DEFAULT NULL,
  pap_FORME_JURIDIQUE varchar(255) DEFAULT NULL,
  pap_RCS varchar(255) DEFAULT NULL,
  `pap_NAF-APE` varchar(255) DEFAULT NULL,
  pap_DATE_CREATION_ENTREPRISE varchar(255) DEFAULT NULL,
  `pap_OBJET _SOCIAL` varchar(255) DEFAULT NULL,
  pap_CAPITAL_SOCIAL varchar(255) DEFAULT NULL,
  pap_TVA_INTRA varchar(255) DEFAULT NULL,
  ADRESSE varchar(255) DEFAULT NULL,
  CP varchar(255) DEFAULT NULL,
  VILLE varchar(255) DEFAULT NULL,
  INSEE varchar(255) DEFAULT NULL,
  Flag_SITE bit(1) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 13,
AVG_ROW_LENGTH = 3640,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_mandat_site`
--
CREATE TABLE tbl_gpt_societe_mandat_site (
  ID_SITE int DEFAULT NULL,
  ID_MANDAT int DEFAULT NULL,
  ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  flag_select tinyint(1) DEFAULT NULL,
  PRIMARY KEY (ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 8496,
AVG_ROW_LENGTH = 49,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_contact_nl`
--
CREATE TABLE tbl_gpt_societe_contact_nl (
  id_contact int DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  HEBDO int DEFAULT NULL,
  `ELEC-TERME` int DEFAULT NULL,
  `GAZ-TERME` int DEFAULT NULL,
  `ELEC-SPOT` int DEFAULT NULL,
  `GAZ-SPOT` int DEFAULT NULL,
  TURPE int DEFAULT NULL,
  PREFAC int DEFAULT NULL,
  MANDAT int DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 13,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_contact_n`
--
CREATE TABLE tbl_gpt_societe_contact_n (
  id_contact int DEFAULT NULL,
  type_N varchar(255) DEFAULT NULL,
  type_ID int DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  FONCTION varchar(255) DEFAULT NULL,
  date_add date DEFAULT NULL,
  date_update date DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 257,
AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tbl_gpt_societe_contact`
--
CREATE TABLE tbl_gpt_societe_contact (
  ORIGINE varchar(255) DEFAULT NULL,
  TITRE varchar(255) DEFAULT NULL,
  FONCTION varchar(255) DEFAULT NULL,
  CIVILITE varchar(255) DEFAULT NULL,
  ID_CONTACT int UNSIGNED NOT NULL AUTO_INCREMENT,
  NOM varchar(255) DEFAULT NULL,
  PRENOM varchar(255) DEFAULT NULL,
  TEL_01 varchar(255) DEFAULT NULL,
  TEL_02 varchar(255) DEFAULT NULL,
  EMAIL varchar(255) DEFAULT NULL,
  ID_SOCIETE int DEFAULT NULL,
  ID_SITE int DEFAULT NULL,
  ID_GPT int DEFAULT NULL,
  ADRESSE varchar(255) DEFAULT NULL,
  CP varchar(255) DEFAULT NULL,
  VILLE varchar(255) DEFAULT NULL,
  EMAIL2 varchar(255) DEFAULT NULL,
  NOM_SOCIETE_LIBRE varchar(255) DEFAULT NULL,
  NOTES text DEFAULT NULL,
  date_add datetime DEFAULT NULL,
  date_update datetime DEFAULT NULL,
  PRIMARY KEY (ID_CONTACT)
)
ENGINE = INNODB,
AUTO_INCREMENT = 1163,
AVG_ROW_LENGTH = 226,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tarif_turpe_col`
--
CREATE TABLE tarif_turpe_col (
  TYPE_TARIF varchar(255) DEFAULT NULL,
  CLASSE_TEMPORELLE varchar(255) DEFAULT NULL,
  DEPASSEMENT_type varchar(255) DEFAULT NULL,
  PRIME_FIXE_unite varchar(255) DEFAULT NULL,
  SOUTIRAGE_unite varchar(255) DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  ANNEE_TURPE datetime DEFAULT NULL,
  AN int DEFAULT NULL,
  FTA_TURPE varchar(255) DEFAULT NULL,
  Composante_gestion double DEFAULT NULL,
  Composante_comptage double DEFAULT NULL,
  Prime_Fixe double DEFAULT NULL,
  SOUTIRAGE double DEFAULT NULL,
  CTA_Pourcentage double DEFAULT NULL,
  Depassements double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2,
AVG_ROW_LENGTH = 420,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tarif_turpe`
--
CREATE TABLE tarif_turpe (
  TYPE_TARIF varchar(255) DEFAULT NULL,
  DEPASSEMENT_type varchar(255) DEFAULT NULL,
  PRIME_FIXE_unite varchar(255) DEFAULT NULL,
  SOUTIRAGE_unite varchar(255) DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  ANNEE_TURPE datetime DEFAULT NULL,
  AN int DEFAULT NULL,
  FTA_TURPE varchar(255) DEFAULT NULL,
  Composante_gestion double DEFAULT NULL,
  Composante_comptage double DEFAULT NULL,
  Prime_Fixe_Base double DEFAULT NULL,
  Prime_Fixe_PTE double DEFAULT NULL,
  Prime_Fixe_HP double DEFAULT NULL,
  Prime_Fixe_HC double DEFAULT NULL,
  Prime_Fixe_HPH double DEFAULT NULL,
  Prime_Fixe_HCH double DEFAULT NULL,
  Prime_Fixe_HPE double DEFAULT NULL,
  Prime_Fixe_HCE double DEFAULT NULL,
  SOUTIRAGE_Base double DEFAULT NULL,
  SOUTIRAGE_PTE double DEFAULT NULL,
  SOUTIRAGE_HP double DEFAULT NULL,
  SOUTIRAGE_HC double DEFAULT NULL,
  SOUTIRAGE_HPH double DEFAULT NULL,
  SOUTIRAGE_HCH double DEFAULT NULL,
  SOUTIRAGE_HPE double DEFAULT NULL,
  SOUTIRAGE_HCE double DEFAULT NULL,
  CTA_Pourcentage double DEFAULT NULL,
  Depassements_PTE double DEFAULT NULL,
  Depassements_HPH double DEFAULT NULL,
  Depassements_HCH double DEFAULT NULL,
  Depassements_HPE double DEFAULT NULL,
  Depassements_HCE double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 45,
AVG_ROW_LENGTH = 420,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `tarif_fournisseur`
--
CREATE TABLE tarif_fournisseur (
  ANNEE int DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  PRM double DEFAULT NULL,
  Debut_contrat varchar(255) DEFAULT NULL,
  Fin_contrat datetime DEFAULT NULL,
  Fournisseur varchar(255) DEFAULT NULL,
  `ENERGIE_ACTIVE_Abonnement_€-Mois` double DEFAULT NULL,
  `ENERGIE_ACTIVE_PTE_€-MWh` double DEFAULT NULL,
  `ENERGIE_ACTIVE_HPH_€-MWh` double DEFAULT NULL,
  `ENERGIE_ACTIVE_HCH_€-MWh` double DEFAULT NULL,
  `ENERGIE_ACTIVE_HPE_€-MWh` double DEFAULT NULL,
  `ENERGIE_ACTIVE_HCE_€-MWh` double DEFAULT NULL,
  `ENERGIE_ACTIVE_CCRR_€-MWh` double DEFAULT NULL,
  GARANTIES_CAPACITE_PTE double DEFAULT NULL,
  GARANTIES_CAPACITE_HPH double DEFAULT NULL,
  GARANTIES_CAPACITE_HCH double DEFAULT NULL,
  GARANTIES_CAPACITE_HPE double DEFAULT NULL,
  GARANTIES_CAPACITE_HCE double DEFAULT NULL,
  Puissance_PP1_kW double DEFAULT NULL,
  Puissance_Coef_Secu double DEFAULT NULL,
  GARANTIES_CAPACITE_OC_kW double DEFAULT NULL,
  `GARANTIES_CAPACITE_Fee_€-MWh` double DEFAULT NULL,
  `GARANTIES_CAPACITE_Regul_€-MWh` double DEFAULT NULL,
  `GARANTIES_CAPACITE_Forfait_€-mois` double DEFAULT NULL,
  `GARANTIES_CAPACITE_Forfait_€-MWh` double DEFAULT NULL,
  ARENH_Pmoy_kW double DEFAULT NULL,
  ARENH_Pourcentage double DEFAULT NULL,
  `ARENH_Regul_€-MWh` double DEFAULT NULL,
  `PRMF_€-MW` double DEFAULT NULL,
  `ARENH_Bonus_€-MWh` double DEFAULT NULL,
  `GO_€-MWh` double DEFAULT NULL,
  `C2E_€-MWh` double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 847,
AVG_ROW_LENGTH = 251,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `sys_docusign_spool`
--
CREATE TABLE sys_docusign_spool (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  client_email varchar(255) DEFAULT NULL,
  client_nom varchar(255) DEFAULT NULL,
  cc_email varchar(255) DEFAULT NULL,
  cc_nom varchar(255) DEFAULT NULL,
  fichier_nom varchar(255) DEFAULT NULL,
  date_traitement datetime DEFAULT NULL,
  sign_id_enveloppe varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 4,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb3,
COLLATE utf8mb3_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `sys_demande_detail_log`
--
CREATE TABLE sys_demande_detail_log (
  type_flux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idprm varchar(20) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  Nbre int DEFAULT NULL,
  date_ajout datetime DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 557,
AVG_ROW_LENGTH = 120,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_sys_demande_detail_idDemande_log` on table `sys_demande_detail_log`
--
ALTER TABLE sys_demande_detail_log
ADD INDEX IDX_sys_demande_detail_idDemande_log (idDemande);

--
-- Create index `IDX_sys_demande_detail_idprm_log` on table `sys_demande_detail_log`
--
ALTER TABLE sys_demande_detail_log
ADD INDEX IDX_sys_demande_detail_idprm_log (idprm);

--
-- Create table `sys_demande_detail`
--
CREATE TABLE sys_demande_detail (
  type_flux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idprm varchar(20) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  Nbre int DEFAULT NULL,
  date_ajout datetime DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 28289,
AVG_ROW_LENGTH = 82,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_sys_demande_detail_idDemande` on table `sys_demande_detail`
--
ALTER TABLE sys_demande_detail
ADD INDEX IDX_sys_demande_detail_idDemande (idDemande);

--
-- Create index `IDX_sys_demande_detail_idprm` on table `sys_demande_detail`
--
ALTER TABLE sys_demande_detail
ADD INDEX IDX_sys_demande_detail_idprm (idprm);

--
-- Create table `sys_demande`
--
CREATE TABLE sys_demande (
  segment_demande varchar(10) DEFAULT NULL,
  type_flux varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  date_demande datetime DEFAULT NULL,
  idDemande varchar(255) DEFAULT NULL,
  periode_deb datetime DEFAULT NULL,
  periode_fin datetime DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 5,
AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `scrapp_epex`
--
CREATE TABLE scrapp_epex (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  date_epex date DEFAULT NULL,
  heure int DEFAULT NULL,
  buy_volume decimal(10, 2) DEFAULT NULL,
  sell_volume decimal(10, 2) DEFAULT NULL,
  volume decimal(10, 2) DEFAULT NULL,
  price decimal(10, 2) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_tva`
--
CREATE TABLE ref_tva (
  TVA_id int DEFAULT NULL,
  TVA_taux_LIB varchar(255) DEFAULT NULL,
  TVA_taux_valeur double DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_titre`
--
CREATE TABLE ref_titre (
  TITRE varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_statut_local`
--
CREATE TABLE ref_statut_local (
  Lib_statut varchar(255) NOT NULL,
  PRIMARY KEY (Lib_statut)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1092,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_pdl`
--
CREATE TABLE ref_pdl (
  TYPE_PDL varchar(20) NOT NULL,
  PRIMARY KEY (TYPE_PDL)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_naf`
--
CREATE TABLE ref_naf (
  NAF_CODE varchar(30) NOT NULL,
  NAF_LIBELLE varchar(50) DEFAULT NULL,
  NAF_PK int DEFAULT NULL,
  NAF_ETAT bit(1) DEFAULT NULL,
  NAF_USER varchar(20) DEFAULT NULL,
  NAF_DATECREATE datetime DEFAULT NULL,
  NAF_DATEMODIF datetime DEFAULT NULL,
  LIB_SECTION varchar(255) DEFAULT NULL,
  PRIMARY KEY (NAF_CODE)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 135,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_mode_reglement`
--
CREATE TABLE ref_mode_reglement (
  ID_Reglement int DEFAULT NULL,
  CODE_Reglement varchar(255) DEFAULT NULL,
  LIB_Reglement varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2730,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_mandat`
--
CREATE TABLE ref_mandat (
  HISTORIQUE_ON varchar(255) DEFAULT NULL,
  TYPE_ENERGIE varchar(20) DEFAULT NULL,
  Type_mandat varchar(255) DEFAULT NULL,
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  Libelle_mandat varchar(255) DEFAULT NULL,
  Fichier_mandat varchar(255) DEFAULT NULL,
  Chemin_mandat_template varchar(255) DEFAULT NULL,
  Chemin_sortie varchar(255) DEFAULT NULL,
  Abreviation_mandat varchar(255) DEFAULT NULL,
  Edition_mandat_template varchar(255) DEFAULT NULL,
  phrase_autorisation text DEFAULT NULL,
  phrase_signature text DEFAULT NULL,
  phrase_mail text DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 33,
AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_grd_type_mandat`
--
CREATE TABLE ref_grd_type_mandat (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  ref_GRD varchar(255) DEFAULT NULL,
  ID_ref_mandat int DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 16,
AVG_ROW_LENGTH = 1489,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_grd_commune`
--
CREATE TABLE ref_grd_commune (
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  commune varchar(255) DEFAULT NULL,
  Region varchar(255) DEFAULT NULL,
  Departement varchar(255) DEFAULT NULL,
  Code_INSEE varchar(255) DEFAULT NULL,
  Code_Postal varchar(255) DEFAULT NULL,
  GRD_Elec varchar(255) DEFAULT NULL,
  GRD_Elec_EIC varchar(255) DEFAULT NULL,
  GRD_Gaz varchar(255) DEFAULT NULL,
  GRD_Gaz_EIC varchar(255) DEFAULT NULL,
  Code_GRD_Elec1 varchar(255) DEFAULT NULL,
  `Code_GRD_ Elec 2` varchar(255) DEFAULT NULL,
  Code_GRD_Gaz varchar(255) DEFAULT NULL,
  `Code_GRD_Gaz 2` varchar(255) DEFAULT NULL,
  EPCI varchar(255) DEFAULT NULL,
  Code_dept varchar(255) DEFAULT NULL,
  Code_region varchar(255) DEFAULT NULL,
  Libelle_EPCI varchar(255) DEFAULT NULL,
  code_insee_commune_1 varchar(255) DEFAULT NULL,
  code_insee_commune_2 varchar(255) DEFAULT NULL,
  Commune_fusionnee varchar(255) DEFAULT NULL,
  GRD_Join varchar(255) DEFAULT NULL,
  GRD_EIC_Join varchar(255) DEFAULT NULL,
  grd_elec_2_eic varchar(255) DEFAULT NULL,
  geom mediumtext DEFAULT NULL,
  geo_point_2d varchar(255) DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 35001,
AVG_ROW_LENGTH = 12451,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_grd`
--
CREATE TABLE ref_grd (
  TYPE_ENERGIE varchar(20) DEFAULT 'ELEC',
  TYPE_PDL varchar(20) DEFAULT NULL,
  REF_GRD varchar(255) NOT NULL,
  ACTIF_ON tinyint(1) DEFAULT 0,
  HISTORIQUE_ON tinyint(1) DEFAULT 0,
  PRIMARY KEY (REF_GRD)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2978,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_fonction`
--
CREATE TABLE ref_fonction (
  FONCTION varchar(255) NOT NULL,
  PRIMARY KEY (FONCTION)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_cp_ville`
--
CREATE TABLE ref_cp_ville (
  id_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  Code_commune_INSEE varchar(255) DEFAULT NULL,
  Nom_de_la_commune varchar(255) DEFAULT NULL,
  Code_postal varchar(255) DEFAULT NULL,
  Libellé_d_acheminement varchar(255) DEFAULT NULL,
  PRIMARY KEY (id_ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 39193,
AVG_ROW_LENGTH = 73,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `Code_commune_INSEE` on table `ref_cp_ville`
--
ALTER TABLE ref_cp_ville
ADD UNIQUE INDEX Code_commune_INSEE (Code_commune_INSEE);

--
-- Create table `ref_cp_departements`
--
CREATE TABLE ref_cp_departements (
  id_ligne int DEFAULT NULL,
  DP_IDDP int DEFAULT NULL,
  DP_CP varchar(2) DEFAULT NULL,
  DP_LIBDEP varchar(25) DEFAULT NULL,
  DP_CODEREGION varchar(30) DEFAULT NULL,
  DP_CHEFLIEU varchar(35) DEFAULT NULL,
  DP_IDUSER varchar(30) DEFAULT NULL,
  DP_DATECREATE datetime DEFAULT NULL,
  DP_DATEMODIF datetime DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 167,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_condition_paiement`
--
CREATE TABLE ref_condition_paiement (
  PAIEMENT_CODE_CONDITION varchar(255) DEFAULT NULL,
  PAIEMENT_LIB_CONDITION varchar(255) DEFAULT NULL,
  PAIEMENT_date int DEFAULT NULL,
  PAIEMENT_Nbre_Jour int DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `ref_classe_temporelle`
--
CREATE TABLE ref_classe_temporelle (
  `Couplage TT` varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `rcxx_log_add`
--
CREATE TABLE rcxx_log_add (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  TYPE varchar(255) DEFAULT NULL,
  NBRE_RCxx varchar(255) DEFAULT NULL,
  date_add datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 3289,
AVG_ROW_LENGTH = 57,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `r67_archive`
--
CREATE TABLE r67_archive (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(10) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures_groupe varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  contexte_groupe varchar(255) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  idMotifReleve varchar(20) DEFAULT NULL,
  libelleMotifReleve varchar(255) DEFAULT NULL,
  grandeur_groupe varchar(10) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  calendrier_groupe varchar(10) DEFAULT NULL,
  libelleGrille varchar(50) DEFAULT NULL,
  libelleCalendrier varchar(50) DEFAULT NULL,
  classeTemporelle_groupe varchar(10) DEFAULT NULL,
  idClasseTemporelle varchar(20) DEFAULT NULL,
  libelleClasseTemporelle varchar(255) DEFAULT NULL,
  quantite_groupe varchar(10) DEFAULT NULL,
  dateCreation datetime DEFAULT NULL,
  dbtMesure date DEFAULT NULL,
  finMesure date DEFAULT NULL,
  quantite bigint DEFAULT NULL,
  libelleNature varchar(50) DEFAULT NULL,
  libelleStatut varchar(50) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE67 varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 769415,
AVG_ROW_LENGTH = 529,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `r63_test`
--
CREATE TABLE r63_test (
  id int UNSIGNED NOT NULL,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CLE63 varchar(255) NOT NULL,
  CLE63_indice varchar(255) DEFAULT NULL,
  PRIMARY KEY (CLE63)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_CLE63_test` on table `r63_test`
--
ALTER TABLE r63_test
ADD INDEX IDX_c63_CLE63_test (CLE63);

--
-- Create index `IDX_c63_etapeMetier_test` on table `r63_test`
--
ALTER TABLE r63_test
ADD INDEX IDX_c63_etapeMetier_test (etapeMetier);

--
-- Create index `IDX_c63_idPrm_test` on table `r63_test`
--
ALTER TABLE r63_test
ADD INDEX IDX_c63_idPrm_test (idPrm, CLE63);

--
-- Create index `IDX_c63_tmp_idPrm_test` on table `r63_test`
--
ALTER TABLE r63_test
ADD INDEX IDX_c63_tmp_idPrm_test (idPrm);

--
-- Create table `r63_moyenne`
--
CREATE TABLE r63_moyenne (
  id_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  vDate date DEFAULT NULL,
  vJour int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  vAN int DEFAULT NULL,
  vHeure int DEFAULT NULL,
  MOY int DEFAULT NULL,
  MAX int DEFAULT NULL,
  MIN int DEFAULT NULL,
  CLE63MOY varchar(255) DEFAULT NULL,
  PRIMARY KEY (id_ligne)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 85,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_c63_moyenne_idPrm` on table `r63_moyenne`
--
ALTER TABLE r63_moyenne
ADD INDEX IDX_c63_moyenne_idPrm (idPrm);

--
-- Create table `r63_minute_p05`
--
CREATE TABLE r63_minute_p05 (
  CLE63PXX varchar(255) DEFAULT NULL,
  segment varchar(255) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  vAN int DEFAULT NULL,
  vMOIS int DEFAULT NULL,
  vDATE date DEFAULT NULL,
  vDATE_HEURE datetime DEFAULT NULL,
  vJOUR int DEFAULT NULL,
  vHEURE int DEFAULT NULL,
  vMINUTE int DEFAULT NULL,
  vVALEUR int DEFAULT NULL,
  CT varchar(10) DEFAULT NULL,
  CT_type varchar(1) DEFAULT NULL,
  heure_0_min_0 int DEFAULT NULL,
  `0_min_5` int DEFAULT NULL,
  `5_min_10` int DEFAULT NULL,
  `10_min_15` int DEFAULT NULL,
  `15_min_20` int DEFAULT NULL,
  `20_min_25` int DEFAULT NULL,
  `25_min_30` int DEFAULT NULL,
  `30_min_35` int DEFAULT NULL,
  `35_min_40` int DEFAULT NULL,
  `40_min_45` int DEFAULT NULL,
  `45_min_50` int DEFAULT NULL,
  `50_min_55` int DEFAULT NULL,
  `55_min_60` int DEFAULT NULL,
  vP05 int DEFAULT NULL,
  vP10 int DEFAULT NULL,
  vP15 int DEFAULT NULL,
  vP30 int DEFAULT NULL,
  vP60 int DEFAULT NULL,
  vAVG int DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 213,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `r63_comparaison_ct`
--
CREATE TABLE r63_comparaison_ct (
  ID int DEFAULT NULL,
  Date_mesure datetime DEFAULT NULL,
  Fin_mesure datetime DEFAULT NULL,
  Valeur double DEFAULT NULL,
  Jour datetime DEFAULT NULL,
  Férie varchar(255) DEFAULT NULL,
  Saison varchar(255) DEFAULT NULL,
  Début_mesure varchar(255) DEFAULT NULL,
  CLEX varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 74,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_r63_comparaison_ct_CLEX` on table `r63_comparaison_ct`
--
ALTER TABLE r63_comparaison_ct
ADD INDEX IDX_r63_comparaison_ct_CLEX (CLEX);

--
-- Create table `prefac_histo_archive_detail`
--
CREATE TABLE prefac_histo_archive_detail (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPRM varchar(50) DEFAULT NULL,
  DATE_HEURE datetime DEFAULT NULL,
  PTE double DEFAULT 0,
  HPH double DEFAULT 0,
  HCH double DEFAULT 0,
  HPE double DEFAULT 0,
  HCE double DEFAULT 0,
  PS_PTE double DEFAULT 0,
  PS_HPH double DEFAULT 0,
  PS_HCH double DEFAULT 0,
  PS_HPE double DEFAULT 0,
  PS_HCE double DEFAULT 0,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 15336,
AVG_ROW_LENGTH = 171,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `prefac_histo_archive`
--
CREATE TABLE prefac_histo_archive (
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  PRM varchar(50) DEFAULT NULL,
  Segment varchar(255) DEFAULT NULL,
  Années int DEFAULT NULL,
  Mois int DEFAULT NULL,
  Date_Releve_Debut datetime DEFAULT NULL,
  Date_Releve_Fin datetime DEFAULT NULL,
  FTA_code varchar(255) DEFAULT NULL,
  PS_PTE int DEFAULT NULL,
  PS_HPH int DEFAULT NULL,
  PS_HCH int DEFAULT NULL,
  PS_HPE int DEFAULT NULL,
  PS_HCE int DEFAULT NULL,
  Conso_Total int DEFAULT NULL,
  Conso_PTE int DEFAULT NULL,
  Conso_HPH int DEFAULT NULL,
  Conso_HCH int DEFAULT NULL,
  Conso_HPE int DEFAULT NULL,
  Conso_HCE int DEFAULT NULL,
  `Conso_Peak_Hiver_Q1-Q4` double DEFAULT NULL,
  `Conso-Off-Peak Hiver_Q1-Q4` double DEFAULT NULL,
  `Conso_Peak_Eté_Q2-Q3` double DEFAULT NULL,
  `Conso_Off-Peak_Eté_Q2-Q3` double DEFAULT NULL,
  Dep_Quad_PTE int DEFAULT NULL,
  Dep_Quad_HPH int DEFAULT NULL,
  Dep_Quad_HCH int DEFAULT NULL,
  Dep_Quad_HPE int DEFAULT NULL,
  Dep_Quad_HCE int DEFAULT NULL,
  Dep_Quad_Total int DEFAULT NULL,
  Cout_Fixe_Acheminement_PTE double DEFAULT NULL,
  Cout_Fixe_Acheminement_HPH double DEFAULT NULL,
  Cout_Fixe_Acheminement_HCH double DEFAULT NULL,
  Cout_Fixe_Acheminement_HPE double DEFAULT NULL,
  Cout_Fixe_Acheminement_HCE double DEFAULT NULL,
  Composante_Gestion double DEFAULT NULL,
  Composante_Comptage double DEFAULT NULL,
  Prime_Fixe double DEFAULT NULL,
  C_Gestion_par_Mois double DEFAULT NULL,
  C_Comptage_par_Mois double DEFAULT NULL,
  Prime_Fixe_Mois double DEFAULT NULL,
  CTA_Mois double DEFAULT NULL,
  Couts_Fixes_par_Mois double DEFAULT NULL,
  Couts_Soutirage_PTE double DEFAULT NULL,
  Couts_Soutirage_HPH double DEFAULT NULL,
  Couts_Soutirage_HCH double DEFAULT NULL,
  Couts_Soutirage_HPE double DEFAULT NULL,
  Couts_Soutirage_HCE double DEFAULT NULL,
  Cout_Dep_Quad_PTE int DEFAULT NULL,
  Cout_Dep_Quad_HPH int DEFAULT NULL,
  Cout_Dep_Quad_HCH double DEFAULT NULL,
  Cout_Dep_Quad_HPE double DEFAULT NULL,
  Cout_Dep_Quad_HCE double DEFAULT NULL,
  Cout_Dep_Quad_Total double DEFAULT NULL,
  `Couts-Energie-Active_Abonnement` int DEFAULT NULL,
  `Couts-Energie-Active_PTE` double DEFAULT NULL,
  `Couts-Energie-Active_HPH` double DEFAULT NULL,
  `Couts-Energie-Active_HCH` double DEFAULT NULL,
  `Couts-Energie-Active_HPE` double DEFAULT NULL,
  `Couts-Energie-Active_HCE` double DEFAULT NULL,
  `Couts-Energie-Active_Peak Hiver_Q1-Q4_` int DEFAULT NULL,
  `Couts-Energie-Active_Off-Peak_Hiver_Q1-Q4` int DEFAULT NULL,
  `Couts-Energie-Active_Peak_Eté_Q2-Q3` int DEFAULT NULL,
  `Couts-Energie-Active_Off-Peak_Eté_Q2-Q3` int DEFAULT NULL,
  `Couts-Energie-Active_Bloc_Spot` int DEFAULT NULL,
  `Couts-Energie-Active_Arenh_Bonus_Malus` int DEFAULT NULL,
  Garantie_Origine double DEFAULT NULL,
  C2E int DEFAULT NULL,
  Garanties_Capacite_Coeff_PTE double DEFAULT NULL,
  Garanties_Capacite_Coeff_HPH double DEFAULT NULL,
  Garanties_Capacite_Coeff_HCH int DEFAULT NULL,
  Garanties_Capacite_Coeff_HPE int DEFAULT NULL,
  Garanties_Capacite_Coeff_HCE int DEFAULT NULL,
  CS double DEFAULT NULL,
  PRMC double DEFAULT NULL,
  Garanties_Capacite_Prix_PTE double DEFAULT NULL,
  Garanties_Capacite_Prix_HPH double DEFAULT NULL,
  Garanties_Capacite_Prix_HCH int DEFAULT NULL,
  Garanties_Capacite_Prix_HPE int DEFAULT NULL,
  Garanties_Capacite_Prix_HCE int DEFAULT NULL,
  `Garanties_Capacite_Prix_Peak_Hiver_Q1-Q4` double DEFAULT NULL,
  `Garanties_Capacite_Prix_Off-Peak_Hiver_Q1-Q4` int DEFAULT NULL,
  `Garanties_Capacite_Prix_Peak_Eté_Q2-Q3` int DEFAULT NULL,
  `Garanties_Capacite_Prix_Off-Peak_Eté_Q2-Q3` int DEFAULT NULL,
  Garanties_Capacite_Prix_Forfait_annuel int DEFAULT NULL,
  Garanties_Capacite_Prix_Forfait_Mensuel int DEFAULT NULL,
  Garanties_Capacite_Prix_Total double DEFAULT NULL,
  TCCFE int DEFAULT NULL,
  TDCFE int DEFAULT NULL,
  TICFE_Régime varchar(255) DEFAULT NULL,
  TICFE_Taux double DEFAULT NULL,
  Budget_Acheminement_Composante_Gestion double DEFAULT NULL,
  Budget_Acheminement_Composante_Comptage double DEFAULT NULL,
  Budget_Acheminement_Prime_fixe double DEFAULT NULL,
  Budget_Acheminement_Soutirage double DEFAULT NULL,
  Budget_Acheminement_Depassements double DEFAULT NULL,
  Budget_Acheminement_CTA int DEFAULT NULL,
  Budget_Acheminement_TURPE double DEFAULT NULL,
  `Budget_Acheminement_en_€/MWh` double DEFAULT NULL,
  Resultat_Abonnement double DEFAULT NULL,
  `Resultat_Energie-Active` int DEFAULT NULL,
  Resultat_Regul_Arenh double DEFAULT NULL,
  Resultat_Garantie_Origine int DEFAULT NULL,
  Resultat_Composante_C2E double DEFAULT NULL,
  Resultat_Garanties_capacité int DEFAULT NULL,
  Resultat_Energie_et_Capacite_Total double DEFAULT NULL,
  Resultat_Accise_TICFE double DEFAULT NULL,
  Resultat_Total_HTVA double DEFAULT NULL,
  Champ108 double DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 15808,
AVG_ROW_LENGTH = 800,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `prefac_bloc`
--
CREATE TABLE prefac_bloc (
  FTA_code varchar(255) DEFAULT NULL,
  AN int DEFAULT NULL,
  AN_b int DEFAULT NULL,
  MOIS int DEFAULT NULL,
  idPrm varchar(255) DEFAULT NULL,
  item_detail varchar(255) DEFAULT NULL,
  type_detail varchar(255) DEFAULT NULL,
  id_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  id_ordre int DEFAULT NULL,
  Pointe double DEFAULT NULL,
  HPH double DEFAULT NULL,
  HCH double DEFAULT NULL,
  HPE double DEFAULT NULL,
  HCE double DEFAULT NULL,
  P_REDUITE double DEFAULT NULL,
  TOTAUX varchar(255) DEFAULT NULL,
  PRIX_MOYEN double DEFAULT NULL,
  PRIMARY KEY (id_ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 4,
AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `data_import_prm_bulk`
--
CREATE TABLE data_import_prm_bulk (
  SIREN varchar(255) DEFAULT NULL,
  ETABLISSEMENT varchar(255) DEFAULT NULL,
  SITE varchar(255) DEFAULT NULL,
  SIRET varchar(255) DEFAULT NULL,
  ADRESSE varchar(255) DEFAULT NULL,
  CP varchar(255) DEFAULT NULL,
  VILLE varchar(255) DEFAULT NULL,
  IDPRM varchar(255) DEFAULT NULL,
  TYPE varchar(255) DEFAULT NULL,
  GRD varchar(255) DEFAULT NULL,
  REF1 varchar(255) DEFAULT NULL,
  ID1 varchar(255) DEFAULT NULL,
  REF2 varchar(255) DEFAULT NULL,
  ID2 varchar(255) DEFAULT NULL,
  REF3 varchar(255) DEFAULT NULL,
  ID3 varchar(255) DEFAULT NULL,
  REF4 varchar(255) DEFAULT NULL,
  ID4 varchar(255) DEFAULT NULL,
  REF5 varchar(255) DEFAULT NULL,
  ID5 varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 83,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `consult_c63`
--
CREATE TABLE consult_c63 (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  header varchar(20) DEFAULT NULL,
  siDemandeur varchar(50) DEFAULT NULL,
  typeDestinataire varchar(50) DEFAULT NULL,
  idDestinataire varchar(50) DEFAULT NULL,
  codeFlux varchar(10) DEFAULT NULL,
  idDemande varchar(50) DEFAULT NULL,
  modePublication varchar(20) DEFAULT NULL,
  idCanalContact varchar(20) DEFAULT NULL,
  publicationCrp varchar(10) DEFAULT NULL,
  format varchar(10) DEFAULT NULL,
  mesures varchar(10) DEFAULT NULL,
  idPrm varchar(50) DEFAULT NULL,
  etapeMetier varchar(20) DEFAULT NULL,
  periode varchar(10) DEFAULT NULL,
  dateDebut datetime DEFAULT NULL,
  dateFin datetime DEFAULT NULL,
  modeCalcul varchar(20) DEFAULT NULL,
  grandeur varchar(20) DEFAULT NULL,
  grandeurMetier varchar(20) DEFAULT NULL,
  grandeurPhysique varchar(20) DEFAULT NULL,
  unite varchar(10) DEFAULT NULL,
  points varchar(10) DEFAULT NULL,
  v int DEFAULT NULL,
  d datetime DEFAULT NULL,
  p varchar(10) DEFAULT NULL,
  n varchar(10) DEFAULT NULL,
  iv varchar(10) DEFAULT NULL,
  ec varchar(10) DEFAULT NULL,
  fichier varchar(100) DEFAULT NULL,
  date_creation datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 170,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `cdcp05_histo`
--
CREATE TABLE cdcp05_histo (
  ID int DEFAULT NULL,
  Date_mesure datetime DEFAULT NULL,
  `Début mesure` datetime DEFAULT NULL,
  Fin_mesure time DEFAULT NULL,
  Valeur double DEFAULT NULL,
  Type_Heure varchar(255) DEFAULT NULL,
  Mois double DEFAULT NULL,
  Jour double DEFAULT NULL,
  vP05 double DEFAULT NULL,
  `vP10-OK` double DEFAULT NULL,
  vP10 double DEFAULT NULL,
  `vP15-OK` double DEFAULT NULL,
  vP15 double DEFAULT NULL,
  `vP30-OK` double DEFAULT NULL,
  vP30 double DEFAULT NULL,
  `vP60-OK` double DEFAULT NULL,
  Champ19 double DEFAULT NULL,
  vP60 double DEFAULT NULL,
  Champ21 datetime DEFAULT NULL,
  Férié varchar(255) DEFAULT NULL,
  Saison varchar(255) DEFAULT NULL,
  Champ24 varchar(255) NOT NULL,
  TURPE varchar(255) NOT NULL,
  Champ26 double NOT NULL,
  PTE_Etat varchar(255) NOT NULL,
  HP_Type varchar(255) DEFAULT NULL,
  HC_Type varchar(255) DEFAULT NULL,
  Champ30 varchar(255) DEFAULT NULL,
  Champ31 varchar(255) DEFAULT NULL,
  Champ32 varchar(255) DEFAULT NULL,
  date datetime DEFAULT NULL,
  annee double DEFAULT NULL,
  zone varchar(255) DEFAULT NULL,
  nom_jour_ferie varchar(255) DEFAULT NULL,
  CLE_histo varchar(255) DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 217,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_cdcp05_histo_CLE_histo` on table `cdcp05_histo`
--
ALTER TABLE cdcp05_histo
ADD INDEX IDX_cdcp05_histo_CLE_histo (CLE_histo);

--
-- Create table `calendrier_jours_feries`
--
CREATE TABLE calendrier_jours_feries (
  ID int UNSIGNED NOT NULL AUTO_INCREMENT,
  date datetime DEFAULT NULL,
  nom_jour_ferie varchar(255) DEFAULT NULL,
  annee double DEFAULT NULL,
  zone varchar(255) DEFAULT NULL,
  CT_JF varchar(255) DEFAULT NULL,
  PRIMARY KEY (ID)
)
ENGINE = INNODB,
AUTO_INCREMENT = 96,
AVG_ROW_LENGTH = 1489,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `calendrier_enedis_col`
--
CREATE TABLE calendrier_enedis_col (
  ID_ligne int UNSIGNED NOT NULL AUTO_INCREMENT,
  TYPE_CALENDRIER varchar(255) DEFAULT NULL,
  vDate date DEFAULT NULL,
  vHeure int DEFAULT NULL,
  Classe_Temp varchar(255) DEFAULT NULL,
  ARENH double DEFAULT NULL,
  `Peak_Off-Peak` varchar(255) DEFAULT NULL,
  PP1 double DEFAULT NULL,
  PP2 double DEFAULT NULL,
  `OP-SEM_OP-WE` varchar(255) DEFAULT NULL,
  PRIMARY KEY (ID_ligne)
)
ENGINE = INNODB,
AUTO_INCREMENT = 157777,
AVG_ROW_LENGTH = 88,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create index `IDX_calendrier_enedis_col` on table `calendrier_enedis_col`
--
ALTER TABLE calendrier_enedis_col
ADD INDEX IDX_calendrier_enedis_col (vDate, vHeure, TYPE_CALENDRIER);

--
-- Create table `calendrier_enedis`
--
CREATE TABLE calendrier_enedis (
  TYPE_CALENDRIER varchar(255) DEFAULT NULL,
  ID int DEFAULT NULL,
  vDATE date DEFAULT NULL,
  vHEURE double DEFAULT NULL,
  `PTE BTS` varchar(255) DEFAULT NULL,
  `HPH BTS` double DEFAULT NULL,
  `HCH BTS` double DEFAULT NULL,
  `HPE BTS` double DEFAULT NULL,
  `HCE BTS` double DEFAULT NULL,
  ARENH double DEFAULT NULL,
  Peak double DEFAULT NULL,
  `Off-Peak` double DEFAULT NULL,
  PP1 double DEFAULT NULL,
  PP2 double DEFAULT NULL,
  `OP SEM` double DEFAULT NULL,
  `OP WE` double DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 131,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `calendar_dates_tmp`
--
CREATE TABLE calendar_dates_tmp (
  dbtMesure date DEFAULT NULL,
  MOIS int DEFAULT NULL,
  AN int DEFAULT NULL
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 74,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `c68_compteurs_tmp_import`
--
CREATE TABLE c68_compteurs_tmp_import (
  id int NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  compteur_serie varchar(255) DEFAULT NULL,
  ct_1 varchar(255) DEFAULT NULL,
  ph_1 varchar(255) DEFAULT NULL,
  ct_2 varchar(255) DEFAULT NULL,
  ph_2 varchar(255) DEFAULT NULL,
  CLE68CO varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 2,
AVG_ROW_LENGTH = 113,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `c68_classestemporelles_tmp_import`
--
CREATE TABLE c68_classestemporelles_tmp_import (
  id int UNSIGNED NOT NULL AUTO_INCREMENT,
  idPrm varchar(50) DEFAULT NULL,
  fta_code varchar(50) DEFAULT NULL,
  ct_code varchar(10) DEFAULT NULL,
  ct_unite varchar(10) DEFAULT NULL,
  ct_valeur int DEFAULT NULL,
  CLE68CPT varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 30,
AVG_ROW_LENGTH = 65,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `b`
--
CREATE TABLE b (
  B varchar(255) DEFAULT NULL,
  cle varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `appros.scrapp_epex`
--
CREATE TABLE `appros.scrapp_epex` (
  trading_modality text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  auction text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  market_area text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  CLE text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  date_epex date DEFAULT NULL,
  heure int DEFAULT NULL,
  minute int DEFAULT NULL,
  buy_volume decimal(10, 2) DEFAULT NULL,
  sell_volume decimal(10, 2) DEFAULT NULL,
  volume decimal(10, 2) DEFAULT NULL,
  price decimal(10, 2) DEFAULT NULL,
  URL_query text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  date_crea datetime DEFAULT NULL
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;

--
-- Create table `a`
--
CREATE TABLE a (
  A varchar(255) DEFAULT NULL,
  cle varchar(255) DEFAULT NULL,
  id int UNSIGNED NOT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
ROW_FORMAT = DYNAMIC;