You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/thrsys/ThrDeptDao.xml

200 lines
7.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.glxp.api.dao.thrsys.ThrDeptDao">
<select id="filterThrInvWarehouse" parameterType="com.glxp.api.req.thrsys.FilterThrDeptRequest"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT *
FROM thr_dept thrInv
left join thr_system thrSys on thrInv.thirdSysFk = thrSys.thirdId
<where>
thrSys.enabled = true
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test="advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="key != null">
and (code like concat('%', #{key}, '%')
or `name` like concat('%', #{key}, '%'))
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="thirdSysFk != null">
and thirdSysFk = #{thirdSysFk}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<select id="selectById" parameterType="Map"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT *
FROM thr_dept
WHERE id = #{id}
</select>
<select id="filterThrGroupInvWarehouse" parameterType="com.glxp.api.req.thrsys.FilterThrDeptRequest"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT * FROM thr_dept
<where>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test="advanceType != '' and advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != '' and isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertThrInvWarehouse" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity">
replace
INTO thr_dept
(id,pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
values (
#{id},
#{pid},
#{code},
#{name},
#{advanceType},
#{isDefault},
#{status},
#{updateTime},
#{remark},
#{thirdSysFk}
)
</insert>
<insert id="insertThrInvWarehouses" parameterType="java.util.List">
replace INTO thr_dept
(pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
VALUES
<foreach collection="thrDeptEntities" item="item" index="index"
separator=",">
(
#{item.pid}, #{item.code},
#{item.name}, #{item.advanceType}, #{item.isDefault},
#{item.status}, #{item.updateTime},
#{item.remark}, #{item.thirdSysFk})
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_dept
WHERE id = #{id}
</delete>
<update id="updateThrInvWarehouse" parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity">
UPDATE thr_dept
<trim prefix="set" suffixOverrides=",">
<if test="pid != null">pid=#{pid},</if>
<if test="name != null">name=#{name},</if>
<if test="code != null">code=#{code},</if>
<if test="advanceType != null">advanceType=#{advanceType},</if>
<if test="isDefault != null">isDefault=#{isDefault},</if>
<if test="status != null">status=#{status},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
</trim>
WHERE id = #{id}
</update>
<select id="selectByCode" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select *
from thr_dept
where code = #{code} and thirdSysFk = #{thirdSysFk}
</select>
<select id="selectMaxCode" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select max(code) as code from thr_dept
<where>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test=" advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="pcode != null">
AND pcode = #{pcode}
</if>
<if test="level != null">
AND `level` = #{level}
</if>
<if test="thirdSysFk != null">
AND `thirdSysFk` = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertInvWarehouses">
replace into thr_dept (pid, code, `name`, advanceType, isDefault, status, updateTime, remark, `level`,
pcode,
thirdSysFk)
values
<foreach collection="thrDeptEntities" index="index" item="item" separator=",">
(#{item.pid},
#{item.code},
#{item.name},
#{item.advanceType},
#{item.isDefault},
#{item.status},
#{item.updateTime},
#{item.remark},
#{item.level},
#{item.pcode},
#{item.thirdSysFk})
</foreach>
</insert>
<select id="selectByLastTime" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select * from thr_dept where updateTime >= #{lastUpdateTime}
</select>
</mapper>