| | |
| | | /** |
| | | * 加入固定点,原workStationStateFixPoint |
| | | * @param dateTime 打固定点的日期 |
| | | * @param includeWorkstationIds |
| | | * @param includeWorkstationIds 指定打固定点的工位id,全都打点传null |
| | | */ |
| | | public void deviceStateFixPoint(DateTime dateTime, List<String> includeWorkstationIds) { |
| | | List<DeviceState> result; |
| | | |
| | | Map<Long, WorkstationDTO> workStations = workstationCache.getWorkStations(); |
| | | Map<String, WorkstationDTO> workStations = workstationCache.getWorkstations(); |
| | | if (ObjectUtil.isEmpty(workStations)) { |
| | | return; |
| | | } |
| | |
| | | tablet.addValue("rps", i, state.getRps()); |
| | | tablet.addValue("is_fix_point", i, state.getIsFixPoint()); |
| | | tablet.addValue("is_sync", i, state.getIsSync()); |
| | | tablet.addValue("is_plan", i, state.getIsPlan()); |
| | | tablet.addValue("is_plan", i, state.getIsPlan()==null ? -1 : state.getIsPlan()); |
| | | tablet.addValue("feedback_point_type", i, state.getFeedbackPointType()); |
| | | tablet.addValue("feedback_id", i, state.getFeedbackId()); |
| | | tablet.addValue("feedback_id", i, state.getFeedbackId() == null?0:state.getFeedbackId()); |
| | | tablet.addValue("is_deleted", i, state.getIsDeleted()); |
| | | tablet.addValue("employee_id", i, state.getEmployeeId()); |
| | | tablet.addValue("employee_id", i, state.getEmployeeId() == null?0:state.getEmployeeId()); |
| | | |
| | | } |
| | | try { |
| | | this.iotdbConfig.getSessionPool().insertAlignedTablet(tablet); |
| | | } catch (Exception e) { |
| | | log.error("保存固定点数据异常",e); |
| | | log.error("保存state固定点数据异常",e); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | private List<DeviceState> getDefaultShift24HourPointDTOS(Long workStationId, String calendarCode, CalendarShiftInfoDTO shift) { |
| | |
| | | return default24HourPointDTOList; |
| | | } |
| | | |
| | | /** |
| | | * 填充设备状态的班次信息 |
| | | * @param calendarShiftList |
| | | * @param default24HourPointDTOList |
| | | * @param state |
| | | */ |
| | | private void packCalendarShiftInfoForTimePoint(List<CalendarShiftInfoDTO> calendarShiftList, List<DeviceState> default24HourPointDTOList, DeviceState state) { |
| | | if (Func.isNotEmpty(calendarShiftList)) { |
| | | CalendarShiftInfoDTO relatedShift = calendarShiftList.stream().filter(item -> { |
| | | return item.getStartTime().getTime() <= state.getTime().longValue() && item.getEndTime().getTime() > state.getTime().longValue(); |
| | | }).findFirst().orElse(null); |
| | | |
| | | if (Func.isNotEmpty(relatedShift)) { |
| | | state.setShiftIndex(relatedShift.getShiftIndex()); |
| | | state.setShiftTimeType(relatedShift.getShiftTimeType()); |
| | | state.setFactoryYear(relatedShift.getFactoryYear()); |
| | | state.setFactoryMonth(relatedShift.getFactoryMonth()); |
| | | state.setFactoryWeek(relatedShift.getFactoryWeek()); |
| | | String factoryDate = relatedShift.getFactoryDate(); |
| | | String[] split = Func.split(factoryDate, "-"); |
| | | state.setFactoryDate(Integer.valueOf(String.join("", split))); |
| | | state.setIsDeleted(Boolean.FALSE); |
| | | default24HourPointDTOList.add(state); |
| | | return; |
| | | } |
| | | log.warn("工位{} 日历{} 未找到整点班次信息", state.getWorkstationId(), state.getCalendarCode()); |
| | | return; |
| | | if (Func.isEmpty(calendarShiftList)) { |
| | | log.error("工位{} 日历{} 无日期:[{}]的班次信息", new Object[]{state.getWorkstationId(), state.getCalendarCode(), state.getTime()}); |
| | | return; |
| | | } |
| | | |
| | | CalendarShiftInfoDTO relatedShift = calendarShiftList.stream().filter(item -> { |
| | | return item.getStartTime().getTime() <= state.getTime() && item.getEndTime().getTime() > state.getTime(); |
| | | }).findFirst().orElse(null); |
| | | |
| | | if (Func.isNotEmpty(relatedShift)) { |
| | | state.setShiftIndex(relatedShift.getShiftIndex()); |
| | | state.setShiftTimeType(relatedShift.getShiftTimeType()); |
| | | state.setFactoryYear(relatedShift.getFactoryYear()); |
| | | state.setFactoryMonth(relatedShift.getFactoryMonth()); |
| | | state.setFactoryWeek(relatedShift.getFactoryWeek()); |
| | | String factoryDate = relatedShift.getFactoryDate(); |
| | | String[] split = Func.split(factoryDate, "-"); |
| | | state.setFactoryDate(Integer.valueOf(String.join("", split))); |
| | | state.setIsDeleted(false); |
| | | default24HourPointDTOList.add(state); |
| | | }else { |
| | | log.warn("工位{} 日历{} 未找到固定点班次信息", state.getWorkstationId(), state.getCalendarCode()); |
| | | } |
| | | log.error("工位{} 日历{} 无自然天{}班次信息", new Object[]{state.getWorkstationId(), state.getCalendarCode(), state.getTime()}); |
| | | } |
| | | |
| | | //不一定能用上 |
| | |
| | | workstationState.setShiftIndex(CommonConstant.DEFAULT_SHIFT_INDEX); |
| | | workstationState.setShiftTimeType(CommonConstant.DEFAULT_SHIFT_TYPE); |
| | | workstationState.setFeedbackPointType(FeedbackTimePointEnum.NO_FEED_BACK_POINT.getValue()); |
| | | workstationState.setIsDeleted(Boolean.FALSE); |
| | | workstationState.setIsDeleted(false); |
| | | } |
| | | } |
| | | } |