From 93723438fd269d2f602439eabca127ed4054818a Mon Sep 17 00:00:00 2001 From: buhuazhen <hua100783@gmail.com> Date: 星期四, 04 九月 2025 11:00:19 +0800 Subject: [PATCH] Merge branch 'pim_bhz' into pim_ywx --- src/main/java/com/ruoyi/staff/mapper/StaffSchedulingMapper.java | 23 ++ src/main/java/com/ruoyi/staff/service/StaffSchedulingService.java | 20 ++ src/main/java/com/ruoyi/staff/pojo/StaffScheduling.java | 106 +++++++++++++ src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java | 49 ++++++ src/main/java/com/ruoyi/staff/vo/SearchSchedulingVo.java | 27 +++ src/main/resources/mapper/staff/StaffSchedulingMapper.xml | 52 ++++++ src/main/java/com/ruoyi/staff/service/impl/StaffSchedulingServiceImpl.java | 61 +++++++ src/main/java/com/ruoyi/staff/dto/SaveStaffSchedulingDto.java | 49 ++++++ src/main/java/com/ruoyi/staff/dto/StaffSchedulingDto.java | 74 +++++++++ src/main/java/com/ruoyi/dto/PageDto.java | 18 ++ 10 files changed, 479 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ruoyi/dto/PageDto.java b/src/main/java/com/ruoyi/dto/PageDto.java new file mode 100644 index 0000000..7c6f399 --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java b/src/main/java/com/ruoyi/staff/controller/StaffSchedulingController.java new file mode 100644 index 0000000..e7c4c40 --- /dev/null +++ b/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(); + } + +} diff --git a/src/main/java/com/ruoyi/staff/dto/SaveStaffSchedulingDto.java b/src/main/java/com/ruoyi/staff/dto/SaveStaffSchedulingDto.java new file mode 100644 index 0000000..25a41b3 --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/ruoyi/staff/dto/StaffSchedulingDto.java b/src/main/java/com/ruoyi/staff/dto/StaffSchedulingDto.java new file mode 100644 index 0000000..6643a38 --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/ruoyi/staff/mapper/StaffSchedulingMapper.java b/src/main/java/com/ruoyi/staff/mapper/StaffSchedulingMapper.java new file mode 100644 index 0000000..45fecac --- /dev/null +++ b/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 閽堝琛ㄣ�恠taff_scheduling銆戠殑鏁版嵁搴撴搷浣淢apper +* @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); +} + + + + diff --git a/src/main/java/com/ruoyi/staff/pojo/StaffScheduling.java b/src/main/java/com/ruoyi/staff/pojo/StaffScheduling.java new file mode 100644 index 0000000..89be920 --- /dev/null +++ b/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; +} \ No newline at end of file diff --git a/src/main/java/com/ruoyi/staff/service/StaffSchedulingService.java b/src/main/java/com/ruoyi/staff/service/StaffSchedulingService.java new file mode 100644 index 0000000..b12faa1 --- /dev/null +++ b/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 閽堝琛ㄣ�恠taff_scheduling銆戠殑鏁版嵁搴撴搷浣淪ervice +* @createDate 2025-09-03 14:50:34 +*/ +public interface StaffSchedulingService extends IService<StaffScheduling> { + + void saveStaffScheduling(SaveStaffSchedulingDto saveStaffSchedulingDto); + + IPage<StaffSchedulingDto> listPage(SearchSchedulingVo vo); +} diff --git a/src/main/java/com/ruoyi/staff/service/impl/StaffSchedulingServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/StaffSchedulingServiceImpl.java new file mode 100644 index 0000000..b42d1fc --- /dev/null +++ b/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 閽堝琛ㄣ�恠taff_scheduling銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 + * @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); + } +} + + + + diff --git a/src/main/java/com/ruoyi/staff/vo/SearchSchedulingVo.java b/src/main/java/com/ruoyi/staff/vo/SearchSchedulingVo.java new file mode 100644 index 0000000..c546208 --- /dev/null +++ b/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; +} diff --git a/src/main/resources/mapper/staff/StaffSchedulingMapper.xml b/src/main/resources/mapper/staff/StaffSchedulingMapper.xml new file mode 100644 index 0000000..1a32ef1 --- /dev/null +++ b/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> -- Gitblit v1.9.3