185 lines
8.0 KiB
XML
185 lines
8.0 KiB
XML
<?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.bonus.sgzb.material.mapper.SecondaryWarehouseMapper">
|
|
<insert id="addOperate">
|
|
insert into team_lease_info (agreement_id,type_id,team_name,lease_man,phone,num,create_by,create_time,type)
|
|
values (#{agreementId},#{typeId},#{teamName},#{leaseMan},#{phone},#{num},#{createBy},now(),#{type});
|
|
</insert>
|
|
|
|
<select id="getList" resultType="com.bonus.sgzb.material.domain.SecondaryWarehouse">
|
|
SELECT
|
|
bui.unit_id AS unitId,
|
|
sai.agreement_id AS agreementId,
|
|
bui.unit_name AS unitName,
|
|
bp.lot_name AS proName,
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
mt.unit_name AS nuitName,
|
|
sai.type_id AS typeId,
|
|
SUM( sai.num ) AS jcNum,
|
|
SUM( CASE WHEN sai.`status` = '1' THEN sai.num ELSE 0 END ) AS tcNum,
|
|
SUM( CASE WHEN sai.`status` = '0' THEN sai.num ELSE 0 END ) - IFNULL( tli.num, 0 ) + IFNULL( tli2.num, 0 ) AS kcNum,
|
|
IFNULL( tli.num, 0 ) AS ckNum,
|
|
IFNULL( tli2.num, 0 ) AS zkNum
|
|
FROM
|
|
slt_agreement_info sai
|
|
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
|
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
|
|
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
|
|
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
LEFT JOIN ( SELECT SUM( num ) AS num, agreement_id, type_id FROM team_lease_info WHERE type = '1' GROUP BY agreement_id, type_id ) tli ON tli.agreement_id = sai.agreement_id
|
|
AND tli.type_id = sai.type_id
|
|
LEFT JOIN ( SELECT SUM( num ) AS num, agreement_id, type_id FROM team_lease_info WHERE type = '2' GROUP BY agreement_id, type_id ) tli2 ON tli2.agreement_id = sai.agreement_id
|
|
AND tli2.type_id = sai.type_id
|
|
WHERE 1=1
|
|
<if test="unitId != null and unitId != ''">
|
|
and bui.unit_id = #{unitId}
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
and bp.lot_id = #{proId}
|
|
</if>
|
|
<if test="typeId != null and typeId != ''">
|
|
and mt1.type_id = #{typeId}
|
|
</if>
|
|
<if test="modelId != null and modelId != ''">
|
|
and mt.type_id = #{modelId}
|
|
</if>
|
|
<if test="keyword != null and keyword != ''">
|
|
and (bui.unit_name like concat('%', #{keyword}, '%') or
|
|
bp.lot_name like concat('%', #{keyword}, '%') or
|
|
mt1.type_name like concat('%', #{keyword}, '%') or
|
|
mt.type_name like concat('%', #{keyword}, '%')
|
|
)
|
|
</if>
|
|
GROUP BY
|
|
sai.agreement_id,
|
|
sai.type_id
|
|
</select>
|
|
<select id="getOperateList" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
SELECT
|
|
bui.unit_name AS unitName,
|
|
bp.lot_name AS proName,
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
tli.num,
|
|
tli.lease_man AS leaseMan,
|
|
su.nick_name AS createBy,
|
|
tli.create_time AS createTime
|
|
FROM
|
|
team_lease_info tli
|
|
LEFT JOIN bm_agreement_info bai ON tli.agreement_id = bai.agreement_id
|
|
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
|
|
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
|
|
LEFT JOIN ma_type mt ON tli.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
LEFT JOIN sys_user su ON su.user_id = tli.create_by
|
|
where tli.type = #{type}
|
|
<if test="unitId != null and unitId != ''">
|
|
and bui.unit_id = #{unitId}
|
|
</if>
|
|
<if test="proId != null and proId != ''">
|
|
and bp.lot_id = #{proId}
|
|
</if>
|
|
<if test="typeId != null and typeId != ''">
|
|
and mt1.type_id = #{typeId}
|
|
</if>
|
|
<if test="modelId != null and modelId != ''">
|
|
and mt.type_id = #{modelId}
|
|
</if>
|
|
<if test="keyword != null and keyword != ''">
|
|
and (bui.unit_name like concat('%', #{keyword}, '%') or
|
|
bp.lot_name like concat('%', #{keyword}, '%') or
|
|
mt1.type_name like concat('%', #{keyword}, '%') or
|
|
mt.type_name like concat('%', #{keyword}, '%') or
|
|
tli.lease_man like concat('%', #{keyword}, '%') or
|
|
su.nick_name like concat('%', #{keyword}, '%')
|
|
)
|
|
</if>
|
|
</select>
|
|
<select id="getRecordsOne" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
SELECT
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
mt.unit_name as nuitName,
|
|
sai.num AS num,
|
|
sai.start_time as startTime
|
|
FROM
|
|
slt_agreement_info sai
|
|
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
where mt.type_id = #{typeId} and sai.agreement_id=#{agreementId}
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE(sai.start_time) = #{startTime}
|
|
</if>
|
|
order by sai.start_time desc
|
|
</select>
|
|
<select id="getRecordsTwo" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
SELECT
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
mt.unit_name as nuitName,
|
|
sai.num AS num,
|
|
sai.end_time as startTime
|
|
FROM
|
|
slt_agreement_info sai
|
|
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
where sai.agreement_id=#{agreementId} and mt.type_id = #{typeId} and sai.status = '1'
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE(sai.end_time) = #{startTime}
|
|
</if>
|
|
order by sai.end_time desc
|
|
</select>
|
|
<select id="getRecordsThree" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
SELECT
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
mt.unit_name as nuitName,
|
|
sai.num AS num,
|
|
sai.start_time as startTime
|
|
FROM
|
|
slt_agreement_info sai
|
|
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
where sai.agreement_id=#{agreementId} and mt.type_id = #{typeId} and sai.status = '0'
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE(sai.start_time) = #{startTime}
|
|
</if>
|
|
order by sai.start_time desc
|
|
</select>
|
|
<select id="getRecordsFour" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
select tli.team_name as teamName,
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
tli.num,
|
|
su.nick_name as createBy,
|
|
tli.create_time as startTime
|
|
from team_lease_info tli
|
|
LEFT JOIN ma_type mt ON tli.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
left join sys_user su on su.user_id = tli.create_by
|
|
where tli.agreement_id=#{agreementId} and mt.type_id = #{typeId} and tli.type = '1'
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE(tli.create_time) = #{startTime}
|
|
</if>
|
|
</select>
|
|
<select id="getRecordsFive" resultType="com.bonus.sgzb.base.api.domain.TeamLeaseInfo">
|
|
select tli.team_name as teamName,
|
|
mt1.type_name AS typeName,
|
|
mt.type_name AS modelName,
|
|
tli.num,
|
|
su.nick_name as createBy,
|
|
tli.create_time as startTime
|
|
from team_lease_info tli
|
|
LEFT JOIN ma_type mt ON tli.type_id = mt.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
left join sys_user su on su.user_id = tli.create_by
|
|
where tli.agreement_id=#{agreementId} and mt.type_id = #{typeId} and tli.type = '2'
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE(tli.create_time) = #{startTime}
|
|
</if>
|
|
</select>
|
|
</mapper> |