{"id":4390,"date":"2019-02-11T16:56:51","date_gmt":"2019-02-11T15:56:51","guid":{"rendered":"http:\/\/gpmfactory.com\/?p=4390"},"modified":"2019-02-11T16:56:51","modified_gmt":"2019-02-11T15:56:51","slug":"oracle-apex-18-diagramme-gantt-de-ressources","status":"publish","type":"post","link":"https:\/\/gpmfactory.com\/index.php\/2019\/02\/11\/oracle-apex-18-diagramme-gantt-de-ressources\/","title":{"rendered":"Oracle APEX 18 &#8211; diagramme Gantt de ressources"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Cas d&rsquo;usage<\/h2>\n\n\n\n<p>On r\u00e9cup\u00e8re un tableau d&rsquo;affectation de techniciens pour des interventions (installation, livraison, r\u00e9paration) chez des clients.  On d\u00e9sire obtenir une repr\u00e9sentation graphique du planning des techniciens (consid\u00e9r\u00e9s ici comme des ressources). Nous allons utiliser un <em>chart <\/em>de type Diagramme de Gantt propos\u00e9 dans Oracle APEX et nous allons voir comment construire la requ\u00eate .<\/p>\n\n\n\n<p><strong>Abstract<\/strong>: Oracle APEX &#8211; Gantt Chart with multiple taks per row<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u00c9chantillon du r\u00e9sultat qui sera obtenu<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"440\" src=\"http:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-1-1024x440.png\" alt=\"\" class=\"wp-image-4392\" srcset=\"https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-1-1024x440.png 1024w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-1-300x129.png 300w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-1-768x330.png 768w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-1.png 1357w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> <br>Diagramme Gantt de ressources <br><br><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Structure de la table<\/h2>\n\n\n\n<p>la colonne NOM contient le nom du client.<br>TECHNICIEN contient le nom du technicien.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"522\" height=\"588\" src=\"http:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image.png\" alt=\"\" class=\"wp-image-4391\" srcset=\"https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image.png 522w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-266x300.png 266w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u00c9chantillon du contenu de la table<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"483\" src=\"http:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-2-1024x483.png\" alt=\"\" class=\"wp-image-4393\" srcset=\"https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-2-1024x483.png 1024w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-2-300x142.png 300w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-2-768x362.png 768w, https:\/\/gpmfactory.com\/wp-content\/uploads\/2019\/02\/image-2.png 1312w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption> <br>\u00c9chantillon du contenu de la table <\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Query dans la section \u00ab\u00a0Series\u00a0\u00bb<\/h2>\n\n\n\n<p>L&rsquo;objectif est de construire un tableau dont les lignes correspondent aux techniciens et les taches correspondent aux clients. On fabrique un id artificiel pour chaque technicien en calculant une valeur de hash et on combine (op\u00e9rateur UNION) la liste des intervention avec celle des clients de fa\u00e7on \u00e0 produire une arborescence de taches \u00e0 un niveau. La fonction ORA_HASH appliqu\u00e9e au nom du technicien produit un ID utilis\u00e9 comme Parent_id des interventions. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from <br> (<br> select distinct technicien task_name,<br>        ora_hash(technicien)           task_id,<br>        null  parent_task,<br>        null   task_start_date,<br>        null     task_end_date,<br>        0 status,<br>        null gold,<br>        (select min(debut) from atour) gantt_start_date,<br>        (select max(debut + duree) from atour)  gantt_end_date,<br>        null viewport_start,<br>        null view_port_end<br> from atour <br> where technicien is not null<br> UNION<br> select gold||'_' || nom    task_name,<br>        id           task_id,<br>        ora_hash(technicien)  parent_task,<br>        debut   task_start_date,<br>        (debut+duree)     task_end_date,<br>        0 status,<br>        gold,<br>        (select min(debut) from atour) gantt_start_date,<br>        (select max(debut + duree) from atour)  gantt_end_date,<br>        (sysdate -10) viewport_start,<br>        (sysdate + 10) view_port_end<br> from atour<br> where debut is not null <br> and technicien is not null<br>     )<br> start with parent_task is null<br> connect by prior task_id = parent_task<br> order siblings by task_name<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Code Javascript dans la section \u00ab\u00a0Attributes\u00a0\u00bb pour l&rsquo;affichage des taches<\/h2>\n\n\n\n<p>Optionnellement, on peut am\u00e9nager l&rsquo;affichage pour produire des effets. Ici, on demande l&rsquo;affichage d&rsquo;une ligne rouge qui mat\u00e9rialise la journ\u00e9e en cours et on applique une couleur sp\u00e9cifique de tache pour les clients poss\u00e9dant un contrat de type \u00ab\u00a0gold\u00a0\u00bb. En raison de limitations des attributs pass\u00e9s dans le payload json, on concat\u00e8ne la valeur du champs GOLD avec celle du champs NOM (cf requete pr\u00e9c\u00e9dente) pour ensuite demander un filtrage u niveai Javascript. cf <a href=\"https:\/\/www.oracle.com\/webfolder\/technetwork\/jet\/jsdocs\/oj.ojGantt.html\">documentation Oracle Jet pour le composant Gantt<\/a>.  <\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function( options ){  \n     options.dataFilter = function( data ) {     \nvar Mydata = data.rows;      \n    Mydata.forEach(function(nrow, i) {    \n           nrow[\"tasks\"].forEach(function(nr, k) {\n               if (String(nr.label).substring(0,1) == '1') {\n                \/\/ data.rows[i].tasks[k].svgStyle     = {'fill': 'red'}; \n                 \/\/  data.rows[i].tasks[k].svgStyle     = {'line': 'blue'}; \n                 data.rows[i].tasks[k].svgClassName = \"u-color-20\";\n                \/\/   data.rows[i].tasks[k].stack-label-style = {'fill': 'red'}; \n               }\n            data.rows[i].tasks[k].label = String(nr.label).substring(2);\n           });\n    }); \n    return data;  \n};  \n\nvar event = new Date();\n\/\/ Define Reference Object line on the chart\nvar constantLine = [ { value: event.toISOString() } ];\n\n\/\/ Set the referenceObjects option as part of the chart initialization\noptions.referenceObjects = constantLine;\n\n \/\/options.gridlines.vertical =\"visible\";\nreturn options;  <\/code><\/pre>\n\n\n\n<p>}  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cas d&rsquo;usage On r\u00e9cup\u00e8re un tableau d&rsquo;affectation de techniciens pour des interventions (installation, livraison, r\u00e9paration) chez des clients. On d\u00e9sire obtenir une repr\u00e9sentation graphique&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[30,38,133,136,137,134,135],"ppma_author":[150],"class_list":["post-4390","post","type-post","status-publish","format-standard","hentry","category-non-classe","tag-apex","tag-chart","tag-gantt","tag-jet","tag-oracle","tag-planning","tag-resources"],"authors":[{"term_id":150,"user_id":1,"is_guest":0,"slug":"admin8700","display_name":"Patrick","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/209d5ed69b74d288390621ab4c1d3773?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/4390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/comments?post=4390"}],"version-history":[{"count":8,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/4390\/revisions"}],"predecessor-version":[{"id":4401,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/posts\/4390\/revisions\/4401"}],"wp:attachment":[{"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/media?parent=4390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/categories?post=4390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/tags?post=4390"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/gpmfactory.com\/index.php\/wp-json\/wp\/v2\/ppma_author?post=4390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}