From 650f5b86d2af51a0a3c7334703bdc2916a82a749 Mon Sep 17 00:00:00 2001 From: lius <Lius2225@163.com> Date: 星期三, 12 七月 2023 14:59:58 +0800 Subject: [PATCH] 假期管理自动生成双休日任务 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java | 38 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java index f064d96..32aa32b 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java @@ -4,12 +4,15 @@ 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; @@ -40,7 +43,20 @@ @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 @@ -96,7 +112,7 @@ */ @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; @@ -108,7 +124,25 @@ 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); + } + } } -- Gitblit v1.9.3