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

105 lines
4.2 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="com.ruoyi.oa.mapper.SysOaWarehouseMasterMapper">
<!-- ===================================================== -->
<!-- 主表 + 子表 统一 ResultMap -->
<!-- ===================================================== -->
<resultMap id="SysOaWarehouseMasterResult"
type="com.ruoyi.oa.domain.vo.SysOaWarehouseMasterVo">
<id property="masterId" column="master_id"/>
<result property="masterNum" column="master_num"/>
<result property="type" column="type"/>
<result property="projectId" column="project_id"/>
<result property="signTime" column="sign_time"/>
<result property="signUser" column="sign_user"/>
<result property="remark" column="remark"/>
<result property="projectName" column="project_name"/>
<result property="status" column="status"/>
<collection property="warehouseList"
column="master_id"
javaType="list"
ofType="com.ruoyi.oa.domain.vo.SysOaWarehouseDetailVo"
select="selectDetailByMasterId"/>
<collection property="warehouseTaskList"
column="master_id"
javaType="list"
ofType="com.ruoyi.oa.domain.SysOaWarehouseTask"
select="selectTaskByMasterId"/>
</resultMap>
<!-- ===================================================== -->
<!-- 分页查询(只查主表字段,真正参与 LIMIT / OFFSET -->
<!-- ===================================================== -->
<select id="selectVoPagePlus"
resultMap="SysOaWarehouseMasterResult">
SELECT
sowm.master_id,
sowm.master_num,
sowm.type,
sowm.project_id,
sowm.sign_time,
sowm.sign_user,
sowm.remark,
sowm.status,
sop.project_name
FROM sys_oa_warehouse_master sowm
LEFT JOIN sys_oa_project sop
ON sop.project_id = sowm.project_id
${ew.getCustomSqlSegment}
</select>
<!-- ===================================================== -->
<!-- 子查询:明细列表 by masterId -->
<!-- ===================================================== -->
<select id="selectDetailByMasterId"
parameterType="long"
resultType="com.ruoyi.oa.domain.vo.SysOaWarehouseDetailVo">
SELECT
sowd.id AS outId,
sowd.master_id,
sowd.sign_price,
sowd.amount,
sowd.project_id,
sow.name AS warehouseName,
COALESCE(sow.model, sowt.model) AS model,
COALESCE(sow.brand, sowt.brand) AS brand,
COALESCE(sow.specifications, sowt.specifications) AS specifications,
sowt.task_inventory,
sop.project_name
FROM sys_oa_warehouse_detail sowd
LEFT JOIN sys_oa_warehouse sow ON sow.id = sowd.warehouse_id
LEFT JOIN sys_oa_warehouse_task sowt ON sowt.master_id = sowd.master_id
LEFT JOIN sys_oa_project sop ON sop.project_id = sowd.project_id
WHERE sowd.del_flag = '0'
AND sowd.master_id = #{masterId}
ORDER BY sowd.id
</select>
<!-- ===================================================== -->
<!-- 子查询:任务列表 by masterId -->
<!-- ===================================================== -->
<select id="selectTaskByMasterId"
parameterType="long"
resultType="com.ruoyi.oa.domain.SysOaWarehouseTask">
SELECT
task_id,
master_id,
name,
model,
task_inventory,
brand,
specifications
FROM sys_oa_warehouse_task
WHERE master_id = #{masterId}
ORDER BY task_id
</select>
</mapper>