liding
9 天以前 db628292cb9b69b901b44b146ac88c5f68e38389
src/main/resources/mapper/account/AccountExpenseMapper.xml
@@ -16,6 +16,9 @@
        <if test="accountExpense.expenseType != null and accountExpense.expenseType != '' ">
            AND expense_type = #{accountExpense.expenseType}
        </if>
        <if test="accountExpense.expenseCategory != null and accountExpense.expenseCategory != '' ">
            AND expense_category = #{accountExpense.expenseCategory}
        </if>
        <if test="accountExpense.expenseMethod != null and accountExpense.expenseMethod != '' ">
            AND expense_method = #{accountExpense.expenseMethod}
        </if>
@@ -35,6 +38,9 @@
        <if test="accountExpense.expenseType != null and accountExpense.expenseType != '' ">
            AND expense_type = #{accountExpense.expenseType}
        </if>
        <if test="accountExpense.expenseCategory != null and accountExpense.expenseCategory != '' ">
            AND expense_category = #{accountExpense.expenseCategory}
        </if>
        <if test="accountExpense.expenseMethod != null and accountExpense.expenseMethod != '' ">
            AND expense_method = #{accountExpense.expenseMethod}
        </if>
@@ -53,7 +59,7 @@
        <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
            AND expense_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
        </if>
        group by expense_type
        group by ae.expense_type, sdd.dict_label
    </select>
    <select id="report1" resultType="java.math.BigDecimal">
@@ -70,4 +76,40 @@
        </if>
    </select>
    <select id="reportByCategory" resultType="java.util.Map">
        SELECT COALESCE(sdd.dict_label, '未分类') AS categoryName,
               ae.expense_category AS categoryValue,
               SUM(ae.expense_money) AS amount
        FROM account_expense ae
        LEFT JOIN sys_dict_data sdd ON ae.expense_category = sdd.dict_value
          AND sdd.dict_type = 'finance_expense_category'
        WHERE 1=1
        <if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != ''">
            AND ae.expense_date &gt;= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
        </if>
        <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != ''">
            AND ae.expense_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
        </if>
        GROUP BY ae.expense_category, sdd.dict_label
    </select>
    <select id="trendByCategory" resultType="java.util.Map">
        SELECT DATE_FORMAT(ae.expense_date, '%Y-%m') AS month,
               ae.expense_category AS categoryValue,
               COALESCE(sdd.dict_label, '未分类') AS categoryName,
               SUM(ae.expense_money) AS amount
        FROM account_expense ae
        LEFT JOIN sys_dict_data sdd ON ae.expense_category = sdd.dict_value
          AND sdd.dict_type = 'finance_expense_category'
        WHERE 1=1
        <if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != ''">
            AND ae.expense_date &gt;= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
        </if>
        <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != ''">
            AND ae.expense_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
        </if>
        GROUP BY DATE_FORMAT(ae.expense_date, '%Y-%m'), ae.expense_category, sdd.dict_label
        ORDER BY month, ae.expense_category
    </select>
</mapper>