السلام عليكم اخوتي في الله
اخوتي المشروع كله واقف على هذا التقرير هذا فأقسم عليكم بالله الرد حتى ولو بفكرة ممكن تساعد
انا عامل تقرير والتقرير شغال بس انا كنت عايز اجمع عدد الليترات والتكلفة لكل سيارة هم في التقرير طالعين بس كل فاتورة لوحها وانا عايز اجمع بحيث اني اعرف كل سيارة استهلكت كام ليتر وقيمة الإستهلاك
و في المرفقات صورة من التقارير اللي عايز يتظبط
وده الكود اللي بيصدر البيانات لتقرير
try {
InputStream inputStream = new FileInputStream(
"src/com/core/rpt/allBills.jrxml");
CarsReportHelper helper = new CarsReportHelper();
List dataBeanList = helper.getAllDataBeanList(dateChooser.getDate(), dateChooser_1.getDate());
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataBeanList);
Map parameters = new HashMap();
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager
.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(
jasperReport, parameters, beanColDataSource);
JasperViewer.viewReport(jasperPrint);
} catch (DAOException | FileNotFoundException | JRException e) {
e.printStackTrace();
} public List<PetrolBill> getDataBeanList(String carNum, Date startDate, Date endDate) throws DAOException {
ArrayList<PetrolBill> dataBeanList = new ArrayList<PetrolBill>();
dataBeanList.addAll(SDRService.getInstance().getPetrolBillSrv()
.getBillsBatweenTowDates(carNum, startDate, endDate));
return dataBeanList;
} public List<PetrolBill> getBillsBatweenTowDates(String carNumber,Date startDate, Date endDate) throws DAOException{
List<PetrolBill> bills = new ArrayList<PetrolBill>();
List<PetrolBill> list = DAOFactory.getInstance().getPetrolBillDAO().selectAll();
List<Car> car = DAOFactory.getInstance().getCarDAO().getByCarNumber(carNumber);
int carId = car.get(0).getId();
for(PetrolBill bill :list){
if(bill.getDate().before(startDate) & bill.getDate().after(endDate) & bill.getCarId().equals(carId))
bills.add(bill);
}
return bills;
}وده كود التقرير
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 3.1.2-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="allBills" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="BetrolBillDA"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<field name="car" class="com.core.entities.Car">
<fieldDescription><![CDATA[car]]></fieldDescription>
</field>
<field name="letterMuch" class="java.lang.Integer">
<fieldDescription><![CDATA[letterMuch]]></fieldDescription>
</field>
<field name="petrol" class="com.core.entities.Petrol">
<fieldDescription><![CDATA[petrol]]></fieldDescription>
</field>
<background>
<band/>
</background>
<title>
<band height="79"/>
</title>
<pageHeader>
<band height="35"/>
</pageHeader>
<columnHeader>
<band height="22">
<staticText>
<reportElement x="340" y="0" width="70" height="20"/>
<textElement lineSpacing="Single"/>
<text><![CDATA[letterMuch]]></text>
</staticText>
<staticText>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<text><![CDATA[Car Number]]></text>
</staticText>
<staticText>
<reportElement x="220" y="0" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<text><![CDATA[Driver Name]]></text>
</staticText>
<staticText>
<reportElement x="430" y="0" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<text><![CDATA[Cost]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="23">
<textField>
<reportElement x="340" y="0" width="80" height="20"/>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{letterMuch}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{car}.getCarNumber()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="220" y="0" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{car}.getDriverName()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="430" y="1" width="100" height="20"/>
<textElement lineSpacing="Single"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{petrol}.getCast()*$F{letterMuch}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45"/>
</columnFooter>
<pageFooter>
<band height="54"/>
</pageFooter>
<summary>
<band height="42"/>
</summary>
</jasperReport>