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.

251 lines
10 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.quality.mapper.QcGoalDistributeMapper">
<resultMap type="QcGoalDistribute" id="QcGoalDistributeResult">
<result property="id" column="id"/>
<result property="belongGoalId" column="belong_goal_id"/>
<result property="supplierCode" column="supplier_code"/>
<result property="supplierName" column="supplier_name"/>
<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"/>
<result property="factoryCode" column="factory_code"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectQcGoalDistributeVo">
select id, belong_goal_id, supplier_code, supplier_name, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, factory_code, del_flag from qc_goal_distribute
</sql>
<select id="selectQcGoalDistributeList" parameterType="QcGoalDistribute" resultMap="QcGoalDistributeResult">
<include refid="selectQcGoalDistributeVo"/>
<where>
<if test="belongGoalId != null and belongGoalId != ''">
and belong_goal_id = #{belongGoalId}
</if>
<if test="supplierCode != null and supplierCode != ''">
and supplier_code = #{supplierCode}
</if>
<if test="supplierName != null and supplierName != ''">
and supplier_name like concat('%', #{supplierName}, '%')
</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="factoryCode != null and factoryCode != ''">
and factory_code = #{factoryCode}
</if>
</where>
</select>
<select id="selectQcGoalDistributeById" parameterType="String"
resultMap="QcGoalDistributeResult">
<include refid="selectQcGoalDistributeVo"/>
where id = #{id}
</select>
<insert id="insertQcGoalDistribute" parameterType="QcGoalDistribute">
insert into qc_goal_distribute
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,
</if>
<if test="belongGoalId != null">belong_goal_id,
</if>
<if test="supplierCode != null">supplier_code,
</if>
<if test="supplierName != null">supplier_name,
</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>
<if test="factoryCode != null and factoryCode != ''">factory_code,
</if>
<if test="delFlag != null">del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},
</if>
<if test="belongGoalId != null">#{belongGoalId},
</if>
<if test="supplierCode != null">#{supplierCode},
</if>
<if test="supplierName != null">#{supplierName},
</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>
<if test="factoryCode != null and factoryCode != ''">#{factoryCode},
</if>
<if test="delFlag != null">#{delFlag},
</if>
</trim>
</insert>
<update id="updateQcGoalDistribute" parameterType="QcGoalDistribute">
update qc_goal_distribute
<trim prefix="SET" suffixOverrides=",">
<if test="belongGoalId != null">belong_goal_id =
#{belongGoalId},
</if>
<if test="supplierCode != null">supplier_code =
#{supplierCode},
</if>
<if test="supplierName != null">supplier_name =
#{supplierName},
</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>
<if test="factoryCode != null and factoryCode != ''">factory_code =
#{factoryCode},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteQcGoalDistributeById" parameterType="String">
delete from qc_goal_distribute where id = #{id}
</delete>
<delete id="deleteQcGoalDistributeByIds" parameterType="String">
delete from qc_goal_distribute where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteQcGoalDistributeByBelongId" parameterType="String">
delete from qc_goal_distribute where belong_goal_id = #{belongGoalId}
</delete>
<select id="getGoalDistributeUndo" parameterType="QcGoalDistribute" resultMap="QcGoalDistributeResult">
select bs.supplier_code,
concat(bs.zh_desc,'(',bs.supplier_code,')') label,
concat(bs.zh_desc,'(',bs.supplier_code,')') supplierName
from base_supplier bs
where bs.active_flag = '1' and bs.del_flag = '0'
and bs.supplier_code not in (
select gd.supplier_code
from qc_goal_distribute gd
where gd.belong_goal_id =#{belongGoalId}
)
<if test="supplierName != null and supplierName != ''">and bs.zh_desc like concat('%', #{supplierName},
'%')
</if>
</select>
<select id="getGoalDistributeDo" parameterType="QcGoalDistribute" resultMap="QcGoalDistributeResult">
select distinct
gd.supplier_code,
concat(bs.zh_desc,'(',bs.supplier_code,')') label
from qc_goal_distribute gd
left join base_supplier bs on gd.supplier_code = bs.supplier_code
where gd.belong_goal_id =#{belongGoalId}
<if test="supplierName != null and supplierName != ''">and bs.zh_desc like concat('%', #{supplierName},
'%')
</if>
</select>
<select id="getProductUndo" parameterType="QcGoalDistribute" resultType="QcGoalDistribute">
SELECT
bp.product_code supplierCode,
concat ( bp.product_desc_zh, '(', bp.product_code, ')' ) label
FROM
base_product bp
WHERE
bp.active_flag = '1'
AND bp.del_flag = '0'
AND bp.product_code NOT IN (
SELECT gd.supplier_code
FROM qc_goal_distribute gd
WHERE gd.belong_goal_id =#{ belongGoalId }
)
<if test="supplierName != null and supplierName != ''">and bs.zh_desc like concat('%', #{supplierName},'%')
</if>
</select>
<select id="getProductDo" parameterType="QcGoalDistribute" resultType="QcGoalDistribute">
SELECT DISTINCT
gd.supplier_code supplierCode,
concat ( bp.product_desc_zh, '(', bp.product_code, ')' ) label
FROM
qc_goal_distribute gd
LEFT JOIN base_product bp ON gd.supplier_code = bp.product_code
WHERE
gd.belong_goal_id =#{ belongGoalId}
<if test="supplierName != null and supplierName != ''">and bp.product_desc_zh like concat('%', #{supplierName},
'%')
</if>
</select>
</mapper>