Relatorio consumindo dois datasets distintos

Pessoal, tudo ótimo? Preciso de ajuda, estou criando um relatorio com o Fluig report tentando consumir dois datasets para ter informações mais precisas de um processo. No código abaixo eu pego o dataset do form e com o número da solicitação eu pesquiso no processTask para pegar data de inicio, fim e status, mas, essas colunas vem espelhadas, exemplo: a coluna de data de inicio vem correto, porém a data final é igual a data inicio e o status é sempre 2.

Abaixo o xml do relatorio.

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
    <property name="createdBy">Eclipse BIRT Designer Version 4.4.2.v201410272105 Build &lt;4.4.2.v20150217-1805></property>
    <property name="units">in</property>
    <method name="initialize"><![CDATA[importPackage(Packages.com.datasul.technology.webdesk.search.controller);
importPackage(Packages.com.datasul.technology.webdesk.dataset.service);
importPackage(Packages.com.datasul.technology.webdesk.dataset);
importPackage(Packages.java.util);
importPackage(Packages.java.text);

var datasetAccession = null;
var datasetProcessTask = null;
var dataset = null;
var count = 0;
var count2 = 0;

var datasetRetorno = null;]]></method>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="layoutPreference">auto layout</property>
    <property name="bidiLayoutOrientation">ltr</property>
    <property name="imageDPI">96</property>
    <data-sources>
        <script-data-source name="Data Source" id="23"/>
    </data-sources>
    <data-sets>
        <script-data-set name="Data Set" id="24">
            <list-property name="resultSetHints">
                <structure>
                    <property name="position">1</property>
                    <property name="name">ipNumberProcess</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">2</property>
                    <property name="name">iniDate</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">3</property>
                    <property name="name">solicitante</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">4</property>
                    <property name="name">NomeRazaosocial</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">5</property>
                    <property name="name">logradouro</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">6</property>
                    <property name="name">numero</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">7</property>
                    <property name="name">complemento</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">8</property>
                    <property name="name">bairro</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">9</property>
                    <property name="name">cidade</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">10</property>
                    <property name="name">estado</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">11</property>
                    <property name="name">cep</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">12</property>
                    <property name="name">pop_planejado</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">13</property>
                    <property name="name">endDate</property>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="position">14</property>
                    <property name="name">status</property>
                    <property name="dataType">string</property>
                </structure>
            </list-property>
            <list-property name="columnHints">
                <structure>
                    <property name="columnName">ipNumberProcess</property>
                    <text-property name="displayName">Nº Solic.</text-property>
                </structure>
                <structure>
                    <property name="columnName">iniDate</property>
                    <text-property name="displayName">Data ínicio</text-property>
                </structure>
                <structure>
                    <property name="columnName">solicitante</property>
                    <text-property name="displayName">Nome Solicitante</text-property>
                </structure>
                <structure>
                    <property name="columnName">NomeRazaosocial</property>
                    <text-property name="displayName">Nome/Razão Social</text-property>
                </structure>
                <structure>
                    <property name="columnName">logradouro</property>
                    <text-property name="displayName">Logradouro</text-property>
                </structure>
                <structure>
                    <property name="columnName">numero</property>
                    <text-property name="displayName">Número</text-property>
                </structure>
                <structure>
                    <property name="columnName">complemento</property>
                    <text-property name="displayName">Complemento</text-property>
                </structure>
                <structure>
                    <property name="columnName">bairro</property>
                    <text-property name="displayName">Bairro</text-property>
                </structure>
                <structure>
                    <property name="columnName">cidade</property>
                    <text-property name="displayName">Cidade</text-property>
                </structure>
                <structure>
                    <property name="columnName">estado</property>
                    <text-property name="displayName">Estado</text-property>
                </structure>
                <structure>
                    <property name="columnName">cep</property>
                    <text-property name="displayName">CEP</text-property>
                </structure>
                <structure>
                    <property name="columnName">pop_planejado</property>
                    <text-property name="displayName">POP Planejado</text-property>
                </structure>
                <structure>
                    <property name="columnName">endDate</property>
                    <text-property name="displayName">Data Finalização</text-property>
                </structure>
                <structure>
                    <property name="columnName">status</property>
                    <text-property name="displayName">Status</text-property>
                </structure>
            </list-property>
            <list-property name="filter">
                <structure>
                    <property name="operator">gt</property>
                    <expression name="expr" type="javascript">row["ipNumberProcess"]</expression>
                    <simple-property-list name="value1">
                        <value>0</value>
                    </simple-property-list>
                </structure>
                <structure>
                    <property name="operator">is-not-null</property>
                    <expression name="expr" type="javascript">row["iniDate"]</expression>
                </structure>
            </list-property>
            <structure name="cachedMetaData">
                <list-property name="resultSet">
                    <structure>
                        <property name="position">1</property>
                        <property name="name">ipNumberProcess</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">2</property>
                        <property name="name">iniDate</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">3</property>
                        <property name="name">solicitante</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">4</property>
                        <property name="name">NomeRazaosocial</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">5</property>
                        <property name="name">logradouro</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">6</property>
                        <property name="name">numero</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">7</property>
                        <property name="name">complemento</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">8</property>
                        <property name="name">bairro</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">9</property>
                        <property name="name">cidade</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">10</property>
                        <property name="name">estado</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">11</property>
                        <property name="name">cep</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">12</property>
                        <property name="name">pop_planejado</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">13</property>
                        <property name="name">endDate</property>
                        <property name="dataType">string</property>
                    </structure>
                    <structure>
                        <property name="position">14</property>
                        <property name="name">status</property>
                        <property name="dataType">string</property>
                    </structure>
                </list-property>
            </structure>
            <method name="beforeOpen"><![CDATA[try{
    var factory = DatasetFactory.getInstance(${WKCompany});
    var constraints = new Array(); 
    var sortingFields = new Array();
    var i = 0;         
    //Dataset
    datasetAccession = factory.getDataset("FormuláriodeAdesão670", null, constraints, sortingFields);     
}catch (e) {
}]]></method>
            <property name="dataSource">Data Source</property>
            <method name="fetch"><![CDATA[var factory = DatasetFactory.getInstance(${WKCompany});
var ReportUtil = {
  formatAsTimestampLiteral: function (value, isEndDate) {
    var calendar = Calendar.getInstance();
    // set up in calender the parse of value as SimpleDateFormat
    calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value));
    // tratando a hora para o horário normal
    calendar.add(Calendar.HOUR, -1);
    if (isEndDate) {
      calendar.add(Calendar.DATE, 1);
      calendar.add(Calendar.SECOND, -1);
    }
    return (new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(calendar.getTime()));
  },
  checkParam: function (paramName, defaultValue) {
    return params[paramName].value != null &amp;&amp; BirtStr.trim(params[paramName].value) != "" &amp;&amp; params[paramName].value != defaultValue;
  }
};

if (datasetAccession != null) {
  if (count < datasetAccession.rowsCount) {
    //monta o objeto da linha
    var ipNumberProcess = datasetAccession.getValue(count, "ipNumberProcess");
    var fieldsReturn = new Array("processTaskPK.processInstanceId", "startDate", "endDate", "status");
    var constraints = new Array();
    constraints[0] = factory.createConstraint("processTaskPK.processInstanceId", ipNumberProcess, ipNumberProcess, ConstraintType.MUST);

    datasetProcessTask = factory.getDataset("processTask", fieldsReturn, constraints, null);

    for (var z = 0; z < datasetProcessTask.rowsCount; z++) {
      if (datasetProcessTask.getValue(z, "processTaskPK.processInstanceId") == ipNumberProcess) {
        var iniDate = ReportUtil.formatAsTimestampLiteral(datasetProcessTask.getValue(z, "startDate"));
        var endDate = ReportUtil.formatAsTimestampLiteral(datasetProcessTask.getValue(z, "endDate"));
        var status = "";

        switch (parseInt(datasetProcessTask.getValue(z, "status"))) {
          case 0: status = "Em aberto";
            break;
          case 1: status = "Em consenso";
            break;
          case 2: status = "Finalizada";
            break;
          case 3: status = "Transferida";
            break;
          case 4: status = "Cancelada";
            break;
        }

        break;
      }

    }

    row["ipNumberProcess"] = ipNumberProcess;
    row["solicitante"] = datasetAccession.getValue(count, "AD1");
    row["NomeRazaosocial"] = datasetAccession.getValue(count, "NomeRazaosocial");
    row["logradouro"] = datasetAccession.getValue(count, "logradouro");
    row["numero"] = datasetAccession.getValue(count, "numero");
    row["complemento"] = datasetAccession.getValue(count, "complemento");
    row["bairro"] = datasetAccession.getValue(count, "bairro");
    row["cidade"] = datasetAccession.getValue(count, "cidade");
    row["estado"] = datasetAccession.getValue(count, "estado");
    row["cep"] = datasetAccession.getValue(count, "cep");
    row["pop_planejado"] = datasetAccession.getValue(count, "AD28");
    row["iniDate"] = iniDate;
    row["endDate"] = endDate;
    row["status"] = status;
    //Atualiza o contador 
    count++;
    return true;
  }
}
return false;]]></method>
        </script-data-set>
    </data-sets>
    <styles>
        <style name="report" id="4">
            <property name="fontFamily">sans-serif</property>
            <property name="fontSize">10pt</property>
        </style>
        <style name="crosstab-cell" id="5">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
        <style name="crosstab" id="6">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
    </styles>
    <page-setup>
        <simple-master-page name="Simple MasterPage" id="2">
            <page-footer>
                <text id="3">
                    <property name="contentType">html</property>
                    <text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
                </text>
            </page-footer>
        </simple-master-page>
    </page-setup>
    <body>
        <label id="75">
            <property name="fontSize">16pt</property>
            <property name="textAlign">center</property>
            <text-property name="text">Relatório de Adesão</text-property>
        </label>
        <table id="367">
            <property name="dataSet">Data Set</property>
            <list-property name="boundDataColumns">
                <structure>
                    <property name="name">ipNumberProcess</property>
                    <text-property name="displayName">Nº Solic.</text-property>
                    <expression name="expression" type="javascript">dataSetRow["ipNumberProcess"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">iniDate</property>
                    <text-property name="displayName">Data ínicio</text-property>
                    <expression name="expression" type="javascript">dataSetRow["iniDate"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">solicitante</property>
                    <text-property name="displayName">Nome Solicitante</text-property>
                    <expression name="expression" type="javascript">dataSetRow["solicitante"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">NomeRazaosocial</property>
                    <text-property name="displayName">Nome/Razão Social</text-property>
                    <expression name="expression" type="javascript">dataSetRow["NomeRazaosocial"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">logradouro</property>
                    <text-property name="displayName">Logradouro</text-property>
                    <expression name="expression" type="javascript">dataSetRow["logradouro"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">numero</property>
                    <text-property name="displayName">Número</text-property>
                    <expression name="expression" type="javascript">dataSetRow["numero"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">complemento</property>
                    <text-property name="displayName">Complemento</text-property>
                    <expression name="expression" type="javascript">dataSetRow["complemento"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">bairro</property>
                    <text-property name="displayName">Bairro</text-property>
                    <expression name="expression" type="javascript">dataSetRow["bairro"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">cidade</property>
                    <text-property name="displayName">Cidade</text-property>
                    <expression name="expression" type="javascript">dataSetRow["cidade"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">estado</property>
                    <text-property name="displayName">Estado</text-property>
                    <expression name="expression" type="javascript">dataSetRow["estado"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">cep</property>
                    <text-property name="displayName">CEP</text-property>
                    <expression name="expression" type="javascript">dataSetRow["cep"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">pop_planejado</property>
                    <text-property name="displayName">POP Planejado</text-property>
                    <expression name="expression" type="javascript">dataSetRow["pop_planejado"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">endDate</property>
                    <text-property name="displayName">Data Finalização</text-property>
                    <expression name="expression" type="javascript">dataSetRow["endDate"]</expression>
                    <property name="dataType">string</property>
                </structure>
                <structure>
                    <property name="name">status</property>
                    <text-property name="displayName">Status</text-property>
                    <expression name="expression" type="javascript">dataSetRow["status"]</expression>
                    <property name="dataType">string</property>
                </structure>
            </list-property>
            <column id="441"/>
            <column id="442"/>
            <column id="443"/>
            <column id="444"/>
            <column id="445"/>
            <column id="446"/>
            <column id="447"/>
            <column id="448"/>
            <column id="449"/>
            <column id="450"/>
            <column id="451"/>
            <column id="452"/>
            <column id="453"/>
            <column id="454"/>
            <header>
                <row id="368">
                    <cell id="369">
                        <label id="370">
                            <text-property name="text">Nº Solic.</text-property>
                        </label>
                    </cell>
                    <cell id="371">
                        <label id="372">
                            <text-property name="text">Data ínicio</text-property>
                        </label>
                    </cell>
                    <cell id="373">
                        <label id="374">
                            <text-property name="text">Nome Solicitante</text-property>
                        </label>
                    </cell>
                    <cell id="375">
                        <label id="376">
                            <text-property name="text">Nome/Razão Social</text-property>
                        </label>
                    </cell>
                    <cell id="377">
                        <label id="378">
                            <text-property name="text">Logradouro</text-property>
                        </label>
                    </cell>
                    <cell id="379">
                        <label id="380">
                            <text-property name="text">Número</text-property>
                        </label>
                    </cell>
                    <cell id="381">
                        <label id="382">
                            <text-property name="text">Complemento</text-property>
                        </label>
                    </cell>
                    <cell id="383">
                        <label id="384">
                            <text-property name="text">Bairro</text-property>
                        </label>
                    </cell>
                    <cell id="385">
                        <label id="386">
                            <text-property name="text">Cidade</text-property>
                        </label>
                    </cell>
                    <cell id="387">
                        <label id="388">
                            <text-property name="text">Estado</text-property>
                        </label>
                    </cell>
                    <cell id="389">
                        <label id="390">
                            <text-property name="text">CEP</text-property>
                        </label>
                    </cell>
                    <cell id="391">
                        <label id="392">
                            <text-property name="text">POP Planejado</text-property>
                        </label>
                    </cell>
                    <cell id="393">
                        <label id="394">
                            <text-property name="text">Data Finalização</text-property>
                        </label>
                    </cell>
                    <cell id="395">
                        <label id="396">
                            <text-property name="text">Status</text-property>
                        </label>
                    </cell>
                </row>
            </header>
            <detail>
                <row id="397">
                    <cell id="398">
                        <data id="399">
                            <property name="resultSetColumn">ipNumberProcess</property>
                        </data>
                    </cell>
                    <cell id="400">
                        <data id="401">
                            <property name="resultSetColumn">iniDate</property>
                        </data>
                    </cell>
                    <cell id="402">
                        <data id="403">
                            <property name="resultSetColumn">solicitante</property>
                        </data>
                    </cell>
                    <cell id="404">
                        <data id="405">
                            <property name="resultSetColumn">NomeRazaosocial</property>
                        </data>
                    </cell>
                    <cell id="406">
                        <data id="407">
                            <property name="resultSetColumn">logradouro</property>
                        </data>
                    </cell>
                    <cell id="408">
                        <data id="409">
                            <property name="resultSetColumn">numero</property>
                        </data>
                    </cell>
                    <cell id="410">
                        <data id="411">
                            <property name="resultSetColumn">complemento</property>
                        </data>
                    </cell>
                    <cell id="412">
                        <data id="413">
                            <property name="resultSetColumn">bairro</property>
                        </data>
                    </cell>
                    <cell id="414">
                        <data id="415">
                            <property name="resultSetColumn">cidade</property>
                        </data>
                    </cell>
                    <cell id="416">
                        <data id="417">
                            <property name="resultSetColumn">estado</property>
                        </data>
                    </cell>
                    <cell id="418">
                        <data id="419">
                            <property name="resultSetColumn">cep</property>
                        </data>
                    </cell>
                    <cell id="420">
                        <data id="421">
                            <property name="resultSetColumn">pop_planejado</property>
                        </data>
                    </cell>
                    <cell id="422">
                        <data id="423">
                            <property name="resultSetColumn">endDate</property>
                        </data>
                    </cell>
                    <cell id="424">
                        <data id="425">
                            <property name="resultSetColumn">status</property>
                        </data>
                    </cell>
                </row>
            </detail>
            <footer>
                <row id="426">
                    <cell id="427"/>
                    <cell id="428"/>
                    <cell id="429"/>
                    <cell id="430"/>
                    <cell id="431"/>
                    <cell id="432"/>
                    <cell id="433"/>
                    <cell id="434"/>
                    <cell id="435"/>
                    <cell id="436"/>
                    <cell id="437"/>
                    <cell id="438"/>
                    <cell id="439"/>
                    <cell id="440"/>
                </row>
            </footer>
        </table>
    </body>
</report>
compartilhar
  1. Você vai ver essas setas em qualquer página de pergunta. Com elas, você pode dizer se uma pergunta ou uma resposta foram relevantes ou não.
  2. Edite sua pergunta ou resposta caso queira alterar ou adicionar detalhes.
  3. Caso haja alguma dúvida sobre a pergunta, adicione um comentário. O espaço de respostas deve ser utilizado apenas para responder a pergunta.
  4. Se o autor da pergunta marcar uma resposta como solucionada, esta marca aparecerá.
  5. Clique aqui para mais detalhes sobre o funcionamento do fluig Forum!

2 respostas

Não é a resposta que estava procurando? Procure outras perguntas com as tags relatorio birt datasets ou faça a sua própria pergunta.