zhaopeiqing 1 éve
szülő
commit
4d21499748

+ 2 - 0
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java

@@ -29,6 +29,8 @@ public class DateUtils {
 
     public static final String FORMAT_HOUR_MINUTE = "HH:mm";
 
+    public static final String FORMAT_HOUR_MINUTE_SECOND = "HH:mm:ss";
+
     /**
      * 将 LocalDateTime 转换成 Date
      *

+ 54 - 0
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/convert/StringToLocalTimeConverter.java

@@ -0,0 +1,54 @@
+package cn.iocoder.yudao.framework.excel.core.convert;
+
+import com.alibaba.excel.converters.Converter;
+import com.alibaba.excel.enums.CellDataTypeEnum;
+import com.alibaba.excel.metadata.GlobalConfiguration;
+import com.alibaba.excel.metadata.data.ReadCellData;
+import com.alibaba.excel.metadata.data.WriteCellData;
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
+
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+/**
+ * String 到 LocalTime 的 Excel 转换器
+ */
+public class StringToLocalTimeConverter implements Converter<LocalTime> {
+
+    // 定义时间格式的字符串,可以根据实际情况调整
+    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
+
+    @Override
+    public Class supportJavaTypeKey() {
+        return LocalTime.class;
+    }
+
+    @Override
+    public CellDataTypeEnum supportExcelTypeKey() {
+        return CellDataTypeEnum.STRING;
+    }
+
+    @Override
+    public LocalTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
+                                       GlobalConfiguration globalConfiguration) throws Exception {
+        // 读取单元格数据
+        String stringValue = cellData.getStringValue();
+        // 尝试解析为 LocalTime
+        try {
+            return LocalTime.parse(stringValue, formatter);
+        } catch (DateTimeParseException e) {
+            throw new UnsupportedOperationException("转换失败,无法将字符串 " + stringValue + " 转换为 LocalTime");
+        }
+    }
+
+    @Override
+    public WriteCellData<?> convertToExcelData(LocalTime value, ExcelContentProperty contentProperty,
+                                               GlobalConfiguration globalConfiguration) throws Exception {
+        // 将 LocalTime 转换回字符串(如果需要写回 Excel)
+        if (value == null) {
+            return new WriteCellData<>("");
+        }
+        return new WriteCellData<>(value.format(formatter));
+    }
+}

+ 9 - 5
yudao-module-personnel/yudao-module-attendance-biz/src/main/java/cn/iocoder/yudao/module/attendance/controller/admin/info/vo/AttendanceInfoImportExcelVO.java

@@ -1,5 +1,7 @@
 package cn.iocoder.yudao.module.attendance.controller.admin.info.vo;
 
+import cn.iocoder.yudao.framework.excel.core.convert.StringToLocalTimeConverter;
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
@@ -11,7 +13,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 import java.time.LocalDate;
 import java.time.LocalTime;
 
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
 
 /**
  * 考勤信息 Excel 导入 VO
@@ -29,6 +31,7 @@ public class AttendanceInfoImportExcelVO {
     @ExcelProperty("员工手机号")
     private String employeeMobile;
 
+    @ExcelIgnore
     private Long deptId;
 
     @ExcelProperty("部门名称")
@@ -41,14 +44,15 @@ public class AttendanceInfoImportExcelVO {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDate attendanceDate;
 
+    @ExcelIgnore
     private String attendanceMonth;
 
-    @ExcelProperty("上班时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    @ExcelProperty(value = "上班时间", converter = StringToLocalTimeConverter.class)
+    @DateTimeFormat(pattern = FORMAT_HOUR_MINUTE_SECOND)
     private LocalTime workStartTime;
 
-    @ExcelProperty("下班时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    @ExcelProperty(value = "下班时间", converter = StringToLocalTimeConverter.class)
+    @DateTimeFormat(pattern = FORMAT_HOUR_MINUTE_SECOND)
     private LocalTime workEndTime;
 
 }

+ 4 - 0
yudao-module-personnel/yudao-module-employee-biz/src/main/java/cn/iocoder/yudao/module/employee/service/info/EmployeeInfoServiceImpl.java

@@ -187,6 +187,7 @@ public class EmployeeInfoServiceImpl implements EmployeeInfoService {
     }
 
     @Override
+    @TenantIgnore
     public Integer updateInfo(EmployeeInfoSaveReqVO updateReqVO) {
         // 校验存在
         validateInfoExists(updateReqVO.getId());
@@ -238,6 +239,9 @@ public class EmployeeInfoServiceImpl implements EmployeeInfoService {
             }
             updateReqVO.setPosition(post.getName());
         }
+        if (updateReqVO.getBaseAnnualLeave() != null && updateReqVO.getUsedAnnualLeave() != null) {
+            updateReqVO.setRemainingAnnualLeave(updateReqVO.getBaseAnnualLeave().subtract(updateReqVO.getUsedAnnualLeave()));
+        }
         EmployeeInfoDO updateObj = BeanUtils.toBean(updateReqVO, EmployeeInfoDO.class);
         return infoMapper.updateById(updateObj);
     }

+ 1 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java

@@ -254,6 +254,7 @@ public class TenantServiceImpl implements TenantService {
         if (employeeDTO != null) {
             EmployeeSaveReqDTO updateObj = BeanUtils.toBean(employeeDTO, EmployeeSaveReqDTO.class);
             updateObj.setUserId(user.getId());
+            updateObj.setTenantId(tenant.getId());
             // 更新员工信息
             employeeApi.updateEmployee(updateObj);
         } else {