feat:项目人员表

main^2
chenhao 2024-10-10 15:25:20 +08:00
parent 8196485264
commit caa8b4f1bc
10 changed files with 208 additions and 23 deletions

View File

@ -2,6 +2,7 @@ package tech.unissense.pms.web.controller.business.project;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tech.unissense.pms.business.project.dto.ProjectQueryDto;
import tech.unissense.pms.business.projectteam.domain.ProjectTeam;
import tech.unissense.pms.business.projectteam.service.IProjectTeamService;
import tech.unissense.pms.business.work.logger.domain.WorkLogger;
@ -111,4 +112,13 @@ public class ProjectController extends BaseController
{
return success(service.executionInfo(workLogger));
}
/**
*
*/
// @PreAuthorize("@ss.hasPermi('system:dept:remove')")
@PostMapping("/workInfo")
public AjaxResult workInfo(@RequestBody ProjectQueryDto dto)
{
return success(service.workInfo(dto));
}
}

View File

@ -0,0 +1,25 @@
package tech.unissense.pms.business.project.dto;
import lombok.Data;
import java.util.Date;
/**
* @author : ch
* @version : 1.0
* @ClassName : ProjectQueryDto
* @Description : TODO()
* @DATE : Created in 14:51 2024/10/10
* <pre> Copyright: Copyright(c)2024 </pre>
* <pre> Company : </pre>
* Modification History:
* Date Author Version Discription
* --------------------------------------------------------------------------
* 2024/10/10 ch 1.0 Why & What is modified: <> *
*/
@Data
public class ProjectQueryDto {
private Integer projectId;
private Date startDate;
private Date endDate;
}

View File

@ -1,13 +1,13 @@
package tech.unissense.pms.business.project.service;
import tech.unissense.pms.business.project.domain.Project;
import tech.unissense.pms.business.project.dto.ProjectQueryDto;
import tech.unissense.pms.business.project.vo.ProjectExecutionVo;
import tech.unissense.pms.business.project.vo.ProjectWorkInfoVo;
import tech.unissense.pms.business.projectteam.vo.TeamStaticsVo;
import tech.unissense.pms.business.work.logger.domain.WorkLogger;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* (Project)
@ -65,4 +65,5 @@ public interface IProjectService {
List<ProjectExecutionVo> executionInfo(WorkLogger workLogger);
ProjectWorkInfoVo workInfo(ProjectQueryDto project);
}

View File

@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.unissense.pms.business.project.domain.Project;
import tech.unissense.pms.business.project.dto.ProjectQueryDto;
import tech.unissense.pms.business.project.mapper.ProjectMapper;
import tech.unissense.pms.business.project.service.IProjectService;
import tech.unissense.pms.business.project.vo.ProjectExecutionVo;
import tech.unissense.pms.business.project.vo.ProjectWorkInfoVo;
import tech.unissense.pms.business.projectteam.domain.ProjectTeam;
import tech.unissense.pms.business.projectteam.service.IProjectTeamService;
import tech.unissense.pms.business.projectteam.vo.TeamStaticsVo;
@ -23,12 +25,12 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.time.temporal.ChronoUnit;
import java.util.stream.Stream;
/**
@ -160,7 +162,12 @@ public class ProjectServiceImpl implements IProjectService {
@Override
public List<ProjectExecutionVo> executionInfo(WorkLogger workLogger) {
List<Project> projects = this.permissisonList(new Project());
Project projectQueryDto = new Project();
if (workLogger.getUserId() != null) {
projectQueryDto.setQueryUserId(Long.valueOf(workLogger.getUserId()));
}
List<Project> projects = this.permissisonList(projectQueryDto);
workLogger.setProjectIdList(projects.stream()
.map(Project::getProjectId)
.collect(Collectors.toList()));
@ -188,4 +195,43 @@ public class ProjectServiceImpl implements IProjectService {
return vo;
}).collect(Collectors.toList());
}
@Override
public ProjectWorkInfoVo workInfo(ProjectQueryDto projectQueryDto) {
Project project = projectMapper.queryById(projectQueryDto.getProjectId());
WorkLogger workLogger = new WorkLogger();
workLogger.setProjectId(projectQueryDto.getProjectId());
workLogger.setStartDate(projectQueryDto.getStartDate());
workLogger.setEndDate(projectQueryDto.getEndDate());
List<WorkLogger> workLoggerList = workLoggerService.listUser(workLogger);
// 使用流按日期分组并对每个日期的工人按用户ID去重保留最后一次记录
Map<String, List<WorkLogger>> workersByDateMap = workLoggerList.stream()
.collect(Collectors.groupingBy(
logger -> DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, logger.getLoggerDate()),
Collectors.collectingAndThen(
Collectors.toMap(
WorkLogger::getUserId,
logger -> logger,
(existing, replacement) -> existing.getCreateTime().after(replacement.getCreateTime()) ? existing : replacement
),
map -> new ArrayList<>(map.values())
)
));
LocalDate startDate = workLogger.getStartDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate endDate = workLogger.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 生成从开始日期到结束日期的工人列表
List<List<WorkLogger>> detailList = Stream.iterate(startDate, date -> date.plusDays(1))
.limit(ChronoUnit.DAYS.between(startDate, endDate) + 1)
.map(localDate -> workersByDateMap.getOrDefault(localDate.toString(), Collections.emptyList()))
.collect(Collectors.toList());
ProjectWorkInfoVo vo = new ProjectWorkInfoVo();
BeanUtils.copyBeanProp(vo, project);
vo.setDetailList(detailList);
return vo;
}
}

View File

@ -0,0 +1,31 @@
package tech.unissense.pms.business.project.vo;
import lombok.Data;
import tech.unissense.pms.business.work.logger.domain.WorkLogger;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author : ch
* @version : 1.0
* @ClassName : ProjectExecutionVo
* @Description : TODO()
* @DATE : Created in 11:20 2024/10/10
* <pre> Copyright: Copyright(c)2024 </pre>
* <pre> Company : </pre>
* Modification History:
* Date Author Version Discription
* --------------------------------------------------------------------------
* 2024/10/10 ch 1.0 Why & What is modified: <> *
*/
@Data
public class ProjectWorkInfoVo {
private Integer projectId;
private String projectName;
private Integer budgetDate;
private Date startDate;
private Date endDate;
private List<List<WorkLogger>> detailList;
}

View File

@ -33,6 +33,7 @@ public class WorkLogger extends BaseEntity {
* id
*/
private Integer userId;
private String userName;
/**
*
*/

View File

@ -80,5 +80,7 @@ public interface WorkLoggerMapper {
int deleteById(Integer id);
List<WorkLogger> calendar(WorkLogger workLogger);
List<WorkLogger> listUser(WorkLogger workLogger);
}

View File

@ -62,4 +62,6 @@ public interface IWorkLoggerService {
List<StaticsHourVo> projectStatics(List<Project> projects, String workHour);
List<StaticsHourVo> personStatics(Integer projectId);
List<WorkLogger> listUser(WorkLogger workLogger);
}

View File

@ -15,6 +15,7 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@ -167,6 +168,11 @@ public class WorkLoggerServiceImpl implements IWorkLoggerService {
return generateStaticsHourVoList(personWorkHourMap);
}
@Override
public List<WorkLogger> listUser(WorkLogger workLogger) {
return workLoggerMapper.listUser(workLogger);
}
// 泛型方法,用于生成统计工时的列表,适用于项目统计
private <T> List<StaticsHourVo> generateStaticsHourVoList(List<T> items, Map<Integer, BigDecimal> workDayMap,
Function<T, Integer> idExtractor, Function<T, String> nameExtractor) {

View File

@ -7,6 +7,7 @@
<result property="loggerDate" column="logger_date" jdbcType="TIMESTAMP"/>
<result property="projectId" column="project_id" jdbcType="INTEGER"/>
<result property="userId" column="user_id" jdbcType="INTEGER"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
<result property="workTime" column="work_time" jdbcType="INTEGER"/>
<result property="workContent" column="work_content" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="VARCHAR"/>
@ -49,61 +50,61 @@
<!--查询指定行数据-->
<select id="list" resultMap="WorkLoggerMap">
select
logger_id, logger_date, project_id, user_id, work_time, work_content, state, create_by, update_by, update_time,
create_time
from pms_work_logger
t1.logger_id, t1.logger_date, t1.project_id, t1.user_id, t1.work_time, t1.work_content, t1.state, t1.create_by, t1.update_by, t1.update_time,
t1.create_time,t2.nick_name user_name
from pms_work_logger t1 left join sys_user t2 on t1.user_id=t2.user_id
<where>
<if test="loggerId != null">
and logger_id = #{loggerId}
and t1.logger_id = #{loggerId}
</if>
<if test="loggerDate != null">
and logger_date = #{loggerDate}
and t1.logger_date = #{loggerDate}
</if>
<if test="startDate != null or endDate!=null">
<choose>
<when test="startDate != null ">
and logger_date <![CDATA[>=]]> #{startDate}
and t1.logger_date <![CDATA[>=]]> #{startDate}
</when>
<when test="endDate != null">
and logger_date <![CDATA[<=]]> #{endDate}
and t1.logger_date <![CDATA[<=]]> #{endDate}
</when>
<otherwise>
and logger_date between #{startDate} and #{endDate}
and t1.logger_date between #{startDate} and #{endDate}
</otherwise>
</choose>
</if>
<if test="projectId != null">
and project_id = #{projectId}
and t1.project_id = #{projectId}
</if>
<if test="projectIdList != null and projectIdList.size>0">
and project_id in
and t1.project_id in
<foreach collection="projectIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userId != null">
and user_id = #{userId}
and t1.user_id = #{userId}
</if>
<if test="workTime != null">
and work_time = #{workTime}
and t1.work_time = #{workTime}
</if>
<if test="workContent != null and workContent != ''">
and work_content = #{workContent}
and t1.work_content = #{workContent}
</if>
<if test="state != null and state != ''">
and state = #{state}
and t1.state = #{state}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
and t1.create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
and t1.update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
and t1.update_time = #{updateTime}
</if>
<if test="createTime != null">
and create_time = #{createTime}
and t1.create_time = #{createTime}
</if>
</where>
</select>
@ -193,6 +194,66 @@
and report_date between #{startDate} and #{endDate}
and user_id=#{userId}
</select>
<select id="listUser" resultMap="WorkLoggerMap">
select
t1.logger_date, t1.user_id, t1.work_time,
t1.create_time,t2.nick_name user_name
from pms_work_logger t1 left join sys_user t2 on t1.user_id=t2.user_id
<where>
<if test="loggerId != null">
and t1.logger_id = #{loggerId}
</if>
<if test="loggerDate != null">
and t1.logger_date = #{loggerDate}
</if>
<if test="startDate != null or endDate!=null">
<choose>
<when test="startDate != null ">
and t1.logger_date <![CDATA[>=]]> #{startDate}
</when>
<when test="endDate != null">
and t1.logger_date <![CDATA[<=]]> #{endDate}
</when>
<otherwise>
and t1.logger_date between #{startDate} and #{endDate}
</otherwise>
</choose>
</if>
<if test="projectId != null">
and t1.project_id = #{projectId}
</if>
<if test="projectIdList != null and projectIdList.size>0">
and t1.project_id in
<foreach collection="projectIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userId != null">
and t1.user_id = #{userId}
</if>
<if test="workTime != null">
and t1.work_time = #{workTime}
</if>
<if test="workContent != null and workContent != ''">
and t1.work_content = #{workContent}
</if>
<if test="state != null and state != ''">
and t1.state = #{state}
</if>
<if test="createBy != null and createBy != ''">
and t1.create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
and t1.update_by = #{updateBy}
</if>
<if test="updateTime != null">
and t1.update_time = #{updateTime}
</if>
<if test="createTime != null">
and t1.create_time = #{createTime}
</if>
</where>
</select>
<!--通过主键修改数据-->
<update id="update">
update pms_work_logger