160 lines
5.4 KiB
XML
160 lines
5.4 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.sip.mapper.OmsStockInfoMapper">
|
|
|
|
<resultMap type="com.ruoyi.sip.domain.OmsStockInfo" id="OmsStockInfoMap">
|
|
<result property="id" column="id"/>
|
|
<result property="orderCode" column="order_code"/>
|
|
<result property="stockStatus" column="stock_status"/>
|
|
<result property="createTime" column="create_time"/>
|
|
</resultMap>
|
|
|
|
<!-- 基本字段 -->
|
|
<sql id="Base_Column_List">
|
|
id, order_code, stock_status, create_time
|
|
</sql>
|
|
|
|
<!--通过实体作为筛选条件查询-->
|
|
<select id="queryAll" resultMap="OmsStockInfoMap">
|
|
SELECT
|
|
t1.*,
|
|
t2.project_id,
|
|
t2.id as order_id,
|
|
t2.delivery_time,
|
|
t2.notifier_address,
|
|
t2.notifier,
|
|
t2.notifier_phone,
|
|
t3.project_name,
|
|
t3.project_code ,
|
|
t4.all_quantity
|
|
FROM
|
|
oms_stock_info t1
|
|
LEFT JOIN project_order_info t2 ON t1.order_code = t2.order_code
|
|
LEFT JOIN project_info t3 ON t2.project_id = t3.id
|
|
left join ( select sum(quantity) all_quantity,project_id from project_product_info group by project_id) t4 on t2.project_id=t4.project_id
|
|
|
|
<where>
|
|
<if test="id != null">
|
|
and t1.id = #{id}
|
|
</if>
|
|
<if test="orderCode != null and orderCode != ''">
|
|
and t1.order_code = #{orderCode}
|
|
</if>
|
|
<if test="stockStatus != null and stockStatus != ''">
|
|
and t1.stock_status = #{stockStatus}
|
|
</if>
|
|
<if test="createTime != null">
|
|
and t1.create_time = #{createTime}
|
|
</if>
|
|
|
|
<if test="orderCode!= null and orderCode!=''">
|
|
and t2.order_code = #{orderCode}
|
|
</if>
|
|
<if test="deliveryTimeStart != null or deliveryTimeEnd != null">
|
|
<choose>
|
|
<when test="deliveryTimeStart != null and deliveryTimeEnd != null">
|
|
and t2.delivery_time between date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00') and
|
|
date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
|
|
</when>
|
|
<when test="deliveryTimeStart != null">
|
|
and t2.delivery_time <![CDATA[ >= ]]> date_format(#{deliveryTimeStart}, '%Y-%m-%d 00:00:00')
|
|
</when>
|
|
<when test="deliveryTimeEnd != null">
|
|
and t2.delivery_time <![CDATA[ <= ]]> date_format(#{deliveryTimeEnd}, '%Y-%m-%d 23:59:59')
|
|
</when>
|
|
|
|
</choose>
|
|
</if>
|
|
<if test="projectCode != null and projectCode!=''">
|
|
and t3.project_code = #{projectCode}
|
|
</if>
|
|
<if test="projectName!= null and projectName!=''">
|
|
and t3.project_name = #{projectName}
|
|
</if>
|
|
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<!--根据ID查详情-->
|
|
<select id="queryById" parameterType="Integer" resultMap="OmsStockInfoMap">
|
|
SELECT id,
|
|
order_code,
|
|
stock_status,
|
|
create_time
|
|
FROM oms_stock_info
|
|
WHERE id = #{id}
|
|
LIMIT 1
|
|
</select>
|
|
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
INSERT INTO oms_stock_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="orderCode != null and orderCode != ''">
|
|
order_code,
|
|
</if>
|
|
<if test="stockStatus != null and stockStatus != ''">
|
|
stock_status,
|
|
</if>
|
|
<if test="onceInStock != null and onceInStock != ''">
|
|
once_in_stock,
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="orderCode != null and orderCode != ''">
|
|
#{orderCode},
|
|
</if>
|
|
<if test="stockStatus != null and stockStatus != ''">
|
|
#{stockStatus},
|
|
</if>
|
|
<if test="onceInStock != null and onceInStock != ''">
|
|
#{onceInStock},
|
|
</if>
|
|
<if test="createTime != null">
|
|
#{createTime},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
UPDATE oms_stock_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="orderCode != null and orderCode != ''">
|
|
order_code = #{orderCode},
|
|
</if>
|
|
<if test="stockStatus != null and stockStatus != ''">
|
|
stock_status = #{stockStatus},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time = #{createTime},
|
|
</if>
|
|
</trim>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
DELETE
|
|
FROM oms_stock_info
|
|
WHERE id = #{id}
|
|
</delete>
|
|
|
|
<!--通过id批量删除-->
|
|
<delete id="batchRemove">
|
|
delete from oms_stock_info where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
</mapper>
|
|
|
|
|
|
|