| | |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcDeviceCalendarMapper; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.EquipmentCalendarVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return mdcDeviceCalendarVos; |
| | | } |
| | | |
| | | @Override |
| | | public String findShiftByEquId(String equipmentId) { |
| | | String result = ""; |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | String date = now.format(formatter); |
| | | String format = DateUtils.format(DateUtils.toDate(date, DateUtils.STRDATE), DateUtils.STR_DATE); |
| | | List<MdcShiftSub> shiftSubList = this.baseMapper.findShiftByEquId(equipmentId, date); |
| | | if (shiftSubList != null && !shiftSubList.isEmpty()) { |
| | | for (MdcShiftSub mdcShiftSub : shiftSubList) { |
| | | LocalDateTime startDate = DateUtils.toDate(format + " " + mdcShiftSub.getStartDate(), DateUtils.STR_DATE_TIME_SMALL).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | LocalDateTime endDate = DateUtils.toDate(format + " " + mdcShiftSub.getEndDate(), DateUtils.STR_DATE_TIME_SMALL).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | if ("true".equals(mdcShiftSub.getIsDaySpan())) { |
| | | endDate = endDate.plusDays(1); |
| | | } |
| | | if (now.isAfter(startDate) && now.isBefore(endDate)) { |
| | | result = mdcShiftSub.getShiftSubName(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(result)) { |
| | | LocalDateTime yesterday = now.plusDays(-1); |
| | | String yes = yesterday.format(formatter); |
| | | String previous = DateUtils.format(DateUtils.toDate(yes, DateUtils.STRDATE), DateUtils.STR_DATE); |
| | | List<MdcShiftSub> shiftSubs = this.baseMapper.findShiftByEquId(equipmentId, previous); |
| | | if (shiftSubs != null && !shiftSubs.isEmpty()) { |
| | | for (MdcShiftSub mdcShiftSub : shiftSubs) { |
| | | LocalDateTime startDate = DateUtils.toDate(format + " " + mdcShiftSub.getStartDate(), DateUtils.STR_DATE_TIME_SMALL).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | LocalDateTime endDate = DateUtils.toDate(format + " " + mdcShiftSub.getEndDate(), DateUtils.STR_DATE_TIME_SMALL).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | if ("true".equals(mdcShiftSub.getIsDaySpan())) { |
| | | endDate = endDate.plusDays(1); |
| | | } |
| | | if (now.isAfter(startDate) && now.isBefore(endDate)) { |
| | | result = mdcShiftSub.getShiftSubName(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | } |