zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?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" >
<!-- Table:epc_app_stander_def_{rule} -->
<mapper namespace="com.changhong.epc.admin.mapper.centen.master.MasterElementMapper">
    
    <resultMap type="com.changhong.epc.bean.tenant.master.MasterElement" id="elementInfosMap">
        <result column="CODE" property="code"/>
        <result column="NAME" property="name"/>
        <result column="TYPE" property="type"/>
    </resultMap>
    
    
    <resultMap id="MasterElementMap" type="com.changhong.epc.bean.tenant.master.extend.MasterElementExtend" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="joinMd" property="joinMd"/>
        <result column="DEFINE_CODE" property="defineCode" jdbcType="VARCHAR" />
           <result column="CODE" property="code"/>
        <result column="NAME" property="name"/>
        <result column="TYPE" property="type"/>
        <result column="LEN" property="len" />
        <result column="PREC" property="prec" />
        <result column="MUST_FLAG" property="mustFlag"/>
        <result column="DESCRIPTION" property="description"/>
        <result column="ALIAS" property="alias"/>
        <result column="DEL_FLAG" property="delFlag"/>
      </resultMap>
 
    <resultMap id="MaterEleMentCodeMap" type="com.changhong.epc.bean.tenant.master.extend.GeneralMasterElement">
        <result column="DEFINE_CODE" property="defineCode" jdbcType="VARCHAR" />
        <result column="CODE" property="code"/>
        <result column="NAME" property="name"/>
        <result column="TYPE" property="type"/>
        <result column="LEN" property="len" />
        <result column="PREC" property="prec" />
        <result column="ALIAS" property="alias"/>
        <result column="DEL_FLAG" property="delFlag"/>
    </resultMap>
    
    <select id="selectByCode" resultMap="MasterElementMap" >
        SELECT
    (
        SELECT
            group_concat(c.DEFINE_CODE)
        FROM
            epc_master_element c
        WHERE
            c.`CODE` = me.`CODE`
        AND c.ALIAS = 'code'
    ) joinMd,
        me.ID,
        me.DEFINE_CODE,
        me.CODE,
        me.NAME,
        me.TYPE,
        me.LEN,
        me.PREC,
        me.MUST_FLAG,
        me.DESCRIPTION,
        me.ALIAS,
        me.DEL_FLAG,
        me.DEF1,
        me.DEF2,
        me.DEF3,
        me.DEF4,
        me.DEF5,
        me.INS_P,
        me.INS_T,
        me.UPD_P,
        me.UPD_T,
        me.TENANT_ID,
        me.DATA_START
        FROM
            epc_master_element  me
        WHERE
            DEFINE_CODE = #{code}
        ORDER BY
            alias DESC,
            joinMd DESC
    </select>
    
    <select id="elementInfos" resultMap="elementInfosMap" >
        select
            CODE
            , REPLACE(name,'code_','') NAME
            , TYPE
        from epc_master_element
            where DEL_FLAG = 0
        <if test="code != null">
            and DEFINE_CODE = #{code}
        </if>
    
    </select>
    
    <select id="geteleCode" resultType="java.lang.String">
        SELECT
            CODE
        FROM
            epc_master_element
        WHERE
            DEFINE_CODE = #{code}
        AND ALIAS = #{type}
    
    
    </select>
    
    
     <delete id="deleteAll">
          delete from epc_master_element
          
     </delete>
     
      <update id="updateAlias">
         UPDATE epc_master_element
        SET
            ALIAS = #{alias}
        WHERE
            DEFINE_CODE = #{defineCode}
        <if test="eleCode != null">
            AND `CODE` = #{eleCode}
         </if>
     </update>
 
    <delete id="deleteByDefineCode">
        delete from
            epc_master_element
        where
            define_code=#{code}
 
    </delete>
 
    <select id="findMasterEleByCode" resultMap="MaterEleMentCodeMap">
        SELECT
          id,define_code,code,name,type,len,prec,alias,del_flag
        from
          epc_master_element
        where
          define_code=#{code}
    </select>
    
</mapper>