168 lines
9.0 KiB
XML
168 lines
9.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.bonus.canteen.core.ims.mapper.ImsInventoryMapper">
|
|
|
|
<resultMap type="com.bonus.canteen.core.ims.domain.ImsInventory" id="ImsInventoryResult">
|
|
<result property="inventoryId" column="inventory_id" />
|
|
<result property="warehouseId" column="warehouse_id" />
|
|
<result property="materialId" column="material_id" />
|
|
<result property="unitId" column="unit_id" />
|
|
<result property="minNum" column="min_num" />
|
|
<result property="maxNum" column="max_num" />
|
|
<result property="materialNum" column="material_num" />
|
|
<result property="inventoryStatus" column="inventory_status" />
|
|
<result property="remark" column="remark" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<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="warehouseName" column="warehouse_name" />
|
|
<result property="materialName" column="material_name" />
|
|
<result property="materialTypeName" column="material_type_name" />
|
|
<result property="unitName" column="unit_name" />
|
|
<result property="barCode" column="bar_code" />
|
|
<result property="size" column="size" />
|
|
<result property="areaName" column="area_name" />
|
|
<result property="areaId" column="area_id" />
|
|
<result property="materialCode" column="material_code" />
|
|
</resultMap>
|
|
|
|
<sql id="selectImsInventoryVo">
|
|
select ii.inventory_id, ii.warehouse_id, ii.material_id, ii.unit_id, min_num, max_num,
|
|
material_num, inventory_status, remark, ii.del_flag, ii.create_by, ii.create_time,
|
|
ii.update_by, ii.update_time, iwi.warehouse_name, cm.material_name, cmt.material_type_name,
|
|
iu.unit_name, cm.bar_code, cm.size, ba.area_name, ba.area_id, cm.material_code
|
|
from ims_inventory ii
|
|
left join ims_warehouse_info iwi on ii.warehouse_id = iwi.warehouse_id
|
|
left join cook_material cm on ii.material_id = cm.material_id
|
|
left join cook_material_type cmt on cm.material_type_id = cmt.material_type_id
|
|
left join ims_unit iu on ii.unit_id = iu.unit_id
|
|
left join basic_area ba on iwi.area_id = ba.area_id
|
|
</sql>
|
|
|
|
<select id="selectImsInventoryList" parameterType="com.bonus.canteen.core.ims.domain.ImsInventory" resultMap="ImsInventoryResult">
|
|
<include refid="selectImsInventoryVo"/>
|
|
<where>
|
|
ii.del_flag = '0'
|
|
<if test="inventoryId != null "> and ii.inventory_id = #{inventoryId}</if>
|
|
<if test="areaId != null "> and ba.area_id = #{areaId}</if>
|
|
<if test="warehouseId != null "> and ii.warehouse_id = #{warehouseId}</if>
|
|
<if test="materialId != null "> and ii.material_id = #{materialId}</if>
|
|
<if test="unitId != null "> and ii.unit_id = #{unitId}</if>
|
|
<if test="minNum != null "> and ii.min_num = #{minNum}</if>
|
|
<if test="maxNum != null "> and ii.max_num = #{maxNum}</if>
|
|
<if test="materialNum != null "> and ii.material_num = #{materialNum}</if>
|
|
<if test="inventoryStatus != null "> and ii.inventory_status = #{inventoryStatus}</if>
|
|
<if test="materialTypeIds != null and materialTypeIds.size() > 0">
|
|
and cmt.material_type_id in
|
|
<foreach collection="materialTypeIds" item="materialTypeId" separator="," open="(" close=")">
|
|
#{materialTypeId}
|
|
</foreach>
|
|
</if>
|
|
<if test="materialName != null and materialName != ''">
|
|
and cm.material_name like CONCAT('%',#{materialName},'%')
|
|
</if>
|
|
<if test="materialCode != null and materialCode != ''">
|
|
and cm.material_code = #{materialCode}
|
|
</if>
|
|
<if test="barCode != null and barCode != ''">
|
|
and cm.bar_code = #{barCode}
|
|
</if>
|
|
<if test="startDateTime != null">
|
|
and ii.create_time <![CDATA[ >= ]]> #{startDateTime}
|
|
</if>
|
|
<if test="endDateTime != null">
|
|
and ii.create_time <![CDATA[ <= ]]> #{endDateTime}
|
|
</if>
|
|
</where>
|
|
order by ii.material_id, ii.create_time desc
|
|
</select>
|
|
|
|
<select id="selectImsInventoryByInventoryId" parameterType="Long" resultMap="ImsInventoryResult">
|
|
<include refid="selectImsInventoryVo"/>
|
|
where ii.inventory_id = #{inventoryId} and ii.del_flag = '0'
|
|
</select>
|
|
|
|
<insert id="insertImsInventory" parameterType="com.bonus.canteen.core.ims.domain.ImsInventory" useGeneratedKeys="true" keyProperty="inventoryId">
|
|
insert into ims_inventory
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="warehouseId != null">warehouse_id,</if>
|
|
<if test="materialId != null">material_id,</if>
|
|
<if test="unitId != null">unit_id,</if>
|
|
<if test="minNum != null">min_num,</if>
|
|
<if test="maxNum != null">max_num,</if>
|
|
<if test="materialNum != null">material_num,</if>
|
|
<if test="inventoryStatus != null">inventory_status,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="delFlag != null">del_flag,</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>-->
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="warehouseId != null">#{warehouseId},</if>
|
|
<if test="materialId != null">#{materialId},</if>
|
|
<if test="unitId != null">#{unitId},</if>
|
|
<if test="minNum != null">#{minNum},</if>
|
|
<if test="maxNum != null">#{maxNum},</if>
|
|
<if test="materialNum != null">#{materialNum},</if>
|
|
<if test="inventoryStatus != null">#{inventoryStatus},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="delFlag != null">#{delFlag},</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>-->
|
|
</trim>
|
|
on duplicate key update material_num = material_num + #{materialNum},
|
|
update_by = #{updateBy},
|
|
update_time = #{updateTime}
|
|
</insert>
|
|
|
|
<update id="updateImsInventory" parameterType="com.bonus.canteen.core.ims.domain.ImsInventory">
|
|
update ims_inventory
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
|
|
<if test="materialId != null">material_id = #{materialId},</if>
|
|
<if test="unitId != null">unit_id = #{unitId},</if>
|
|
<if test="minNum != null">min_num = #{minNum},</if>
|
|
<if test="maxNum != null">max_num = #{maxNum},</if>
|
|
<if test="materialNum != null">material_num = #{materialNum},</if>
|
|
<if test="fetchNum != null">material_num = material_num - #{fetchNum},</if>
|
|
<if test="inventoryStatus != null">inventory_status = #{inventoryStatus},</if>
|
|
<if test="inventoryStatus == null">
|
|
inventory_status = CASE
|
|
WHEN material_num <![CDATA[ < ]]> min_num THEN 2
|
|
WHEN material_num <![CDATA[ > ]]> max_num THEN 3
|
|
ELSE 1
|
|
END,
|
|
</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</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>
|
|
</trim>
|
|
where inventory_id = #{inventoryId}
|
|
<if test="fetchNum != null">
|
|
and material_num <![CDATA[ >= ]]> #{fetchNum}
|
|
</if>
|
|
and del_flag = '0'
|
|
</update>
|
|
|
|
<delete id="deleteImsInventoryByInventoryId" parameterType="Long">
|
|
update ims_inventory set del_flag = '2' where inventory_id = #{inventoryId}
|
|
</delete>
|
|
|
|
<delete id="deleteImsInventoryByInventoryIds" parameterType="String">
|
|
update ims_inventory set del_flag = '2' where inventory_id in
|
|
<foreach item="inventoryId" collection="array" open="(" separator="," close=")">
|
|
#{inventoryId}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |