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/ThrInvWarehouseDao.xml

167 lines
5.7 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.ThrInvWarehouseDao">
2 years ago
<select id="filterThrInvWarehouse" parameterType="com.glxp.api.req.thrsys.FilterThrSubInvWarehouseRequest"
resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
SELECT *
FROM thr_inv_warehouse
<where>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND `name` = #{name}
</if>
<if test="parentId != '' and parentId != null">
AND parentId = #{parentId}
</if>
<if test="thirdSysFk != null">
and thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<select id="selectById" parameterType="Map"
resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
SELECT *
FROM thr_inv_warehouse
WHERE id = #{id}
</select>
2 years ago
<select id="selectByPid" parameterType="Map"
resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
SELECT *
FROM thr_inv_warehouse
WHERE parentId = #{pid}
</select>
2 years ago
<select id="selectByThrDeptCode" parameterType="com.glxp.api.req.thrsys.FilterThrSubInvWarehouseRequest"
resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
select *
from thr_inv_warehouse
<where>
parentId not in (SELECT code
FROM thr_dept
where status = #{status}
and thirdSysFk = #{thirdSysFk})
and thirdSysFk = #{thirdSysFk}
<if test="name != '' and name != null">
and name like concat('%', #{name}, '%')
</if>
</where>
2 years ago
</select>
<select id="countSubInvByParentInvId" resultType="java.lang.Integer">
select count(*)
from thr_inv_warehouse
where parentId = (select code from thr_dept where id = #{parentInvId})
</select>
<select id="filterThrInvWarehouseResponse"
resultType="com.glxp.api.res.thrsys.ThrInvWarehouseResponse">
select t1.*, t2.name as parentName
from thr_inv_warehouse t1
left join thr_dept t2
on t2.code = t1.parentId
<where>
<if test="id != '' and id != null">
AND t1.id = #{id}
</if>
<if test="code != '' and code != null">
AND t1.code = #{code}
</if>
<if test="name != '' and name != null">
AND t1.`name` = #{name}
</if>
<if test="parentId != '' and parentId != null">
AND t1.parentId = #{parentId}
</if>
<if test="thirdSysFk != null">
and t1.thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertThrInvWarehouse" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
replace
INTO thr_inv_warehouse
(id, code, `name`, parentId, remark, thirdSysFk, updateTime)
values (#{id},
#{code},
#{name},
#{parentId},
#{remark},
#{thirdSysFk},
#{updateTime})
</insert>
<insert id="insertThrInvWarehouses" parameterType="java.util.List">
replace INTO thr_inv_warehouse
(id, code, `name`, parentId, remark, thirdSysFk, updateTime)
VALUES
2 years ago
<foreach collection="thrInvWarehouseEntitys" item="item" index="index"
separator=",">
(#{item.id}, #{item.code},
#{item.name}, #{item.parentId},
#{item.remark}, #{item.thirdSysFk}, #{item.updateTime})
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_inv_warehouse
WHERE id = #{id}
</delete>
<update id="updateThrInvWarehouse" parameterType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
UPDATE thr_inv_warehouse
<trim prefix="set" suffixOverrides=",">
<if test="name != null">
`name`=#{name},
</if>
<if test="code != null">
code=#{code},
</if>
<if test="parentId != null">
parentId=#{parentId},
</if>
<if test="remark != null">
remark=#{remark},
</if>
<if test="thirdSysFk != null">
thirdSysFk=#{thirdSysFk},
</if>
<if test="updateTime != null">
updateTime=#{updateTime},
</if>
</trim>
WHERE id = #{id}
</update>
<select id="selectByLastTime" resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
select *
from thr_inv_warehouse
where updateTime >= #{lastUpdateTime}
</select>
<select id="selectByCodeAndThirdId" resultType="com.glxp.api.entity.thrsys.ThrInvWarehouseEntity">
select id, name, parentId, remark
from thr_inv_warehouse
<where>
<if test="code != null and code != ''">
AND code = #{code}
</if>
<if test="thirdId != null and thirdId != ''">
AND thirdSysFk = #{thirdId}
</if>
</where>
limit 1
</select>
</mapper>