@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.ruoyi.oa.domain.* ;
import com.ruoyi.oa.domain.bo.BatchBo ;
import com.ruoyi.oa.domain.bo.BatchDelayBo ;
import com.ruoyi.oa.domain.dto.NodeDTO ;
import com.ruoyi.oa.domain.dto.PersonalReportDTO ;
import com.ruoyi.oa.domain.vo.OaExpressVo ;
@@ -71,15 +72,15 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
private final OaProjectScheduleStepMapper projectScheduleStepMapper ;
private final ISysOaTaskService sysOaTaskService ;
private final OaProjectReportMapper projectReportMapper ;
private final SysOaTaskMapper taskMapper ;
private final OaUserActiveMapper userActiveMapper ;
private final OaExpressQuestionMapper expressQuestionMapper ;
private final OaRequirementsMapper requirementsMapper ;
private final IOaExpressService oaExpressService ;
@@ -606,49 +607,49 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
return count ! = null ? count . intValue ( ) : 0 ;
}
/**
* 统计报工信息
*/
private PersonalReportDTO . WorkReportStats getWorkReportStats ( Long userId , Date startDate , Date endDate ) {
PersonalReportDTO . WorkReportStats stats = new PersonalReportDTO . WorkReportStats ( ) ;
LambdaQueryWrapper < OaProjectReport > wrapper = Wrappers . < OaProjectReport > lambdaQuery ( )
. eq ( OaProjectReport : : getDelFlag , 0 )
. eq ( OaProjectReport : : getUserId , userId ) ;
// 添加时间范围条件
if ( startDate ! = null & & endDate ! = null ) {
wrapper . between ( OaProjectReport : : getCreateTime , startDate , endDate ) ;
}
List < OaProjectReport > reports = projectReportMapper . selectList ( wrapper ) ;
// 计算报工天数(这里简化处理,实际可能需要按日期去重)
stats . setTotalWorkDays ( BigDecimal . valueOf ( reports . size ( ) ) ) ;
stats . setValidWorkDays ( BigDecimal . valueOf ( reports . size ( ) ) ) ;
// 统计涉及的项目数量
Set < Long > projectIds = reports . stream ( )
. map ( OaProjectReport : : getProjectId )
. filter ( Objects : : nonNull )
. collect ( Collectors . toSet ( ) ) ;
stats . setReportProjectCount ( projectIds . size ( ) ) ;
return stats ;
}
/**
* 统计出差信息
*/
private PersonalReportDTO . BusinessTripStats getBusinessTripStats ( Long userId , Date startDate , Date endDate ) {
PersonalReportDTO . BusinessTripStats stats = new PersonalReportDTO . BusinessTripStats ( ) ;
LambdaQueryWrapper < OaProjectReport > wrapper = Wrappers . < OaProjectReport > lambdaQuery ( )
. eq ( OaProjectReport : : getDelFlag , 0 )
. eq ( OaProjectReport : : getIsTrip , 1 ) // 出差标记
. eq ( OaProjectReport : : getUserId , userId ) ;
// 添加时间范围条件
if ( startDate ! = null & & endDate ! = null ) {
wrapper . between ( OaProjectReport : : getCreateTime , startDate , endDate ) ;
@@ -673,7 +674,7 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
// 3. 国内出差天数 = 总出差天数 - 国外出差天数
stats . setDomesticTripDays ( BigDecimal . valueOf ( totalTripCount - foreignTripCount ) ) ;
// 统计出差项目数量
Set < Long > tripProjectIds = projectReportMapper . selectObjs ( wrapper
. select ( OaProjectReport : : getProjectId ) ) // 只查询project_id字段
@@ -682,10 +683,10 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
. map ( obj - > ( Long ) obj )
. collect ( Collectors . toSet ( ) ) ;
stats . setTripProjectCount ( tripProjectIds . size ( ) ) ;
return stats ;
}
/**
* 统计项目信息
*/
@@ -765,45 +766,45 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
stats . setProjectList ( projectList ) ;
return stats ;
}
/**
* 统计任务信息
*/
private PersonalReportDTO . TaskStats getTaskStats ( Long userId , Date startDate , Date endDate , List < Long > projectIds ) {
PersonalReportDTO . TaskStats stats = new PersonalReportDTO . TaskStats ( ) ;
// 查询发放的任务(创建的任务)
LambdaQueryWrapper < SysOaTask > assignedWrapper = Wrappers . < SysOaTask > lambdaQuery ( )
. eq ( SysOaTask : : getCreateUserId , userId ) ;
if ( startDate ! = null & & endDate ! = null ) {
assignedWrapper . between ( SysOaTask : : getBeginTime , startDate , endDate ) ;
}
if ( projectIds ! = null & & ! projectIds . isEmpty ( ) ) {
assignedWrapper . in ( SysOaTask : : getProjectId , projectIds ) ;
}
List < SysOaTask > assignedTasks = taskMapper . selectList ( assignedWrapper ) ;
// 查询承担的任务(被分配的任务)
LambdaQueryWrapper < SysOaTask > undertakenWrapper = Wrappers . < SysOaTask > lambdaQuery ( )
. eq ( SysOaTask : : getWorkerId , userId ) ;
if ( startDate ! = null & & endDate ! = null ) {
undertakenWrapper . between ( SysOaTask : : getBeginTime , startDate , endDate ) ;
}
if ( projectIds ! = null & & ! projectIds . isEmpty ( ) ) {
undertakenWrapper . in ( SysOaTask : : getProjectId , projectIds ) ;
}
List < SysOaTask > undertakenTasks = taskMapper . selectList ( undertakenWrapper ) ;
// 统计数量
stats . setAssignedTasks ( assignedTasks . size ( ) ) ;
stats . setUndertakenTasks ( undertakenTasks . size ( ) ) ;
// 统计已完成任务数量(状态为完成)
long completedAssigned = assignedTasks . stream ( ) . filter ( task - > Long . valueOf ( 2 ) . equals ( task . getState ( ) ) ) . count ( ) ;
long completedUndertaken = undertakenTasks . stream ( ) . filter ( task - > Long . valueOf ( 2 ) . equals ( task . getState ( ) ) ) . count ( ) ;
@@ -817,27 +818,27 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
long unfinishedAssigned = assignedTasks . stream ( ) . filter ( task - > Long . valueOf ( 0 ) . equals ( task . getState ( ) ) ) . count ( ) ;
long unfinishedUndertaken = undertakenTasks . stream ( ) . filter ( task - > Long . valueOf ( 0 ) . equals ( task . getState ( ) ) ) . count ( ) ;
stats . setUnfinishedTasks ( ( int ) ( unfinishedAssigned + unfinishedUndertaken ) ) ;
// 统计延期任务数量
long delayedAssigned = assignedTasks . stream ( ) . filter ( task - > Long . valueOf ( 15 ) . equals ( task . getState ( ) ) ) . count ( ) ;
long delayedUndertaken = undertakenTasks . stream ( ) . filter ( task - > Long . valueOf ( 15 ) . equals ( task . getState ( ) ) ) . count ( ) ;
stats . setDelayedTasks ( ( int ) ( delayedAssigned + delayedUndertaken ) ) ;
// 构建任务清单
List < PersonalReportDTO . TaskSummary > assignedTaskList = assignedTasks . stream ( )
. map ( this : : buildTaskSummary )
. collect ( Collectors . toList ( ) ) ;
List < PersonalReportDTO . TaskSummary > undertakenTaskList = undertakenTasks . stream ( )
. map ( this : : buildTaskSummary )
. collect ( Collectors . toList ( ) ) ;
stats . setAssignedTaskList ( assignedTaskList ) ;
stats . setUndertakenTaskList ( undertakenTaskList ) ;
return stats ;
}
/**
* 构建任务摘要
*/
@@ -848,7 +849,7 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
summary . setState ( task . getState ( ) ) ;
summary . setIsDelayed ( task . getPostponements ( ) ! = null & & task . getPostponements ( ) > 0 ) ;
summary . setPostponements ( task . getPostponements ( ) ) ;
// 获取项目名称
if ( task . getProjectId ( ) ! = null ) {
SysOaProject project = projectMapper . selectById ( task . getProjectId ( ) ) ;
@@ -856,17 +857,17 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
summary . setProjectName ( project . getProjectName ( ) ) ;
}
}
return summary ;
}
/**
* 统计工程异常信息( 基于oa_express_question表)
*/
private PersonalReportDTO . EngineeringExceptionStats getExceptionStats ( String nickName , Date startDate , Date endDate ) {
PersonalReportDTO . EngineeringExceptionStats stats = new PersonalReportDTO . EngineeringExceptionStats ( ) ;
// 查询快递问题表,通过汇报人匹配
LambdaQueryWrapper < OaExpressQuestion > wrapper = Wrappers . < OaExpressQuestion > lambdaQuery ( )
. eq ( OaExpressQuestion : : getReportBy , nickName )
@@ -876,18 +877,18 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
if ( startDate ! = null & & endDate ! = null ) {
wrapper . between ( OaExpressQuestion : : getReportTime , startDate , endDate ) ;
}
List < OaExpressQuestion > questions = expressQuestionMapper . selectList ( wrapper ) ;
stats . setTotalExceptions ( questions . size ( ) ) ;
// 统计已解决和未解决的异常
long resolvedCount = questions . stream ( ) . filter ( q - > Long . valueOf ( 1 ) . equals ( q . getStatus ( ) ) ) . count ( ) ;
long unresolvedCount = questions . stream ( ) . filter ( q - > Long . valueOf ( 0 ) . equals ( q . getStatus ( ) ) ) . count ( ) ;
stats . setResolvedExceptions ( ( int ) resolvedCount ) ;
stats . setDelayedExceptions ( ( int ) unresolvedCount ) ; // 未解决的视为延期异常
// 构建异常清单
List < PersonalReportDTO . ExceptionSummary > exceptionList = questions . stream ( )
. map ( question - > {
@@ -896,49 +897,49 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
summary . setDescription ( question . getDescription ( ) ) ;
summary . setStatus ( Long . valueOf ( 1 ) . equals ( question . getStatus ( ) ) ? " 已解决 " : " 未解决 " ) ;
summary . setIsDelayed ( Long . valueOf ( 0 ) . equals ( question . getStatus ( ) ) ) ; // 未解决的视为延期
// 这里可以根据expressId关联获取项目信息
summary . setProjectName ( oaExpressService . queryById ( question . getExpressId ( ) ) . getProjectName ( ) ) ;
return summary ;
} )
. collect ( Collectors . toList ( ) ) ;
stats . setExceptionList ( exceptionList ) ;
return stats ;
}
/**
* 统计关键采购任务信息( 基于oa_requirements表)
*/
private PersonalReportDTO . ProcurementTaskStats getProcurementStats ( Long userId , Date startDate , Date endDate ) {
PersonalReportDTO . ProcurementTaskStats stats = new PersonalReportDTO . ProcurementTaskStats ( ) ;
// 查询需求表, 通过负责人ID匹配
LambdaQueryWrapper < OaRequirements > wrapper = Wrappers . < OaRequirements > lambdaQuery ( )
. eq ( OaRequirements : : getOwnerId , userId )
. eq ( OaRequirements : : getDelFlag , 0 ) ;
// 添加时间范围条件
if ( startDate ! = null & & endDate ! = null ) {
wrapper . between ( OaRequirements : : getCreateTime , startDate , endDate ) ;
}
List < OaRequirements > requirements = requirementsMapper . selectList ( wrapper ) ;
stats . setTotalProcurementTasks ( requirements . size ( ) ) ;
// 统计已完成和延期的需求
long completedCount = requirements . stream ( ) . filter ( req - > Integer . valueOf ( 1 ) . equals ( req . getStatus ( ) ) ) . count ( ) ;
stats . setCompletedProcurementTasks ( ( int ) completedCount ) ;
// 计算延期需求(截止日期已过但未完成的)
long delayedCount = requirements . stream ( )
. filter ( req - > Integer . valueOf ( 0 ) . equals ( req . getStatus ( ) ) ) // 未完成
. filter ( req - > req . getDeadline ( ) ! = null & & req . getDeadline ( ) . before ( new Date ( ) ) ) // 已过期
. count ( ) ;
stats . setDelayedProcurementTasks ( ( int ) delayedCount ) ;
// 构建采购任务清单
List < PersonalReportDTO . ProcurementTaskSummary > procurementList = requirements . stream ( )
. map ( req - > {
@@ -946,12 +947,12 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
summary . setProcurementId ( req . getRequirementId ( ) ) ;
summary . setProcurementContent ( req . getTitle ( ) ) ;
summary . setStatus ( Integer . valueOf ( 1 ) . equals ( req . getStatus ( ) ) ? " 已完成 " : " 进行中 " ) ;
// 判断是否延期
boolean isDelayed = Integer . valueOf ( 0 ) . equals ( req . getStatus ( ) ) & &
boolean isDelayed = Integer . valueOf ( 0 ) . equals ( req . getStatus ( ) ) & &
req . getDeadline ( ) ! = null & & req . getDeadline ( ) . before ( new Date ( ) ) ;
summary . setIsDelayed ( isDelayed ) ;
// 获取项目名称
if ( req . getProjectId ( ) ! = null ) {
SysOaProject project = projectMapper . selectById ( req . getProjectId ( ) ) ;
@@ -961,11 +962,11 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
} else {
summary . setProjectName ( " 无关联项目 " ) ;
}
return summary ;
} )
. collect ( Collectors . toList ( ) ) ;
stats . setProcurementTaskList ( procurementList ) ;
return stats ;
}
@@ -1035,5 +1036,40 @@ public class OaProjectScheduleStepServiceImpl implements IOaProjectScheduleStepS
// return stats;
// }
@Override
@Transactional ( rollbackFor = Exception . class )
public Boolean batchDelay ( BatchDelayBo bo ) {
if ( bo . getTrackIds ( ) = = null | | bo . getTrackIds ( ) . isEmpty ( ) ) {
return false ;
}
// 延期前检查:查询所有待延期的步骤,判断是否已完成
List < OaProjectScheduleStep > steps = baseMapper . selectList (
new LambdaQueryWrapper < OaProjectScheduleStep > ( )
. in ( OaProjectScheduleStep : : getTrackId , bo . getTrackIds ( ) )
) ;
// 检查是否有已完成的步骤( status=2)
String completedTrack = steps . stream ( )
. filter ( step - > step . getStatus ( ) ! = null & & step . getStatus ( ) = = 2 )
. map ( OaProjectScheduleStep : : getSecondLevelNode )
. collect ( Collectors . joining ( " , " ) ) ;
if ( ! completedTrack . isEmpty ( ) ) {
throw new RuntimeException ( " 以下步骤已完成,不允许延期: " + completedTrack ) ;
}
Long delayMinutes ;
if ( " day " . equals ( bo . getDelayUnit ( ) ) ) {
delayMinutes = bo . getDelayValue ( ) * 24L * 60L ;
} else if ( " hour " . equals ( bo . getDelayUnit ( ) ) ) {
delayMinutes = bo . getDelayValue ( ) * 60L ;
} else {
return false ;
}
int updated = baseMapper . batchDelayPlanEnd ( bo . getTrackIds ( ) , delayMinutes ) ;
return updated > 0 ;
}
}