2024-03-01 17:57:05 +08:00
<?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" >
2024-03-26 18:06:37 +08:00
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});
2024-03-01 17:57:05 +08:00
</insert>
<select id= "getList" resultType= "com.bonus.sgzb.material.domain.SecondaryWarehouse" >
SELECT
2024-03-26 18:06:37 +08:00
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
2024-03-01 17:57:05 +08:00
FROM
2024-03-26 18:06:37 +08:00
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
2024-03-01 17:57:05 +08:00
<if test= "unitId != null and unitId != ''" >
and bui.unit_id = #{unitId}
</if>
2024-03-26 18:06:37 +08:00
<if test= "proId != null and proId != ''" >
and bp.lot_id = #{proId}
</if>
2024-03-01 17:57:05 +08:00
<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
2024-03-26 18:06:37 +08:00
bp.lot_name like concat('%', #{keyword}, '%') or
2024-03-01 17:57:05 +08:00
mt1.type_name like concat('%', #{keyword}, '%') or
mt.type_name like concat('%', #{keyword}, '%')
)
</if>
GROUP BY
2024-03-26 18:06:37 +08:00
sai.agreement_id,
sai.type_id
2024-03-01 17:57:05 +08:00
</select>
2024-08-06 14:25:10 +08:00
<select id= "getOperateList" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-26 18:06:37 +08:00
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
2024-03-01 17:57:05 +08:00
LEFT JOIN ma_type mt ON tli.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
2024-03-26 18:06:37 +08:00
LEFT JOIN sys_user su ON su.user_id = tli.create_by
2024-03-01 17:57:05 +08:00
where tli.type = #{type}
<if test= "unitId != null and unitId != ''" >
and bui.unit_id = #{unitId}
</if>
2024-03-26 18:06:37 +08:00
<if test= "proId != null and proId != ''" >
and bp.lot_id = #{proId}
</if>
2024-03-01 17:57:05 +08:00
<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
2024-03-26 18:06:37 +08:00
bp.lot_name like concat('%', #{keyword}, '%') or
2024-03-01 17:57:05 +08:00
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>
2024-08-06 14:25:10 +08:00
<select id= "getRecordsOne" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-01 17:57:05 +08:00
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
2024-03-26 18:06:37 +08:00
where mt.type_id = #{typeId} and sai.agreement_id=#{agreementId}
2024-03-01 17:57:05 +08:00
<if test= "startTime != null and startTime != ''" >
and DATE(sai.start_time) = #{startTime}
</if>
order by sai.start_time desc
</select>
2024-08-06 14:25:10 +08:00
<select id= "getRecordsTwo" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-01 17:57:05 +08:00
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
2024-03-26 18:06:37 +08:00
where sai.agreement_id=#{agreementId} and mt.type_id = #{typeId} and sai.status = '1'
2024-03-01 17:57:05 +08:00
<if test= "startTime != null and startTime != ''" >
and DATE(sai.end_time) = #{startTime}
</if>
order by sai.end_time desc
</select>
2024-08-06 14:25:10 +08:00
<select id= "getRecordsThree" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-01 17:57:05 +08:00
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
2024-03-26 18:06:37 +08:00
where sai.agreement_id=#{agreementId} and mt.type_id = #{typeId} and sai.status = '0'
2024-03-01 17:57:05 +08:00
<if test= "startTime != null and startTime != ''" >
and DATE(sai.start_time) = #{startTime}
</if>
order by sai.start_time desc
</select>
2024-08-06 14:25:10 +08:00
<select id= "getRecordsFour" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-15 18:00:23 +08:00
select tli.team_name as teamName,
2024-03-01 17:57:05 +08:00
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
2024-03-26 18:06:37 +08:00
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>
2024-08-06 14:25:10 +08:00
<select id= "getRecordsFive" resultType= "com.bonus.sgzb.base.api.domain.TeamLeaseInfo" >
2024-03-26 18:06:37 +08:00
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'
2024-03-01 17:57:05 +08:00
<if test= "startTime != null and startTime != ''" >
and DATE(tli.create_time) = #{startTime}
</if>
</select>
</mapper>