如何计算条件下员工的出勤状况?

时间:2019-05-26 12:58:31

标签: jasper-reports

我想像 我想在ireport中计算这些状态字符。

output image.png

present days p=5
absent days  A=3
Leave Days   L=2

我的模板:

    <?xml version="1.0" encoding="UTF-8"?>
<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="attendance_report" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="16d3a92a-64fe-4827-883b-4a161b2dc49d">
    <queryString>
        <![CDATA[SELECT * FROM `empolyee_attendance`]]>
    </queryString>
    <field name="id" class="java.lang.Integer"/>
    <field name="emp_id" class="java.lang.Integer"/>
    <field name="emp_name" class="java.lang.String"/>
    <field name="start_time" class="java.lang.String"/>
    <field name="end_time" class="java.lang.String"/>
    <field name="status" class="java.lang.String"/>
    <field name="regdate" class="java.lang.String"/>
    <field name="last_update" class="java.lang.String"/>
    <variable name="status_1" class="java.lang.Integer" calculation="Count">
        <variableExpression><![CDATA[($V{status_1}.equals("P"))]]></variableExpression>
    </variable>
    <variable name="status_2" class="java.lang.Integer" resetType="Page" calculation="Count">
        <variableExpression><![CDATA[$F{status}]]></variableExpression>
    </variable>
    <variable name="emp_name_1" class="java.lang.Integer" resetType="Page" calculation="Count">
        <variableExpression><![CDATA[$F{emp_name}]]></variableExpression>
    </variable>
    <variable name="status_3" class="java.lang.Integer" resetType="Page" calculation="DistinctCount">
        <variableExpression><![CDATA[$F{status}]]></variableExpression>
    </variable>
    <title>
        <band height="40" splitType="Stretch">
            <staticText>
                <reportElement x="2" y="13" width="354" height="23" uuid="8af8f4ee-40e9-46d0-a6d7-b391d36c9fd9"/>
                <textElement>
                    <font size="14" isBold="true"/>
                </textElement>
                <text><![CDATA[Empolyee Attendance Reports ]]></text>
            </staticText>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement x="416" y="17" width="100" height="20" uuid="6b03a44b-b137-4396-bc73-d6ce843dcfb7"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="81" splitType="Stretch">
            <staticText>
                <reportElement x="4" y="27" width="100" height="16" uuid="d906edc7-2497-4c05-8435-5d7c9f21e2ce"/>
                <text><![CDATA[Absent Days]]></text>
            </staticText>
            <staticText>
                <reportElement x="4" y="44" width="100" height="16" uuid="7daa8cd1-349c-409a-ba35-d83425afd663"/>
                <text><![CDATA[Leave Days]]></text>
            </staticText>
            <staticText>
                <reportElement x="4" y="62" width="100" height="16" uuid="178362b9-73ec-45b0-9b08-84524ec9a906"/>
                <text><![CDATA[Total Month days]]></text>
            </staticText>
            <staticText>
                <reportElement x="4" y="10" width="100" height="16" uuid="befe2df8-3beb-4204-a339-6c377677f555"/>
                <text><![CDATA[Present Days]]></text>
            </staticText>
        </band>
    </pageHeader>
<columnHeader>
    <band height="36" splitType="Stretch">
        <rectangle>
            <reportElement x="0" y="2" width="553" height="30" backcolor="#FFCC99" uuid="7db87eac-bb51-408f-8772-d7691186e35f"/>
        </rectangle>
        <staticText>
            <reportElement x="10" y="2" width="39" height="20" uuid="ca66f02c-c2b5-4147-979e-1b152a90f4ed"/>
            <textElement>
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[SrNo]]></text>
        </staticText>
        <staticText>
            <reportElement x="61" y="2" width="50" height="20" uuid="a3886825-01b2-4fae-a8d0-2f96fe91e59a"/>
            <textElement>
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[Emp ID]]></text>
        </staticText>
        <staticText>
            <reportElement x="149" y="2" width="100" height="20" uuid="e073001d-a4e8-4370-8dc4-d8029f0b78be"/>
            <textElement>
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[Start Time]]></text>
        </staticText>
        <staticText>
            <reportElement x="264" y="2" width="100" height="20" uuid="86323ede-a3a9-48d9-8a83-6a86b5a44967"/>
            <textElement>
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[End Time]]></text>
        </staticText>
        <staticText>
            <reportElement x="450" y="3" width="100" height="20" uuid="60b93931-aaf1-42f2-9a36-04c0f6169b83"/>
            <textElement textAlignment="Right">
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[Regdate]]></text>
        </staticText>
        <staticText>
            <reportElement x="391" y="2" width="84" height="20" uuid="7c936914-bb99-4e4a-8eb6-f66bbf6119c9"/>
            <textElement>
                <font size="13" isBold="true"/>
            </textElement>
            <text><![CDATA[Status]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="18" splitType="Stretch">
        <textField>
            <reportElement x="10" y="0" width="29" height="16" uuid="df8e0c53-6dd8-430f-846f-63c018b7e553"/>
            <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="61" y="0" width="79" height="16" uuid="0f79e3ad-b523-4c72-91a1-da239e086d80"/>
            <textFieldExpression><![CDATA[$F{emp_id}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="149" y="0" width="100" height="16" uuid="f265bd1b-c01a-4519-a4f2-81143e1c11db"/>
            <textFieldExpression><![CDATA[$F{start_time}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="264" y="0" width="100" height="16" uuid="5bd74e93-8b87-49eb-8188-cc29c483ae4e"/>
            <textFieldExpression><![CDATA[$F{end_time}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="450" y="0" width="100" height="16" uuid="a8207318-60b9-4f3b-86bf-6ffe20e6ffb3"/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA[$F{regdate}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="391" y="0" width="84" height="16" uuid="095298a3-d47b-4e77-b7df-d4387fc3e240"/>
            <textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<pageFooter>
    <band height="54" splitType="Stretch">
        <textField>
            <reportElement x="11" y="34" width="80" height="20" uuid="12778826-9c73-417d-99d2-6597b7080a6a"/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
        </textField>
        <textField evaluationTime="Report">
            <reportElement x="91" y="34" width="40" height="20" uuid="3922050b-ed16-4f96-a2d4-df012812812f"/>
            <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="437" y="34" width="100" height="20" uuid="5d880110-1cc0-4f7d-9d83-c92b5321a4b7"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
</jasperReport>

如何在iReport中做到这一点?

0 个答案:

没有答案