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.
HwMes/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsInventoryCheckMapper.xml

206 lines
13 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.hw.wms.mapper.WmsInventoryCheckMapper">
<resultMap type="WmsInventoryCheck" id="WmsInventoryCheckResult">
<result property="inventoryCheckId" column="inventory_check_id" />
<result property="inventoryCheckCode" column="inventory_check_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="checkStatus" column="check_status" />
<result property="checkType" column="check_type" />
<result property="beginTime" column="begin_time" />
<result property="endTime" column="end_time" />
<result property="locationAmount" column="location_amount" />
<result property="inventoryingAmount" column="inventorying_amount" />
<result property="inventoriedAmount" column="inventoried_amount" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createDate" column="create_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="warehouseName" column="warehouse_name" />
</resultMap>
<resultMap id="WmsInventoryCheckWmsInventoryCheckDetailResult" type="WmsInventoryCheck" extends="WmsInventoryCheckResult">
<collection property="wmsInventoryCheckDetailList" notNullColumn="sub_inventory_check_detail_id" javaType="java.util.List" resultMap="WmsInventoryCheckDetailResult" />
</resultMap>
<resultMap type="WmsInventoryCheckDetail" id="WmsInventoryCheckDetailResult">
<result property="inventoryCheckDetailId" column="sub_inventory_check_detail_id" />
<result property="inventoryCheckId" column="sub_inventory_check_id" />
<result property="materialId" column="sub_material_id" />
<result property="locationCode" column="sub_location_code" />
<result property="materialBarcode" column="sub_material_barcode" />
<result property="stockType" column="sub_stock_type" />
<result property="stockId" column="sub_stock_id" />
<result property="stockAmount" column="sub_stock_amount" />
<result property="realAmount" column="sub_real_amount" />
<result property="checkStatus" column="sub_check_status" />
<result property="inventoryTime" column="sub_inventory_time" />
<result property="erpStatus" column="sub_erp_status" />
<result property="erpAmount" column="sub_erp_amount" />
<result property="remark" column="sub_remark" />
<result property="createBy" column="sub_create_by" />
<result property="createDate" column="sub_create_date" />
<result property="updateBy" column="sub_update_by" />
<result property="updateDate" column="sub_update_date" />
<result property="materialCode" column="sub_material_code" />
<result property="materialName" column="sub_material_name" />
</resultMap>
<sql id="selectWmsInventoryCheckVo">
select inventory_check_id, inventory_check_code, warehouse_id, check_status, begin_time, end_time, location_amount, inventorying_amount, inventoried_amount, remark, create_by, create_date, update_by, update_date from wms_inventory_check
</sql>
<select id="selectWmsInventoryCheckList" parameterType="WmsInventoryCheck" resultMap="WmsInventoryCheckResult">
<include refid="selectWmsInventoryCheckVo"/>
<where>
<if test="inventoryCheckCode != null and inventoryCheckCode != ''"> and inventory_check_code = #{inventoryCheckCode}</if>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="checkStatus != null and checkStatus != ''"> and check_status = #{checkStatus}</if>
<if test="beginTime != null "> and begin_time = #{beginTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="createDate != null "> and create_date = #{createDate}</if>
<if test="updateDate != null "> and update_date = #{updateDate}</if>
</where>
</select>
<select id="selectWmsInventoryCheckByInventoryCheckId" parameterType="Long" resultMap="WmsInventoryCheckWmsInventoryCheckDetailResult">
select a.inventory_check_id, a.inventory_check_code, a.warehouse_id, a.check_status, a.begin_time, a.end_time, a.location_amount, a.inventorying_amount, a.inventoried_amount, a.remark, a.create_by, a.create_date, a.update_by, a.update_date,
b.inventory_check_detail_id as sub_inventory_check_detail_id, b.inventory_check_id as sub_inventory_check_id, b.material_id as sub_material_id, b.location_code as sub_location_code, b.material_barcode as sub_material_barcode, b.stock_type as sub_stock_type, b.stock_id as sub_stock_id, b.stock_amount as sub_stock_amount, b.real_amount as sub_real_amount, b.check_status as sub_check_status, b.inventory_time as sub_inventory_time, b.erp_status as sub_erp_status, b.erp_amount as sub_erp_amount, b.remark as sub_remark, b.create_by as sub_create_by, b.create_date as sub_create_date, b.update_by as sub_update_by, b.update_date as sub_update_date,
mbmi.material_code as sub_material_code,mbmi.material_name as sub_material_name
from wms_inventory_check a
left join wms_inventory_check_detail b on b.inventory_check_id = a.inventory_check_id
left join mes_base_material_info mbmi on b.material_id=mbmi.material_id
where a.inventory_check_id = #{inventoryCheckId}
</select>
<insert id="insertWmsInventoryCheck" parameterType="WmsInventoryCheck" useGeneratedKeys="true" keyProperty="inventoryCheckId">
insert into wms_inventory_check
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="inventoryCheckCode != null">inventory_check_code,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="checkStatus != null and checkStatus != ''">check_status,</if>
<if test="checkType != null and checkType != ''">check_type,</if>
<if test="beginTime != null">begin_time,</if>
<if test="endTime != null">end_time,</if>
<if test="locationAmount != null">location_amount,</if>
<if test="inventoryingAmount != null">inventorying_amount,</if>
<if test="inventoriedAmount != null">inventoried_amount,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createDate != null">create_date,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateDate != null">update_date,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="inventoryCheckCode != null">#{inventoryCheckCode},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="checkStatus != null and checkStatus != ''">#{checkStatus},</if>
<if test="checkType != null and checkType != ''">#{checkType},</if>
<if test="beginTime != null">#{beginTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="locationAmount != null">#{locationAmount},</if>
<if test="inventoryingAmount != null">#{inventoryingAmount},</if>
<if test="inventoriedAmount != null">#{inventoriedAmount},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateDate != null">#{updateDate},</if>
</trim>
</insert>
<update id="updateWmsInventoryCheck" parameterType="WmsInventoryCheck">
update wms_inventory_check
<trim prefix="SET" suffixOverrides=",">
<if test="inventoryCheckCode != null">inventory_check_code = #{inventoryCheckCode},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="checkStatus != null and checkStatus != ''">check_status = #{checkStatus},</if>
<if test="beginTime != null">begin_time = #{beginTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="locationAmount != null">location_amount = #{locationAmount},</if>
<if test="inventoryingAmount != null">inventorying_amount = #{inventoryingAmount},</if>
<if test="inventoriedAmount != null">inventoried_amount = #{inventoriedAmount},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createDate != null">create_date = #{createDate},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateDate != null">update_date = #{updateDate},</if>
</trim>
where inventory_check_id = #{inventoryCheckId}
</update>
<delete id="deleteWmsInventoryCheckByInventoryCheckId" parameterType="Long">
delete from wms_inventory_check where inventory_check_id = #{inventoryCheckId}
</delete>
<delete id="deleteWmsInventoryCheckByInventoryCheckIds" parameterType="String">
delete from wms_inventory_check where inventory_check_id in
<foreach item="inventoryCheckId" collection="array" open="(" separator="," close=")">
#{inventoryCheckId}
</foreach>
</delete>
<delete id="deleteWmsInventoryCheckDetailByInventoryCheckIds" parameterType="String">
delete from wms_inventory_check_detail where inventory_check_id in
<foreach item="inventoryCheckId" collection="array" open="(" separator="," close=")">
#{inventoryCheckId}
</foreach>
</delete>
<delete id="deleteWmsInventoryCheckDetailByInventoryCheckId" parameterType="Long">
delete from wms_inventory_check_detail where inventory_check_id = #{inventoryCheckId}
</delete>
<insert id="batchWmsInventoryCheckDetail">
insert into wms_inventory_check_detail( inventory_check_detail_id, inventory_check_id, material_id, location_code, material_barcode, stock_type, stock_id, stock_amount, real_amount, check_status, inventory_time, erp_status, erp_amount, remark, create_by, create_date, update_by, update_date) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.inventoryCheckDetailId}, #{item.inventoryCheckId}, #{item.materialId}, #{item.locationCode}, #{item.materialBarcode}, #{item.stockType}, #{item.stockId}, #{item.stockAmount}, #{item.realAmount}, #{item.checkStatus}, #{item.inventoryTime}, #{item.erpStatus}, #{item.erpAmount}, #{item.remark}, #{item.createBy}, #{item.createDate}, #{item.updateBy}, #{item.updateDate})
</foreach>
</insert>
<select id="selectWmsInventoryCheckJoinList" parameterType="WmsInventoryCheck" resultMap="WmsInventoryCheckResult">
select wic.inventory_check_id, wic.inventory_check_code, wic.warehouse_id, wic.check_status, wic.begin_time, wic.end_time,wic.location_amount, wic.inventorying_amount, wic.inventoried_amount,
wbw.warehouse_name,wic.create_by,wic.create_date,wic.update_by,wic.update_date
from wms_inventory_check wic left join wms_base_warehouse wbw on wic.warehouse_id = wbw.warehouse_id
<where>
<if test="inventoryCheckCode != null and inventoryCheckCode != ''"> and wic.inventory_check_code = #{inventoryCheckCode}</if>
<if test="warehouseId != null "> and wic.warehouse_id = #{warehouseId}</if>
<if test="checkStatus != null and checkStatus != ''"> and wic.check_status = #{checkStatus}</if>
<if test="checkType != null and checkType != ''"> and wic.check_type = #{checkType}</if>
<if test="params.beginBeginTime != null and params.beginBeginTime != '' and params.endBeginTime != null and params.endBeginTime != ''">
and wic.begin_time between #{params.beginBeginTime} and #{params.endBeginTime}</if>
<if test="params.beginEndTime != null and params.beginEndTime != '' and params.endEndTime != null and params.endEndTime != ''">
and wic.end_time between #{params.beginEndTime} and #{params.endEndTime}</if>
<if test="createBy != null and createBy != ''"> and wic.create_by like concat('%', #{createBy},'%')</if>
<if test="params.beginCreateDate != null and params.beginCreateDate != '' and params.endCreateDate != null and params.endCreateDate != ''">
and wic.create_date between #{params.beginCreateDate} and #{params.endCreateDate}</if>
<if test="params.beginUpdateDate != null and params.beginUpdateDate != '' and params.endUpdateDate != null and params.endUpdateDate != ''">
and wic.update_date between #{params.beginUpdateDate} and #{params.endUpdateDate}</if>
</where>
order by wic.inventory_check_id desc
</select>
<select id="selectOnlyInventoryCheckByInventoryCheckId" parameterType="Long" resultMap="WmsInventoryCheckResult">
<include refid="selectWmsInventoryCheckVo"/>
where inventory_check_id = #{inventoryCheckId}
</select>
</mapper>