<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<mapper namespace="com.ruoyi.account.mapper.AccountExpenseMapper">
|
<select id="accountExpenseListPage" resultType="com.ruoyi.account.pojo.AccountExpense">
|
SELECT
|
*
|
FROM account_expense
|
where
|
1=1
|
<if test="accountExpense.entryDateStart != null and accountExpense.entryDateStart != '' ">
|
AND expense_date >= DATE_FORMAT(#{accountExpense.entryDateStart},'%Y-%m-%d')
|
</if>
|
<if test="accountExpense.entryDateEnd != null and accountExpense.entryDateEnd != '' ">
|
AND expense_date <= DATE_FORMAT(#{accountExpense.entryDateEnd},'%Y-%m-%d')
|
</if>
|
<if test="accountExpense.expenseType != null and accountExpense.expenseType != '' ">
|
AND expense_type = #{accountExpense.expenseType}
|
</if>
|
<if test="accountExpense.expenseMethod != null and accountExpense.expenseMethod != '' ">
|
AND expense_method = #{accountExpense.expenseMethod}
|
</if>
|
</select>
|
<select id="accountExpenseExport" resultType="com.ruoyi.account.pojo.AccountExpense">
|
SELECT
|
*
|
FROM account_expense
|
where
|
1=1
|
<if test="accountExpense.entryDateStart != null and accountExpense.entryDateStart != '' ">
|
AND expense_date >= DATE_FORMAT(#{accountExpense.entryDateStart},'%Y-%m-%d')
|
</if>
|
<if test="accountExpense.entryDateEnd != null and accountExpense.entryDateEnd != '' ">
|
AND expense_date <= DATE_FORMAT(#{accountExpense.entryDateEnd},'%Y-%m-%d')
|
</if>
|
<if test="accountExpense.expenseType != null and accountExpense.expenseType != '' ">
|
AND expense_type = #{accountExpense.expenseType}
|
</if>
|
<if test="accountExpense.expenseMethod != null and accountExpense.expenseMethod != '' ">
|
AND expense_method = #{accountExpense.expenseMethod}
|
</if>
|
</select>
|
<select id="report" resultType="com.ruoyi.account.dto.AccountDto2">
|
SELECT
|
sdd.dict_label typeName,
|
sum(expense_money) account
|
FROM account_expense ae
|
left join sys_dict_data sdd on ae.expense_type = sdd.dict_value and sdd.dict_type='expense_types'
|
where
|
1=1
|
<if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != '' ">
|
AND expense_date >= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
|
</if>
|
<if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
|
AND expense_date <= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
|
</if>
|
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 >= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
|
</if>
|
<if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
|
AND expense_date <= 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 >= #{startDate}
|
</if>
|
<if test="endDate != null and endDate != ''">
|
AND ae.expense_date <= #{endDate}
|
</if>
|
</where>
|
GROUP BY ae.expense_type, sdd.dict_label
|
</select>
|
|
</mapper>
|