2024-10-31 12:50:25 +00:00
<?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.ktg.mes.md.mapper.BaseKnifeMapper" >
<resultMap type= "BaseKnife" id= "BaseKnifeResult" >
<result property= "baseKnifeId" column= "BASE_KNIFE_ID" />
<result property= "mbbBdMrlId" column= "MBB_BD_MRL_ID" />
<result property= "rfid" column= "RFID" />
<result property= "knifeCode" column= "KNIFE_CODE" />
<result property= "knifeName" column= "KNIFE_NAME" />
<result property= "knifeUnit" column= "KNIFE_UNIT" />
<result property= "knifeType" column= "KNIFE_TYPE" />
<result property= "safeStock" column= "SAFE_STOCK" />
<result property= "standardQuantity" column= "STANDARD_QUANTITY" />
<result property= "areaCode" column= "AREA_CODE" />
<result property= "knifeLife" column= "KNIFE_LIFE" />
<result property= "knifeFineState" column= "KNIFE_FINE_STATE" />
<result property= "isLocked" column= "IS_LOCKED" />
<result property= "lockedStartTime" column= "LOCKED_START_TIME" />
<result property= "lockedEndTime" column= "LOCKED_END_TIME" />
<result property= "planSheet" column= "PLAN_SHEET" />
<result property= "resetCount" column= "RESET_COUNT" />
2024-11-01 02:38:03 +00:00
<result property= "itemOrProduct" column= "ITEM_OR_PRODUCT" />
2024-10-31 12:50:25 +00:00
<result property= "remark" column= "REMARK" />
<result property= "attr1" column= "ATTR1" />
<result property= "attr2" column= "ATTR2" />
<result property= "attr3" column= "ATTR3" />
<result property= "attr4" column= "ATTR4" />
<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>
<resultMap id= "BaseKnifeMdItemResult" type= "BaseKnife" extends= "BaseKnifeResult" >
<collection property= "mdItemList" notNullColumn= "sub_ITEM_ID" javaType= "java.util.List" resultMap= "MdItemResult" />
</resultMap>
<resultMap type= "MdItem" id= "MdItemResult" >
<result property= "itemId" column= "sub_ITEM_ID" />
<result property= "itemCode" column= "sub_ITEM_CODE" />
<result property= "itemName" column= "sub_ITEM_NAME" />
<result property= "specification" column= "sub_SPECIFICATION" />
<result property= "unitOfMeasure" column= "sub_UNIT_OF_MEASURE" />
<result property= "itemOrProduct" column= "sub_ITEM_OR_PRODUCT" />
<result property= "itemTypeId" column= "sub_ITEM_TYPE_ID" />
<result property= "itemTypeCode" column= "sub_ITEM_TYPE_CODE" />
<result property= "itemTypeName" column= "sub_ITEM_TYPE_NAME" />
<result property= "enableFlag" column= "sub_ENABLE_FLAG" />
<result property= "safeStockFlag" column= "sub_SAFE_STOCK_FLAG" />
<result property= "minStock" column= "sub_MIN_STOCK" />
<result property= "maxStock" column= "sub_MAX_STOCK" />
<result property= "remark" column= "sub_REMARK" />
<result property= "attr1" column= "sub_ATTR1" />
<result property= "attr2" column= "sub_ATTR2" />
<result property= "attr3" column= "sub_ATTR3" />
<result property= "attr4" column= "sub_ATTR4" />
<result property= "createBy" column= "sub_CREATE_BY" />
<result property= "createTime" column= "sub_CREATE_TIME" />
<result property= "updateBy" column= "sub_UPDATE_BY" />
<result property= "updateTime" column= "sub_UPDATE_TIME" />
<result property= "highValue" column= "sub_HIGH_VALUE" />
<result property= "unitName" column= "sub_UNIT_NAME" />
<result property= "modelNumber" column= "sub_MODEL_NUMBER" />
<result property= "standardNumber" column= "sub_STANDARD_NUMBER" />
</resultMap>
<sql id= "selectBaseKnifeVo" >
SELECT BK.BASE_KNIFE_ID, BK.MBB_BD_MRL_ID, RFID, MI.ITEM_CODE AS KNIFE_CODE, MI.ITEM_NAME AS KNIFE_NAME, MI.UNIT_NAME AS KNIFE_UNIT,
MIT.ITEM_TYPE_NAME AS KNIFE_TYPE, BK.SAFE_STOCK, BK.STANDARD_QUANTITY, BK.AREA_CODE, BK.KNIFE_LIFE, BK.KNIFE_FINE_STATE,
2024-11-01 02:38:03 +00:00
BK.IS_LOCKED, BK.LOCKED_START_TIME, BK.LOCKED_END_TIME, BK.PLAN_SHEET, BK.RESET_COUNT, BK.ITEM_OR_PRODUCT,
2024-10-31 12:50:25 +00:00
BK.REMARK, BK.ATTR1, BK.ATTR2, BK.ATTR3, BK.ATTR4, BK.CREATE_BY, BK.CREATE_TIME, BK.UPDATE_BY, BK.UPDATE_TIME from BASE_KNIFE BK
LEFT JOIN MD_ITEM MI on BK.MBB_BD_MRL_ID = MI.ITEM_ID
LEFT JOIN MD_ITEM_TYPE MIT ON MI.ITEM_TYPE_ID = MIT.ITEM_TYPE_ID
</sql>
<select id= "selectBaseKnifeList" parameterType= "BaseKnife" resultMap= "BaseKnifeResult" >
<include refid= "selectBaseKnifeVo" />
<where >
<if test= "mbbBdMrlId != null and mbbBdMrlId != ''" > and MBB_BD_MRL_ID = #{mbbBdMrlId}</if>
<if test= "rfid != null and rfid != ''" > and RFID = #{rfid}</if>
<if test= "knifeCode != null and knifeCode != ''" > and KNIFE_CODE = #{knifeCode}</if>
<if test= "knifeName != null and knifeName != ''" > and KNIFE_NAME like concat('%', #{knifeName}, '%')</if>
<if test= "knifeUnit != null and knifeUnit != ''" > and KNIFE_UNIT = #{knifeUnit}</if>
<if test= "knifeType != null and knifeType != ''" > and KNIFE_TYPE = #{knifeType}</if>
<if test= "safeStock != null and safeStock != ''" > and SAFE_STOCK = #{safeStock}</if>
<if test= "standardQuantity != null and standardQuantity != ''" > and STANDARD_QUANTITY = #{standardQuantity}</if>
<if test= "areaCode != null and areaCode != ''" > and AREA_CODE = #{areaCode}</if>
<if test= "knifeLife != null and knifeLife != ''" > and KNIFE_LIFE = #{knifeLife}</if>
2024-11-01 02:38:03 +00:00
<if test= "knifeFineState != null " > and KNIFE_FINE_STATE = #{knifeFineState}</if>
<if test= "isLocked != null" > and IS_LOCKED = #{isLocked}</if>
<if test= "itemOrProduct != null and itemOrProduct != ''" > and ITEM_OR_PRODUCT = #{itemOrProduct}</if>
2024-10-31 12:50:25 +00:00
<if test= "remark != null and remark != ''" > and REMARK = #{remark}</if>
<if test= "attr1 != null and attr1 != ''" > and ATTR1 = #{attr1}</if>
<if test= "attr2 != null and attr2 != ''" > and ATTR2 = #{attr2}</if>
<if test= "attr3 != null and attr3 != ''" > and ATTR3 = #{attr3}</if>
<if test= "attr4 != null and attr4 != ''" > and ATTR4 = #{attr4}</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= "selectBaseKnifeByBaseKnifeId" parameterType= "String" resultMap= "BaseKnifeMdItemResult" >
select a.BASE_KNIFE_ID, a.MBB_BD_MRL_ID, a.RFID, a.KNIFE_CODE, a.KNIFE_NAME, a.KNIFE_UNIT, a.KNIFE_TYPE, a.SAFE_STOCK, a.STANDARD_QUANTITY, a.AREA_CODE, a.KNIFE_LIFE, a.KNIFE_FINE_STATE, a.REMARK, a.ATTR1, a.ATTR2, a.ATTR3, a.ATTR4, a.CREATE_BY, a.CREATE_TIME, a.UPDATE_BY, a.UPDATE_TIME, a.IS_LOCKED, a.LOCKED_START_TIME, a.LOCKED_END_TIME
b.ITEM_ID as sub_ITEM_ID, b.ITEM_CODE as sub_ITEM_CODE, b.ITEM_NAME as sub_ITEM_NAME, b.SPECIFICATION as sub_SPECIFICATION, b.UNIT_OF_MEASURE as sub_UNIT_OF_MEASURE, b.ITEM_OR_PRODUCT as sub_ITEM_OR_PRODUCT, b.ITEM_TYPE_ID as sub_ITEM_TYPE_ID, b.ITEM_TYPE_CODE as sub_ITEM_TYPE_CODE, b.ITEM_TYPE_NAME as sub_ITEM_TYPE_NAME, b.ENABLE_FLAG as sub_ENABLE_FLAG, b.SAFE_STOCK_FLAG as sub_SAFE_STOCK_FLAG, b.MIN_STOCK as sub_MIN_STOCK, b.MAX_STOCK as sub_MAX_STOCK, b.REMARK as sub_REMARK, b.ATTR1 as sub_ATTR1, b.ATTR2 as sub_ATTR2, b.ATTR3 as sub_ATTR3, b.ATTR4 as sub_ATTR4, b.CREATE_BY as sub_CREATE_BY, b.CREATE_TIME as sub_CREATE_TIME, b.UPDATE_BY as sub_UPDATE_BY, b.UPDATE_TIME as sub_UPDATE_TIME, b.HIGH_VALUE as sub_HIGH_VALUE, b.UNIT_NAME as sub_UNIT_NAME, b.MODEL_NUMBER as sub_MODEL_NUMBER, b.STANDARD_NUMBER as sub_STANDARD_NUMBER
from BASE_KNIFE a
left join MD_ITEM b on b.ITEM_ID = a.BASE_KNIFE_ID
where a.BASE_KNIFE_ID = #{baseKnifeId}
</select>
<insert id= "insertBaseKnife" parameterType= "BaseKnife" useGeneratedKeys= "true" keyProperty= "baseKnifeId" >
insert into BASE_KNIFE
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "mbbBdMrlId != null" > MBB_BD_MRL_ID,</if>
<if test= "rfid != null" > RFID,</if>
<if test= "knifeCode != null" > KNIFE_CODE,</if>
<if test= "knifeName != null" > KNIFE_NAME,</if>
<if test= "knifeUnit != null" > KNIFE_UNIT,</if>
<if test= "knifeType != null" > KNIFE_TYPE,</if>
<if test= "safeStock != null" > SAFE_STOCK,</if>
<if test= "standardQuantity != null" > STANDARD_QUANTITY,</if>
<if test= "areaCode != null" > AREA_CODE,</if>
<if test= "knifeLife != null" > KNIFE_LIFE,</if>
<if test= "knifeFineState != null" > KNIFE_FINE_STATE,</if>
2024-11-01 02:38:03 +00:00
<if test= "isLocked != null" > is_locked,</if>
<if test= "lockedStartTime != null" > locked_start_time,</if>
<if test= "lockedEndTime != null" > locked_end_time,</if>
<if test= "planSheet != null" > plan_sheet,</if>
<if test= "resetCount != null" > reset_count,</if>
<if test= "itemOrProduct != null" > item_or_product,</if>
2024-10-31 12:50:25 +00:00
<if test= "remark != null" > REMARK,</if>
<if test= "attr1 != null" > ATTR1,</if>
<if test= "attr2 != null" > ATTR2,</if>
<if test= "attr3 != null" > ATTR3,</if>
<if test= "attr4 != null" > ATTR4,</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= "mbbBdMrlId != null" > #{mbbBdMrlId},</if>
<if test= "rfid != null" > #{rfid},</if>
<if test= "knifeCode != null" > #{knifeCode},</if>
<if test= "knifeName != null" > #{knifeName},</if>
<if test= "knifeUnit != null" > #{knifeUnit},</if>
<if test= "knifeType != null" > #{knifeType},</if>
<if test= "safeStock != null" > #{safeStock},</if>
<if test= "standardQuantity != null" > #{standardQuantity},</if>
<if test= "areaCode != null" > #{areaCode},</if>
<if test= "knifeLife != null" > #{knifeLife},</if>
<if test= "knifeFineState != null" > #{knifeFineState},</if>
2024-11-01 02:38:03 +00:00
<if test= "isLocked != null" > #{isLocked},</if>
<if test= "lockedStartTime != null" > #{lockedStartTime},</if>
<if test= "lockedEndTime != null" > #{lockedEndTime},</if>
<if test= "planSheet != null" > #{planSheet},</if>
<if test= "resetCount != null" > #{resetCount},</if>
<if test= "itemOrProduct != null" > #{itemOrProduct},</if>
2024-10-31 12:50:25 +00:00
<if test= "remark != null" > #{remark},</if>
<if test= "attr1 != null" > #{attr1},</if>
<if test= "attr2 != null" > #{attr2},</if>
<if test= "attr3 != null" > #{attr3},</if>
<if test= "attr4 != null" > #{attr4},</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= "updateBaseKnife" parameterType= "BaseKnife" >
update BASE_KNIFE
<trim prefix= "SET" suffixOverrides= "," >
<if test= "mbbBdMrlId != null" > MBB_BD_MRL_ID = #{mbbBdMrlId},</if>
<if test= "rfid != null" > RFID = #{rfid},</if>
<if test= "knifeCode != null" > KNIFE_CODE = #{knifeCode},</if>
<if test= "knifeName != null" > KNIFE_NAME = #{knifeName},</if>
<if test= "knifeUnit != null" > KNIFE_UNIT = #{knifeUnit},</if>
<if test= "knifeType != null" > KNIFE_TYPE = #{knifeType},</if>
<if test= "safeStock != null" > SAFE_STOCK = #{safeStock},</if>
<if test= "standardQuantity != null" > STANDARD_QUANTITY = #{standardQuantity},</if>
<if test= "areaCode != null" > AREA_CODE = #{areaCode},</if>
<if test= "knifeLife != null" > KNIFE_LIFE = #{knifeLife},</if>
<if test= "knifeFineState != null" > KNIFE_FINE_STATE = #{knifeFineState},</if>
2024-11-01 02:38:03 +00:00
<if test= "isLocked != null" > is_locked = #{isLocked},</if>
<if test= "lockedStartTime != null" > locked_start_time = #{lockedStartTime},</if>
<if test= "lockedEndTime != null" > locked_end_time = #{lockedEndTime},</if>
<if test= "planSheet != null" > plan_sheet = #{planSheet},</if>
<if test= "resetCount != null" > reset_count = #{resetCount},</if>
<if test= "itemOrProduct != null" > item_or_product = #{itemOrProduct},</if>
2024-10-31 12:50:25 +00:00
<if test= "remark != null" > REMARK = #{remark},</if>
<if test= "attr1 != null" > ATTR1 = #{attr1},</if>
<if test= "attr2 != null" > ATTR2 = #{attr2},</if>
<if test= "attr3 != null" > ATTR3 = #{attr3},</if>
<if test= "attr4 != null" > ATTR4 = #{attr4},</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 BASE_KNIFE_ID = #{baseKnifeId}
</update>
2024-11-01 03:20:21 +00:00
<update id= "resetBaseKnife" >
update BASE_KNIFE set reset_count = reset_count - 1, knife_life = 100 where BASE_KNIFE_ID = #{baseKnifeId}
</update>
2024-10-31 12:50:25 +00:00
<delete id= "deleteBaseKnifeByBaseKnifeId" parameterType= "String" >
delete from BASE_KNIFE where BASE_KNIFE_ID = #{baseKnifeId}
</delete>
<delete id= "deleteBaseKnifeByBaseKnifeIds" parameterType= "String" >
delete from BASE_KNIFE where BASE_KNIFE_ID in
<foreach item= "baseKnifeId" collection= "array" open= "(" separator= "," close= ")" >
#{baseKnifeId}
</foreach>
</delete>
<delete id= "deleteMdItemByItemIds" parameterType= "String" >
delete from MD_ITEM where ITEM_ID in
<foreach item= "itemId" collection= "array" open= "(" separator= "," close= ")" >
#{itemId}
</foreach>
</delete>
<insert id= "batchMdItem" >
insert into MD_ITEM( ITEM_ID, ITEM_CODE, ITEM_NAME, SPECIFICATION, UNIT_OF_MEASURE, ITEM_OR_PRODUCT, ITEM_TYPE_ID, ITEM_TYPE_CODE, ITEM_TYPE_NAME, ENABLE_FLAG, SAFE_STOCK_FLAG, MIN_STOCK, MAX_STOCK, REMARK, ATTR1, ATTR2, ATTR3, ATTR4, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, HIGH_VALUE, UNIT_NAME, MODEL_NUMBER, STANDARD_NUMBER) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.itemId}, #{item.itemCode}, #{item.itemName}, #{item.specification}, #{item.unitOfMeasure}, #{item.itemOrProduct}, #{item.itemTypeId}, #{item.itemTypeCode}, #{item.itemTypeName}, #{item.enableFlag}, #{item.safeStockFlag}, #{item.minStock}, #{item.maxStock}, #{item.remark}, #{item.attr1}, #{item.attr2}, #{item.attr3}, #{item.attr4}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.highValue}, #{item.unitName}, #{item.modelNumber}, #{item.standardNumber})
</foreach>
</insert>
</mapper>