| | |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.qianwen.smartman.common.constant.DateConstant; |
| | | import com.qianwen.smartman.common.enums.GlobalWcsTypeEnum; |
| | | import com.qianwen.smartman.common.utils.LocalDateTimeUtils; |
| | | import com.qianwen.smartman.modules.cps.dto.WorkstationWcsDmpDTO; |
| | | import com.qianwen.smartman.modules.cps.entity.GlobalWcs; |
| | | import com.qianwen.smartman.modules.cps.entity.Workstation; |
| | | import com.qianwen.smartman.modules.cps.enums.TrayEnum; |
| | | import com.qianwen.smartman.modules.cps.enums.WorkstationTypeEnum; |
| | | import com.qianwen.smartman.modules.cps.mapper.WorkstationMapper; |
| | | import com.qianwen.smartman.modules.cps.message.dto.TelemetryDataResponseDTO; |
| | | import com.qianwen.smartman.modules.cps.service.IGlobalWcsService; |
| | | import com.qianwen.smartman.modules.cps.service.IWorkstationService; |
| | | import com.qianwen.smartman.modules.smis.dto.WorkstationWcsDmpDTO; |
| | | import com.qianwen.smartman.modules.smis.entity.GlobalWcs; |
| | | import com.qianwen.smartman.modules.smis.entity.Workstation; |
| | | import com.qianwen.smartman.modules.smis.enums.TrayEnum; |
| | | import com.qianwen.smartman.modules.smis.enums.WorkstationTypeEnum; |
| | | import com.qianwen.smartman.modules.smis.mapper.WorkstationMapper; |
| | | import com.qianwen.smartman.modules.smis.message.dto.TelemetryDataResponseDTO; |
| | | import com.qianwen.smartman.modules.smis.service.IGlobalWcsService; |
| | | import com.qianwen.smartman.modules.smis.service.IWorkstationService; |
| | | import com.qianwen.smartman.modules.mdc.entity.WorkstationCollectData; |
| | | import com.qianwen.smartman.modules.mdc.mapper.SuperAggregateStateMapper; |
| | | import com.qianwen.smartman.modules.mdc.mapper.SuperAlarmMapper; |
| | |
| | | public class WorkstationAnalysisServiceImpl implements IWorkstationAnalysisService { |
| | | private static final Logger log = LoggerFactory.getLogger(WorkstationAnalysisServiceImpl.class); |
| | | public static final String STATUS = "STATUS"; |
| | | private final SuperAggregateStateMapper superAggregateStateMapper; |
| | | private final SuperAlarmMapper superAlarmMapper; |
| | | private final IGlobalWcsService globalWcsService; |
| | | private final WorkstationMapper workstationMapper; |
| | | private final SuperProcessParameterMapper superProcessParameterMapper; |
| | | private final IWorkstationService workstationService; |
| | | |
| | | @Autowired |
| | | private SuperAggregateStateMapper superAggregateStateMapper; |
| | | @Autowired |
| | | private SuperAlarmMapper superAlarmMapper; |
| | | @Autowired |
| | | private IGlobalWcsService globalWcsService; |
| | | @Autowired |
| | | private WorkstationMapper workstationMapper; |
| | | @Autowired |
| | | private IWorkstationService workstationService; |
| | | @Autowired |
| | | private IProcessParameterService processParameterService; |
| | | |
| | | public WorkstationAnalysisServiceImpl(final SuperAggregateStateMapper superAggregateStateMapper, final SuperAlarmMapper superAlarmMapper, final IGlobalWcsService globalWcsService, final WorkstationMapper workstationMapper, final SuperProcessParameterMapper superProcessParameterMapper, final IWorkstationService workstationService,IProcessParameterService aProcessParameterService) { |
| | | this.superAggregateStateMapper = superAggregateStateMapper; |
| | | this.superAlarmMapper = superAlarmMapper; |
| | | this.globalWcsService = globalWcsService; |
| | | this.workstationMapper = workstationMapper; |
| | | this.superProcessParameterMapper = superProcessParameterMapper; |
| | | this.workstationService = workstationService; |
| | | this.processParameterService = aProcessParameterService; |
| | | } |
| | | |
| | | @Override |
| | | public List<StatusAnalysisWorkstationVO> statusByWorkstation(String workstationId) { |
| | |
| | | List<AlarmAnalysisWorkstationVO> result; |
| | | try { |
| | | result = this.superAlarmMapper.alarmByWorkstation(workstationId, Integer.valueOf((query.getCurrent() - 1) * query.getSize()), query.getSize()); |
| | | result.forEach(a -> { |
| | | a.setAlarmTime(DateUtil.formatDateTime(new Date(a.getTime().getTime()))); |
| | | }); |
| | | total = this.superAlarmMapper.alarmByWorkstationTotal(workstationId); |
| | | } catch (Exception e) { |
| | | log.error("查询报警异常",e); |
| | |
| | | List<Workstation> workstationList = this.workstationService.list(Wrappers.<Workstation>lambdaQuery() |
| | | .eq(Workstation::getType, WorkstationTypeEnum.MACHINE.getCode()) |
| | | .eq(Workstation::getStatus, TrayEnum.StatusEnum.ACTIVATING.getStatus())); |
| | | /* |
| | | List<Workstation> workstationList = this.workstationService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getType(); |
| | | }, WorkstationTypeEnum.MACHINE.getCode())).eq((v0) -> { |
| | | return v0.getStatus(); |
| | | }, TrayEnum.StatusEnum.ACTIVATING.getStatus()));*/ |
| | | |
| | | if (Func.isEmpty(workstationList)) { |
| | | return wcsList.stream().map(c -> { |
| | | return DeviceStatusStatisticsVO.builder().status(c.getCode()).statusName(c.getName()).deviceNum(0L).build(); |
| | |
| | | |
| | | Set<String> wIds = workstationList.stream().map(Workstation::getId).map(String::valueOf).collect(Collectors.toSet()); |
| | | |
| | | //下面是查询设备的最新状态值 |
| | | //deviceMap key为wcs的code值,value是设备数量(该状态的) |
| | | Map<String, Long> deviceMap = wIds.stream().map(wId -> { |
| | | Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(wId); |
| | | |
| | | //下面的缓存是TelemetryDataRealTimeConsumer中设置的(接收数据)。需要再collect中设置,避免格式问题,我们不需要这么干了,直接查询 |
| | | Map<String, Object> realTimeData = WorkstationCache.getWorkstationAllCollect(wId); |
| | | //WorkstationWcsDmpDTO dmpDTO = WorkstationCache.getDmpStatus(wId);//这里使用了blade_workstation_wcs blade_dmp_variables表,考虑去掉了,我们没有dmp |
| | | WorkstationWcsDmpDTO dmpDTO = new WorkstationWcsDmpDTO(); |
| | | dmpDTO.setName("DeviceStatus"); |
| | |
| | | return dto.getV(); |
| | | } |
| | | |
| | | //如果缓存没有数据 |
| | | //this error |
| | | //如果以上从缓存没有拿到数据(我们肯定没有缓存,不知道缓存哪儿来的),查询最新时序数据 |
| | | //List<WorkstationCollectData> workstationCollectData = this.superProcessParameterMapper.queryLastParameter(wId);//该工位最新的last(ts),last(v) |
| | | |
| | | List<WorkstationCollectData> workstationCollectData = processParameterService.lastParameter(Long.parseLong(wId)); |
| | | |
| | | List<WorkstationCollectData> workstationCollectData = processParameterService.queryLastParameter(Long.parseLong(wId)); |
| | | if (Func.isNotEmpty(workstationCollectData)) { |
| | | //resultMapping ,key:n ,value:TelemetryDataResponseDTO{last(ts),last(v)} |
| | | Map<String, Object> resultMapping = workstationCollectData.stream().collect(Collectors.toMap((v0) -> { |