Files
FT546MWS/ruoyi-admin/src/main/resources/mapper/productAndStock/ViewProductAndStockMapper.xml

201 lines
12 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.ruoyi.out.productAndStock.mapper.ViewProductAndStockMapper">
<resultMap type="ViewProductAndStock" id="ViewProductAndStockResult">
<result property="onlyIdentity" column="only_identity" />
<result property="productId" column="product_id" />
<result property="lotNo" column="lot_no" />
<result property="productName" column="product_name" />
<result property="quantity" column="quantity" />
<result property="warehouseId" column="warehouse_id" />
<result property="stackingId" column="stacking_id" />
<result property="spare1" column="spare1" />
<result property="spare2" column="spare2" />
<result property="spare3" column="spare3" />
<result property="spare4" column="spare4" />
<result property="spare5" column="spare5" />
<result property="spare6" column="spare6" />
<result property="voltage" column="voltage" />
<result property="power" column="power" />
<result property="phase" column="phase" />
</resultMap>
<sql id="selectViewProductAndStockVo">
select only_identity, product_id, lot_no, product_name, quantity, warehouse_id, stacking_id, spare1, spare2, spare3, spare4, spare5, spare6, voltage, power, phase from view_product_and_stock
</sql>
<sql id="selectViewProductAndStockPdVo">
select only_identity, product_id, lot_no, product_name, quantity, warehouse_id, stacking_id, spare1, spare2, spare3, spare4, spare5, spare6, voltage, power, phase from view_product_and_stock_pd
</sql>
<select id="selectViewProductAndStockList" parameterType="ViewProductAndStock" resultMap="ViewProductAndStockResult">
<include refid="selectViewProductAndStockVo"/>
<where>
<if test="onlyIdentity != null "> and only_identity like concat('%', #{onlyIdentity}, '%')</if>
<if test="productId != null and productId != ''"> and product_id like concat('%', #{productId}, '%')</if>
<if test="lotNo != null and lotNo != ''"> and lot_no like concat('%', #{lotNo}, '%')</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="quantity != null and quantity != ''"> and quantity like concat('%', #{quantity}, '%')</if>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id like concat('%', #{warehouseId}, '%')</if>
<if test="stackingId != null and stackingId != ''"> and stacking_id like concat('%', #{stackingId}, '%')</if>
<if test="spare1 != null and spare1 != ''"> and spare1 like concat('%', #{spare1}, '%')</if>
<if test="spare2 != null and spare2 != ''"> and spare2 like concat('%', #{spare2}, '%')</if>
<if test="spare3 != null and spare3 != ''"> and spare3 like concat('%', #{spare3}, '%')</if>
<if test="spare4 != null and spare4 != ''"> and spare4 like concat('%', #{spare4}, '%')</if>
<if test="spare5 != null and spare5 != ''"> and spare5 like concat('%', #{spare5}, '%')</if>
<if test="spare6 != null and spare6 != ''"> and spare6 like concat('%', #{spare6}, '%')</if>
<if test="voltage != null and voltage != ''"> and voltage like concat('%', #{voltage}, '%')</if>
<if test="power != null and power != ''"> and power like concat('%', #{power}, '%')</if>
<if test="phase != null and phase != ''"> and phase like concat('%', #{phase}, '%')</if>
</where>
</select>
<select id="selectViewProductAndStockByOnlyIdentity" parameterType="Long" resultMap="ViewProductAndStockResult">
<include refid="selectViewProductAndStockVo"/>
where only_identity = #{onlyIdentity}
</select>
<select id="selectViewProductAndStockPdList" parameterType="ViewProductAndStock"
resultMap="ViewProductAndStockResult">
<include refid="selectViewProductAndStockPdVo"/>
<where>
<if test="onlyIdentity != null ">and only_identity like concat('%', #{onlyIdentity}, '%')</if>
<if test="productId != null and productId != ''">and product_id like concat('%', #{productId}, '%')</if>
<if test="lotNo != null and lotNo != ''">and lot_no like concat('%', #{lotNo}, '%')</if>
<if test="productName != null and productName != ''">and product_name like concat('%', #{productName},
'%')
</if>
<if test="quantity != null and quantity != ''">and quantity like concat('%', #{quantity}, '%')</if>
<if test="warehouseId != null and warehouseId != ''">and warehouse_id like concat('%', #{warehouseId}, '%')</if>
<if test="stackingId != null and stackingId != ''">and stacking_id like concat('%', #{stackingId}, '%')</if>
<if test="spare1 != null and spare1 != ''">and spare1 like concat('%', #{spare1}, '%')</if>
<if test="spare2 != null and spare2 != ''">and spare2 like concat('%', #{spare2}, '%')</if>
<if test="spare3 != null and spare3 != ''">and spare3 like concat('%', #{spare3}, '%')</if>
<if test="spare4 != null and spare4 != ''">and spare4 like concat('%', #{spare4}, '%')</if>
<if test="spare5 != null and spare5 != ''">and spare5 like concat('%', #{spare5}, '%')</if>
<if test="spare6 != null and spare6 != ''">and spare6 like concat('%', #{spare6}, '%')</if>
<if test="voltage != null and voltage != ''">and voltage like concat('%', #{voltage}, '%')</if>
<if test="power != null and power != ''">and power like concat('%', #{power}, '%')</if>
<if test="phase != null and phase != ''">and phase like concat('%', #{phase}, '%')</if>
</where>
</select>
<select id="selectFlatProductAndStockList" parameterType="ViewProductAndStock" resultMap="ViewProductAndStockResult">
select row_number() over (order by bs.product_id, bs.stock_id) as only_identity,
bs.product_id,
bs.lot_no,
bs.product_name,
isnull(bs.quantity, 0) - isnull(bs.out_quantity, 0) as quantity,
bs.warehouse_id,
bs.stacking_id,
bs.spare1,
bs.spare2,
bs.spare3,
bs.spare4,
bs.spare5,
bs.spare6,
bs.voltage,
bs.power,
bs.phase
from bas_stock_hc bs
<where>
<!-- try_convert(int, bs.warehouse_id) = 2-->
<!-- and isnull(bs.quantity, 0) - isnull(bs.out_quantity, 0) > 0-->
bs.quantity>0
and bs.out_quantity =0
<if test="productId != null and productId != ''">and bs.product_id like concat('%', #{productId}, '%')</if>
<if test="lotNo != null and lotNo != ''">and bs.lot_no like concat('%', #{lotNo}, '%')</if>
<if test="productName != null and productName != ''">and bs.product_name like concat('%', #{productName}, '%')</if>
<if test="spare1 != null and spare1 != ''">and bs.spare1 like concat('%', #{spare1}, '%')</if>
<if test="spare2 != null and spare2 != ''">and bs.spare2 like concat('%', #{spare2}, '%')</if>
<if test="spare3 != null and spare3 != ''">and bs.spare3 like concat('%', #{spare3}, '%')</if>
<if test="spare4 != null and spare4 != ''">
and (bs.spare4 like concat('%', #{spare4}, '%')
or bs.order_id like concat('%', #{spare4}, '%')
or bs.job_id like concat('%', #{spare4}, '%'))
</if>
<if test="spare5 != null and spare5 != ''">and bs.spare5 like concat('%', #{spare5}, '%')</if>
<if test="spare6 != null and spare6 != ''">and bs.spare6 like concat('%', #{spare6}, '%')</if>
<if test="voltage != null and voltage != ''">and bs.voltage like concat('%', #{voltage}, '%')</if>
<if test="power != null and power != ''">and bs.power like concat('%', #{power}, '%')</if>
<if test="phase != null and phase != ''">and bs.phase like concat('%', #{phase}, '%')</if>
</where>
</select>
<insert id="insertViewProductAndStock" parameterType="ViewProductAndStock">
insert into view_product_and_stock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="onlyIdentity != null">only_identity,</if>
<if test="productId != null">product_id,</if>
<if test="lotNo != null">lot_no,</if>
<if test="productName != null">product_name,</if>
<if test="quantity != null">quantity,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="stackingId != null">stacking_id,</if>
<if test="spare1 != null">spare1,</if>
<if test="spare2 != null">spare2,</if>
<if test="spare3 != null">spare3,</if>
<if test="spare4 != null">spare4,</if>
<if test="spare5 != null">spare5,</if>
<if test="spare6 != null">spare6,</if>
<if test="voltage != null">voltage,</if>
<if test="power != null">power,</if>
<if test="phase != null">phase,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="onlyIdentity != null">#{onlyIdentity},</if>
<if test="productId != null">#{productId},</if>
<if test="lotNo != null">#{lotNo},</if>
<if test="productName != null">#{productName},</if>
<if test="quantity != null">#{quantity},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="stackingId != null">#{stackingId},</if>
<if test="spare1 != null">#{spare1},</if>
<if test="spare2 != null">#{spare2},</if>
<if test="spare3 != null">#{spare3},</if>
<if test="spare4 != null">#{spare4},</if>
<if test="spare5 != null">#{spare5},</if>
<if test="spare6 != null">#{spare6},</if>
<if test="voltage != null">#{voltage},</if>
<if test="power != null">#{power},</if>
<if test="phase != null">#{phase},</if>
</trim>
</insert>
<update id="updateViewProductAndStock" parameterType="ViewProductAndStock">
update view_product_and_stock
<trim prefix="SET" suffixOverrides=",">
<if test="productId != null">product_id = #{productId},</if>
<if test="lotNo != null">lot_no = #{lotNo},</if>
<if test="productName != null">product_name = #{productName},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="stackingId != null">stacking_id = #{stackingId},</if>
<if test="spare1 != null">spare1 = #{spare1},</if>
<if test="spare2 != null">spare2 = #{spare2},</if>
<if test="spare3 != null">spare3 = #{spare3},</if>
<if test="spare4 != null">spare4 = #{spare4},</if>
<if test="spare5 != null">spare5 = #{spare5},</if>
<if test="spare6 != null">spare6 = #{spare6},</if>
<if test="voltage != null">voltage = #{voltage},</if>
<if test="power != null">power = #{power},</if>
<if test="phase != null">phase = #{phase},</if>
</trim>
where only_identity = #{onlyIdentity}
</update>
<delete id="deleteViewProductAndStockByOnlyIdentity" parameterType="Long">
delete from view_product_and_stock where only_identity = #{onlyIdentity}
</delete>
<delete id="deleteViewProductAndStockByOnlyIdentitys" parameterType="String">
delete from view_product_and_stock where only_identity in
<foreach item="onlyIdentity" collection="array" open="(" separator="," close=")">
#{onlyIdentity}
</foreach>
</delete>
</mapper>