Commit 5ae275e1 authored by lwy's avatar lwy

填报工时、工时查询

parent 07a4ef90
......@@ -46,6 +46,12 @@
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
......
package com.ruoyi.controller;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.domain.Timesheet;
import com.ruoyi.domain.dto.AddTimesheetDTO;
import com.ruoyi.domain.dto.TimesheetDTO;
import com.ruoyi.service.ITimesheetService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
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 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.Timesheet;
import com.ruoyi.service.ITimesheetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 工时记录Controller
*
*
* @author ruoyi
* @date 2025-02-28
* @date 2025-03-11
*/
@RestController
@RequestMapping("/timesheet/timesheet")
......@@ -36,57 +34,71 @@ public class TimesheetController extends BaseController
@Autowired
private ITimesheetService timesheetService;
/*查询个人工时*/
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@GetMapping("/pTimesheetList")
public ResponseEntity<List<TimesheetDTO>> getProjectTimesheetList(
@ModelAttribute Timesheet timesheet,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
@RequestParam(required = false) String managerName // 添加 managerName 参数
) {
// 设置查询条件
timesheet.setStartTime(startTime);
timesheet.setEndTime(endTime);
timesheet.setManagerName(managerName); // 设置 managerName
/**
* 查询工时记录列表
List<TimesheetDTO> result = timesheetService.getProjectTimesheetList(timesheet);
return ResponseEntity.ok(result);
}
/*
* 填报工时--查询个人填报
*/
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@GetMapping("/list")
public TableDataInfo list(Timesheet timesheet)
{
startPage();
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
return getDataTable(list);
@GetMapping("/personalTimesheet/{employId}")
public ResponseEntity<List<AddTimesheetDTO>> getPersonalTimesheet(@PathVariable("employId") Long employId) {
List<AddTimesheetDTO> result = timesheetService.getPersonalTimesheet(employId);
return ResponseEntity.ok(result);
}
/**
* 导出工时记录列表
* 批量插入工时记录
*
*/
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')")
@Log(title = "工时记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Timesheet timesheet)
{
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
ExcelUtil<Timesheet> util = new ExcelUtil<Timesheet>(Timesheet.class);
util.exportExcel(response, list, "工时记录数据");
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:add')")
@Log(title = "插入工时记录", businessType = BusinessType.INSERT)
@PostMapping("/batchInsert")
public AjaxResult batchInsertTimesheet(@RequestBody AddTimesheetDTO addTimesheetDTO) {
logger.info("Received batch insert request: {}", addTimesheetDTO);
int result = timesheetService.insertTimesheetList(addTimesheetDTO);
return toAjax(result);
}
/**
* 查询工时记录列表
*/
/*@PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@GetMapping("/list")
public TableDataInfo list(Timesheet timesheet)
{
startPage();
List<TimesheetVo> list = timesheetService.selectTimesheetList(timesheet);
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
return getDataTable(list);
}*/
}
/**
* 导出工时记录列表
*/
/* @PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')")
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')")
@Log(title = "工时记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Timesheet timesheet)
{
List<TimesheetVo> list = timesheetService.selectTimesheetList(timesheet);
ExcelUtil<TimesheetVo> util = new ExcelUtil<TimesheetVo>(TimesheetVo.class);
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
ExcelUtil<Timesheet> util = new ExcelUtil<Timesheet>(Timesheet.class);
util.exportExcel(response, list, "工时记录数据");
}*/
}
/**
* 获取工时记录详细信息
......
......@@ -3,7 +3,9 @@ package com.ruoyi.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
......@@ -15,6 +17,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi
* @date 2025-02-28
*/
@Data
public class Timesheet extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -23,6 +26,7 @@ public class Timesheet extends BaseEntity
private Long id;
/** 员工编号 */
@Excel(name = "员工编号")
private Long employId;
/** 员工姓名 */
......@@ -38,239 +42,67 @@ public class Timesheet extends BaseEntity
private String projectName;
/** 项目经理编号 */
@Excel(name = "项目经理编号")
private Long managerId;
/** 事业部负责人编号 */
@Excel(name = "事业部负责人编号")
private Long departmentLeaderId;
/** 工作内容 */
private String description;
/** 工时 */
@Excel(name = "工时")
private BigDecimal hours;
/** 工作日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "工作日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date workTime;
/** 工作开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "工作开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date startTime;
/** 工作结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "工作结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date endTime;
/** 周标识 */
@Excel(name = "周标识")
private String workWeek;
/** 审批时间 */
private Date approvalTime;
/** 审批意见备注 */
@Excel(name = "审批意见备注")
private String approvalNote;
/** 审批状态 */
/** 审批状态 0-被驳回 1-已通过 2-待填报 3-审核中*/
@Excel(name = "审批状态")
private String approvalState;
/** 草稿标识 */
private Long flag;
/** 删除标识 */
private Long deleted;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setEmployId(Long employId)
{
this.employId = employId;
}
public Long getEmployId()
{
return employId;
}
public void setEmployName(String employName)
{
this.employName = employName;
}
public String getEmployName()
{
return employName;
}
public void setProjectNumber(String projectNumber)
{
this.projectNumber = projectNumber;
}
// 事业部负责人名称(查询列表)
@TableField(exist = false)
private String departmentLeaderName;
public String getProjectNumber()
{
return projectNumber;
}
public void setProjectName(String projectName)
{
this.projectName = projectName;
}
// 项目经理名称(查询列表)
@TableField(exist = false)
private String managerName;
public String getProjectName()
{
return projectName;
}
public void setManagerId(Long managerId)
{
this.managerId = managerId;
}
@TableField(exist = false)
private BigDecimal totalHours;
public Long getManagerId()
{
return managerId;
}
public void setDepartmentLeaderId(Long departmentLeaderId)
{
this.departmentLeaderId = departmentLeaderId;
}
public Long getDepartmentLeaderId()
{
return departmentLeaderId;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
public void setHours(BigDecimal hours)
{
this.hours = hours;
}
public BigDecimal getHours()
{
return hours;
}
public void setWorkTime(Date workTime)
{
this.workTime = workTime;
}
public Date getWorkTime()
{
return workTime;
}
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 setWorkWeek(String workWeek)
{
this.workWeek = workWeek;
}
public String getWorkWeek()
{
return workWeek;
}
public void setApprovalTime(Date approvalTime)
{
this.approvalTime = approvalTime;
}
public Date getApprovalTime()
{
return approvalTime;
}
public void setApprovalNote(String approvalNote)
{
this.approvalNote = approvalNote;
}
//开始时间(查询条件)
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(exist = false)
private Date startTime;
public String getApprovalNote()
{
return approvalNote;
}
public void setApprovalState(String approvalState)
{
this.approvalState = approvalState;
}
//结束时间(查询条件)
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(exist = false)
private Date endTime;
public String getApprovalState()
{
return approvalState;
}
public void setFlag(Long flag)
{
this.flag = flag;
}
/* @TableField(exist = false)
private Date startTime;
public Long getFlag()
{
return flag;
}
public void setDeleted(Long deleted)
{
this.deleted = deleted;
}
@TableField(exist = false)
private Date endTime;*/
public Long getDeleted()
{
return deleted;
}
/** 删除标识 0-正常 1-已删除 */
private Long deleted;
public static final long NO_DELETE = 0;
public static final long DELETE = 1;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("employId", getEmployId())
.append("employName", getEmployName())
.append("projectNumber", getProjectNumber())
.append("projectName", getProjectName())
.append("managerId", getManagerId())
.append("departmentLeaderId", getDepartmentLeaderId())
.append("description", getDescription())
.append("hours", getHours())
.append("workTime", getWorkTime())
.append("startTime", getStartTime())
.append("endTime", getEndTime())
.append("workWeek", getWorkWeek())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("approvalTime", getApprovalTime())
.append("approvalNote", getApprovalNote())
.append("approvalState", getApprovalState())
.append("flag", getFlag()).append("deleted", getDeleted())
.toString();
}
}
package com.ruoyi.domain.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.Date;
@Data
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知字段
public class WorkingDayDTO {
private String date;
private String name;
private boolean isOffDay;
}
package com.ruoyi.mapper;
import java.util.Date;
import java.util.List;
import com.ruoyi.domain.Timesheet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 工时记录Mapper接口
......@@ -9,8 +12,23 @@ import com.ruoyi.domain.Timesheet;
* @author ruoyi
* @date 2025-02-28
*/
@Mapper
public interface TimesheetMapper
{
/**
* 工时查询--个人工时
* @param query
* @return
*/
public List<Timesheet> selectTimesheetGroupByProject(Timesheet query);
/**
* 填报工时--个人工时查询
* @return
*/
List<Timesheet> selectPersonalTimesheet(@Param("employId") Long employId, @Param("workTime") Date workTime, @Param("projectNumber") String projectNumber);
/**
* 查询工时记录
*
......
package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.Timesheet;
import com.ruoyi.domain.dto.AddTimesheetDTO;
import com.ruoyi.domain.dto.TimesheetDTO;
import java.util.Date;
import java.util.List;
/**
* 工时记录Service接口
*
*
* @author ruoyi
* @date 2025-02-28
* @date 2025-03-11
*/
public interface ITimesheetService
public interface ITimesheetService
{
/**
* 查询工时记录
*
* @param id 工时记录主键
* 工时查询--查询个人工时记录
*
* @param query 工时记录主键
* @return 工时记录
*/
public Timesheet selectTimesheetById(Long id);
public List<TimesheetDTO> getProjectTimesheetList(Timesheet query);
/**
* 查询工时记录列表
*
* @param timesheet 工时记录
* @return 工时记录集合
* 填报工时--查询个人填报
*
* @param
* @return 工时记录
*/
List<AddTimesheetDTO> getPersonalTimesheet(Long employId);
/**
* 填报工时--获取法定节假日
*/
// public List<TimesheetVo> selectTimesheetList(Timesheet timesheet);
public List<Date> getWorkingDaysFromAPI();
/**
* 查询工时记录
*
* @param id 工时记录主键
* @return 工时记录
*/
public Timesheet selectTimesheetById(Long id);
/**
* 查询工时记录列表
*
......@@ -35,18 +52,26 @@ public interface ITimesheetService
* @return 工时记录集合
*/
public List<Timesheet> selectTimesheetList(Timesheet timesheet);
/**
*
* 新增工时记录
*
*
* @param timesheet 工时记录
* @return 结果
*/
public int insertTimesheet(Timesheet timesheet);
/**
* 批量加入工时记录
*
* @param
* @return 结果
*/
public int insertTimesheetList(AddTimesheetDTO addTimesheetDTO);
/**
* 修改工时记录
*
*
* @param timesheet 工时记录
* @return 结果
*/
......@@ -54,7 +79,7 @@ public interface ITimesheetService
/**
* 批量删除工时记录
*
*
* @param ids 需要删除的工时记录主键集合
* @return 结果
*/
......@@ -62,9 +87,14 @@ public interface ITimesheetService
/**
* 删除工时记录信息
*
*
* @param id 工时记录主键
* @return 结果
*/
public int deleteTimesheetById(Long id);
// 自定义方法获取星期几
public String getDayOfWeek(Date date);
}
......@@ -68,4 +68,8 @@ public interface ProjectManageMapper
List<ProjectManage> selectProjectManageByProjectName(@Param("projectName") String projectName);
/*
* 个人正在进行中的项目
* */
public List<ProjectManage> selectPersonalProjectManageList(@Param("projectId") Long projectId);
}
......@@ -74,4 +74,12 @@ public interface ProjectMemberMapper
* @param memberId 成员 ID
* */
public void deleteProjectMember(@Param("projectId") Long projectId, @Param("memberId") Long memberId);
/**
* 根据用户 ID 查询项目成员列表
*
* @param userId 用户 ID
* @return 项目成员列表
*/
List<ProjectMember> selectProjectMemberListByUserId(@Param("userId") Long userId);
}
......@@ -184,4 +184,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select * from project_manage where project_name = #{projectName} and del_flag = '0'
</select>
<!--获取个人正在进行中的项目-->
<select id="selectPersonalProjectManageList" parameterType="ProjectManage" resultMap="ProjectManageResult">
select pm.id,
pm.project_number,
pm.project_name,
pm.department_leader_id,
pm.project_manager_id,
pm.project_type,
pm.start_date,
pm.end_date,
pm.project_cost,
pm.project_describe,
pm.project_status,
pm.create_date,
pm.update_date,
su1.nick_name as departmentLeaderName,
su2.nick_name as projectManagerName
from project_manage pm
left join sys_user su1 on su1.user_id = pm.department_leader_id
left join sys_user su2 on su2.user_id = pm.project_manager_id
left join project_member pmem on pmem.project_id = pm.id
left join sys_user su on su.user_id = pmem.user_id
where pm.del_flag = '0'
and pm.draft = '1'
and pm.id = #{projectId}
and pm.project_status = '0'
group by pm.id,
su1.nick_name, su2.nick_name
</select>
</mapper>
......@@ -66,4 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteProjectMember">
delete from project_member where project_id = #{projectId} and user_id = #{memberId}
</delete>
<!-- 根据用户ID查询项目成员列表 -->
<select id="selectProjectMemberListByUserId" parameterType="Long" resultType="com.ruoyi.system.domain.ProjectMember">
<include refid="selectProjectMemberVo"/>
<where>
<if test="userId != null">user_id = #{userId}</if>
</where>
</select>
</mapper>
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