Files
fad_oa/ruoyi-oa/src/main/resources/mapper/oa/SysOaFinanceMapper.xml

204 lines
8.6 KiB
XML
Raw Normal View History

2024-07-07 21:09:28 +08:00
<?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.oa.mapper.SysOaFinanceMapper">
<resultMap type="com.ruoyi.oa.domain.vo.SysOaFinanceVo" id="SysOaFinanceResult">
2024-07-07 21:09:28 +08:00
<result property="financeId" column="finance_id"/>
<result property="projectId" column="project_id"/>
<result property="financeTitle" column="finance_title"/>
<result property="financeParties" column="finance_parties"/>
<result property="payType" column="pay_type"/>
<result property="financeType" column="finance_type"/>
<result property="financeTime" column="finance_time"/>
<result property="makeRatio" column="make_ratio"/>
<result property="makePrice" column="make_price"/>
<result property="makeTime" column="make_time"/>
<result property="makeExplain" column="make_explain"/>
<result property="accessory" column="accessory"/>
<result property="remark" column="finance_remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
2024-12-30 16:44:53 +08:00
<result property="outType" column="out_type"/>
<result property="outMoney" column="out_money"/>
<result property="totalOut" column="total_out"/>
<result property="totalIn" column="total_in"/>
<result property="month" column="month"/>
2024-12-30 16:44:53 +08:00
<result property="receiveAccountId" column="receive_account_id"/>
<result property="receiveAccountName" column="receive_account_name"/>
2024-07-07 21:09:28 +08:00
<association property="project" column="project_id" javaType="SysOaProject" resultMap="SysOaProjectResult"/>
<association property="detailList" javaType="java.util.List" resultMap="detailResult"/>
</resultMap>
<resultMap id="detailResult" type="SysOaDetail">
<id property="detailId" column="detail_id"/>
<result property="financeId" column="finance_id"/>
<result property="detailTitle" column="detail_title"/>
<result property="price" column="price"/>
<result property="bigPrice" column="big_price"/>
<result property="exitType" column="exit_type"/>
<result property="remark" column="detail_remark"/>
</resultMap>
<resultMap id="SysOaProjectResult" type="SysOaProject">
<result property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
</resultMap>
<sql id="selectFinanceVo">
select a.finance_id,
a.project_id,
a.finance_title,
a.finance_parties,
a.pay_type,
a.finance_type,
a.finance_time,
a.make_ratio,
a.make_price,
a.make_time,
a.make_explain,
a.accessory,
a.remark as finance_remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
b.detail_id,
b.detail_title,
2024-12-30 16:44:53 +08:00
a.out_type,
2024-07-07 21:09:28 +08:00
b.price,
b.big_price,
b.remark as detail_remark
from sys_oa_finance a
left join sys_oa_detail b on a.finance_id = b.finance_id
</sql>
<select id="selectPageFinanceList" resultMap="SysOaFinanceResult">
<include refid="selectFinanceVo" />
${ew.getCustomSqlSegment}
</select>
<select id="selectFinanceList" resultMap="SysOaFinanceResult">
select sof.finance_id,
sof.project_id,
sof.finance_title,
sof.finance_parties,
sof.pay_type,
sof.finance_type,
sof.finance_time,
sof.make_ratio,
sof.make_price,
sof.make_time,
sof.make_explain,
sof.accessory,
sof.remark as finance_remark,
sof.create_by,
sof.create_time,
sof.update_by,
sof.update_time,
2024-12-30 16:44:53 +08:00
sof.out_type,
b.detail_id,
b.detail_title,
b.price,
b.big_price,
b.remark as detail_remark,
p.project_id,
p.project_name,
sora.receive_account_name,
sora.receive_account_id
from sys_oa_finance sof
left join sys_oa_detail b on sof.finance_id = b.finance_id
left join sys_oa_project p on sof.project_id = p.project_id
left join sys_oa_receive_account sora on sof.receive_account_id = sora.receive_account_id
2024-07-07 21:09:28 +08:00
${ew.getCustomSqlSegment}
</select>
<select id="selectFinanceById" parameterType="Long" resultMap="SysOaFinanceResult">
select sof.finance_id,
sof.project_id,
sof.finance_title,
sof.finance_parties,
sof.pay_type,
sof.finance_type,
sof.finance_time,
sof.make_ratio,
sof.make_price,
sof.make_time,
sof.make_explain,
sof.accessory,
sof.remark as finance_remark,
sof.create_by,
sof.create_time,
sof.update_by,
sof.update_time,
2024-12-30 16:44:53 +08:00
sof.out_type,
b.detail_id,
b.detail_title,
b.price,
b.big_price,
b.remark as detail_remark,
p.project_id,
p.project_name,
sora.receive_account_name,
sora.receive_account_id
from sys_oa_finance sof
left join sys_oa_detail b on sof.finance_id = b.finance_id
left join sys_oa_project p on sof.project_id = p.project_id
left join sys_oa_receive_account sora on sof.receive_account_id = sora.receive_account_id
where sof.finance_id = #{financeId}
2024-07-07 21:09:28 +08:00
</select>
<!--进出账查询-->
<select id="selectFinanceByProjectId" resultMap="SysOaFinanceResult">
select a.finance_id, a.project_id, a.finance_title, a.finance_parties, a.pay_type, a.finance_type, a.finance_time, a.make_ratio, a.make_price, a.make_time, a.make_explain, a.accessory, a.remark as finance_remark, a.create_by, a.create_time, a.update_by, a.update_time,
2024-12-30 16:44:53 +08:00
b.detail_id, b.detail_title, b.price, b.big_price, b.remark as detail_remark,a.out_type
2024-07-07 21:09:28 +08:00
from sys_oa_finance a
left join sys_oa_detail b on a.finance_id = b.finance_id
where a.project_id = #{projectId} and a.finance_type = #{financeType}
</select>
<!--进出账查询-->
<select id="findFinanceByTime" resultMap="SysOaFinanceResult">
<include refid="selectFinanceVo" />
where a.finance_type = #{financeType}
2025-02-15 10:45:23 +08:00
<if test=" payType!=NULL and payType!=null and payType !='0' and payType!=0 ">
2024-12-16 11:27:43 +08:00
and a.pay_type = #{payType}
</if>
2025-02-15 10:45:23 +08:00
<if test=" receiveAccountId!=NULL and receiveAccountId!=null and receiveAccountId!='-1' ">
and a.receive_account_id = #{receiveAccountId}
</if>
2024-07-07 21:09:28 +08:00
and a.project_id = 0
and date_format(a.finance_time,'%Y-%m-%d %H:%i:%s') >= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
and date_format(a.finance_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
</select>
<select id="getBarData" resultMap="SysOaFinanceResult">
SELECT
DATE_FORMAT(a.create_time, '%Y-%m') AS month,
SUM(CASE WHEN a.finance_type = '0' THEN b.price ELSE 0 END) AS total_out,
SUM(CASE WHEN a.finance_type = '1' THEN b.price ELSE 0 END) AS total_in
FROM sys_oa_finance a
LEFT JOIN sys_oa_detail b
ON a.finance_id = b.finance_id
AND a.create_time >= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 5 MONTH), '%Y-%m-01')
AND DATE_ADD(DATE_FORMAT(NOW(), '%Y-%m-01'), INTERVAL 1 MONTH) > a.create_time
GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
ORDER BY month;
2024-12-30 16:44:53 +08:00
</select>
2024-07-07 21:09:28 +08:00
<!--项目进出账查询-->
<!-- <select id="findFinanceByTimeAndProjectId" resultMap="SysOaFinanceResult">
<include refid="selectFinanceVo" />
where a.finance_type = #{financeType}
and a.project_id > 0
and date_format(a.create_time,'%Y-%m-%d %H:%i:%s') >= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
and date_format(a.create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
</select>-->
</mapper>