Commit 5ae275e1 authored by lwy's avatar lwy

填报工时、工时查询

parent 07a4ef90
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
<artifactId>ooxml-schemas</artifactId> <artifactId>ooxml-schemas</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
......
package com.ruoyi.controller; package com.ruoyi.controller;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; 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.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType; 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.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
...@@ -27,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo; ...@@ -27,7 +25,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* 工时记录Controller * 工时记录Controller
* *
* @author ruoyi * @author ruoyi
* @date 2025-02-28 * @date 2025-03-11
*/ */
@RestController @RestController
@RequestMapping("/timesheet/timesheet") @RequestMapping("/timesheet/timesheet")
...@@ -36,57 +34,71 @@ public class TimesheetController extends BaseController ...@@ -36,57 +34,71 @@ public class TimesheetController extends BaseController
@Autowired @Autowired
private ITimesheetService timesheetService; 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')") @PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@GetMapping("/list") @GetMapping("/personalTimesheet/{employId}")
public TableDataInfo list(Timesheet timesheet) public ResponseEntity<List<AddTimesheetDTO>> getPersonalTimesheet(@PathVariable("employId") Long employId) {
{ List<AddTimesheetDTO> result = timesheetService.getPersonalTimesheet(employId);
startPage(); return ResponseEntity.ok(result);
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
return getDataTable(list);
} }
/** /**
* 导出工时记录列表 * 批量插入工时记录
*
*/ */
@PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')") @PreAuthorize("@ss.hasPermi('timesheet:timesheet:add')")
@Log(title = "工时记录", businessType = BusinessType.EXPORT) @Log(title = "插入工时记录", businessType = BusinessType.INSERT)
@PostMapping("/export") @PostMapping("/batchInsert")
public void export(HttpServletResponse response, Timesheet timesheet) public AjaxResult batchInsertTimesheet(@RequestBody AddTimesheetDTO addTimesheetDTO) {
{ logger.info("Received batch insert request: {}", addTimesheetDTO);
List<Timesheet> list = timesheetService.selectTimesheetList(timesheet); int result = timesheetService.insertTimesheetList(addTimesheetDTO);
ExcelUtil<Timesheet> util = new ExcelUtil<Timesheet>(Timesheet.class); return toAjax(result);
util.exportExcel(response, list, "工时记录数据");
} }
/** /**
* 查询工时记录列表 * 查询工时记录列表
*/ */
/*@PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')") @PreAuthorize("@ss.hasPermi('timesheet:timesheet:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(Timesheet timesheet) public TableDataInfo list(Timesheet timesheet)
{ {
startPage(); startPage();
List<TimesheetVo> list = timesheetService.selectTimesheetList(timesheet); List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
return getDataTable(list); return getDataTable(list);
}*/ }
/** /**
* 导出工时记录列表 * 导出工时记录列表
*/ */
/* @PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')") @PreAuthorize("@ss.hasPermi('timesheet:timesheet:export')")
@Log(title = "工时记录", businessType = BusinessType.EXPORT) @Log(title = "工时记录", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Timesheet timesheet) public void export(HttpServletResponse response, Timesheet timesheet)
{ {
List<TimesheetVo> list = timesheetService.selectTimesheetList(timesheet); List<Timesheet> list = timesheetService.selectTimesheetList(timesheet);
ExcelUtil<TimesheetVo> util = new ExcelUtil<TimesheetVo>(TimesheetVo.class); ExcelUtil<Timesheet> util = new ExcelUtil<Timesheet>(Timesheet.class);
util.exportExcel(response, list, "工时记录数据"); util.exportExcel(response, list, "工时记录数据");
}*/ }
/** /**
* 获取工时记录详细信息 * 获取工时记录详细信息
......
...@@ -3,7 +3,9 @@ package com.ruoyi.domain; ...@@ -3,7 +3,9 @@ package com.ruoyi.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
...@@ -15,6 +17,7 @@ import com.ruoyi.common.core.domain.BaseEntity; ...@@ -15,6 +17,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author ruoyi * @author ruoyi
* @date 2025-02-28 * @date 2025-02-28
*/ */
@Data
public class Timesheet extends BaseEntity public class Timesheet extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -23,6 +26,7 @@ public class Timesheet extends BaseEntity ...@@ -23,6 +26,7 @@ public class Timesheet extends BaseEntity
private Long id; private Long id;
/** 员工编号 */ /** 员工编号 */
@Excel(name = "员工编号")
private Long employId; private Long employId;
/** 员工姓名 */ /** 员工姓名 */
...@@ -38,239 +42,67 @@ public class Timesheet extends BaseEntity ...@@ -38,239 +42,67 @@ public class Timesheet extends BaseEntity
private String projectName; private String projectName;
/** 项目经理编号 */ /** 项目经理编号 */
@Excel(name = "项目经理编号")
private Long managerId; private Long managerId;
/** 事业部负责人编号 */ /** 事业部负责人编号 */
@Excel(name = "事业部负责人编号")
private Long departmentLeaderId; private Long departmentLeaderId;
/** 工作内容 */
private String description;
/** 工时 */ /** 工时 */
@Excel(name = "工时") @Excel(name = "工时")
private BigDecimal hours; private BigDecimal hours;
/** 工作日期 */ /** 工作日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "工作日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date workTime; 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 String workWeek;
/** 审批时间 */
private Date approvalTime;
/** 审批意见备注 */ /** 审批意见备注 */
@Excel(name = "审批意见备注")
private String approvalNote; private String approvalNote;
/** 审批状态 */ /** 审批状态 0-被驳回 1-已通过 2-待填报 3-审核中*/
@Excel(name = "审批状态") @Excel(name = "审批状态")
private String approvalState; 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() // 事业部负责人名称(查询列表)
{ @TableField(exist = false)
return employName; private String departmentLeaderName;
}
public void setProjectNumber(String projectNumber)
{
this.projectNumber = projectNumber;
}
public String getProjectNumber() // 项目经理名称(查询列表)
{ @TableField(exist = false)
return projectNumber; private String managerName;
}
public void setProjectName(String projectName)
{
this.projectName = projectName;
}
public String getProjectName() @TableField(exist = false)
{ private BigDecimal totalHours;
return projectName;
}
public void setManagerId(Long managerId)
{
this.managerId = managerId;
}
public Long getManagerId() //开始时间(查询条件)
{ @JsonFormat(pattern = "yyyy-MM-dd")
return managerId; @TableField(exist = false)
} private Date startTime;
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;
}
public String getApprovalNote() //结束时间(查询条件)
{ @JsonFormat(pattern = "yyyy-MM-dd")
return approvalNote; @TableField(exist = false)
} private Date endTime;
public void setApprovalState(String approvalState)
{
this.approvalState = approvalState;
}
public String getApprovalState() /* @TableField(exist = false)
{ private Date startTime;
return approvalState;
}
public void setFlag(Long flag)
{
this.flag = flag;
}
public Long getFlag() @TableField(exist = false)
{ private Date endTime;*/
return flag;
}
public void setDeleted(Long deleted)
{
this.deleted = deleted;
}
public Long getDeleted() /** 删除标识 0-正常 1-已删除 */
{ private Long deleted;
return 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; package com.ruoyi.mapper;
import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.domain.Timesheet; import com.ruoyi.domain.Timesheet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 工时记录Mapper接口 * 工时记录Mapper接口
...@@ -9,8 +12,23 @@ import com.ruoyi.domain.Timesheet; ...@@ -9,8 +12,23 @@ import com.ruoyi.domain.Timesheet;
* @author ruoyi * @author ruoyi
* @date 2025-02-28 * @date 2025-02-28
*/ */
@Mapper
public interface TimesheetMapper 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; package com.ruoyi.service;
import java.util.List;
import com.ruoyi.domain.Timesheet; 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接口 * 工时记录Service接口
* *
* @author ruoyi * @author ruoyi
* @date 2025-02-28 * @date 2025-03-11
*/ */
public interface ITimesheetService public interface ITimesheetService
{ {
/** /**
* 查询工时记录 * 工时查询--查询个人工时记录
* *
* @param id 工时记录主键 * @param query 工时记录主键
* @return 工时记录 * @return 工时记录
*/ */
public Timesheet selectTimesheetById(Long id); public List<TimesheetDTO> getProjectTimesheetList(Timesheet query);
/** /**
* 查询工时记录列表 * 填报工时--查询个人填报
* *
* @param timesheet 工时记录 * @param
* @return 工时记录集合 * @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,8 +52,8 @@ public interface ITimesheetService ...@@ -35,8 +52,8 @@ public interface ITimesheetService
* @return 工时记录集合 * @return 工时记录集合
*/ */
public List<Timesheet> selectTimesheetList(Timesheet timesheet); public List<Timesheet> selectTimesheetList(Timesheet timesheet);
/** /**
*
* 新增工时记录 * 新增工时记录
* *
* @param timesheet 工时记录 * @param timesheet 工时记录
...@@ -44,6 +61,14 @@ public interface ITimesheetService ...@@ -44,6 +61,14 @@ public interface ITimesheetService
*/ */
public int insertTimesheet(Timesheet timesheet); public int insertTimesheet(Timesheet timesheet);
/**
* 批量加入工时记录
*
* @param
* @return 结果
*/
public int insertTimesheetList(AddTimesheetDTO addTimesheetDTO);
/** /**
* 修改工时记录 * 修改工时记录
* *
...@@ -67,4 +92,9 @@ public interface ITimesheetService ...@@ -67,4 +92,9 @@ public interface ITimesheetService
* @return 结果 * @return 结果
*/ */
public int deleteTimesheetById(Long id); public int deleteTimesheetById(Long id);
// 自定义方法获取星期几
public String getDayOfWeek(Date date);
} }
...@@ -68,4 +68,8 @@ public interface ProjectManageMapper ...@@ -68,4 +68,8 @@ public interface ProjectManageMapper
List<ProjectManage> selectProjectManageByProjectName(@Param("projectName") String projectName); List<ProjectManage> selectProjectManageByProjectName(@Param("projectName") String projectName);
/*
* 个人正在进行中的项目
* */
public List<ProjectManage> selectPersonalProjectManageList(@Param("projectId") Long projectId);
} }
...@@ -74,4 +74,12 @@ public interface ProjectMemberMapper ...@@ -74,4 +74,12 @@ public interface ProjectMemberMapper
* @param memberId 成员 ID * @param memberId 成员 ID
* */ * */
public void deleteProjectMember(@Param("projectId") Long projectId, @Param("memberId") Long memberId); 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" ...@@ -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 * from project_manage where project_name = #{projectName} and del_flag = '0'
</select> </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> </mapper>
...@@ -66,4 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -66,4 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteProjectMember"> <delete id="deleteProjectMember">
delete from project_member where project_id = #{projectId} and user_id = #{memberId} delete from project_member where project_id = #{projectId} and user_id = #{memberId}
</delete> </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> </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