ludc
2023-05-05 4cd535de8ef099afa96238e5458e6866edccfea7
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
284
package com.vci.ubcs.starter.web.wrapper;
 
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
//package com.vci.starter.web.wrapper;
 
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.stream.Collectors;
 
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.web.annotation.VciFieldType;
import com.vci.ubcs.starter.web.annotation.VciUseEnum;
import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.ubcs.starter.web.pagemodel.PageHelper;
import com.vci.ubcs.starter.web.service.VciSecretServiceI;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import org.springframework.util.CollectionUtils;
 
import javax.xml.bind.annotation.XmlType;
 
public class VciQueryWrapperForDO implements VciSecretServiceI {
    public static boolean USER_TABLE_COMPATIBILITY = false;
    public static String DATABASE_PLATFORM;
    public static Map<String, String> USER_TABLE_COMPATIBILITY_BTM_MAP;
    public static Map<String, String> USER_TABLE_COMPATIBILITY_FIELD_MAP;
    public static final String USER_TABLE_COMPATIBILITY_FIELD_SEP = "${vcicomplibitysep}";
    private Map<String, String> conditionMap;
    private Map<String, String> customerSqlMap;
    private String oidFieldName;
    private static final String SPACE = " ";
    public static final String QUERY_FIELD_SECRET = "${vciQuerySecret}";
    public static final String QUERY_FIELD_DATARIGHT = "${vciQueryDataRight}";
    private Class<?> doClass;
    private PageHelper pageHelper;
    private Map<String, String> allFieldNameMap;
    private List<String> xmlTypeFieldList;
    private boolean distinct;
    public static final String OID_FIELD = "oid";
    public static final String ID_FIELD = "id";
    public static final String LC_STATUS_FIELD = "lcstatus";
    public static final String LC_STATUS_FIELD_TEXT = "lcStatus_text";
    private Map<String, VciFieldTypeEnum> allFieldTypeMap;
    private Map<String, String> useReferMap;
    private Map<String, String> enumFieldMap;
    private String linkTableSql;
    private String selectFieldSql;
    private String selectPrefixForPage;
    private String whereSql;
    private String orderSql;
    private String whereSubfixForPage;
    private Map<String, String> valuesMap;
    private String tableNick;
    private Map<String, String> extendFieldMap;
    private static final String DATETIME_FORMAT = "yyyy-mm-dd hh24:mi:ss";
    private static final String DATE_FORMAT = "yyyy-mm-dd";
 
    public void clearPage() {
        this.pageHelper = null;
        this.selectPrefixForPage = "";
        this.whereSubfixForPage = "";
    }
 
    public VciQueryWrapperForDO in(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, "\\IN");
        return this;
    }
 
    public VciQueryWrapperForDO notIn(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, "\\NOTIN");
        return this;
    }
 
    public VciQueryWrapperForDO eq(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value);
        return this;
    }
 
    public VciQueryWrapperForDO neq(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, "!=");
        return this;
    }
 
    public VciQueryWrapperForDO less(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, "<");
        return this;
    }
 
    public VciQueryWrapperForDO lessThan(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, "<=");
        return this;
    }
 
    public VciQueryWrapperForDO more(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, ">");
        return this;
    }
 
    public VciQueryWrapperForDO moreThan(String key, String value) throws VciBaseException {
        this.addQueryMap(key, value, ">=");
        return this;
    }
 
    public VciQueryWrapperForDO isNull(String key) throws VciBaseException {
        this.addQueryMap(key, "_n", "=null");
        return this;
    }
 
    public VciQueryWrapperForDO isNotNull(String key) throws VciBaseException {
        this.addQueryMap(key, "_n", "!=null");
        return this;
    }
 
    public VciQueryWrapperForDO secret() throws VciBaseException {
        String secretSql = this.getLessThanUserSecretSql();
        this.addQueryMap("secretGrade", secretSql, "<=");
        return this;
    }
 
    public void addQueryMap(String key, String value) {
        this.addQueryMap(key, value, (String)null);
    }
 
    public void addQueryMap(String key, String value, String operation) {
        VciBaseUtil.alertNotNull(new Object[]{key, "查询条件的名称"});
        if (StringUtils.isNotBlank(value)) {
            if (this.conditionMap == null) {
                this.conditionMap = new HashMap();
            }
 
            if (operation == null) {
                operation = "";
            }
 
            this.conditionMap.put(key, operation + value);
        }
 
    }
 
    public void addCustomSql(String key, String sql) {
        VciBaseUtil.alertNotNull(new Object[]{key, "自定义SQL的KEY", sql, "自定义的SQL语句"});
        if (StringUtils.isNotBlank(sql)) {
            if (this.customerSqlMap == null) {
                this.customerSqlMap = new HashMap();
            }
 
            this.customerSqlMap.put(key, sql);
        }
 
    }
 
    public void addExtendField(String fieldName) {
        this.addExtendField(fieldName, fieldName);
    }
 
    public void addExtendField(String fieldName, String nickName) {
        this.extendFieldMap.put(fieldName, nickName);
    }
 
    public Map<String, String> getConditionMap() {
        return this.conditionMap;
    }
 
    public void setConditionMap(Map<String, String> conditionMap) {
        this.conditionMap = conditionMap;
    }
 
    public Map<String, String> switchConditionMap() {
        Map<String, String> queryMap = new HashMap();
        if (!CollectionUtils.isEmpty(this.conditionMap)) {
            this.conditionMap.forEach((key, value) -> {
                queryMap.put(key, value);
            });
            this.allFieldNameMap.forEach((dbField, field) -> {
                if (this.conditionMap.containsKey(field)) {
                    queryMap.put(dbField, this.conditionMap.get(field));
                }
 
            });
        }
 
        return queryMap;
    }
 
    public String getLinkTableSql() {
        return this.linkTableSql;
    }
 
    public void setLinkTableSql(String linkTableSql) {
        this.linkTableSql = linkTableSql;
    }
 
    public void addLinkTableSql(String linkTableSql) {
        this.linkTableSql = this.linkTableSql + " " + linkTableSql + " ";
    }
 
    public void setSelectFieldSql(String selectFieldSql) {
        this.selectFieldSql = selectFieldSql;
    }
 
    public void appendSelectField(String sql) {
        this.selectFieldSql = this.selectFieldSql + "," + sql;
    }
 
    public void appendSelectPagePrefix(String sql) {
        this.selectPrefixForPage = this.selectPrefixForPage + "," + sql;
    }
 
    public String getWhereSql() {
        if (StringUtils.isBlank(this.whereSql)) {
            this.whereSql = " 1 = 1 ";
        }
 
        return this.pageHelper != null && this.pageHelper.getLimit() > 0 ? this.whereSql + (this.orderSql == null ? "" : this.orderSql) + (this.whereSubfixForPage == null ? "" : this.whereSubfixForPage) : (StringUtils.isNotBlank(this.whereSql) ? this.whereSql : " 1= 1 ") + (this.orderSql == null ? "" : this.orderSql);
    }
 
    public void setWhereSql(String whereSql) {
        this.whereSql = whereSql;
    }
 
    public Map<String, String> getValuesMap() {
        return this.valuesMap;
    }
 
    public void setValuesMap(Map<String, String> valuesMap) {
        this.valuesMap = valuesMap;
    }
 
    public String getTableNick() {
        return this.tableNick;
    }
 
    public void setTableNick(String tableNick) {
        this.tableNick = tableNick;
    }
 
    public String getOrderSql() {
        return this.orderSql;
    }
 
    public void setOrderSql(String orderSql) {
        this.orderSql = orderSql;
    }
 
    public String getOidFieldName() {
        return this.oidFieldName;
    }
 
    public void setOidFieldName(String oidFieldName) {
        this.oidFieldName = oidFieldName;
    }
 
    public boolean isDistinct() {
        return this.distinct;
    }
 
    public void setDistinct(boolean distinct) {
        this.distinct = distinct;
    }
 
    public Map<String, String> getCustomerSqlMap() {
        return this.customerSqlMap;
    }
 
    public void setCustomerSqlMap(Map<String, String> customerSqlMap) {
        this.customerSqlMap = customerSqlMap;
    }
 
}