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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?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.admin.mapper.centen.cost.CostTypeTemplateMapper">
    <resultMap type="com.changhong.epc.bean.admin.CostTypeTemplate" id="selectCost">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="costDesc" column="cost_desc"/>
        <result property="formIdStr" column="FORM_ID_STR"/>
    </resultMap>
 
    <select id="selectByPage" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate" resultMap="selectCost">
            SELECT
                ID, 
                NAME, 
                COST_DESC, 
                INS_T, 
                INS_P, 
                UPD_T, 
                UPD_P, 
                DATA_START,
                FORM_ID_STR
            FROM
                EPC_COST_TYPE_TEMPLATE_GROUP
            WHERE DATA_START = 0
            ORDER BY ID DESC        
    </select>
 
 
    <resultMap id="getCostTypeTemplateMap" type="com.changhong.epc.bean.admin.extend.CostTypeTemplateExtend">
        <id column="gId" property="id"/>
        <result column="FORM_ID_STR" property="formIdStr"/>
        <collection property="constGroupTypes" ofType="com.changhong.epc.bean.admin.extend.CostGroupTypeExtend">
            <id column="tId" property="id"/>
            <result column="codeId" property="codeId"/>
            <result column="node_name" property="nodeName"/>
            <collection property="costFromTemplate" ofType="com.changhong.epc.bean.admin.CostFromTemplate">
                <id column="fId" property="id"/>
                <result column="ct_id" property="ctId"/>
                <result column="f_id" property="fId"/>
                <result column="f_name" property="fName"/>
                <result column="type" property="type"/>
            </collection>
        </collection>
    </resultMap>
 
    <select id="getCostTypeTemplate" resultMap="getCostTypeTemplateMap">
        select
            tt.id tId
            , tt.codeId
            , tt.node_name
            , ft.id fId
            , ft.ct_id
            , ft.f_id
            , ft.f_name
            , ft.type
            , g.id gId
            , g.FORM_ID_STR
        from EPC_COST_TYPE_TEMPLATE_GROUP g
        left join epc_cost_type_template tt on g.id = tt.g_id and tt.data_start = 0
        left join epc_cost_from_template ft on tt.id = ft.ct_id and ft.data_start = 0
        where g.id = #{ctId}
    </select>
    <!--and ft.id is not null-->
 
    <update id="updateTemplate" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate">
        UPDATE EPC_COST_TYPE_TEMPLATE_GROUP
        SET
        <trim suffix="" suffixOverrides="," >
            <if test="name != null">
                 name = #{name},
            </if>
            <if test="costDesc != null">
                 cost_desc = #{costDesc},
            </if>
            <if test="formIdStr != null">
                 form_id_str = #{formIdStr}
            </if>
        </trim>
        WHERE id = #{id}
    </update>
 
    <select id="getCostTypeTemplateByName" resultType="com.changhong.epc.bean.admin.CostTypeTemplate">
            SELECT
                ID,
                NAME,
                COST_DESC,
                INS_T,
                INS_P,
                UPD_T,
                UPD_P,
                DATA_START
            FROM
                EPC_COST_TYPE_TEMPLATE_GROUP
            WHERE
                NAME = #{name}
            AND
                DATA_START = 0
    </select>
 
    <insert id="createTemplate" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate">
        INSERT INTO EPC_COST_TYPE_TEMPLATE_GROUP
        (
            NAME,
            COST_DESC,
            INS_T,
            INS_P,
            UPD_T,
            UPD_P,
            DATA_START
        )
        VALUE
        (
            #{name},
            #{costDesc},
            #{insT},
            #{insP},
            #{updT},
            #{updP},
            #{dataStart}
        )
    </insert>
 
    <resultMap id="suppAndapp" type="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
        <id property="id" column="id"/><!-- 主键id -->
        <result property="name" column="name"/>
        <result property="type" column="type"/>
        <result property="typeName" column="type_name"/>
        <result property="subType" column="sub_type"/>
        <result property="rule" column="rule"/>
        <result property="ctId" column="ct_id"/>
        <result property="cgId" column="cg_id"/>
        <!--        <result property="overlookExpendType" column="overlook_expend_type"/>-->
        <result property="dataStart" column="data_start"/>
        <result property="insP" column="ins_p"/>
        <result property="insT" column="ins_t"/>
        <result property="updP" column="upd_p"/>
        <result property="updT" column="upd_t"/>
        <collection property="appStanderDefs" javaType="java.util.List"
                    ofType="com.changhong.epc.bean.admin.extend.AppStanderDefTemplateExtend">
            <id property="id" column="appId"/>
            <result property="elIden" column="el_iden"/>
            <result property="masDefineCode" column="mas_define_code"/>
            <result property="type" column="aType"/>
            <result property="defType" column="def_type"/>
            <result property="defName" column="def_name"/>
            <result property="asDefValue" column="def_value"/>
            <result property="defValue" column="def_value"/>
            <result property="rowNo" column="row_no"/>
            <result property="colNo" column="col_no"/>
            <result property="squ" column="squ"/>
            <result property="showFlag" column="show_flag"/>
            <result property="relation" column="relation"/>
            <result property="inverse" column="inverse"/>
            <result property="showCount" column="show_count"/>
            <result property="count" column="count"/>
            <result property="insP" column="ins_p"/>
            <result property="insT" column="ins_t"/>
            <result property="updP" column="upd_p"/>
            <result property="updT" column="upd_t"/>
            <result property="dataStart" column="data_start"/>
        </collection>
    </resultMap>
 
    <select id="selectByid" resultMap="suppAndapp" parameterType="com.changhong.epc.bean.admin.SuppStanderTemplate">
        SELECT
        t1.id,
        t1.NAME,
        t1.type,
        t1.type_name,
        t1.sub_type,
        t1.rule,
        t1.ct_id,
        t1.cg_id,
        t1.data_start,
        t1.ins_p,
        t1.ins_t,
        t1.upd_p,
        t1.upd_t,
        t2.el_iden,
        t2.mas_define_code,
        t2.type as aType,
        t2.def_type,
        t2.def_name,
        t2.def_value,
        t2.row_no,
        t2.col_no,
        t2.squ,
        t2.show_flag,
        t2.relation,
        t2.inverse,
        t2.show_count,
        t2.count,
        t2.ss_id,
        t2.ins_p,
        t2.ins_t,
        t2.upd_p,
        t2.upd_t,
        t2.data_start
        FROM epc_cost_supp_stander_template t1
        LEFT JOIN epc_cost_app_stander_def_template t2 ON t1.id = t2.ss_id
        <trim prefix="WHERE" prefixOverrides="AND | OR">
            t1.data_start = 0
            <if test="ctId!=null">
                and t1.ct_id=#{ctId}
            </if>
            <if test="cgId!=null">
                and t1.cg_id=#{cgId}
            </if>
        </trim>
        group by t2.ss_id,t2.row_no,t2.col_no
    </select>
 
    <update id="suppStanderUpdate" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
        update epc_cost_supp_stander_template SET data_start=99
        where ct_id
        <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
            #{sup.ctId}
        </foreach>
        and cg_id
        <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
            #{sup.cgId}
        </foreach>
    </update>
 
    <update id="appStanderDefUpdate" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
        update epc_cost_app_stander_def_template SET data_start=99
        where
        ss_Id
        in(
        select id from epc_cost_supp_stander_template where ct_id
        <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
            #{sup.ctId}
        </foreach>
        and cg_id
        <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
            #{sup.cgId}
        </foreach>
        )
    </update>
 
    <insert id="suppStanderSave" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend"
            useGeneratedKeys="true" keyProperty="supp.id">
        insert into epc_cost_supp_stander_template (id, cg_id,name,type,type_name,sub_type,rule,ct_id,data_start,ins_p,ins_t,upd_p,upd_t)
        values
        (null,#{supp.cgId}, #{supp.name},#{supp.type},#{supp.typeName},#{supp.subType},#{supp.rule},#{supp.ctId},#{supp.dataStart},#{supp.insP},#{supp.insT},#{supp.updP},#{supp.updT})
    </insert>
 
    <insert id="appStanderDefSaveOne">
        insert into epc_cost_app_stander_def_template (el_iden,mas_define_code,type,def_type,def_name,def_value,row_no,col_no,squ,show_flag,relation,inverse,
        show_count,count,ss_id,ins_p,ins_t,upd_p,upd_t,data_start)
        values
            (#{app.elIden},#{app.masDefineCode},#{app.type},#{app.defType},#{app.defName},#{app.asDefValue},#{app.rowNo},#{app.colNo},#{app.squ},#{app.showFlag},#{app.relation},#{app.inverse},#{app.showCount},#{app.count},#{supp.id},#{supp.insP},#{supp.insT},#{supp.updP},#{supp.updT},#{supp.dataStart})
    </insert>
 
</mapper>