zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
commit | author | age
a18bfa 1 <?xml version="1.0" encoding="UTF-8" ?>
Z 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 <mapper namespace="com.changhong.epc.admin.mapper.centen.cost.CostTypeTemplateMapper">
4     <resultMap type="com.changhong.epc.bean.admin.CostTypeTemplate" id="selectCost">
5         <id property="id" column="id"/>
6         <result property="name" column="name"/>
7         <result property="costDesc" column="cost_desc"/>
8         <result property="formIdStr" column="FORM_ID_STR"/>
9     </resultMap>
10
11     <select id="selectByPage" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate" resultMap="selectCost">
12             SELECT
13                 ID, 
14                 NAME, 
15                 COST_DESC, 
16                 INS_T, 
17                 INS_P, 
18                 UPD_T, 
19                 UPD_P, 
20                 DATA_START,
21                 FORM_ID_STR
22             FROM
23                 EPC_COST_TYPE_TEMPLATE_GROUP
24             WHERE DATA_START = 0
25             ORDER BY ID DESC        
26     </select>
27
28
29     <resultMap id="getCostTypeTemplateMap" type="com.changhong.epc.bean.admin.extend.CostTypeTemplateExtend">
30         <id column="gId" property="id"/>
31         <result column="FORM_ID_STR" property="formIdStr"/>
32         <collection property="constGroupTypes" ofType="com.changhong.epc.bean.admin.extend.CostGroupTypeExtend">
33             <id column="tId" property="id"/>
34             <result column="codeId" property="codeId"/>
35             <result column="node_name" property="nodeName"/>
36             <collection property="costFromTemplate" ofType="com.changhong.epc.bean.admin.CostFromTemplate">
37                 <id column="fId" property="id"/>
38                 <result column="ct_id" property="ctId"/>
39                 <result column="f_id" property="fId"/>
40                 <result column="f_name" property="fName"/>
41                 <result column="type" property="type"/>
42             </collection>
43         </collection>
44     </resultMap>
45
46     <select id="getCostTypeTemplate" resultMap="getCostTypeTemplateMap">
47         select
48             tt.id tId
49             , tt.codeId
50             , tt.node_name
51             , ft.id fId
52             , ft.ct_id
53             , ft.f_id
54             , ft.f_name
55             , ft.type
56             , g.id gId
57             , g.FORM_ID_STR
58         from EPC_COST_TYPE_TEMPLATE_GROUP g
59         left join epc_cost_type_template tt on g.id = tt.g_id and tt.data_start = 0
60         left join epc_cost_from_template ft on tt.id = ft.ct_id and ft.data_start = 0
61         where g.id = #{ctId}
62     </select>
63     <!--and ft.id is not null-->
64
65     <update id="updateTemplate" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate">
66         UPDATE EPC_COST_TYPE_TEMPLATE_GROUP
67         SET
68         <trim suffix="" suffixOverrides="," >
69             <if test="name != null">
70                  name = #{name},
71             </if>
72             <if test="costDesc != null">
73                  cost_desc = #{costDesc},
74             </if>
75             <if test="formIdStr != null">
76                  form_id_str = #{formIdStr}
77             </if>
78         </trim>
79         WHERE id = #{id}
80     </update>
81
82     <select id="getCostTypeTemplateByName" resultType="com.changhong.epc.bean.admin.CostTypeTemplate">
83             SELECT
84                 ID,
85                 NAME,
86                 COST_DESC,
87                 INS_T,
88                 INS_P,
89                 UPD_T,
90                 UPD_P,
91                 DATA_START
92             FROM
93                 EPC_COST_TYPE_TEMPLATE_GROUP
94             WHERE
95                 NAME = #{name}
96             AND
97                 DATA_START = 0
98     </select>
99
100     <insert id="createTemplate" parameterType="com.changhong.epc.bean.admin.CostTypeTemplate">
101         INSERT INTO EPC_COST_TYPE_TEMPLATE_GROUP
102         (
103             NAME,
104             COST_DESC,
105             INS_T,
106             INS_P,
107             UPD_T,
108             UPD_P,
109             DATA_START
110         )
111         VALUE
112         (
113             #{name},
114             #{costDesc},
115             #{insT},
116             #{insP},
117             #{updT},
118             #{updP},
119             #{dataStart}
120         )
121     </insert>
122
123     <resultMap id="suppAndapp" type="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
124         <id property="id" column="id"/><!-- 主键id -->
125         <result property="name" column="name"/>
126         <result property="type" column="type"/>
127         <result property="typeName" column="type_name"/>
128         <result property="subType" column="sub_type"/>
129         <result property="rule" column="rule"/>
130         <result property="ctId" column="ct_id"/>
131         <result property="cgId" column="cg_id"/>
132         <!--        <result property="overlookExpendType" column="overlook_expend_type"/>-->
133         <result property="dataStart" column="data_start"/>
134         <result property="insP" column="ins_p"/>
135         <result property="insT" column="ins_t"/>
136         <result property="updP" column="upd_p"/>
137         <result property="updT" column="upd_t"/>
138         <collection property="appStanderDefs" javaType="java.util.List"
139                     ofType="com.changhong.epc.bean.admin.extend.AppStanderDefTemplateExtend">
140             <id property="id" column="appId"/>
141             <result property="elIden" column="el_iden"/>
142             <result property="masDefineCode" column="mas_define_code"/>
143             <result property="type" column="aType"/>
144             <result property="defType" column="def_type"/>
145             <result property="defName" column="def_name"/>
146             <result property="asDefValue" column="def_value"/>
147             <result property="defValue" column="def_value"/>
148             <result property="rowNo" column="row_no"/>
149             <result property="colNo" column="col_no"/>
150             <result property="squ" column="squ"/>
151             <result property="showFlag" column="show_flag"/>
152             <result property="relation" column="relation"/>
153             <result property="inverse" column="inverse"/>
154             <result property="showCount" column="show_count"/>
155             <result property="count" column="count"/>
156             <result property="insP" column="ins_p"/>
157             <result property="insT" column="ins_t"/>
158             <result property="updP" column="upd_p"/>
159             <result property="updT" column="upd_t"/>
160             <result property="dataStart" column="data_start"/>
161         </collection>
162     </resultMap>
163
164     <select id="selectByid" resultMap="suppAndapp" parameterType="com.changhong.epc.bean.admin.SuppStanderTemplate">
165         SELECT
166         t1.id,
167         t1.NAME,
168         t1.type,
169         t1.type_name,
170         t1.sub_type,
171         t1.rule,
172         t1.ct_id,
173         t1.cg_id,
174         t1.data_start,
175         t1.ins_p,
176         t1.ins_t,
177         t1.upd_p,
178         t1.upd_t,
179         t2.el_iden,
180         t2.mas_define_code,
181         t2.type as aType,
182         t2.def_type,
183         t2.def_name,
184         t2.def_value,
185         t2.row_no,
186         t2.col_no,
187         t2.squ,
188         t2.show_flag,
189         t2.relation,
190         t2.inverse,
191         t2.show_count,
192         t2.count,
193         t2.ss_id,
194         t2.ins_p,
195         t2.ins_t,
196         t2.upd_p,
197         t2.upd_t,
198         t2.data_start
199         FROM epc_cost_supp_stander_template t1
200         LEFT JOIN epc_cost_app_stander_def_template t2 ON t1.id = t2.ss_id
201         <trim prefix="WHERE" prefixOverrides="AND | OR">
202             t1.data_start = 0
203             <if test="ctId!=null">
204                 and t1.ct_id=#{ctId}
205             </if>
206             <if test="cgId!=null">
207                 and t1.cg_id=#{cgId}
208             </if>
209         </trim>
210         group by t2.ss_id,t2.row_no,t2.col_no
211     </select>
212
213     <update id="suppStanderUpdate" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
214         update epc_cost_supp_stander_template SET data_start=99
215         where ct_id
216         <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
217             #{sup.ctId}
218         </foreach>
219         and cg_id
220         <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
221             #{sup.cgId}
222         </foreach>
223     </update>
224
225     <update id="appStanderDefUpdate" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend">
226         update epc_cost_app_stander_def_template SET data_start=99
227         where
228         ss_Id
229         in(
230         select id from epc_cost_supp_stander_template where ct_id
231         <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
232             #{sup.ctId}
233         </foreach>
234         and cg_id
235         <foreach collection="supp" item="sup" open="in(" close=")" separator=",">
236             #{sup.cgId}
237         </foreach>
238         )
239     </update>
240
241     <insert id="suppStanderSave" parameterType="com.changhong.epc.bean.admin.extend.SuppStanderTemplateExtend"
242             useGeneratedKeys="true" keyProperty="supp.id">
243         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)
244         values
245         (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})
246     </insert>
247
248     <insert id="appStanderDefSaveOne">
249         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,
250         show_count,count,ss_id,ins_p,ins_t,upd_p,upd_t,data_start)
251         values
252             (#{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})
253     </insert>
254
255 </mapper>