refactor(入库计划明细实例): 增加批量插入

This commit is contained in:
LJW 2024-11-07 14:22:20 +08:00
parent be916cd00d
commit f274691bad

View File

@ -1,47 +1,59 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper">
<resultMap type="WmsInPlanDetailEntity" id="WmsInPlanDetailEntityResult">
<result property="id" column="ID" />
<result property="planId" column="PLAN_ID" />
<result property="planDetailsId" column="PLAN_DETAILS_ID" />
<result property="source" column="SOURCE" />
<result property="knifeId" column="KNIFE_ID" />
<result property="consumeLife" column="CONSUME_LIFE" />
<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="id" column="ID"/>
<result property="planId" column="PLAN_ID"/>
<result property="planDetailsId" column="PLAN_DETAILS_ID"/>
<result property="source" column="SOURCE"/>
<result property="knifeId" column="KNIFE_ID"/>
<result property="consumeLife" column="CONSUME_LIFE"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<sql id="selectWmsInPlanDetailEntityVo">
select ID, PLAN_ID, PLAN_DETAILS_ID, SOURCE, KNIFE_ID, CONSUME_LIFE, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME from WMS_IN_PLAN_DETAIL_ENTITY
select ID,
PLAN_ID,
PLAN_DETAILS_ID,
SOURCE,
KNIFE_ID,
CONSUME_LIFE,
CREATE_BY,
CREATE_TIME,
UPDATE_BY,
UPDATE_TIME
from WMS_IN_PLAN_DETAIL_ENTITY
</sql>
<select id="selectWmsInPlanDetailEntityList" parameterType="WmsInPlanDetailEntity" resultMap="WmsInPlanDetailEntityResult">
<select id="selectWmsInPlanDetailEntityList" parameterType="WmsInPlanDetailEntity"
resultMap="WmsInPlanDetailEntityResult">
<include refid="selectWmsInPlanDetailEntityVo"/>
<where>
<if test="planId != null and planId != ''"> and PLAN_ID = #{planId}</if>
<if test="planDetailsId != null and planDetailsId != ''"> and PLAN_DETAILS_ID = #{planDetailsId}</if>
<if test="source != null and source != ''"> and SOURCE = #{source}</if>
<if test="knifeId != null and knifeId != ''"> and KNIFE_ID = #{knifeId}</if>
<if test="consumeLife != null and consumeLife != ''"> and CONSUME_LIFE = #{consumeLife}</if>
<if test="createBy != null and createBy != ''"> and CREATE_BY = #{createBy}</if>
<if test="createTime != null and createTime != ''"> and CREATE_TIME = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime}</if>
<where>
<if test="planId != null and planId != ''">and PLAN_ID = #{planId}</if>
<if test="planDetailsId != null and planDetailsId != ''">and PLAN_DETAILS_ID = #{planDetailsId}</if>
<if test="source != null and source != ''">and SOURCE = #{source}</if>
<if test="knifeId != null and knifeId != ''">and KNIFE_ID = #{knifeId}</if>
<if test="consumeLife != null and consumeLife != ''">and CONSUME_LIFE = #{consumeLife}</if>
<if test="createBy != null and createBy != ''">and CREATE_BY = #{createBy}</if>
<if test="createTime != null and createTime != ''">and CREATE_TIME = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''">and UPDATE_TIME = #{updateTime}</if>
</where>
</select>
<select id="selectWmsInPlanDetailEntityById" parameterType="Long" resultMap="WmsInPlanDetailEntityResult">
<include refid="selectWmsInPlanDetailEntityVo"/>
where ID = #{id}
</select>
<insert id="insertWmsInPlanDetailEntity" parameterType="WmsInPlanDetailEntity" useGeneratedKeys="true" keyProperty="id">
<insert id="insertWmsInPlanDetailEntity" parameterType="WmsInPlanDetailEntity" useGeneratedKeys="true"
keyProperty="id">
insert into WMS_IN_PLAN_DETAIL_ENTITY
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null">PLAN_ID,</if>
@ -53,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">CREATE_TIME,</if>
<if test="updateBy != null">UPDATE_BY,</if>
<if test="updateTime != null">UPDATE_TIME,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null">#{planId},</if>
<if test="planDetailsId != null">#{planDetailsId},</if>
@ -64,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateWmsInPlanDetailEntity" parameterType="WmsInPlanDetailEntity">
@ -84,13 +96,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteWmsInPlanDetailEntityById" parameterType="Long">
delete from WMS_IN_PLAN_DETAIL_ENTITY where ID = #{id}
delete
from WMS_IN_PLAN_DETAIL_ENTITY
where ID = #{id}
</delete>
<delete id="deleteWmsInPlanDetailEntityByIds" parameterType="String">
delete from WMS_IN_PLAN_DETAIL_ENTITY where ID in
delete from WMS_IN_PLAN_DETAIL_ENTITY where ID in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!--批量插入-->
<insert id="batchWmsInPlanDetailEntity">
insert into WMS_IN_PLAN_DETAIL_ENTITY(
ID,PLAN_ID,PLAN_DETAILS_ID,SOURCE,KNIFE_ID,CONSUME_LIFE,CREATE_BY,CREATE_TIME,UPDATE_BY,UPDATE_TIME) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.planId}, #{item.planDetailsId}, #{item.source}, #{item.knifeId},
#{item.consumeLife},#{item.createBy}, #{item.createTime}, #{item.updateBy},
#{item.updateTime})
</foreach>
</insert>
</mapper>