后台-退料申请与审核
This commit is contained in:
parent
891246c5a9
commit
b15f613f82
|
|
@ -396,94 +396,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="getView" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
|
<select id="getView" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
|
||||||
SELECT
|
SELECT
|
||||||
result1.*,
|
bai.back_person AS backPerson,
|
||||||
result2.num AS useNum
|
bai.phone AS phone,
|
||||||
|
bai.back_time as backTime,
|
||||||
|
lot.lot_name AS lotName,
|
||||||
|
unit.unit_name AS unitName,
|
||||||
|
mt.type_name typeCode,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
bagi.agreement_code as agreementCode,
|
||||||
|
bad.pre_num AS num
|
||||||
FROM
|
FROM
|
||||||
(
|
back_apply_details bad
|
||||||
-- 结果1的原始查询
|
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
|
||||||
SELECT
|
LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id
|
||||||
bad.id as detailsId,
|
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
|
||||||
bpl.lot_name as lotName,
|
LEFT JOIN bm_project_lot lot ON lot.lot_id = bagi.project_id
|
||||||
bui.unit_name as unitName,
|
LEFT JOIN bm_unit_info unit ON unit.unit_id = bagi.unit_id
|
||||||
bagi.agreement_code as agreementCode,
|
LEFT JOIN ma_type mt ON mt.type_id = bad.type_id
|
||||||
bai.back_person as backPerson,
|
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id
|
||||||
bai.phone,
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||||
bai.back_time as backTime,
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||||
bai.`code`,
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||||
bai.remark,
|
WHERE
|
||||||
us.user_name as createName,
|
bai.id = #{id}
|
||||||
us2.user_name as examineName,
|
|
||||||
bad.type_id as typeId,
|
|
||||||
mt.type_name typeCode,
|
|
||||||
CONCAT_WS(
|
|
||||||
'/',
|
|
||||||
IFNULL( mt3.type_name, '' )) AS typeName,
|
|
||||||
bad.pre_num AS num,
|
|
||||||
mm.ma_code AS maCode
|
|
||||||
FROM
|
|
||||||
back_apply_details bad
|
|
||||||
LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id
|
|
||||||
LEFT JOIN ma_type mt ON mt.type_id = bad.type_id
|
|
||||||
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id
|
|
||||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
|
||||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
||||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
||||||
LEFT JOIN ma_machine mm ON mm.type_id = bad.type_id
|
|
||||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id
|
|
||||||
LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id
|
|
||||||
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bagi.project_id
|
|
||||||
LEFT JOIN bm_unit_info bui ON bui.unit_id = bagi.unit_id
|
|
||||||
LEFT JOIN sys_user us on us.user_id=bai.create_by
|
|
||||||
LEFT JOIN sys_user us2 on us2.user_id=bai.direct_audit_by
|
|
||||||
WHERE
|
|
||||||
bai.id = #{id}
|
|
||||||
<if test="keyWord != null and keyWord != ''">
|
|
||||||
and mt.type_name like concat('%', #{keyWord}, '%') or
|
|
||||||
mt3.type_name like concat('%', #{keyWord}, '%') or
|
|
||||||
mm.ma_code like concat('%', #{keyWord}, '%')
|
|
||||||
</if>
|
|
||||||
) AS result1
|
|
||||||
LEFT JOIN
|
|
||||||
(
|
|
||||||
-- 结果2的原始查询,作为子查询
|
|
||||||
SELECT
|
|
||||||
subquery1.type_id AS typeId,
|
|
||||||
subquery1.typeName typeCode,
|
|
||||||
subquery1.out_num - COALESCE ( subquery2.audit_num, 0 ) AS num
|
|
||||||
FROM
|
|
||||||
(-- 第一个查询作为子查询
|
|
||||||
SELECT
|
|
||||||
mt.type_id,
|
|
||||||
mt.type_name AS typeName,
|
|
||||||
lod.out_num
|
|
||||||
FROM
|
|
||||||
tm_task_agreement tta
|
|
||||||
LEFT JOIN lease_apply_info lai ON lai.task_id = tta.task_id
|
|
||||||
LEFT JOIN lease_out_details lod ON lod.parent_id = lai.id
|
|
||||||
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
|
||||||
LEFT JOIN tm_task tt ON tt.task_id = tta.task_id
|
|
||||||
WHERE
|
|
||||||
tta.agreement_id = #{agreementId}
|
|
||||||
AND tt.task_type = '29'
|
|
||||||
and mt.type_id is not null
|
|
||||||
) AS subquery1
|
|
||||||
LEFT JOIN (-- 第二个查询作为子查询
|
|
||||||
SELECT
|
|
||||||
mt.type_id,
|
|
||||||
mt.type_name,
|
|
||||||
bad.audit_num
|
|
||||||
FROM
|
|
||||||
tm_task tt
|
|
||||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
|
|
||||||
LEFT JOIN back_apply_info bai ON bai.task_id = tta.task_id
|
|
||||||
LEFT JOIN back_apply_details bad ON bad.parent_id = bai.id
|
|
||||||
LEFT JOIN ma_type mt ON mt.type_id = bad.type_id
|
|
||||||
WHERE
|
|
||||||
tta.agreement_id = #{agreementId}
|
|
||||||
AND tt.task_type = '36'
|
|
||||||
and mt.type_id is not null
|
|
||||||
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
|
||||||
) AS result2 ON result1.typeId = result2.typeId
|
|
||||||
</select>
|
</select>
|
||||||
<select id="getUseTypeTree" resultType="com.bonus.sgzb.material.domain.TypeTreeNode">
|
<select id="getUseTypeTree" resultType="com.bonus.sgzb.material.domain.TypeTreeNode">
|
||||||
WITH RECURSIVE cte AS (
|
WITH RECURSIVE cte AS (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue