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
<?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.initguide.InitCompanyMapper">
    <select id="isInitCompany" resultType="java.lang.Integer">
        SELECT 
            COUNT(0)
        FROM
            epc_init_company
        WHERE        
            companyId = #{companyId}
            
    </select>
    
    <select id="getCostGroupType" resultType="com.changhong.epc.bean.admin.CostGroupType">
            SELECT 
                a.id id,
                case when b.node_name != '' then b.node_name  else a.node_name  end as type,
                a.node_name nodeName,
                case when b.codeId !='' then b.codeId else '0' end as parentId,
                a.g_id as gId,
                a.codeId as codeId
            FROM
                epc_cost_type_template a
            LEFT JOIN
                epc_cost_type_template b
            ON
                a.parent_id = b.codeId
            WHERE
                a.g_id = #{id}
            AND 
                a.data_start = 0
            LIMIT 0, 100000
    </select>
    
    <insert id="addInitCompany">
        INSERT INTO 
            epc_init_company
        (
            company_id,
            tenant_id,
            power_app_key,
            power_secret_key
        )
        VALUE
        (
            #{company.id},            
            #{company.tenantId},
            #{tableRule.appKey},
            #{tableRule.secretKey}
        )
    
    </insert>
    
    <select id="selectInitCompany" parameterType="com.changhong.epc.bean.admin.InitCompany" resultType="com.changhong.epc.bean.admin.InitCompany">
        SELECT
            id,
            company_id companyId,
            company_name companyName,
            tenant_id tenantId,
            tenant_name tenantName,
            init_state initState,
            power_app_key powerAppKey,
            power_secret_key powerSecretKey,
            ins_t insT,
            upd_t updT,
            ins_p insP,
            upd_p updP,
            data_start dataStart,
            power_name powerName,
            db_name dbName
        FROM
            epc_init_company
        WHERE
            data_start = 0
            <if test="id != null">
        AND 
            id = #{id}
            </if>
            <if test="companyId != null">
        AND
            company_id = #{companyId}
            </if>
            <if test="tenantId != null">
        AND 
            tenant_id = #{tenantId}
            </if>
            <if test="initState != null">
        AND 
            init_state = #{initState}
            </if>
            <if test="powerAppKey != null">
        AND 
            power_app_key = #{powerAppKey}
            </if>
            <if test="powerSecretKey != null">
        AND 
            power_secret_key = #{powerSecretKey}
            </if>
            <if test="powerName != null">
        AND 
            power_name = #{powerName}
            </if>
    </select>
 
    <select id="initMenu" statementType="CALLABLE">
        {
            call init_menu(#{tenantId}, #{companyId})
        }
    </select>
 
    <select id="selectInitCompanyId" resultType="java.lang.String">
        select GROUP_CONCAT(company_id) from epc_init_company where tenant_id = #{tenantId}
    </select>
 
    <select id="selectTenantnameAndCompanynameByid" resultType="map">
        select company_name,tenant_name from epc_init_company
        <where>
            <if test="tenantId != null and tenantId != '' ">
                AND tenant_id = #{tenantId}
            </if>
            <if test="companyId != null and companyId != '' ">
                AND company_id = #{companyId}
            </if>
        </where>
    </select>
 
</mapper>