buhuazhen
2 天以前 93723438fd269d2f602439eabca127ed4054818a
Merge branch 'pim_bhz' into pim_ywx
已添加10个文件
479 ■■■■■ 文件已修改
src/main/java/com/ruoyi/dto/PageDto.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/dto/SaveStaffSchedulingDto.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/dto/StaffSchedulingDto.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/mapper/StaffSchedulingMapper.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/pojo/StaffScheduling.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/service/StaffSchedulingService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/service/impl/StaffSchedulingServiceImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/staff/vo/SearchSchedulingVo.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/staff/StaffSchedulingMapper.xml 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/dto/PageDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.ruoyi.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
 * @author buhuazhen
 * @date 2025/9/3
 * @email 3038525872@qq.com
 */
@Getter
@Setter
public class PageDto implements Serializable {
    private Integer current = 1;
    private Integer size = 100;
}
src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package com.ruoyi.staff.controller;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.staff.dto.SaveStaffSchedulingDto;
import com.ruoyi.staff.service.StaffSchedulingService;
import com.ruoyi.staff.vo.SearchSchedulingVo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * æŽ’班
 * @author buhuazhen
 * @date 2025/9/3
 * @email 3038525872@qq.com
 */
@RestController
@RequestMapping("/staff/staffScheduling")
@RequiredArgsConstructor
public class StaffSchedulingController {
    private final StaffSchedulingService staffSchedulingService;
    @PostMapping("/listPage")
    public AjaxResult listPage(@RequestBody SearchSchedulingVo vo){
       return AjaxResult.success(staffSchedulingService.listPage(vo));
    }
    @PostMapping("/save")
    public AjaxResult save(@RequestBody @Validated SaveStaffSchedulingDto saveStaffSchedulingDto){
        staffSchedulingService.saveStaffScheduling(saveStaffSchedulingDto);
        return AjaxResult.success();
    }
    @DeleteMapping("/delByIds")
    public AjaxResult delByIds(@RequestBody List<Integer> ids){
        staffSchedulingService.removeByIds(ids);
        return AjaxResult.success();
    }
    @DeleteMapping("/del/{id}")
    public AjaxResult del(@PathVariable("id") Integer id){
        staffSchedulingService.removeById(id);
        return AjaxResult.success();
    }
}
src/main/java/com/ruoyi/staff/dto/SaveStaffSchedulingDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package com.ruoyi.staff.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
 * @author buhuazhen
 * @date 2025/9/3
 * @email 3038525872@qq.com
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SaveStaffSchedulingDto implements Serializable {
    private Integer id;
    @NotNull(message = "必须要选择员工")
    private Integer staffId;
    @NotNull(message = "部门id不能为空!")
    private Integer department;
    @NotNull(message = "班次id不能为空!")
    private Integer shiftType;
    @NotNull(message = "工作日不能为空!")
    private Date workDate;
    @NotNull(message = "上班时间不能为空!")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime workStartTime;
    @NotNull(message = "下班时间不能为空!")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime workEndTime;
    @NotNull(message = "工时不能为空!")
    private Integer status;
    private String remark;
}
src/main/java/com/ruoyi/staff/dto/StaffSchedulingDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
package com.ruoyi.staff.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
 * @author buhuazhen
 * @date 2025/9/4
 * @email 3038525872@qq.com
 */
@Data
public class StaffSchedulingDto implements Serializable {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * å‘˜å·¥ID
     */
    private Integer staffId;
    private String staffName;
    private String staffNo;
    /**
     * éƒ¨é—¨
     */
    private String department;
    /**
     * æŽ’班类型
     */
    private String shiftType;
    /**
     * å·¥ä½œæ—¥æœŸ
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date workDate;
    /**
     * å¼€å§‹å·¥ä½œæ—¶é—´
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime workStartTime;
    /**
     * ç»“束工作时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime workEndTime;
    /**
     * å·¥ä½œæ—¶é•¿
     */
    private BigDecimal workHours;
    /**
     * çŠ¶æ€
     */
    private String status;
    /**
     * å¤‡æ³¨
     */
    private String remark;
}
src/main/java/com/ruoyi/staff/mapper/StaffSchedulingMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.ruoyi.staff.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.staff.dto.StaffSchedulingDto;
import com.ruoyi.staff.pojo.StaffScheduling;
import com.ruoyi.staff.vo.SearchSchedulingVo;
import org.apache.ibatis.annotations.Param;
/**
* @author buhuazhen
* @description é’ˆå¯¹è¡¨ã€staff_scheduling】的数据库操作Mapper
* @createDate 2025-09-03 14:50:34
* @Entity generator.domain.StaffScheduling
*/
public interface StaffSchedulingMapper extends BaseMapper<StaffScheduling> {
    IPage<StaffSchedulingDto> listPage(IPage page, @Param("vo") SearchSchedulingVo vo);
}
src/main/java/com/ruoyi/staff/pojo/StaffScheduling.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,106 @@
package com.ruoyi.staff.pojo;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
 *
 * @TableName staff_scheduling
 */
@TableName(value ="staff_scheduling")
@Data
public class StaffScheduling {
    /**
     *
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * å‘˜å·¥ID
     */
    @TableField(value = "staff_id")
    private Integer staffId;
    /**
     * éƒ¨é—¨
     */
    @TableField(value = "department")
    private Integer department;
    /**
     * æŽ’班类型
     */
    @TableField(value = "shift_type")
    private Integer shiftType;
    /**
     * å·¥ä½œæ—¥æœŸ
     */
    @TableField(value = "work_date")
    private Date workDate;
    /**
     * å¼€å§‹å·¥ä½œæ—¶é—´
     */
    @TableField(value = "work_start_time")
    private LocalDateTime workStartTime;
    /**
     * ç»“束工作时间
     */
    @TableField(value = "work_end_time")
    private LocalDateTime workEndTime;
    /**
     * å·¥ä½œæ—¶é•¿
     */
    @TableField(value = "work_hours")
    private BigDecimal workHours;
    /**
     * çŠ¶æ€
     */
    @TableField(value = "status")
    private Integer status;
    /**
     * å¤‡æ³¨
     */
    @TableField(value = "remark")
    private String remark;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    /**
     * åˆ›å»ºç”¨æˆ·
     */
    @TableField(value = "create_user",fill = FieldFill.INSERT)
    private Long createUser;
    /**
     * ä¿®æ”¹æ—¶é—´
     */
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    /**
     * ä¿®æ”¹ç”¨æˆ·
     */
    @TableField(value = "update_user",fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;
    /**
     * ç§Ÿæˆ·ID
     */
    @TableField(value = "tenant_id",fill = FieldFill.INSERT)
    private Long tenantId;
}
src/main/java/com/ruoyi/staff/service/StaffSchedulingService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.ruoyi.staff.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.staff.dto.SaveStaffSchedulingDto;
import com.ruoyi.staff.dto.StaffSchedulingDto;
import com.ruoyi.staff.pojo.StaffScheduling;
import com.ruoyi.staff.vo.SearchSchedulingVo;
/**
* @author buhuazhen
* @description é’ˆå¯¹è¡¨ã€staff_scheduling】的数据库操作Service
* @createDate 2025-09-03 14:50:34
*/
public interface StaffSchedulingService extends IService<StaffScheduling> {
    void saveStaffScheduling(SaveStaffSchedulingDto saveStaffSchedulingDto);
    IPage<StaffSchedulingDto> listPage(SearchSchedulingVo vo);
}
src/main/java/com/ruoyi/staff/service/impl/StaffSchedulingServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ruoyi.staff.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.staff.dto.SaveStaffSchedulingDto;
import com.ruoyi.staff.dto.StaffSchedulingDto;
import com.ruoyi.staff.mapper.StaffSchedulingMapper;
import com.ruoyi.staff.pojo.StaffScheduling;
import com.ruoyi.staff.service.StaffSchedulingService;
import com.ruoyi.staff.vo.SearchSchedulingVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.Duration;
/**
 * @author buhuazhen
 * @description é’ˆå¯¹è¡¨ã€staff_scheduling】的数据库操作Service实现
 * @createDate 2025-09-03 14:50:34
 */
@Service
@RequiredArgsConstructor
public class StaffSchedulingServiceImpl extends ServiceImpl<StaffSchedulingMapper, StaffScheduling>
        implements StaffSchedulingService {
    private final StaffSchedulingMapper staffSchedulingMapper;
    @Lazy
    @Resource
    private StaffSchedulingService staffSchedulingService;
    @Override
    public void saveStaffScheduling(SaveStaffSchedulingDto saveStaffSchedulingDto) {
        StaffScheduling staffScheduling = new StaffScheduling();
        BeanUtils.copyProperties(saveStaffSchedulingDto, staffScheduling);
        // å¼€å§‹è®¡ç®—æ—¶é—´
        Duration duration = Duration.between(staffScheduling.getWorkStartTime(), staffScheduling.getWorkEndTime());
        long hours = duration.toHours();
        // 0.5
        double minutes = (duration.toMinutes() % 60) / 60.0;
        // minutes = minutes < 0.5 ? 0 : 0.5; å…¬å¸ä¸€èˆ¬ä»¥0.5为标准计算
        staffScheduling.setWorkHours(BigDecimal.valueOf(hours + minutes));
        staffSchedulingService.saveOrUpdate(staffScheduling);
    }
    @Override
    public IPage<StaffSchedulingDto> listPage(SearchSchedulingVo vo) {
        Page<StaffScheduling> page = new Page<>(vo.getCurrent(), vo.getSize());
        return staffSchedulingMapper.listPage(page, vo);
    }
}
src/main/java/com/ruoyi/staff/vo/SearchSchedulingVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.ruoyi.staff.vo;
import com.ruoyi.dto.PageDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
/**
 * @author buhuazhen
 * @date 2025/9/3
 * @email 3038525872@qq.com
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SearchSchedulingVo extends PageDto {
    private String staffName;
    private String shiftType;
    private LocalDate startDate;
    private LocalDate endDate;
}
src/main/resources/mapper/staff/StaffSchedulingMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,52 @@
<?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.StaffSchedulingMapper">
    <resultMap id="BaseResultMap" type="com.ruoyi.staff.pojo.StaffScheduling">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="staffId" column="staff_id" jdbcType="INTEGER"/>
            <result property="department" column="department" jdbcType="INTEGER"/>
            <result property="shiftType" column="shift_type" jdbcType="INTEGER"/>
            <result property="workDate" column="work_date" jdbcType="DATE"/>
            <result property="workStartTime" column="work_start_time" jdbcType="TIMESTAMP"/>
            <result property="workEndTime" column="work_end_time" jdbcType="TIMESTAMP"/>
            <result property="workHours" column="work_hours" jdbcType="DECIMAL"/>
            <result property="status" column="status" jdbcType="INTEGER"/>
            <result property="remark" column="remark" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="createUser" column="create_user" jdbcType="BIGINT"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
            <result property="updateUser" column="update_user" jdbcType="BIGINT"/>
            <result property="tenantId" column="tenant_id" jdbcType="BIGINT"/>
    </resultMap>
    <sql id="Base_Column_List">
        id,staff_id,department,
        shift_type,work_date,work_start_time,
        work_end_time,work_hours,status,
        remark,create_time,create_user,
        update_time,update_user,tenant_id
    </sql>
    <select id="listPage" resultType="com.ruoyi.staff.dto.StaffSchedulingDto">
        SELECT
        t1.*,t2.staff_name as 'staff_name' ,t2.staff_no as 'staff_no'
        FROM staff_scheduling t1
        left join staff_join_leave_record t2 on t1.staff_id = t2.id
        where 1=1
        <if test="vo.staffName != null and vo.staffName != '' ">
            AND t2.staff_name LIKE CONCAT('%', #{vo.staffName}, '%')
        </if>
        <if test="vo.shiftType != null and vo.shiftType != '' ">
            AND t1.shift_type = #{vo.shiftType}
        </if>
        <if test="vo.startDate != null ">
            AND t1.work_date >=  DATE_FORMAT(#{vo.startDate},'%Y-%m-%d')
        </if>
        <if test="vo.endDate != null ">
            AND t1.work_date  <![CDATA[ <= ]]> DATE_FORMAT(#{vo.endDate},'%Y-%m-%d')
        </if>
        ORDER BY t1.create_time DESC
    </select>
</mapper>