пытаюсь нарисовать, не выходит.
если пытаюсь сделать чтоб столбцы брались с xml файла
Код:
implements bitel.billing.server.reports.BGCSVReport.CSVFillerData
пишет
Вложение:
Выделение_136.png [ 4.2 КБ | Просмотров: 20835 ]
если ставить
Код:
bitel.billing.server.reports.BGCSVReport.CSVFillerDataFields
то все компилится. но я вот незнаю, верно ли я добавил столбцы?
Код:
String colid = "title";
String colname = "title";
fields.put( colid, colname );
кажется неверно
файл cat kernel_allParam.rep.xml
Код:
<report title="Заполненые параметры договоров" dyn_class="ru.bitel.bgbilling.modules.reports.AllParam" type="java">
<checkedList name="object" title="Фильтр по объектам">
<item id="9" title="ул. , д.3"/>
<item id="7" title="ул. , д. 98"/>
<item id="16" title="ул. , д. 79Б"/>
<item id="8" title="ул. , д.8"/>
<item id="14" title="ул. , 19А"/>
<item id="19" title="ул. , д.27/26"/>
<item id="20" title="ул. , д.7/10"/>
</checkedList>
<fields>
<item id="title" title="Договор"/>
<item id="param" title="Параметры"/>
</fields>
</report>
код класса
Код:
package ru.bitel.bgbilling.modules.reports;
import bitel.billing.server.admin.reports.BGReportFilter;
import bitel.billing.server.reports.BGCSVReport.ReportResult;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import ru.bitel.common.sql.ConnectionSet;
public class AllParam
implements bitel.billing.server.reports.BGCSVReport.CSVFillerDataFields
{
@Override
public void fillReport( Connection con, BGReportFilter filter, ReportResult result, Map<String, String> fields )
throws Exception
{
int object = filter.getIntParam( "object" );
List<Map<String, String>> data = new ArrayList<Map<String, String>>( 1000 );
String query = " SELECT c.id, c.title FROM contract AS c" +
" LEFT JOIN contract_parameter_type_7 AS cpt ON cpt.cid = c.id " +
" WHERE cpt.val = " + object;
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next())
{
Map map = new HashMap();
int cid = rs.getInt(1);
String title = rs.getString(2);
map.put("title", title);
//print ("Договора " + title);
String allParam = " SELECT `cntrct_prmtrs_pref`.`title` " +
" , `cntrct_prmtr_tp_1`.`val` AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_1` AS `cntrct_prmtr_tp_1` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_1`.`pid` " +
" AND `cntrct_prmtr_tp_1`.`cid` = " + cid +
" WHERE `cntrct_prmtr_tp_1`.`val` IS NOT NULL " +
" UNION " +
" SELECT `cntrct_prmtrs_pref`.`title` " +
" , CONCAT(`addrss_ct`.`title`, ', ', `addrss_strt`.`title`, ', ' , `addrss_hs`.`house`, ', ', `cntrct_prmtr_tp_2`.`flat`) " +
" AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_2` AS `cntrct_prmtr_tp_2` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_2`.`pid` " +
" AND `cntrct_prmtr_tp_2`.`cid` = "+ cid +
" LEFT JOIN `address_house` AS `addrss_hs` " +
" ON `cntrct_prmtr_tp_2`.`hid` = `addrss_hs`.`id` " +
" LEFT JOIN `address_street` AS `addrss_strt` " +
" ON `addrss_hs`.`streetid` = `addrss_strt`.`id` " +
" LEFT JOIN `address_city` AS `addrss_ct` " +
" ON `addrss_strt`.`cityid` = `addrss_ct`.`id` " +
" WHERE `cntrct_prmtr_tp_2`.`flat` IS NOT NULL " +
" UNION " +
" SELECT `cntrct_prmtrs_pref`.`title` " +
" , `cntrct_prmtr_tp_3`.`email` AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_3` AS `cntrct_prmtr_tp_3` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_3`.`pid` " +
" AND `cntrct_prmtr_tp_3`.`cid` = " + cid +
" WHERE `cntrct_prmtr_tp_3`.`email` IS NOT NULL " +
" UNION " +
" SELECT `cntrct_prmtrs_pref`.`title` " +
" , `cntrct_prmtr_tp_6`.`val` AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_6` AS `cntrct_prmtr_tp_6` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_6`.`pid` " +
" AND `cntrct_prmtr_tp_6`.`cid` = " + cid +
" WHERE `cntrct_prmtr_tp_6`.`val` IS NOT NULL " +
" UNION " +
" SELECT `cntrct_prmtrs_pref`.`title` " +
" , `cntrct_prmtr_tp_7_vls`.`title` AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_7` AS `cntrct_prmtr_tp_7` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_7`.`pid` " +
" AND `cntrct_prmtr_tp_7`.`cid` = " + cid +
" LEFT JOIN `contract_parameter_type_7_values` AS `cntrct_prmtr_tp_7_vls` " +
" ON `cntrct_prmtr_tp_7`.`val` = `cntrct_prmtr_tp_7_vls`.`id` " +
" WHERE `cntrct_prmtr_tp_7_vls`.`title` IS NOT NULL " +
" UNION " +
" SELECT `cntrct_prmtrs_pref`.`title` " +
" , `cntrct_prmtr_tp_phn_itm`.`phone` AS `data` " +
" , `cntrct_prmtrs_pref`.`sort` " +
" FROM `contract_parameters_pref` AS `cntrct_prmtrs_pref` " +
" LEFT JOIN `contract_parameter_type_phone_item` AS `cntrct_prmtr_tp_phn_itm` " +
" ON `cntrct_prmtrs_pref`.`id` = `cntrct_prmtr_tp_phn_itm`.`pid` " +
" AND `cntrct_prmtr_tp_phn_itm`.`cid` = " + cid +
" WHERE `cntrct_prmtr_tp_phn_itm`.`phone` IS NOT NULL " +
" ORDER BY `sort` ";
PreparedStatement paramPs = con.prepareStatement(allParam);
ResultSet paramRs = paramPs.executeQuery();
while (paramRs.next())
{
String paramName = paramRs.getString(1);
String DATA = paramRs.getString(2);
//print ("paramName " + paramName + " data " + DATA);
}
data.add( map );
}
result.setData( data );
String colid = "title";
String colname = title;
fields.put( colid, colname );
}
}
и если формировать отчет, когда класс нормально компилится, то вылетает ошибка
Код:
java.lang.RuntimeException: java.lang.ClassCastException: ru.bitel.bgbilling.modules.reports.AllParam cannot be cast to bitel.billing.server.reports.BGCSVReport$CSVFillerData at bitel.billing.server.reports.BGCSVReport.getResultDyncode(BGCSVReport.java:227)
at bitel.billing.server.reports.BGCSVReport.fillReportToStream(BGCSVReport.java:63)
at bitel.billing.server.reports.action.ActionReport.doAction(ActionReport.java:57)
at bitel.billing.server.Executer.doModule(Unknown Source)
at bitel.billing.server.Executer$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at bitel.billing.server.Executer.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at ru.bitel.common.server.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassCastException: ru.bitel.bgbilling.modules.reports.AllParam cannot be cast to bitel.billing.server.reports.BGCSVReport$CSVFillerData at bitel.billing.server.reports.BGCSVReport.getResultDyncode(BGCSVReport.java:219)
... 28 more
_________________
Код:
Клиент: вер. 6.2.714 / 25.05.2015 17:27:15
os: Linux; java: Java HotSpot(TM) 64-Bit Server VM, v.1.8.0_45
Сервер: вер. 6.2.881 / 22.05.2015 17:56:55
os: Linux; java: Java HotSpot(TM) 64-Bit Server VM, v.1.8.0_45
Помощь по администрированию bgbilling в jabber конференции или Группа в telegramСтиль программирования - пьяный мастерстер
Разработка мобильных приложений