zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
commit | author | age
a18bfa 1 <?xml version="1.0" encoding="UTF-8" ?>  
Z 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 <mapper namespace="cn.autoform.web.mapper.datamanagement.DataManagementMapper">
4     
5     <select id="getUserName" resultType="java.lang.String">
6     /*!mycat:sql=select tenantid from FORMDATAMANAGER WHERE TENANTID = '${tenantID}' AND FROMID = '${formID}' */        
7         select createUser from 
8             FORMDATA_${tenantID}_${formID} 
9         WHERE  
10             TENANTID = #{tenantID}     
11             AND dataRowNum = #{dataRowNum}
12     </select>
13     
14     <select id="getsubFormFieldCount" resultType="java.lang.Integer">
15     SELECT
16         COUNT(0)
17     FROM
18         formfield
19     WHERE
20         FORMID = #{formID}
21     AND TENANTID = #{tenantID}
22     AND FIELDTYPE != "subform"
23     AND PARENTSUBFORMNUM != 0
24     </select>
25     <select id="getFormContext" resultType="java.util.Map">
26         SELECT
27             formset.BUSSINESSSYSTEM,
28             formset.CREATEDATETIME,
29             formset.CREATEUSER
30         FROM
31             formset,
32             formversion
33         WHERE
34             formset.FORMSETID = formversion.FORMSETID
35         AND formversion.FORMID = #{formID}
36         AND formversion.TENANTID = #{tenantID}
37     </select>
38     
39     <select id="getFormDataContext" resultType="java.util.Map">
40         SELECT
41             mainForm.CREATEDATETIME as createDateTime,
42             mainForm.CREATEUSER as createUser,
43             mainForm.ENCLOSUREINFO as enclosureInfo,
44             process.process_state as processState
45         FROM
46             ${formName} AS mainForm
47         LEFT JOIN process_log AS process
48              ON process.FORMID = #{formID}
49             AND process.tenant_id = mainForm.TENANTID
50             AND process.DATAROWNUM = mainForm.DATAROWNUM
51         WHERE
52             mainForm.DATAROWNUM = #{datarowNum}
53         AND mainForm.TENANTID = #{tenantID}
54     </select>
55     
56     <select id="queryFormFieldPropertyByFieldKey" resultType="cn.autoform.db.entity.FormFieldEntity">
57         SELECT
58             `COLUMNORDERNUM`,
59             `FIELDKEY`
60         FROM
61             formfield
62         WHERE
63             FORMID = #{formID}
64         AND TENANTID = #{tenantID}
65         AND FIELDKEY = #{fieldKey}
66     </select>
67
68     <select id="queryFormFieldProperty" resultType="cn.autoform.db.entity.FieldPropertyEntity">
69         SELECT
70             `FORMID`,
71             `TENANTID`,
72             `COLUMNORDERNUM`,
73             `PROPERTY`,
74             `VALUE`,
75             `DELETEFLG`,
76             `CREATEUSER`,
77             `CREATEDATETIME`,
78             `UPDATEUSER`,
79             `UPDATEDATETIME`
80         FROM
81             fieldproperty
82         WHERE
83             FORMID = #{formID}
84         AND TENANTID = #{tenantID}
85         AND COLUMNORDERNUM = #{columnOrderNum}
86     </select>
87
88     <select id="queryFormFieldPropertyByField" resultType="cn.autoform.db.entity.FieldPropertyEntity">
89         SELECT
90             f1.`FORMID`,
91             f1.`TENANTID`,
92             f1.`COLUMNORDERNUM`,
93             f1.`PROPERTY`,
94             f1.`VALUE`,
95             f1.`DELETEFLG`,
96             f1.`CREATEUSER`,
97             f1.`CREATEDATETIME`,
98             f1.`UPDATEUSER`,
99             f1.`UPDATEDATETIME`
100         FROM
101             fieldproperty f1
102         left join formfield f2 on f1.COLUMNORDERNUM = f2.COLUMNORDERNUM and f2.FORMID = f1.FORMID and f2.TENANTID = f1.TENANTID
103         WHERE
104             f1.FORMID = #{formID}
105         AND f1.TENANTID = #{tenantID}
106         AND f2.FIELDKEY = #{field}
107     </select>
108     
109     <select id="queryFormMainField" resultType="cn.autoform.db.entity.FormFieldEntity">
110         SELECT
111             `TENANTID`,
112             `FORMID`,
113             `COLUMNORDERNUM`,
114             `FIELDTYPE`,
115             `PARENTSUBFORMNUM`,
116             `FIELDORDERNUM`,
117             `FIELDKEY`,
118             `DELETEFLG`,
119             `CREATEUSER`,
120             `CREATEDATETIME`,
121             `UPDATEUSER`,
122             `UPDATEDATETIME`,
123             `FIELDISSHOW`,
124             `SEARCHISSHOW`
125         FROM
126             FORMFIELD
127         WHERE
128             FORMID = #{formID}
129         AND TENANTID = #{tenantID}
130         AND PARENTSUBFORMNUM = 0
131         AND DELETEFLG = 0
132         AND FIELDTYPE IN (
133             'radio',
134             'dropdownlist',
135             'checkbox',
136             'tree'
137         );
138         
139     
140     </select>
141     
142     <select id="queryFormSubField" resultType="cn.autoform.db.entity.FormFieldEntity">
143         SELECT
144             `TENANTID`,
145             `FORMID`,
146             `COLUMNORDERNUM`,
147             `FIELDTYPE`,
148             `PARENTSUBFORMNUM`,
149             `FIELDORDERNUM`,
150             `FIELDKEY`,
151             `DELETEFLG`,
152             `CREATEUSER`,
153             `CREATEDATETIME`,
154             `UPDATEUSER`,
155             `UPDATEDATETIME`,
156             `FIELDISSHOW`,
157             `SEARCHISSHOW`
158         FROM
159             FORMFIELD
160         WHERE
161             FORMID = #{formID}
162         AND TENANTID = #{tenantID}
163         AND PARENTSUBFORMNUM != 0
164         AND DELETEFLG = 0
165         AND FIELDTYPE IN (
166             'radio',
167             'dropdownlist',
168             'checkbox',
169             'tree'
170         );
171         
172     
173     </select>
174     
175     <select id="queryFormAllField" resultType="cn.autoform.db.entity.FormFieldEntity">
176         SELECT
177             `TENANTID`,
178             `FORMID`,
179             `COLUMNORDERNUM`,
180             `FIELDTYPE`,
181             `PARENTSUBFORMNUM`,
182             `FIELDORDERNUM`,
183             `FIELDKEY`,
184             `DELETEFLG`,
185             `CREATEUSER`,
186             `CREATEDATETIME`,
187             `UPDATEUSER`,
188             `UPDATEDATETIME`,
189             `FIELDISSHOW`,
190             `SEARCHISSHOW`
191         FROM
192             FORMFIELD
193         WHERE
194             FORMID = #{formID}
195         AND TENANTID = #{tenantID}
196         AND PARENTSUBFORMNUM = 0
197         AND DELETEFLG = 0
198     </select>
199
200     <select id="getBaseTableName" resultType="java.lang.String">
201         SELECT
202             m.FORMDATATABLE
203         FROM
204             formdatamanager m
205         WHERE
206             m.FORMID = #{formID}
207         AND m.SUBFORMFLG = 0
208         AND tenantID = #{tenantID}
209     </select>
210     
211     <select id="queryCloudMainValue" resultType="java.lang.String">
212         ${excuteSql}
213     </select>
214     
215     <select id="queryFormDataPage" resultType="java.util.Map">
216         {mycat}
217         select
218             DATAROWNUM,processState,processLog,processTask,processUser
219             <if test="arrays.length > 0">
220                 ,
221             </if> 
222             <foreach collection="arrays" item="field" separator=",">
223                 ${field.fieldKey}
224             </foreach>
225         from {formname}
226         where deleteFlg = 0
227         and TENANTID = '{tenantId}'
228         <if test="where != null and where != ''">
229             and ${where}
230         </if>
231         order by DATAROWNUM desc
232     </select>
233     
234     <select id="queryAutoAttr" resultType="java.util.Map">
235         SELECT
236             PROPERTY,
237             `VALUE`
238         FROM
239             FIELDPROPERTY
240         WHERE
241             FORMID = #{formID}
242             
243         AND TENANTID = #{tenantID}
244         
245         AND PROPERTY IN (
246         'prefix',
247         'suffix',
248         'generationLength',
249         'gengerate'
250         )
251     </select>
252     
253     <select id="queryCodeAutoAttr" resultType="java.util.Map">
254         SELECT
255             PROPERTY,
256             `VALUE`
257         FROM
258             FIELDPROPERTY
259         WHERE
260             FORMID = #{formID}
261             
262         AND TENANTID = #{tenantID} 
263         
264         AND COLUMNORDERNUM = #{columnordernum}
265         
266         AND PROPERTY IN (
267         'autoType',
268         'autoTypeNumber',
269         'autoTypePrefix'
270         )
271     </select>
272     
273     <select id="checkFormId" resultType="java.lang.Integer">
274         SELECT
275             count(FORMID)
276         FROM
277             FORMDATAMANAGER
278         WHERE
279             FORMID = #{formID}
280         AND TENANTID = #{tenantID}
281     </select>
282
283     <select id="queryFormFields" resultType="cn.autoform.db.entity.FormFieldEntity">
284         select
285             formfield.formid as formid,
286             formfield.tenantid as tenantid,
287             formfield.columnordernum as columnordernum,
288             case when fieldproperty.value = 'password' then 'password' else formfield.fieldtype end as fieldtype,
289             formfield.parentsubformnum as parentsubformnum,
290             formfield.fieldordernum as fieldordernum,
291             formfield.fieldkey as fieldkey,
292             fieldproperty.value as value,
293             formbase.fieldset
294         from
295             formfield
296         left join fieldproperty
297         on
298                formfield.formid = fieldproperty.formid
299         and formfield.tenantid = fieldproperty.tenantid
300         and formfield.columnordernum = fieldproperty.columnordernum
301         and (fieldproperty.property = 'datatype' or fieldproperty.property = 'format' or fieldproperty.property = 'chooseForm')
302         and fieldproperty.deleteflg = '0'
303         left join formbase 
304         on
305             formfield.formid = formbase.formid 
306         and formfield.tenantid = formbase.tenantid
307         where
308             formfield.formid = #{formID} and
309             formfield.tenantid = #{tenantID} and
310             formfield.deleteflg = '0'
311         order by formfield.fieldordernum
312     </select>
313     
314     <select id="getFormFieldMain" resultType="cn.autoform.db.entity.FormFieldEntity">
315         SELECT
316             formfield.formid AS formid,
317             formfield.tenantid AS tenantid,
318             formfield.columnordernum AS columnordernum,
319             CASE
320         WHEN fieldproperty.
321         VALUE
322             = 'password' THEN
323                 'password'
324             ELSE
325                 formfield.fieldtype
326             END AS fieldtype,
327             formfield.parentsubformnum AS parentsubformnum,
328             formfield.fieldordernum AS fieldordernum,
329             formfield.fieldkey AS fieldkey,
330             fieldproperty.
331         VALUE
332             AS
333         VALUE
334         
335         FROM
336             formfield
337         LEFT JOIN fieldproperty ON formfield.formid = fieldproperty.formid
338         AND formfield.tenantid = fieldproperty.tenantid
339         AND formfield.columnordernum = fieldproperty.columnordernum
340         AND (
341             fieldproperty.property = 'datatype'
342             OR fieldproperty.property = 'format'
343         )
344         AND fieldproperty.deleteflg = '0'
345         WHERE
346             formfield.formid = #{formID}
347         AND formfield.tenantid = #{tenantID}
348         AND formfield.deleteflg = '0'
349         AND formfield.FIELDTYPE != 'subform'
350         AND formfield.PARENTSUBFORMNUM = 0
351         ORDER BY
352             formfield.fieldordernum
353     </select>
354     
355     <select id="queryFormFieldsAboutData" resultType="cn.autoform.db.entity.FieldPropertyEntity">
356         SELECT
357             PROPERTY,
358             VALUE
359         FROM
360             FIELDPROPERTY
361         WHERE
362             FIELDPROPERTY.FORMID = #{formID} AND
363             FIELDPROPERTY.TENANTID = #{tenantID} AND
364             FIELDPROPERTY.COLUMNORDERNUM = #{columnOrderNum} AND
365             FIELDPROPERTY.PROPERTY IN ('datasourcetype','custom','datasource','masterData','apiUrl','textcolumn','valuecolumn','namecolumn','apiIdKey','apiPIdKey') AND
366             FIELDPROPERTY.DELETEFLG = '0'
367     </select>
368     
369     <update id = "updateFormFieldState" parameterType="cn.autoform.db.entity.FormFieldEntity">
370         UPDATE 
371             FORMFIELD
372         SET 
373             FIELDISSHOW = #{fieldIsShow}
374         WHERE
375             FORMID = #{formID} AND
376             TENANTID = #{tenantID} AND
377             FIELDKEY = #{fieldKey}
378     </update>
379     
380     <update id = "updateMainFormFieldService" parameterType="cn.autoform.db.entity.FormFieldEntity">
381         UPDATE 
382             FORMFIELD
383         SET 
384             SEARCHISSHOW = #{searchIsShow}
385         WHERE
386             FORMID = #{formID} AND
387             TENANTID = #{tenantID} AND
388             FIELDKEY = #{fieldKey}
389     </update>
390     
391     <select id="queryMaxOrderNum" resultType="java.lang.Integer">
392         SELECT
393             MAX(columnOrderNum) AS MAXNUM
394         FROM
395             FORMFIELD
396         WHERE
397             FORMID = #{formID} AND
398             TENANTID = #{tenantID} AND
399             DELETEFLG = '0'
400         ORDER BY FIELDORDERNUM
401     </select>
402     
403     <select id="queryFormdataMangers" resultType="cn.autoform.db.entity.FormDataMangerEntity">
404         SELECT
405             FORMID,
406             TENANTID,
407             FORMDATANUM,
408             FORMDATATABLE,
409             DATAROWNUM
410         FROM
411             FORMDATAMANAGER
412         WHERE
413             FORMID = #{formID} AND
414             TENANTID = #{tenantID} AND
415             DELETEFLG = '0'
416         ORDER BY FORMDATANUM
417     </select>
418     
419     <select id="queryFormdataMangers1" resultType="cn.autoform.db.entity.FormDataMangerEntity">
420         SELECT
421             FORMID,
422             TENANTID,
423             FORMDATANUM,
424             FORMDATATABLE,
425             DATAROWNUM
426         FROM
427             FORMDATAMANAGER
428         WHERE
429             FORMID = #{formID} AND
430             TENANTID = #{tenantID} AND
431             FORMDATANUM = #{formdataNum} AND
432             DELETEFLG = '0'
433         ORDER BY FORMDATANUM
434     </select>
435     
436     
437     <select id="queryFormdatas" resultType="java.util.HashMap">
438             ${executesql}
439     </select>
440     
441     <select id="queryFormdataCount" resultType="java.lang.Integer">
442         ${executesql}
443     </select>
444     
445     <select id="queryFormFields2" resultType="cn.autoform.db.entity.FormFieldEntity">
446         SELECT
447             FORMFIELD.FORMID,
448             FORMFIELD.TENANTID,
449             FORMFIELD.COLUMNORDERNUM,
450             FORMFIELD.FIELDTYPE,
451             FORMFIELD.PARENTSUBFORMNUM,
452             FORMFIELD.FIELDORDERNUM,
453             FORMFIELD.FIELDKEY
454         FROM
455             FORMFIELD
456         WHERE
457             FORMFIELD.FORMID = #{formID} AND
458             FORMFIELD.TENANTID = #{tenantID} AND
459             FORMFIELD.DELETEFLG = '0'
460         ORDER BY FORMFIELD.FIELDORDERNUM
461     </select>
462     
463     <select id="queryFormFields3" resultType="cn.autoform.db.entity.FormFieldEntity">        
464         SELECT
465             FORMFIELD.FORMID,
466             FORMFIELD.TENANTID,
467             FORMFIELD.COLUMNORDERNUM,
468             FORMFIELD.FIELDTYPE,
469             FORMFIELD.PARENTSUBFORMNUM,
470             FORMFIELD.FIELDORDERNUM,
471             FORMFIELD.FIELDKEY
472         FROM
473             FORMFIELD
474         WHERE
475             FORMFIELD.FORMID = #{formID} AND
476             FORMFIELD.TENANTID = #{tenantID} AND
477             FORMFIELD.DELETEFLG = '0'
478         ORDER BY FORMFIELD.FIELDORDERNUM
479     </select>
480     
481     <select id="queryFormdataManagers2" resultType="cn.autoform.db.entity.FormDataMangerEntity">
482         SELECT
483             FORMID,
484             TENANTID,
485             FORMDATANUM,
486             FORMDATATABLE,
487             SUBFORMFLG,
488             SUBFORMFIELDKEY,
489             DATAROWNUM
490         FROM
491             FORMDATAMANAGER
492         WHERE
493             FORMID = #{formID} AND
494             TENANTID = #{tenantID} AND
495             DELETEFLG = '0'
496     </select>
497     
498     <select id="queryFormdataManagersFor" resultType="cn.autoform.db.entity.FormDataMangerEntity">
499         SELECT
500             FORMID,
501             TENANTID,
502             FORMDATANUM,
503             FORMDATATABLE,
504             SUBFORMFLG,
505             SUBFORMFIELDKEY,
506             DATAROWNUM
507         FROM
508             FORMDATAMANAGER
509         WHERE
510             FORMID = #{formID} AND
511             TENANTID = #{tenantID} AND
512             FORMDATANUM = 0 AND
513             DELETEFLG = '0'
514         FOR UPDATE
515     </select>
516     
517     <update id = "updateFormdataManagersFor" parameterType="cn.autoform.db.entity.FormdataManagerEntity">
518         UPDATE 
519             FORMDATAMANAGER
520         SET 
521             DATAROWNUM = #{datarowNum}
522         WHERE
523             FORMID = #{formID} AND
524             TENANTID = #{tenantID} AND
525             FORMDATANUM = 0 AND
526             DELETEFLG = '0'
527     </update>
528     
529     <insert id="excuteFormDataInsert">
530         ${excuteSql}
531     </insert>
532     
533     <update id="removeFormData">
534         ${excuteSql}
535     </update>
536     
537     <update id="updateFormData">
538         ${excuteSql}
539     </update>
540     
541     <select id="queryFormdataManagers3" resultType="cn.autoform.db.entity.FormDataMangerEntity">
542         SELECT
543             FORMID,
544             TENANTID,
545             FORMDATANUM,
546             FORMDATATABLE,
547             SUBFORMFLG,
548             SUBFORMFIELDKEY,
549             DATAROWNUM
550         FROM
551             FORMDATAMANAGER
552         WHERE
553             FORMID = #{formID} AND
554             TENANTID = #{tenantID} AND
555             FORMDATANUM = #{formdataNum} AND
556             DELETEFLG = '0'
557     </select>
558             
559     <update id="addFormStateData" parameterType="String">
560     /*!mycat:sql=select tenantid from FORMDATAMANAGER WHERE TENANTID = '%s' AND FROMID = '%s' */        
561         UPDATE 
562             FORMDATA_${formState.tenantID}_${formState.formID} 
563         SET 
564             FORMSTATE = #{formState.formStateData} 
565         WHERE  
566             TENANTID = #{formState.tenantID}     
567     </update> 
568     
569     <select id="queryFormFiled" resultType = "java.util.Map">
570         SELECT
571             formfield.PARENTSUBFORMNUM,
572             formfield.FIELDKEY,
573             formfield.FIELDTYPE,
574             fieldproperty.`VALUE` title
575         FROM
576             formfield
577         LEFT JOIN 
578             fieldproperty 
579         ON formfield.FORMID = fieldproperty.FORMID
580         AND formfield.TENANTID = fieldproperty.TENANTID
581         AND formfield.COLUMNORDERNUM = fieldproperty.COLUMNORDERNUM
582         AND fieldproperty.PROPERTY = 'title'
583         AND fieldproperty.DELETEFLG = '0'
584         WHERE
585             formfield.FORMID = '${formID}'
586         AND formfield.TENANTID = '${tenantID}'
587         AND formfield.DELETEFLG = '0'
588         AND formfield.FIELDTYPE != 'subform'
589         AND formfield.FIELDKEY != 'DATAROWNUM'
590         AND formfield.FIELDTYPE != 'mytext'
591     </select>
592     
593     <select id="queryFormFields4" resultType="cn.autoform.db.entity.FormFieldEntity">        
594         select
595             formfield.formid as formid,
596             formfield.tenantid as tenantid,
597             formfield.columnordernum as columnordernum,
598             case when fieldproperty.value = 'password' then 'password' else formfield.fieldtype end as fieldtype,
599             formfield.parentsubformnum as parentsubformnum,
600             formfield.fieldordernum as fieldordernum,
601             formfield.fieldkey as fieldkey,
602             fieldproperty.value as value,
603             formbase.fieldset
604         from
605             formfield
606         left join fieldproperty
607         on
608                formfield.formid = fieldproperty.formid
609         and formfield.tenantid = fieldproperty.tenantid
610         and formfield.columnordernum = fieldproperty.columnordernum
611         and (fieldproperty.property = 'datatype' or fieldproperty.property = 'format' or fieldproperty.property = 'chooseForm')
612         and fieldproperty.deleteflg = '0'
613         left join formbase 
614         on
615             formfield.formid = formbase.formid 
616         and formfield.tenantid = formbase.tenantid
617         where
618             formfield.formid = #{formID} and
619             formfield.tenantid = #{tenantID} and
620             formfield.deleteflg = '0'
621         limit 1
622     </select>
623 </mapper>