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
<?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_supp_stander_{rule}   -->
<mapper namespace="com.changhong.epc.tenant.mapper.tenant.norm.SuppStanderMapper">
     <resultMap id="suppAndapp" type="com.changhong.epc.bean.tenant.norm.extend.SuppStanderExtend">
        <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="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.tenant.norm.extend.AppStanderExtend">
          <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>
    
    <sql id="normTypeSql">
        t1.id,t1.NAME,t1.type,t1.type_name,
        t1.sub_type,t1.rule,t1.ct_id,
        t1.data_start,t1.ins_p,t1.ins_t,
        t1.upd_p,t1.upd_t,t2.id as appId,
        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
    </sql>
    <insert id="SuppStanderSave" parameterType="com.changhong.epc.bean.tenant.norm.extend.SuppStanderExtend"
     useGeneratedKeys="true"  keyProperty="supp.id" >
        insert into epc_supp_stander_{rule}  (id,name,type,type_name,sub_type,rule,ct_id,data_start,ins_p,ins_t,upd_p,upd_t)
        values
        (null,#{supp.name},#{supp.type},#{supp.typeName},#{supp.subType},#{supp.rule},#{supp.ctId},#{supp.dataStart},#{supp.insP},#{supp.insT},#{supp.updP},#{supp.updT})
    </insert>
 
    <select id="selectByid" resultMap="suppAndapp" parameterType="java.lang.Integer">
        SELECT
            t1.id,
            t1.NAME,
            t1.type,
            t1.type_name,
            t1.sub_type,
            t1.rule,
            t1.ct_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,
            ct.overlook_expend_type
        FROM
        epc_supp_stander_{rule}   t1
        left join epc_cost_type_{rule} ct on t1.ct_id = ct.id and ct.data_start = 0
        LEFT JOIN epc_app_stander_def_{rule} 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>
        </trim>
        group by t2.ss_id,t2.row_no,t2.col_no
    </select>
    
    <update id="SuppStanderUpdate" parameterType="com.changhong.epc.bean.tenant.norm.extend.SuppStanderExtend">
        update  epc_supp_stander_{rule}   SET data_start=99
        where ct_id 
        <foreach collection="supp" item="sup" open="in("  close=")" separator=",">
            #{sup.ctId}
        </foreach>
    </update>
 
    <select id="selectCostTypeIds" resultType="com.changhong.epc.bean.tenant.cost.CostType">
        select
            DISTINCT
            ct_id id
        from epc_supp_stander_{rule}
        where data_start = 0
    </select>
 
    <insert id="copySuppStander" >
        insert into epc_supp_stander_{rule}(id,NAME,type,type_name,sub_type,rule,ct_id,data_start,ins_p,ins_t,upd_p,upd_t)
        select id,NAME,type,type_name,sub_type,rule,ct_id,data_start,ins_p,ins_t,upd_p,upd_t
        from epc_center.epc_cost_supp_stander_template
        where cg_id = #{costTypeTempId}
        and ct_id = #{ctId}
    </insert>
 
    <insert id="copyAppStanderDef">
        insert into epc_app_stander_def_{rule}
        select a.*
        from epc_center.epc_cost_app_stander_def_template a
        left join epc_center.epc_cost_supp_stander_template c on a.ss_id = c.id
        where c.cg_id = #{costTypeTempId}
        and c.ct_id = #{ctId}
    </insert>
 
</mapper>