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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?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="cn.autoform.web.mapper.formset.FormSetMapper" >
 
    <resultMap id="FormSetListInfoMap" type="cn.autoform.db.entity.FormSetInfoEntity">
        <id property="formSetID" column="FORMSETID" />
        <result property="formName" column="FORMNAME"/>
        <result property="usedversion" column="USEDVERSION"/>
        <result property="createUser" column="CREATEUSER"/>
        <result property="createDatetime" column="CREATEDATETIME"/>
        <result property="bussinesssystem" column="BUSSINESSSYSTEM"/>
         <collection property="formbaseInfos" ofType="cn.autoform.db.entity.FormBaseInfoEntity">
            <id property="formID" column="FORMID" />
            <result property="formVer" column="FORMVERSION" />
            <result property="formSetID" column="FORMSETID" />
        </collection>
    </resultMap>
    
    <select id ="getFlagByFormID" resultType="java.lang.String">
        SELECT
            formset.BUSSINESSSYSTEM
        FROM
            formset
        LEFT JOIN formversion ON formset.FORMSETID = formversion.FORMSETID AND formset.TENANTID = formversion.TENANTID
        WHERE
            formversion.FORMID = #{formID}
        AND
            formversion.TENANTID = #{tenantID}
    
    </select>
 
    <select id="getFormSetInfo" resultType="cn.autoform.db.entity.FormSetEntity">
        SELECT
            FORMSETID,
            TENANTID,
            FORMNAME,
            DESCRIPTION,
            USEDVERSION,
            DELETEFLG,
            CREATEUSER,
            CREATEDATETIME,
            UPDATEUSER
        FROM
            FORMSET
        WHERE
        
            FORMSETID = #{formSetID}
        AND
            TENANTID = #{tenantID}
        AND
            DELETEFLG = "0"
    </select>
 
    <select id="getFormSetListInfo" resultMap="FormSetListInfoMap">
        SELECT
            FSET.FORMSETID,
            FSET.FORMNAME,
            FSET.USEDVERSION,
            FSET.CREATEUSER,
            FSET.CREATEDATETIME,
            FSET.BUSSINESSSYSTEM,
            FVERSION.FORMID,
            FVERSION.FORMVERSION
        FROM
            FORMSET FSET
        LEFT JOIN FORMVERSION FVERSION ON FSET.FORMSETID = FVERSION.FORMSETID
        WHERE
            FSET.TENANTID =#{tenantID}
        AND
            FSET.DELETEFLG = "0"
        <if test="selectName != null">
          AND
             FSET.FORMNAME LIKE CONCAT('%',#{selectName},'%')
          </if>
        ORDER BY FSET.FORMNAME ASC,
            FSET.CREATEDATETIME DESC
        <if test="pageSize != 0 ">
        LIMIT #{pageStrat},#{pageSize}
        </if>
    </select>
    <select id="getFormSetListCount" resultType="int">
        SELECT
            count(*)
        FROM
            FORMSET FSET
        LEFT JOIN FORMVERSION FVERSION ON FSET.FORMSETID = FVERSION.FORMSETID
        WHERE
            FSET.TENANTID =#{tenantID}
        AND
            FSET.DELETEFLG = "0"
        <if test="selectName != null">
          AND
             FSET.FORMNAME LIKE CONCAT(#{selectName},'%')
          </if>
    </select>
    <!--  AND A.BUSSINESSSYSTEM = #{businessSystem} 后续修改添加flag使用 -->
    <select id="queryFormSetPaging" parameterType="cn.autoform.db.exten.FormSetPage" resultType="cn.autoform.db.entity.FormOperationEntity">
        SELECT
            formSet.FORMSETID,
            formBase.FORMID,
            formSet.TENANTID,
            formSet.FORMNAME,
            formSet.BUSSINESSSYSTEM,
            ENABLESETTING 
        FROM
            FORMSET formSet
        INNER JOIN FORMVERSION formVersion
        ON
            formSet.FORMSETID = formVersion.FORMSETID
        AND formSet.TENANTID = formVersion.TENANTID
        INNER JOIN FORMBASE formBase
        ON
            formVersion.FORMID = formBase.FORMID
        AND formVersion.TENANTID = formBase.TENANTID
        WHERE
            formSet.TENANTID = #{tenantID}
 
        AND formSet.DELETEFLG = '0'
        AND formBase.DELETEFLG = '0'
         <if test="formName != null">
          AND
             formSet.FORMNAME LIKE concat('%', #{formName}, '%')
          </if>
        ORDER BY formSet.FORMNAME ASC,
            formSet.CREATEDATETIME DESC
    </select>
    
    <select id="queryFormSetBussinesssystem" parameterType="cn.autoform.db.entity.FormSetEntity" resultType="java.lang.String">
        SELECT
            BUSSINESSSYSTEM
        FROM
            FORMSET
        WHERE
            FORMSETID = #{formSetID}
        AND TENANTID = #{tenantID}
    </select>
    
    <select id="getFormVersionByFormsetId" resultType="cn.autoform.db.entity.FormBaseInfoEntity">
        SELECT
            FVERSION.FORMID,
            FVERSION.FORMVERSION AS formVer,
            FORMSETID
        FROM
            FORMVERSION FVERSION
        WHERE
            FVERSION.FORMSETID = #{formSetID}
    </select>
 
     <select id="queryFormSetCount" resultType="java.lang.Integer">
        SELECT
            COUNT(1)
        FROM
            FORMSET formSet
        INNER JOIN FORMVERSION formVersion
        ON
            formSet.FORMSETID = formVersion.FORMSETID
        AND formSet.TENANTID = formVersion.TENANTID
        INNER JOIN FORMBASE formBase
        ON
            formVersion.FORMID = formBase.FORMID
        AND formVersion.TENANTID = formBase.TENANTID
        WHERE
            formSet.TENANTID = 001    #{tenantID}
        AND formBase.ENABLESETTING = '1'
        AND formSet.DELETEFLG = '0'
        AND formBase.DELETEFLG = '0'
            <if test="formName != null">
        WHERE
             formSet.FORMNAME LIKE #{formName}
          </if>
    </select> 
 
    <update id="updateFormSetInfo" parameterType="cn.autoform.db.entity.FormSetEntity">
        UPDATE FORMSET
        SET
            FORMNAME = #{formName},
            DESCRIPTION = #{description},
            USEDVERSION = #{usedversion}
        WHERE
            FORMSETID = #{formSetID}
        AND TENANTID = #{tenantID}
    </update>
    
    <update id="updateFormSetUseVerInfo" parameterType="cn.autoform.db.entity.FormSetEntity">
        UPDATE FORMSET
        SET
            USEDVERSION = #{usedversion},
            UPDATEUSER = #{updateUser}
        WHERE
            FORMSETID = #{formSetID}
        AND TENANTID = #{tenantID}
    </update>
    
    <insert id="insert" parameterType="cn.autoform.db.entity.FormSetEntity">
        INSERT INTO FORMSET
           (FORMSETID,
            TENANTID,
            FORMNAME,
            DESCRIPTION,
            USEDVERSION,
            DELETEFLG,
            CREATEUSER,
            CREATEDATETIME,
            UPDATEUSER,
            UPDATEDATETIME,
            BUSSINESSSYSTEM)
        VALUES
           (#{formSetID},
            #{tenantID},
            #{formName},
            #{description},
            #{usedversion},
            '0',
            #{createUser},
            CURRENT_TIMESTAMP(),
            #{updateUser},
            CURRENT_TIMESTAMP(),
            #{businessSystem})
    </insert>
    
    <select id="getFormOperationInfo" resultType="cn.autoform.db.entity.FormOperationEntity">
        SELECT
            formSet.FORMSETID,
            formBase.FORMID,
            formSet.TENANTID,
            formSet.FORMNAME,
            formSet.BUSSINESSSYSTEM
        FROM
            FORMSET formSet
        INNER JOIN FORMVERSION formVersion
        ON
            formSet.FORMSETID = formVersion.FORMSETID
        AND formSet.TENANTID = formVersion.TENANTID
        INNER JOIN FORMBASE formBase
        ON
            formVersion.FORMID = formBase.FORMID
        AND formVersion.TENANTID = formBase.TENANTID
        WHERE
            formSet.TENANTID = #{tenantID}
        AND formBase.ENABLESETTING = '1'
        AND formSet.DELETEFLG = '0'
        AND formBase.DELETEFLG = '0'
        ORDER BY formSet.FORMNAME ASC,
            formSet.CREATEDATETIME DESC
    </select>
    
    <update id="updateFormSetInfo1" parameterType="cn.autoform.db.entity.FormSetEntity">
        UPDATE FORMSET
        SET
            FORMNAME = #{formName},
            UPDATEUSER = #{updateUser}
        WHERE
            FORMSETID = #{formSetID}
        AND TENANTID = #{tenantID}
    </update>
    
    <update id="deleteFormSet" parameterType="cn.autoform.db.entity.FormSetEntity">
        UPDATE FORMSET
        SET
            DELETEFLG = "1",
            UPDATEUSER = #{updateUser}
        WHERE
            FORMSETID = #{formSetID}
        AND TENANTID = #{tenantID}
    </update>
    
    <select id="selectBuss" resultType="java.lang.String">
        SELECT
            FORMNAME
        FROM
            formset
        WHERE
            FORMSETID = (
                SELECT
                    FORMSETID
                FROM
                    formversion
                WHERE
                    FORMID = #{formId}  and TENANTID = #{tenantId}
            )
        limit 1    
    </select>
</mapper>