yangys
2024-11-02 27eb2df01ab873bc7f1451ff5865ed66b2876159
smart-man-boot/src/main/java/com/qianwen/smartman/modules/smis/service/impl/WorkstationServiceImpl.java
@@ -87,7 +87,6 @@
import com.qianwen.smartman.modules.smis.service.ICalendarService;
import com.qianwen.smartman.modules.smis.service.ICommonGroupOfItemService;
import com.qianwen.smartman.modules.smis.service.ICommonGroupService;
import com.qianwen.smartman.modules.smis.service.IDmpVariablesService;
import com.qianwen.smartman.modules.smis.service.IMachineService;
import com.qianwen.smartman.modules.smis.service.IWorkstationOfMachineService;
import com.qianwen.smartman.modules.smis.service.IWorkstationService;
@@ -135,8 +134,7 @@
    private WorkstationMapper workstationMapper;
    @Autowired
    private OssBuilder ossBuilder;
    @Autowired
    private IDmpVariablesService dmpVariablesService;
    @Autowired
    private IWorkstationWorkbenchService workbenchService;
@@ -589,65 +587,11 @@
        return manualBuildIPage(query, buildProperties(result, dto.getDeviceStatus()));
    }
    @Override
    public List<RealTimeStatusVO> getRealTimeProperties(Long workstationId, Long machineId) {
        List<RealTimeStatusVO> properties = new ArrayList<>();
        Map<String, Object> map = WorkstationCache.getWorkstationRealTime(String.valueOf(workstationId));
        List<DmpVariablesVO> list = this.dmpVariablesService.getDmpVariablesByWorkstationId(workstationId);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(dmpVariablesVO -> {
                RealTimeStatusVO vo = new RealTimeStatusVO();
                vo.setKey(dmpVariablesVO.getName());
                vo.setName(dmpVariablesVO.getDescription());
                vo.setUnit(dmpVariablesVO.getDmpType());
                vo.setSort(dmpVariablesVO.getIdx());
                vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
                vo.setBigScreen(dmpVariablesVO.getBigScreen());
                vo.setRealTimeData(dmpVariablesVO.getRealTimeData());
                if (map.containsKey(dmpVariablesVO.getName())) {
                    TelemetryDataResponseDTO t = (TelemetryDataResponseDTO) MapUtils.getObject(map, dmpVariablesVO.getName());
                    vo.setValue(t.getV());
                }
                properties.add(vo);
            });
        }
        return properties;
    }
    public Map<Long, List<RealTimeStatusVO>> getRealTimeProperties(List<Long> workstationIdList) {
        Map<Long, List<RealTimeStatusVO>> properties = new HashMap<>();
        //在这里!!!!
        //顶顶顶顶
        //List<DmpVariablesVO> list = this.dmpVariablesService.getDmpVariablesByWorkstationIds(workstationIdList);
        //this.wsDpService.getDatapointsByWorkstationIds();
        //if (Func.isNotEmpty(list)) {
           /*
            Map<Long, List<DmpVariablesVO>> dmpVariablesMap =list.stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getWorkstationId();
            }));
            dmpVariablesMap.forEach((workstationId, dmpVariablesVOList) -> {
                ArrayList<RealTimeStatusVO> arrayList = new ArrayList<>();
                Map<String, Object> map = WorkstationCache.getWorkstationRealTime(String.valueOf(workstationId));//应该有数据,因为缓存没有,直接查的queryLastParameter
                dmpVariablesVOList.forEach(dmpVariablesVO -> {
                    RealTimeStatusVO vo = new RealTimeStatusVO();
                    vo.setKey(dmpVariablesVO.getName());
                    vo.setName(dmpVariablesVO.getDescription());
                    vo.setUnit(dmpVariablesVO.getDmpType());
                    vo.setSort(dmpVariablesVO.getIdx());
                    vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
                    vo.setBigScreen(dmpVariablesVO.getBigScreen());
                    vo.setRealTimeData(dmpVariablesVO.getRealTimeData());
                    if (map.containsKey(dmpVariablesVO.getName())) {
                        TelemetryDataResponseDTO t = (TelemetryDataResponseDTO) MapUtils.getObject(map, dmpVariablesVO.getName());
                        vo.setValue(t.getV());
                    }
                    arrayList.add(vo);
                });
                properties.put(workstationId, arrayList);
            });
            */
        //}
        //yangys修改,改为数据点位的方式
        for(Long workstationId: workstationIdList) {
          
@@ -667,7 +611,7 @@
                RealTimeStatusVO vo = new RealTimeStatusVO();
                prop = cfgRow.getString("dpName");
                   vo.setKey(prop);
                   /*
                   label = prop;
                   if(StringUtils.equals("DeviceStatus", prop)) {
                      label = "状态";
@@ -675,11 +619,9 @@
                      label = "产量";
                   }else if(StringUtils.equals("AlarmNo", prop)) {
                      label = "告警号";
                   }
                   vo.setName(label);
                   //vo.setUnit(headRow.getString("dpUnit"));
                   }*/
                   vo.setName(cfgRow.getString("dpLabel"));
                   vo.setSort(i);
                   //vo.setWcsDataType(dmpVariablesVO.getWcsDataType());
                   vo.setBigScreen(false);
                   vo.setRealTimeData(true);
                   
@@ -1041,7 +983,7 @@
        }
        return null;
    }
    /*
    @Override 
    public List<DmpVariablesVO> getDmpVariables(String workstationId, String machineId) {
        if (Func.isBlank(machineId)) {
@@ -1052,6 +994,7 @@
            return v0.getRealTimeData();
        }).collect(Collectors.toList());
    }
    */
    private void checkWorkstation(WorkstationSubmitVO workstationSubmitVO) {
        if (Func.isNotEmpty(workstationSubmitVO.getCode()) && workstationSubmitVO.getCode().length() > 24) {