From 80d7376aa460b02b6233200779e725b386e0d648 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 06 三月 2026 16:49:54 +0800
Subject: [PATCH] 人员排班

---
 src/main/java/com/ruoyi/staff/dto/PerformanceShiftAddDto.java                        |   33 +
 src/main/java/com/ruoyi/staff/utils/JackSonUtil.java                                 |  133 ++++++
 src/main/java/com/ruoyi/staff/pojo/PersonalShift.java                                |   59 ++
 src/main/java/com/ruoyi/staff/mapper/PersonalShiftMapper.java                        |   34 +
 src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java |   39 +
 src/main/java/com/ruoyi/staff/service/PersonalShiftService.java                      |   32 +
 src/main/java/com/ruoyi/staff/utils/StyleYearUtils.java                              |   89 ++++
 src/main/java/com/ruoyi/staff/service/impl/PersonalShiftServiceImpl.java             |  488 ++++++++++++++++++++++
 src/main/java/com/ruoyi/staff/utils/StyleMonthUtils.java                             |   86 +++
 src/main/resources/mapper/staff/PersonalShiftMapper.xml                              |  106 ++++
 src/main/java/com/ruoyi/staff/pojo/PersonalAttendanceLocationConfig.java             |    3 
 pom.xml                                                                              |    8 
 src/main/java/com/ruoyi/ScheduleTask.java                                            |    2 
 src/main/java/com/ruoyi/staff/controller/PersonalShiftController.java                |   98 ++++
 src/main/java/com/ruoyi/staff/dto/PerformanceShiftMapDto.java                        |   26 +
 src/main/java/com/ruoyi/staff/task/PersonalAttendanceRecordsTask.java                |   72 +++
 src/main/java/com/ruoyi/staff/dto/PersonalAttendanceRecordsDto.java                  |    3 
 17 files changed, 1,297 insertions(+), 14 deletions(-)

diff --git a/pom.xml b/pom.xml
index 25bd9fe..1eadd23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,7 @@
         <tomcat.version>9.0.102</tomcat.version>
         <minio.version>8.4.3</minio.version>
         <okhttp.version>4.9.0</okhttp.version>
+        <hutool.version>5.8.18</hutool.version>
         <logback.version>1.2.13</logback.version>
         <spring-security.version>5.7.12</spring-security.version>
         <spring-framework.version>5.3.39</spring-framework.version>
@@ -314,6 +315,13 @@
             <version>${getui-sdk.version}</version>
             <scope>compile</scope>
         </dependency>
+    
+        <!--hutool宸ュ叿鍖�-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>${hutool.version}</version>
+        </dependency>
 
     </dependencies>
 
diff --git a/src/main/java/com/ruoyi/ScheduleTask.java b/src/main/java/com/ruoyi/ScheduleTask.java
index 9913292..2cb1ad7 100644
--- a/src/main/java/com/ruoyi/ScheduleTask.java
+++ b/src/main/java/com/ruoyi/ScheduleTask.java
@@ -55,4 +55,6 @@
                 .eq(SysNotice::getStatus,"1")
                 .lt(SysNotice::getCreateTime, LocalDateTime.now()));
     }
+
+
 }
diff --git a/src/main/java/com/ruoyi/staff/controller/PersonalShiftController.java b/src/main/java/com/ruoyi/staff/controller/PersonalShiftController.java
new file mode 100644
index 0000000..85ff013
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/controller/PersonalShiftController.java
@@ -0,0 +1,98 @@
+package com.ruoyi.staff.controller;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.staff.dto.PerformanceShiftAddDto;
+import com.ruoyi.staff.pojo.PersonalAttendanceLocationConfig;
+import com.ruoyi.staff.pojo.PersonalShift;
+import com.ruoyi.staff.service.PersonalAttendanceLocationConfigService;
+import com.ruoyi.staff.service.PersonalShiftService;
+import com.ruoyi.staff.utils.StyleMonthUtils;
+import com.ruoyi.staff.utils.StyleYearUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.constraints.NotNull;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  鍓嶇鎺у埗鍣�
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-03-05 03:52:19
+ */
+@RestController
+@RequestMapping("/personalShift")
+@Api(tags = "浜哄憳鎺掔彮")
+public class PersonalShiftController {
+
+    @Autowired
+    private PersonalShiftService personalShiftService;
+
+    @ApiOperation("浜哄憳鎺掔彮")
+    @PostMapping("/add")
+    public R add(@RequestBody PerformanceShiftAddDto performanceShiftAddDto){
+        return R.ok(personalShiftService.performanceShiftAdd(performanceShiftAddDto));
+    }
+
+    @ApiOperation(value = "鏈堜唤鍒嗛〉鏌ヨ")
+    @GetMapping("page")
+    public R performanceShiftPage(Integer size, Integer current, String time, String userName, Integer sysDeptId) {
+        return R.ok(personalShiftService.performanceShiftPage(new Page<>(current, size), time, userName, sysDeptId));
+    }
+
+    @ApiOperation(value = "骞翠唤鍒嗛〉鏌ヨ")
+    @GetMapping("pageYear")
+    public R performanceShiftPageYear(Integer size, Integer current, String time, String userName, Integer sysDeptId) {
+        return R.ok(personalShiftService.performanceShiftPageYear(new Page<>(current, size), time, userName, sysDeptId));
+    }
+
+    @ApiOperation(value = "鐝鐘舵�佷慨鏀�")
+    @PostMapping("update")
+    public R performanceShiftUpdate(@RequestBody PersonalShift personalShift) {
+        personalShiftService.performanceShiftUpdate(personalShift);
+        return R.ok();
+    }
+
+    @ApiOperation(value = "瀵煎嚭")
+    @GetMapping("export")
+    public void exportToExcel(@NotNull(message = "鏃堕棿涓嶈兘涓虹┖锛�") String time, String userName, Integer sysDeptId, Boolean isMonth, HttpServletResponse response) throws Exception {
+        Map<Object, Object> data;
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setHeader("requestType","excel");
+        response.setHeader("Access-Control-Expose-Headers", "requestType");
+        if (!isMonth) {
+            data = personalShiftService.exportToYearExcel(time, userName, sysDeptId);
+            // 璁剧疆鍗曞厓鏍兼牱寮�
+            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.getContentStyle());
+            // 淇濆瓨鍒扮涓�涓猻heet涓�
+            EasyExcel.write(response.getOutputStream())
+                    .head((List<List<String>>) data.get("header"))
+                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 鑷�傚簲鍒楀
+                    .registerWriteHandler(horizontalCellStyleStrategy)
+                    .sheet("骞村害")
+                    .doWrite((Collection<?>) data.get("data"));
+        } else {
+            data = personalShiftService.exportToMonthExcel(time, userName, sysDeptId);
+            // 璁剧疆鍗曞厓鏍兼牱寮�
+            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleMonthUtils.getHeadStyle(), StyleMonthUtils.getContentStyle());
+            EasyExcel.write(response.getOutputStream())
+                    .head((List<List<String>>) data.get("header"))
+                    .registerWriteHandler(horizontalCellStyleStrategy)
+                    .sheet("鏈堝害")
+                    .doWrite((Collection<?>) data.get("data"));
+        }
+    }
+
+
+}
diff --git a/src/main/java/com/ruoyi/staff/dto/PerformanceShiftAddDto.java b/src/main/java/com/ruoyi/staff/dto/PerformanceShiftAddDto.java
new file mode 100644
index 0000000..d7aff73
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/dto/PerformanceShiftAddDto.java
@@ -0,0 +1,33 @@
+package com.ruoyi.staff.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Data
+public class PerformanceShiftAddDto {
+
+    @NotNull(message = "璇烽�夋嫨鐝")
+    @ApiModelProperty("鐝")
+    private Integer personalAttendanceLocationConfigId;
+
+    @NotNull(message = "璇烽�夋嫨鍛樺伐")
+    @ApiModelProperty("鍛樺伐id")
+    private String staffOnJobId;
+
+    @NotNull(message = "璇烽�夋嫨鍛ㄦ")
+    @ApiModelProperty("寮�濮嬪懆娆�")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime startWeek;
+
+    @NotNull(message = "璇烽�夋嫨鍛ㄦ")
+    @ApiModelProperty("缁撴潫鍛ㄦ")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime endWeek;
+}
diff --git a/src/main/java/com/ruoyi/staff/dto/PerformanceShiftMapDto.java b/src/main/java/com/ruoyi/staff/dto/PerformanceShiftMapDto.java
new file mode 100644
index 0000000..ccb0590
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/dto/PerformanceShiftMapDto.java
@@ -0,0 +1,26 @@
+package com.ruoyi.staff.dto;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class PerformanceShiftMapDto {
+
+    private String name;
+
+    private String shiftTime;
+
+    private String userId;
+
+    private String department;
+
+    private Map<String, Object> monthlyAttendance = new HashMap<>();
+
+    private List<Map<String, Object>> list = new ArrayList<>();
+
+    private List<Map<Object, Object>> headerList = new ArrayList<>();
+}
diff --git a/src/main/java/com/ruoyi/staff/dto/PersonalAttendanceRecordsDto.java b/src/main/java/com/ruoyi/staff/dto/PersonalAttendanceRecordsDto.java
index 511390c..ccb9da4 100644
--- a/src/main/java/com/ruoyi/staff/dto/PersonalAttendanceRecordsDto.java
+++ b/src/main/java/com/ruoyi/staff/dto/PersonalAttendanceRecordsDto.java
@@ -40,4 +40,7 @@
     @JsonFormat(pattern = "HH:mm")
     @DateTimeFormat(pattern = "HH:mm")
     private LocalTime  endAt;
+
+    //鐝
+    private String shift;
 }
diff --git a/src/main/java/com/ruoyi/staff/mapper/PersonalShiftMapper.java b/src/main/java/com/ruoyi/staff/mapper/PersonalShiftMapper.java
new file mode 100644
index 0000000..8ae881f
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/mapper/PersonalShiftMapper.java
@@ -0,0 +1,34 @@
+package com.ruoyi.staff.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.config.MyBaseMapper;
+import com.ruoyi.staff.dto.PerformanceShiftMapDto;
+import com.ruoyi.staff.pojo.PersonalShift;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  Mapper 鎺ュ彛
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-03-05 03:52:19
+ */
+@Mapper
+public interface PersonalShiftMapper extends BaseMapper<PersonalShift> {
+
+    IPage<PerformanceShiftMapDto> performanceShiftPage(Page<Object> page, @Param("time") String time, @Param("userName") String userName, @Param("sysDeptId") Integer sysDeptId);
+
+
+    IPage<Map<String, Object>> performanceShiftYear(Page<Object> page, @Param("time") String time, @Param("userName") String userName, @Param("sysDeptId") Integer sysDeptId);
+
+    List<Map<String, Object>> performanceShiftYearList(@Param("time") String time, @Param("userName") String userName, @Param("sysDeptId") Integer sysDeptId);
+
+    List<PerformanceShiftMapDto> performanceShiftList(@Param("time") String time, @Param("userName") String userName, @Param("sysDeptId") Integer sysDeptId);
+}
diff --git a/src/main/java/com/ruoyi/staff/pojo/PersonalAttendanceLocationConfig.java b/src/main/java/com/ruoyi/staff/pojo/PersonalAttendanceLocationConfig.java
index 3b677e1..647359e 100644
--- a/src/main/java/com/ruoyi/staff/pojo/PersonalAttendanceLocationConfig.java
+++ b/src/main/java/com/ruoyi/staff/pojo/PersonalAttendanceLocationConfig.java
@@ -57,4 +57,7 @@
     @JsonFormat(pattern = "HH:mm")
     @DateTimeFormat(pattern = "HH:mm")
     private LocalTime  endAt;
+
+    @ApiModelProperty("鐝")
+    private String shift;
 }
diff --git a/src/main/java/com/ruoyi/staff/pojo/PersonalShift.java b/src/main/java/com/ruoyi/staff/pojo/PersonalShift.java
new file mode 100644
index 0000000..337ab96
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/pojo/PersonalShift.java
@@ -0,0 +1,59 @@
+package com.ruoyi.staff.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-03-05 03:52:19
+ */
+@Getter
+@Setter
+@TableName("personal_shift")
+@ApiModel(value = "PersonalShift瀵硅薄", description = "")
+public class PersonalShift implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty("鐝(鎵撳崱瑙勫垯id)")
+    private Integer personalAttendanceLocationConfigId;
+
+    @ApiModelProperty("鍛樺伐鍦ㄨ亴id")
+    private Long staffOnJobId;
+
+    @ApiModelProperty("褰曞叆鏃堕棿")
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty("鏇存柊鏃堕棿")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty("鎺掔彮鏃ユ湡")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime workTime;
+}
diff --git a/src/main/java/com/ruoyi/staff/service/PersonalShiftService.java b/src/main/java/com/ruoyi/staff/service/PersonalShiftService.java
new file mode 100644
index 0000000..e6eb140
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/service/PersonalShiftService.java
@@ -0,0 +1,32 @@
+package com.ruoyi.staff.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.staff.dto.PerformanceShiftAddDto;
+import com.ruoyi.staff.pojo.PersonalShift;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * <p>
+ *  鏈嶅姟绫�
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-03-05 03:52:19
+ */
+public interface PersonalShiftService extends IService<PersonalShift> {
+
+    int performanceShiftAdd(PerformanceShiftAddDto performanceShiftAddDto);
+
+    Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, Integer sysDeptId);
+
+    void performanceShiftUpdate(PersonalShift performanceShift);
+
+    IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, Integer sysDeptId);
+
+    Map<Object, Object> exportToYearExcel(String time, String userName, Integer sysDeptId) throws Exception;
+
+    Map<Object, Object> exportToMonthExcel(String time, String userName, Integer sysDeptId);
+}
diff --git a/src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java
index b323a22..9d5e688 100644
--- a/src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java
+++ b/src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ruoyi.staff.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -14,10 +15,12 @@
 import com.ruoyi.staff.dto.PersonalAttendanceRecordsDto;
 import com.ruoyi.staff.dto.StaffOnJobDto;
 import com.ruoyi.staff.mapper.PersonalAttendanceLocationConfigMapper;
+import com.ruoyi.staff.mapper.PersonalShiftMapper;
 import com.ruoyi.staff.mapper.StaffOnJobMapper;
 import com.ruoyi.staff.pojo.PersonalAttendanceLocationConfig;
 import com.ruoyi.staff.pojo.PersonalAttendanceRecords;
 import com.ruoyi.staff.mapper.PersonalAttendanceRecordsMapper;
+import com.ruoyi.staff.pojo.PersonalShift;
 import com.ruoyi.staff.pojo.StaffOnJob;
 import com.ruoyi.staff.service.PersonalAttendanceRecordsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -63,6 +66,9 @@
     @Autowired
     private SysDeptMapper sysDeptMapper;
 
+    @Autowired
+    private PersonalShiftMapper personalShiftMapper;
+
     @Override
     public int add(PersonalAttendanceRecordsDto personalAttendanceRecordsDto) {
         // 褰撳墠鏃堕棿
@@ -76,20 +82,24 @@
         if (staffOnJob == null) {
             throw new BaseException("褰撳墠鐢ㄦ埛娌℃湁瀵瑰簲鐨勫憳宸ヤ俊鎭�");
         }
-        /*鍒ゆ柇鎵撳崱浣嶇疆鏄惁鍦ㄨ鍒欒寖鍥村唴*/
-        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(Wrappers.<PersonalAttendanceLocationConfig>lambdaQuery()
-                .eq(PersonalAttendanceLocationConfig::getSysDeptId, staffOnJob.getSysDeptId())
-                .orderByDesc(PersonalAttendanceLocationConfig::getId));
-        if (personalAttendanceLocationConfigs == null || personalAttendanceLocationConfigs.isEmpty()) {
-            throw new BaseException("褰撳墠閮ㄩ棬娌℃湁璁剧疆鎵撳崱瑙勫垯");
+        //鍒ゆ柇鍒ゆ柇鍛樺伐褰撳ぉ鏄惁鏈夋帓鐝暟鎹�
+        List<PersonalShift> personalShifts = personalShiftMapper.selectList(Wrappers.<PersonalShift>lambdaQuery()
+                .eq(PersonalShift::getStaffOnJobId, staffOnJob.getId())
+                .eq(PersonalShift::getWorkTime, currentDate.atStartOfDay())
+                .isNotNull(PersonalShift::getPersonalAttendanceLocationConfigId));
+        if (CollectionUtil.isEmpty(personalShifts)){
+            throw new BaseException("褰撳墠鐢ㄦ埛褰撳ぉ娌℃湁鎺掔彮鏁版嵁");
         }
+        /*鍒ゆ柇鎵撳崱浣嶇疆鏄惁鍦ㄨ鍒欒寖鍥村唴*/
+        PersonalShift personalShift = personalShifts.get(0);
+
+        PersonalAttendanceLocationConfig locationConfig = personalAttendanceLocationConfigMapper.selectById(personalShift.getPersonalAttendanceLocationConfigId());
         Double punchLongitude = personalAttendanceRecordsDto.getLongitude(); //鎵撳崱鐨勭粡搴�
         Double punchLatitude = personalAttendanceRecordsDto.getLatitude(); // 鎵撳崱鐨勭含搴�
         if (punchLongitude == null || punchLatitude == null) {
             throw new BaseException("鎵撳崱澶辫触锛氭湭鑾峰彇鍒版偍鐨勪綅缃俊鎭紝璇峰紑鍚畾浣嶆潈闄�");
         }
         //璁$畻鎵撳崱浣嶇疆涓庤�冨嫟鐐圭殑璺濈
-        PersonalAttendanceLocationConfig locationConfig = personalAttendanceLocationConfigs.get(0);//鑾峰彇鏈�鏂扮殑涓�鏉℃暟鎹�
         double allowedRadius = locationConfig.getRadius(); // 鍏佽鐨勮寖鍥达紙绫筹級
         double actualDistance = LocationUtils.calculateDistance(
                 punchLatitude, punchLongitude, // 鍛樺伐鎵撳崱鐨勭粡绾害
@@ -231,12 +241,15 @@
         SysDept dept = sysDeptMapper.selectDeptById(staffOnJob.getSysDeptId());
         resultDto.setDeptName(dept != null ? dept.getDeptName() : null);
         //鑾峰彇璇ュ憳宸ュ搴旂殑鎵撳崱瑙勫垯
-        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(Wrappers.<PersonalAttendanceLocationConfig>lambdaQuery()
-                .eq(PersonalAttendanceLocationConfig::getSysDeptId, staffOnJob.getSysDeptId())
-                .orderByDesc(PersonalAttendanceLocationConfig::getId));
-        if (personalAttendanceLocationConfigs.size()>0){
-            resultDto.setStartAt(personalAttendanceLocationConfigs.get(0).getStartAt());
-            resultDto.setEndAt(personalAttendanceLocationConfigs.get(0).getEndAt());
+        List<PersonalShift> personalShifts = personalShiftMapper.selectList(Wrappers.<PersonalShift>lambdaQuery()
+                .eq(PersonalShift::getStaffOnJobId, staffOnJob.getId())
+                .eq(PersonalShift::getWorkTime, currentDate.atStartOfDay())
+                .isNotNull(PersonalShift::getPersonalAttendanceLocationConfigId));
+        if (CollectionUtil.isNotEmpty(personalShifts)){
+            PersonalAttendanceLocationConfig personalAttendanceLocationConfig = personalAttendanceLocationConfigMapper.selectById(personalShifts.get(0).getPersonalAttendanceLocationConfigId());
+            resultDto.setStartAt(personalAttendanceLocationConfig.getStartAt());
+            resultDto.setEndAt(personalAttendanceLocationConfig.getEndAt());
+            resultDto.setShift(personalAttendanceLocationConfig.getShift());
         }
         return resultDto;
     }
diff --git a/src/main/java/com/ruoyi/staff/service/impl/PersonalShiftServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/PersonalShiftServiceImpl.java
new file mode 100644
index 0000000..dd4cf4b
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/service/impl/PersonalShiftServiceImpl.java
@@ -0,0 +1,488 @@
+package com.ruoyi.staff.service.impl;
+
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.staff.dto.PerformanceShiftAddDto;
+import com.ruoyi.staff.dto.PerformanceShiftMapDto;
+import com.ruoyi.staff.mapper.PersonalAttendanceLocationConfigMapper;
+import com.ruoyi.staff.pojo.PersonalAttendanceLocationConfig;
+import com.ruoyi.staff.pojo.PersonalShift;
+import com.ruoyi.staff.mapper.PersonalShiftMapper;
+import com.ruoyi.staff.service.PersonalAttendanceLocationConfigService;
+import com.ruoyi.staff.service.PersonalShiftService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.staff.utils.JackSonUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import cn.hutool.core.date.DateUtil;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.*;
+
+
+/**
+ * <p>
+ *  鏈嶅姟瀹炵幇绫�
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-03-05 03:52:19
+ */
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class PersonalShiftServiceImpl extends ServiceImpl<PersonalShiftMapper, PersonalShift> implements PersonalShiftService {
+
+    @Autowired
+    private PersonalAttendanceLocationConfigMapper personalAttendanceLocationConfigMapper;
+
+    @Override
+    public int performanceShiftAdd(PerformanceShiftAddDto performanceShiftAddDto) {
+        List<PersonalShift> list = new ArrayList<>();
+        LocalDateTime startWeek = performanceShiftAddDto.getStartWeek();//寮�濮嬫棩鏈�
+        LocalDateTime endWeek = performanceShiftAddDto.getEndWeek();//缁撴潫鏃ユ湡
+
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        String formattedDateTime = performanceShiftAddDto.getStartWeek().format(formatter);
+        String[] splitUserId = performanceShiftAddDto.getStaffOnJobId().split(",");
+        for (String userId : splitUserId) {
+            //鍒ゆ柇鏄惁璺ㄦ湀
+            boolean isMonth = startWeek.getMonthValue() != endWeek.getMonthValue();
+            if (isMonth){
+                //濡傛灉璺ㄦ湀,鍒欎袱涓湀閮藉垽鏂竴涓嬬湅鏁版嵁搴撴槸鍝釜鏈堜唤鐨勬暟鎹病鏈�
+                boolean exists1 = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
+                        .eq(PersonalShift::getWorkTime, startWeek)
+                        .eq(PersonalShift::getStaffOnJobId, userId));
+                boolean exists2 = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
+                        .eq(PersonalShift::getWorkTime, endWeek)
+                        .eq(PersonalShift::getStaffOnJobId, userId));
+                if (!exists1 && !exists2){
+                    //涓や釜鏈堥兘涓嶅瓨鍦ㄦ暟鎹�
+                    list = saveMonth(performanceShiftAddDto.getStartWeek(), userId, list);
+                    list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
+                }else if (!exists1 && exists2){
+                    //寮�濮嬬殑鏈堜唤涓嶅瓨鍦ㄦ暟鎹�
+                    list = saveMonth(performanceShiftAddDto.getStartWeek(), userId, list);
+                }else if (exists1 && !exists2){
+                    //缁撴潫鐨勬湀浠戒笉瀛樺湪鏁版嵁
+                    list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
+                }
+            }else {
+                //涓嶈法鏈�
+                boolean exists = baseMapper.exists(Wrappers.<PersonalShift>lambdaQuery()
+                        .in(PersonalShift::getWorkTime, formattedDateTime)
+                        .eq(PersonalShift::getStaffOnJobId, userId));
+                // 濡傛灉涓嶅瓨鍦ㄦ坊鍔犳暟鎹�
+                if (!exists) {
+                    list = saveMonth(performanceShiftAddDto.getEndWeek(), userId, list);
+                }
+            }
+        }
+        if (!list.isEmpty()) {
+           saveBatch(list);
+            list.clear();
+        }
+        // 鍐嶆鏇存柊
+        List<LocalDateTime> datesBetween = getLocalDateTimesBetween(performanceShiftAddDto.getStartWeek(), performanceShiftAddDto.getEndWeek());
+        for (LocalDateTime date : datesBetween) {
+            for (String s : splitUserId) {
+                PersonalShift personalShift = new PersonalShift();
+                personalShift.setPersonalAttendanceLocationConfigId(performanceShiftAddDto.getPersonalAttendanceLocationConfigId());
+                personalShift.setStaffOnJobId(Long.valueOf(s));
+                personalShift.setWorkTime(date);
+                String formatterDateTime = date.format(formatter);
+                baseMapper.update(new PersonalShift(), Wrappers.<PersonalShift>lambdaUpdate()
+                        .set(PersonalShift::getPersonalAttendanceLocationConfigId, performanceShiftAddDto.getPersonalAttendanceLocationConfigId())
+                        .eq(PersonalShift::getStaffOnJobId, s)
+                        .eq(PersonalShift::getWorkTime, formatterDateTime));
+            }
+        }
+        return 0;
+    }
+
+    @Override
+    public Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, Integer sysDeptId) {
+        IPage<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftPage(page, time, userName, sysDeptId);
+        //鏌ヨ鎵�鏈夌彮娆�(鎵撳崱瑙勫垯)
+        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
+        mapIPage.getRecords().forEach(i -> {
+            String[] shiftTimes = i.getShiftTime().split(";");
+            double totalAttendance = 0;//鎬诲嚭鍕ゅぉ鏁�
+            List<Map<String, Object>> map = new ArrayList<>();
+            // 鍒嗗壊鏃ユ湡
+            for (String shiftTime : shiftTimes) {
+                i.setShiftTime(null);
+                Map<String, Object> hashMap = new HashMap<>();
+                String[] shiftTimeAndShift = shiftTime.split("锛�");
+                //鎺掔彮璇︾粏鏁版嵁
+                hashMap.put("id", shiftTimeAndShift[2]);
+                hashMap.put("shift", shiftTimeAndShift[1]);
+                hashMap.put("time", shiftTimeAndShift[0]);
+                map.add(hashMap);
+                i.setList(map);
+                //姹囨�荤殑鍚勭彮娆$粺璁℃暟鎹�
+                for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                    if (!i.getMonthlyAttendance().containsKey(personalAttendanceLocationConfig.getShift())){
+                        i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), 0);
+                    }
+                    if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift[1])) {
+                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(personalAttendanceLocationConfig.getShift()).toString());
+                        i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), bigDecimal.add(new BigDecimal("1")));
+                    }
+                }
+                //缁熻鎬诲嚭鍕ゅぉ鏁�(鏃�/涓�/鏅�/澶�)閮界畻鍑哄嫟,鍏朵綑閮芥槸浼戞伅
+                if (shiftTimeAndShift[1].contains("鏃�") ||
+                        shiftTimeAndShift[1].contains("涓�") ||
+                        shiftTimeAndShift[1].contains("鏅�") ||
+                        shiftTimeAndShift[1].contains("澶�")) {
+                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
+                }
+            }
+        });
+        // 鑾峰彇header鏃堕棿
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        // 灏嗗瓧绗︿覆鏃堕棿杞崲涓� LocalDateTime 绫诲瀷鏃堕棿
+        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
+        LocalDate firstDayOfMonth = localDateTime.toLocalDate().withDayOfMonth(1);
+        LocalDate lastDayOfMonth = localDateTime.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
+        List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
+        List<Object> list1 = new ArrayList<>();
+        for (LocalDateTime dateTime : localDateTimesBetween) {
+            Map<Object, Object> hashMap = new HashMap<>();
+            DateTime parse = DateUtil.parse(dateTime.format(formatter));
+            hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1)));
+            hashMap.put("headerTime", getWeek(dateTime.format(formatters)));
+            list1.add(hashMap);
+        }
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("page", mapIPage);
+        resultMap.put("headerList", list1);
+        return resultMap;
+    }
+
+    @Override
+    public void performanceShiftUpdate(PersonalShift personalShift) {
+        baseMapper.update(new PersonalShift(), Wrappers.<PersonalShift>lambdaUpdate()
+                .eq(PersonalShift::getId, personalShift.getId())
+                .set(PersonalShift::getPersonalAttendanceLocationConfigId, personalShift.getPersonalAttendanceLocationConfigId()));
+    }
+
+    @Override
+    public IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, Integer sysDeptId) {
+        IPage<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYear(page, time, userName, sysDeptId);
+        //鏌ヨ鎵�鏈夌彮娆�(鎵撳崱瑙勫垯)
+        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
+        mapYearIPage.setRecords(annualAttendanceProcessing(mapYearIPage.getRecords(), personalAttendanceLocationConfigs));
+        return mapYearIPage;
+    }
+
+    @Override
+    public Map<Object, Object> exportToYearExcel(String time, String userName, Integer sysDeptId) throws Exception {
+        Map<Object, Object> map = new HashMap<>();
+        //鏌ヨ鎵�鏈夌彮娆�(鎵撳崱瑙勫垯)
+        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
+        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        // 灏嗗瓧绗︿覆鏃堕棿杞崲涓� LocalDateTime 绫诲瀷鏃堕棿
+        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
+        map.put("header", getYearHeader(localDateTime.getYear() + " 骞�", personalAttendanceLocationConfigs));
+        List<Map<String, Object>> mapYearList = baseMapper.performanceShiftYearList(time, userName, sysDeptId);
+        annualAttendanceProcessing(mapYearList, personalAttendanceLocationConfigs);
+        List<List<Object>> lists = dataRequiredForProcessingIntoExcel(mapYearList, personalAttendanceLocationConfigs);
+        map.put("data", lists);
+        return map;
+    }
+
+    @Override
+    public Map<Object, Object> exportToMonthExcel(String time, String userName, Integer sysDeptId) {
+        //鏌ヨ鎵�鏈夌彮娆�(鎵撳崱瑙勫垯)
+        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
+        List<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftList(time, userName, sysDeptId);
+        mapIPage.forEach(i -> {
+            String[] shiftTimes = i.getShiftTime().split(";");
+            double totalAttendance = 0;
+            List<Map<String, Object>> map = new ArrayList<>();
+            // 鍒嗗壊鏃ユ湡
+            for (String shiftTime : shiftTimes) {
+                Map<String, Object> hashMap = new HashMap<>();
+                String[] shiftTimeAndShift = shiftTime.split("锛�");
+                for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                    if (!i.getMonthlyAttendance().containsKey(personalAttendanceLocationConfig.getShift())) {
+                        i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), 0);
+                    }
+                    if (personalAttendanceLocationConfig.getShift().equals(shiftTimeAndShift[1])) {
+                        BigDecimal bigDecimal = new BigDecimal(i.getMonthlyAttendance().get(personalAttendanceLocationConfig.getShift()).toString());
+                        i.getMonthlyAttendance().put(personalAttendanceLocationConfig.getShift(), bigDecimal.add(new BigDecimal("1")));
+                    }
+                }
+                //缁熻鎬诲嚭鍕ゅぉ鏁�(鏃�/涓�/鏅�/澶�)閮界畻鍑哄嫟,鍏朵綑閮芥槸浼戞伅
+                if (shiftTimeAndShift[1].contains("鏃�") ||
+                        shiftTimeAndShift[1].contains("涓�") ||
+                        shiftTimeAndShift[1].contains("鏅�") ||
+                        shiftTimeAndShift[1].contains("澶�")) {
+                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
+                }
+                hashMap.put("id", shiftTimeAndShift[2]);
+                hashMap.put("shift", shiftTimeAndShift[1]);
+                hashMap.put("time", shiftTimeAndShift[0]);
+                map.add(hashMap);
+            }
+            i.setList(map);
+            i.setShiftTime(null);
+        });
+        Map<Object, Object> map = new HashMap<>();
+        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        // 灏嗗瓧绗︿覆鏃堕棿杞崲涓� LocalDateTime 绫诲瀷鏃堕棿
+        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
+        map.put("header", getMonthHeader(localDateTime));
+        List<List<Object>> lists = dataRequiredForProcessingIntoExcelMonth(mapIPage, personalAttendanceLocationConfigs);
+        map.put("data", lists);
+        return map;
+    }
+
+    // 骞村垎椤典笌瀵煎嚭鍏卞悓浣跨敤
+    public List<Map<String, Object>> annualAttendanceProcessing(List<Map<String, Object>> mapYearList,List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
+        for (Map<String, Object> map : mapYearList) {
+            Map<String, Object> resultMap = new LinkedHashMap<>();
+            Map<String, Object> hashMapYear = new LinkedHashMap<>();
+            double totalYearAttendance = 0;
+            // 涓�骞�12涓湀
+            for (int i = 1; i < 13; i++) {
+                Map<String, Object> hashMapMonth = new LinkedHashMap<>();
+                double totalMonthAttendance = 0;
+                for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                    // 鍒濆鍖栬祴鍊�
+                    if (!hashMapYear.containsKey(personalAttendanceLocationConfig.getShift())){
+                        hashMapYear.put(personalAttendanceLocationConfig.getShift(), 0);
+                    }
+                    // 鏈�
+                    if (!ObjectUtils.isEmpty(map.get("month_str"))) {
+                        String charArray = map.get("month_str").toString();
+                        int count = countOccurrences(charArray, i + "锛�" + personalAttendanceLocationConfig.getShift());
+                        hashMapMonth.put(personalAttendanceLocationConfig.getShift(), count);
+                        hashMapYear.put(personalAttendanceLocationConfig.getShift(), new BigDecimal(hashMapYear.get(personalAttendanceLocationConfig.getShift()).toString()).add(new BigDecimal(count)));
+                        // 鏃╋紝涓紝澶滐紝宸�
+                        if (personalAttendanceLocationConfig.getShift().contains("鏃�") ||
+                                personalAttendanceLocationConfig.getShift().contains("涓�") ||
+                                personalAttendanceLocationConfig.getShift().contains("鏅�") ||
+                                personalAttendanceLocationConfig.getShift().contains("澶�")) {
+                            totalMonthAttendance += count;
+                            totalYearAttendance += count;
+                        }
+                    }
+                    // 绌烘暟鎹�
+                    else {
+                        map.put("work_time", i);
+                        hashMapMonth.put(personalAttendanceLocationConfig.getShift(), 0);
+                    }
+                }
+                hashMapMonth.put("totalMonthAttendance", totalMonthAttendance);
+                hashMapYear.put("totalYearAttendance", totalYearAttendance);
+                resultMap.put(i + "", hashMapMonth);
+            }
+            map.remove("month_str");
+            map.remove("year_str");
+            map.put("year", hashMapYear);
+            map.put("month", resultMap);
+        }
+        return mapYearList;
+    }
+
+    public static int countOccurrences(String str, String target) {
+        int count = 0;
+        int index = 0;
+        while ((index = str.indexOf(target, index)) != -1) {
+            count++;
+            index += target.length();
+        }
+        return count;
+    }
+
+    public List<List<Object>> dataRequiredForProcessingIntoExcel(List<Map<String, Object>> list, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) throws Exception {
+        List<List<Object>> data = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            List<Object> excelRowList = new ArrayList<>();
+            excelRowList.add(i + 1);
+            excelRowList.add(list.get(i).get("account"));
+            excelRowList.add(list.get(i).get("name"));
+            Map<String, Object> year = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("year")), Map.class);
+            excelRowList.add(year.get("totalYearAttendance"));
+            personalAttendanceLocationConfigs.forEach(j -> {
+                excelRowList.add(year.get(j.getShift()));
+            });
+            Map<String, Map<String, Object>> month = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("month")), Map.class);
+            for (int j = 1; j < 13; j++) {
+                Object totalMonthAttendance = month.get(j + "").get("totalMonthAttendance");
+                excelRowList.add(totalMonthAttendance);
+                for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                        excelRowList.add(month.get(j + "").get(personalAttendanceLocationConfig.getShift()));
+                }
+            }
+            data.add(excelRowList);
+        }
+        return data;
+    }
+
+
+    private List<PersonalShift>   saveMonth (LocalDateTime week,String userId,List<PersonalShift> list){
+        LocalDate firstDayOfMonth = week.toLocalDate().withDayOfMonth(1);
+        LocalDate lastDayOfMonth = week.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
+        List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
+        localDateTimesBetween.forEach(i -> {
+            PersonalShift personalShift = new PersonalShift();
+            personalShift.setStaffOnJobId(Long.valueOf(userId));
+            personalShift.setWorkTime(i);
+            list.add(personalShift);
+            if (list.size() >= 1000) {
+                saveBatch(list);
+                list.clear();
+            }
+        });
+        return list;
+    }
+
+    // 鑾峰彇涓や釜localDateTime鐨勬瘡涓�澶�
+    public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) {
+        List<LocalDateTime> localDateTimes = new ArrayList<>();
+        LocalDate currentDate = start.toLocalDate();
+        LocalDateTime currentLocalDateTime = start;
+        while (!currentDate.isAfter(end.toLocalDate())) {
+            localDateTimes.add(currentLocalDateTime);
+            currentLocalDateTime = currentLocalDateTime.plusDays(1);
+            currentDate = currentDate.plusDays(1);
+        }
+        return localDateTimes;
+    }
+
+    public static String getWeek(String dayStr) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date date = sdf.parse(dayStr);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
+            int day = calendar.get(Calendar.DAY_OF_MONTH);
+            return day + " " + getWeekDay(dayOfWeek);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static String getWeekDay(int dayOfWeek) {
+        switch (dayOfWeek) {
+            case Calendar.MONDAY:
+                return "鍛ㄤ竴";
+            case Calendar.TUESDAY:
+                return "鍛ㄤ簩";
+            case Calendar.WEDNESDAY:
+                return "鍛ㄤ笁";
+            case Calendar.THURSDAY:
+                return "鍛ㄥ洓";
+            case Calendar.FRIDAY:
+                return "鍛ㄤ簲";
+            case Calendar.SATURDAY:
+                return "鍛ㄥ叚";
+            case Calendar.SUNDAY:
+                return "鍛ㄦ棩";
+            default:
+                return "鏈煡";
+        }
+    }
+
+    /**
+     * 杩斿洖琛ㄥご
+     * <p>
+     * 澶栧眰List浠h〃琛屽唴灞� List浠h〃鍒�  鐩稿悓鐨勫垪鏁版嵁浼氳涓诲姩鍚堝苟
+     * 鏋勯�犲弻鍒楄〃澶�
+     *
+     * @return List<List < String>>
+     */
+    private static List<List<String>> getYearHeader(String year, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
+        List<List<String>> line = new ArrayList<>();
+        line.add(Arrays.asList("鑰冨嫟姹囨��", "搴忓彿", "搴忓彿"));
+        line.add(Arrays.asList("鑰冨嫟姹囨��", "宸ュ彿", "宸ュ彿"));
+        line.add(Arrays.asList("鑰冨嫟姹囨��", "濮撳悕", "濮撳悕"));
+        line.add(Arrays.asList("鍑哄嫟璇︽儏", year, "鍑哄嫟"));
+        // 骞� header
+        for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                line.add(Arrays.asList("鑰冨嫟姹囨��", year, personalAttendanceLocationConfig.getShift()));
+        }
+        // 鏈坔eader
+        for (int i = 1; i < 13; i++) {
+            line.add(Arrays.asList("鍑哄嫟璇︽儏", i + " 鏈�", "鍑哄嫟"));
+            for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                line.add(Arrays.asList("鍑哄嫟璇︽儏", i + " 鏈�", personalAttendanceLocationConfig.getShift()));
+            }
+        }
+        return line;
+    }
+
+    private static List<List<String>> getMonthHeader(LocalDateTime localDateTimeYear) {
+        String year = localDateTimeYear.getYear() + " 骞翠汉鍛樼彮娆�";
+        List<List<String>> line = new ArrayList<>();
+        line.add(Arrays.asList(year, "搴忓彿", "搴忓彿", "搴忓彿"));
+        line.add(Arrays.asList(year, "濮撳悕", "濮撳悕", "濮撳悕"));
+        line.add(Arrays.asList(year, "閮ㄩ棬", "閮ㄩ棬", "閮ㄩ棬"));
+        line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "", "鍑哄嫟"));
+        line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "","浼�"));
+        line.add(Arrays.asList(year, "骞�", "骞�", "璇峰亣"));
+        line.add(Arrays.asList(year, localDateTimeYear.getMonthValue() + "", localDateTimeYear.getMonthValue() + "", "鏃�"));
+        line.add(Arrays.asList(year, "鏈�", "鏈�", "涓�"));
+        line.add(Arrays.asList(year, "", "", "澶�"));
+        line.add(Arrays.asList(year, "鍛ㄦ", "鏄熸湡", "鍑哄樊"));
+        LocalDate firstDayOfMonth = localDateTimeYear.toLocalDate().withDayOfMonth(1);
+        LocalDate lastDayOfMonth = localDateTimeYear.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
+        List<LocalDateTime> timeList = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
+        timeList.forEach(i -> {
+            int dayOfYear = i.getDayOfMonth();
+            Date from = Date.from(i.atZone(ZoneId.systemDefault()).toInstant());
+            String weekDay = getWeekDay(i.getDayOfWeek().getValue());
+            line.add(Arrays.asList(year, DateUtil.weekOfYear(DateUtil.offsetDay(from, 1)) + "", weekDay, dayOfYear + ""));
+        });
+        return line;
+    }
+
+    public List<List<Object>> dataRequiredForProcessingIntoExcelMonth(List<PerformanceShiftMapDto> list, List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs) {
+        List<List<Object>> data = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            List<Object> excelRowList = new ArrayList<>();
+            excelRowList.add(i + 1);
+            excelRowList.add(list.get(i).getName());
+            excelRowList.add(list.get(i).getDepartment());
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("totalAttendance"));
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%浼�%")); // 浼�
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%鍋�%")); // 鍋�
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%鏃�%")); // 鏃�
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%涓�%")); // 涓�
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%澶�%")); // 澶�
+            excelRowList.add(list.get(i).getMonthlyAttendance().get("%宸�%")); // 宸�
+            for (Map<String, Object> o : list.get(i).getList()) {
+                String enumLabel = "";
+                for (PersonalAttendanceLocationConfig personalAttendanceLocationConfig : personalAttendanceLocationConfigs) {
+                    if (personalAttendanceLocationConfig.getShift().equals(o.get("shift"))) {
+                        enumLabel = personalAttendanceLocationConfig.getShift();
+                    }
+                }
+                excelRowList.add(ObjectUtils.isEmpty(enumLabel) ? "-" : enumLabel);
+            }
+            data.add(excelRowList);
+        }
+        return data;
+    }
+
+}
diff --git a/src/main/java/com/ruoyi/staff/task/PersonalAttendanceRecordsTask.java b/src/main/java/com/ruoyi/staff/task/PersonalAttendanceRecordsTask.java
index 9730df6..a791300 100644
--- a/src/main/java/com/ruoyi/staff/task/PersonalAttendanceRecordsTask.java
+++ b/src/main/java/com/ruoyi/staff/task/PersonalAttendanceRecordsTask.java
@@ -1,9 +1,17 @@
 package com.ruoyi.staff.task;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.staff.dto.PerformanceShiftAddDto;
+import com.ruoyi.staff.mapper.PersonalAttendanceLocationConfigMapper;
+import com.ruoyi.staff.mapper.PersonalShiftMapper;
+import com.ruoyi.staff.mapper.StaffOnJobMapper;
+import com.ruoyi.staff.pojo.PersonalAttendanceLocationConfig;
 import com.ruoyi.staff.pojo.PersonalAttendanceRecords;
 import com.ruoyi.staff.pojo.StaffOnJob;
 import com.ruoyi.staff.service.PersonalAttendanceRecordsService;
 import com.ruoyi.staff.mapper.PersonalAttendanceRecordsMapper;
+import com.ruoyi.staff.service.PersonalShiftService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -12,7 +20,14 @@
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.temporal.TemporalAdjusters;
+import java.time.temporal.WeekFields;
 import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 涓汉鑰冨嫟璁板綍瀹氭椂浠诲姟
@@ -29,6 +44,15 @@
 
     @Autowired
     private PersonalAttendanceRecordsService personalAttendanceRecordsService;
+
+    @Autowired
+    private PersonalAttendanceLocationConfigMapper personalAttendanceLocationConfigMapper;
+
+    @Autowired
+    private StaffOnJobMapper staffOnJobMapper;
+
+    @Autowired
+    private PersonalShiftService personalShiftService;
 
     /**
      * 姣忓ぉ鍑屾櫒鐢熸垚鏄ㄦ棩鐨勭己鍕よ褰�
@@ -73,4 +97,50 @@
             log.error("鐢熸垚鏄ㄦ棩缂哄嫟璁板綍浠诲姟鎵ц澶辫触锛歿}", e.getMessage(), e);
         }
     }
-}
\ No newline at end of file
+
+    /**
+     * 瀹氭椂浠诲姟,姣忎釜鏈�1鍙风殑00:00:00缁欎笅涓�涓湀鎺掔彮
+     * 缁欐瘡涓汉閮借繘琛屾帓鐝�(榛樿鏃╃彮)
+     */
+    @Scheduled(cron = "0 10 0 1 * ?")
+    private void timerCreateSchedule() {
+        log.info("寮�濮嬬粰姣忎釜浜鸿繘琛屾帓鐝�,榛樿鏃╃彮======start");
+        PerformanceShiftAddDto performanceShiftAddDto = new PerformanceShiftAddDto();
+        //鏌ヨ鎵�鏈夌彮娆�(鎵撳崱瑙勫垯)
+        List<PersonalAttendanceLocationConfig> personalAttendanceLocationConfigs = personalAttendanceLocationConfigMapper.selectList(null);
+        if (CollectionUtil.isEmpty(personalAttendanceLocationConfigs)){
+            return;
+        }
+        performanceShiftAddDto.setPersonalAttendanceLocationConfigId(personalAttendanceLocationConfigs.get(0).getId());
+        //鍦ㄨ亴浜哄憳
+        List<StaffOnJob> staffOnJobs = staffOnJobMapper.selectList(Wrappers.<StaffOnJob>lambdaQuery().eq(StaffOnJob::getStaffState, 1));
+        if (CollectionUtil.isEmpty(staffOnJobs)){
+            return;
+        }
+        String userIds = staffOnJobs.stream().map(user -> user.getId().toString()).distinct().collect(Collectors.joining(","));
+        performanceShiftAddDto.setStaffOnJobId(userIds);
+        //鍛ㄦ--褰撴湀鎵�鏈�
+        // 鑾峰彇褰撳墠鏃ユ湡
+        LocalDate today = LocalDate.now(ZoneId.of(ZoneId.SHORT_IDS.get("CTT"))).plusMonths(1);
+        // 鑾峰彇鏈湀鐨勭涓�澶╁拰鏈�鍚庝竴澶�
+        LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth());
+        LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
+        // 鑾峰彇鍛ㄥ瓧娈典俊鎭紙鏍规嵁鍖哄煙璁剧疆锛�
+        WeekFields weekFields = WeekFields.of(Locale.getDefault());
+        // 鑾峰彇鏈湀绗竴澶╃殑鍛ㄤ竴
+        LocalDate startOfWeek = firstDayOfMonth.with(TemporalAdjusters.previousOrSame(weekFields.getFirstDayOfWeek()));
+        // 閬嶅巻鏈湀鎵�鏈夊ぉ鏁帮紝鎵惧嚭姣忓懆鐨勭涓�澶╁拰鏈�鍚庝竴澶�
+        LocalDate endOfWeek;
+        while (startOfWeek.isBefore(firstDayOfMonth.plusMonths(1))) {
+            endOfWeek = startOfWeek.plusDays(6);
+            LocalDateTime startDateTime = LocalDateTime.of(startOfWeek, LocalTime.MIDNIGHT);
+            LocalDateTime endDateTime = LocalDateTime.of(endOfWeek, LocalTime.MIDNIGHT);
+            log.info("Week starts on {} and ends on {}", startDateTime, endDateTime);
+            performanceShiftAddDto.setStartWeek(startDateTime);
+            performanceShiftAddDto.setEndWeek(endDateTime);
+            personalShiftService.performanceShiftAdd(performanceShiftAddDto);
+            startOfWeek = startOfWeek.plusWeeks(1);
+        }
+        log.info("鎺掔彮缁撴潫======end");
+    }
+}
diff --git a/src/main/java/com/ruoyi/staff/utils/JackSonUtil.java b/src/main/java/com/ruoyi/staff/utils/JackSonUtil.java
new file mode 100644
index 0000000..ab1b093
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/utils/JackSonUtil.java
@@ -0,0 +1,133 @@
+package com.ruoyi.staff.utils;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * JSON瑙f瀽澶勭悊
+ *
+ * @author zss
+ */
+@Component
+public class JackSonUtil {
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+    private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writerWithDefaultPrettyPrinter();
+
+    public static void marshal(File file, Object value) throws Exception {
+        try {
+            OBJECT_WRITER.writeValue(file, value);
+        } catch (JsonGenerationException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static void marshal(OutputStream os, Object value) throws Exception {
+        try {
+            OBJECT_WRITER.writeValue(os, value);
+        } catch (JsonGenerationException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static String marshal(Object value) throws Exception {
+        try {
+            return OBJECT_WRITER.writeValueAsString(value);
+        } catch (JsonGenerationException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static byte[] marshalBytes(Object value) throws Exception {
+        try {
+            return OBJECT_WRITER.writeValueAsBytes(value);
+        } catch (JsonGenerationException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static <T> T unmarshal(File file, Class<T> valueType) throws Exception {
+        try {
+            return OBJECT_MAPPER.readValue(file, valueType);
+        } catch (JsonParseException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static <T> T unmarshal(InputStream is, Class<T> valueType) throws Exception {
+        try {
+            return OBJECT_MAPPER.readValue(is, valueType);
+        } catch (JsonParseException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    /**
+     * 瀛楃涓茶浆瀵硅薄
+     * @param str
+     * @param valueType
+     * @return
+     * @param <T>
+     * @throws Exception
+     */
+    public static <T> T unmarshal(String str, Class<T> valueType) throws Exception {
+        try {
+            OBJECT_MAPPER.registerModule(new JavaTimeModule());
+            return OBJECT_MAPPER.readValue(str, valueType);
+        } catch (JsonParseException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+
+    public static <T> T unmarshal(byte[] bytes, Class<T> valueType) throws Exception {
+        try {
+            if (bytes == null) {
+                bytes = new byte[0];
+            }
+            return OBJECT_MAPPER.readValue(bytes, 0, bytes.length, valueType);
+        } catch (JsonParseException e) {
+            throw new Exception(e);
+        } catch (JsonMappingException e) {
+            throw new Exception(e);
+        } catch (IOException e) {
+            throw new Exception(e);
+        }
+    }
+}
diff --git a/src/main/java/com/ruoyi/staff/utils/StyleMonthUtils.java b/src/main/java/com/ruoyi/staff/utils/StyleMonthUtils.java
new file mode 100644
index 0000000..da5cef0
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/utils/StyleMonthUtils.java
@@ -0,0 +1,86 @@
+package com.ruoyi.staff.utils;
+
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
+import com.alibaba.excel.write.metadata.style.WriteFont;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+
+public class StyleMonthUtils {
+    /**
+     * 鏍囬鏍峰紡
+     * @return
+     */
+    public static WriteCellStyle getHeadStyle(){
+        // 澶寸殑绛栫暐
+        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+        // 鑳屾櫙棰滆壊
+//        headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
+//        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
+
+        // 瀛椾綋
+        WriteFont headWriteFont = new WriteFont();
+        headWriteFont.setFontName("绛夌嚎");//璁剧疆瀛椾綋鍚嶅瓧
+        headWriteFont.setFontHeightInPoints((short)9);//璁剧疆瀛椾綋澶у皬
+        headWriteFont.setBold(true);//瀛椾綋鍔犵矖
+        headWriteFont.setColor((short) 0);
+        headWriteCellStyle.setWriteFont(headWriteFont); //鍦ㄦ牱寮忕敤搴旂敤璁剧疆鐨勫瓧浣�;
+
+        // 鏍峰紡
+        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
+        headWriteCellStyle.setBottomBorderColor((short) 0);//璁剧疆搴曡竟妗嗛鑹�;
+        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //璁剧疆宸﹁竟妗�;
+        headWriteCellStyle.setLeftBorderColor((short) 0);//璁剧疆宸﹁竟妗嗛鑹�;
+        headWriteCellStyle.setBorderRight(BorderStyle.THIN);//璁剧疆鍙宠竟妗�;
+        headWriteCellStyle.setRightBorderColor((short) 0);//璁剧疆鍙宠竟妗嗛鑹�;
+        headWriteCellStyle.setBorderTop(BorderStyle.THIN);//璁剧疆椤惰竟妗�;
+        headWriteCellStyle.setTopBorderColor((short) 0); //璁剧疆椤惰竟妗嗛鑹�;
+
+        headWriteCellStyle.setWrapped(false);  //璁剧疆鑷姩鎹㈣;
+
+        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//璁剧疆姘村钩瀵归綈鐨勬牱寮忎负灞呬腑瀵归綈;
+        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);  //璁剧疆鍨傜洿瀵归綈鐨勬牱寮忎负灞呬腑瀵归綈;
+        headWriteCellStyle.setShrinkToFit(true);//璁剧疆鏂囨湰鏀剁缉鑷冲悎閫�
+
+        return headWriteCellStyle;
+    }
+
+
+    /**
+     * 鍐呭鏍峰紡
+     * @return
+     */
+    public static WriteCellStyle getContentStyle(){
+        // 鍐呭鐨勭瓥鐣�
+        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+
+        // 杩欓噷闇�瑕佹寚瀹� FillPatternType 涓篎illPatternType.SOLID_FOREGROUND 涓嶇劧鏃犳硶鏄剧ず鑳屾櫙棰滆壊.澶撮粯璁や簡 FillPatternType鎵�浠ュ彲浠ヤ笉鎸囧畾
+//        contentWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
+        contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
+
+        // 璁剧疆瀛椾綋
+        WriteFont contentWriteFont = new WriteFont();
+        contentWriteFont.setFontHeightInPoints((short) 10);//璁剧疆瀛椾綋澶у皬
+        contentWriteFont.setFontName("绛夌嚎"); //璁剧疆瀛椾綋鍚嶅瓧
+        contentWriteCellStyle.setWriteFont(contentWriteFont);//鍦ㄦ牱寮忕敤搴旂敤璁剧疆鐨勫瓧浣�;
+
+        //璁剧疆鏍峰紡;
+        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
+        contentWriteCellStyle.setBottomBorderColor((short) 0);//璁剧疆搴曡竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //璁剧疆宸﹁竟妗�;
+        contentWriteCellStyle.setLeftBorderColor((short) 0);//璁剧疆宸﹁竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//璁剧疆鍙宠竟妗�;
+        contentWriteCellStyle.setRightBorderColor((short) 0);//璁剧疆鍙宠竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//璁剧疆椤惰竟妗�;
+        contentWriteCellStyle.setTopBorderColor((short) 0); ///璁剧疆椤惰竟妗嗛鑹�;
+
+        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 姘村钩灞呬腑
+        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 鍨傜洿灞呬腑
+        contentWriteCellStyle.setWrapped(false); //璁剧疆鑷姩鎹㈣;
+
+//        contentWriteCellStyle.setShrinkToFit(true);//璁剧疆鏂囨湰鏀剁缉鑷冲悎閫�
+
+        return contentWriteCellStyle;
+    }
+}
diff --git a/src/main/java/com/ruoyi/staff/utils/StyleYearUtils.java b/src/main/java/com/ruoyi/staff/utils/StyleYearUtils.java
new file mode 100644
index 0000000..961420e
--- /dev/null
+++ b/src/main/java/com/ruoyi/staff/utils/StyleYearUtils.java
@@ -0,0 +1,89 @@
+package com.ruoyi.staff.utils;
+
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
+import com.alibaba.excel.write.metadata.style.WriteFont;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+
+public class StyleYearUtils {
+    /**
+     * 鏍囬鏍峰紡
+     *
+     * @return
+     */
+    public static WriteCellStyle getHeadStyle() {
+        // 澶寸殑绛栫暐
+        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+        // 鑳屾櫙棰滆壊
+//        headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
+        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
+
+        // 瀛椾綋
+        WriteFont headWriteFont = new WriteFont();
+        headWriteFont.setFontName("浠垮畫");//璁剧疆瀛椾綋鍚嶅瓧
+        headWriteFont.setFontHeightInPoints((short) 9);//璁剧疆瀛椾綋澶у皬
+        headWriteFont.setBold(true);//瀛椾綋鍔犵矖
+        headWriteFont.setColor((short) 1);
+        headWriteCellStyle.setWriteFont(headWriteFont); //鍦ㄦ牱寮忕敤搴旂敤璁剧疆鐨勫瓧浣�;
+
+        // 鏍峰紡
+        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
+        headWriteCellStyle.setBottomBorderColor((short) 1);//璁剧疆搴曡竟妗嗛鑹�;
+        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //璁剧疆宸﹁竟妗�;
+        headWriteCellStyle.setLeftBorderColor((short) 1);//璁剧疆宸﹁竟妗嗛鑹�;
+        headWriteCellStyle.setBorderRight(BorderStyle.THIN);//璁剧疆鍙宠竟妗�;
+        headWriteCellStyle.setRightBorderColor((short) 1);//璁剧疆鍙宠竟妗嗛鑹�;
+        headWriteCellStyle.setBorderTop(BorderStyle.THIN);//璁剧疆椤惰竟妗�;
+        headWriteCellStyle.setTopBorderColor((short) 1); //璁剧疆椤惰竟妗嗛鑹�;
+
+        headWriteCellStyle.setWrapped(false);  //璁剧疆鑷姩鎹㈣;
+
+        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//璁剧疆姘村钩瀵归綈鐨勬牱寮忎负灞呬腑瀵归綈;
+        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);  //璁剧疆鍨傜洿瀵归綈鐨勬牱寮忎负灞呬腑瀵归綈;
+        headWriteCellStyle.setShrinkToFit(true);//璁剧疆鏂囨湰鏀剁缉鑷冲悎閫�
+
+        return headWriteCellStyle;
+    }
+
+
+    /**
+     * 鍐呭鏍峰紡
+     *
+     * @return
+     */
+    public static WriteCellStyle getContentStyle() {
+        // 鍐呭鐨勭瓥鐣�
+        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+
+        // 杩欓噷闇�瑕佹寚瀹� FillPatternType 涓篎illPatternType.SOLID_FOREGROUND 涓嶇劧鏃犳硶鏄剧ず鑳屾櫙棰滆壊.澶撮粯璁や簡 FillPatternType鎵�浠ュ彲浠ヤ笉鎸囧畾
+//        contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
+
+        // 璁剧疆瀛椾綋
+        WriteFont contentWriteFont = new WriteFont();
+        contentWriteFont.setFontHeightInPoints((short) 9);//璁剧疆瀛椾綋澶у皬
+        contentWriteFont.setFontName("浠垮畫"); //璁剧疆瀛椾綋鍚嶅瓧
+        contentWriteCellStyle.setWriteFont(contentWriteFont);//鍦ㄦ牱寮忕敤搴旂敤璁剧疆鐨勫瓧浣�;
+
+        //璁剧疆鏍峰紡;
+        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//璁剧疆搴曡竟妗�;
+        contentWriteCellStyle.setBottomBorderColor((short) 0);//璁剧疆搴曡竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //璁剧疆宸﹁竟妗�;
+        contentWriteCellStyle.setLeftBorderColor((short) 0);//璁剧疆宸﹁竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//璁剧疆鍙宠竟妗�;
+        contentWriteCellStyle.setRightBorderColor((short) 0);//璁剧疆鍙宠竟妗嗛鑹�;
+        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//璁剧疆椤惰竟妗�;
+        contentWriteCellStyle.setTopBorderColor((short) 0); ///璁剧疆椤惰竟妗嗛鑹�;
+
+        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 姘村钩灞呬腑
+        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 鍨傜洿灞呬腑
+        contentWriteCellStyle.setWrapped(false); //璁剧疆鑷姩鎹㈣;
+
+//        contentWriteCellStyle.setShrinkToFit(true);//璁剧疆鏂囨湰鏀剁缉鑷冲悎閫�
+
+        return contentWriteCellStyle;
+    }
+
+}
diff --git a/src/main/resources/mapper/staff/PersonalShiftMapper.xml b/src/main/resources/mapper/staff/PersonalShiftMapper.xml
new file mode 100644
index 0000000..d8ddb1d
--- /dev/null
+++ b/src/main/resources/mapper/staff/PersonalShiftMapper.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.staff.mapper.PersonalShiftMapper">
+
+    <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+    <resultMap id="BaseResultMap" type="com.ruoyi.staff.pojo.PersonalShift">
+        <id column="id" property="id" />
+        <result column="personal_attendance_location_config_id" property="personalAttendanceLocationConfigId" />
+        <result column="staff_on_job_id" property="staffOnJobId" />
+        <result column="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+        <result column="work_time" property="workTime" />
+    </resultMap>
+    <select id="performanceShiftPage" resultType="com.ruoyi.staff.dto.PerformanceShiftMapDto">
+         SELECT
+        u.staff_name name,
+        GROUP_CONCAT(s.work_time, '锛�', IFNULL(palc.shift, ''), '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time,
+                u.id user_id
+        FROM personal_shift s
+        LEFT JOIN staff_on_job u ON u.id = s.staff_on_job_id
+        LEFT JOIN personal_attendance_location_config palc ON palc.id = s.personal_attendance_location_config_id
+        <where>
+             <if test="sysDeptId != null and sysDeptId != ''">
+                and u.sys_dept_id = #{sysDeptId}
+            </if>
+            <if test="time != null and time != ''">
+                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
+            </if>
+            <if test="userName != null and userName != ''">
+                and u.staff_name like concat('%', #{userName}, '%')
+            </if>
+        </where>
+        GROUP BY u.id
+        order by s.create_time
+    </select>
+   
+    <select id="performanceShiftYear" resultType="java.util.Map">
+         SELECT
+         u.staff_name name,
+         u.id user_id,
+         u.staff_no account,
+        DATE_FORMAT(s.work_time, '%c') work_time,
+        GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), '锛�', IFNULL(palc.shift, '') order by s.work_time SEPARATOR ';') month_str
+        FROM personal_shift s
+        LEFT JOIN staff_on_job u ON u.id = s.staff_on_job_id
+         LEFT JOIN personal_attendance_location_config palc ON palc.id = s.personal_attendance_location_config_id
+         <where>
+            <if test="time != null and time != ''">
+                and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' )
+            </if>
+            <if test="userName != null and userName != ''">
+                and u.staff_name like concat('%', #{userName}, '%')
+            </if>
+             <if test="sysDeptId != null and sysDeptId != ''">
+                and u.sys_dept_id = #{sysDeptId}
+            </if>
+          </where>
+        GROUP BY u.id
+        order by s.create_time
+    </select>
+    <select id="performanceShiftYearList" resultType="java.util.Map">
+         SELECT
+        u.staff_name name,
+        s.staff_on_job_id user_id, u.staff_no account,
+        DATE_FORMAT(s.work_time, '%c') work_time,
+        GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), '锛�', IFNULL(palc.shift, '') order by s.work_time SEPARATOR ';') month_str
+        FROM personal_shift s
+        LEFT JOIN staff_on_job u ON u.id = s.staff_on_job_id
+        LEFT JOIN personal_attendance_location_config palc ON palc.id = s.personal_attendance_location_config_id
+       <where>
+        <if test="time != null and time != ''">
+            and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' )
+        </if>
+        <if test="userName != null and userName != ''">
+            and u.staff_name like concat('%', #{userName}, '%')
+        </if>
+       <if test="sysDeptId != null and sysDeptId != ''">
+            and u.sys_dept_id = #{sysDeptId}
+       </if>
+          </where>
+        GROUP BY u.id
+        order by s.create_time
+    </select>
+    <select id="performanceShiftList" resultType="com.ruoyi.staff.dto.PerformanceShiftMapDto">
+         SELECT
+        u.staff_name name,
+        GROUP_CONCAT(s.work_time, '锛�', IFNULL(palc.shift, ''), '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time, u.id user_id
+        FROM personal_shift s
+        LEFT JOIN staff_on_job u ON u.id = s.staff_on_job_id
+        LEFT JOIN personal_attendance_location_config palc ON palc.id = s.personal_attendance_location_config_id
+        <where>
+            <if test="time != null and time != ''">
+                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
+            </if>
+            <if test="userName != null and userName != ''">
+                and u.staff_name like concat('%', #{userName}, '%')
+            </if>
+             <if test="sysDeptId != null and sysDeptId != ''">
+                and u.sys_dept_id = #{sysDeptId}
+            </if>
+        </where>
+        GROUP BY u.id
+        order by s.create_time
+    </select>
+
+</mapper>

--
Gitblit v1.9.3