267 lines
12 KiB
XML
267 lines
12 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.material.clz.mapper.MaterialBackAppointmentMapper">
|
|
<insert id="insertBackPreApply" useGeneratedKeys="true" keyProperty="id">
|
|
insert into clz_back_pre_apply
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="agreementId != null">clz_agreement_id,</if>
|
|
<if test="backTime != null">back_time,</if>
|
|
<if test="backPerson != null">back_person,</if>
|
|
<if test="code != null">back_code,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
create_time,
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="agreementId != null">#{agreementId},</if>
|
|
<if test="backTime != null">#{backTime},</if>
|
|
<if test="backPerson != null">#{backPerson},</if>
|
|
<if test="code != null">#{code},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
NOW(),
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
<insert id="insertBackPreDetails">
|
|
insert into clz_back_pre_details
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="parentId != null">apply_id,</if>
|
|
<if test="typeId != null">type_id,</if>
|
|
<if test="maId != null">ma_id,</if>
|
|
<if test="backNum != null">back_num,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
create_time,
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="parentId != null">#{parentId},</if>
|
|
<if test="typeId != null">#{typeId},</if>
|
|
<if test="maId != null">#{maId},</if>
|
|
<if test="backNum != null">#{backNum},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
NOW(),
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
<update id="updateBackPreApply">
|
|
update clz_back_pre_apply
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="agreementId != null">clz_agreement_id = #{agreementId},</if>
|
|
<if test="backTime != null">back_time = #{backTime},</if>
|
|
<if test="backPerson != null">back_person = #{backPerson},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
update_time = NOW(),
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
<delete id="deleteBackPreDetails">
|
|
delete
|
|
from clz_back_pre_details
|
|
where apply_id = #{parentId}
|
|
</delete>
|
|
<delete id="deleteById">
|
|
delete
|
|
from clz_back_pre_apply
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
<select id="getUseTypeList" resultType="com.bonus.material.clz.domain.back.MaterialBackApplyDetails">
|
|
SELECT
|
|
mt.type_id as typeId,
|
|
mt1.type_name as typeName,
|
|
mt.type_name as typeModel,
|
|
mt.parent_id as parentId,
|
|
mt.unit_name as unitName,
|
|
mt.unit_value as unitValue,
|
|
mt.manage_type as manageType,
|
|
SUM(sai.num) AS num,
|
|
mt.LEVEL as level
|
|
FROM
|
|
ma_type mt
|
|
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
|
WHERE
|
|
sai.STATUS = '0' and sai.is_slt='0' and sai.agreement_id = #{agreementId}
|
|
GROUP BY
|
|
mt.type_id
|
|
HAVING
|
|
num > 0
|
|
</select>
|
|
<select id="selectNumByMonth" resultType="java.lang.Integer">
|
|
select count(*)
|
|
from clz_back_pre_apply
|
|
where DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
|
|
</select>
|
|
<select id="selectBackPreApplyList" resultType="com.bonus.material.clz.domain.back.MaterialBackPreApply">
|
|
SELECT
|
|
cbpa.id,
|
|
bu.unit_name as unitName,
|
|
bp.pro_id as proId,
|
|
bp.pro_name as proName,
|
|
cbpa.back_person as backPerson,
|
|
cbpa.back_time as backTime,
|
|
cbpa.back_code as `code`,
|
|
cbpa.status,
|
|
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
|
|
bp.imp_unit as impUnit,
|
|
bu.bzz_idcard AS idCard
|
|
FROM
|
|
clz_back_pre_apply cbpa
|
|
LEFT JOIN clz_back_pre_details cbpd on cbpd.apply_id=cbpa.id
|
|
LEFT JOIN ma_type mt on mt.type_id=cbpd.type_id
|
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
|
LEFT JOIN bm_agreement_info cbai on cbai.agreement_id=cbpa.clz_agreement_id
|
|
LEFT JOIN bm_unit bu on bu.unit_id=cbai.unit_id
|
|
LEFT JOIN bm_project bp on bp.pro_id=cbai.project_id
|
|
where 1=1
|
|
<if test="unitName != null and unitName!=''">
|
|
and bu.unit_name like CONCAT('%', #{unitName}, '%')
|
|
</if>
|
|
<if test="proName != null and proName!=''">
|
|
and bp.pro_name like CONCAT('%', #{proName}, '%')
|
|
</if>
|
|
<if test="backPerson != null and backPerson!=''">
|
|
and cbpa.back_person like CONCAT('%', #{backPerson}, '%')
|
|
</if>
|
|
<if test="code != null and code!=''">
|
|
and cbpa.back_code like CONCAT('%', #{code}, '%')
|
|
</if>
|
|
<if test="projectIdList != null and projectIdList.size() > 0">
|
|
and bp.external_id in
|
|
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">
|
|
and bu.bzz_idcard = #{idCard}
|
|
</if>
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
and cbpa.back_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
GROUP BY cbpa.id
|
|
ORDER BY cbpa.create_time DESC
|
|
</select>
|
|
<select id="getBackPreApply" resultType="com.bonus.material.clz.domain.back.MaterialBackPreApply">
|
|
SELECT
|
|
cbpa.id,
|
|
bu.unit_id as unitId,
|
|
bu.unit_name as unitName,
|
|
bp.pro_id as proId,
|
|
bp.pro_name as proName,
|
|
cbpa.`status`,
|
|
cbpa.clz_agreement_id as agreementId,
|
|
cbpa.back_time as backTime,
|
|
cbpa.back_person as backPerson
|
|
FROM
|
|
clz_back_pre_apply cbpa
|
|
LEFT JOIN bm_agreement_info bai on bai.agreement_id=cbpa.clz_agreement_id
|
|
LEFT JOIN bm_unit bu on bu.unit_id=bai.unit_id
|
|
LEFT JOIN bm_project bp on bp.pro_id=bai.project_id
|
|
WHERE
|
|
cbpa.id=#{id}
|
|
</select>
|
|
<select id="getListDetails" resultType="com.bonus.material.clz.domain.back.MaterialBackPreDetails">
|
|
SELECT cbpd.id,
|
|
cbpd.apply_id as parentId,
|
|
cbpd.type_id as typeId,
|
|
mt2.type_name as typeName,
|
|
mt.type_name as typeModel,
|
|
mt.unit_name as unitName,
|
|
aa.num,
|
|
mt.manage_type as manageType,
|
|
cbpd.back_num as backNum,
|
|
cbpd.remark
|
|
FROM clz_back_pre_details cbpd
|
|
LEFT JOIN ma_type mt on mt.type_id = cbpd.type_id
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
|
LEFT JOIN (SELECT mt.type_id as typeId,
|
|
mt1.type_name as typeName,
|
|
mt.type_name as typeModel,
|
|
mt.parent_id as parentId,
|
|
mt.unit_name as unitName,
|
|
mt.unit_value as unitValue,
|
|
mt.manage_type as manageType,
|
|
SUM(sai.num) AS num,
|
|
mt.LEVEL as level
|
|
FROM ma_type mt
|
|
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
|
WHERE sai.STATUS = '0'
|
|
and sai.is_slt = '0'
|
|
and sai.agreement_id = #{agreementId}
|
|
GROUP BY mt.type_id
|
|
HAVING num > 0) aa on aa.typeId = cbpd.type_id
|
|
WHERE apply_id = #{id}
|
|
</select>
|
|
<select id="export" resultType="com.bonus.material.clz.domain.back.MaterialBackPreApply">
|
|
SELECT cbpa.id,
|
|
bu.unit_name as unitName,
|
|
bp.pro_name as proName,
|
|
cbpa.back_person as backPerson,
|
|
cbpa.back_time as backTime,
|
|
cbpa.back_code as `code`,
|
|
cbpa.status,
|
|
mt2.type_name as typeName,
|
|
mt.type_name as typeModel,
|
|
mt.unit_name as unit,
|
|
bp.imp_unit as impUnit,
|
|
bu.bzz_idcard AS idCard,
|
|
CASE
|
|
WHEN mt.manage_type = '0' THEN
|
|
'编码'
|
|
ELSE
|
|
'数量'
|
|
END manageType,
|
|
cbpd.back_num as backNum,
|
|
cbpd.remark
|
|
|
|
FROM clz_back_pre_apply cbpa
|
|
LEFT JOIN clz_back_pre_details cbpd on cbpd.apply_id = cbpa.id
|
|
LEFT JOIN ma_type mt on mt.type_id = cbpd.type_id
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
|
LEFT JOIN bm_agreement_info cbai on cbai.agreement_id = cbpa.clz_agreement_id
|
|
LEFT JOIN bm_unit bu on bu.unit_id = cbai.unit_id
|
|
LEFT JOIN bm_project bp on bp.pro_id = cbai.project_id
|
|
where 1 = 1
|
|
and cbpa.status = '1'
|
|
<if test="unitName != null and unitName!=''">
|
|
and bu.unit_name like CONCAT('%', #{unitName}, '%')
|
|
</if>
|
|
<if test="proName != null and proName!=''">
|
|
and bp.pro_name like CONCAT('%', #{proName}, '%')
|
|
</if>
|
|
<if test="backPerson != null and backPerson!=''">
|
|
and cbpa.back_person like CONCAT('%', #{backPerson}, '%')
|
|
</if>
|
|
<if test="code != null and code!=''">
|
|
and cbpa.back_code like CONCAT('%', #{code}, '%')
|
|
</if>
|
|
<if test="projectIdList != null and projectIdList.size() > 0">
|
|
and bp.external_id in
|
|
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">
|
|
and bu.bzz_idcard = #{idCard}
|
|
</if>
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
and cbpa.back_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
ORDER BY cbpa.create_time DESC
|
|
</select>
|
|
</mapper> |