2024-09-27 15:26:57 +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.material.lease.mapper.LeaseApplyDetailsMapper">
|
|
|
|
|
<resultMap type="com.bonus.material.lease.domain.LeaseApplyDetails" id="LeaseApplyDetailsResult">
|
|
|
|
|
<result property="id" column="id" />
|
2024-11-11 10:18:32 +08:00
|
|
|
<result property="parentId" column="parent_id" />
|
2024-09-27 15:26:57 +08:00
|
|
|
<result property="typeId" column="type_id" />
|
2024-11-13 13:57:05 +08:00
|
|
|
<result property="typeName" column="type_name" />
|
|
|
|
|
<result property="maTypeName" column="ma_type_name" />
|
|
|
|
|
<result property="unitName" column="unit_name" />
|
|
|
|
|
<result property="storageNum" column="storage_num" />
|
2024-09-27 15:26:57 +08:00
|
|
|
<result property="preNum" column="pre_num" />
|
|
|
|
|
<result property="auditNum" column="audit_num" />
|
|
|
|
|
<result property="alNum" column="al_num" />
|
|
|
|
|
<result property="status" column="status" />
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
<result property="companyId" column="company_id" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
2024-11-13 09:30:23 +08:00
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
id, parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by, update_time, remark, company_id
|
|
|
|
|
</sql>
|
|
|
|
|
|
2024-09-27 15:26:57 +08:00
|
|
|
<sql id="selectLeaseApplyDetailsVo">
|
2024-11-13 11:08:34 +08:00
|
|
|
select
|
2024-11-13 13:57:05 +08:00
|
|
|
lad.id, lad.parent_id, mt.type_id, mt.type_name, mt2.type_name as ma_type_name, mt.storage_num,
|
2024-11-13 15:41:40 +08:00
|
|
|
mt.manage_type as manageType,
|
|
|
|
|
(lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,
|
2024-11-14 16:38:12 +08:00
|
|
|
IFNULL(lad.pre_num,0) as pre_num,
|
|
|
|
|
IFNULL(lad.audit_num,0) as audit_num,
|
|
|
|
|
IFNULL(lad.al_num,0) as al_num,
|
2024-11-19 15:18:00 +08:00
|
|
|
IFNULL(lad.status,0) as status, mt.unit_name,
|
2024-11-13 11:08:34 +08:00
|
|
|
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id
|
|
|
|
|
from
|
|
|
|
|
lease_apply_details lad
|
2024-11-13 13:57:05 +08:00
|
|
|
left join
|
|
|
|
|
ma_type mt on lad.type_id = mt.type_id and mt.`level` = '4' and mt.del_flag = '0'
|
|
|
|
|
left join
|
|
|
|
|
ma_type mt2 on mt2.type_id = mt.parent_id and mt2.`level` = '3' and mt2.del_flag = '0'
|
2024-09-27 15:26:57 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectLeaseApplyDetailsList" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" resultMap="LeaseApplyDetailsResult">
|
|
|
|
|
<include refid="selectLeaseApplyDetailsVo"/>
|
|
|
|
|
<where>
|
2024-11-13 11:08:34 +08:00
|
|
|
<if test="parentId != null "> and lad.parent_id = #{parentId}</if>
|
|
|
|
|
<if test="typeId != null "> and lad.type_id = #{typeId}</if>
|
|
|
|
|
<if test="preNum != null "> and lad.pre_num = #{preNum}</if>
|
|
|
|
|
<if test="auditNum != null "> and lad.audit_num = #{auditNum}</if>
|
|
|
|
|
<if test="alNum != null "> and lad.al_num = #{alNum}</if>
|
|
|
|
|
<if test="status != null and status != ''"> and lad.status = #{status}</if>
|
|
|
|
|
<if test="companyId != null "> and lad.company_id = #{companyId}</if>
|
2024-09-27 15:26:57 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectLeaseApplyDetailsById" parameterType="Long" resultMap="LeaseApplyDetailsResult">
|
|
|
|
|
<include refid="selectLeaseApplyDetailsVo"/>
|
2024-11-13 11:08:34 +08:00
|
|
|
where lad.id = #{id}
|
2024-09-27 15:26:57 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into lease_apply_details
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2024-11-11 10:18:32 +08:00
|
|
|
<if test="parentId != null">parent_id,</if>
|
2024-09-27 15:26:57 +08:00
|
|
|
<if test="typeId != null">type_id,</if>
|
|
|
|
|
<if test="preNum != null">pre_num,</if>
|
|
|
|
|
<if test="auditNum != null">audit_num,</if>
|
|
|
|
|
<if test="alNum != null">al_num,</if>
|
|
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2024-11-11 10:18:32 +08:00
|
|
|
<if test="parentId != null">#{parentId},</if>
|
2024-09-27 15:26:57 +08:00
|
|
|
<if test="typeId != null">#{typeId},</if>
|
|
|
|
|
<if test="preNum != null">#{preNum},</if>
|
|
|
|
|
<if test="auditNum != null">#{auditNum},</if>
|
|
|
|
|
<if test="alNum != null">#{alNum},</if>
|
|
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2024-11-11 10:08:01 +08:00
|
|
|
<insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
|
|
|
|
|
insert into lease_apply_details
|
2024-11-11 10:18:32 +08:00
|
|
|
(parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
|
2024-11-11 10:08:01 +08:00
|
|
|
update_time, remark, company_id)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
2024-11-11 10:18:32 +08:00
|
|
|
(#{item.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER},
|
2024-11-11 10:08:01 +08:00
|
|
|
#{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
|
|
|
|
|
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
|
|
|
|
|
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
2024-09-27 15:26:57 +08:00
|
|
|
<update id="updateLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
update lease_apply_details
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
2024-11-11 10:18:32 +08:00
|
|
|
<if test="parentId != null">parent_id = #{parentId},</if>
|
2024-09-27 15:26:57 +08:00
|
|
|
<if test="typeId != null">type_id = #{typeId},</if>
|
|
|
|
|
<if test="preNum != null">pre_num = #{preNum},</if>
|
|
|
|
|
<if test="auditNum != null">audit_num = #{auditNum},</if>
|
|
|
|
|
<if test="alNum != null">al_num = #{alNum},</if>
|
|
|
|
|
<if test="status != null">status = #{status},</if>
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
|
|
|
</trim>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteLeaseApplyDetailsById" parameterType="Long">
|
|
|
|
|
delete from lease_apply_details where id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteLeaseApplyDetailsByIds" parameterType="String">
|
|
|
|
|
delete from lease_apply_details where id in
|
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
2024-11-11 10:18:32 +08:00
|
|
|
|
|
|
|
|
<delete id="deleteLeaseApplyDetailsByParentIds" parameterType="Long">
|
2024-11-16 14:43:35 +08:00
|
|
|
delete from lease_apply_details where parent_id in
|
2024-11-11 10:18:32 +08:00
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
2024-11-13 09:30:23 +08:00
|
|
|
|
|
|
|
|
<select id="getByParentId" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
<!--@mbg.generated-->
|
|
|
|
|
select
|
2024-11-16 15:02:12 +08:00
|
|
|
id, parent_id as parentId, type_id as typeId, pre_num as preNum, al_num as alNum, `status`
|
2024-11-13 09:30:23 +08:00
|
|
|
from lease_apply_details
|
2024-11-13 09:47:36 +08:00
|
|
|
where parent_id = #{parentId}
|
2024-11-13 09:30:23 +08:00
|
|
|
</select>
|
2024-11-14 16:02:40 +08:00
|
|
|
|
|
|
|
|
<update id="updateLeaseApplyDetailsOutNum">
|
|
|
|
|
UPDATE
|
|
|
|
|
lease_apply_details
|
|
|
|
|
SET
|
|
|
|
|
al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}),
|
|
|
|
|
<if test="record.updateBy != null and record.updateBy!= '' ">
|
|
|
|
|
update_by = #{record.updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
update_time = now(),
|
|
|
|
|
status = '1'
|
|
|
|
|
WHERE
|
|
|
|
|
parent_id = #{record.parentId} and type_id = #{record.typeId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<select id="getLeaseApplyDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
ifnull( pre_num, 0 ) AS preNum,
|
|
|
|
|
ifnull( audit_num, 0 ) AS auditNum,
|
|
|
|
|
ifnull( al_num, 0 ) AS alNum
|
|
|
|
|
FROM
|
|
|
|
|
lease_apply_details
|
|
|
|
|
WHERE
|
|
|
|
|
parent_id = #{record.parentId}
|
|
|
|
|
AND type_id = #{record.typeId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="updateLeaseApplyDetailsByLeaseOutRecord">
|
|
|
|
|
UPDATE
|
|
|
|
|
lease_apply_details
|
|
|
|
|
SET
|
|
|
|
|
status = '2'
|
|
|
|
|
WHERE
|
|
|
|
|
parent_id = #{record.parentId} and type_id = #{record.typeId}
|
|
|
|
|
</update>
|
2024-11-19 10:33:56 +08:00
|
|
|
|
|
|
|
|
<select id="getOutboundNum" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
|
|
|
|
|
SELECT id, parent_id as parentId, type_id as typeId, pre_num as preNum, al_num as alNum, `status`, remark
|
|
|
|
|
FROM lease_apply_details
|
|
|
|
|
WHERE id = #{id} AND (pre_num - IFNULL(al_num, 0)) > 0
|
|
|
|
|
</select>
|
2024-11-19 13:50:48 +08:00
|
|
|
|
|
|
|
|
<select id="selectMaTypeNameByParentId" resultType="java.lang.String">
|
|
|
|
|
select
|
|
|
|
|
GROUP_CONCAT(type_name) typeName
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
distinct lad.parent_id, mt1.type_name
|
|
|
|
|
from
|
|
|
|
|
lease_apply_details lad
|
|
|
|
|
left join ma_type mt on lad.type_id = mt.type_id
|
|
|
|
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
|
|
|
|
where
|
|
|
|
|
1=1
|
|
|
|
|
<if test="parentId != null">
|
|
|
|
|
and lad.parent_id = #{parentId}
|
|
|
|
|
</if>
|
|
|
|
|
) t
|
|
|
|
|
GROUP BY parent_id
|
|
|
|
|
</select>
|
2024-09-27 15:26:57 +08:00
|
|
|
</mapper>
|