考勤管理-班次管理后台接口完成
This commit is contained in:
parent
a0c5fdcb5f
commit
e73257514b
|
@ -86,4 +86,15 @@ public class Constants {
|
|||
* 1:代表隐藏
|
||||
*/
|
||||
public static final String VISIBLE_1 = "1";
|
||||
|
||||
|
||||
/**
|
||||
* 0:代表发布
|
||||
*/
|
||||
public static final String STATUS_PUBLISH = "0";
|
||||
|
||||
/**
|
||||
* 1:代表未发布
|
||||
*/
|
||||
public static final String STATUS_UNPUBLISH = "1";
|
||||
}
|
||||
|
|
|
@ -51,4 +51,13 @@ public class Message implements Serializable {
|
|||
public static final String TASK_STATUS_NOT_IN_PROGRESS = "任务状态不是进行中";
|
||||
public static final String TASK_IN_CYCLE = "父级任务存在循环依赖:";
|
||||
public static final String TASK_GROUP_ID_NOT_EXIST = "任务组id不存在";
|
||||
public static final String WORK_TIME_START_CAN_NOT_BEFORE_WORK_TIME_END = "下班时间不能早于上班时间";
|
||||
public static final String REST_TIME_START_CAN_NOT_BEFORE_REST_TIME_END = "休息结束时间不能早于休息开始时间";
|
||||
public static final String REST_TIME_START_MUST_BETWEEN_WORK_TIME = "休息开始时间必须是在上班时间范围内";
|
||||
public static final String REST_TIME_END_MUST_BETWEEN_WORK_TIME = "休息结束时间必须是在上班时间范围内";
|
||||
public static final String EARLY_TIME_LIMIT_CAN_NOT_BEFORE_EARLY_TIME_OFFSET = "早退临界时间不能小于早退豁免时间";
|
||||
public static final String LATE_TIME_LIMIT_CAN_NOT_BEFORE_LATE_TIME_OFFSET = "迟到临界时间不能小于迟到豁免时间";
|
||||
public static final String WORK_SHIFT_NAME_EXIST = "班次名称已经存在";
|
||||
public static final String WORK_SHIFT_NOT_EXIST = "班次不存在";
|
||||
public static final String WORK_SHIFT_IS_NOT_UNPUBLISH = "班次的状态不是未发布";
|
||||
}
|
||||
|
|
|
@ -91,5 +91,11 @@ public interface Converts {
|
|||
InsuranceInfoEntity toInsuranceInfoEntity(InsuranceInfoReq req);
|
||||
|
||||
AttachInfoResp toAttacheInfoResp(AttachInfoEntity entity);
|
||||
|
||||
List<WorkShiftListResp> toWorkShiftListResp(List<WorkShiftEntity> list);
|
||||
|
||||
WorkShiftResp toWorkShiftResp(WorkShiftEntity entity);
|
||||
|
||||
WorkShiftEntity toWorkShiftEntity(WorkShiftReq req);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,15 @@ public class MenuEntity extends AuditableEntity implements Serializable {
|
|||
@TableField("order_num")
|
||||
private Integer orderNum;
|
||||
|
||||
@ExcelProperty("请求地址")
|
||||
@ApiModelProperty("请求地址")
|
||||
@TableField("url")
|
||||
private String url;
|
||||
@ExcelProperty("组件地址")
|
||||
@ApiModelProperty("组件地址")
|
||||
@TableField("component")
|
||||
private String component;
|
||||
|
||||
@ExcelProperty("路由地址")
|
||||
@ApiModelProperty("路由地址")
|
||||
@TableField("path")
|
||||
private String path;
|
||||
|
||||
@ExcelProperty("菜单类型(M目录 C菜单 F按钮)")
|
||||
@ApiModelProperty("菜单类型(M目录 C菜单 F按钮)")
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package com.dite.znpt.domain.entity;
|
||||
|
||||
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 com.dite.znpt.domain.AuditableEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:08
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("work_shift")
|
||||
@ApiModel(value="WorkShitEntity对象", description="班次信息")
|
||||
public class WorkShiftEntity extends AuditableEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1912356282767651959L;
|
||||
|
||||
@ApiModelProperty("班次id")
|
||||
@TableId(value = "work_shift_id", type = IdType.ASSIGN_UUID)
|
||||
private String workShiftId;
|
||||
|
||||
@ApiModelProperty("班次名称")
|
||||
@TableField("work_shift_name")
|
||||
private String workShiftName;
|
||||
|
||||
@ApiModelProperty("上班时间")
|
||||
@TableField("work_time_start")
|
||||
private LocalTime workTimeStart;
|
||||
|
||||
@ApiModelProperty("迟到豁免时间,单位分钟")
|
||||
@TableField("late_time_offset")
|
||||
private Integer lateTimeOffset;
|
||||
|
||||
@ApiModelProperty("迟到时间临界值,单位分钟")
|
||||
@TableField("late_time_limit")
|
||||
private Integer lateTimeLimit;
|
||||
|
||||
@ApiModelProperty("下班时间")
|
||||
@TableField("work_time_end")
|
||||
private LocalTime workTimeEnd;
|
||||
|
||||
@ApiModelProperty("早退豁免时间,单位分钟")
|
||||
@TableField("early_time_offset")
|
||||
private Integer earlyTimeOffset;
|
||||
|
||||
@ApiModelProperty("早退时间临界值,单位分钟")
|
||||
@TableField("early_time_limit")
|
||||
private Integer earlyTimeLimit;
|
||||
|
||||
@ApiModelProperty("休息时间开始")
|
||||
@TableField("rest_time_start")
|
||||
private LocalTime restTimeStart;
|
||||
|
||||
@ApiModelProperty("休息时间结束")
|
||||
@TableField("rest_time_end")
|
||||
private LocalTime restTimeEnd;
|
||||
|
||||
@ApiModelProperty("工作时间长")
|
||||
@TableField("work_time")
|
||||
private Integer workTime;
|
||||
|
||||
@ApiModelProperty("状态,0-已发布,1-未发布")
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 1代表删除)")
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.dite.znpt.util.ValidationGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -32,9 +34,14 @@ public class MenuReq implements Serializable {
|
|||
@ApiModelProperty("显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
@Size(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, max = 100, message = "请求地址不能超过100个字符")
|
||||
@ApiModelProperty("请求地址")
|
||||
private String url;
|
||||
@Size(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, max = 200, message = "路由地址不能超过200个字符")
|
||||
@ApiModelProperty("路由地址")
|
||||
private String path;
|
||||
|
||||
@Size(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, max = 200, message = "组件地址不能超过200个字符")
|
||||
@ExcelProperty("组件地址")
|
||||
@ApiModelProperty("组件地址")
|
||||
private String component;
|
||||
|
||||
@NotBlank(groups = {ValidationGroup.Insert.class, ValidationGroup.Update.class}, message = "菜单类型不能为空")
|
||||
@ApiModelProperty("菜单类型")
|
||||
|
|
|
@ -30,8 +30,11 @@ public class MenuResp implements Serializable {
|
|||
@ApiModelProperty("显示顺序")
|
||||
private String orderNum;
|
||||
|
||||
@ApiModelProperty("请求地址")
|
||||
private String url;
|
||||
@ApiModelProperty("路由地址")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty("组件地址")
|
||||
private String component;
|
||||
|
||||
@ApiModelProperty("菜单类型")
|
||||
private String menuType;
|
||||
|
|
|
@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +15,10 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
@ApiModel("用户信息")
|
||||
public class UserInfo {
|
||||
public class UserInfo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1433874497843073028L;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
private UserListResp user;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:39
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("班次信息列表响应实体")
|
||||
public class WorkShiftListResp implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 530703326351692657L;
|
||||
|
||||
@ApiModelProperty("班次id")
|
||||
private String workShiftId;
|
||||
|
||||
@ApiModelProperty("班次名称")
|
||||
private String workShiftName;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("上班时间")
|
||||
private LocalTime workTimeStart;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("下班时间")
|
||||
private LocalTime workTimeEnd;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("状态描述")
|
||||
private String statusLabel;
|
||||
|
||||
@ApiModelProperty("创建人id")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建人名称")
|
||||
private String createUserName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:39
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("班次信息请求实体")
|
||||
public class WorkShiftReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3008068678585003135L;
|
||||
|
||||
@NotBlank(message = "班次名称不能为空")
|
||||
@ApiModelProperty("班次名称")
|
||||
private String workShiftName;
|
||||
|
||||
@NotNull(message = "上班时间不能为空")
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("上班时间")
|
||||
private LocalTime workTimeStart;
|
||||
|
||||
@ApiModelProperty("迟到豁免时间,单位分钟")
|
||||
private Integer lateTimeOffset;
|
||||
|
||||
@ApiModelProperty("迟到时间临界值,单位分钟")
|
||||
private Integer lateTimeLimit;
|
||||
|
||||
@NotNull(message = "下班时间不能为空")
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("下班时间")
|
||||
private LocalTime workTimeEnd;
|
||||
|
||||
@ApiModelProperty("早退豁免时间,单位分钟")
|
||||
private Integer earlyTimeOffset;
|
||||
|
||||
@ApiModelProperty("早退时间临界值,单位分钟")
|
||||
private Integer earlyTimeLimit;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("休息时间开始")
|
||||
private LocalTime restTimeStart;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("休息时间结束")
|
||||
private LocalTime restTimeEnd;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:39
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("班次信息响应实体")
|
||||
public class WorkShiftResp implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 7000086760170568103L;
|
||||
|
||||
@ApiModelProperty("班次id")
|
||||
private String workShiftId;
|
||||
|
||||
@ApiModelProperty("班次名称")
|
||||
private String workShiftName;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("上班时间")
|
||||
private LocalTime workTimeStart;
|
||||
|
||||
@ApiModelProperty("迟到豁免时间,单位分钟")
|
||||
private Integer lateTimeOffset;
|
||||
|
||||
@ApiModelProperty("迟到时间临界值,单位分钟")
|
||||
private Integer lateTimeLimit;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("下班时间")
|
||||
private LocalTime workTimeEnd;
|
||||
|
||||
@ApiModelProperty("早退豁免时间,单位分钟")
|
||||
private Integer earlyTimeOffset;
|
||||
|
||||
@ApiModelProperty("早退时间临界值,单位分钟")
|
||||
private Integer earlyTimeLimit;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("休息时间开始")
|
||||
private LocalTime restTimeStart;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@ApiModelProperty("休息时间结束")
|
||||
private LocalTime restTimeEnd;
|
||||
|
||||
@ApiModelProperty("工作时间长")
|
||||
private Integer workTime;
|
||||
|
||||
@ApiModelProperty("状态,0-已发布,1-未发布")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("状态,0-已发布,1-未发布")
|
||||
private String statusLabel;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.dite.znpt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dite.znpt.domain.entity.WorkShiftEntity;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:26
|
||||
* @description
|
||||
*/
|
||||
public interface WorkShiftMapper extends BaseMapper<WorkShiftEntity> {
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.dite.znpt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dite.znpt.domain.entity.WorkShiftEntity;
|
||||
import com.dite.znpt.domain.vo.WorkShiftListResp;
|
||||
import com.dite.znpt.domain.vo.WorkShiftReq;
|
||||
import com.dite.znpt.domain.vo.WorkShiftResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:27
|
||||
* @description
|
||||
*/
|
||||
public interface WorkShiftService extends IService<WorkShiftEntity> {
|
||||
|
||||
List<WorkShiftListResp> page(String workShitName);
|
||||
|
||||
List<WorkShiftListResp> list(String workShitName);
|
||||
|
||||
WorkShiftResp detail(String workShiftId);
|
||||
|
||||
void save(WorkShiftReq req);
|
||||
|
||||
void update(String workShiftId, WorkShiftReq req);
|
||||
|
||||
void publish(String workShiftId);
|
||||
|
||||
void delete(String workShiftId);
|
||||
|
||||
|
||||
}
|
|
@ -46,9 +46,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
|
|||
tree.setId(treeNode.getMenuId());
|
||||
tree.setParentId(treeNode.getParentId());
|
||||
tree.setName(treeNode.getMenuName());
|
||||
tree.setWeight(treeNode.getOrderNum());
|
||||
tree.putExtra("menuType",treeNode.getMenuType());
|
||||
tree.putExtra("visible",treeNode.getVisible());
|
||||
tree.putExtra("orderNum",treeNode.getOrderNum());
|
||||
tree.putExtra("path",treeNode.getPath());
|
||||
tree.putExtra("component",treeNode.getComponent());
|
||||
tree.putExtra("perms",treeNode.getPerms());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.constant.Constants;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.converts.Converts;
|
||||
import com.dite.znpt.domain.entity.UserEntity;
|
||||
import com.dite.znpt.domain.entity.WorkShiftEntity;
|
||||
import com.dite.znpt.domain.vo.WorkShiftListResp;
|
||||
import com.dite.znpt.domain.vo.WorkShiftReq;
|
||||
import com.dite.znpt.domain.vo.WorkShiftResp;
|
||||
import com.dite.znpt.exception.ServiceException;
|
||||
import com.dite.znpt.mapper.WorkShiftMapper;
|
||||
import com.dite.znpt.service.UserService;
|
||||
import com.dite.znpt.service.WorkShiftService;
|
||||
import com.dite.znpt.util.PageUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:28
|
||||
* @description
|
||||
*/
|
||||
@Service
|
||||
public class WorkShitServiceImpl extends ServiceImpl<WorkShiftMapper, WorkShiftEntity> implements WorkShiftService {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public List<WorkShiftListResp> page(String workShitName) {
|
||||
PageUtil.startPage();
|
||||
return this.list(workShitName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkShiftListResp> list(String workShitName) {
|
||||
List<WorkShiftEntity> list = this.list(Wrappers.lambdaQuery(WorkShiftEntity.class).eq(WorkShiftEntity::getDelFlag, Constants.DEL_FLAG_0).like(StrUtil.isNotBlank(workShitName), WorkShiftEntity::getWorkShiftName, workShitName));
|
||||
List<String> userIds = list.stream().map(WorkShiftEntity::getCreateBy).toList();
|
||||
Map<String, UserEntity> userIdMap = !userIds.isEmpty() ? userService.listByIds(userIds).stream().collect(Collectors.toMap(UserEntity::getUserId, Function.identity())): new HashMap<>();
|
||||
List<WorkShiftListResp> result = Converts.INSTANCE.toWorkShiftListResp(list);
|
||||
result.forEach(workShiftListResp -> {
|
||||
workShiftListResp.setStatusLabel(Constants.STATUS_UNPUBLISH.equals(workShiftListResp.getStatus()) ? "未发布" : "已发布");
|
||||
if(userIdMap.containsKey(workShiftListResp.getCreateBy())){
|
||||
workShiftListResp.setCreateUserName(userIdMap.get(workShiftListResp.getCreateBy()).getName());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkShiftResp detail(String workShiftId) {
|
||||
WorkShiftEntity workShift = this.getById(workShiftId);
|
||||
if(workShift == null || !Constants.DEL_FLAG_0.equals(workShift.getDelFlag())){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NOT_EXIST);
|
||||
}
|
||||
WorkShiftResp workShiftResp = Converts.INSTANCE.toWorkShiftResp(workShift);
|
||||
workShiftResp.setStatusLabel(Constants.STATUS_UNPUBLISH.equals(workShiftResp.getStatus()) ? "未发布" : "已发布");
|
||||
return workShiftResp;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(WorkShiftReq req) {
|
||||
List<WorkShiftEntity> list = this.list(Wrappers.lambdaQuery(WorkShiftEntity.class).eq(WorkShiftEntity::getDelFlag, Constants.DEL_FLAG_0).eq(WorkShiftEntity::getWorkShiftName, req.getWorkShiftName()));
|
||||
if(!list.isEmpty()){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NAME_EXIST);
|
||||
}
|
||||
WorkShiftEntity entity = validation(req);
|
||||
entity.setStatus(Constants.STATUS_UNPUBLISH);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
private WorkShiftEntity validation(WorkShiftReq req) {
|
||||
if(req.getWorkTimeEnd().isBefore(req.getWorkTimeStart())){
|
||||
throw new ServiceException(Message.WORK_TIME_START_CAN_NOT_BEFORE_WORK_TIME_END);
|
||||
}
|
||||
int workTime = req.getWorkTimeEnd().toSecondOfDay() - req.getWorkTimeStart().toSecondOfDay() ;
|
||||
if(req.getRestTimeEnd() != null && req.getRestTimeStart()!= null){
|
||||
if(req.getRestTimeEnd().isBefore(req.getRestTimeStart())){
|
||||
throw new ServiceException(Message.REST_TIME_START_CAN_NOT_BEFORE_REST_TIME_END);
|
||||
}
|
||||
if(!(req.getRestTimeStart().isAfter(req.getWorkTimeStart()) && req.getRestTimeStart().isBefore(req.getWorkTimeEnd()))){
|
||||
throw new ServiceException(Message.REST_TIME_START_MUST_BETWEEN_WORK_TIME);
|
||||
}
|
||||
if(!(req.getRestTimeEnd().isAfter(req.getWorkTimeStart()) && req.getRestTimeEnd().isBefore(req.getWorkTimeEnd()))){
|
||||
throw new ServiceException(Message.REST_TIME_END_MUST_BETWEEN_WORK_TIME);
|
||||
}
|
||||
workTime = workTime - (req.getRestTimeEnd().toSecondOfDay() - req.getRestTimeStart().toSecondOfDay());
|
||||
}else {
|
||||
req.setRestTimeEnd(null);
|
||||
req.setRestTimeEnd(null);
|
||||
}
|
||||
if(req.getEarlyTimeLimit() != null && req.getEarlyTimeOffset()!= null && req.getEarlyTimeLimit() <= req.getEarlyTimeOffset()){
|
||||
throw new ServiceException(Message.EARLY_TIME_LIMIT_CAN_NOT_BEFORE_EARLY_TIME_OFFSET);
|
||||
}
|
||||
if(req.getLateTimeLimit() != null && req.getLateTimeOffset() != null && req.getLateTimeLimit() <= req.getLateTimeOffset()){
|
||||
throw new ServiceException(Message.LATE_TIME_LIMIT_CAN_NOT_BEFORE_LATE_TIME_OFFSET);
|
||||
}
|
||||
|
||||
WorkShiftEntity entity = Converts.INSTANCE.toWorkShiftEntity(req);
|
||||
entity.setWorkTime(workTime/60);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void update(String workShiftId, WorkShiftReq req) {
|
||||
WorkShiftEntity workShift = this.getById(workShiftId);
|
||||
if(workShift == null || !Constants.DEL_FLAG_0.equals(workShift.getDelFlag())){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NOT_EXIST);
|
||||
}
|
||||
List<WorkShiftEntity> list = this.list(Wrappers.lambdaQuery(WorkShiftEntity.class).eq(WorkShiftEntity::getDelFlag, Constants.DEL_FLAG_0).eq(WorkShiftEntity::getWorkShiftName, req.getWorkShiftName()));
|
||||
if(!req.getWorkShiftName().equals(workShift.getWorkShiftName()) && !list.isEmpty()){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NAME_EXIST);
|
||||
}
|
||||
WorkShiftEntity entity = validation(req);
|
||||
entity.setWorkShiftId(workShiftId);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void publish(String workShiftId) {
|
||||
WorkShiftEntity workShift = this.getById(workShiftId);
|
||||
if(workShift == null || !Constants.DEL_FLAG_0.equals(workShift.getDelFlag())){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NOT_EXIST);
|
||||
}
|
||||
if(!Constants.STATUS_UNPUBLISH.equals(workShift.getStatus())){
|
||||
throw new ServiceException(Message.WORK_SHIFT_IS_NOT_UNPUBLISH);
|
||||
}
|
||||
workShift.setStatus(Constants.STATUS_PUBLISH);
|
||||
this.updateById(workShift);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void delete(String workShiftId) {
|
||||
WorkShiftEntity workShift = this.getById(workShiftId);
|
||||
if(workShift == null || !Constants.DEL_FLAG_0.equals(workShift.getDelFlag())){
|
||||
throw new ServiceException(Message.WORK_SHIFT_NOT_EXIST);
|
||||
}
|
||||
workShift.setDelFlag(Constants.DEL_FLAG_1);
|
||||
this.updateById(workShift);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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.dite.znpt.mapper.WorkShiftMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,77 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.WorkShiftListResp;
|
||||
import com.dite.znpt.domain.vo.WorkShiftReq;
|
||||
import com.dite.znpt.domain.vo.WorkShiftResp;
|
||||
import com.dite.znpt.service.WorkShiftService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/30/周一 10:29
|
||||
* @description
|
||||
*/
|
||||
@Api(tags = "班次管理")
|
||||
@RestController
|
||||
@RequestMapping("/work-shift")
|
||||
public class WorkShiftController {
|
||||
|
||||
@Resource
|
||||
private WorkShiftService workShiftService;
|
||||
|
||||
@ApiOperation(value = "分页查询班次信息", httpMethod = "GET")
|
||||
@GetMapping("/page")
|
||||
public PageResult<WorkShiftListResp> page(@RequestParam(required = false) String workShitName) {
|
||||
return PageResult.ok(workShiftService.page(workShitName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询班次信息列表", httpMethod = "GET")
|
||||
@GetMapping("/list")
|
||||
public Result<List<WorkShiftListResp>> list(@RequestParam(required = false) String workShiftName) {
|
||||
return Result.ok(workShiftService.list(workShiftName));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "查询班次详情信息", httpMethod = "GET")
|
||||
@GetMapping("/detail/{workShiftId}")
|
||||
public Result<WorkShiftResp> detail(@PathVariable String workShiftId) {
|
||||
return Result.ok(workShiftService.detail(workShiftId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增班次信息", httpMethod = "POST")
|
||||
@PostMapping()
|
||||
public Result<?> add(@Valid @RequestBody WorkShiftReq req){
|
||||
workShiftService.save(req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改班次信息", httpMethod = "PUT")
|
||||
@PutMapping("/{workShiftId}")
|
||||
public Result<?> edit(@PathVariable String workShiftId, @Valid @RequestBody WorkShiftReq req){
|
||||
workShiftService.update(workShiftId, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "发布班次信息", httpMethod = "PUT")
|
||||
@PutMapping("/publish/{workShiftId}")
|
||||
public Result<?> publish(@PathVariable String workShiftId){
|
||||
workShiftService.publish(workShiftId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除班次信息", httpMethod = "DELETE")
|
||||
@DeleteMapping("/{workShiftId}")
|
||||
public Result<?> remove(@PathVariable String workShiftId){
|
||||
workShiftService.delete(workShiftId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue