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
<?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_cost_from_mapping_{rule} -->
<mapper namespace="com.changhong.epc.tenant.mapper.tenant.cost.CostFromMappingMapper">
          
          <resultMap type="com.changhong.epc.bean.tenant.cost.extend.CostFromMappingExtend" id="CostFromResult">
              <id property="id" column="id"/>
              <result property="fId" column="f_id"/>
              <result property="fName" column="f_name"/>
              <result property="type" column="type"/>
              <result property="ctId" column="ct_id"/>
              <association property="costType" javaType="com.changhong.epc.bean.tenant.cost.CostType">
                  <id property="id" column="bId"/>
                  <result property="nodeName" column="node_name"/>
                  <result property="parentId" column="parent_id"/>
              </association>
          </resultMap>
  
         <select id="selectByctId" resultType="com.changhong.epc.bean.tenant.cost.CostFromMapping">
             SELECT
                id,f_name,f_id
            FROM
                epc_cost_from_mapping_{rule}
            WHERE
                ct_id = #{cost.ctId} and type = #{cost.type}
         </select>
         
         <update id="updateCost" parameterType="com.changhong.epc.bean.tenant.cost.CostFromMapping">
             UPDATE epc_cost_from_mapping_{rule}
            SET 
            <if test="fName!=null">
                f_name = #{fName},
            </if>
            <if test="fId !=null">
                f_id = #{fId}
            </if>    
            WHERE
                ct_id = #{ctId} and type = #{type}    
         </update>
         
         <select id="selectCostType" resultMap="CostFromResult"
             parameterType="com.changhong.epc.bean.tenant.cost.CostFromMapping">
             SELECT
                a.id,
                a.f_id,
                a.f_name,
                a.type,
                a.ct_id,
                b.id bId,
                b.node_name,
                b.parent_id
            FROM
                epc_cost_from_mapping_{rule} a
            LEFT JOIN epc_cost_type_{rule} b ON a.ct_id = b.id
            <trim prefix="where" >
                <if test="fId !=null">
                    a.f_id = #{fId}
                </if>
           </trim>
            LIMIT 1         
         </select>
         
         <update id="deleteForm">
             UPDATE epc_cost_from_mapping_{rule} SET
                data_start = 99
                where ct_id = #{id}
         
         
         </update>
         
         <update id="deleteFormByCtidAndType">
            DELETE
            FROM
                epc_cost_from_mapping_{rule}
            WHERE
                ct_id = #{ctId}
            AND
                type = #{type}
         </update>
 
    <select id="getConstFroms" parameterType="com.changhong.epc.bean.tenant.cost.CostFromMapping" resultMap="CostFromResult">
        SELECT
                a.id,
                a.f_id,
                a.f_name,
                a.type,
                a.ct_id
        FROM
            epc_cost_from_mapping_{rule} a
        WHERE
            a.ct_id IN(
                SELECT
                    b.ct_id
                FROM
                    epc_cost_from_mapping_{rule} b
                WHERE
                    b.f_id = #{fId}
            )
    </select>
 
    <select id="selectType" resultMap="CostFromResult">
        SELECT
            id,
            f_id,
            f_name,
            type,
            ct_id
        FROM
            epc_cost_from_mapping_{rule}
        WHERE
            data_start = 0
            and type = #{type}
            AND f_id is not null
    </select>
    <!--GROUP BY f_id-->
</mapper>