<?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.changhong.epc.tenant.mapper.tenant.norm.MasterValueMapper">
|
|
<resultMap type="com.changhong.epc.bean.tenant.master.MasterValue" id="ValueResultMap">
|
<result property="eleValue" column="ELE_VALUE"/>
|
<result property="rowNo" column="ROW_NO"/>
|
</resultMap>
|
|
<resultMap type="com.changhong.epc.bean.tenant.master.MasterValue" id="ValueResultMap1">
|
<result property="eleCode" column="ELE_CODE"/>
|
<result property="eleValue" column="ELE_VALUE"/>
|
<result property="rowNo" column="ROW_NO"/>
|
</resultMap>
|
|
<resultMap id="MasterElementMap" type="com.changhong.epc.bean.tenant.master.extend.MasterElementExtend" >
|
<result column="CODE" property="code"/>
|
<result column="ALIAS" property="alias"/>
|
</resultMap>
|
|
<resultMap type="com.changhong.epc.bean.tenant.master.extend.MasterValueListExtend" id="masterValueMap">
|
<id column="DEFINE_CODE" property="mdCode"/>
|
<collection property="values" ofType="java.util.Map" javaType="com.changhong.epc.bean.tenant.master.MasterValueList">
|
<id column="ID" property="id"/>
|
<result column="ELE_CODE" property="eleCode"/>
|
<result column="ELE_VALUE" property="eleValue"/>
|
<result column="ROW_NO" property="rowNo"/>
|
</collection>
|
</resultMap>
|
|
|
<select id="isEmpty" resultType="java.lang.Integer">
|
|
select count(0) from epc_master_value_{rule} b where
|
|
b.DEFINE_CODE = #{mdCode}
|
AND b.ELE_CODE = #{eleCode}
|
AND b.TENANT_ID = #{tenantId}
|
AND DATA_START = 0
|
AND b.ROW_NO = #{rowNo}
|
|
</select>
|
|
<select id="getMasterValString" resultType="java.lang.String">
|
select getVal_{rule}(
|
#{paramMap.defineCode}
|
, #{paramMap.eleCode}
|
, #{paramMap.masterCode}
|
, #{paramMap.eleValue}
|
)
|
</select>
|
|
<update id="updateStart" >
|
update epc_master_value_{rule}
|
set
|
data_start = 99
|
,upd_p = -1
|
,upd_t = now()
|
where
|
define_code = #{mdCode}
|
and row_no
|
<foreach collection="list" item="data" open="IN (" close=")" separator=",">
|
#{data.rowNum}
|
</foreach>
|
</update>
|
|
<delete id="deleteValue">
|
delete from epc_master_value_{rule}
|
where define_code = #{config.masDataDefCode}
|
and row_no = #{config.rowNum}
|
</delete>
|
|
<select id="getVal" resultType="Object" parameterType="com.changhong.epc.bean.tenant.master.MasterEleValue">
|
SELECT
|
getVal_{rule} (
|
#{mast.defineCode},
|
#{mast.inMeCode},
|
#{mast.outMeCode} ,
|
#{mast.mvCode}
|
);
|
</select>
|
|
|
|
<select id="selectCode" resultMap="MasterElementMap" >
|
SELECT
|
CODE,
|
ALIAS
|
FROM
|
epc_master_element_{rule}
|
WHERE
|
DEFINE_code = #{code}
|
AND ALIAS IN ('code', 'value')
|
</select>
|
|
<select id="selectMasterValueListExtend" resultMap="masterValueMap">
|
select
|
ID,
|
DEFINE_CODE,
|
<choose>
|
|
<when test="params != null">
|
(
|
CASE
|
<foreach collection="params" item="item" index="index">
|
WHEN ELE_CODE = #{item.code}
|
THEN #{item.alias}
|
</foreach>
|
END
|
) ELE_CODE,
|
|
</when>
|
<otherwise>
|
ELE_CODE,
|
</otherwise>
|
</choose>
|
ELE_VALUE,
|
ROW_NO
|
from epc_master_value_{rule}
|
where DEFINE_CODE = #{defineCode}
|
and ELE_CODE in
|
|
<foreach collection="params" item="item" index="index" open="(" close=")" separator=",">
|
#{item.code}
|
</foreach>
|
|
and DEL_FLAG = 0
|
<if test="list != null">
|
and ROW_NO in(select ROW_NO from epc_master_value_{rule} where DEFINE_CODE = #{defineCode} and ELE_VALUE in
|
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
)
|
</if>
|
<if test="value != null and list ==null">
|
and ROW_NO in(select ROW_NO from epc_master_value_{rule} where DEFINE_CODE = #{defineCode}
|
and ELE_CODE in
|
<foreach collection="params" item="item" index="index" open="(" close=")" separator=",">
|
#{item.code}
|
</foreach>
|
and ELE_VALUE LIKE CONCAT('%',#{value},'%'))
|
</if>
|
<if test="value != null and list !=null">
|
or ROW_NO in(select ROW_NO from epc_master_value_{rule} where DEFINE_CODE = #{defineCode}
|
and ELE_CODE in
|
<foreach collection="params" item="item" index="index" open="(" close=")" separator=",">
|
#{item.code}
|
</foreach>
|
and ELE_VALUE LIKE CONCAT('%',#{value},'%'))
|
</if>
|
ORDER BY ROW_NO
|
<if test="isAll!=null">
|
limit 200
|
</if>
|
</select>
|
|
<select id="selectValue" resultMap="ValueResultMap">
|
SELECT
|
DISTINCT
|
ELE_VALUE,ROW_NO
|
FROM
|
epc_master_value_{rule} T1
|
RIGHT JOIN (
|
SELECT
|
mse.DEFINE_CODE,
|
mse.CODE,
|
mse.ALIAS
|
FROM
|
epc_master_element_{rule} mse
|
WHERE
|
mse.DEFINE_CODE = #{code}
|
AND mse.ALIAS IN ('code', 'value')
|
) T2
|
ON T2.DEFINE_CODE = T1.DEFINE_CODE
|
AND T2.CODE = T1.ELE_CODE
|
ORDER BY ROW_NO,ALIAS
|
</select>
|
|
<select id="getValString" resultType="java.lang.String">
|
SELECT
|
(
|
select T3.ELE_VALUE FROM epc_master_value_{rule} T3
|
WHERE
|
T3.DEFINE_CODE = T2.DEFINE_CODE
|
and T3.ROW_NO = T2.ROW_NO
|
and T3.ELE_CODE = #{meCode}
|
and T3.DEL_FLAG = 0
|
limit 1
|
) result
|
FROM
|
(
|
select
|
DISTINCT
|
T1.DEFINE_CODE,
|
T1.ELE_CODE,
|
T1.ELE_VALUE,
|
T1.ROW_NO
|
from epc_master_value_{rule} T1
|
WHERE T1.DEFINE_CODE = #{mdCode}
|
AND T1.DEL_FLAG = 0
|
ORDER BY
|
T1.ROW_NO
|
)T2
|
<where>
|
<foreach collection="params" item="item" open="(" close=")" separator="or">
|
(T2.ELE_CODE, T2.ELE_VALUE) = (#{item.leftMeCode},#{item.meValue})
|
</foreach>
|
</where>
|
GROUP BY T2.ROW_NO
|
HAVING count(ROW_NO) = ${params.size()}
|
LIMIT 1
|
</select>
|
|
|
<select id="selectValues" resultType="java.util.Map" >
|
select
|
id,
|
<foreach collection="list" item="ele" separator=",">
|
${ele.tableField} as #{ele.meCode}
|
</foreach>
|
from ${name}
|
where data_start = 0 and isBlock = '0'
|
</select>
|
|
|
<delete id="deleteAll">
|
delete from epc_master_value_{rule}
|
|
</delete>
|
|
<select id="selectValueSeache" resultMap="ValueResultMap">
|
SELECT
|
DISTINCT
|
ELE_VALUE,ROW_NO
|
FROM
|
epc_master_value_{rule} T1
|
RIGHT JOIN (
|
SELECT
|
mse.DEFINE_CODE,
|
mse.CODE,
|
mse.ALIAS
|
FROM
|
epc_master_element_{rule} mse
|
WHERE
|
mse.DEFINE_CODE = #{code}
|
AND mse.ALIAS IN ('code', 'value')
|
) T2
|
ON T2.DEFINE_CODE = T1.DEFINE_CODE
|
AND T2.CODE = T1.ELE_CODE
|
<if test="value !=null">
|
and ROW_NO in(select ROW_NO from epc_master_value_{rule} where DEFINE_CODE = #{code} and ELE_VALUE LIKE CONCAT('%',#{value},'%'))
|
</if>
|
<if test="list !=null">
|
and ROW_NO in(select ROW_NO from epc_master_value_{rule} where DEFINE_CODE = #{code} and ELE_VALUE in
|
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
)
|
</if>
|
ORDER BY ROW_NO,ALIAS
|
LIMIT 200
|
</select>
|
|
<select id="getMasterCode" resultType="java.lang.String">
|
SELECT
|
a.ELE_VALUE
|
FROM
|
epc_master_value_{rule} a
|
WHERE
|
a.DEFINE_CODE = #{master.defineCode}
|
AND a.ELE_CODE = (
|
SELECT
|
CODE
|
FROM
|
epc_master_element_{rule} b
|
WHERE
|
b.DEFINE_CODE = #{master.defineCode}
|
AND b.alias = 'code'
|
limit 1
|
)
|
AND a.ROW_NO = (
|
SELECT
|
ROW_NO
|
FROM
|
epc_master_value_{rule} c
|
WHERE
|
c.DEFINE_CODE = #{master.defineCode} and
|
c.ELE_VALUE = #{master.eleValue}
|
limit 1
|
)
|
limit 1
|
</select>
|
|
|
<select id="selectValue1" resultMap="ValueResultMap1">
|
SELECT
|
ELE_CODE,
|
ELE_VALUE,ROW_NO
|
FROM
|
epc_master_value_{rule} T1
|
where DEFINE_CODE = #{code}
|
ORDER BY ROW_NO
|
</select>
|
|
<insert id="addConfigMaster">
|
insert into ${tableName}
|
<foreach collection="data" index="key" item="vaj" separator="," open="(" close=")">
|
${key}
|
</foreach>
|
values
|
<foreach collection="data" index="key" item="val" separator="," open="(" close=")">
|
#{val}
|
</foreach>
|
</insert>
|
|
<delete id="deleteConfigMaster">
|
delete from ${tableName}
|
where id = #{id}
|
</delete>
|
|
<update id="updateConfigMaster">
|
update ${tableName} set
|
<foreach collection="data" index="key" item="val" separator="," >
|
${key}=#{val}
|
</foreach>
|
,company_code = #{companyCode}
|
,company_name = #{companyName}
|
where id = #{id}
|
</update>
|
|
<select id="getValTwoDimensional" resultType="java.lang.String">
|
select
|
${resField}
|
from ${tableName}
|
<where>
|
<if test="params != null">
|
<foreach collection="params" item="param" separator=" AND ">
|
${param.fieldName} = #{param.meValue}
|
</foreach>
|
</if>
|
</where>
|
limit 1
|
</select>
|
|
<select id="twoCodeValue" resultType="java.lang.String">
|
|
select ${field}
|
from ${tableName}
|
where ${conditionField} = #{conditionValue}
|
LIMIT 1
|
</select>
|
|
<select id="seacherValues" resultType="java.util.Map">
|
SELECT
|
${code} `code`,
|
${value} `value`
|
FROM
|
${tableName}
|
<trim prefix="where" prefixOverrides="AND | OR">
|
<if test="eleValue != null">
|
and ${value} LIKE CONCAT('%', #{eleValue}, '%')
|
</if>
|
<if test="list!=null">
|
and ${code} in
|
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
#{item}
|
</foreach>
|
</if>
|
</trim>
|
</select>
|
|
</mapper>
|