Commit debeaf8d authored by huanghaoting's avatar huanghaoting

加班申请和请假申请后端代码

parent 1e18f600
package com.ruoyi.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.LeaveApplication;
import com.ruoyi.service.ILeaveApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 请假申请Controller
*
* @author hht
* @date 2025-03-03
*/
@RestController
@RequestMapping("/application/application")
public class LeaveApplicationController extends BaseController
{
@Autowired
private ILeaveApplicationService leaveApplicationService;
/**
* 查询请假申请列表
*/
@PreAuthorize("@ss.hasPermi('application:application:list')")
@GetMapping("/list")
public TableDataInfo list(LeaveApplication leaveApplication)
{
startPage();
List<LeaveApplication> list = leaveApplicationService.selectLeaveApplicationList(leaveApplication);
return getDataTable(list);
}
/**
* 导出请假申请列表
*/
@PreAuthorize("@ss.hasPermi('application:application:export')")
@Log(title = "请假申请", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, LeaveApplication leaveApplication)
{
List<LeaveApplication> list = leaveApplicationService.selectLeaveApplicationList(leaveApplication);
ExcelUtil<LeaveApplication> util = new ExcelUtil<LeaveApplication>(LeaveApplication.class);
util.exportExcel(response, list, "请假申请数据");
}
/**
* 获取请假申请详细信息
*/
@PreAuthorize("@ss.hasPermi('application:application:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(leaveApplicationService.selectLeaveApplicationById(id));
}
/**
* 新增请假申请
*/
@PreAuthorize("@ss.hasPermi('application:application:add')")
@Log(title = "请假申请", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody LeaveApplication leaveApplication)
{
return toAjax(leaveApplicationService.insertLeaveApplication(leaveApplication));
}
/**
* 修改请假申请
*/
@PreAuthorize("@ss.hasPermi('application:application:edit')")
@Log(title = "请假申请", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody LeaveApplication leaveApplication)
{
return toAjax(leaveApplicationService.updateLeaveApplication(leaveApplication));
}
/**
* 删除请假申请
*/
@PreAuthorize("@ss.hasPermi('application:application:remove')")
@Log(title = "请假申请", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(leaveApplicationService.deleteLeaveApplicationByIds(ids));
}
}
package com.ruoyi.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
import com.ruoyi.domain.vo.ProjectEmployeeInfoVo;
import com.ruoyi.service.IProjectEmployeeInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.OvertimeApplication;
import com.ruoyi.service.IOvertimeApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 加班申请Controller
*
* @author hht
* @date 2025-03-06
*/
@RestController
@RequestMapping("/application/overtimeApplication")
public class OvertimeApplicationController extends BaseController {
@Autowired
private IOvertimeApplicationService overtimeApplicationService;
@Autowired
private IProjectEmployeeInfoService projectEmployeeInfoService;
/**
* 查询加班申请列表
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:list')")
@GetMapping("/list")
public TableDataInfo list(OvertimeApplication overtimeApplication) {
startPage();
List<OvertimeApplication> list = overtimeApplicationService.selectOvertimeApplicationList(overtimeApplication);
return getDataTable(list);
}
/**
* 查询加班申请信息
*/
@GetMapping("/find")
public AjaxResult getProjectEmployeeInfo(@RequestParam String projectManagerNickName) {
List<ProjectEmployeeInfoVo> projectEmployeeInfoList = projectEmployeeInfoService.getProjectEmployeeInfo(projectManagerNickName);
return success(projectEmployeeInfoList);
}
/**
* 导出加班申请列表
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:export')")
@Log(title = "加班申请", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, OvertimeApplication overtimeApplication) {
List<OvertimeApplication> list = overtimeApplicationService.selectOvertimeApplicationList(overtimeApplication);
ExcelUtil<OvertimeApplication> util = new ExcelUtil<OvertimeApplication>(OvertimeApplication.class);
util.exportExcel(response, list, "加班申请数据");
}
/**
* 获取加班申请详细信息
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(overtimeApplicationService.selectOvertimeApplicationById(id));
}
/**
* 新增加班申请
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:add')")
@Log(title = "加班申请", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody OvertimeApplication overtimeApplication) {
return toAjax(overtimeApplicationService.insertOvertimeApplication(overtimeApplication));
}
/**
* 批量新增加班申请
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:add')")
@Log(title = "加班申请(批量)", businessType = BusinessType.INSERT)
@PostMapping("/batch")
public AjaxResult addBatch(@RequestBody OvertimeApplicationBatchDTO batchRequest) {
// 调用 Service 层方法,批量插入
System.out.println("批量插入的数据:"+batchRequest);
int rows = overtimeApplicationService.insertOvertimeApplicationBatch(batchRequest);
return toAjax(rows);
}
/**
* 修改加班申请
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:edit')")
@Log(title = "加班申请", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody OvertimeApplication overtimeApplication) {
return toAjax(overtimeApplicationService.updateOvertimeApplication(overtimeApplication));
}
/**
* 删除加班申请
*/
@PreAuthorize("@ss.hasPermi('application:overtimeApplication:remove')")
@Log(title = "加班申请", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(overtimeApplicationService.deleteOvertimeApplicationByIds(ids));
}
}
package com.ruoyi.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 请假申请对象 leave_application
*
* @author hht
* @date 2025-03-03
*/
public class LeaveApplication extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id自增,记录的唯一标识
*/
private Long id;
/**
* 请假单号
*/
@Excel(name = "请假单号")
private String leaveId;
/**
* 申请日期
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "申请日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date requestDate;
/**
* 请假类型(0代表病假,1代表产假,2代表倒休,3代表婚嫁,4代表年假,5代表陪产假,6代表丧假,7代表事假,8代表孕检假,9代表流产假))
*/
@Excel(name = "请假类型", readConverterExp = "0=病假,1=产假,2=倒休,3=婚假,4=年假,5=陪产假,6=丧假,7=事假,8=孕检假,9=流产假")
private String leaveType;
/**
* 姓名
*/
@Excel(name = "姓名")
private String uname;
/**
* 一级审批人
*/
@Excel(name = "一级审批人")
private String firstApprover;
/**
* 二级审批人
*/
@Excel(name = "二级审批人")
private String secondApprover;
/**
* 请假开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "请假开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date startTime;
/**
* 请假结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "请假结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date endTime;
/**
* 请假时长
*/
@Excel(name = "请假时长")
private BigDecimal leavetimeHours;
/**
* 请假天数
*/
@Excel(name = "请假天数")
private BigDecimal leaveDaysSubtotal;
/**
* 合计请假天数
*/
@Excel(name = "合计请假天数")
private BigDecimal totalLeaveDays;
/**
* 请假事由说明
*/
@Excel(name = "请假事由说明")
private String reason;
/**
* 相关证明(保存文件或图片的路径)
*/
@Excel(name = "相关证明", readConverterExp = "相关证明(保存文件或图片的路径)")
private String proof;
/**
* 审批状态
*/
@Excel(name = "审批状态")
private String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date updatedTime;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setLeaveId(String leaveId) {
this.leaveId = leaveId;
}
public String getLeaveId() {
return leaveId;
}
public void setRequestDate(Date requestDate) {
this.requestDate = requestDate;
}
public Date getRequestDate() {
return requestDate;
}
public void setLeaveType(String leaveType) {
this.leaveType = leaveType;
}
public String getLeaveType() {
return leaveType;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUname() {
return uname;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getStartTime() {
return startTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public Date getEndTime() {
return endTime;
}
public void setLeavetimeHours(BigDecimal leavetimeHours) {
this.leavetimeHours = leavetimeHours;
}
public BigDecimal getLeavetimeHours() {
return leavetimeHours;
}
public void setLeaveDaysSubtotal(BigDecimal leaveDaysSubtotal) {
this.leaveDaysSubtotal = leaveDaysSubtotal;
}
public BigDecimal getLeaveDaysSubtotal() {
return leaveDaysSubtotal;
}
public void setTotalLeaveDays(BigDecimal totalLeaveDays) {
this.totalLeaveDays = totalLeaveDays;
}
public BigDecimal getTotalLeaveDays() {
return totalLeaveDays;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getReason() {
return reason;
}
public void setProof(String proof) {
this.proof = proof;
}
public String getProof() {
return proof;
}
public String getSecondApprover() {return secondApprover;}
public void setSecondApprover(String secondApprover) {this.secondApprover = secondApprover;}
public String getFirstApprover() {return firstApprover;}
public void setFirstApprover(String firstApprover) {this.firstApprover = firstApprover;}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getCreatedTime() {
return createdTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public Date getUpdatedTime() {
return updatedTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("leaveId", getLeaveId())
.append("requestDate", getRequestDate())
.append("leaveType", getLeaveType())
.append("uname", getUname())
.append("startTime", getStartTime())
.append("endTime", getEndTime())
.append("leavetimeHours", getLeavetimeHours())
.append("leaveDaysSubtotal", getLeaveDaysSubtotal())
.append("totalLeaveDays", getTotalLeaveDays())
.append("reason", getReason())
.append("proof", getProof())
.append("status", getStatus())
.append("createdTime", getCreatedTime())
.append("updatedTime", getUpdatedTime())
.append("firstApprover",getFirstApprover())
.append("secondApprover",getSecondApprover())
.toString();
}
}
package com.ruoyi.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 加班申请对象 overtime_application
*
* @author hht
* @date 2025-03-06
*/
public class OvertimeApplication extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* id号
*/
private Long id;
/**
* 加班单号
*/
@Excel(name = "加班单号")
private String overtimeId;
/**
* 姓名
*/
@Excel(name = "姓名")
private String uname;
/**
* 申请日期
*/
@Excel(name = "申请日期", width = 30, dateFormat = "yyyy-MM-dd")
private String requestDate;
/**
* 归属月份
*/
@Excel(name = "归属月份")
private String yearMonth;
/**
* 加班时长
*/
@Excel(name = "加班时长")
private String overtimeHours;
/**
* 加班总天数
*/
private BigDecimal totalOvertimeDays;
/**
* 归属项目
*/
@Excel(name = "归属项目")
private String project;
/**
* 项目负责人
*/
@Excel(name = "项目负责人")
private String projectLeader;
/**
* 事业部负责人
*/
@Excel(name = "事业部负责人")
private String divisionLeader;
/**
* 创建时间
*/
private Date createdTime;
/**
* 修改时间
*/
private Date updatedTime;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setOvertimeId(String overtimeId) {
this.overtimeId = overtimeId;
}
public String getOvertimeId() {
return overtimeId;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUname() {
return uname;
}
public void setRequestDate(String requestDate) {
this.requestDate = requestDate;
}
public String getRequestDate() {
return requestDate;
}
public void setYearMonth(String yearMonth) {
this.yearMonth = yearMonth;
}
public String getYearMonth() {
return yearMonth;
}
public void setOvertimeHours(String overtimeHours) {
this.overtimeHours = overtimeHours;
}
public String getOvertimeHours() {
return overtimeHours;
}
public void setTotalOvertimeDays(BigDecimal totalOvertimeDays) {
this.totalOvertimeDays = totalOvertimeDays;
}
public BigDecimal getTotalOvertimeDays() {
return totalOvertimeDays;
}
public String getDivisionLeader() {return divisionLeader;}
public void setDivisionLeader(String divisionLeader) {this.divisionLeader = divisionLeader;}
public String getProjectLeader() {return projectLeader;}
public void setProjectLeader(String projectLeader) {this.projectLeader = projectLeader;}
public String getProject() {return project;}
public void setProject(String project) {this.project = project;}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getCreatedTime() {
return createdTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public Date getUpdatedTime() {
return updatedTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("overtimeId", getOvertimeId())
.append("uname", getUname())
.append("requestDate", getRequestDate())
.append("yearMonth", getYearMonth())
.append("overtimeHours", getOvertimeHours())
.append("totalOvertimeDays", getTotalOvertimeDays())
.append("project", getProject())
.append("projectLeader", getProjectLeader())
.append("divisionLeader", getDivisionLeader())
.append("createdTime", getCreatedTime())
.append("updatedTime", getUpdatedTime())
.toString();
}
}
package com.ruoyi.domain.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OvertimeApplicationBatchDTO {
private String project;
private String divisionLeader;
// 员工的加班列表
private List<OvertimeDetail> employees;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class OvertimeDetail {
// 员工姓名
private String uname;
// 加班日期
private String requestDate;
// 加班时长
private String overtimeHours;
}
}
package com.ruoyi.domain.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProjectEmployeeInfoVo {
//事业部负责人
private String departmentLeaderName;
//项目经理
private String projectManagerName;
//项目名称
private String projectName;
//员工姓名
private String employeeName;
}
package com.ruoyi.mapper;
import java.util.List;
import com.ruoyi.domain.LeaveApplication;
/**
* 请假申请Mapper接口
*
* @author hht
* @date 2025-03-03
*/
public interface LeaveApplicationMapper
{
/**
* 查询请假申请
*
* @param id 请假申请主键
* @return 请假申请
*/
public LeaveApplication selectLeaveApplicationById(Long id);
/**
* 查询请假申请列表
*
* @param leaveApplication 请假申请
* @return 请假申请集合
*/
public List<LeaveApplication> selectLeaveApplicationList(LeaveApplication leaveApplication);
/**
* 新增请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
public int insertLeaveApplication(LeaveApplication leaveApplication);
/**
* 修改请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
public int updateLeaveApplication(LeaveApplication leaveApplication);
/**
* 删除请假申请
*
* @param id 请假申请主键
* @return 结果
*/
public int deleteLeaveApplicationById(Long id);
/**
* 批量删除请假申请
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteLeaveApplicationByIds(Long[] ids);
}
package com.ruoyi.mapper;
import java.util.List;
import com.ruoyi.domain.OvertimeApplication;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
/**
* 加班申请Mapper接口
*
* @author hht
* @date 2025-03-06
*/
public interface OvertimeApplicationMapper
{
/**
* 查询加班申请
*
* @param id 加班申请主键
* @return 加班申请
*/
public OvertimeApplication selectOvertimeApplicationById(Long id);
/**
* 查询加班申请列表
*
* @param overtimeApplication 加班申请
* @return 加班申请集合
*/
public List<OvertimeApplication> selectOvertimeApplicationList(OvertimeApplication overtimeApplication);
/**
* 新增加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
public int insertOvertimeApplication(OvertimeApplication overtimeApplication);
/**
* 修改加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
public int updateOvertimeApplication(OvertimeApplication overtimeApplication);
/**
* 删除加班申请
*
* @param id 加班申请主键
* @return 结果
*/
public int deleteOvertimeApplicationById(Long id);
/**
* 批量删除加班申请
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteOvertimeApplicationByIds(Long[] ids);
//批量添加加班申请
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest);
}
package com.ruoyi.mapper;
import com.ruoyi.domain.vo.ProjectEmployeeInfoVo;
import java.util.List;
public interface ProjectEmployeeInfoMapper {
List<ProjectEmployeeInfoVo> getProjectEmployeeInfo(String projectManagerNickName);
}
package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.LeaveApplication;
/**
* 请假申请Service接口
*
* @author hht
* @date 2025-03-03
*/
public interface ILeaveApplicationService
{
/**
* 查询请假申请
*
* @param id 请假申请主键
* @return 请假申请
*/
public LeaveApplication selectLeaveApplicationById(Long id);
/**
* 查询请假申请列表
*
* @param leaveApplication 请假申请
* @return 请假申请集合
*/
public List<LeaveApplication> selectLeaveApplicationList(LeaveApplication leaveApplication);
/**
* 新增请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
public int insertLeaveApplication(LeaveApplication leaveApplication);
/**
* 修改请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
public int updateLeaveApplication(LeaveApplication leaveApplication);
/**
* 批量删除请假申请
*
* @param ids 需要删除的请假申请主键集合
* @return 结果
*/
public int deleteLeaveApplicationByIds(Long[] ids);
/**
* 删除请假申请信息
*
* @param id 请假申请主键
* @return 结果
*/
public int deleteLeaveApplicationById(Long id);
}
package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.OvertimeApplication;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
/**
* 加班申请Service接口
*
* @author hht
* @date 2025-03-06
*/
public interface IOvertimeApplicationService
{
/**
* 查询加班申请
*
* @param id 加班申请主键
* @return 加班申请
*/
public OvertimeApplication selectOvertimeApplicationById(Long id);
/**
* 查询加班申请列表
*
* @param overtimeApplication 加班申请
* @return 加班申请集合
*/
public List<OvertimeApplication> selectOvertimeApplicationList(OvertimeApplication overtimeApplication);
/**
* 新增加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
public int insertOvertimeApplication(OvertimeApplication overtimeApplication);
/**
* 修改加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
public int updateOvertimeApplication(OvertimeApplication overtimeApplication);
/**
* 批量删除加班申请
*
* @param ids 需要删除的加班申请主键集合
* @return 结果
*/
public int deleteOvertimeApplicationByIds(Long[] ids);
/**
* 删除加班申请信息
*
* @param id 加班申请主键
* @return 结果
*/
public int deleteOvertimeApplicationById(Long id);
//批量添加加班申请
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest);
}
package com.ruoyi.service;
import com.ruoyi.domain.vo.ProjectEmployeeInfoVo;
import java.util.List;
public interface IProjectEmployeeInfoService {
List<ProjectEmployeeInfoVo> getProjectEmployeeInfo(String projectManagerNickName);
}
package com.ruoyi.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.LeaveApplicationMapper;
import com.ruoyi.domain.LeaveApplication;
import com.ruoyi.service.ILeaveApplicationService;
/**
* 请假申请Service业务层处理
*
* @author hht
* @date 2025-03-03
*/
@Service
public class LeaveApplicationServiceImpl implements ILeaveApplicationService
{
@Autowired
private LeaveApplicationMapper leaveApplicationMapper;
/**
* 查询请假申请
*
* @param id 请假申请主键
* @return 请假申请
*/
@Override
public LeaveApplication selectLeaveApplicationById(Long id)
{
return leaveApplicationMapper.selectLeaveApplicationById(id);
}
/**
* 查询请假申请列表
*
* @param leaveApplication 请假申请
* @return 请假申请
*/
@Override
public List<LeaveApplication> selectLeaveApplicationList(LeaveApplication leaveApplication)
{
return leaveApplicationMapper.selectLeaveApplicationList(leaveApplication);
}
/**
* 新增请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
@Override
public int insertLeaveApplication(LeaveApplication leaveApplication)
{
// 生成请假单号
leaveApplication.setLeaveId(generateLeaveId());
// 生成请假日期
leaveApplication.setRequestDate(new Date());
return leaveApplicationMapper.insertLeaveApplication(leaveApplication);
}
// 生成请假单号
private String generateLeaveId() {
// 生成时间戳部分
String timestamp = Long.toString(System.currentTimeMillis(), 16);
// 生成随机数部分
Random random = new Random();
String randomNum = Integer.toHexString(random.nextInt(10000)).substring(0, 2);
return randomNum + timestamp;
}
/**
* 修改请假申请
*
* @param leaveApplication 请假申请
* @return 结果
*/
@Override
public int updateLeaveApplication(LeaveApplication leaveApplication)
{
return leaveApplicationMapper.updateLeaveApplication(leaveApplication);
}
/**
* 批量删除请假申请
*
* @param ids 需要删除的请假申请主键
* @return 结果
*/
@Override
public int deleteLeaveApplicationByIds(Long[] ids)
{
return leaveApplicationMapper.deleteLeaveApplicationByIds(ids);
}
/**
* 删除请假申请信息
*
* @param id 请假申请主键
* @return 结果
*/
@Override
public int deleteLeaveApplicationById(Long id)
{
return leaveApplicationMapper.deleteLeaveApplicationById(id);
}
}
package com.ruoyi.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import com.ruoyi.domain.dto.OvertimeApplicationBatchDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.OvertimeApplicationMapper;
import com.ruoyi.domain.OvertimeApplication;
import com.ruoyi.service.IOvertimeApplicationService;
/**
* 加班申请Service业务层处理
*
* @author hht
* @date 2025-03-06
*/
@Service
public class OvertimeApplicationServiceImpl implements IOvertimeApplicationService
{
@Autowired
private OvertimeApplicationMapper overtimeApplicationMapper;
/**
* 查询加班申请
*
* @param id 加班申请主键
* @return 加班申请
*/
@Override
public OvertimeApplication selectOvertimeApplicationById(Long id)
{
return overtimeApplicationMapper.selectOvertimeApplicationById(id);
}
/**
* 查询加班申请列表
*
* @param overtimeApplication 加班申请
* @return 加班申请
*/
@Override
public List<OvertimeApplication> selectOvertimeApplicationList(OvertimeApplication overtimeApplication)
{
return overtimeApplicationMapper.selectOvertimeApplicationList(overtimeApplication);
}
/**
* 新增加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
@Override
public int insertOvertimeApplication(OvertimeApplication overtimeApplication)
{ // 生成加班单号
overtimeApplication.setOvertimeId(generateLeaveId());
return overtimeApplicationMapper.insertOvertimeApplication(overtimeApplication);
}
// 生成加假单号
private String generateLeaveId() {
// 生成时间戳部分
String timestamp = Long.toString(System.currentTimeMillis(), 16);
// 生成随机数部分
Random random = new Random();
String randomNum = Integer.toHexString(random.nextInt(10000)).substring(0, 2);
return randomNum + timestamp;
}
/**
* 修改加班申请
*
* @param overtimeApplication 加班申请
* @return 结果
*/
@Override
public int updateOvertimeApplication(OvertimeApplication overtimeApplication)
{
return overtimeApplicationMapper.updateOvertimeApplication(overtimeApplication);
}
/**
* 批量删除加班申请
*
* @param ids 需要删除的加班申请主键
* @return 结果
*/
@Override
public int deleteOvertimeApplicationByIds(Long[] ids)
{
return overtimeApplicationMapper.deleteOvertimeApplicationByIds(ids);
}
/**
* 删除加班申请信息
*
* @param id 加班申请主键
* @return 结果
*/
@Override
public int deleteOvertimeApplicationById(Long id)
{
return overtimeApplicationMapper.deleteOvertimeApplicationById(id);
}
@Override
public int insertOvertimeApplicationBatch(OvertimeApplicationBatchDTO batchRequest)
{
List<OvertimeApplication> list = new ArrayList<>();
// 计算上个月的归属月份
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -1);
String yearMonth = String.format("%02d", cal.get(Calendar.MONTH) + 1);
for (OvertimeApplicationBatchDTO.OvertimeDetail detail : batchRequest.getEmployees()) {
OvertimeApplication entity = new OvertimeApplication();
// 公共字段
entity.setProject(batchRequest.getProject());
entity.setDivisionLeader(batchRequest.getDivisionLeader());
// 单条记录字段
entity.setUname(detail.getUname());
entity.setOvertimeHours(detail.getOvertimeHours());
entity.setRequestDate(detail.getRequestDate());
// 设置归属月份为上个月的月份
entity.setYearMonth(yearMonth);
// 生成加班单号
entity.setOvertimeId(generateLeaveId());
// 其他字段,如 createdTime, updatedTime 等
entity.setCreatedTime(new Date());
list.add(entity);
}
// 循环插入
int count = 0;
for (OvertimeApplication oa : list) {
count += overtimeApplicationMapper.insertOvertimeApplication(oa);
}
return count;
}
}
package com.ruoyi.service.impl;
import com.ruoyi.domain.vo.ProjectEmployeeInfoVo;
import com.ruoyi.mapper.ProjectEmployeeInfoMapper;
import com.ruoyi.service.IProjectEmployeeInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProjectEmployeeInfoServiceImpl implements IProjectEmployeeInfoService {
@Autowired
private ProjectEmployeeInfoMapper projectManageMapper;
// 初始化 logger
private static final Logger logger = LoggerFactory.getLogger(ProjectEmployeeInfoServiceImpl.class);
@Override
public List<ProjectEmployeeInfoVo> getProjectEmployeeInfo(String projectManagerNickName) {
logger.info("Fetching project employee info for project manager: {}", projectManagerNickName);
List<ProjectEmployeeInfoVo> projectEmployeeInfoList = projectManageMapper.getProjectEmployeeInfo(projectManagerNickName);
logger.info("Fetched project employee info: {}", projectEmployeeInfoList);
return projectEmployeeInfoList;
}
}
<?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.mapper.LeaveApplicationMapper">
<resultMap type="LeaveApplication" id="LeaveApplicationResult">
<result property="id" column="id" />
<result property="leaveId" column="leave_id" />
<result property="requestDate" column="request_date" />
<result property="leaveType" column="leave_type" />
<result property="uname" column="uname" />
<result property="firstApprover" column="first_approver"/>
<result property="secondApprover" column="second_approver"/>
<result property="department" column="department" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="scope" column="scope" />
<result property="leavetimeHours" column="leavetime_hours" />
<result property="leaveDaysSubtotal" column="leave_days_subtotal" />
<result property="totalLeaveDays" column="total_leave_days" />
<result property="reason" column="reason" />
<result property="proof" column="proof" />
<result property="createdTime" column="created_time" />
<result property="updatedTime" column="updated_time" />
</resultMap>
<sql id="selectLeaveApplicationVo">
select id, leave_id, request_date, leave_type, uname,first_approver, second_approver, start_time, end_time, leavetime_hours, leave_days_subtotal, total_leave_days, reason, proof, created_time, updated_time from leave_application
</sql>
<select id="selectLeaveApplicationList" parameterType="LeaveApplication" resultMap="LeaveApplicationResult">
<include refid="selectLeaveApplicationVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="leaveId != null and leaveId != ''"> and leave_id = #{leaveId}</if>
<if test="requestDate != null "> and request_date = #{requestDate}</if>
<if test="leaveType != null and leaveType != ''"> and leave_type = #{leaveType}</if>
<if test="uname != null and uname != ''"> and uname like concat('%', #{uname}, '%')</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="leavetimeHours != null "> and leavetime_hours = #{leavetimeHours}</if>
<if test="leaveDaysSubtotal != null "> and leave_days_subtotal = #{leaveDaysSubtotal}</if>
<if test="totalLeaveDays != null "> and total_leave_days = #{totalLeaveDays}</if>
<if test="reason != null and reason != ''"> and reason = #{reason}</if>
<if test="proof != null and proof != ''"> and proof = #{proof}</if>
<if test="firstApprover != null and firstApprover != ''"> and first_approver = #{firstApprover}</if>
<if test="secondApprover != null and secondApprover != ''"> and second_approver = #{secondApprover}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
</where>
order by id desc
</select>
<select id="selectLeaveApplicationById" parameterType="Long" resultMap="LeaveApplicationResult">
<include refid="selectLeaveApplicationVo"/>
where id = #{id}
</select>
<insert id="insertLeaveApplication" parameterType="LeaveApplication" useGeneratedKeys="true" keyProperty="id">
insert into leave_application
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="leaveId != null">leave_id,</if>
<if test="requestDate != null">request_date,</if>
<if test="leaveType != null and leaveType != ''">leave_type,</if>
<if test="uname != null">uname,</if>
<if test="firstApprover != null">first_approver,</if>
<if test="secondApprover != null">second_approver,</if>
<if test="department != null">department,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="scope != null">scope,</if>
<if test="leavetimeHours != null">leavetime_hours,</if>
<if test="leaveDaysSubtotal != null">leave_days_subtotal,</if>
<if test="totalLeaveDays != null">total_leave_days,</if>
<if test="reason != null and reason != ''">reason,</if>
<if test="proof != null">proof,</if>
<if test="status != null">status,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="leaveId != null">#{leaveId},</if>
<if test="requestDate != null">#{requestDate},</if>
<if test="leaveType != null and leaveType != ''">#{leaveType},</if>
<if test="uname != null">#{uname},</if>
<if test="firstApprover != null">#{firstApprover},</if>
<if test="secondApprover != null">#{secondApprover},</if>
<if test="department != null">#{department},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="scope != null">#{scope},</if>
<if test="leavetimeHours != null">#{leavetimeHours},</if>
<if test="leaveDaysSubtotal != null">#{leaveDaysSubtotal},</if>
<if test="totalLeaveDays != null">#{totalLeaveDays},</if>
<if test="reason != null and reason != ''">#{reason},</if>
<if test="proof != null">#{proof},</if>
<if test="status != null">#{status},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedTime != null">#{updatedTime},</if>
</trim>
</insert>
<update id="updateLeaveApplication" parameterType="LeaveApplication">
update leave_application
<trim prefix="SET" suffixOverrides=",">
<if test="leaveId != null">leave_id = #{leaveId},</if>
<if test="requestDate != null">request_date = #{requestDate},</if>
<if test="leaveType != null and leaveType != ''">leave_type = #{leaveType},</if>
<if test="uname != null">uname = #{uname},</if>
<if test="firstApprover != null">first_approver = #{firstApprover},</if>
<if test="secondApprover != null">second_approver = #{secondApprover},</if>
<if test="department != null">department = #{department},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="scope != null">scope = #{scope},</if>
<if test="leavetimeHours != null">leavetime_hours = #{leavetimeHours},</if>
<if test="leaveDaysSubtotal != null">leave_days_subtotal = #{leaveDaysSubtotal},</if>
<if test="totalLeaveDays != null">total_leave_days = #{totalLeaveDays},</if>
<if test="reason != null and reason != ''">reason = #{reason},</if>
<if test="proof != null">proof = #{proof},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLeaveApplicationById" parameterType="Long">
delete from leave_application where id = #{id}
</delete>
<delete id="deleteLeaveApplicationByIds" parameterType="String">
delete from leave_application where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.mapper.OvertimeApplicationMapper">
<resultMap type="OvertimeApplication" id="OvertimeApplicationResult">
<result property="id" column="id" />
<result property="overtimeId" column="overtime_id" />
<result property="uname" column="uname" />
<result property="requestDate" column="request_date" />
<result property="yearMonth" column="year_month" />
<result property="overtimeHours" column="overtime_hours" />
<result property="totalOvertimeDays" column="total_overtime_days" />
<result property="project" column="project" />
<result property="projectLeader" column="project_leader" />
<result property="divisionLeader" column="division_leader" />
<result property="createdTime" column="created_time" />
<result property="updatedTime" column="updated_time" />
</resultMap>
<sql id="selectOvertimeApplicationVo">
select id, overtime_id, uname, request_date, `year_month`, overtime_hours, total_overtime_days, project, project_leader, division_leader, created_time, updated_time from overtime_application
</sql>
<select id="selectOvertimeApplicationList" parameterType="OvertimeApplication" resultMap="OvertimeApplicationResult">
<include refid="selectOvertimeApplicationVo"/>
<where>
<if test="uname != null and uname != ''"> and uname like concat('%', #{uname}, '%')</if>
<if test="requestDate != null "> and request_date = #{requestDate}</if>
<if test="yearMonth != null "> and `year_month` = #{yearMonth}</if>
</where>
order by id desc
</select>
<select id="selectOvertimeApplicationById" parameterType="Long" resultMap="OvertimeApplicationResult">
<include refid="selectOvertimeApplicationVo"/>
where id = #{id}
</select>
<insert id="insertOvertimeApplication" parameterType="OvertimeApplication" useGeneratedKeys="true" keyProperty="id">
insert into overtime_application
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">overtime_id,</if>
<if test="uname != null and uname != ''">uname,</if>
<if test="requestDate != null">request_date,</if>
<if test="yearMonth != null">`year_month`,</if>
<if test="overtimeHours != null">overtime_hours,</if>
<if test="project != null">project,</if>
<if test="projectLeader != null">project_leader,</if>
<if test="divisionLeader != null">division_leader,</if>
<if test="totalOvertimeDays != null">total_overtime_days,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">#{overtimeId},</if>
<if test="uname != null and uname != ''">#{uname},</if>
<if test="requestDate != null">#{requestDate},</if>
<if test="yearMonth != null">#{yearMonth},</if>
<if test="overtimeHours != null">#{overtimeHours},</if>
<if test="project != null">#{project},</if>
<if test="projectLeader != null">#{projectLeader},</if>
<if test="divisionLeader != null">#{divisionLeader},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedTime != null">#{updatedTime},</if>
</trim>
</insert>
<update id="updateOvertimeApplication" parameterType="OvertimeApplication">
update overtime_application
<trim prefix="SET" suffixOverrides=",">
<if test="overtimeId != null and overtimeId != ''">overtime_id = #{overtimeId},</if>
<if test="uname != null and uname != ''">uname = #{uname},</if>
<if test="department != null">department = #{department},</if>
<if test="requestDate != null">request_date = #{requestDate},</if>
<if test="yearMonth != null">`year_month` = #{yearMonth},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="dayOfWeek != null and dayOfWeek != ''">day_of_week = #{dayOfWeek},</if>
<if test="overtimeHours != null">overtime_hours = #{overtimeHours},</if>
<if test="totalOvertimeDays != null">total_overtime_days = #{totalOvertimeDays},</if>
<if test="reason != null">reason = #{reason},</if>
<if test="directSupervisor != null">direct_supervisor = #{directSupervisor},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteOvertimeApplicationById" parameterType="Long">
delete from overtime_application where id = #{id}
</delete>
<delete id="deleteOvertimeApplicationByIds" parameterType="String">
delete from overtime_application where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.mapper.ProjectEmployeeInfoMapper">
<resultMap id="ProjectEmployeeInfoResultMap" type="com.ruoyi.domain.vo.ProjectEmployeeInfoVo">
<result column="department_leader_name" property="departmentLeaderName"/>
<result column="project_manager_name" property="projectManagerName"/>
<result column="project_name" property="projectName"/>
<result column="employee_names" property="employeeName"/>
</resultMap>
<select id="getProjectEmployeeInfo" resultMap="ProjectEmployeeInfoResultMap">
SELECT
su1.nick_name AS department_leader_name,
su2.nick_name AS project_manager_name,
pm.project_name,
GROUP_CONCAT(su3.nick_name ORDER BY su3.nick_name SEPARATOR ', ') AS employee_names
FROM
project_manage pm
JOIN
sys_user su1 ON pm.department_leader_id = su1.user_id
JOIN
sys_user su2 ON pm.project_manager_id = su2.user_id
JOIN
sys_user_project sup ON pm.id = sup.project_id
JOIN
sys_user su3 ON sup.user_id = su3.user_id
WHERE
su2.nick_name = #{projectManagerNickName}
GROUP BY
su1.nick_name, su2.nick_name, pm.project_name;
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment