¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.board.vo.EquDowntimeInfo; |
| | | import org.jeecg.modules.mdc.dto.MdcDowntimeDto; |
| | | import org.jeecg.modules.mdc.entity.MdcDowntime; |
| | | import org.jeecg.modules.mdc.mapper.MdcDowntimeMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcDowntimeService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.MdcDowntimeVo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: å¾
æºåæºè¡¨ |
| | | * @Author: lius |
| | | * @Date: 2025-03-12 |
| | | */ |
| | | @Service |
| | | public class MdcDowntimeServiceImpl extends ServiceImpl<MdcDowntimeMapper, MdcDowntime> implements IMdcDowntimeService { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param userId |
| | | * @param page |
| | | * @param mdcDowntimeVo |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<MdcDowntimeDto> pageList(String userId, Page<MdcDowntimeDto> page, MdcDowntimeVo mdcDowntimeVo, HttpServletRequest req) { |
| | | // è·å设å¤IDå表 |
| | | List<String> equipmentIds = getEquipmentIds(userId, mdcDowntimeVo); |
| | | |
| | | // å¦æè®¾å¤IDå表为空ï¼ç´æ¥è¿å空å页 |
| | | if (equipmentIds == null || equipmentIds.isEmpty()) { |
| | | return new Page<>(page.getCurrent(), page.getSize(), 0); |
| | | } |
| | | |
| | | // 设置设å¤IDåè¡¨å°æ¥è¯¢æ¡ä»¶ä¸ |
| | | mdcDowntimeVo.setEquipmentIdList(equipmentIds); |
| | | |
| | | // æ§è¡å页æ¥è¯¢ |
| | | return this.baseMapper.pageList(page, mdcDowntimeVo); |
| | | } |
| | | |
| | | @Override |
| | | public Integer findPlanTimeDuration(String equipmentId, String validDate, String closeType) { |
| | | int result = 0; |
| | | List<MdcDowntime> mdcDowntimeList = this.baseMapper.findPlanTimeDuration(equipmentId, validDate, closeType); |
| | | if (mdcDowntimeList != null && !mdcDowntimeList.isEmpty()) { |
| | | for (MdcDowntime mdcDowntime : mdcDowntimeList) { |
| | | result = DateUtils.differentMinutes(mdcDowntime.getStartDate(), mdcDowntime.getEndDate()) + result; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<EquDowntimeInfo> equDowntimeStatistics(List<String> equipmentIdList, String start, String end) { |
| | | return this.baseMapper.equDowntimeStatistics(equipmentIdList, start, end); |
| | | } |
| | | |
| | | private List<String> getEquipmentIds(String userId, MdcDowntimeVo mdcDowntimeVo) { |
| | | if (StringUtils.isNotEmpty(mdcDowntimeVo.getEquipmentId())) { |
| | | return Collections.singletonList(mdcDowntimeVo.getEquipmentId()); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(mdcDowntimeVo.getParentId())) { |
| | | return "2".equals(mdcDowntimeVo.getTypeTree()) |
| | | ? mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcDowntimeVo.getParentId()) |
| | | : mdcEquipmentService.getEquipmentIdsProduction(userId, mdcDowntimeVo.getParentId()); |
| | | } |
| | | |
| | | return "2".equals(mdcDowntimeVo.getTypeTree()) |
| | | ? mdcEquipmentService.getEquipmentIdsByDepart(userId, null) |
| | | : mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | |
| | | } |