Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
isoft_psa
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王飞
isoft_psa
Commits
5ae275e1
Commit
5ae275e1
authored
Mar 18, 2025
by
lwy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
填报工时、工时查询
parent
07a4ef90
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
555 additions
and
313 deletions
+555
-313
pom.xml
ruoyi-psa/pom.xml
+6
-0
TimesheetController.java
...c/main/java/com/ruoyi/controller/TimesheetController.java
+50
-38
Timesheet.java
ruoyi-psa/src/main/java/com/ruoyi/domain/Timesheet.java
+35
-203
WorkingDayDTO.java
...psa/src/main/java/com/ruoyi/domain/dto/WorkingDayDTO.java
+14
-0
TimesheetMapper.java
...i-psa/src/main/java/com/ruoyi/mapper/TimesheetMapper.java
+18
-0
ITimesheetService.java
...sa/src/main/java/com/ruoyi/service/ITimesheetService.java
+48
-18
TimesheetServiceImpl.java
...ain/java/com/ruoyi/service/impl/TimesheetServiceImpl.java
+269
-15
TimesheetMapper.xml
...a/src/main/resources/mapper/timesheet/TimesheetMapper.xml
+66
-39
ProjectManageMapper.java
...ain/java/com/ruoyi/system/mapper/ProjectManageMapper.java
+4
-0
ProjectMemberMapper.java
...ain/java/com/ruoyi/system/mapper/ProjectMemberMapper.java
+8
-0
ProjectManageMapper.xml
...src/main/resources/mapper/project/ProjectManageMapper.xml
+29
-0
ProjectMemberMapper.xml
...src/main/resources/mapper/project/ProjectMemberMapper.xml
+8
-0
No files found.
ruoyi-psa/pom.xml
View file @
5ae275e1
...
...
@@ -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>
...
...
ruoyi-psa/src/main/java/com/ruoyi/controller/TimesheetController.java
View file @
5ae275e1
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-0
2-28
* @date 2025-0
3-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<Timesheet
Vo
> 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<Timesheet
Vo
> list = timesheetService.selectTimesheetList(timesheet);
ExcelUtil<Timesheet
Vo> util = new ExcelUtil<TimesheetVo>(TimesheetVo
.class);
List
<
Timesheet
>
list
=
timesheetService
.
selectTimesheetList
(
timesheet
);
ExcelUtil
<
Timesheet
>
util
=
new
ExcelUtil
<
Timesheet
>(
Timesheet
.
class
);
util
.
exportExcel
(
response
,
list
,
"工时记录数据"
);
}
*/
}
/**
* 获取工时记录详细信息
...
...
ruoyi-psa/src/main/java/com/ruoyi/domain/Timesheet.java
View file @
5ae275e1
...
...
@@ -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
();
}
}
ruoyi-psa/src/main/java/com/ruoyi/domain/dto/WorkingDayDTO.java
0 → 100644
View file @
5ae275e1
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
;
}
ruoyi-psa/src/main/java/com/ruoyi/mapper/TimesheetMapper.java
View file @
5ae275e1
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
);
/**
* 查询工时记录
*
...
...
ruoyi-psa/src/main/java/com/ruoyi/service/ITimesheetService.java
View file @
5ae275e1
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-0
2-28
* @date 2025-0
3-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
);
}
ruoyi-psa/src/main/java/com/ruoyi/service/impl/TimesheetServiceImpl.java
View file @
5ae275e1
package
com
.
ruoyi
.
service
.
impl
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.domain.dto.*
;
import
com.ruoyi.service.ITimesheetService
;
import
com.ruoyi.system.domain.ProjectManage
;
import
com.ruoyi.system.domain.ProjectMember
;
import
com.ruoyi.system.mapper.ProjectManageMapper
;
import
com.ruoyi.system.mapper.ProjectMemberMapper
;
import
com.ruoyi.system.mapper.SysUserMapper
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.mapper.TimesheetMapper
;
import
com.ruoyi.domain.Timesheet
;
import
com.ruoyi.service.ITimesheetService
;
/**
* 工时记录Service业务层处理
...
...
@@ -18,11 +36,219 @@ import com.ruoyi.service.ITimesheetService;
* @date 2025-02-28
*/
@Service
public
class
TimesheetServiceImpl
implements
ITimesheetService
public
class
TimesheetServiceImpl
implements
ITimesheetService
{
@Autowired
private
TimesheetMapper
timesheetMapper
;
@Autowired
private
SysUserMapper
sysUserMapper
;
@Autowired
private
ProjectManageMapper
projectManageMapper
;
@Autowired
private
ProjectMemberMapper
projectMemberMapper
;
private
static
final
String
API_URL
=
"https://api.jiejiariapi.com/v1/workdays/2025"
;
@Override
public
List
<
TimesheetDTO
>
getProjectTimesheetList
(
Timesheet
query
)
{
query
.
setManagerName
(
query
.
getManagerName
());
// 确保传递 managerName
List
<
Timesheet
>
timesheets
=
timesheetMapper
.
selectTimesheetGroupByProject
(
query
);
Map
<
String
,
TimesheetDTO
>
projectMap
=
new
LinkedHashMap
<>();
for
(
Timesheet
timesheet
:
timesheets
)
{
String
projectNumber
=
timesheet
.
getProjectNumber
();
if
(!
projectMap
.
containsKey
(
projectNumber
))
{
TimesheetDTO
dto
=
new
TimesheetDTO
();
dto
.
setProjectNumber
(
timesheet
.
getProjectNumber
());
dto
.
setProjectName
(
timesheet
.
getProjectName
());
dto
.
setManagerName
(
timesheet
.
getManagerName
());
dto
.
setDepartmentLeaderName
(
timesheet
.
getDepartmentLeaderName
());
dto
.
setTotalHours
(
BigDecimal
.
ZERO
);
// 初始化 totalHours 为 0
dto
.
setWorkDetails
(
new
ArrayList
<>());
projectMap
.
put
(
projectNumber
,
dto
);
}
TimesheetDTO
dto
=
projectMap
.
get
(
projectNumber
);
// 检查是否已存在相同的 workTime 和 hours
boolean
isDuplicate
=
dto
.
getWorkDetails
().
stream
()
.
anyMatch
(
workDetail
->
workDetail
.
getWorkTime
().
equals
(
timesheet
.
getWorkTime
())
&&
workDetail
.
getHours
().
equals
(
timesheet
.
getHours
()));
if
(!
isDuplicate
)
{
dto
.
getWorkDetails
().
add
(
new
WorkDetailDTO
(
timesheet
.
getWorkTime
(),
timesheet
.
getHours
()
));
// 累加 totalHours
dto
.
setTotalHours
(
dto
.
getTotalHours
().
add
(
timesheet
.
getHours
()));
}
}
// 计算 startTime 和 endTime
for
(
TimesheetDTO
dto
:
projectMap
.
values
())
{
if
(!
dto
.
getWorkDetails
().
isEmpty
())
{
// 找到最早和最晚的时间
Date
startTime
=
dto
.
getWorkDetails
().
stream
()
.
map
(
WorkDetailDTO:
:
getWorkTime
)
.
min
(
Date:
:
compareTo
)
.
orElse
(
null
);
Date
endTime
=
dto
.
getWorkDetails
().
stream
()
.
map
(
WorkDetailDTO:
:
getWorkTime
)
.
max
(
Date:
:
compareTo
)
.
orElse
(
null
);
dto
.
setStartTime
(
startTime
);
dto
.
setEndTime
(
endTime
);
}
}
return
new
ArrayList
<>(
projectMap
.
values
());
}
/*
* 填报工时--获取法定工作日
*/
@Override
public
List
<
Date
>
getWorkingDaysFromAPI
()
{
List
<
Date
>
workingDays
=
new
ArrayList
<>();
try
(
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
())
{
HttpGet
request
=
new
HttpGet
(
API_URL
);
try
(
CloseableHttpResponse
response
=
httpClient
.
execute
(
request
))
{
if
(
response
.
getStatusLine
().
getStatusCode
()
==
200
)
{
String
jsonResult
=
EntityUtils
.
toString
(
response
.
getEntity
());
ObjectMapper
objectMapper
=
new
ObjectMapper
();
// 添加日志输出,方便调试
System
.
out
.
println
(
"API Response: "
+
jsonResult
);
try
{
Map
<
String
,
WorkingDayDTO
>
apiResponse
=
objectMapper
.
readValue
(
jsonResult
,
new
TypeReference
<
Map
<
String
,
WorkingDayDTO
>>()
{});
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
for
(
Map
.
Entry
<
String
,
WorkingDayDTO
>
entry
:
apiResponse
.
entrySet
())
{
WorkingDayDTO
workingDay
=
entry
.
getValue
();
if
(!
workingDay
.
isOffDay
())
{
Date
date
=
sdf
.
parse
(
workingDay
.
getDate
().
toString
());
workingDays
.
add
(
date
);
}
}
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
// 处理 JSON 格式错误
System
.
err
.
println
(
"JSON Parsing Error: "
+
e
.
getMessage
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
// 处理日期解析错误
System
.
err
.
println
(
"Date Parsing Error: "
+
e
.
getMessage
());
}
}
else
{
System
.
err
.
println
(
"API Request Failed with Status Code: "
+
response
.
getStatusLine
().
getStatusCode
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// 处理 IO 异常
System
.
err
.
println
(
"IO Error: "
+
e
.
getMessage
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// 处理 IO 异常
System
.
err
.
println
(
"IO Error: "
+
e
.
getMessage
());
}
return
workingDays
;
}
/**
* 填报工时--获取填报列表
* @return 个人工时记录列表
*/
@Override
public
List
<
AddTimesheetDTO
>
getPersonalTimesheet
(
Long
employId
)
{
String
employName
=
sysUserMapper
.
selectUserById
(
employId
).
getNickName
();
// 获取当前日期和本周的起始日期(周一)与结束日期(周日)
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
SUNDAY
);
Date
startOfWeek
=
calendar
.
getTime
();
calendar
.
add
(
Calendar
.
DAY_OF_WEEK
,
6
);
Date
endOfWeek
=
calendar
.
getTime
();
// 获取所有工作日
List
<
Date
>
workingDays
=
getWorkingDaysFromAPI
();
// 过滤本周的工作日
List
<
Date
>
thisWeekWorkingDays
=
workingDays
.
stream
()
.
filter
(
workingDay
->
!
workingDay
.
before
(
startOfWeek
)
&&
!
workingDay
.
after
(
endOfWeek
))
.
collect
(
Collectors
.
toList
());
//System.out.println("This Week Working Days: " + thisWeekWorkingDays);
// 获取员工的项目列表
ProjectMember
projectMember
=
new
ProjectMember
();
projectMember
.
setUserId
(
employId
);
List
<
ProjectMember
>
projectMembers
=
projectMemberMapper
.
selectProjectMemberList
(
projectMember
);
List
<
ProjectManage
>
projects
=
projectMembers
.
stream
()
.
map
(
member
->
projectManageMapper
.
selectPersonalProjectManageList
(
member
.
getProjectId
()))
.
flatMap
(
List:
:
stream
)
// 将嵌套的List<ProjectManage>扁平化为Stream<ProjectManage>
.
filter
(
Objects:
:
nonNull
)
// 过滤掉可能为 null 的结果
.
distinct
()
// 去重
.
collect
(
Collectors
.
toList
());
List
<
AddTimesheetDTO
>
addTimesheetList
=
new
ArrayList
<>();
// 遍历每个项目
for
(
ProjectManage
project
:
projects
)
{
AddTimesheetDTO
addTimesheetDTO
=
new
AddTimesheetDTO
();
addTimesheetDTO
.
setEmployId
(
employId
);
addTimesheetDTO
.
setEmployName
(
employName
);
addTimesheetDTO
.
setProjectNumber
(
project
.
getProjectNumber
());
addTimesheetDTO
.
setProjectName
(
project
.
getProjectName
());
addTimesheetDTO
.
setManagerId
(
project
.
getProjectManagerId
());
addTimesheetDTO
.
setManagerName
(
project
.
getProjectManagerName
());
addTimesheetDTO
.
setDepartmentLeaderId
(
project
.
getDepartmentLeaderId
());
addTimesheetDTO
.
setDepartmentLeaderName
(
project
.
getDepartmentLeaderName
());
addTimesheetDTO
.
setApprovalState
(
"2"
);
// 默认审批状态
addTimesheetDTO
.
setApprovalNote
(
""
);
// 默认审批备注
addTimesheetDTO
.
setTotalHours
(
BigDecimal
.
ZERO
);
// 初始化总工时为0
List
<
AddWorkDTO
>
addWorkList
=
new
ArrayList
<>();
// 遍历本周的每个工作日
for
(
Date
workTime
:
thisWeekWorkingDays
)
{
// System.out.println("workTime Day: " + workTime+"//////////////////////");
// 查询该工作日的工时记录
List
<
Timesheet
>
timesheets
=
timesheetMapper
.
selectPersonalTimesheet
(
employId
,
workTime
,
project
.
getProjectNumber
());
AddWorkDTO
addWorkDTO
=
new
AddWorkDTO
();
addWorkDTO
.
setWorkTime
(
workTime
);
addWorkDTO
.
setWorkWeek
(
getDayOfWeek
(
workTime
));
// 获取星期几
if
(!
timesheets
.
isEmpty
())
{
// 如果有工时记录,设置工时并从第一条记录中获取审批状态和备注
addWorkDTO
.
setHours
(
timesheets
.
get
(
0
).
getHours
());
addTimesheetDTO
.
setApprovalState
(
timesheets
.
get
(
0
).
getApprovalState
());
addTimesheetDTO
.
setApprovalNote
(
timesheets
.
get
(
0
).
getApprovalNote
());
// 累加总工时
addTimesheetDTO
.
setTotalHours
(
addTimesheetDTO
.
getTotalHours
().
add
(
timesheets
.
get
(
0
).
getHours
()));
}
else
{
// 如果没有工时记录,设置工时为0,并保留默认审批状态和备注
addWorkDTO
.
setHours
(
BigDecimal
.
ZERO
);
}
addWorkList
.
add
(
addWorkDTO
);
}
addTimesheetDTO
.
setAddWorkList
(
addWorkList
);
addTimesheetList
.
add
(
addTimesheetDTO
);
}
return
addTimesheetList
;
}
/**
* 查询工时记录
*
...
...
@@ -89,6 +315,37 @@ public class TimesheetServiceImpl implements ITimesheetService
return
timesheetMapper
.
insertTimesheet
(
timesheet
);
}
/**
* 批量插入工时记录
*
*/
@Override
public
int
insertTimesheetList
(
AddTimesheetDTO
addTimesheetDTO
)
{
int
result
=
0
;
// 检查 addWorkList 是否为空
if
(
addTimesheetDTO
.
getAddWorkList
()
==
null
||
addTimesheetDTO
.
getAddWorkList
().
isEmpty
())
{
throw
new
IllegalArgumentException
(
"addWorkList cannot be empty"
);
}
for
(
AddWorkDTO
addWorkDTO
:
addTimesheetDTO
.
getAddWorkList
())
{
Timesheet
timesheet
=
new
Timesheet
();
timesheet
.
setEmployId
(
addTimesheetDTO
.
getEmployId
());
timesheet
.
setEmployName
(
addTimesheetDTO
.
getEmployName
());
timesheet
.
setProjectNumber
(
addTimesheetDTO
.
getProjectNumber
());
timesheet
.
setProjectName
(
addTimesheetDTO
.
getProjectName
());
timesheet
.
setManagerId
(
addTimesheetDTO
.
getManagerId
());
timesheet
.
setDepartmentLeaderId
(
addTimesheetDTO
.
getDepartmentLeaderId
());
timesheet
.
setHours
(
addWorkDTO
.
getHours
());
timesheet
.
setWorkTime
(
addWorkDTO
.
getWorkTime
());
timesheet
.
setWorkWeek
(
addWorkDTO
.
getWorkWeek
());
timesheet
.
setApprovalState
(
"3"
);
timesheet
.
setApprovalNote
(
addTimesheetDTO
.
getApprovalNote
());
timesheet
.
setDeleted
(
Timesheet
.
NO_DELETE
);
result
+=
timesheetMapper
.
insertTimesheet
(
timesheet
);
}
return
result
;
}
/**
* 修改工时记录
*
...
...
@@ -126,18 +383,15 @@ public class TimesheetServiceImpl implements ITimesheetService
return
timesheetMapper
.
deleteTimesheetById
(
id
);
}
private
String
determineProjectType
(
Timesheet
timesheet
)
{
// 根据业务逻辑确定projectType
return
"A型"
;
// 示例值
@Override
public
String
getDayOfWeek
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
int
dayOfWeek
=
calendar
.
get
(
Calendar
.
DAY_OF_WEEK
);
// 调整数组顺序,使其与 Calendar.DAY_OF_WEEK 的值对应
String
[]
days
=
new
String
[]{
"周日"
,
"周一"
,
"周二"
,
"周三"
,
"周四"
,
"周五"
,
"周六"
};
return
days
[
dayOfWeek
-
1
];
// 因为数组索引从0开始,所以需要减1
}
private
String
getDepartmentLeaderName
(
Timesheet
timesheet
)
{
// 根据业务逻辑获取部门领导的名字
return
"李四"
;
// 示例值
}
private
BigDecimal
calculateSumHours
(
Timesheet
timesheet
)
{
// 根据业务逻辑计算sumHours
return
new
BigDecimal
(
16
);
// 示例值
}
}
ruoyi-psa/src/main/resources/mapper/timesheet/TimesheetMapper.xml
View file @
5ae275e1
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.mapper.TimesheetMapper"
>
<resultMap
type=
"Timesheet"
id=
"TimesheetResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"employId"
column=
"employ_id"
/>
...
...
@@ -12,35 +12,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"projectName"
column=
"project_name"
/>
<result
property=
"managerId"
column=
"manager_id"
/>
<result
property=
"departmentLeaderId"
column=
"department_leader_id"
/>
<result
property=
"description"
column=
"description"
/>
<result
property=
"hours"
column=
"hours"
/>
<result
property=
"workTime"
column=
"work_time"
/>
<result
property=
"startTime"
column=
"start_time"
/>
<result
property=
"endTime"
column=
"end_time"
/>
<result
property=
"workWeek"
column=
"work_week"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"approvalTime"
column=
"approval_time"
/>
<result
property=
"approvalNote"
column=
"approval_note"
/>
<result
property=
"approvalState"
column=
"approval_state"
/>
<result
property=
"flag"
column=
"flag"
/>
<result
property=
"deleted"
column=
"deleted"
/>
</resultMap>
<sql
id=
"selectTimesheetVo"
>
select id, employ_id, employ_name, project_number, project_name, manager_id, department_leader_id,
description, hours, work_time, start_time, end_time, work_week, create_time, update_time, approval_time, approval_note, approval_state, flag
, deleted from timesheet
select id, employ_id, employ_name, project_number, project_name, manager_id, department_leader_id,
hours, work_time, work_week, create_time, update_time, approval_note, approval_state
, deleted from timesheet
</sql>
<select
id=
"selectTimesheetList"
parameterType=
"Timesheet"
resultMap=
"TimesheetResult"
>
<include
refid=
"selectTimesheetVo"
/>
<where>
<if
test=
"projectNumber != null "
>
and project_number = #{projectNumber}
</if>
<if
test=
"projectName != null and projectName != ''"
>
and project_name like concat('%', #{projectName}, '%')
</if>
<if
test=
"startTime != null "
>
and start_time = #{startTime}
</if>
<if
test=
"endTime != null "
>
and end_time = #{endTime}
</if>
</where>
<!--查询工时-->
<select
id=
"selectTimesheetGroupByProject"
parameterType=
"Timesheet"
resultMap=
"TimesheetResult"
>
select tm.id, tm.employ_id, tm.employ_name, tm.project_number, tm.project_name, tm.manager_id, tm.department_leader_id, tm.hours, tm.work_time,
tm.work_week, tm.create_time, tm.update_time, tm.approval_note, tm.approval_state, su1.nick_name as managerName, su2.nick_name as departmentLeaderName
from timesheet tm
left join sys_user su1 on su1.user_id = tm.manager_id
left join sys_user su2 on su2.user_id = tm.department_leader_id
left join project_manage pm on pm.project_number = tm.project_number
left join project_member pmem on pmem.user_id = tm.employ_id
where tm.deleted = 0 and tm.approval_state = '1'
<if
test=
"projectName != null and projectName != ''"
>
and tm.project_name like concat('%', #{projectName}, '%')
</if>
<if
test=
"managerName != null and managerName != ''"
>
and su1.nick_name like concat('%', #{managerName}, '%')
</if>
<if
test=
"employId != null and employId != ''"
>
and tm.employ_id = #{employId}
</if>
<if
test=
"startTime != null"
>
and tm.work_time
>
= #{startTime}
</if>
<if
test=
"endTime != null"
>
and tm.work_time
<
= #{endTime}
</if>
<!-- <if test="startTime != null and startTime.id != ''">
and tm.work_time >= #{startTime}
</if>
<if test="endTime != null and endTime.id != ''">
and tm.work_time <= #{endTime}
</if>-->
order by tm.work_time asc
</select>
<!--获取工时填报基本信息-->
<select
id=
"selectPersonalTimesheet"
resultMap=
"TimesheetResult"
>
SELECT tm.id, tm.employ_id, tm.employ_name, tm.project_number, tm.project_name, tm.manager_id,
tm.department_leader_id, tm.hours, tm.work_time, tm.work_week, tm.create_time,
tm.update_time, tm.approval_note, tm.approval_state, su1.nick_name as managerName, su2.nick_name as departmentLeaderName
FROM timesheet tm
JOIN project_member pmem ON pmem.user_id = tm.employ_id
JOIN project_manage pm ON pm.project_number = tm.project_number
LEFT JOIN sys_user su1 ON su1.user_id = tm.manager_id
LEFT JOIN sys_user su2 ON su2.user_id = tm.department_leader_id
WHERE tm.deleted = 0
<if
test=
"employId != null and employId != ''"
>
and pmem.user_id = #{employId}
</if>
<if
test=
"workTime != null"
>
and tm.work_time = #{workTime}
</if>
<if
test=
"projectNumber != null and projectNumber != ''"
>
and tm.project_number = #{projectNumber}
</if>
ORDER BY tm.work_time ASC
</select>
<select
id=
"selectTimesheetById"
parameterType=
"Long"
resultMap=
"TimesheetResult"
>
<include
refid=
"selectTimesheetVo"
/>
where id = #{id}
...
...
@@ -51,45 +93,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"employId != null"
>
employ_id,
</if>
<if
test=
"employName != null and employName != ''"
>
employ_name,
</if>
<if
test=
"projectNumber != null"
>
project_number,
</if>
<if
test=
"projectNumber != null
and projectNumber != ''
"
>
project_number,
</if>
<if
test=
"projectName != null and projectName != ''"
>
project_name,
</if>
<if
test=
"managerId != null"
>
manager_id,
</if>
<if
test=
"departmentLeaderId != null"
>
department_leader_id,
</if>
<if
test=
"description != null"
>
description,
</if>
<if
test=
"hours != null"
>
hours,
</if>
<if
test=
"workTime != null"
>
work_time,
</if>
<if
test=
"startTime != null"
>
start_time,
</if>
<if
test=
"endTime != null"
>
end_time,
</if>
<if
test=
"workWeek != null and workWeek != ''"
>
work_week,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"approvalTime != null"
>
approval_time,
</if>
<if
test=
"approvalNote != null"
>
approval_note,
</if>
<if
test=
"approvalState != null"
>
approval_state,
</if>
<if
test=
"flag != null"
>
flag,
</if>
<if
test=
"deleted != null"
>
deleted,
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"employId != null"
>
#{employId},
</if>
<if
test=
"employName != null and employName != ''"
>
#{employName},
</if>
<if
test=
"projectNumber != null"
>
#{projectNumber},
</if>
<if
test=
"projectNumber != null
and projectNumber != ''
"
>
#{projectNumber},
</if>
<if
test=
"projectName != null and projectName != ''"
>
#{projectName},
</if>
<if
test=
"managerId != null"
>
#{managerId},
</if>
<if
test=
"departmentLeaderId != null"
>
#{departmentLeaderId},
</if>
<if
test=
"description != null"
>
#{description},
</if>
<if
test=
"hours != null"
>
#{hours},
</if>
<if
test=
"workTime != null"
>
#{workTime},
</if>
<if
test=
"startTime != null"
>
#{startTime},
</if>
<if
test=
"endTime != null"
>
#{endTime},
</if>
<if
test=
"workWeek != null and workWeek != ''"
>
#{workWeek},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"approvalTime != null"
>
#{approvalTime},
</if>
<if
test=
"approvalNote != null"
>
#{approvalNote},
</if>
<if
test=
"approvalState != null"
>
#{approvalState},
</if>
<if
test=
"flag != null"
>
#{flag},
</if>
<if
test=
"deleted != null"
>
#{deleted},
</if>
</trim>
</trim>
</insert>
<update
id=
"updateTimesheet"
parameterType=
"Timesheet"
>
...
...
@@ -97,22 +129,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"employId != null"
>
employ_id = #{employId},
</if>
<if
test=
"employName != null and employName != ''"
>
employ_name = #{employName},
</if>
<if
test=
"projectNumber != null"
>
project_number = #{projectNumber},
</if>
<if
test=
"projectNumber != null
and projectNumber != ''
"
>
project_number = #{projectNumber},
</if>
<if
test=
"projectName != null and projectName != ''"
>
project_name = #{projectName},
</if>
<if
test=
"managerId != null"
>
manager_id = #{managerId},
</if>
<if
test=
"departmentLeaderId != null"
>
department_leader_id = #{departmentLeaderId},
</if>
<if
test=
"description != null"
>
description = #{description},
</if>
<if
test=
"hours != null"
>
hours = #{hours},
</if>
<if
test=
"workTime != null"
>
work_time = #{workTime},
</if>
<if
test=
"startTime != null"
>
start_time = #{startTime},
</if>
<if
test=
"endTime != null"
>
end_time = #{endTime},
</if>
<if
test=
"workWeek != null and workWeek != ''"
>
work_week = #{workWeek},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"approvalTime != null"
>
approval_time = #{approvalTime},
</if>
<if
test=
"approvalNote != null"
>
approval_note = #{approvalNote},
</if>
<if
test=
"approvalState != null"
>
approval_state = #{approvalState},
</if>
<if
test=
"flag != null"
>
flag = #{flag},
</if>
<if
test=
"deleted != null"
>
deleted = #{deleted},
</if>
</trim>
where id = #{id}
...
...
@@ -123,7 +150,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete
id=
"deleteTimesheetByIds"
parameterType=
"String"
>
delete from timesheet where id in
delete from timesheet where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
...
...
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ProjectManageMapper.java
View file @
5ae275e1
...
...
@@ -68,4 +68,8 @@ public interface ProjectManageMapper
List
<
ProjectManage
>
selectProjectManageByProjectName
(
@Param
(
"projectName"
)
String
projectName
);
/*
* 个人正在进行中的项目
* */
public
List
<
ProjectManage
>
selectPersonalProjectManageList
(
@Param
(
"projectId"
)
Long
projectId
);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ProjectMemberMapper.java
View file @
5ae275e1
...
...
@@ -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
);
}
ruoyi-system/src/main/resources/mapper/project/ProjectManageMapper.xml
View file @
5ae275e1
...
...
@@ -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>
ruoyi-system/src/main/resources/mapper/project/ProjectMemberMapper.xml
View file @
5ae275e1
...
...
@@ -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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment