| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import net.sf.saxon.expr.Component; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcVacationManagement; |
| | | import org.jeecg.modules.mdc.mapper.MdcVacationManagementMappper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcVacationManagementService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Override |
| | | public Boolean addVacation(MdcVacationManagement mdcVacationManagement) { |
| | | return this.save(mdcVacationManagement); |
| | | boolean result = false; |
| | | String[] equipmentIds = mdcVacationManagement.getEquipmentIds().split(","); |
| | | for (String equipmentId : equipmentIds) { |
| | | MdcEquipment mdcEquipment = equipmentService.findEquipmentNameByEquipmentId(equipmentId); |
| | | MdcVacationManagement vacationManagement = new MdcVacationManagement(); |
| | | BeanUtils.copyProperties(mdcVacationManagement, vacationManagement); |
| | | vacationManagement.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | vacationManagement.setEquipmentName(mdcEquipment.getEquipmentName()); |
| | | boolean b = super.save(vacationManagement); |
| | | if (b) { |
| | | result = true; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | @Override |
| | | public void generateWeekDays() { |
| | | MdcVacationManagement mdcVacationManagement = this.baseMapper.selectOne(new LambdaQueryWrapper<MdcVacationManagement>().eq(MdcVacationManagement::getType, "双休日").orderByDesc(MdcVacationManagement::getVacationDate).last("limit 1")); |
| | | MdcVacationManagement mdcVacationManagement = this.baseMapper.selectLastWeekDays(); |
| | | // 获取生成开始时间和结束时间 |
| | | LocalDate startDate; |
| | | LocalDate endDate; |
| | |
| | | startDate = vacationDate.with(TemporalAdjusters.firstDayOfMonth()); |
| | | endDate = vacationDate.with(TemporalAdjusters.lastDayOfMonth()); |
| | | } |
| | | List<MdcVacationManagement> list = new ArrayList<>(); |
| | | // 获取开始时间和结束时间的中间双休日集合 |
| | | List<Date> dateList = DateUtils.getWeekDays(startDate, endDate); |
| | | if (!dateList.isEmpty()) { |
| | | // 获取所有设备 |
| | | List<MdcEquipment> equipmentList = equipmentService.list(); |
| | | for (Date date : dateList) { |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcVacationManagement management = new MdcVacationManagement(); |
| | | management.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | management.setEquipmentName(mdcEquipment.getEquipmentName()); |
| | | management.setVacationDate(date); |
| | | management.setVacationType("双休日"); |
| | | management.setCreateBy("root"); |
| | | list.add(management); |
| | | } |
| | | } |
| | | super.saveBatch(list); |
| | | } |
| | | |
| | | } |
| | | } |