161 lines
7.2 KiB
XML
161 lines
7.2 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 (type_id,team_name,lease_man,phone,num,create_by,create_time,type)
|
||
|
|
values (#{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,
|
||
|
|
bui.unit_name AS unitName,
|
||
|
|
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) as kcNum,
|
||
|
|
SUM(CASE WHEN tli.num is null then 0 ELSE tli.num end) AS ckNum,
|
||
|
|
SUM(CASE WHEN sai.`status` = '0' THEN sai.num ELSE 0 END) - SUM(CASE WHEN tli.num IS NULL THEN 0 ELSE tli.num END) 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 bm_unit_person bup ON bui.unit_id = bup.unit_id
|
||
|
|
LEFT JOIN team_lease_info tli ON bup.user_id = tli.create_by and sai.type_id = tli.type_id and tli.type = '1'
|
||
|
|
where 1=1
|
||
|
|
<if test="unitId != null and unitId != ''">
|
||
|
|
and bui.unit_id = #{unitId}
|
||
|
|
</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
|
||
|
|
mt1.type_name like concat('%', #{keyword}, '%') or
|
||
|
|
mt.type_name like concat('%', #{keyword}, '%')
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
GROUP BY
|
||
|
|
bui.unit_id,
|
||
|
|
sai.type_id
|
||
|
|
</select>
|
||
|
|
<select id="getOperateList" resultType="com.bonus.sgzb.material.domain.TeamLeaseInfo">
|
||
|
|
select bui.unit_name AS unitName,
|
||
|
|
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_unit_person bup ON tli.create_by = bup.user_id
|
||
|
|
LEFT JOIN bm_unit_info bui ON bui.unit_id = bup.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="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
|
||
|
|
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.material.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 bm_agreement_info bai ON sai.agreement_id = bai.agreement_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
|
||
|
|
where bui.unit_id = #{unitId} and mt.type_id = #{typeId}
|
||
|
|
<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.material.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 bm_agreement_info bai ON sai.agreement_id = bai.agreement_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
|
||
|
|
where bui.unit_id = #{unitId} 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.material.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 bm_agreement_info bai ON sai.agreement_id = bai.agreement_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
|
||
|
|
where bui.unit_id = #{unitId} 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.material.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 bm_unit_person bup ON tli.create_by = bup.user_id
|
||
|
|
LEFT JOIN bm_unit_info bui ON bui.unit_id = bup.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 bui.unit_id = #{unitId} and mt.type_id = #{typeId}
|
||
|
|
<if test="startTime != null and startTime != ''">
|
||
|
|
and DATE(tli.create_time) = #{startTime}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
</mapper>
|