From 71ec1ef4d277ade4cbd76c721f3b63d21182fac0 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期五, 15 八月 2025 11:08:39 +0800 Subject: [PATCH] 停机管理新增修改 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 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 index c7dff38..08e1569 100644 --- 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 @@ -7,7 +7,6 @@ import org.jeecg.modules.mdc.dto.MdcDowntimeDto; import org.jeecg.modules.mdc.entity.MdcDowntime; import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.entity.MdcStandardProcessDuration; import org.jeecg.modules.mdc.mapper.MdcDowntimeMapper; import org.jeecg.modules.mdc.service.IMdcDowntimeService; import org.jeecg.modules.mdc.service.IMdcEquipmentService; @@ -15,6 +14,7 @@ import org.jeecg.modules.mdc.vo.MdcDowntimeVo; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -66,8 +66,6 @@ List<MdcDowntime> mdcDowntimeList = this.baseMapper.findPlanTimeDuration(equipmentId, validDate, closeType); if (mdcDowntimeList != null && !mdcDowntimeList.isEmpty()) { for (MdcDowntime mdcDowntime : mdcDowntimeList) { -// Date startDate = DateUtils.toDate(mdcDowntime.getTheDate() + " " + mdcDowntime.getStartTime(), DateUtils.STR_DATE_TIME_SMALL); -// Date endDate = DateUtils.toDate(mdcDowntime.getTheDate() + " " + mdcDowntime.getEndTime(), DateUtils.STR_DATE_TIME_SMALL); result = mdcDowntime.getDownLong() + result; } } @@ -80,22 +78,25 @@ * @return */ @Override + @Transactional(rollbackFor = Exception.class) public boolean saveDowntime(MdcDowntime mdcDowntime) { - boolean result = false; String[] equipmentIds = mdcDowntime.getEquipmentIds().split(","); + List<String> dateList = mdcDowntime.getDateList(); + List<MdcDowntime> mdcDowntimeList = new ArrayList<>(); for (String equipmentId : equipmentIds) { - MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId); - MdcDowntime downtime = new MdcDowntime(); - BeanUtils.copyProperties(mdcDowntime, downtime); - downtime.setEquipmentId(mdcEquipment.getEquipmentId()); - downtime.setEquipmentName(mdcEquipment.getEquipmentName()); - boolean b = super.save(downtime); - if (b) { - result = true; + for (String date : dateList) { + String format = DateUtils.format(DateUtils.toDate(date, DateUtils.STRDATE), DateUtils.STR_DATE); + MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId); + MdcDowntime downtime = new MdcDowntime(); + BeanUtils.copyProperties(mdcDowntime, downtime); + downtime.setEquipmentId(mdcEquipment.getEquipmentId()); + downtime.setEquipmentName(mdcEquipment.getEquipmentName()); + downtime.setTheDate(format); + mdcDowntimeList.add(downtime); } } - - return result; + this.saveBatch(mdcDowntimeList); + return true; } private List<String> getEquipmentIds(String userId, MdcDowntimeVo mdcDowntimeVo) { -- Gitblit v1.9.3