zn-cloud/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/oa/BpmOALoanMapper.xml
furongxin f1b88b349a fix(bpm): 修复报销和借款相关问题
- 修改报销查询条件,使用月份格式比较时间- 更新报销和借款关联方式,使用 LEFT JOIN
- 在报销流程中添加工厂 ID 变量- 优化借款查询 SQL,移除不必要的条件
2025-04-10 01:20:06 +08:00

75 lines
2.8 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALoanMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectSumByStaffId" resultType="cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO">
SELECT
sf_user_id AS sfUserId,
SUM(total_money) AS totalAmount
FROM
bpm_oa_loan
WHERE
deleted = 0
AND result = 2
AND return_date = #{month}
AND sf_user_id IN
<foreach item="item" index="index" collection="staffId" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
sf_user_id
</select>
<select id="selectReturnList" resultType="cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.loan.BpmOAReturnVO">
<if test="pageReqVO.loanType == 1">
SELECT
s.staff_id AS staffId,
CONVERT(st.nick_name USING utf8mb4) COLLATE utf8mb4_unicode_ci AS staffName,
s.factory_id AS factoryId,
sf.short_name AS factoryName,
s.month AS month,
s.return_amount AS repaymentAmount,
2 AS type
FROM
sf_staff_salary s
LEFT JOIN sf_staff st ON s.staff_id = st.id
LEFT JOIN sf_factory_info sf ON s.factory_id = sf.id
WHERE
s.staff_id = #{pageReqVO.staffId}
AND s.return_amount &gt; 0
AND s.deleted = 0
AND st.deleted = 0
AND sf.deleted = 0
</if>
<if test="pageReqVO.loanType == 2">
SELECT
e.user_id AS staffId,
u.nickname AS staffName,
d.factory_id AS factoryId,
d.name AS factoryName,
DATE_FORMAT( p.end_time, '%Y-%m' ) AS month,
e.amount_paid AS repaymentAmount,
1 AS type
FROM
bpm_oa_expenses e
LEFT JOIN system_users u ON e.user_id = u.id
LEFT JOIN system_dept d ON u.dept_id = d.id
LEFT JOIN bpm_process_instance_ext p ON e.process_instance_id = p.process_instance_id
WHERE
e.deleted = 0
AND e.result = 2
AND e.status = 2
AND u.deleted = 0
AND d.deleted = 0
AND p.deleted = 0
</if>
</select>
</mapper>