zhangherong
2025-05-09 f9a9fb9090c2e9e1a4e00374d48181efe2463a56
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
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
package org.jeecg.modules.system.service.impl;
 
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.FillRuleConstant;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.FillRuleUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper;
import org.jeecg.modules.system.mapper.MdcProductionMapper;
import org.jeecg.modules.system.mapper.MdcUserProductionMapper;
import org.jeecg.modules.system.mapper.SysUserMapper;
import org.jeecg.modules.system.model.MdcProductionTreeModel;
import org.jeecg.modules.system.model.ProductionIdModel;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysDictService;
import org.jeecg.modules.system.service.ISysParamsService;
import org.jeecg.modules.system.util.FindsProductionsChildrenUtil;
import org.jeecg.modules.system.vo.MdcProOptionsVo;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @Description: 产线表
 * @Author: liuS
 * @Date: 2023-03-23
 * @Version: V1.0
 */
@Service
public class MdcProductionServiceImpl extends ServiceImpl<MdcProductionMapper, MdcProduction> implements IMdcProductionService {
 
    @Resource
    private SysUserMapper sysUserMapper;
 
    @Resource
    private MdcUserProductionMapper userProductionMapper;
 
    @Resource
    private MdcProductionEquipmentMapper productionEquipmentMapper;
 
    @Resource
    private ISysParamsService sysParamsService;
 
    @Resource
    private ISysDictService sysDictService;
    /**
     * queryTreeList 对应 queryTreeList 查询所有的产线数据,以树结构形式响应给前端
     */
    @Override
    @Cacheable(value = "mdc:cache:production:alldata")
    public List<MdcProductionTreeModel> queryTreeList() {
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        query.orderByAsc(MdcProduction::getProductionOrder);
        List<MdcProduction> list = this.list(query);
        //设置用户id,让前台显示
        this.setUserIdsByProList(list);
        //调用wrapTreeDataToTreeList方法生成树状数据
        return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
    }
 
    /**
     * 查询所有产线信息,并分节点进行显示(添加系统配置)
     */
    @Override
    public List<MdcProductionTreeModel> queryTreeListByConfig(){
        SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production");
        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        if (sysParams == null) {
            return null;
        }else {
            List<String> productionIds = new ArrayList<>();
            if (!("admin").equals(loginUser.getUsername())) {
                //不是超级管理员,获取用户拥有的产线
                if (loginUser.getProductionIds() != null) {
                    if (loginUser.getProductionIds().contains(",")) {
                        productionIds = Arrays.asList(loginUser.getProductionIds().split(","));
                    } else {
                        productionIds = Collections.singletonList(loginUser.getProductionIds());
                    }
                }
            }
            if (("0").equals(sysParams.getSettingValue())){
                query.eq(MdcProduction::getOrgType,"2");
                query.in(!productionIds.isEmpty(), MdcProduction::getId, productionIds);
                query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
                query.orderByAsc(MdcProduction::getProductionOrder);
                List<MdcProduction> list = this.list(query);
                //设置用户id,让前台显示
                this.setUserIdsByProList(list);
                //封装一级树
                List<MdcProductionTreeModel> listResult = new ArrayList<>();
                for (MdcProduction production : list) {
                    if (production.getDescription().isEmpty()){
                        production.setDescription("");
                    }
                    listResult.add(new MdcProductionTreeModel(production));
                }
                //调用wrapTreeDataToTreeList方法生成树状数据
                return listResult;
            }else {
                query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
                query.orderByAsc(MdcProduction::getProductionOrder);
                List<MdcProduction> list = this.list(query);
                //设置用户id,让前台显示
                this.setUserIdsByProList(list);
                //调用wrapTreeDataToTreeList方法生成树状数据
                return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
            }
        }
    }
 
    /**
     * queryTreeList 根据产线id查询,前端回显调用
     */
    @Override
    public List<MdcProductionTreeModel> queryTreeList(String ids) {
        List<MdcProductionTreeModel> listResult = new ArrayList<>();
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        if (oConvertUtils.isNotEmpty(ids)) {
            query.in(true, MdcProduction::getId, ids.split(","));
        }
        query.orderByAsc(MdcProduction::getProductionOrder);
        List<MdcProduction> list = this.list(query);
        for (MdcProduction production : list) {
            if (production.getDescription().isEmpty()){
                production.setDescription("");
            }
            listResult.add(new MdcProductionTreeModel(production));
        }
        return listResult;
    }
 
    @Override
    @Cacheable(value = "mdc:cache:production:allids")
    public List<ProductionIdModel> queryProductionIdTreeList() {
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>();
        query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        query.orderByAsc(MdcProduction::getProductionOrder);
        List<MdcProduction> list = this.list(query);
        //调用wrapTreeDataToTreeList方法生成树状数据
        return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list);
    }
 
    /**
     * 根据关键字搜索相关的部门数据
     */
    @Override
    public List<MdcProductionTreeModel> searchByKeyWord(String keyWord) {
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>();
        List<MdcProductionTreeModel> newList = new ArrayList<>();
        query.like(MdcProduction::getProductionName, keyWord);
        MdcProductionTreeModel model = new MdcProductionTreeModel();
        List<MdcProduction> productionList = this.list(query);
        if (!productionList.isEmpty()) {
            for (MdcProduction mdcProduction : productionList) {
                model = new MdcProductionTreeModel(mdcProduction);
                model.setChildren(null);
                newList.add(model);
            }
            return newList;
        }
        return Collections.emptyList();
    }
 
    /**
     * saveProductionData 对应 add 保存用户在页面添加的新的产线对象数据
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveProductionData(MdcProduction mdcProduction) {
        if (mdcProduction != null) {
            if (mdcProduction.getParentId() == null) {
                mdcProduction.setParentId("");
            }
            mdcProduction.setId(IdWorker.getIdStr(mdcProduction));
            // 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
            // 获取父级ID
            String parentId = mdcProduction.getParentId();
            JSONObject formData = new JSONObject();
            formData.put("parentId",parentId);
            String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.PRODUCTION,formData);
            mdcProduction.setOrgCode(codeArray[0]);
            String orgType = codeArray[1];
            mdcProduction.setOrgType(String.valueOf(orgType));
            mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
            this.save(mdcProduction);
 
            //处理存在父子关系 mdc标记统一的问题
            //1.mdc标记 为 1 开启 父级节点要统一开启
            //2.mdc标记 为 0 关闭 子级节点要统一关闭  新增操作 不存在此情况
            if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){
                openParentMdcFlag(parentId);
            }
        }
    }
 
    /**
     * updateProductionDataById 对应 edit 根据产线主键来更新对应的产线数据
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateProductionDataById(MdcProduction mdcProduction) {
        if (mdcProduction != null) {
            this.updateById(mdcProduction);
 
            //处理存在父子关系 mdc标记统一的问题
            //1.mdc标记 为 1 开启 父级节点要统一开启
            //2.mdc标记 为 0 关闭 子级节点要统一关闭
            String parentId = mdcProduction.getParentId();
            if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){
                openParentMdcFlag(parentId);
            }
            if(CommonConstant.DEFAULT_0.equals(mdcProduction.getMdcFlag())){
                //关闭
                closeChildrenMdcFlag(mdcProduction.getId());
            }
            return true;
        }
        return false;
    }
 
    /**
     * 根据产线id删除并删除其可能存在的子级产线
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(String id) {
        List<String> idList = new ArrayList<>();
        idList.add(id);
        this.checkChildrenExists(id, idList);
        boolean result = this.removeByIds(idList);
        //根据产线id删除用户与产线关系
        userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList));
        //根据产线id删除产线与设备关系
        productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList));
        return result;
    }
 
    /**
     * 根据产线id批量删除并删除其可能存在的子级产线
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBatchWithChildren(List<String> ids) {
        List<String> idList = new ArrayList<>();
        for (String id : ids) {
            idList.add(id);
            this.checkChildrenExists(id, idList);
        }
        this.removeByIds(idList);
        //根据产线id删除用户与产线关系
        userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList));
        //根据产线id删除产线与设备关系
        productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList));
    }
 
    /**
     * 根据id查询下级产线
     */
    @Override
    public List<MdcProduction> queryProdByPid(String pid) {
        return this.baseMapper.queryProdByPid(pid);
    }
 
    /**
     * 递归查询所有子节点
     */
    @Override
    public List<MdcProduction> recursionChildrenByPid(String pid){
        List<String> ids=this.recursionChildren(pid);
        return super.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).in(MdcProduction::getId, ids));
    }
 
    /**
     * 根据用户id获取产线下拉树选项
     */
    @Override
    public List<ProductionIdModel> loadProductionTreeOptions(String userId) {
        //获取所有产线数据
        List<MdcProduction> productionList = this.baseMapper.selectList(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder));
        //根据用户id获取拥有的产线信息集合
        List<String> productionIds = userProductionMapper.queryProductionIdsByUserId(userId);
        List<String> allProductionIds = new ArrayList<>();
        //找到所有产线id的上级id
        if (productionIds != null && !productionIds.isEmpty()) {
            for (String productionId : productionIds) {
                this.getAllProductionIds(productionList, productionId, allProductionIds);
            }
        }
        //过滤产线数据
        List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList());
        return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list);
    }
 
    /**
     * 递归查询所有子节点id
     */
    @Override
    public List<String> recursionChildren(String productionId) {
        return this.baseMapper.recursionChildren(productionId);
    }
 
    /**
     * 根据用户id和车间id获取用户拥有的车间id
     * @param userId
     * @param productionId
     * @return
     */
    @Override
    public String findFirstProduction(String userId, String productionId) {
        return this.baseMapper.findFirstProduction(userId, productionId);
    }
 
    /**
     * 根据用户id查询用户工段权限
     */
    @Override
    public String findThreeProductionId(String userId) {
        return this.baseMapper.findThreeProductionId(userId);
    }
 
    /**
     * delete 方法调用 递归查找子集id
     */
    private void checkChildrenExists(String id, List<String> idList) {
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>();
        query.eq(MdcProduction::getParentId, id);
        List<MdcProduction> productionList = this.list(query);
        if (productionList != null && !productionList.isEmpty()) {
            for (MdcProduction production : productionList) {
                idList.add(production.getId());
                this.checkChildrenExists(production.getId(), idList);
            }
        }
    }
 
    /**
     * 获取所有的产线id(包含所有上级)
     */
    private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) {
        if (!allProductionIds.contains(productionId)) {
            allProductionIds.add(productionId);
        }
        for (MdcProduction mdcProduction : productionList) {
            if (StringUtils.isEmpty(mdcProduction.getParentId())) {
                continue;
            }
            if (productionId.equals(mdcProduction.getId())) {
                if (!allProductionIds.contains(mdcProduction.getParentId())) {
                    allProductionIds.add(mdcProduction.getParentId());
                    getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds);
                }
            }
        }
    }
 
    /**
     * 通过产线集合为产线设置用户id,用于前台展示
     */
    private void setUserIdsByProList(List<MdcProduction> productionList) {
        //查询负责部门不为空的情况
        LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
        query.isNotNull(SysUser::getDepartIds);
        List<SysUser> users = sysUserMapper.selectList(query);
        Map<String, Object> map = new HashMap(5);
        //先循环一遍找到不同的负责产线id
        for (SysUser user : users) {
            String productionIds = user.getProductionIds();
            if (StringUtils.isNotBlank(productionIds)) {
                String[] productionIdArray = productionIds.split(",");
                for (String productionId : productionIdArray) {
                    if (map.containsKey(productionId)) {
                        String userIds = map.get(productionId) + "," + user.getId();
                        map.put(productionId, userIds);
                    } else {
                        map.put(productionId, user.getId());
                    }
                }
            }
        }
        //循环产线集合找到产线id对应的负责用户
        for (MdcProduction mdcProduction : productionList) {
            if (map.containsKey(mdcProduction.getId())) {
                mdcProduction.setDirectorUserIds(map.get(mdcProduction.getId()).toString());
            }
        }
    }
 
    /**
     *  查询所有父节点和本节点名称
     * @param id
     * @return
     */
    @Override
    public List<String> findListParentTreeAll(String id){
        MdcProductionEquipment mdcProductionEquipment=productionEquipmentMapper.selectOne(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",id));
        if (mdcProductionEquipment==null) {
            return null;
        }
        List<String> strings = new ArrayList<>();
        MdcProduction en=super.getById(mdcProductionEquipment.getProductionId());
        if (en == null) {
            return null;
        }
        strings.add(en.getProductionName());
        if (StringUtils.isEmpty(en.getParentId())) {
            return strings;
        } else {
            return findListParentTree(en.getParentId(),strings);
        }
    }
 
    //  查询所以父节点
    @Override
    public List<String> findListParentTree(String parentId,List<String> stringList){
        if (StringUtils.isEmpty(parentId)) {
            return null;
        }
        if (stringList == null || stringList.isEmpty()) {
            stringList = new ArrayList<>();
        }
        boolean p = true;
        if (p) {
            MdcProduction en = super.getById(parentId);
            if (en != null) {
                stringList.add(0,en.getProductionName());
            }
            if (StringUtils.isNotBlank(en.getParentId())) {
                parentId = en.getParentId();
                findListParentTree(parentId,stringList);
            } else {
                p = false;
                return stringList;
            }
        }
        return stringList;
    }
 
    /**
     * 获取用户已分配的部门列表
     * @param userId
     * @return
     */
     @Override
     public Map<String, MdcProduction> getUserAssignedDepart(String userId){
         if(StrUtil.isEmpty(userId))
             return null;
         List<MdcProduction> userPermDepart = this.baseMapper.findAllProductionId(userId);
         if(userPermDepart == null || userPermDepart.isEmpty())
             return null;
         Map<String, MdcProduction> map = new HashMap<>();
         userPermDepart.forEach(item -> {
             map.put(item.getId(), item);
         });
         return map;
    }
 
    /**
     * 通过一组id获取部门
     * @param ids
     * @return
     */
    @Override
    public List<String> findAllProductionIds(List<String> ids){
        return this.baseMapper.recursionChildrenByList(ids);
    }
 
    @Override
    public List<String> findParentIdsForProduction(String parentId, List<String> idList) {
        if (StringUtils.isEmpty(parentId)) {
            return null;
        }
        if (idList == null || idList.isEmpty()) {
            idList = new ArrayList<>();
        }
        boolean p = true;
        if (p) {
            MdcProduction en = super.getById(parentId);
            if (en != null) {
                idList.add(0, en.getId());
            }
            if (StringUtils.isNotBlank(en.getParentId())) {
                parentId = en.getParentId();
                findParentIdsForProduction(parentId, idList);
            } else {
                p = false;
                return idList;
            }
        }
        return idList;
    }
 
    @Override
    public List<MdcProductionTreeModel> queryTreeListByMdc(String ids) {
        List<MdcProductionTreeModel> listResult = new ArrayList<>();
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1);
        if (oConvertUtils.isNotEmpty(ids)) {
            query.in(true, MdcProduction::getId, ids.split(","));
        }
        query.orderByAsc(MdcProduction::getProductionOrder);
        List<MdcProduction> list = this.list(query);
        for (MdcProduction production : list) {
            if (production.getDescription().isEmpty()){
                production.setDescription("");
            }
            listResult.add(new MdcProductionTreeModel(production));
        }
        return listResult;
    }
 
    @Override
    public List<MdcProductionTreeModel> queryTreeListByMdc() {
        LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>();
        query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
        query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1);
        query.orderByAsc(MdcProduction::getProductionOrder);
        List<MdcProduction> list = this.list(query);
        //设置用户id,让前台显示
        this.setUserIdsByProList(list);
        //调用wrapTreeDataToTreeList方法生成树状数据
        return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list);
    }
 
    @Override
    public List<String> findChildren(List<String> mdcProductionIds) {
        return this.baseMapper.findChildren(mdcProductionIds);
    }
 
    /**
     * 根据用户id获取产线(中心)或班组下拉选项
     * @param userId
     * @param productionId
     * @return
     */
    @Override
    public List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId) {
        List<MdcProOptionsVo> result = new ArrayList<>();
        List<MdcProduction> mdcProductionList = this.baseMapper.loadProductionOptions(userId, productionId);
        if (mdcProductionList != null && !mdcProductionList.isEmpty()) {
            for (MdcProduction mdcProduction : mdcProductionList) {
                MdcProOptionsVo vo = new MdcProOptionsVo().convert(mdcProduction);
                result.add(vo);
            }
        }
        return result;
    }
 
    @Override
    public List<MdcProduction> findMdcPros(String userId, String productionId) {
        return this.baseMapper.loadProductionOptions(userId, productionId);
    }
 
    @Override
    public List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId) {
        List<MdcProOptionsVo> result = new ArrayList<>();
        List<String> productionList = this.findChildren(Arrays.asList(productionId.split(",")));
        if (productionList != null && !productionList.isEmpty()) {
            List<String> dictValues = this.baseMapper.findTeamValue(userId, productionList);
            if (dictValues != null && !dictValues.isEmpty()) {
                List<DictModel> dictModels = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM);
                if (dictModels != null && !dictModels.isEmpty()) {
                    for (DictModel dictModel : dictModels) {
                        if (dictValues.contains(dictModel.getValue())) {
                            MdcProOptionsVo vo = new MdcProOptionsVo();
                            vo.setKey(dictModel.getValue());
                            vo.setValue(dictModel.getValue());
                            vo.setTitle(dictModel.getText());
                            result.add(vo);
                        }
                    }
                }
            }
        }
        return result;
    }
 
    @Override
    public List<String> findProIdsByUId(String userId, List<String> allProductionIds) {
        return this.baseMapper.findProIdsByUId(userId, allProductionIds);
    }
 
    @Override
    public List<String> findChildByProId(String productionId) {
        return this.baseMapper.findChildByProId(productionId);
    }
 
    /**
     * 打开 父节点 及 以上的mdc标记
     * @param parentId
     */
    private void openParentMdcFlag(String parentId) {
        List<String> listParentTree = findParentIdsForProduction(parentId, new ArrayList<>());
        if (!CollectionUtil.isEmpty(listParentTree)) {
            UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>();
            updateWrapper.in("id", listParentTree);
            updateWrapper.set("mdc_flag", "1");
            super.update(updateWrapper);
        }
    }
 
    /**
     * 关闭所有子节点的mdc标记
     * @param productionId
     */
    private void closeChildrenMdcFlag(String productionId) {
        List<String> childrenList = recursionChildren(productionId);
        if (!CollectionUtil.isEmpty(childrenList)) {
            UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>();
            updateWrapper.in("id", childrenList);
            updateWrapper.set("mdc_flag", "0");
            super.update(updateWrapper);
        }
    }
}