hyingbo
2025-07-10 7feb2d0ebb7c6899cc654ca4ca88416b7d5ffdd0
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
package org.jeecg.modules.dnc.service.impl;
 
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.ListUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
import org.jeecg.modules.dnc.entity.*;
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.mapper.WorkStepMapper;
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
import org.jeecg.modules.dnc.request.TreeInfoRequest;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.ProcessInfoCode;
import org.jeecg.modules.dnc.response.ProductInfoCode;
import org.jeecg.modules.dnc.response.UcenterCode;
import org.jeecg.modules.dnc.service.*;
import org.jeecg.modules.dnc.utils.ValidateUtil;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.*;
import java.util.stream.Collectors;
 
@Service
public class WorkStepServiceImpl extends ServiceImpl<WorkStepMapper, WorkStep> implements IWorkStepService {
    @Autowired
    private IPermissionStreamNewService permissionStreamNewService;
 
    @Autowired
    private IWorkStepDepartmentService workStepDepartmentService;
 
    @Autowired
    private IWorkStepPermissionService workStepPermissionService;
 
    @Autowired
    private IDocRelativeService iDocRelativeService;
 
    @Autowired
    private IProductPermissionService productPermissionService;
 
    @Autowired
    private IProductMixService productMixService;
 
    @Autowired
    @Lazy
    private IDocInfoService docInfoService;
    @Autowired
    private IDeviceTypeService deviceTypeService;
 
    @Override
    public List<WorkStep> getByUserPerms(String userId) {
        if(!ValidateUtil.validateString(userId))
            return Collections.emptyList();
        return super.getBaseMapper().getByUserPerms(userId);
    }
 
    /**
     * 根据用户id获取授权的工步信息
     * @param userId
     * @param queryParam 查询条件
     * @return
     */
    @Override
    public List<WorkStep> getByUserPerms(String userId,String queryParam){
        if(!ValidateUtil.validateString(userId))
            return Collections.emptyList();
        if(!ValidateUtil.validateString(queryParam))
            return Collections.emptyList();
        LambdaQueryWrapper<WorkStep> queryWrapper = Wrappers.lambdaQuery();
        if(ValidateUtil.validateString(queryParam)) {
            queryWrapper.and(wrapper->wrapper.like(WorkStep::getStepName, queryParam)
                    .or()
                    .like(WorkStep::getStepName, queryParam));
        }
        queryWrapper.orderByAsc(WorkStep::getCreateTime);
        return super.list(queryWrapper);
    }
 
    /**
     * 新增产品信息
     * @param workStep
     * @return
     */
    @Override
    public boolean addWorkStep(WorkStep workStep){
        if(workStep == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(workStep.getProductId()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_PRODUCT_NONE);
        if(!ValidateUtil.validateString(workStep.getComponentId()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_COMPONENT_NONE);
        if(!ValidateUtil.validateString(workStep.getStepName()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE);
        if(!ValidateUtil.validateString(workStep.getStepCode()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_CODE_NONE);
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!ValidateUtil.validateString(userId))
            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
        WorkStep en =getByWorkStepNo(workStep.getProcessId(), workStep.getCraftNo());
        if(en != null) {
            ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST);
        }
        boolean b =super.save(workStep);
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        //添加部门权限
        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(workStep.getProcessId(), DocAttributionTypeEnum.PROCESS.getCode().toString(),"1");
        if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
            List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>();
            List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
            oldDepartPermList.forEach(item -> {
                WorkStepDepartment pd = new WorkStepDepartment();
                pd.setDepartId(item.getDepartId());
                pd.setStepId(workStep.getId());
                workStepDepartmentList.add(pd);
                PermissionStreamNew perm = new PermissionStreamNew();
                perm.setDepartId(item.getDepartId());
                perm.setBusinessId(workStep.getId());
                perm.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                permissionStreamList.add(perm);
            });
            if(!workStepDepartmentList.isEmpty()) {
                b = workStepDepartmentService.saveBatch(workStepDepartmentList);
                if(!b)
                    ExceptionCast.cast(CommonCode.FAIL);
            }
            if(!permissionStreamList.isEmpty()) {
                b = permissionStreamNewService.saveBatch(permissionStreamList);
                if(!b)
                    ExceptionCast.cast(CommonCode.FAIL);
            }
        }
        //添加用户权限
        b = productPermissionService.add(workStep.getId(), userId,DocAttributionTypeEnum.WORKSITE.getCode().toString());
        if (!b) {
            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
        }
        //添加结构树
        ProductMix productMix = new ProductMix(Long.parseLong(workStep.getId()),Long.parseLong(workStep.getProcessId())
                ,workStep.getStepName(),workStep.getStepCode(),DocAttributionTypeEnum.WORKSITE.getCode(),new Date());
        productMixService.save(productMix);
        //添加权限验证
        PermissionStreamNew permissionStream = new PermissionStreamNew();
        permissionStream.setUserId(userId);
        permissionStream.setBusinessId(workStep.getId());
        permissionStream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
        return permissionStreamNewService.addPermissionStreamNew(permissionStream);
    }
 
    /**
     * 编辑产品信息
     * @param id
     * @param workStep
     * @return
     */
    @Override
    public boolean editWorkStep(String id ,WorkStep workStep){
        if(!ValidateUtil.validateString(id) || workStep == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(workStep.getStepName()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE);
        WorkStep en = super.getById(id);
        if(en == null)
            ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST);
        //同步修改结构树
        ProductMix productMix = productMixService.getById(Long.parseLong(id));
        productMix.setTreeName(workStep.getStepName());
        productMix.setTreeCode(workStep.getStepCode());
        productMixService.updateById(productMix);
        return super.updateById(workStep);
    }
 
    @Override
    public WorkStep getByWorkStepNo(String processId,String craftNo){
        if(ValidateUtil.validateString(processId)) {
            List<WorkStep> list = super.lambdaQuery().eq(WorkStep::getProcessId, processId).eq(WorkStep::getCraftNo,craftNo).list();
            if(list == null || list.isEmpty())
                return null;
            return list.get(0);
        }
        return null;
 
    }
 
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public boolean assignAddDepart(WorkStep workStep, Collection<MdcProduction> departmentList) {
        if(workStep == null || departmentList == null || departmentList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        departmentList.forEach(item -> {
            WorkStepDepartment en = workStepDepartmentService.getByStepIdAndDepartId(workStep.getId(), item.getId());
            if(en == null) {
                en = new WorkStepDepartment();
                en.setDepartId(item.getId());
                en.setStepId(workStep.getId());
                workStepDepartmentList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
            if(stream == null) {
                stream = new PermissionStreamNew();
                stream.setDepartId(item.getId());
                stream.setBusinessId(workStep.getId());
                stream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                permissionStreamList.add(stream);
            }
        });
        if(!workStepDepartmentList.isEmpty()) {
            boolean b = workStepDepartmentService.saveBatch(workStepDepartmentList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        if(!permissionStreamList.isEmpty()) {
            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        return true;
    }
 
    @Override
    public List<WorkStep> getByProcessIds(String productId,List<String> processIds) {
        if(!ValidateUtil.validateString(productId) || processIds == null || processIds.isEmpty())
            return null;
        List<WorkStep> list = new ArrayList<>();
        if(processIds.size() > 1000){
            List<List<String>> processListArr = ListUtils.partition(processIds, 100);
            for(List<String> processList : processListArr){
                List<WorkStep> workStepList = super.lambdaQuery().eq(WorkStep::getProductId, productId).in(WorkStep::getProcessId, processList).list();
                if(workStepList != null && !workStepList.isEmpty()){
                    list.addAll(workStepList);
                }
            }
        }else {
            list = super.lambdaQuery().eq(WorkStep::getProductId, productId).in(WorkStep::getProcessId, processIds).list();
        }
        if(list == null || list.isEmpty())
            return null;
        return list;
    }
 
    /**
     * 分配部门权限
     * @param workStep
     * @param departmentList
     * @return
     */
    @Override
    public boolean assignRemoveDepart(WorkStep workStep, Collection<MdcProduction> departmentList){
        if(workStep == null || departmentList == null || departmentList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        departmentList.forEach(item -> {
            WorkStepDepartment en = workStepDepartmentService.getByStepIdAndDepartId(workStep.getId(), item.getId());
            if(en != null) {
                workStepDepartmentList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
            if(stream != null) {
                permissionStreamList.add(stream);
            }
        });
        if(!workStepDepartmentList.isEmpty()) {
            boolean b = workStepDepartmentService.removeByCollection(workStepDepartmentList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        if(!permissionStreamList.isEmpty()) {
            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        return true;
    }
 
    /**
     * 删除工步信息 逻辑删除
     * @param id
     * @return
     */
    public boolean deleteWorkStep(String id){
        if(!ValidateUtil.validateString(id))
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        WorkStep en = super.getById(id);
        if(en == null)
            ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST);
        //验证是否存在文档
        List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type",DocAttributionTypeEnum.WORKSITE.getCode().toString()).eq("attribution_id",id));
        if (!docRelativeList.isEmpty()){
            ExceptionCast.cast(ProcessInfoCode.WORKSTEP_HAS_DOC);
        }
        boolean b=productMixService.removeById(id);
        if(!b) {
            ExceptionCast.cast(CommonCode.FAIL);
        }
        return super.removeById(id);
    }
 
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public boolean assignAddUser(WorkStep workStep, Collection<SysUser> userList) {
        if(workStep == null || userList == null || userList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<WorkStepPermission> permissionList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        userList.forEach(item -> {
            WorkStepPermission en = workStepPermissionService.getByStepIdAndUserId(workStep.getId(), item.getId());
            if(en == null) {
                en = new WorkStepPermission();
                en.setUserId(item.getId());
                en.setStepId(workStep.getId());
                permissionList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
            if(stream == null) {
                stream = new PermissionStreamNew();
                stream.setUserId(item.getId());
                stream.setBusinessId(workStep.getId());
                stream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                permissionStreamList.add(stream);
            }
        });
        if(!permissionList.isEmpty()) {
            boolean b = workStepPermissionService.saveBatch(permissionList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        if(!permissionStreamList.isEmpty()) {
            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        return true;
    }
 
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public boolean assignRemoveUser(WorkStep workStep, Collection<SysUser> userList) {
        if(workStep == null || userList == null || userList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<WorkStepPermission> permissionList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        userList.forEach(item -> {
            WorkStepPermission en = workStepPermissionService.getByStepIdAndUserId(workStep.getId(), item.getId());
            if(en != null) {
                permissionList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
            if(stream != null) {
                permissionStreamList.add(stream);
            }
        });
        //清空用户权限校验
        if(!permissionList.isEmpty()) {
            boolean b = workStepPermissionService.removeByCollection(permissionList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        if(!permissionStreamList.isEmpty()) {
            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
            if(!b) {
                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
            }
        }
        return true;
    }
 
    /**
     * 通过工步号、工步名称等查询对应NC文件
     * NC文件存在设备类下面
     * @param treeInfoRequest
     * @return
     */
    @Override
    public List<DocInfo> getByWorkStepOtherFile(TreeInfoRequest treeInfoRequest){
        LambdaQueryWrapper<WorkStep> queryWrapper = new LambdaQueryWrapper<>();
        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
            queryWrapper.in(WorkStep::getProductId, treeInfoRequest.getProductIds());
        }
        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
            queryWrapper.in(WorkStep::getComponentId, treeInfoRequest.getComponentIds());
        }
        if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
            queryWrapper.in(WorkStep::getPartsId, treeInfoRequest.getPartsIds());
        }
        if (treeInfoRequest.getPsvIds() != null && !treeInfoRequest.getPsvIds().isEmpty()) {
            queryWrapper.in(WorkStep::getPsvId, treeInfoRequest.getPsvIds());
        }
        if (treeInfoRequest.getProcessIds() != null && !treeInfoRequest.getProcessIds().isEmpty()) {
            queryWrapper.in(WorkStep::getProcessId, treeInfoRequest.getProcessIds());
        }
        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())){
            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),WorkStep::getId,treeInfoRequest.getAttributionId());
        }
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),WorkStep::getStepName, treeInfoRequest.getTreeName());
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),WorkStep::getStepCode, treeInfoRequest.getTreeName());
        queryWrapper.orderByDesc(WorkStep::getCreateTime);
        List<WorkStep> list = super.list(queryWrapper);
        List<DocInfo> docInfos;
        if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){
            return new ArrayList<>();
        }else {
            String ids=list.stream().map(WorkStep::getId).collect(Collectors.joining(","));
            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
            BeanUtil.copyProperties(treeInfoRequest,docQuery);
            docQuery.setAttributionIds(ids);
            docQuery.setDocClassCode("OTHER");
            docQuery.setAttributionType(DocAttributionTypeEnum.WORKSITE.getCode());
            docInfos=docInfoService.findListByDocQuery(docQuery);
        }
        return docInfos;
    }
 
    /**
     * 通过工步号、工步名称等查询对应NC文件
     * NC文件存在设备类下面
     * @param treeInfoRequest
     * @return
     */
    @Override
    public List<DocInfo> getByWorkStepNCFile(TreeInfoRequest treeInfoRequest){
        LambdaQueryWrapper<WorkStep> queryWrapper = new LambdaQueryWrapper<>();
        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
            queryWrapper.in(WorkStep::getProductId, treeInfoRequest.getProductIds());
        }
        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
            queryWrapper.in(WorkStep::getComponentId, treeInfoRequest.getComponentIds());
        }
        if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
            queryWrapper.in(WorkStep::getPartsId, treeInfoRequest.getPartsIds());
        }
        if (treeInfoRequest.getPsvIds() != null && !treeInfoRequest.getPsvIds().isEmpty()) {
            queryWrapper.in(WorkStep::getPsvId, treeInfoRequest.getPsvIds());
        }
        if (treeInfoRequest.getProcessIds() != null && !treeInfoRequest.getProcessIds().isEmpty()) {
            queryWrapper.in(WorkStep::getProcessId, treeInfoRequest.getProcessIds());
        }
        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())){
            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),WorkStep::getProcessId,treeInfoRequest.getAttributionId());
        }
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),WorkStep::getStepName, treeInfoRequest.getTreeName());
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),WorkStep::getStepCode, treeInfoRequest.getTreeName());
        queryWrapper.orderByDesc(WorkStep::getCreateTime);
        List<WorkStep> list = super.list(queryWrapper);
        List<DocInfo> docInfos = new ArrayList<>();
        //NC文件存在对应的设备类下,所以需要过滤
        if (!list.isEmpty()) {
            List<String> workStepIds = list.stream().map(WorkStep::getId).collect(Collectors.toList());
            List<DeviceType> deviceTypeList = deviceTypeService.getDeviceTypeByAttribution(workStepIds,
                    DocAttributionTypeEnum.WORKSITE.getCode(),treeInfoRequest.getDeviceManagementName(),treeInfoRequest.getDeviceManagementCode());
            if (deviceTypeList != null && !deviceTypeList.isEmpty()) {
                List<String> deviceTypeIds=deviceTypeList.stream().map(DeviceType::getId).collect(Collectors.toList());
                DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
                BeanUtil.copyProperties(treeInfoRequest,docQuery);
                docQuery.setAttributionIds(String.join(",",deviceTypeIds));
                docQuery.setDocClassCode("NC");
                docQuery.setAttributionType(DocAttributionTypeEnum.WORKSITE.getCode());
                docInfos=docInfoService.findListByDocQuery(docQuery);
            }
            return docInfos;
        }
        return new ArrayList<>();
    }
 
    @Override
    public boolean assignPermission(Object entity, Collection<SysUser> userList, boolean isAdd){
        if (isAdd) {
            return assignAddUser((WorkStep) entity, userList);
        } else {
            return assignRemoveUser((WorkStep) entity, userList);
        }
    }
    @Override
    public boolean assignDepartPermission(Object entity, Collection<MdcProduction> departments, boolean isAdd) {
        if (isAdd) {
            return assignAddDepart((WorkStep) entity, departments);
        } else {
            return assignRemoveDepart((WorkStep) entity, departments);
        }
    }
}