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.

186 lines
8.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.op.wms.mapper.BaseBomMapper">
<resultMap type="BaseBom" id="BaseBomResult">
<result property="factoryCode" column="factory_code" />
<result property="productionVersion" column="production_version" />
<result property="bomCode" column="bom_code" />
<result property="optionalBom" column="optional_bom" />
<result property="optionalBomText" column="optional_bom_text" />
<result property="pvvd" column="pvvd" />
<result property="pved" column="pved" />
<result property="bomCalculateNumber" column="bom_calculate_number" />
<result property="bomCalculateUnit" column="bom_calculate_unit" />
<result property="bomBaseNumber" column="bom_base_number" />
<result property="bomBaseUnit" column="bom_base_unit" />
<result property="componentUnit" column="component_unit" />
<result property="componentProFlag" column="component_pro_flag" />
<result property="msi" column="msi" />
<result property="sanka" column="sanka" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<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="remark" column="remark" />
<result property="currentVersion" column="current_version" />
</resultMap>
<sql id="selectBaseBomVo">
select factory_code, production_version, bom_code, optional_bom, optional_bom_text, pvvd, pved, bom_calculate_number, bom_calculate_unit, bom_base_number, bom_base_unit, component_unit, component_pro_flag, msi, sanka, attr1, attr2, attr3, create_by, create_time, update_by, update_time, remark, current_version from base_bom
</sql>
<select id="selectBaseBomList" parameterType="BaseBom" resultType="com.op.wms.domain.BaseBom">
select
bb.factory_code as factoryCode,
bb.production_version as productionVersion,
bb.bom_code as bomCode,
bb.optional_bom as optionalBom,
bb.optional_bom_text as optionalBomText,
bb.pvvd as pvvd,
bb.pved as pved,
bb.bom_calculate_number as bomCalculateNumber,
bb.bom_calculate_unit as bomCalculateUnit,
bb.bom_base_number as bomBaseNumber,
bb.bom_base_unit as bomBaseUnit,
bb.component_unit as componentUnit,
bb.component_pro_flag as componentProFlag,
bb.msi as msi,
bb.sanka as sanka,
bb.attr1 as attr1,
bb.attr2 as attr2,
bb.attr3 as attr3,
bb.create_by as createBy,
bb.create_time as createTime,
bb.update_by as updateBy,
bb.update_time,
bb.remark as remark,
bb.current_version as currentVersion,
bbc.product_code as productCode,
b1.product_desc_zh as productDescZh,
bp.product_desc_zh as componentDescZh,
bbc.cumc as cumc,
bbc.component as component,
bbc.bom_hierarchy as bomHierarchy,
bbc.project_no as projectNo,
bbc.standard_dosage as standardDosage,
bbc.loss_rate as lossRate,
bbc.loss_amount as lossAmount,
bbc.cilosses as cilosses
from base_bom bb
left join base_bom_component bbc on bb.bom_code = bbc.bom_code
left join base_product b1 on right(b1.product_code,11) = bbc.product_code
left join base_product bp on right(bp.product_code,11) = bbc.component
<where>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="bomCode != null and bomCode != ''"> and bom_code = #{bomCode}</if>
</where>
</select>
<select id="selectBaseBomByFactoryCode" parameterType="String" resultMap="BaseBomResult">
<include refid="selectBaseBomVo"/>
where factory_code = #{factoryCode}
</select>
<insert id="insertBaseBom" parameterType="BaseBom">
insert into base_bom
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="factoryCode != null">factory_code,</if>
<if test="productionVersion != null">production_version,</if>
<if test="bomCode != null">bom_code,</if>
<if test="optionalBom != null">optional_bom,</if>
<if test="optionalBomText != null">optional_bom_text,</if>
<if test="pvvd != null">pvvd,</if>
<if test="pved != null">pved,</if>
<if test="bomCalculateNumber != null">bom_calculate_number,</if>
<if test="bomCalculateUnit != null">bom_calculate_unit,</if>
<if test="bomBaseNumber != null">bom_base_number,</if>
<if test="bomBaseUnit != null">bom_base_unit,</if>
<if test="componentUnit != null">component_unit,</if>
<if test="componentProFlag != null">component_pro_flag,</if>
<if test="msi != null">msi,</if>
<if test="sanka != null">sanka,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</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>
<if test="remark != null">remark,</if>
<if test="currentVersion != null">current_version,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="factoryCode != null">#{factoryCode},</if>
<if test="productionVersion != null">#{productionVersion},</if>
<if test="bomCode != null">#{bomCode},</if>
<if test="optionalBom != null">#{optionalBom},</if>
<if test="optionalBomText != null">#{optionalBomText},</if>
<if test="pvvd != null">#{pvvd},</if>
<if test="pved != null">#{pved},</if>
<if test="bomCalculateNumber != null">#{bomCalculateNumber},</if>
<if test="bomCalculateUnit != null">#{bomCalculateUnit},</if>
<if test="bomBaseNumber != null">#{bomBaseNumber},</if>
<if test="bomBaseUnit != null">#{bomBaseUnit},</if>
<if test="componentUnit != null">#{componentUnit},</if>
<if test="componentProFlag != null">#{componentProFlag},</if>
<if test="msi != null">#{msi},</if>
<if test="sanka != null">#{sanka},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</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>
<if test="remark != null">#{remark},</if>
<if test="currentVersion != null">#{currentVersion},</if>
</trim>
</insert>
<update id="updateBaseBom" parameterType="BaseBom">
update base_bom
<trim prefix="SET" suffixOverrides=",">
<if test="productionVersion != null">production_version = #{productionVersion},</if>
<if test="bomCode != null">bom_code = #{bomCode},</if>
<if test="optionalBom != null">optional_bom = #{optionalBom},</if>
<if test="optionalBomText != null">optional_bom_text = #{optionalBomText},</if>
<if test="pvvd != null">pvvd = #{pvvd},</if>
<if test="pved != null">pved = #{pved},</if>
<if test="bomCalculateNumber != null">bom_calculate_number = #{bomCalculateNumber},</if>
<if test="bomCalculateUnit != null">bom_calculate_unit = #{bomCalculateUnit},</if>
<if test="bomBaseNumber != null">bom_base_number = #{bomBaseNumber},</if>
<if test="bomBaseUnit != null">bom_base_unit = #{bomBaseUnit},</if>
<if test="componentUnit != null">component_unit = #{componentUnit},</if>
<if test="componentProFlag != null">component_pro_flag = #{componentProFlag},</if>
<if test="msi != null">msi = #{msi},</if>
<if test="sanka != null">sanka = #{sanka},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</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>
<if test="remark != null">remark = #{remark},</if>
<if test="currentVersion != null">current_version = #{currentVersion},</if>
</trim>
where factory_code = #{factoryCode}
</update>
<delete id="deleteBaseBomByFactoryCode" parameterType="String">
delete from base_bom where factory_code = #{factoryCode}
</delete>
<delete id="deleteBaseBomByFactoryCodes" parameterType="String">
delete from base_bom where factory_code in
<foreach item="factoryCode" collection="array" open="(" separator="," close=")">
#{factoryCode}
</foreach>
</delete>
</mapper>