lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcDeviceCalendarMapper.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.mdc.entity.MdcDeviceCalendar; import org.jeecg.modules.mdc.entity.MdcShiftSub; import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo; import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; @@ -33,4 +34,5 @@ List<MdcDeviceCalendarVo> listByEquipmentAndDates(@Param("equipmentId") String equipmentId, @Param("stringDates") List<String> stringDates); List<MdcShiftSub> findShiftByEquId(@Param("equipmentId") String equipmentId, @Param("date") String date); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml
@@ -152,4 +152,16 @@ t1.effective_date ASC </select> <select id="findShiftByEquId" resultType="org.jeecg.modules.mdc.entity.MdcShiftSub"> SELECT t3.* FROM mdc_device_calendar t1 LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id WHERE t1.equipment_id = #{equipmentId} AND t1.effective_date = #{date} </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcDeviceCalendarService.java
@@ -73,4 +73,9 @@ MdcDeviceCalendar getFirstData(String equipmentId); List<MdcDeviceCalendarVo> listByEquipmentIdAndDate(String equipmentId, String date); /** * 根据设备id查询当前班次名称 */ String findShiftByEquId(String equipmentId); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcBoardServiceImpl.java
@@ -22,12 +22,14 @@ import org.jeecg.modules.mdcJc.service.IMdcJcRcJobreportService; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.joda.time.LocalDateTime; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -68,6 +70,9 @@ @Resource private MdcBoardMapper mdcBoardMapper; @Resource private IMdcDeviceCalendarService mdcDeviceCalendarService; /** * 设备状态 @@ -311,8 +316,8 @@ String realName = commonAPI.translateDictFromTable("sys_user", "realname", "username", mdcBoardEquRealTImeVo.getEquipmentManager()); mdcBoardEquRealTImeVo.setEquipmentManager(realName); mdcBoardEquRealTImeVo.setAlarm("无"); if (mdcBoardEquRealTImeVo.getOporation() != null) { switch (mdcBoardEquRealTImeVo.getOporation()) { if (mdcBoardEquRealTImeVo.getOperation() != null) { switch (mdcBoardEquRealTImeVo.getOperation()) { case 1: case 2: mdcBoardEquRealTImeVo.setOporationDict("待机"); @@ -334,7 +339,7 @@ } } else { mdcBoardEquRealTImeVo.setOporationDict("关机"); mdcBoardEquRealTImeVo.setOporation(0); mdcBoardEquRealTImeVo.setOperation(0); } //设备运行数据 Map<String, Object> mapData = equipmentWorkLineService.getDataList(mdcBoardEquRealTImeVo.getSaveTableName()); @@ -383,7 +388,12 @@ } else { mdcBoardEquRealTImeVo.setReportRepairStatus("无"); } // 下次点检下次保养 // 班次 String shift = mdcDeviceCalendarService.findShiftByEquId(equipmentId); if (StringUtils.isNotBlank(shift)) { mdcBoardEquRealTImeVo.setShift(shift); } // 点检 保养 Date nextInspection = mdcBoardMapper.findInsOrMain(equipmentId, MaintenanceCategoryEnum.POINT_INSPECTION.name()); if (nextInspection != null) { mdcBoardEquRealTImeVo.setNextInspection(nextInspection); lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java
@@ -8,6 +8,7 @@ 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; @@ -18,8 +19,12 @@ 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; /** @@ -222,4 +227,47 @@ 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; } }