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
package com.qianwen.smartman.modules.coproduction.service.impl;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.tool.node.ForestNodeMerger;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.coproduction.entity.PlanProcess;
import com.qianwen.smartman.modules.coproduction.mapper.PlanProcessMapper;
import com.qianwen.smartman.modules.coproduction.service.IPlanProcessService;
import com.qianwen.smartman.modules.coproduction.vo.PlanProcessVO;
import com.qianwen.smartman.modules.cps.entity.Workstation;
import com.qianwen.smartman.modules.cps.service.IWorkstationService;
import org.springframework.stereotype.Service;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/coproduction/service/impl/PlanProcessServiceImpl.class */
public class PlanProcessServiceImpl extends BaseServiceImpl<PlanProcessMapper, PlanProcess> implements IPlanProcessService {
    private final IWorkstationService workstationService;
 
    public PlanProcessServiceImpl(final IWorkstationService workstationService) {
        this.workstationService = workstationService;
    }
 
    @Override // org.springblade.modules.coproduction.service.IPlanProcessService
    public List<PlanProcessVO> listByPlanId(Long planId) {
        List<PlanProcessVO> planProcessVOList = ((PlanProcessMapper) this.baseMapper).listByPlanId(planId);
        List<Workstation> workstationList = this.workstationService.list();
        
        Map<Long, String> workstationMap = workstationList.stream().collect(Collectors.toMap(Workstation::getId, Workstation::getName));
        planProcessVOList.forEach(planProcessVO -> {
            planProcessVO.setParentId(Long.valueOf(Func.isNotEmpty(planProcessVO.getMainSequenceId()) ? planProcessVO.getMainSequenceId().longValue() : 0L));
            
            List<Long> workstationIdList = Func.toLongList(planProcessVO.getWorkstationId());
            List<Long> workstationIds = new ArrayList<>();
            workstationIdList.forEach(id -> {
                 if (workstationMap.containsKey(id)) {
                     workstationIds.add(id);
                 }
            });
 
            
            String workstationId = workstationIds.stream().map(String::valueOf).collect(Collectors.joining(","));
            String workstationName = workstationIds.stream().map(workstationMap::get).collect(Collectors.joining(","));
            planProcessVO.setWorkstationId(workstationId);
            planProcessVO.setWorkstationName(workstationName);
            
        });
        
        return ForestNodeMerger.merge(planProcessVOList);
        /*
        Map<Long, String> workstationMap = (Map) workstationList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, (v0) -> {
            return v0.getName();
        }));
        planProcessVOList.forEach(planProcessVO -> {
            planProcessVO.setParentId(Long.valueOf(Func.isNotEmpty(planProcessVO.getMainSequenceId()) ? planProcessVO.getMainSequenceId().longValue() : 0L));
            List<Long> workstationIdList = Func.toLongList(planProcessVO.getWorkstationId());
            List<Long> workstationIds = new ArrayList<>();
            workstationIdList.forEach(id -> {
                if (workstationMap.containsKey(id)) {
                    workstationIds.add(id);
                }
            });
            String workstationId = (String) workstationIds.stream().map((v0) -> {
                return String.valueOf(v0);
            }).collect(Collectors.joining(","));
            Stream<Long> stream = workstationIds.stream();
            workstationMap.getClass();
            String workstationName = (String) stream.map((v1) -> {
                return r1.get(v1);
            }).collect(Collectors.joining(","));
            planProcessVO.setWorkstationId(workstationId);
            planProcessVO.setWorkstationName(workstationName);
        });
        return ForestNodeMerger.merge(planProcessVOList);
        */
    }
}