| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | 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.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.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | 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; |
| | | result = mdcDowntime.getDownLong() + result; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param mdcDowntime |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveDowntime(MdcDowntime mdcDowntime) { |
| | | String[] equipmentIds = mdcDowntime.getEquipmentIds().split(","); |
| | | List<String> dateList = mdcDowntime.getDateList(); |
| | | List<MdcDowntime> mdcDowntimeList = new ArrayList<>(); |
| | | for (String equipmentId : equipmentIds) { |
| | | for (String date : dateList) { |
| | | // this.baseMapper.delete(new LambdaQueryWrapper<MdcDowntime>().eq(MdcDowntime::getTheDate, date).eq(MdcDowntime::getEquipmentId, equipmentId)); |
| | | MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId); |
| | | MdcDowntime downtime = new MdcDowntime(); |
| | | BeanUtils.copyProperties(mdcDowntime, downtime); |
| | | downtime.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | downtime.setEquipmentName(mdcEquipment.getEquipmentName()); |
| | | downtime.setTheDate(date); |
| | | mdcDowntimeList.add(downtime); |
| | | } |
| | | } |
| | | this.saveBatch(mdcDowntimeList); |
| | | return true; |
| | | } |
| | | |
| | | private List<String> getEquipmentIds(String userId, MdcDowntimeVo mdcDowntimeVo) { |
| | | if (StringUtils.isNotEmpty(mdcDowntimeVo.getEquipmentId())) { |
| | | return Collections.singletonList(mdcDowntimeVo.getEquipmentId()); |