yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
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
package com.qianwen.smartman.modules.cps.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.google.common.collect.Lists;
import java.lang.invoke.SerializedLambda;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.CraftConstant;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.core.mp.service.impl.BladeServiceImpl;
import com.qianwen.core.tool.support.Kv;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.core.tool.utils.RandomType;
import com.qianwen.core.tool.utils.StringUtil;
import com.qianwen.smartman.modules.cps.convert.CraftRoutingConvert;
import com.qianwen.smartman.modules.cps.convert.ProductConvert;
import com.qianwen.smartman.modules.cps.convert.ProductionCraftProcessConvert;
import com.qianwen.smartman.modules.cps.dto.CraftVersionDTO;
import com.qianwen.smartman.modules.cps.entity.CraftRouting;
import com.qianwen.smartman.modules.cps.entity.CraftVersionLine;
import com.qianwen.smartman.modules.cps.entity.Product;
import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcess;
import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcessFile;
import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcessRelatedFixture;
import com.qianwen.smartman.modules.cps.entity.ProductionCraftProcessRelatedTool;
import com.qianwen.smartman.modules.cps.entity.ProductionCraftVersion;
import com.qianwen.smartman.modules.cps.mapper.CraftRoutingMapper;
import com.qianwen.smartman.modules.cps.service.ICraftRoutingService;
import com.qianwen.smartman.modules.cps.service.ICraftVersionLineService;
import com.qianwen.smartman.modules.cps.service.IProductService;
import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessFileService;
import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessRelatedFixtureService;
import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessRelatedToolService;
import com.qianwen.smartman.modules.cps.service.IProductionCraftProcessService;
import com.qianwen.smartman.modules.cps.service.IProductionCraftVersionService;
import com.qianwen.smartman.modules.cps.utils.ThrowFun;
import com.qianwen.smartman.modules.cps.vo.CraftRoutingAddVO;
import com.qianwen.smartman.modules.cps.vo.CraftRoutingDetailVO;
import com.qianwen.smartman.modules.cps.vo.CraftRoutingUpdateVO;
import com.qianwen.smartman.modules.cps.vo.CraftRoutingVO;
import com.qianwen.smartman.modules.cps.vo.CraftVersionAddVO;
import com.qianwen.smartman.modules.cps.vo.ParallelProVO;
import com.qianwen.smartman.modules.cps.vo.ProcessParallelSaveVO;
import com.qianwen.smartman.modules.cps.vo.ProductVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftProcessFileVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftProcessRelatedFixtureVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftProcessRelatedToolVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftProcessVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftVersionCopyVO;
import com.qianwen.smartman.modules.cps.vo.ProductionCraftVersionVO;
import com.qianwen.smartman.modules.cps.vo.SearchVO;
import com.qianwen.smartman.modules.cps.vo.VersionProcessAddVO;
import com.qianwen.smartman.modules.system.service.IBasCoderuleService;
import com.qianwen.smartman.modules.tpm.enums.MetaTypeEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/service/impl/CraftRoutingServiceImpl.class */
public class CraftRoutingServiceImpl extends BladeServiceImpl<CraftRoutingMapper, CraftRouting> implements ICraftRoutingService {
    private static final Logger log = LoggerFactory.getLogger(CraftRoutingServiceImpl.class);
    private final IProductionCraftVersionService craftVersionService;
    private final ICraftVersionLineService versionLineService;
    private final IProductService productService;
    private final IProductionCraftProcessService craftProcessService;
    private final IProductionCraftProcessRelatedFixtureService relatedFixtureService;
    private final IProductionCraftProcessRelatedToolService relatedToolService;
    private final IProductionCraftProcessFileService processFileService;
    private final IBasCoderuleService basCodeRuleService;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1416707747:
                if (implMethodName.equals("getVersionId")) {
                    z = true;
                    break;
                }
                break;
            case -1291082392:
                if (implMethodName.equals("getVersionProcessId")) {
                    z = true;
                    break;
                }
                break;
            case -1061435468:
                if (implMethodName.equals("getProductId")) {
                    z = true;
                    break;
                }
                break;
            case -75308287:
                if (implMethodName.equals("getName")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
            case 1330288580:
                if (implMethodName.equals("getGroupId")) {
                    z = true;
                    break;
                }
                break;
            case 2061868837:
                if (implMethodName.equals("getCraftId")) {
                    z = false;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftVersion") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getCraftId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getCraftId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcess") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcess") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcessRelatedFixture") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionProcessId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcessRelatedTool") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionProcessId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/ProductionCraftProcessFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getVersionProcessId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getName();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case RegionCache.VILLAGE_LEVEL /* 5 */:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftVersionLine") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getGroupId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/CraftRouting") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getProductId();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public CraftRoutingServiceImpl(final IProductionCraftVersionService craftVersionService, final ICraftVersionLineService versionLineService, final IProductService productService, final IProductionCraftProcessService craftProcessService, final IProductionCraftProcessRelatedFixtureService relatedFixtureService, final IProductionCraftProcessRelatedToolService relatedToolService, final IProductionCraftProcessFileService processFileService, final IBasCoderuleService basCodeRuleService) {
        this.craftVersionService = craftVersionService;
        this.versionLineService = versionLineService;
        this.productService = productService;
        this.craftProcessService = craftProcessService;
        this.relatedFixtureService = relatedFixtureService;
        this.relatedToolService = relatedToolService;
        this.processFileService = processFileService;
        this.basCodeRuleService = basCodeRuleService;
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public CraftRoutingVO saveRouting(CraftRoutingAddVO vo) {
        CraftRouting craftRouting = saveCraftRouting(vo);
        return CraftRoutingConvert.INSTANCE.convert(craftRouting);
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public List<CraftRoutingVO> listCraftRouting(SearchVO vo) {
        Wrapper<CraftRouting> wrapper = getWrapper(vo);
        return this.baseMapper.listCraftRouting(Func.isBlank(wrapper.getSqlSegment()) ? null : wrapper);
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public CraftRoutingDetailVO detailCraft(Long id) {
        CraftRoutingDetailVO vo = new CraftRoutingDetailVO();
        setProduce(vo, id);
        setCraftVersion(vo, id);
        return vo;
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    @Transactional(rollbackFor = {Exception.class})
    public Boolean deleteCraft(Long id) {
        boolean flag = removeById(id);
        List<Long> versionIds = this.craftVersionService.listObjs((Wrapper) Wrappers.lambdaQuery(ProductionCraftVersion.class).select(new SFunction[]{(v0) -> {
            return v0.getId();
        }}).eq((v0) -> {
            return v0.getCraftId();
        }, id), c -> {
            return Long.valueOf(c instanceof BigDecimal ? ((BigDecimal) c).longValue() : ((Long) c).longValue());
        });
        if (Func.isNotEmpty(versionIds)) {
            flag = flag && this.craftVersionService.removeVersion(versionIds).booleanValue();
        }
        return Boolean.valueOf(flag && this.versionLineService.remove((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getCraftId();
        }, id)));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public Boolean updateCraft(CraftRoutingUpdateVO vo) {
        validNameExist(vo.getId(), vo.getName());
        CraftRouting routing = CraftRoutingConvert.INSTANCE.convert(vo);
        return Boolean.valueOf(updateById(routing));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    @Transactional(rollbackFor = {Exception.class})
    public Boolean copyCraftVersion(ProductionCraftVersionCopyVO vo) {
        Integer type = vo.getType();
        if (CraftConstant.COPY_TYPE_PRODUCT.equals(type)) {
            CraftRouting routing = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> {
                return v0.getProductId();
            }, vo.getProductId()));
            if (Func.isNull(routing)) {
                return Boolean.valueOf(copyProductNewCraft(vo));
            }
            return Boolean.valueOf(copyCraftNewVersion(vo, routing.getId()));
        }
        return Boolean.valueOf(copyCraftNewVersion(vo, vo.getCraftId()));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public List<ProductionCraftVersionVO> listFixedVersionByProduction(Long productionId) {
        CraftRouting craft = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> {
            return v0.getProductId();
        }, productionId));
        if (Func.isNull(craft)) {
            return Lists.newArrayList();
        }
        return this.craftVersionService.listFixed(craft.getId());
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public CraftRoutingDetailVO getCraftByProduction(Long production) {
        CraftRouting craft = (CraftRouting) getOne((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).eq((v0) -> {
            return v0.getProductId();
        }, production));
        if (Func.isNull(craft)) {
            return null;
        }
        return detailCraft(craft.getId());
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public List<CraftRoutingVO> listNotBandCraft() {
        return CraftRoutingConvert.INSTANCE.convert(list((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).isNull((v0) -> {
            return v0.getProductId();
        })));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public Boolean craftBindProduction(Long productionId, Long craftId) {
        return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate(CraftRouting.class).set((v0) -> {
            return v0.getProductId();
        }, productionId)).eq((v0) -> {
            return v0.getId();
        }, craftId)));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public Boolean craftUnbindProduction(Long craftId) {
        return Boolean.valueOf(update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate(CraftRouting.class).set((v0) -> {
            return v0.getProductId();
        }, (Object) null)).eq((v0) -> {
            return v0.getId();
        }, craftId)));
    }
 
    @Override // org.springblade.modules.cps.service.ICraftRoutingService
    public List<ProductVO> notBandProduct(Long craftId) {
        List<Product> products = this.productService.notBandProduct(craftId);
        return ProductConvert.INSTANCE.convert(products);
    }
 
    private boolean copyCraftNewVersion(ProductionCraftVersionCopyVO vo, Long craftId) {
        Long versionId = vo.getVersionId();
        ProductionCraftVersion version = (ProductionCraftVersion) this.craftVersionService.getById(versionId);
        CraftVersionAddVO newVersion = new CraftVersionAddVO();
        boolean existCodeRule = this.basCodeRuleService.isExistCodeRule(MetaTypeEnum.PRODUCTION_CRAFT_VERSION.getCode());
        if (!existCodeRule) {
            newVersion.setName(version.getName() + Func.random(4, RandomType.STRING));
        }
        newVersion.setDescription(version.getDescription());
        newVersion.setGroupIds(getGroupIds(versionId));
        ProductionCraftVersionVO craftVersion = this.craftVersionService.saveCraftVersion(craftId, newVersion);
        List<ProductionCraftProcess> processList = this.craftProcessService.list((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcess.class).eq((v0) -> {
            return v0.getVersionId();
        }, version.getId()));
        ProcessParallelSaveVO saveVO = copyProductNewCraftProcess(craftVersion.getId(), processList);
        List<ProductionCraftProcessVO> vos = this.craftProcessService.parallelSave(saveVO);
        return Func.isNotEmpty(vos);
    }
 
    private boolean copyProductNewCraft(ProductionCraftVersionCopyVO vo) {
        CraftRoutingAddVO newCraft = new CraftRoutingAddVO();
        String newCraftName = vo.getCraftName() + Func.random(4, RandomType.STRING);
        newCraft.setName(newCraftName);
        newCraft.setProductId(vo.getProductId());
        CraftRouting craftRouting = saveCraftRouting(newCraft);
        Long versionId = vo.getVersionId();
        ProductionCraftVersion version = (ProductionCraftVersion) this.craftVersionService.getById(versionId);
        CraftVersionAddVO newVersion = new CraftVersionAddVO();
        newVersion.setName(version.getName());
        newVersion.setDescription(version.getDescription());
        newVersion.setGroupIds(getGroupIds(versionId));
        ProductionCraftVersionVO craftVersion = this.craftVersionService.saveCraftVersion(craftRouting.getId(), newVersion);
        List<ProductionCraftProcess> processList = this.craftProcessService.list((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcess.class).eq((v0) -> {
            return v0.getVersionId();
        }, version.getId()));
        ProcessParallelSaveVO saveVO = copyProductNewCraftProcess(craftVersion.getId(), processList);
        List<ProductionCraftProcessVO> vos = this.craftProcessService.parallelSave(saveVO);
        return Func.isNotEmpty(vos);
    }
 
    private ProcessParallelSaveVO copyProductNewCraftProcess(Long versionId, List<ProductionCraftProcess> processList) {
        ProcessParallelSaveVO vo = new ProcessParallelSaveVO();
        if (Func.isNotEmpty(processList)) {
            List<Long> processIds = (List) processList.stream().map((v0) -> {
                return v0.getId();
            }).collect(Collectors.toList());
            Map<Long, List<ProductionCraftProcessRelatedFixture>> processFixtureMap = (Map) this.relatedFixtureService.list((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcessRelatedFixture.class).in((v0) -> {
                return v0.getVersionProcessId();
            }, processIds)).stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getVersionProcessId();
            }));
            Map<Long, List<ProductionCraftProcessRelatedTool>> processToolMap = (Map) this.relatedToolService.list((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcessRelatedTool.class).in((v0) -> {
                return v0.getVersionProcessId();
            }, processIds)).stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getVersionProcessId();
            }));
            Map<Long, List<ProductionCraftProcessFile>> processFileMap = (Map) this.processFileService.list((Wrapper) Wrappers.lambdaQuery(ProductionCraftProcessFile.class).in((v0) -> {
                return v0.getVersionProcessId();
            }, processIds)).stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getVersionProcessId();
            }));
            List<VersionProcessAddVO> collect = (List) processList.stream().filter(c -> {
                return Func.isNull(c.getMainSequenceId()) && Func.notNull(c.getProcessId());
            }).map(process -> {
                return getVersionProcessAddVO(processFixtureMap, processToolMap, processFileMap, process);
            }).collect(Collectors.toList());
            List<ProductionCraftProcess> list = (List) processList.stream().filter(c2 -> {
                return Func.notNull(c2.getMainSequenceId()) || Func.isNull(c2.getProcessId());
            }).collect(Collectors.toList());
            List<ParallelProVO> parallelProcessList = Lists.newArrayList();
            list.stream().filter(l1 -> {
                return Func.isNull(l1.getProcessId());
            }).forEach(l12 -> {
                ParallelProVO proVO = new ParallelProVO();
                proVO.setProcessCode(l12.getProcessCode());
                proVO.setProcessName(l12.getProcessName());
                proVO.setSort(l12.getSort());
                proVO.setSourceId(l12.getSourceId());
                proVO.setTargetId(l12.getTargetId());
                proVO.setXCoordinate(l12.getXCoordinate());
                proVO.setYCoordinate(l12.getYCoordinate());
                proVO.setHeight(l12.getHeight());
                List<VersionProcessAddVO> vos = (List) list.stream().filter(l2 -> {
                    return l12.getId().equals(l2.getMainSequenceId());
                }).map(process2 -> {
                    return getVersionProcessAddVO(processFixtureMap, processToolMap, processFileMap, process2);
                }).collect(Collectors.toList());
                proVO.setChildProcessList(vos);
                parallelProcessList.add(proVO);
            });
            vo.setNormalProcessList(collect);
            vo.setParallelProcessList(parallelProcessList);
        }
        vo.setVersionId(versionId);
        return vo;
    }
 
    /* JADX INFO: Access modifiers changed from: private */
    public static VersionProcessAddVO getVersionProcessAddVO(Map<Long, List<ProductionCraftProcessRelatedFixture>> processFixtureMap, Map<Long, List<ProductionCraftProcessRelatedTool>> processToolMap, Map<Long, List<ProductionCraftProcessFile>> processFileMap, ProductionCraftProcess process) {
        VersionProcessAddVO processAddVO = ProductionCraftProcessConvert.INSTANCE.convertAdd(process);
        List<ProductionCraftProcessRelatedFixture> fixtures = processFixtureMap.get(process.getId());
        if (Func.isNotEmpty(fixtures)) {
            List<ProductionCraftProcessRelatedFixtureVO> fixtureAddList = (List) fixtures.stream().map(c -> {
                return new ProductionCraftProcessRelatedFixtureVO().setFixtureId(c.getFixtureId()).setVersionProcessId(c.getVersionProcessId()).setFixtureCode(c.getFixtureCode()).setFixtureName(c.getFixtureName()).setFixtureGroupName(c.getFixtureGroupName());
            }).collect(Collectors.toList());
            processAddVO.setFixtures(fixtureAddList);
        }
        List<ProductionCraftProcessFile> files = processFileMap.get(process.getId());
        if (Func.isNotEmpty(files)) {
            List<ProductionCraftProcessFileVO> fileAddList = (List) files.stream().map(c2 -> {
                return new ProductionCraftProcessFileVO().setFileName(c2.getFileName()).setObjectKey(c2.getObjectKey()).setContentType(c2.getContentType()).setLink(c2.getLink()).setFileSize(c2.getFileSize()).setUploadTime(c2.getUploadTime()).setVersionProcessId(c2.getVersionProcessId());
            }).collect(Collectors.toList());
            processAddVO.setFiles(fileAddList);
        }
        List<ProductionCraftProcessRelatedTool> tools = processToolMap.get(process.getId());
        if (Func.isNotEmpty(tools)) {
            List<ProductionCraftProcessRelatedToolVO> toolAddList = (List) tools.stream().map(c3 -> {
                return new ProductionCraftProcessRelatedToolVO().setToolId(c3.getToolId()).setVersionProcessId(c3.getVersionProcessId()).setToolCode(c3.getToolCode()).setToolCategoryName(c3.getToolCategoryName()).setToolModelName(c3.getToolModelName());
            }).collect(Collectors.toList());
            processAddVO.setTools(toolAddList);
        }
        return processAddVO;
    }
 
    private List<Long> getGroupIds(Long versionId) {
        return this.versionLineService.listObjs((Wrapper) Wrappers.lambdaQuery(CraftVersionLine.class).select(new SFunction[]{(v0) -> {
            return v0.getGroupId();
        }}).eq((v0) -> {
            return v0.getVersionId();
        }, versionId), c -> {
            if (c instanceof BigDecimal) {
                return Long.valueOf(((BigDecimal) c).longValue());
            }
            return (Long) c;
        });
    }
 
    private void setProduce(CraftRoutingDetailVO vo, Long id) {
        CraftRouting craft = (CraftRouting) getById(id);
        ThrowFun.isTrue(Func.isNull(craft)).throwMessage(MessageUtils.message("cps.craft.not.exist", new Object[0]));
        vo.setId(id);
        vo.setName(craft.getName());
        vo.setDescription(craft.getDescription());
        vo.setStatus(craft.getStatus());
        vo.setProductId(craft.getProductId());
        Long productId = craft.getProductId();
        if (!Func.isNull(productId)) {
            Product product = (Product) this.productService.getById(productId);
            if (!Func.isNull(product)) {
                vo.setProductCode(product.getCode());
                vo.setProductName(product.getName());
            }
        }
    }
 
    private void setCraftVersion(CraftRoutingDetailVO vo, Long id) {
        List<CraftVersionDTO> craftVersionList = this.craftVersionService.listVersion(id);
        vo.setDtos(craftVersionList);
    }
 
    private QueryWrapper<CraftRouting> getWrapper(SearchVO vo) {
        List<SearchVO.KV> param = vo.getParams();
        Map<String, String> params = (Map) param.stream().collect(Collectors.toMap((v0) -> {
            return v0.getKey();
        }, (v0) -> {
            return v0.getValue();
        }));
        Kv exclude = Kv.create().set("Blade-Auth", "Blade-Auth").set("current", "current").set("size", "size").set("ascs", "ascs").set("descs", "descs");
        exclude.forEach(k, v -> {
            String str = (String) params.remove(k);
        });
        QueryWrapper<CraftRouting> wrapper = new QueryWrapper<>();
        if (Func.isNotEmpty(params)) {
            params.forEach(k2, v2 -> {
                if (k2.endsWith(CraftConstant.LIKE)) {
                    wrapper.likeRight("bcr." + getColumn(k2, CraftConstant.LIKE), v2);
                } else if (k2.endsWith(CraftConstant.ASC)) {
                    wrapper.orderByAsc("bcr." + getColumn(k2, CraftConstant.ASC));
                } else if (k2.endsWith(CraftConstant.DESC)) {
                    wrapper.orderByDesc("bcr." + getColumn(k2, CraftConstant.DESC));
                }
            });
        }
        return wrapper;
    }
 
    private String getColumn(String column, String keyword) {
        return StringUtil.humpToUnderline(StringUtil.removeSuffix(column, keyword));
    }
 
    private CraftRouting saveCraftRouting(CraftRoutingAddVO vo) {
        String name = vo.getName();
        validNameExist(null, name);
        CraftRouting craftRouting = new CraftRouting().setName(name).setDescription(vo.getDescription()).setProductId(vo.getProductId());
        save(craftRouting);
        return craftRouting;
    }
 
    private void validNameExist(Long id, String name) {
        long count = count((Wrapper) Wrappers.lambdaQuery(CraftRouting.class).ne(Func.isNotEmpty(id), (v0) -> {
            return v0.getId();
        }, id).eq((v0) -> {
            return v0.getName();
        }, name));
        ThrowFun.isTrue(count > 0).throwMessage(MessageUtils.message("cps.craft.name.exist", new Object[0]));
    }
}