Commit ab3b271b authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Suppression du TBL service_referentiel, non utilisé, et remplacement par le nouveau tbl_referentiel

parent 1c5b261b
......@@ -2641,101 +2641,8 @@ CREATE OR REPLACE PACKAGE BODY "UNICAEN_TBL" AS
PROCEDURE C_SERVICE_REFERENTIEL(useParams BOOLEAN DEFAULT FALSE) IS
TYPE r_cursor IS REF CURSOR;
c r_cursor;
d TBL_SERVICE_REFERENTIEL%rowtype;
viewQuery CLOB;
BEGIN
viewQuery := 'WITH t AS (
SELECT
i.annee_id,
i.id intervenant_id,
si.referentiel referentiel,
vh.type_volume_horaire_id,
s.structure_id,
CASE WHEN v.id IS NULL AND vh.auto_validation=0 THEN 0 ELSE 1 END valide
FROM
intervenant i
JOIN statut si ON si.id = i.statut_id
LEFT JOIN service_referentiel s ON s.intervenant_id = i.id
AND s.histo_destruction IS NULL
LEFT JOIN volume_horaire_ref vh ON vh.service_referentiel_id = s.id
AND vh.histo_destruction IS NULL
LEFT JOIN validation_vol_horaire_ref vvh ON vvh.volume_horaire_ref_id = vh.id
LEFT JOIN validation v ON v.id = vvh.validation_id
AND v.histo_destruction IS NULL
WHERE
i.histo_destruction IS NULL
/*@INTERVENANT_ID=i.id*/
/*@ANNEE_ID=i.annee_id*/
)
SELECT
annee_id,
intervenant_id,
referentiel,
type_volume_horaire_id,
structure_id,
CASE WHEN type_volume_horaire_id IS NULL THEN 0 ELSE COUNT(*) END nbvh,
SUM(valide) valide
FROM
t
WHERE
NOT (structure_id IS NOT NULL AND type_volume_horaire_id IS NULL)
GROUP BY
annee_id,
intervenant_id,
referentiel,
type_volume_horaire_id,
structure_id';
OPEN c FOR '
SELECT
CASE WHEN
t.ANNEE_ID = v.ANNEE_ID
AND t.INTERVENANT_ID = v.INTERVENANT_ID
AND t.REFERENTIEL = v.REFERENTIEL
AND COALESCE(t.TYPE_VOLUME_HORAIRE_ID,0) = COALESCE(v.TYPE_VOLUME_HORAIRE_ID,0)
AND COALESCE(t.STRUCTURE_ID,0) = COALESCE(v.STRUCTURE_ID,0)
AND t.NBVH = v.NBVH
AND t.VALIDE = v.VALIDE
THEN -1 ELSE t.ID END ID,
v.ANNEE_ID,
v.INTERVENANT_ID,
v.REFERENTIEL,
v.TYPE_VOLUME_HORAIRE_ID,
v.STRUCTURE_ID,
v.NBVH,
v.VALIDE
FROM
(' || QUERY_APPLY_PARAMS(viewQuery, useParams) || ') v
FULL JOIN TBL_SERVICE_REFERENTIEL t ON
t.INTERVENANT_ID = v.INTERVENANT_ID
AND COALESCE(t.TYPE_VOLUME_HORAIRE_ID,0) = COALESCE(v.TYPE_VOLUME_HORAIRE_ID,0)
AND COALESCE(t.STRUCTURE_ID,0) = COALESCE(v.STRUCTURE_ID,0)
WHERE ' || PARAMS_MAKE_FILTER(useParams);
LOOP
FETCH c INTO d; EXIT WHEN c%NOTFOUND;
IF d.id IS NULL THEN
d.id := TBL_SERVICE_REFERENTIEL_ID_SEQ.NEXTVAL;
INSERT INTO TBL_SERVICE_REFERENTIEL values d;
ELSIF
d.INTERVENANT_ID IS NULL
AND d.TYPE_VOLUME_HORAIRE_ID IS NULL
AND d.STRUCTURE_ID IS NULL
THEN
DELETE FROM TBL_SERVICE_REFERENTIEL WHERE id = d.id;
ELSIF d.id <> -1 THEN
UPDATE TBL_SERVICE_REFERENTIEL SET row = d WHERE id = d.id;
END IF;
END LOOP;
CLOSE c;
return;
END;
......
<?php
//@formatter:off
return [
'name' => 'TBL_SERVICE_REFERENTIEL',
'temporary' => FALSE,
'logging' => FALSE,
'commentaire' => 'Référentiel',
'sequence' => 'TBL_SERVICE_REFERENTIEL_ID_SEQ',
'columns' => [
'ANNEE_ID' => [
'name' => 'ANNEE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'ID' => [
'name' => 'ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'INTERVENANT_ID' => [
'name' => 'INTERVENANT_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'NBVH' => [
'name' => 'NBVH',
'type' => 'float',
'bdd-type' => 'FLOAT',
'length' => 0,
'scale' => NULL,
'precision' => 126,
'nullable' => FALSE,
'default' => '0',
'position' => 7,
'commentaire' => 'Nombre de volumes horaires',
],
'REFERENTIEL' => [
'name' => 'REFERENTIEL',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 4,
'commentaire' => 'Témoin (1=peut saisir du référentiel)',
],
'STRUCTURE_ID' => [
'name' => 'STRUCTURE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 6,
'commentaire' => NULL,
],
'TYPE_VOLUME_HORAIRE_ID' => [
'name' => 'TYPE_VOLUME_HORAIRE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
'VALIDE' => [
'name' => 'VALIDE',
'type' => 'float',
'bdd-type' => 'FLOAT',
'length' => 0,
'scale' => NULL,
'precision' => 126,
'nullable' => FALSE,
'default' => '0',
'position' => 8,
'commentaire' => 'Nombre de volumes horaires validés',
],
],
];
//@formatter:on
CREATE OR REPLACE FORCE VIEW V_TBL_REFERENTIEL AS
SELECT
t.annee_id,
t.intervenant_id,
t.type_volume_horaire_id,
t.actif,
t.structure_id,
t.intervenant_structure_id,
t.service_referentiel_id,
t.fonction_referentiel_id,
t.type_intervenant_id,
t.type_intervenant_code,
t.type_volume_horaire_code,
SUM(nbvh) nbvh,
SUM(heures) heures,
SUM(valide) valide
FROM
(
SELECT
i.annee_id annee_id,
i.id intervenant_id,
tvh.id type_volume_horaire_id,
CASE tvh.code
WHEN 'PREVU' THEN si.referentiel_prevu
WHEN 'REALISE' THEN si.referentiel_realise
ELSE 0
END actif,
s.structure_id structure_id,
i.structure_id intervenant_structure_id,
s.id service_referentiel_id,
s.fonction_id fonction_referentiel_id,
ti.id type_intervenant_id,
tvh.code type_volume_horaire_code,
ti.code type_intervenant_code,
vh.heures heures,
1 nbvh,
CASE WHEN v.id IS NULL AND vh.auto_validation=0 THEN 0 ELSE 1 END valide
FROM
volume_horaire_ref vh
JOIN service_referentiel s ON s.id = vh.service_referentiel_id
AND s.histo_destruction IS NULL
JOIN intervenant i ON i.id = s.intervenant_id
AND i.histo_destruction IS NULL
JOIN statut si ON si.id = i.statut_id
JOIN type_intervenant ti ON ti.id = si.type_intervenant_id
JOIN type_volume_horaire tvh ON tvh.id = vh.type_volume_horaire_id
LEFT JOIN validation_vol_horaire_ref vvh ON vvh.volume_horaire_ref_id = vh.id
LEFT JOIN validation v ON v.id = vvh.validation_id
AND v.histo_destruction IS NULL
WHERE
vh.histo_destruction IS NULL
/*@INTERVENANT_ID=i.id*/
/*@ANNEE_ID=i.annee_id*/
/*@STRUCTURE_ID=COALESCE(s.structure_id,i.structure_id)*/
) t
GROUP BY
t.annee_id,
t.intervenant_id,
t.type_volume_horaire_id,
t.actif,
t.structure_id,
t.intervenant_structure_id,
t.service_referentiel_id,
t.fonction_referentiel_id,
t.type_intervenant_id,
t.type_intervenant_code,
t.type_volume_horaire_code
\ No newline at end of file
CREATE OR REPLACE FORCE VIEW V_TBL_SERVICE_REFERENTIEL AS
WITH t AS (
SELECT
i.annee_id,
i.id intervenant_id,
si.referentiel referentiel,
vh.type_volume_horaire_id,
s.structure_id,
CASE WHEN v.id IS NULL AND vh.auto_validation=0 THEN 0 ELSE 1 END valide
FROM
intervenant i
JOIN statut si ON si.id = i.statut_id
LEFT JOIN service_referentiel s ON s.intervenant_id = i.id
AND s.histo_destruction IS NULL
LEFT JOIN volume_horaire_ref vh ON vh.service_referentiel_id = s.id
AND vh.histo_destruction IS NULL
LEFT JOIN validation_vol_horaire_ref vvh ON vvh.volume_horaire_ref_id = vh.id
LEFT JOIN validation v ON v.id = vvh.validation_id
AND v.histo_destruction IS NULL
WHERE
i.histo_destruction IS NULL
/*@INTERVENANT_ID=i.id*/
/*@ANNEE_ID=i.annee_id*/
)
SELECT
annee_id,
intervenant_id,
referentiel,
type_volume_horaire_id,
structure_id,
CASE WHEN type_volume_horaire_id IS NULL THEN 0 ELSE COUNT(*) END nbvh,
SUM(valide) valide
FROM
t
WHERE
NOT (structure_id IS NOT NULL AND type_volume_horaire_id IS NULL)
GROUP BY
annee_id,
intervenant_id,
referentiel,
type_volume_horaire_id,
structure_id
\ No newline at end of file
......@@ -1583,14 +1583,21 @@ return [
'HEURES',
'VALIDE',
],
'TBL_SERVICE_REFERENTIEL' => [
'TBL_REFERENTIEL' => [
'ID',
'ANNEE_ID',
'INTERVENANT_ID',
'REFERENTIEL',
'TYPE_VOLUME_HORAIRE_ID',
'ACTIF',
'STRUCTURE_ID',
'INTERVENANT_STRUCTURE_ID',
'SERVICE_REFERENTIEL_ID',
'FONCTION_REFERENTIEL_ID',
'TYPE_INTERVENANT_ID',
'TYPE_INTERVENANT_CODE',
'TYPE_VOLUME_HORAIRE_CODE',
'NBVH',
'HEURES',
'VALIDE',
],
'TBL_SERVICE_SAISIE' => [
......
......@@ -7,6 +7,7 @@ return [
'TBL_DEMS',
'TMP_SCENARIO_NOEUD_EFFECTIF',
'DOSSIER_CHAMP_AUTRE_PAR_STATUT',
'TBL_SERVICE_REFERENTIEL',
],
],
'materialized-view' => [
......@@ -38,6 +39,7 @@ return [
'V_INDICATEUR_1221',
'V_INDICATEUR_1230',
'V_INDICATEUR_1240',
'V_TBL_SERVICE_REFERENTIEL',
], 'excludes' => [
'V_TBL_PLAFOND_%', // Les vues plafonds sont générées et non créées à partir de la DDL
],
......
......@@ -673,11 +673,11 @@ return [
'FEUILLE_DE_ROUTE' => true,
],
[
'TBL_NAME' => 'service_referentiel',
'TABLE_NAME' => 'TBL_SERVICE_REFERENTIEL',
'VIEW_NAME' => 'V_TBL_SERVICE_REFERENTIEL',
'TBL_NAME' => 'referentiel',
'TABLE_NAME' => 'TBL_REFERENTIEL',
'VIEW_NAME' => 'V_TBL_REFERENTIEL',
'SEQUENCE_NAME' => null,
'CONSTRAINT_NAME' => 'TBL_SERVICE_REFERENTIEL_UN',
'CONSTRAINT_NAME' => 'TBL_REFERENTIEL_UN',
'CUSTOM_CALCUL_PROC' => null,
'ORDRE' => 11,
'FEUILLE_DE_ROUTE' => true,
......
......@@ -349,20 +349,28 @@ Services d'ensiegnement
| HEURES | NB d'heures saisi |
## Table TBL_SERVICE_REFERENTIEL
## Table TBL_REFERENTIEL
Référentiel
| Colonne |Description |
|------------------------|-------------------------------------|
| ID | |
| ANNEE_ID |==> ANNEE.ID |
| INTERVENANT_ID |==> INTERVENANT.ID |
| REFERENTIEL |Témoin (1=peut saisir du référentiel)|
| TYPE_VOLUME_HORAIRE_ID |==> TYPE_VOLUME_HORAIRE.ID |
| STRUCTURE_ID |==> STRUCTURE.ID |
| NBVH |Nombre de volumes horaires |
| VALIDE |Nombre de volumes horaires validés |
| Colonne | Description |
|---------------------------|------------------------------------|
| ID | |
| ANNEE_ID | ==> ANNEE.ID |
| INTERVENANT_ID | ==> INTERVENANT.ID |
| ACTIF | Témoin (0 ou 1) |
| TYPE_VOLUME_HORAIRE_ID | ==> TYPE_VOLUME_HORAIRE.ID |
| STRUCTURE_ID | ==> STRUCTURE.ID |
| NBVH | Nombre de volumes horaires |
| VALIDE | Nombre de volumes horaires validés |
| INTERVENANT_STRUCTURE_ID | ==> STRUCTURE.ID |
| SERVICE_REFERENTIEL_ID | ==> SERVICE_REFERENTIEL.ID |
| FONCTION_REFERENTIEL_ID | ==> FONCTION_REFERENTIEL.ID |
| TYPE_INTERVENANT_ID | ==> TYPE_INTERVENANT.ID |
| TYPE_INTERVENANT_CODE | ==> TYPE_INTERVENANT.CODE |
| TYPE_VOLUME_HORAIRE_CODE | ==> TYPE_VOLUME_HORAIRE.CODE |
| HEURES | Nombre d'heures concernées |
## Table TBL_SERVICE_SAISIE
......
......@@ -169,7 +169,6 @@ return [
'Application\Entity\Db\TblPieceJointeDemande' => __DIR__ . '/src/Entity/Db/TblPieceJointeDemande.php',
'Application\Entity\Db\TblPieceJointeFournie' => __DIR__ . '/src/Entity/Db/TblPieceJointeFournie.php',
'Application\Entity\Db\TblService' => __DIR__ . '/src/Entity/Db/TblService.php',
'Application\Entity\Db\TblServiceReferentiel' => __DIR__ . '/src/Entity/Db/TblServiceReferentiel.php',
'Application\Entity\Db\TblServiceSaisie' => __DIR__ . '/src/Entity/Db/TblServiceSaisie.php',
'Application\Entity\Db\TblValidationEnseignement' => __DIR__ . '/src/Entity/Db/TblValidationEnseignement.php',
'Application\Entity\Db\TblValidationReferentiel' => __DIR__ . '/src/Entity/Db/TblValidationReferentiel.php',
......
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Db\TblServiceReferentiel" table="TBL_SERVICE_REFERENTIEL">
<indexes>
<index name="IDX_606D1CD0AA401F5C" columns="ANNEE_ID"/>
<index name="IDX_606D1CD078FF2BCB" columns="INTERVENANT_ID"/>
<index name="IDX_606D1CD0884B0F7B" columns="STRUCTURE_ID"/>
<index name="IDX_606D1CD065ABF61" columns="TYPE_VOLUME_HORAIRE_ID"/>
</indexes>
<unique-constraints>
<unique-constraint name="tbl_service_referentiel__un" columns="INTERVENANT_ID,TYPE_VOLUME_HORAIRE_ID,STRUCTURE_ID"/>
</unique-constraints>
<id name="id" type="integer" column="ID">
<generator strategy="SEQUENCE"/>
<sequence-generator sequence-name="TBL_SERVICE_REFERENTIEL_ID_seq" allocation-size="1" initial-value="1"/>
</id>
<field name="nbvh" type="float" column="NBVH" precision="126" scale="0" nullable="false">
<options>
<option name="default">0</option>
</options>
</field>
<field name="peutSaisirService" type="boolean" column="PEUT_SAISIR_SERVICE" nullable="false">
<options>
<option name="default">0</option>
</options>
</field>
<field name="valide" type="float" column="VALIDE" precision="126" scale="0" nullable="false">
<options>
<option name="default">0</option>
</options>
</field>
<many-to-one field="typeVolumeHoraire" target-entity="Application\Entity\Db\TypeVolumeHoraire" fetch="LAZY">
<join-columns>
<join-column name="TYPE_VOLUME_HORAIRE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="structure" target-entity="Application\Entity\Db\Structure" fetch="LAZY">
<join-columns>
<join-column name="STRUCTURE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="intervenant" target-entity="Application\Entity\Db\Intervenant" fetch="LAZY">
<join-columns>
<join-column name="INTERVENANT_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="annee" target-entity="Application\Entity\Db\Annee" fetch="LAZY">
<join-columns>
<join-column name="ANNEE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
</entity>
</doctrine-mapping>
<?php
namespace Application\Entity\Db;
/**
* TblServiceReferentiel
*/
class TblServiceReferentiel
{
/**
* @var float
*/
private $nbvh = 0;
/**
* @var boolean
*/
private $peutSaisirService = false;
/**
* @var float
*/
private $valide = 0;
/**
* @var integer
*/
private $id;
/**
* @var \Application\Entity\Db\TypeVolumeHoraire
*/
private $typeVolumeHoraire;
/**
* @var \Application\Entity\Db\Structure
*/
private $structure;
/**
* @var \Application\Entity\Db\Intervenant
*/
private $intervenant;
/**
* @var \Application\Entity\Db\Annee
*/
private $annee;
/**
* Get nbvh
*
* @return float
*/
public function getNbvh()
{
return $this->nbvh;
}
/**
* Get peutSaisirService
*
* @return boolean
*/
public function getPeutSaisirService()
{
return $this->peutSaisirService;
}
/**
* Get valide
*
* @return float
*/
public function getValide()
{
return $this->valide;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get typeVolumeHoraire
*
* @return \Application\Entity\Db\TypeVolumeHoraire
*/