buhuazhen
6 天以前 c60f4c46134cafd36f6531114f03828faf755166
src/main/resources/mapper/account/AccountExpenseMapper.xml
@@ -10,6 +10,12 @@
        <if test="accountExpense.entryDateStart != null and accountExpense.entryDateStart != '' ">
            AND expense_date &gt;= DATE_FORMAT(#{accountExpense.entryDateStart},'%Y-%m-%d')
        </if>
        <if test=" accountExpense.supplierName != null and accountExpense.supplierName != ''">
            AND supplier_name like CONCAT('%',#{accountExpense.supplierName},'%')
        </if>
        <if test=" accountExpense.invoiceNumber != null and accountExpense.invoiceNumber != ''">
            AND invoice_number like CONCAT('%',#{accountExpense.invoiceNumber},'%')
        </if>
        <if test="accountExpense.entryDateEnd != null and accountExpense.entryDateEnd != '' ">
            AND  expense_date &lt;= DATE_FORMAT(#{accountExpense.entryDateEnd},'%Y-%m-%d')
        </if>
@@ -56,4 +62,40 @@
        group by expense_type
    </select>
    <select id="report1" resultType="java.math.BigDecimal">
        SELECT
        ifnull(sum(expense_money),0) account
        FROM account_expense ai
        where
        expense_type=#{dictValue}
        <if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != '' ">
            AND expense_date &gt;= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
        </if>
        <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
            AND expense_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
        </if>
    </select>
    <select id="selectAccountExpenseStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
        SELECT DATE_FORMAT(expense_date, #{dateFormat}) as dateStr, IFNULL(SUM(expense_money), 0) as amount
        FROM account_expense
        WHERE expense_date BETWEEN #{startDate} AND #{endDate}
        GROUP BY dateStr
    </select>
    <select id="selectExpenseComposition" resultType="com.ruoyi.dto.MapDto">
        SELECT sdd.dict_label as name, CAST(IFNULL(SUM(ae.expense_money), 0) AS CHAR) as value
        FROM account_expense ae
        LEFT JOIN sys_dict_data sdd ON ae.expense_type = sdd.dict_value AND sdd.dict_type = 'expense_types'
        <where>
            <if test="startDate != null and startDate != ''">
                AND ae.expense_date &gt;= #{startDate}
            </if>
            <if test="endDate != null and endDate != ''">
                AND ae.expense_date &lt;= #{endDate}
            </if>
        </where>
        GROUP BY ae.expense_type, sdd.dict_label
    </select>
</mapper>