kimi
2020-03-13 8033eea1502d4cb0a91aa4b86c848ccb00ba8dc0
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
<?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.highdatas.mdm.mapper.MaintainMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.highdatas.mdm.entity.Maintain">
        <id column="id" property="id" />
        <result column="operate" property="operate" />
        <result column="table_name" property="tableName" />
        <result column="flow_id" property="flowId" />
        <result column="charge_id" property="chargeId" />
        <result column="desp" property="desp" />
        <result column="version" property="version" />
        <result column="create_time" property="createTime" />
    </resultMap>
 
    <select id="selectVersionOperator"  resultType="java.util.Map">
        SELECT * from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        where parent_id = #{maintaInId} and ${where}
   </select>
    <select id="selectVersionOperatorByPage"  resultType="java.util.Map">
        SELECT * from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        where parent_id = #{maintaInId} and ${where}
        ${limit}
    </select>
 
    <select id="countVersionOperator"  resultType="java.lang.Long">
        SELECT count(1) from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        where parent_id = #{maintaInId} and ${where}
    </select>
 
 
    <select id="selectVersionOperatorByType" resultType="java.util.Map" >
        SELECT * from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        WHERE parent_id = #{maintaInId} and ${where}
        AND d.operate = #{operate}
    </select>
 
    <select id="selectVersionOperatorByTypeByPage" resultType="java.util.Map" >
        SELECT * from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        WHERE parent_id = #{maintaInId}
        AND d.operate = #{operate} and ${where}
        ${limit}
    </select>
 
    <select id="selectInvalidVersionData" resultType="java.util.Map" >
        <![CDATA[
        SELECT ${tempHFields},status, operate,version  from (
                (SELECT h.*, status,operate,version,order_no
        FROM
            ${tableTempName} h
        LEFT JOIN maintain_detail d ON d.pre_merge_id = h.id
        LEFT JOIN maintain ON maintain.id = d.parent_id
        LEFT JOIN flows on flows.business_id = maintain.id
        WHERE flows.`status` <> 'open' and flows.`status` <> 'close'
         order BY  maintain.order_no desc)
        UNION
        (SELECT h.*, status,operate,version,order_no
        FROM
            ${tableTempName} h
        LEFT JOIN maintain_detail d ON d.pre_merge_id = h.id
        LEFT JOIN maintain ON maintain.id = d.parent_id
        LEFT JOIN flows on flows.business_id = maintain.id
        WHERE flows.id is null and maintain.id is not null
         order BY  maintain.order_no desc)
        ) a where ${where} ORDER BY order_no  desc
        ${limit}
         ]]>
    </select>
 
    <select id="countInvalidVersionData" resultType="java.lang.Long" >
        <![CDATA[
        SELECT count(1) from
        (
                SELECT h.*, status,operate
        FROM
            ${tableTempName} h
        LEFT JOIN maintain_detail d ON d.pre_merge_id = h.id
        LEFT JOIN maintain ON maintain.id = d.parent_id
        LEFT JOIN flows on flows.business_id = maintain.id
        WHERE flows.`status` <> 'open' and flows.`status` <> 'close'
        UNION
        SELECT h.*, status,operate
        FROM
            ${tableTempName} h
        LEFT JOIN maintain_detail d ON d.pre_merge_id = h.id
        LEFT JOIN maintain ON maintain.id = d.parent_id
        LEFT JOIN flows on flows.business_id = maintain.id
        WHERE flows.id is null and maintain.id is not null
        ) a where ${where}
        ]]>
    </select>
 
 
    <select id="countVersionOperatorByType" resultType="java.lang.Long">
        SELECT count(1) from ${tableTempName} t
        LEFT  JOIN maintain_detail d on d.pre_merge_id = t.id
        WHERE parent_id = #{maintaInId}
        AND d.operate = #{operate} and ${where}
    </select>
 
    <select id="countTempDataByVersionByFlow" resultType="java.lang.Long">
        SELECT count(1) from ${tableTempName} mt
        LEFT JOIN maintain_detail mad  on mad.pre_merge_id = mt.id
        LEFT JOIN flows on flows.business_id = mad.parent_id
        WHERE flows.id = #{flowId}
        AND  ${where}
    </select>
 
    <select id="tempDataByVersionByFlow" resultType="java.util.Map">
         SELECT ${fields}, mad.operate from ${tableTempName} mt
        LEFT JOIN maintain_detail mad  on mad.pre_merge_id = mt.id
        LEFT JOIN flows on flows.business_id = mad.parent_id
        WHERE flows.id = #{flowId}
        AND  ${where} ${limit}
    </select>
 
 
 
    <select id="countUnSubmitData" resultType="java.lang.Long">
        SELECT count(1) from ${tableTempName} mt
        LEFT JOIN maintain_detail mad  on mad.pre_merge_id = mt.id
        WHERE mad.parent_id = ${maintainId}
        AND  ${where}
    </select>
 
    <select id="selectUnSubmitData" resultType="java.util.Map">
         SELECT ${fields}, mad.operate from ${tableTempName} mt
        LEFT JOIN maintain_detail mad  on mad.pre_merge_id = mt.id
        WHERE mad.parent_id = ${maintainId}
        AND  ${where} ${limit}
    </select>
</mapper>