This commit is contained in:
parent
7a2a10372f
commit
27f942d77d
|
|
@ -525,7 +525,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ELSE
|
||||
IFNULL(m.storage_num, 0)
|
||||
END as storage_num,
|
||||
m.company_id as companyId
|
||||
m.company_id as companyId,
|
||||
IFNULL(subquery1.pendingOutNum,0) as pendingOutNum
|
||||
from ma_type m
|
||||
left join (SELECT mt.type_id,
|
||||
mt2.type_name AS typeName,
|
||||
|
|
@ -536,6 +537,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
||||
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
combined.typeId AS typeId,
|
||||
COALESCE ( SUM( combined.pendingOutNum ), 0 ) AS pendingOutNum
|
||||
FROM
|
||||
(-- 第一个查询
|
||||
SELECT
|
||||
lad.type_id AS typeId,
|
||||
SUM( pre_num ) - SUM( al_num ) AS pendingOutNum
|
||||
FROM
|
||||
lease_apply_info lai
|
||||
LEFT JOIN lease_apply_details lad ON lad.parent_id = lai.id
|
||||
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
|
||||
WHERE
|
||||
tt.task_status = '3'
|
||||
AND tt.task_type = '2'
|
||||
GROUP BY
|
||||
lad.type_id UNION ALL-- 第二个查询
|
||||
SELECT
|
||||
lpd.new_type AS typeId,
|
||||
SUM( lpd.num ) - IFNULL( lod.alNum, 0 ) AS pendingOutNum
|
||||
FROM
|
||||
lease_publish_details lpd
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
lod.type_id AS typeId,
|
||||
SUM( lod.out_num ) AS alNum
|
||||
FROM
|
||||
lease_out_details lod
|
||||
WHERE
|
||||
publish_task IS NOT NULL
|
||||
GROUP BY
|
||||
lod.type_id
|
||||
) lod ON lpd.new_type = lod.typeId
|
||||
GROUP BY
|
||||
lpd.new_type
|
||||
) combined
|
||||
GROUP BY
|
||||
combined.typeId
|
||||
) subquery1 on subquery1.typeId=m.type_id
|
||||
<where>
|
||||
m.del_flag = '0'
|
||||
<if test="typeName != null and typeName !=''">
|
||||
|
|
|
|||
Loading…
Reference in New Issue