shichongfu
2023-04-25 ce0b49552668d3331055e2b1a1447a743dc54939
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
package com.product.org.admin.service;
 
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.product.admin.service.OrganizationCacheService;
import com.product.common.collect.SetUtils;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.entity.SystemUser;
import com.product.org.admin.config.CmnConst;
import com.product.org.admin.config.SystemCode;
import com.product.org.admin.service.idel.IOrganizationService;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.List;
import java.util.Map;
import java.util.Set;
 
/**
 * Copyright © 6c
 *
 * @Date: 2021-03-18 14:45
 * @Author: 6c
 * @Description:
 */
@Component
public class OrganizationService extends AbstractBaseService implements IOrganizationService {
    @Autowired
    public BaseDao baseDao;
 
    /**
     * 获取组织架构
     *
     * @param fse 传入的fse参数
     * @return JSONArray
     */
    @Override
    public JSONArray getOrganization(FieldSetEntity fse) {
        boolean showCurUserFlag = "1".equals(fse.getString("is_show_cur_user_info"));
 
        Integer typeValue = fse.getInteger("type");
        int type;
        if (typeValue != null) {
            type = typeValue;
        } else {
            throw new BaseException(SystemCode.SYSTEM_ACQUIRE_PARAM_FAIL.getValue(), SystemCode.SYSTEM_ACQUIRE_PARAM_FAIL.getText() + ":organization-type");
        }
        Map<String, Map<String, FieldSetEntity>> resultMap = Maps.newLinkedHashMap();
        perfectData(fse, type, showCurUserFlag);
        getOrganizationInfo(resultMap, fse, type);
 
        DataTableEntity aimDte = new DataTableEntity();
        dealSpMap2Dte(aimDte, resultMap, CmnConst.COMPANYS);
        dealSpMap2Dte(aimDte, resultMap, CmnConst.DEPTS);
        dealSpMap2Dte(aimDte, resultMap, CmnConst.POSTS);
        dealSpMap2Dte(aimDte, resultMap, CmnConst.STAFFS);
 
        return BaseUtil.dataTableToTreeData(aimDte, "sid", "pid", null, false);
    }
 
    /**
     * 完善数据-自下而上
     *
     * @param fse  参数fse
     * @param type 类型:1-公司,2-公司-部门,3-公司-部门-岗位,4-公司-部门-岗位-人员,5-公司-部门-人员
     */
    private void perfectData(FieldSetEntity fse, int type, boolean showCurUserFlag) {
        SystemUser curUser = SpringMVCContextHolder.getCurrentUser();
        String curUUID;
        Set<String> perfectCompanySet = Sets.newHashSet();
        Set<String> perfectDeptSet = Sets.newHashSet();
        Set<String> perfectPostSet = Sets.newHashSet();
 
        String companyUUIDs = fse.getString("org_level_uuids");
        Set<String> companyUUIDSet = SetUtils.string2Set(companyUUIDs, ",");
        String deptUUIDs = fse.getString("dept_uuids");
        Set<String> deptUUIDSet = SetUtils.string2Set(deptUUIDs, ",");
        String postUUIDs = fse.getString("post_uuids");
        Set<String> postUUIDSet = SetUtils.string2Set(postUUIDs, ",");
        String userIDs = fse.getString("user_ids");
        Set<String> userIDSet = SetUtils.string2Set(userIDs, ",");
 
        if (showCurUserFlag) {
            curUUID = curUser.getOrg_level_uuid();
            if (!StringUtils.isEmpty(curUUID) && !companyUUIDSet.contains(curUUID)) {
                companyUUIDSet.add(curUUID);
                perfectCompanySet.add(curUUID);
            }
 
            curUUID = curUser.getDept_uuid();
            if (!StringUtils.isEmpty(curUUID) && !deptUUIDSet.contains(curUUID)) {
                deptUUIDSet.add(curUUID);
                perfectDeptSet.add(curUUID);
            }
 
 
            curUUID = curUser.getPost();
            if (!StringUtils.isEmpty(curUUID) && !postUUIDSet.contains(curUUID)) {
                postUUIDSet.add(curUUID);
                perfectPostSet.add(curUUID);
            }
 
            int userID = curUser.getUser_id();
            curUUID = userID > 0 ? String.valueOf(userID) : "";
            if (!StringUtils.isEmpty(curUUID) && !postUUIDSet.contains(curUUID)) {
                userIDSet.add(curUUID);
            }
        }
 
        if (type == 5) {
            // 公司-部门-人员
            perfectDeptSet.addAll(perfectData(deptUUIDSet, userIDSet, "部门-人员", "dept_uuid"));
            fse.setValue("perfect_dept", perfectDeptSet);
        }
        if (type == 4) {
            // 公司-部门-岗位-人员
            perfectPostSet.addAll(perfectData(postUUIDSet, userIDSet, "岗位-人员", "job_post_uuid"));
            fse.setValue("perfect_post", perfectPostSet);
        }
        if (type >= 3) {
            // 公司-部门-岗位
            perfectDeptSet.addAll(perfectData(deptUUIDSet, postUUIDSet, "部门-岗位", "dept_uuid"));
            fse.setValue("perfect_dept", perfectDeptSet);
        }
        if (type >= 2) {
            // 公司-部门
            perfectCompanySet.addAll(perfectData(companyUUIDSet, deptUUIDSet, "公司-部门", "org_level_uuid"));
            fse.setValue("perfect_company", perfectCompanySet);
        }
 
        fse.setValue("org_level_uuids", SetUtils.set2String(companyUUIDSet, ","));
        fse.setValue("dept_uuids", SetUtils.set2String(deptUUIDSet, ","));
        fse.setValue("post_uuids", SetUtils.set2String(postUUIDSet, ","));
        fse.setValue("user_ids", SetUtils.set2String(userIDSet, ","));
    }
 
    /**
     * 完善数据-自下而上-通用
     *
     * @param parentSet       父类UUIDSet
     * @param childSet        子类UUIDSet
     * @param cacheName       缓存名称
     * @param parentFieldName 子类关联父类字段
     */
    private Set<String> perfectData(Set<String> parentSet, Set<String> childSet, String cacheName, String parentFieldName) {
        DataTableEntity tempDte = DataPoolCacheImpl.getInstance().getCacheData(cacheName);
        if ("部门-人员".equals(cacheName) || "岗位-人员".equals(cacheName)) {
            tempDte = OrganizationCacheService.getUserData();
        } else if ("部门-岗位".equals(cacheName)) {
            tempDte = OrganizationCacheService.getPostData();
        } else if ("公司-部门".equals(cacheName)) {
            tempDte = OrganizationCacheService.getOrgData("2");
        }
        FieldSetEntity tempFse;
        String parentUUID;
        Set<String> perfectSet = Sets.newHashSet();
        for (int i = 0; i < tempDte.getRows(); i++) {
            tempFse = tempDte.getFieldSetEntity(i);
            if (childSet.contains(tempFse.getUUID())) {
                parentUUID = tempFse.getString(parentFieldName);
                if (!parentSet.contains(parentUUID)) {
                    parentSet.add(parentUUID);
                    perfectSet.add(parentUUID);
                }
            }
        }
        return perfectSet;
    }
 
    /**
     * 获取组织架构信息
     *
     * @param resultMap 结果map
     * @param fse       参数fse
     * @param type      类型:1-公司,2-公司-部门,3-公司-部门-岗位,4-公司-部门-岗位-人员,5-公司-部门-人员
     */
    public DataTableEntity getOrganizationInfo(Map<String, Map<String, FieldSetEntity>> resultMap, FieldSetEntity fse, int type) {
        String companyUUIDs = fse.getString("org_level_uuids");
        String deptUUIDs = fse.getString("dept_uuids");
        String postUUIDs = fse.getString("post_uuids");
        String userIDs = fse.getString("user_ids");
        Set<String> perfectCompanySet = fse.getValue("perfect_company") == null ? null : (Set<String>) fse.getValue("perfect_company");
        Set<String> perfectDeptSet = fse.getValue("perfect_dept") == null ? null : (Set<String>) fse.getValue("perfect_dept");
        Set<String> perfectPostSet = fse.getValue("perfect_post") == null ? null : (Set<String>) fse.getValue("perfect_post");
        DataTableEntity dte = new DataTableEntity();
        boolean isAll = StringUtils.isEmpty(companyUUIDs) && StringUtils.isEmpty(deptUUIDs) && StringUtils.isEmpty(postUUIDs) && StringUtils.isEmpty(userIDs);
        if (type == 1) {
            // 公司
            dte = getCompany(resultMap, companyUUIDs, isAll);
        } else if (type == 2) {
            // 公司-部门
            dte = getDept(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, isAll);
        } else if (type == 3) {
            // 公司-部门-岗位
            dte = getPost(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, perfectDeptSet, postUUIDs, isAll);
        } else if (type == 4) {
            // 公司-部门-岗位-人员
            dte = getStaff(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, perfectDeptSet, postUUIDs, perfectPostSet, userIDs, isAll);
        } else if (type == 5) {
            // 公司-部门-人员
            dte = getStaff(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, perfectDeptSet, userIDs, isAll);
        }
        return dte;
    }
 
    /**
     * 公司
     *
     * @param resultMap 结果map
     * @param uuids     指定的公司uuids
     * @param isAll     是否全部
     * @return
     */
    private DataTableEntity getCompany(Map<String, Map<String, FieldSetEntity>> resultMap, String uuids, boolean isAll) {
        SystemUser curUser = SpringMVCContextHolder.getCurrentUser();
        String curClientUUID;
        if (curUser.getUserType() == 1) {
            // 超管,看所有客户
            DataTableEntity clientDte = DataPoolCacheImpl.getInstance().getCacheData("客户信息");
            curClientUUID = clientDte.getUuidsToString();
            isAll = true;
        } else {
            curClientUUID = curUser.getClient_uuid();
            if (curUser.getUserType() == 4) {
                if (!StringUtils.isEmpty(curClientUUID)) {
                    curClientUUID += ",";
                }
                curClientUUID += curUser.getClientUuid() == null ? "" : curUser.getClientUuid();
            }
        }
 
        String aimUUIDs = uuids;
 
        DataTableEntity companyDte = DataPoolCacheImpl.getInstance().getCacheData("所有公司信息");
        DataTableEntity aimDte = new DataTableEntity();
 
        Map<String, String> showFieldMap = Maps.newHashMap();
        showFieldMap.put("value", "uuid");
        showFieldMap.put("label", "org_level_name");
        showFieldMap.put("pid", "org_level_code_parent");
        showFieldMap.put("sid", "org_level_code");
        List<String> list = Lists.newArrayList();
 
        FieldSetEntity tempFse;
        Map<String, FieldSetEntity> companyMap = resultMap.computeIfAbsent(CmnConst.COMPANYS, k -> Maps.newLinkedHashMap());
        for (int i = 0; i < companyDte.getRows(); i++) {
            tempFse = companyDte.getFieldSetEntity(i);
            if ((
                    (
                            (
                                    !isAll && StringUtils.headAndTailJointAimSign(aimUUIDs, ",").contains(StringUtils.headAndTailJointAimSign(tempFse.getUUID(), ","))
                            ) || isAll
                    ) && StringUtils.headAndTailJointAimSign(curClientUUID, ",").contains(StringUtils.headAndTailJointAimSign(tempFse.getString(CmnConst.CLIENT_UUID), ","))
            ) || checkIsSub(list, tempFse.getString("org_level_code_parent"))) {
                list.add(tempFse.getString("org_level_code"));
                tempFse = spDeal(tempFse, showFieldMap, 1);
                aimDte.addFieldSetEntity(tempFse);
                companyMap.put(tempFse.getString("value"), tempFse);
            }
        }
        return aimDte;
    }
 
    /**
     * 提取map中的数据转换为dte
     *
     * @param dte
     * @param map
     * @param sign
     */
    private void dealSpMap2Dte(DataTableEntity dte, Map<String, Map<String, FieldSetEntity>> map, String sign) {
        Map<String, FieldSetEntity> sourceMap = map.get(sign);
        if (sourceMap == null) {
            return;
        }
        sourceMap.forEach((k, v) -> {
            dte.addFieldSetEntity(v);
        });
    }
 
    /**
     * 公司-部门
     *
     * @param resultMap         结果map
     * @param companyUUIDs      指定的公司uuids
     * @param perfectCompanySet 完善公司的uuid集合
     * @param deptUUIDs         指定的部门uuids
     * @param iaAll             是否全部
     * @return
     */
    private DataTableEntity getDept(Map<String, Map<String, FieldSetEntity>> resultMap, String companyUUIDs, Set<String> perfectCompanySet, String deptUUIDs, boolean iaAll) {
        DataTableEntity companyDte = getCompany(resultMap, companyUUIDs, iaAll);
 
        Map<String, String> showFieldMap = Maps.newHashMap();
        showFieldMap.put("value", "uuid");
        showFieldMap.put("label", "org_level_name");
        showFieldMap.put("pid", "org_level_code_parent");
        showFieldMap.put("sid", "org_level_code");
 
        return getOrganization(resultMap, CmnConst.DEPTS, companyDte, deptUUIDs, perfectCompanySet, "公司-部门", showFieldMap, true, 2);
    }
 
    /**
     * 公司-部门-岗位
     *
     * @param resultMap         结果map
     * @param companyUUIDs      指定的公司uuids
     * @param perfectCompanySet 完善公司的uuid集合
     * @param deptUUIDs         指定的部门uuids
     * @param perfectDeptSet    完善部门的uuid集合
     * @param postUUIDs         指定的岗位uuids
     * @param iaAll             是否全部
     * @return
     */
    private DataTableEntity getPost(Map<String, Map<String, FieldSetEntity>> resultMap, String companyUUIDs, Set<String> perfectCompanySet, String deptUUIDs, Set<String> perfectDeptSet, String postUUIDs, boolean iaAll) {
        DataTableEntity deptDte = getDept(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, iaAll);
 
        Map<String, String> showFieldMap = Maps.newHashMap();
        showFieldMap.put("value", "uuid");
        showFieldMap.put("label", "job_post_name");
        showFieldMap.put("pid", "org_level_code");
        showFieldMap.put("sid", "uuid");
 
        return getOrganization(resultMap, CmnConst.POSTS, deptDte, postUUIDs, perfectDeptSet, "部门-岗位", showFieldMap, 3);
    }
 
    /**
     * 公司-部门-岗位-人员
     *
     * @param resultMap         结果map
     * @param companyUUIDs      指定的公司uuids
     * @param perfectCompanySet 完善公司的uuid集合
     * @param deptUUIDs         指定的部门uuids
     * @param perfectDeptSet    完善部门的uuid集合
     * @param postUUIDs         指定的岗位uuids
     * @param perfectPostSet    完善岗位的uuid集合
     * @param userIDs           指定的人员id
     * @param iaAll             是否全部
     * @return
     */
    private DataTableEntity getStaff(Map<String, Map<String, FieldSetEntity>> resultMap, String companyUUIDs, Set<String> perfectCompanySet, String deptUUIDs, Set<String> perfectDeptSet,
                                     String postUUIDs, Set<String> perfectPostSet, String userIDs, boolean iaAll) {
        DataTableEntity postDte = getPost(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, perfectDeptSet, postUUIDs, iaAll);
 
        Map<String, String> showFieldMap = Maps.newHashMap();
        showFieldMap.put("value", "uuid");
        showFieldMap.put("label", "show_name");
        showFieldMap.put("pid", "job_post_uuid");
 
        return getOrganization(resultMap, CmnConst.STAFFS, postDte, userIDs, perfectPostSet, "岗位-人员", showFieldMap, 4);
    }
 
    /**
     * 公司-部门-人员
     *
     * @param resultMap         结果map
     * @param companyUUIDs      指定的公司uuids
     * @param perfectCompanySet 完善公司的uuid集合
     * @param deptUUIDs         指定的部门uuids
     * @param perfectDeptSet    完善部门的uuid集合
     * @param userIDs           指定的人员id
     * @param iaAll             是否全部
     * @return
     */
    private DataTableEntity getStaff(Map<String, Map<String, FieldSetEntity>> resultMap, String companyUUIDs, Set<String> perfectCompanySet, String deptUUIDs, Set<String> perfectDeptSet, String userIDs, boolean iaAll) {
        DataTableEntity deptDte = getDept(resultMap, companyUUIDs, perfectCompanySet, deptUUIDs, iaAll);
 
        Map<String, String> showFieldMap = Maps.newHashMap();
        showFieldMap.put("value", "user_id");
        showFieldMap.put("label", "user_name");
        showFieldMap.put("pid", "org_level_code");
 
        return getOrganization(resultMap, CmnConst.STAFFS, deptDte, userIDs, perfectDeptSet, "部门-人员", showFieldMap, 4);
    }
 
    /**
     * 获取组织架构-通用
     *
     * @param parentDte        父类数据集合
     * @param uuids            允许查看的uuids,逗号分割
     * @param parentPerfectSet 完善的父类uuid集合
     * @param cacheName        缓存名称
     * @param showFieldMap     展示的字段,原名=别名
     * @param existsLeader     是否存在上下级关系,目前仅用于公司部门表
     * @param type             1-公司,2-部门,3-岗位,4-人员
     * @return
     */
    private DataTableEntity getOrganization(Map<String, Map<String, FieldSetEntity>> resultMap, String sign, DataTableEntity parentDte, String uuids, Set<String> parentPerfectSet, String cacheName,
                                            Map<String, String> showFieldMap, boolean existsLeader, int type) {
        String aimUUIDs = uuids;
 
        DataTableEntity aimDte = new DataTableEntity();
        aimDte.addFieldSetEntity(parentDte);
 
 
        FieldSetEntity parentFse;
        DataTableEntity childDte;
        FieldSetEntity childFse;
        List<String> list = Lists.newArrayList();
        String parentFieldName = null;
        String childFieldName = null;
        for (Map.Entry<String, String> entry : showFieldMap.entrySet()) {
            if ("pid".equalsIgnoreCase(entry.getKey())) {
                parentFieldName = entry.getValue();
            }
            if ("sid".equalsIgnoreCase(entry.getKey())) {
                childFieldName = entry.getValue();
            }
        }
        if (StringUtils.isEmpty(parentFieldName) || StringUtils.isEmpty(childFieldName)) {
            existsLeader = false;
        }
 
        Map<String, FieldSetEntity> aimMap = resultMap.computeIfAbsent(sign, k -> Maps.newLinkedHashMap());
        DataTableEntity aimChildDte;
        FieldSetEntity tempFse;
        String parentValue;
        for (int i = 0; i < parentDte.getRows(); i++) {
            parentFse = parentDte.getFieldSetEntity(i);
            parentValue = parentFse.getString("value");
            if ("部门-人员".equals(cacheName)) {
                childDte = OrganizationCacheService.getUserDataByDept(parentValue);
            } else if ("岗位-人员".equals(cacheName)) {
                childDte = OrganizationCacheService.getUserDataByPost(parentValue);
            } else if ("部门-岗位".equals(cacheName)) {
                childDte = OrganizationCacheService.getPostDataByDept(parentValue);
            } else if ("公司-部门".equals(cacheName)) {
                childDte = OrganizationCacheService.getDeptDataByCompany(parentValue);
            } else {
                childDte = DataPoolCacheImpl.getInstance().getCacheData(cacheName, new String[]{parentValue});
            }
 
            if (childDte == null || childDte.getRows() == 0) {
                continue;
            }
            if (!parentPerfectSet.contains(parentValue)) {
                aimChildDte = spDeal(childDte, showFieldMap, type);
            } else {
                aimChildDte = new DataTableEntity();
                for (int j = 0; j < childDte.getRows(); j++) {
                    childFse = childDte.getFieldSetEntity(j);
                    if (StringUtils.headAndTailJointAimSign(aimUUIDs, ",").contains(StringUtils.headAndTailJointAimSign(childFse.getUUID(), ","))
                            || (existsLeader && checkIsSub(list, childFse.getString(parentFieldName)))) {
                        list.add(childFse.getString(childFieldName));
                        aimChildDte.addFieldSetEntity(spDeal(childFse, showFieldMap, type));
                    }
                }
            }
            aimDte.addFieldSetEntity(aimChildDte);
            for (int j = 0; j < aimChildDte.getRows(); j++) {
                tempFse = aimChildDte.getFieldSetEntity(j);
                aimMap.put(tempFse.getString("value"), tempFse);
            }
        }
        return aimDte;
    }
 
    private DataTableEntity getOrganization(Map<String, Map<String, FieldSetEntity>> resultMap, String sign, DataTableEntity parentDte, String uuids, Set<String> parentPerfectSet, String cacheName, Map<String, String> showFieldMap, int type) {
        return getOrganization(resultMap, sign, parentDte, uuids, parentPerfectSet, cacheName, showFieldMap, false, type);
    }
 
    /**
     * 筛选并替换指定字段名称-fse
     *
     * @param fse
     * @param showFieldMap
     * @param type
     * @return
     */
    private FieldSetEntity spDeal(FieldSetEntity fse, Map<String, String> showFieldMap, int type) {
        FieldSetEntity aimFse = new FieldSetEntity();
        aimFse.setTableName(fse.getTableName());
        String fieldName;
        String replaceFieldName;
        for (Map.Entry<String, String> entry : showFieldMap.entrySet()) {
            fieldName = entry.getValue();
            replaceFieldName = entry.getKey();
            if (!StringUtils.isEmpty(replaceFieldName)) {
                aimFse.setValue(replaceFieldName, fse.getString(fieldName));
            } else {
                aimFse.setValue(fieldName, fse.getString(fieldName));
            }
            aimFse.setValue("type", type);
        }
        return aimFse;
    }
 
    /**
     * 筛选并替换指定字段名称-dte
     *
     * @param dte
     * @param showFieldMap
     * @return
     */
    private DataTableEntity spDeal(DataTableEntity dte, Map<String, String> showFieldMap, int type) {
        DataTableEntity aimDte = new DataTableEntity();
        if (dte == null || dte.getRows() == 0) {
            return aimDte;
        }
        for (int i = 0; i < dte.getRows(); i++) {
            aimDte.addFieldSetEntity(spDeal(dte.getFieldSetEntity(i), showFieldMap, type));
        }
        return aimDte;
    }
 
    /**
     * 检查是否为子类(目前用于公司部门表)
     *
     * @param list
     * @param content
     * @return
     */
    private boolean checkIsSub(List<String> list, String content) {
        if (StringUtils.isEmpty(content)) {
            return false;
        }
        boolean flag = false;
        for (String str : list) {
            if (content.startsWith(str)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}