lyh
2025-06-16 24e0bdd24a10449c98013cdb5bcc5e37735f5a91
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
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.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
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.ComponentInfoMapper;
import org.jeecg.modules.dnc.mapper.PartsInfoMapper;
import org.jeecg.modules.dnc.mapper.ProcessSpecVersionMapper;
import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
import org.jeecg.modules.dnc.request.TreeInfoRequest;
import org.jeecg.modules.dnc.response.*;
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 java.util.*;
import java.util.stream.Collectors;
 
@Service
public class ProcessSpecVersionServiceImpl extends ServiceImpl<ProcessSpecVersionMapper, ProcessSpecVersion> implements IProcessSpecVersionService{
    @Autowired
    private ProductInfoMapper productInfoMapper;
    @Autowired
    private ComponentInfoMapper componentInfoMapper;
    @Autowired
    private PartsInfoMapper partsInfoMapper;
    @Autowired
    private IPermissionStreamNewService permissionStreamNewService;
    @Autowired
    @Lazy
    private IProcessStreamService processStreamService;
    @Autowired
    private IProcessSpecVersionPermissionService processSpecVersionPermissionService;
    @Autowired
    private IProcessSpecVersionDepartmentService processSpecVersionDepartmentService;
    @Autowired
    private IProductMixService productMixService;
    @Autowired
    private IWorkStepService workStepService;
    @Autowired
    private IProductPermissionService productPermissionService;
    @Autowired
    @Lazy
    private IDocInfoService docInfoService;
    /**
     * 根据用户id获取授权的工艺规程版本表信息
     * @param userId
     * @return
     */
    @Override
    public List<ProcessSpecVersion> getByUserPerms(String userId){
        if(!ValidateUtil.validateString(userId))
            return Collections.emptyList();
        return super.getBaseMapper().getByUserPerms(userId);
    }
 
    /**
     * 根据用户id获取授权的工艺规程版本表信息
     * @param userId
     * @param queryParam 查询条件
     * @return
     */
    @Override
    public List<ProcessSpecVersion> getByUserPerms(String userId,String queryParam){
        if(!ValidateUtil.validateString(userId))
            return Collections.emptyList();
        if(!ValidateUtil.validateString(queryParam))
            return Collections.emptyList();
        LambdaQueryWrapper<ProcessSpecVersion> queryWrapper = Wrappers.lambdaQuery();
        if(ValidateUtil.validateString(queryParam)) {
            queryWrapper.and(wrapper->wrapper.like(ProcessSpecVersion::getProcessSpecVersionName, queryParam)
                    .or()
                    .like(ProcessSpecVersion::getProcessSpecVersionName, queryParam));
        }
        queryWrapper.orderByAsc(ProcessSpecVersion::getCreateTime);
        return super.list(queryWrapper);
    }
 
    /**
     * 新增工艺规程版本表信息
     * @param processSpecVersion
     * @return
     */
    @Override
    public boolean addProcessSpecVersion(ProcessSpecVersion processSpecVersion){
        if(processSpecVersion == null)
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionName()))
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE);
        if(!ValidateUtil.validateString(processSpecVersion.getProductId()))
            ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
        if(!ValidateUtil.validateString(processSpecVersion.getComponentId()))
            ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
        if(!ValidateUtil.validateString(processSpecVersion.getPartsId()))
            ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE);
        if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionCode()))
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE);
        ProcessSpecVersion en = getByCode(processSpecVersion.getPartsId(),processSpecVersion.getProcessSpecVersionCode());
        if(en != null)
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!ValidateUtil.validateString(userId))
            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
        ProductInfo productInfo = productInfoMapper.selectById(processSpecVersion.getProductId());
        if(productInfo == null)
            ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
        ComponentInfo componentInfo = componentInfoMapper.selectById(processSpecVersion.getComponentId());
        if(componentInfo == null)
            ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
        PartsInfo partsInfo = partsInfoMapper.selectById(processSpecVersion.getPartsId());
        if(partsInfo == null)
            ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
        //相同零件号下面版本号不能重复
        List<ProcessSpecVersion> list = super.list(new LambdaQueryWrapper<ProcessSpecVersion>().eq(ProcessSpecVersion::getPartsId,partsInfo.getPartsId()));
        if (list != null && list.size() > 0) {
            list.forEach(processSpecVersion1 -> {
                if (processSpecVersion1.getProcessSpecVersionCode().equals(processSpecVersion.getProcessSpecVersionCode())) {
                    ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
                }
            });
        }
        boolean b = super.save(processSpecVersion);
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        //添加部门权限
        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(processSpecVersion.getPartsId(), DocAttributionTypeEnum.PARTS.getCode().toString(),"1");
        if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
            List<ProcessSpecVersionDepartment> processSpecVersionDepartmentList = new ArrayList<>();
            List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
            oldDepartPermList.forEach(item -> {
                ProcessSpecVersionDepartment pd = new ProcessSpecVersionDepartment();
                pd.setDepartId(item.getDepartId());
                pd.setPsvId(processSpecVersion.getId());
                processSpecVersionDepartmentList.add(pd);
                PermissionStreamNew perm = new PermissionStreamNew();
                perm.setDepartId(item.getDepartId());
                perm.setBusinessId(processSpecVersion.getId());
                perm.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                permissionStreamList.add(perm);
            });
            if(!processSpecVersionDepartmentList.isEmpty()) {
                b = processSpecVersionDepartmentService.saveBatch(processSpecVersionDepartmentList);
                if(!b)
                    ExceptionCast.cast(CommonCode.FAIL);
            }
            if(!permissionStreamList.isEmpty()) {
                b = permissionStreamNewService.saveBatch(permissionStreamList);
                if(!b)
                    ExceptionCast.cast(CommonCode.FAIL);
            }
        }
        //添加用户权限
        b = productPermissionService.add(processSpecVersion.getId(), userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
        if (!b) {
            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
        }
        //添加结构树
        ProductMix productMix = new ProductMix(Long.parseLong(processSpecVersion.getId()),Long.parseLong(processSpecVersion.getPartsId())
                ,processSpecVersion.getProcessSpecVersionName(),
                processSpecVersion.getProcessSpecVersionCode(),DocAttributionTypeEnum.OPERATION.getCode(),new Date());
        productMixService.save(productMix);
        //添加用户权限
        PermissionStreamNew stream = new PermissionStreamNew();
        stream.setBusinessId(processSpecVersion.getId());
        stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
        stream.setUserId(userId);
        return permissionStreamNewService.addPermissionStreamNew(stream);
    }
 
    /**
     * 编辑工艺规程版本表信息
     * @param id
     * @param processSpecVersion
     * @return
     */
    @Override
    public boolean editProcessSpecVersion(String id ,ProcessSpecVersion processSpecVersion){
        if(!ValidateUtil.validateString(id) || processSpecVersion == null)
            ExceptionCast.cast(CommonCode.SUCCESS);
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!ValidateUtil.validateString(userId))
            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
        ProcessSpecVersion en = super.getById(id);
        if(en == null)
            ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
        processSpecVersion.setId(id);
        processSpecVersion.setProductId(null);
        processSpecVersion.setComponentId(null);
        processSpecVersion.setPartsId(null);
        boolean b = super.updateById(processSpecVersion);
        //同步修改结构树
        ProductMix productMix = productMixService.getById(Long.parseLong(id));
        productMix.setTreeName(processSpecVersion.getProcessSpecVersionName());
        productMix.setTreeCode(processSpecVersion.getProcessSpecVersionCode());
        productMixService.updateById(productMix);
        if(!b)
            return false;
        ProcessSpecVersionPermission permission = processSpecVersionPermissionService.getByPsvIdAndUserId(id, userId);
        if(permission == null) {
            permission = new ProcessSpecVersionPermission(id,userId);
            b = processSpecVersionPermissionService.save(permission);
            if(!b)
                return false;
        }
        PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
        if(stream == null) {
            stream = new PermissionStreamNew();
            stream.setBusinessId(id);
            stream.setUserId(userId);
            return permissionStreamNewService.save(stream);
        }
        return b;
    }
 
    /**
     * 删除工艺规程版本表信息
     * @param id
     * @return
     */
    @Override
    public boolean deleteProcessSpecVersion(String id){
        if(!ValidateUtil.validateString(id))
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        ProcessSpecVersion processSpecVersion = super.getById(id);
        if(processSpecVersion == null)
            ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
        List<ProcessStream> processStreams = processStreamService.findBypsvId(id);
        if(processStreams!= null &&!processStreams.isEmpty())
            ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_PROCESS_EXIST);
        boolean b = processSpecVersionPermissionService.deleteByPsvId(processSpecVersion.getId());
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        b = processSpecVersionDepartmentService.deleteByPsvId(processSpecVersion.getId());
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"0");
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"1");
        if(!b)
            ExceptionCast.cast(CommonCode.FAIL);
        b = productMixService.removeById(processSpecVersion.getId());
        if (!b)
            ExceptionCast.cast(CommonCode.FAIL);
        return super.removeById(processSpecVersion.getId());
    }
 
    @Override
    public ProcessSpecVersion getByCode(String partId,String processSpecVersionCode) {
        if(ValidateUtil.validateString(processSpecVersionCode)) {
            List<ProcessSpecVersion> list = super.lambdaQuery()
                    .eq(ProcessSpecVersion::getPartsId, partId)
                    .eq(ProcessSpecVersion::getProcessSpecVersionCode, processSpecVersionCode).list();
            if(list == null || list.isEmpty())
                return null;
            return list.get(0);
        }
        return null;
    }
 
    @Override
    public List<ProcessSpecVersion> getByPartsId(String partsId) {
        if(ValidateUtil.validateString(partsId)) {
            List<ProcessSpecVersion> list = super.lambdaQuery().eq(ProcessSpecVersion::getPartsId, partsId).list();
            if(list == null || list.isEmpty())
                return null;
            return list;
        }
        return null;
    }
 
    /**
     * 根据一组零件id获取
     * @param partsIds
     * @return
     */
    @Override
    public List<ProcessSpecVersion> getByPartsIds(List<String> partsIds){
        if(partsIds == null || partsIds.isEmpty())
            return Collections.emptyList();
        List<ProcessSpecVersion> list = super.lambdaQuery().in(ProcessSpecVersion::getPartsId, partsIds).list();
        if(list == null || list.isEmpty())
            return null;
        else
            return list;
    }
 
 
    /**
     * 分配用户权限
     * @param processSpecVersion
     * @param userList
     * @return
     */
    @Override
    public boolean assignAddUser(ProcessSpecVersion processSpecVersion, Collection<SysUser> userList){
        if(processSpecVersion == null || userList == null || userList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<ProcessSpecVersionPermission> permissionList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        userList.forEach(item -> {
            ProcessSpecVersionPermission en = processSpecVersionPermissionService.getByPsvIdAndUserId(processSpecVersion.getId(), item.getId());
            if(en == null) {
                en = new ProcessSpecVersionPermission();
                en.setUserId(item.getId());
                en.setPsvId(processSpecVersion.getId());
                permissionList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
            if(stream == null) {
                stream = new PermissionStreamNew();
                stream.setUserId(item.getId());
                stream.setBusinessId(processSpecVersion.getId());
                stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                permissionStreamList.add(stream);
            }
        });
        if(!permissionList.isEmpty()) {
            boolean b = processSpecVersionPermissionService.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;
    }
 
 
    /**
     * 移除用户权限
     * @param processSpecVersion
     * @param userList
     * @return
     */
    @Override
    public boolean assignRemoveUser(ProcessSpecVersion processSpecVersion, Collection<SysUser> userList){
        if(processSpecVersion == null || userList == null || userList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<ProcessSpecVersionPermission> permissionList = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        userList.forEach(item -> {
            ProcessSpecVersionPermission en = processSpecVersionPermissionService.getByPsvIdAndUserId(processSpecVersion.getId(), item.getId());
            if(en != null) {
                permissionList.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
            if(stream != null) {
                permissionStreamList.add(stream);
            }
        });
        //清空用户权限校验
        if(!permissionList.isEmpty()) {
            boolean b = processSpecVersionPermissionService.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;
    }
    /**
     * 分配部门权限
     * @param processSpecVersion
     * @param departmentList
     * @return
     */
    @Override
    public boolean assignAddDepart(ProcessSpecVersion processSpecVersion, Collection<MdcProduction> departmentList){
        if(processSpecVersion == null || departmentList == null || departmentList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<ProcessSpecVersionDepartment> partsDepartments = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        departmentList.forEach(item -> {
            ProcessSpecVersionDepartment en = processSpecVersionDepartmentService.getByProcessSpecVersionIdAndDepartId(processSpecVersion.getId(), item.getId());
            if(en == null) {
                en = new ProcessSpecVersionDepartment();
                en.setDepartId(item.getId());
                en.setPsvId(processSpecVersion.getId());
                partsDepartments.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
            if(stream == null) {
                stream = new PermissionStreamNew();
                stream.setDepartId(item.getId());
                stream.setBusinessId(processSpecVersion.getId());
                stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                permissionStreamList.add(stream);
            }
        });
        if(!partsDepartments.isEmpty()) {
            boolean b = processSpecVersionDepartmentService.saveBatch(partsDepartments);
            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;
    }
 
    /**
     * 分配部门权限
     * @param processSpecVersion
     * @param departmentList
     * @return
     */
    @Override
    public boolean assignRemoveDepart(ProcessSpecVersion processSpecVersion, Collection<MdcProduction> departmentList){
        if(processSpecVersion == null || departmentList == null || departmentList.isEmpty())
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        List<ProcessSpecVersionDepartment> partsDepartments = new ArrayList<>();
        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
        departmentList.forEach(item -> {
            ProcessSpecVersionDepartment en = processSpecVersionDepartmentService.getByProcessSpecVersionIdAndDepartId(processSpecVersion.getId(), item.getId());
            if(en != null) {
                partsDepartments.add(en);
            }
            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),"3");
            if(stream != null) {
                permissionStreamList.add(stream);
            }
        });
        if(!partsDepartments.isEmpty()) {
            boolean b = processSpecVersionDepartmentService.removeByCollection(partsDepartments);
            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;
    }
 
    /**
     * 根据工艺规程id查询,下级工序工步数量
     * @param processSpecId
     * @return
     */
    @Override
    public Result<?> getProcessSpecVersionCount(String processSpecId){
        List<ProcessStream> list = processStreamService.findBypsvId(processSpecId);
        List<WorkStep> workStepList=workStepService.list(new LambdaQueryWrapper<WorkStep>().eq(WorkStep::getPsvId,processSpecId));
        return null;
    }
 
    /**
     * 通过零件号、材质等查询对应电子样板
     * @param treeInfoRequest
     * @return
     */
    @Override
    public List<DocInfo> getByProcessSpecVersion(TreeInfoRequest treeInfoRequest){
        LambdaQueryWrapper<ProcessSpecVersion> queryWrapper = new LambdaQueryWrapper<>();
        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
            queryWrapper.in(ProcessSpecVersion::getProductId, treeInfoRequest.getProductIds());
        }
        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
            queryWrapper.in(ProcessSpecVersion::getComponentId, treeInfoRequest.getComponentIds());
        }
        if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
            queryWrapper.in(ProcessSpecVersion::getPartsId, treeInfoRequest.getPartsIds());
        }
        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ProcessSpecVersion::getId,treeInfoRequest.getAttributionId());
        }
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ProcessSpecVersion::getProcessSpecVersionName, treeInfoRequest.getTreeName());
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName());
        queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime);
        List<ProcessSpecVersion> 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(ProcessSpecVersion::getId).collect(Collectors.joining(","));
            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
            BeanUtil.copyProperties(treeInfoRequest,docQuery);
            docQuery.setAttributionIds(ids);
            docQuery.setDocClassCode("OTHER");
            docQuery.setAttributionType(DocAttributionTypeEnum.OPERATION.getCode());
            docInfos=docInfoService.findListByDocQuery(docQuery);
            if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
                List<String> id =new ArrayList<>();
                id.add(treeInfoRequest.getAttributionId());
                treeInfoRequest.setPsvIds(id);
                //工序
                List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest);
                docInfos.addAll(processStreams);
                //工步
                List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest);
                docInfos.addAll(workSteps);
            }
        }
        return docInfos;
    }
}