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.

199 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.hw.mes.mapper.MesOrderBindMapper">
<resultMap type="MesOrderBind" id="MesOrderBindResult">
<result property="orderBindId" column="order_bind_id" />
<result property="safeFlag" column="safe_flag" />
<result property="saleOrderId" column="sale_order_id" />
<result property="saleOrderCode" column="sale_order_code" />
<result property="productId" column="product_id" />
<result property="productCode" column="product_code" />
<result property="productName" column="product_name" />
<result property="purchaseOrderId" column="purchase_order_id" />
<result property="poNo" column="po_no" />
<result property="materialId" column="material_id" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="bindAmount" column="bind_amount" />
<result property="barcodeAmount" column="barcode_amount" />
<result property="remark" column="remark" />
<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="productSpec" column="product_spec" />
<result property="materialSpec" column="material_spec" />
<result property="specificationParameter" column="specification_parameter" />
<result property="saleOrderAmount" column="order_amount" />
</resultMap>
<sql id="selectMesOrderBindVo">
select order_bind_id, safe_flag, sale_order_id, sale_order_code, product_id, product_code, product_name, purchase_order_id, po_no, material_id, material_code, material_name, bind_amount, barcode_amount,remark, create_by, create_time, update_by, update_time from mes_order_bind
</sql>
<select id="selectMesOrderBindList" parameterType="MesOrderBind" resultMap="MesOrderBindResult">
<include refid="selectMesOrderBindVo"/>
<where>
<if test="safeFlag != null and safeFlag != ''"> and safe_flag = #{safeFlag}</if>
<if test="saleOrderId != null "> and sale_order_id = #{saleOrderId}</if>
<if test="saleOrderCode != null and saleOrderCode != ''"> and sale_order_code = #{saleOrderCode}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productCode != null and productCode != ''"> and product_code = #{productCode}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="purchaseOrderId != null "> and purchase_order_id = #{purchaseOrderId}</if>
<if test="poNo != null and poNo != ''"> and po_no = #{poNo}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="bindAmount != null "> and bind_amount = #{bindAmount}</if>
</where>
</select>
<select id="selectMesOrderBindByOrderBindId" parameterType="Long" resultMap="MesOrderBindResult">
<include refid="selectMesOrderBindVo"/>
where order_bind_id = #{orderBindId}
</select>
<insert id="insertMesOrderBind" parameterType="MesOrderBind" useGeneratedKeys="true" keyProperty="orderBindId">
insert into mes_order_bind
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="safeFlag != null and safeFlag != ''">safe_flag,</if>
<if test="saleOrderId != null">sale_order_id,</if>
<if test="saleOrderCode != null">sale_order_code,</if>
<if test="productId != null">product_id,</if>
<if test="productCode != null">product_code,</if>
<if test="productName != null">product_name,</if>
<if test="purchaseOrderId != null">purchase_order_id,</if>
<if test="poNo != null">po_no,</if>
<if test="materialId != null">material_id,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="bindAmount != null">bind_amount,</if>
<if test="remark != null">remark,</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="safeFlag != null and safeFlag != ''">#{safeFlag},</if>
<if test="saleOrderId != null">#{saleOrderId},</if>
<if test="saleOrderCode != null">#{saleOrderCode},</if>
<if test="productId != null">#{productId},</if>
<if test="productCode != null">#{productCode},</if>
<if test="productName != null">#{productName},</if>
<if test="purchaseOrderId != null">#{purchaseOrderId},</if>
<if test="poNo != null">#{poNo},</if>
<if test="materialId != null">#{materialId},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="bindAmount != null">#{bindAmount},</if>
<if test="remark != null">#{remark},</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>
</insert>
<update id="updateMesOrderBind" parameterType="MesOrderBind">
update mes_order_bind
<trim prefix="SET" suffixOverrides=",">
<if test="safeFlag != null and safeFlag != ''">safe_flag = #{safeFlag},</if>
<if test="saleOrderId != null">sale_order_id = #{saleOrderId},</if>
<if test="saleOrderCode != null">sale_order_code = #{saleOrderCode},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="productCode != null">product_code = #{productCode},</if>
<if test="productName != null">product_name = #{productName},</if>
<if test="purchaseOrderId != null">purchase_order_id = #{purchaseOrderId},</if>
<if test="poNo != null">po_no = #{poNo},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="bindAmount != null">bind_amount = #{bindAmount},</if>
<if test="barcodeAmount != null">barcode_amount = #{barcodeAmount},</if>
<if test="remark != null">remark = #{remark},</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 order_bind_id = #{orderBindId}
</update>
<delete id="deleteMesOrderBindByOrderBindId" parameterType="Long">
delete from mes_order_bind where order_bind_id = #{orderBindId}
</delete>
<delete id="deleteMesOrderBindByOrderBindIds" parameterType="String">
delete from mes_order_bind where order_bind_id in
<foreach item="orderBindId" collection="array" open="(" separator="," close=")">
#{orderBindId}
</foreach>
</delete>
<select id="selectMesOrderBindJoinList" parameterType="MesOrderBind" resultMap="MesOrderBindResult">
select mob.order_bind_id, mob.safe_flag, mob.sale_order_id, mob.sale_order_code,
mob.purchase_order_id, mob.po_no, mob.bind_amount, mob.barcode_amount,
mob.product_id,pbmi.material_code as product_code,pbmi.material_name as product_name,pbmi.material_spec as product_spec,
mob.material_id,mbmi.material_code,mbmi.material_name,mbmi.material_spec,mso.specification_parameter,
mso.order_amount
from mes_order_bind mob left join mes_base_material_info pbmi on mob.product_id=pbmi.material_id
left join mes_base_material_info mbmi on mob.material_id=mbmi.material_id
left join mes_sale_order mso on mob.sale_order_id = mso.sale_order_id
<where>
mso.is_flag = '1'
<if test="mergeFlag != null and mergeFlag != ''"> and mob.bind_amount=1 and mob.barcode_amount=0 and mso.order_amount=1</if>
<if test="singleFlag != null and singleFlag != ''"> and mob.bind_amount &gt; mob.barcode_amount</if>
<if test="safeFlag != null and safeFlag != ''"> and mob.safe_flag = #{safeFlag}</if>
<if test="saleOrderId != null"> and mob.sale_order_id = #{saleOrderId}</if>
<if test="purchaseOrderId != null"> and mob.purchase_order_id = #{purchaseOrderId}</if>
<if test="saleOrderCode != null and saleOrderCode != ''"> and mob.sale_order_code like concat('%', #{saleOrderCode}, '%')</if>
<if test="productCode != null and productCode != ''"> and pbmi.product_code like concat('%', #{productCode}, '%')</if>
<if test="productName != null and productName != ''"> and pbmi.product_name like concat('%', #{productName}, '%')</if>
<if test="poNo != null and poNo != ''"> and mob.po_no like concat('%', #{poNo}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and mbmi.material_code like concat('%', #{materialCode}, '%')</if>
<if test="materialName != null and materialName != ''"> and mbmi.material_name like concat('%', #{materialName}, '%')</if>
<if test="materialSpec != null and materialSpec != ''">and replace(mbmi.material_spec,' ','') like concat('%', #{materialSpec},
'%')</if>
<if test="specificationParameter != null and specificationParameter != ''">and replace(mso.specification_parameter,' ','') like concat('%', #{specificationParameter},
'%')</if>
</where>
order by mob.order_bind_id desc
</select>
<select id="selectMesOrderBindJoinProductList" parameterType="MesOrderBind" resultMap="MesOrderBindResult">
select mob.order_bind_id, mob.safe_flag, mob.sale_order_id, mob.sale_order_code,
mob.purchase_order_id, mob.po_no, mob.bind_amount, mob.barcode_amount,
mob.product_id,pbmi.material_code as product_code,pbmi.material_name as product_name,pbmi.material_spec as product_spec,
mob.material_id,mbmi.material_code,mbmi.material_name,mbmi.material_spec
from mes_order_bind mob left join mes_base_material_info pbmi on mob.product_id=pbmi.material_id
<where>
<if test="mergeFlag != null and mergeFlag != ''"> and mob.bind_amount=1 and mob.barcode_amount=0 and mso.order_amount=1</if>
<if test="singleFlag != null and singleFlag != ''"> and mob.bind_amount &gt; mob.barcode_amount</if>
<if test="safeFlag != null and safeFlag != ''"> and mob.safe_flag = #{safeFlag}</if>
<if test="saleOrderId != null"> and mob.sale_order_id = #{saleOrderId}</if>
<if test="purchaseOrderId != null"> and mob.purchase_order_id = #{purchaseOrderId}</if>
<if test="saleOrderCode != null and saleOrderCode != ''"> and mob.sale_order_code like concat('%', #{saleOrderCode}, '%')</if>
<if test="productCode != null and productCode != ''"> and pbmi.product_code like concat('%', #{productCode}, '%')</if>
<if test="productName != null and productName != ''"> and pbmi.product_name like concat('%', #{productName}, '%')</if>
</where>
order by mob.order_bind_id desc
</select>
</mapper>