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

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

View File

@ -1,38 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper"> <mapper namespace="com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper">
<resultMap type="WmsInPlanDetailEntity" id="WmsInPlanDetailEntityResult"> <resultMap type="WmsInPlanDetailEntity" id="WmsInPlanDetailEntityResult">
<result property="id" column="ID" /> <result property="id" column="ID"/>
<result property="planId" column="PLAN_ID" /> <result property="planId" column="PLAN_ID"/>
<result property="planDetailsId" column="PLAN_DETAILS_ID" /> <result property="planDetailsId" column="PLAN_DETAILS_ID"/>
<result property="source" column="SOURCE" /> <result property="source" column="SOURCE"/>
<result property="knifeId" column="KNIFE_ID" /> <result property="knifeId" column="KNIFE_ID"/>
<result property="consumeLife" column="CONSUME_LIFE" /> <result property="consumeLife" column="CONSUME_LIFE"/>
<result property="createBy" column="CREATE_BY" /> <result property="createBy" column="CREATE_BY"/>
<result property="createTime" column="CREATE_TIME" /> <result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY" /> <result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME" /> <result property="updateTime" column="UPDATE_TIME"/>
</resultMap> </resultMap>
<sql id="selectWmsInPlanDetailEntityVo"> <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> </sql>
<select id="selectWmsInPlanDetailEntityList" parameterType="WmsInPlanDetailEntity" resultMap="WmsInPlanDetailEntityResult"> <select id="selectWmsInPlanDetailEntityList" parameterType="WmsInPlanDetailEntity"
resultMap="WmsInPlanDetailEntityResult">
<include refid="selectWmsInPlanDetailEntityVo"/> <include refid="selectWmsInPlanDetailEntityVo"/>
<where> <where>
<if test="planId != null and planId != ''"> and PLAN_ID = #{planId}</if> <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="planDetailsId != null and planDetailsId != ''">and PLAN_DETAILS_ID = #{planDetailsId}</if>
<if test="source != null and source != ''"> and SOURCE = #{source}</if> <if test="source != null and source != ''">and SOURCE = #{source}</if>
<if test="knifeId != null and knifeId != ''"> and KNIFE_ID = #{knifeId}</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="consumeLife != null and consumeLife != ''">and CONSUME_LIFE = #{consumeLife}</if>
<if test="createBy != null and createBy != ''"> and CREATE_BY = #{createBy}</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="createTime != null and createTime != ''">and CREATE_TIME = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and UPDATE_BY = #{updateBy}</if> <if test="updateBy != null and updateBy != ''">and UPDATE_BY = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''"> and UPDATE_TIME = #{updateTime}</if> <if test="updateTime != null and updateTime != ''">and UPDATE_TIME = #{updateTime}</if>
</where> </where>
</select> </select>
@ -41,7 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where ID = #{id} where ID = #{id}
</select> </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 insert into WMS_IN_PLAN_DETAIL_ENTITY
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null">PLAN_ID,</if> <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="createTime != null">CREATE_TIME,</if>
<if test="updateBy != null">UPDATE_BY,</if> <if test="updateBy != null">UPDATE_BY,</if>
<if test="updateTime != null">UPDATE_TIME,</if> <if test="updateTime != null">UPDATE_TIME,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null">#{planId},</if> <if test="planId != null">#{planId},</if>
<if test="planDetailsId != null">#{planDetailsId},</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="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
</trim> </trim>
</insert> </insert>
<update id="updateWmsInPlanDetailEntity" parameterType="WmsInPlanDetailEntity"> <update id="updateWmsInPlanDetailEntity" parameterType="WmsInPlanDetailEntity">
@ -84,7 +96,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteWmsInPlanDetailEntityById" parameterType="Long"> <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>
<delete id="deleteWmsInPlanDetailEntityByIds" parameterType="String"> <delete id="deleteWmsInPlanDetailEntityByIds" parameterType="String">
@ -93,4 +107,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </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> </mapper>