接口提交
This commit is contained in:
parent
91426aaa7d
commit
9e8e4335b7
|
|
@ -6,170 +6,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getProjUsingRecordList" resultType="com.bonus.material.basic.domain.ProjUsingRecord">
|
||||
SELECT
|
||||
subquery1.agreementCode as agreementCode,
|
||||
subquery1.unitName as unitName,
|
||||
subquery1.proName as proName,
|
||||
subquery1.contractPart as contractPart,
|
||||
subquery1.impUnitName as impUnitName,
|
||||
subquery1.typeName as typeName,
|
||||
subquery1.typeModelName as typeModelName,
|
||||
subquery1.unit as unit,
|
||||
IFNULL(subquery1.leaseNum, 0) as leaseNum,
|
||||
IFNULL(subquery2.backNum, 0) as backNum,
|
||||
CASE
|
||||
WHEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0) > 0
|
||||
THEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0)
|
||||
ELSE 0.000
|
||||
END as usNum,
|
||||
CASE
|
||||
WHEN IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0) > 0 THEN
|
||||
ROUND(IFNULL(subquery1.buy_price, 0) *
|
||||
(IFNULL(subquery1.leaseNum, 0) - IFNULL(subquery2.backNum, 0)), 2)
|
||||
ELSE
|
||||
0.00
|
||||
END as usPrice,
|
||||
ROUND(IFNULL(subquery1.leaseNum, 0) * IFNULL(subquery1.buy_price, 0), 2) as totalPrice,
|
||||
subquery1.isSlt as isSlt,
|
||||
subquery1.isSltName as isSltName
|
||||
FROM (SELECT bai.agreement_id,
|
||||
mt.type_id,
|
||||
mt.buy_price,
|
||||
bai.agreement_code AS agreementCode,
|
||||
bui.unit_name AS unitName,
|
||||
bpl.pro_name AS proName,
|
||||
bpl.contract_part as contractPart,
|
||||
sd.dept_name as impUnitName,
|
||||
bp.pro_name AS proName,
|
||||
bu.unit_name AS unitName,
|
||||
sd.dept_name AS impUnitName,
|
||||
mt2.type_name AS typeName,
|
||||
bp.contract_part AS contractPart,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
SUM(IFNULL(lod.out_num, 0)) AS leaseNum,
|
||||
sai.is_slt as isSlt,
|
||||
CASE
|
||||
sai.is_slt
|
||||
WHEN '0' then '未结算'
|
||||
WHEN '1' then '已结算'
|
||||
ELSE ''
|
||||
END as isSltName
|
||||
FROM lease_out_details lod
|
||||
LEFT JOIN lease_apply_info lai ON lai.id = lod.parent_id
|
||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = lai.task_id
|
||||
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
|
||||
LEFT JOIN (
|
||||
SELECT agreement_id, is_slt
|
||||
FROM slt_agreement_info
|
||||
GROUP BY agreement_id
|
||||
) sai ON bai.agreement_id = sai.agreement_id
|
||||
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
||||
LEFT JOIN sys_dept sd on sd.dept_id = bpl.imp_unit
|
||||
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
||||
ifnull(SUM( sai.num ) , 0) AS leaseNum,
|
||||
ifnull(SUM( CASE WHEN sai.end_time IS NOT NULL THEN sai.num ELSE 0 END ) , 0) AS backNum,
|
||||
ifnull(SUM( CASE WHEN sai.end_time IS NULL THEN sai.num ELSE 0 END ) , 0) AS usNum,
|
||||
ROUND(
|
||||
IFNULL( mt.buy_price, 0 ) * IFNULL( SUM( CASE WHEN sai.end_time IS NULL THEN sai.num ELSE 0 END ), 0 ),
|
||||
2
|
||||
) AS usPrice,
|
||||
ROUND( IFNULL( mt.buy_price, 0 ) * IFNULL( SUM( sai.num ), 0 ), 2 ) AS totalPrice
|
||||
FROM
|
||||
bm_agreement_info bai
|
||||
LEFT JOIN slt_agreement_info sai ON sai.agreement_id = bai.agreement_id
|
||||
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||||
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
||||
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = lod.ma_id
|
||||
where 1=1
|
||||
<if test="externalId != null and externalId != '' ">
|
||||
and bpl.external_id = #{externalId}
|
||||
WHERE
|
||||
1=1
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
and bai.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (bai.agreement_code like concat('%',#{keyWord},'%') or
|
||||
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||
bpl.pro_name like concat('%',#{keyWord},'%') or
|
||||
bu.unit_name like concat('%',#{keyWord},'%') or
|
||||
bp.pro_name like concat('%',#{keyWord},'%') or
|
||||
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||
mt.type_name like concat('%',#{keyWord},'%') or
|
||||
mt.unit_name like concat('%',#{keyWord},'%') or
|
||||
bpl.contract_part like concat('%', #{keyWord}, '%') or
|
||||
sd.dept_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="unitId != null">
|
||||
and bui.unit_id = #{unitId}
|
||||
and bu.unit_id = #{unitId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and bpl.pro_id = #{proId}
|
||||
and bp.pro_id = #{proId}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
and mt2.type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="typeModelName != null and typeModelName != ''">
|
||||
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND bai.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
</if>
|
||||
<if test="isSlt != null and isSlt != ''">
|
||||
and sai.is_slt = #{isSlt}
|
||||
</if>
|
||||
GROUP BY bai.agreement_id,
|
||||
mt.type_id ORDER BY bai.agreement_code) AS subquery1
|
||||
LEFT JOIN (SELECT bai.agreement_id,
|
||||
mt.type_id,
|
||||
mt.rent_price,
|
||||
bai.agreement_code AS agreementCode,
|
||||
bui.unit_name AS unitName,
|
||||
bpl.pro_name AS proName,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unit,
|
||||
bpl.contract_part as contractPart,
|
||||
sd.dept_name as impUnitName,
|
||||
SUM(IFNULL(bcd.back_num, 0)) backNum,
|
||||
sai.is_slt as isSlt,
|
||||
CASE
|
||||
sai.is_slt
|
||||
WHEN '0' then '未结算'
|
||||
WHEN '1' then '已结算'
|
||||
ELSE ''
|
||||
END as isSltName
|
||||
FROM back_check_details bcd
|
||||
LEFT JOIN back_apply_info baif ON baif.id = bcd.parent_id
|
||||
LEFT JOIN tm_task_agreement tta ON tta.task_id = baif.task_id
|
||||
LEFT JOIN bm_agreement_info bai ON bai.agreement_id = tta.agreement_id
|
||||
LEFT JOIN (
|
||||
SELECT agreement_id, is_slt
|
||||
FROM slt_agreement_info
|
||||
GROUP BY agreement_id
|
||||
) sai ON bai.agreement_id = sai.agreement_id
|
||||
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
|
||||
LEFT JOIN sys_dept sd on sd.dept_id = bpl.imp_unit
|
||||
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
||||
where 1=1 and bcd.is_finished = '1'
|
||||
<if test="externalId != null and externalId != '' ">
|
||||
and bpl.external_id = #{externalId}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (bai.agreement_code like concat('%',#{keyWord},'%') or
|
||||
bui.unit_name like concat('%',#{keyWord},'%') or
|
||||
bpl.pro_name like concat('%',#{keyWord},'%') or
|
||||
mt2.type_name like concat('%',#{keyWord},'%') or
|
||||
mt.type_name like concat('%',#{keyWord},'%') or
|
||||
mt.unit_name like concat('%',#{keyWord},'%') or
|
||||
bpl.contract_part like concat('%', #{keyWord}, '%') or
|
||||
sd.dept_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="unitId != null">
|
||||
and bui.unit_id = #{unitId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and bpl.pro_id = #{proId}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
and mt2.type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="typeModelName != null and typeModelName != ''">
|
||||
and mt.type_name like concat('%',#{typeModelName},'%')
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND bai.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
</if>
|
||||
<if test="isSlt != null and isSlt != ''">
|
||||
and sai.is_slt = #{isSlt}
|
||||
</if>
|
||||
GROUP BY bai.agreement_id,
|
||||
mt.type_id ORDER BY bai.agreement_code) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||
AND subquery1.agreement_id = subquery2.agreement_id
|
||||
GROUP BY
|
||||
bai.agreement_id,
|
||||
mt.type_id
|
||||
ORDER BY
|
||||
bai.agreement_code
|
||||
</select>
|
||||
|
||||
<select id="getMachineHistoryRecordList" resultType="com.bonus.material.basic.domain.MachineHistoryRecordBean">
|
||||
|
|
|
|||
Loading…
Reference in New Issue