From 44546c7c5f41b670f18cc520a9b863973ecf3b25 Mon Sep 17 00:00:00 2001
From: “linengliang” <vanSuperEnergy@163.com>
Date: 星期二, 22 八月 2023 17:12:22 +0800
Subject: [PATCH] lnl,bug修改
---
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