添加了按照时间段查询工时记录的接口
This commit is contained in:
parent
3f8e3f2a39
commit
f0d0f473ef
@ -99,19 +99,22 @@ public class WorkHourRecordController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询我参与的当前项目的提交的工时记录
|
* 查询我参与的当前项目的提交的工时记录
|
||||||
* @param projectNumber
|
* @param map
|
||||||
* @param token
|
* @param token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/findRecord")
|
@PostMapping("/findRecord")
|
||||||
@PreAuthorize("hasAnyAuthority('auth_administor','auth_general_user')")
|
@PreAuthorize("hasAnyAuthority('auth_administor','auth_general_user')")
|
||||||
public String findRecord(@RequestParam("projectNumber") String projectNumber,@RequestHeader(value="Authorization") String token){
|
public String findRecord(@RequestBody Map map,@RequestHeader(value="Authorization") String token){
|
||||||
// 获取区域信息
|
// 获取区域信息
|
||||||
Locale locale = LocaleContextHolder.getLocale();
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
String projectNumber = (String) map.get("projectNumber");
|
||||||
|
String startTime = (String) map.get("startTime");
|
||||||
|
String endTime = (String) map.get("endTime");
|
||||||
// 验证token
|
// 验证token
|
||||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||||
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
||||||
List<WorkHourRecord> workHourRecords = workHourRecordService.findRecord(projectNumber, sysUserEntity.getId());
|
List<WorkHourRecord> workHourRecords = workHourRecordService.findRecord(projectNumber, sysUserEntity.getId(),startTime,endTime);
|
||||||
if(workHourRecords == null || workHourRecords.size() == 0){
|
if(workHourRecords == null || workHourRecords.size() == 0){
|
||||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有该项目的工时记录",locale);
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有该项目的工时记录",locale);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.xkrs.model.vo.MemberWorkRecordVo;
|
|||||||
import com.xkrs.model.vo.OutExcelVo;
|
import com.xkrs.model.vo.OutExcelVo;
|
||||||
import com.xkrs.model.vo.OutMemberVo;
|
import com.xkrs.model.vo.OutMemberVo;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
@ -17,7 +18,7 @@ import java.util.Map;
|
|||||||
* @author XinYi Song
|
* @author XinYi Song
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public interface WorkHourRecordDao extends JpaRepository<WorkHourRecord,Long> {
|
public interface WorkHourRecordDao extends JpaRepository<WorkHourRecord,Long>, JpaSpecificationExecutor<WorkHourRecord> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询我参与的
|
* 查询我参与的
|
||||||
|
@ -47,9 +47,11 @@ public interface WorkHourRecordService {
|
|||||||
* 查询我参与的当前项目的提交的工时记录
|
* 查询我参与的当前项目的提交的工时记录
|
||||||
* @param projectNumber
|
* @param projectNumber
|
||||||
* @param userId
|
* @param userId
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<WorkHourRecord> findRecord(String projectNumber,Integer userId);
|
List<WorkHourRecord> findRecord(String projectNumber,Integer userId,String startTime, String endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改工时记录
|
* 修改工时记录
|
||||||
|
@ -12,6 +12,7 @@ import com.xkrs.model.vo.OutExcelVo;
|
|||||||
import com.xkrs.model.vo.OutMemberVo;
|
import com.xkrs.model.vo.OutMemberVo;
|
||||||
import com.xkrs.service.WorkHourRecordService;
|
import com.xkrs.service.WorkHourRecordService;
|
||||||
import com.xkrs.utils.DateTimeUtil;
|
import com.xkrs.utils.DateTimeUtil;
|
||||||
|
import com.xkrs.utils.Query;
|
||||||
import org.apache.poi.hssf.usermodel.*;
|
import org.apache.poi.hssf.usermodel.*;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
@ -40,6 +41,9 @@ public class WorkHourRecordServiceImpl implements WorkHourRecordService {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Query query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交工时记录
|
* 提交工时记录
|
||||||
* @param workRecordQo
|
* @param workRecordQo
|
||||||
@ -101,11 +105,13 @@ public class WorkHourRecordServiceImpl implements WorkHourRecordService {
|
|||||||
* 查询我参与的当前项目的提交的工时记录
|
* 查询我参与的当前项目的提交的工时记录
|
||||||
* @param projectNumber
|
* @param projectNumber
|
||||||
* @param userId
|
* @param userId
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<WorkHourRecord> findRecord(String projectNumber, Integer userId) {
|
public List<WorkHourRecord> findRecord(String projectNumber, Integer userId, String startTime, String endTime) {
|
||||||
return workHourRecordDao.findRecord(projectNumber,userId);
|
return query.selectWorkRecord(projectNumber,userId,startTime,endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.xkrs.utils;
|
package com.xkrs.utils;
|
||||||
|
|
||||||
import com.xkrs.dao.ProjectOverviewDao;
|
import com.xkrs.dao.ProjectOverviewDao;
|
||||||
|
import com.xkrs.dao.WorkHourRecordDao;
|
||||||
import com.xkrs.model.entity.ProjectOverview;
|
import com.xkrs.model.entity.ProjectOverview;
|
||||||
|
import com.xkrs.model.entity.WorkHourRecord;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -23,6 +25,9 @@ public class Query {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectOverviewDao projectOverviewDao;
|
private ProjectOverviewDao projectOverviewDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkHourRecordDao workHourRecordDao;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态多条件查询项目信息
|
* 动态多条件查询项目信息
|
||||||
* @param
|
* @param
|
||||||
@ -47,4 +52,37 @@ public class Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询工时记录
|
||||||
|
* @param projectNumber
|
||||||
|
* @param userId
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<WorkHourRecord> selectWorkRecord(String projectNumber, Integer userId, String startTime, String endTime) {
|
||||||
|
Specification<WorkHourRecord> specification = new Specification<WorkHourRecord>() {
|
||||||
|
@Override
|
||||||
|
public Predicate toPredicate(Root<WorkHourRecord> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
||||||
|
List<Predicate> list = new ArrayList<>();
|
||||||
|
if (projectNumber != null && !"".equals(projectNumber)) {
|
||||||
|
list.add(criteriaBuilder.equal(root.get("projectNumber").as(String.class), projectNumber));
|
||||||
|
}
|
||||||
|
if (userId != null && !"".equals(userId)) {
|
||||||
|
list.add(criteriaBuilder.equal(root.get("userId").as(Integer.class), userId));
|
||||||
|
}
|
||||||
|
if(startTime != null && !"".equals(startTime)){
|
||||||
|
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("submitTime").as(String.class), startTime));
|
||||||
|
}
|
||||||
|
if(endTime != null && !"".equals(endTime)){
|
||||||
|
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("submitTime").as(String.class), endTime));
|
||||||
|
}
|
||||||
|
Predicate[] predicates = new Predicate[list.size()];
|
||||||
|
return criteriaBuilder.and(list.toArray(predicates));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return workHourRecordDao.findAll(specification);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ spring.datasource.hikari.validation-timeout = 3000
|
|||||||
## Spring Data JPA 配置
|
## Spring Data JPA 配置
|
||||||
spring.jpa.database = POSTGRESQL
|
spring.jpa.database = POSTGRESQL
|
||||||
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
|
||||||
spring.jpa.show-sql = true
|
spring.jpa.show-sql = false
|
||||||
# 指定 ddl mode (none, validate, create, create-drop, update)
|
# 指定 ddl mode (none, validate, create, create-drop, update)
|
||||||
spring.jpa.hibernate.ddl-auto = update
|
spring.jpa.hibernate.ddl-auto = update
|
||||||
# 命名策略
|
# 命名策略
|
||||||
|
Loading…
Reference in New Issue
Block a user