From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 93 insertions(+), 0 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java new file mode 100644 index 0000000..e914e8e --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java @@ -0,0 +1,93 @@ +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); + } + +} -- Gitblit v1.9.3