yangys
2024-04-01 14f1953b1944b3e53d8312e151902c4695faa2e1
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
package com.qianwen.smartman.modules.mdc.service.impl;
 
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import com.qianwen.smartman.common.cache.cps.WorkstationCache;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.dto.WorkstationRealTimeStatusDTO;
import com.qianwen.smartman.modules.cps.entity.WorkstationOfMachine;
import com.qianwen.smartman.modules.cps.mapper.WorkstationMapper;
import com.qianwen.smartman.modules.cps.message.dto.TelemetryDataResponseDTO;
import com.qianwen.smartman.modules.cps.service.IDmpVariablesService;
import com.qianwen.smartman.modules.cps.service.IWorkstationOfMachineService;
import com.qianwen.smartman.modules.cps.vo.DmpStatusVariableVO;
import com.qianwen.smartman.modules.cps.vo.DmpVariablesVO;
import com.qianwen.smartman.modules.mdc.service.IRealTimeDataService;
import com.qianwen.smartman.modules.mdc.vo.WorkstationVO;
import org.springframework.stereotype.Service;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/service/impl/RealTimeDataServiceImpl.class */
public class RealTimeDataServiceImpl implements IRealTimeDataService {
    private final WorkstationMapper workstationMapper;
    private final IWorkstationOfMachineService workstationOfMachineService;
    private final IDmpVariablesService dmpVariablesService;
 
    public RealTimeDataServiceImpl(final WorkstationMapper workstationMapper, final IWorkstationOfMachineService workstationOfMachineService, final IDmpVariablesService dmpVariablesService) {
        this.workstationMapper = workstationMapper;
        this.workstationOfMachineService = workstationOfMachineService;
        this.dmpVariablesService = dmpVariablesService;
    }
 
    @Override // org.springblade.modules.mdc.service.IRealTimeDataService
    public List<DmpStatusVariableVO> getWorkstationRealTimeStatus(WorkstationVO workstationVO) {
        List<Long> workstationIdList = workstationVO.getWorkstationIdList();
        if (Func.isEmpty(workstationIdList)) {
            List<String> workstationGroupIdList = (List) workstationVO.getWorkstationGroupIdList().stream().map(x -> {
                return String.valueOf(x);
            }).collect(Collectors.toList());
            WorkstationRealTimeStatusDTO workstationRealTimeStatusDTO = new WorkstationRealTimeStatusDTO();
            workstationRealTimeStatusDTO.setWorkStationGroupIdList(workstationGroupIdList);
            workstationIdList = (List) this.workstationMapper.getWorkstationListByWorkStationGroupIdList(null, workstationRealTimeStatusDTO).stream().map((v0) -> {
                return v0.getId();
            }).collect(Collectors.toList());
        }
        List<DmpStatusVariableVO> dmpStatusVariableList = this.dmpVariablesService.getDmpVariablesByWorkstationIdList(workstationIdList);
        dmpStatusVariableList.forEach(x2 -> {
            Map<String, Object> map = WorkstationCache.getWorkstationRealTime(String.valueOf(x2.getWorkstationId()));
            if (map.containsKey(x2.getVariableKey())) {
                TelemetryDataResponseDTO t = (TelemetryDataResponseDTO) MapUtils.getObject(map, x2.getVariableKey());
                x2.setVariableValue(t.getV());
            }
        });
        return dmpStatusVariableList;
    }
 
    @Override // org.springblade.modules.mdc.service.IRealTimeDataService
    public List<DmpVariablesVO> getWorkstationDmpVariables(Long workstationId) {
        WorkstationOfMachine workstationOfMachine = this.workstationOfMachineService.getWorkstationOfMachineByWorkstationId(workstationId);
        if (Func.isEmpty(workstationOfMachine)) {
            throw new ServiceException(MessageUtils.message("workstation.not.turn.on.acquisition.function", new Object[0]));
        }
        List<DmpVariablesVO> dmpVariables = this.dmpVariablesService.getDmpVariablesByWorkstationId(Long.valueOf(workstationId.longValue()));
        return (List) dmpVariables.stream().filter((v0) -> {
            return v0.getRealTimeData();
        }).collect(Collectors.toList());
    }
}